signify-ts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -0
- package/dist/keri/core/cigar.d.ts +8 -0
- package/dist/keri/core/cipher.d.ts +5 -0
- package/dist/keri/core/core.d.ts +68 -0
- package/dist/keri/core/decrypter.d.ts +10 -0
- package/dist/keri/core/diger.d.ts +21 -0
- package/dist/keri/core/encrypter.d.ts +9 -0
- package/dist/keri/core/indexer.d.ts +88 -0
- package/dist/keri/core/keeping.d.ts +1 -0
- package/dist/keri/core/kering.d.ts +5 -0
- package/dist/keri/core/manager.d.ts +151 -0
- package/dist/keri/core/matter.d.ts +47 -0
- package/dist/keri/core/siger.d.ts +22 -0
- package/dist/keri/core/signer.d.ts +34 -0
- package/dist/keri/core/utils.d.ts +16 -0
- package/dist/signify-ts.cjs.development.js +13 -0
- package/dist/signify-ts.cjs.development.js.map +1 -0
- package/dist/signify-ts.cjs.production.min.js +2 -0
- package/dist/signify-ts.cjs.production.min.js.map +1 -0
- package/dist/signify-ts.esm.js +9 -0
- package/dist/signify-ts.esm.js.map +1 -0
- package/package.json +66 -0
- package/src/index.ts +6 -0
- package/src/keri/core/cigar.ts +19 -0
- package/src/keri/core/cipher.ts +25 -0
- package/src/keri/core/core.ts +174 -0
- package/src/keri/core/decrypter.ts +66 -0
- package/src/keri/core/diger.ts +82 -0
- package/src/keri/core/encrypter.ts +60 -0
- package/src/keri/core/indexer.ts +406 -0
- package/src/keri/core/keeping.ts +9 -0
- package/src/keri/core/kering.ts +12 -0
- package/src/keri/core/manager.ts +874 -0
- package/src/keri/core/matter.ts +252 -0
- package/src/keri/core/salter.ts +85 -0
- package/src/keri/core/siger.ts +39 -0
- package/src/keri/core/signer.ts +112 -0
- package/src/keri/core/tsconfig.json +100 -0
- package/src/keri/core/utils.ts +94 -0
- package/src/keri/core/verfer.ts +33 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
|
|
2
|
+
export function pad(n: any, width = 3, z = 0) {
|
|
3
|
+
return (String(z).repeat(width) + String(n)).slice(String(n).length);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description Returns list of depth first recursively extracted values from elements of
|
|
8
|
+
key event dict ked whose flabels are in lables list
|
|
9
|
+
|
|
10
|
+
* @param {*} ked ked is key event dict
|
|
11
|
+
* @param {*} labels labels is list of element labels in ked from which to extract values
|
|
12
|
+
*/
|
|
13
|
+
export function extractValues(ked: any, labels: any) {
|
|
14
|
+
let values = [];
|
|
15
|
+
for (let label of labels) {
|
|
16
|
+
values = extractElementValues(ked[label], values);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return values;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function arrayEquals(ar1: Uint8Array, ar2: Uint8Array) {
|
|
23
|
+
return (
|
|
24
|
+
ar1.length === ar2.length &&
|
|
25
|
+
ar1.every((val, index) => val === ar2[index])
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @description Recusive depth first search that recursively extracts value(s) from element
|
|
31
|
+
and appends to values list
|
|
32
|
+
Assumes that extracted values are str
|
|
33
|
+
|
|
34
|
+
* @param {*} element
|
|
35
|
+
* @param {*} values
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
function extractElementValues(element: any, values: any) {
|
|
39
|
+
let data = [];
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
if((element instanceof Array) && !(typeof(element) == 'string')) {
|
|
44
|
+
for(let k in element)
|
|
45
|
+
extractElementValues(element[k], values);
|
|
46
|
+
} else if (typeof(element) == 'string') {
|
|
47
|
+
values.push(element);
|
|
48
|
+
}
|
|
49
|
+
data = values;
|
|
50
|
+
} catch (error:any) {
|
|
51
|
+
throw new Error(error);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @description Returns True if obj is non-string iterable, False otherwise
|
|
62
|
+
|
|
63
|
+
* @param {*} obj
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
// function nonStringIterable(obj) {
|
|
67
|
+
// obj instanceof (String)
|
|
68
|
+
// return instanceof(obj, (str, bytes)) && instanceof(obj, Iterable))
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
export function range(start: any, stop: any, step: any) {
|
|
74
|
+
if (typeof stop == 'undefined') {
|
|
75
|
+
// one param defined
|
|
76
|
+
stop = start;
|
|
77
|
+
start = 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (typeof step == 'undefined') {
|
|
81
|
+
step = 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let result = [];
|
|
89
|
+
for (let i = start; step > 0 ? i < stop : i > stop; i += step) {
|
|
90
|
+
result.push(i);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
const libsodium = require('libsodium-wrappers-sumo');
|
|
3
|
+
const {Matter} = require('./matter');
|
|
4
|
+
import {MatterArgs, MtrDex} from './matter';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description Verfer :sublclass of Matter,helps to verify signature of serialization
|
|
8
|
+
* using .raw as verifier key and .code as signature cypher suite
|
|
9
|
+
*/
|
|
10
|
+
export class Verfer extends Matter {
|
|
11
|
+
constructor({raw, code, qb64, qb64b, qb2}: MatterArgs) {
|
|
12
|
+
super({raw, code, qb64, qb64b, qb2});
|
|
13
|
+
|
|
14
|
+
if (Array.from([MtrDex.Ed25519N, MtrDex.Ed25519]).includes(this.code)) {
|
|
15
|
+
this._verify = this._ed25519
|
|
16
|
+
} else {
|
|
17
|
+
throw new Error(`Unsupported code = ${this.code} for verifier.`)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
verify(sig: any, ser: any) {
|
|
22
|
+
return this._verify(sig, ser, this.raw)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_ed25519(sig: any, ser: any, key: any) {
|
|
26
|
+
try {
|
|
27
|
+
return libsodium.crypto_sign_verify_detached(sig, ser, key);
|
|
28
|
+
|
|
29
|
+
} catch (error: any) {
|
|
30
|
+
throw new Error(error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|