index.jsView |
---|
7 | 7 | var createHmac = require('hmac') |
8 | 8 | var Blake2s = require('blake2s') |
9 | 9 | |
10 | 10 | var ecc = require('./eccjs') |
| 11 | +var isRef = require('ssb-ref') |
11 | 12 | |
12 | 13 | |
13 | 14 | |
14 | 15 | function clone (obj) { |
23 | 24 | function hash (data, enc) { |
24 | 25 | return new Blake2s().update(data, enc).digest('base64') + '.blake2s' |
25 | 26 | } |
26 | 27 | |
27 | | -function isHash (data) { |
28 | | - return isString(data) && /^[A-Za-z0-9\/+]{43}=\.blake2s$/.test(data) |
29 | | -} |
30 | 28 | |
31 | | -function isId (data) { |
32 | | - return isString(data) && /^[A-Za-z0-9\/+]{43}=\.(?:ed25519|blake2s)$/.test(data) |
33 | | -} |
| 29 | +var isHash = isRef.isHash |
| 30 | +var isFeedId = isRef.isFeedId |
34 | 31 | |
| 32 | +exports.hash = hash |
| 33 | +exports.isHash = isHash |
35 | 34 | |
36 | 35 | function isObject (o) { |
37 | 36 | return 'object' === typeof o |
38 | 37 | } |
40 | 39 | function isFunction (f) { |
41 | 40 | return 'function' === typeof f |
42 | 41 | } |
43 | 42 | |
44 | | -exports.isHash = isHash |
45 | | -exports.hash = hash |
46 | | - |
47 | | -exports.isId = isId |
48 | | -exports.isIdentity = isId |
49 | | - |
50 | 43 | function isString(s) { |
51 | 44 | return 'string' === typeof s |
52 | 45 | } |
53 | 46 | |