signify-ts 0.2.1 → 0.3.0-rc2
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/README.md +104 -34
- package/dist/exports.d.ts +40 -40
- package/dist/exports.js +40 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -8
- package/dist/keri/app/aiding.d.ts +34 -14
- package/{src/keri/app/aiding.ts → dist/keri/app/aiding.js} +104 -235
- package/dist/keri/app/clienting.d.ts +57 -22
- package/{src/keri/app/clienting.ts → dist/keri/app/clienting.js} +145 -234
- package/dist/keri/app/contacting.d.ts +33 -21
- package/{src/keri/app/contacting.ts → dist/keri/app/contacting.js} +25 -62
- package/dist/keri/app/controller.d.ts +49 -6
- package/{src/keri/app/controller.ts → dist/keri/app/controller.js} +79 -185
- package/dist/keri/app/coring.d.ts +30 -8
- package/{src/keri/app/coring.ts → dist/keri/app/coring.js} +62 -51
- package/dist/keri/app/credentialing.d.ts +183 -65
- package/dist/keri/app/credentialing.js +540 -0
- package/dist/keri/app/delegating.d.ts +18 -0
- package/dist/keri/app/delegating.js +24 -0
- package/dist/keri/app/escrowing.d.ts +1 -1
- package/{src/keri/app/escrowing.ts → dist/keri/app/escrowing.js} +2 -8
- package/dist/keri/app/exchanging.d.ts +7 -6
- package/{src/keri/app/exchanging.ts → dist/keri/app/exchanging.js} +33 -110
- package/dist/keri/app/grouping.d.ts +2 -2
- package/{src/keri/app/grouping.ts → dist/keri/app/grouping.js} +6 -25
- package/dist/keri/app/habery.d.ts +2 -2
- package/dist/keri/app/habery.js +117 -0
- package/dist/keri/app/notifying.d.ts +2 -2
- package/{src/keri/app/notifying.ts → dist/keri/app/notifying.js} +7 -17
- package/dist/keri/core/authing.d.ts +2 -2
- package/{src/keri/core/authing.ts → dist/keri/core/authing.js} +26 -42
- package/dist/keri/core/base64.d.ts +2 -0
- package/dist/keri/core/base64.js +16 -0
- package/dist/keri/core/bexter.d.ts +1 -1
- package/{src/keri/core/bexter.ts → dist/keri/core/bexter.js} +18 -32
- package/dist/keri/core/cigar.d.ts +2 -2
- package/dist/keri/core/cigar.js +13 -0
- package/dist/keri/core/cipher.d.ts +1 -1
- package/{src/keri/core/cipher.ts → dist/keri/core/cipher.js} +10 -19
- package/dist/keri/core/core.d.ts +117 -9
- package/dist/keri/core/core.js +385 -0
- package/dist/keri/core/counter.d.ts +2 -2
- package/dist/keri/core/counter.js +221 -0
- package/dist/keri/core/decrypter.d.ts +4 -4
- package/{src/keri/core/decrypter.ts → dist/keri/core/decrypter.js} +23 -40
- package/dist/keri/core/diger.d.ts +3 -3
- package/{src/keri/core/diger.ts → dist/keri/core/diger.js} +18 -33
- package/dist/keri/core/encrypter.d.ts +2 -2
- package/{src/keri/core/encrypter.ts → dist/keri/core/encrypter.js} +18 -38
- package/dist/keri/core/eventing.d.ts +4 -4
- package/{src/keri/core/eventing.ts → dist/keri/core/eventing.js} +134 -321
- package/dist/keri/core/httping.d.ts +11 -4
- package/{src/keri/core/httping.ts → dist/keri/core/httping.js} +36 -101
- package/dist/keri/core/indexer.d.ts +1 -1
- package/dist/keri/core/indexer.js +407 -0
- package/dist/keri/core/keeping.d.ts +98 -46
- package/dist/keri/core/keeping.js +365 -0
- package/{src/keri/core/kering.ts → dist/keri/core/kering.js} +1 -3
- package/dist/keri/core/keyState.d.ts +85 -0
- package/dist/keri/core/keyState.js +1 -0
- package/dist/keri/core/manager.d.ts +147 -12
- package/dist/keri/core/manager.js +880 -0
- package/dist/keri/core/matter.d.ts +1 -1
- package/dist/keri/core/matter.js +460 -0
- package/dist/keri/core/number.d.ts +1 -1
- package/{src/keri/core/number.ts → dist/keri/core/number.js} +21 -30
- package/dist/keri/core/pather.d.ts +2 -2
- package/{src/keri/core/pather.ts → dist/keri/core/pather.js} +12 -27
- package/dist/keri/core/prefixer.d.ts +10 -10
- package/dist/keri/core/prefixer.js +182 -0
- package/dist/keri/core/saider.d.ts +2 -12
- package/dist/keri/core/saider.js +107 -0
- package/dist/keri/core/salter.d.ts +45 -3
- package/dist/keri/core/salter.js +117 -0
- package/dist/keri/core/seqner.d.ts +1 -1
- package/{src/keri/core/seqner.ts → dist/keri/core/seqner.js} +20 -21
- package/dist/keri/core/serder.d.ts +25 -12
- package/dist/keri/core/serder.js +133 -0
- package/dist/keri/core/siger.d.ts +2 -2
- package/{src/keri/core/siger.ts → dist/keri/core/siger.js} +4 -14
- package/dist/keri/core/signer.d.ts +4 -4
- package/dist/keri/core/signer.js +84 -0
- package/{src/keri/core/tholder.ts → dist/keri/core/tholder.js} +69 -94
- package/dist/keri/core/utils.d.ts +1 -1
- package/{src/keri/core/utils.ts → dist/keri/core/utils.js} +30 -60
- package/dist/keri/core/vdring.d.ts +2 -2
- package/dist/keri/core/vdring.js +61 -0
- package/dist/keri/core/verfer.d.ts +2 -6
- package/dist/keri/core/verfer.js +37 -0
- package/dist/keri/end/ending.d.ts +10 -8
- package/dist/keri/end/ending.js +136 -0
- package/{src/ready.ts → dist/ready.js} +1 -2
- package/dist/types/keria-api-schema.d.ts +304 -0
- package/dist/types/keria-api-schema.js +2 -0
- package/package.json +53 -50
- package/dist/buffer-polyfill.d.ts +0 -1
- package/dist/math.d.ts +0 -1
- package/dist/signify-ts.cjs +0 -7842
- package/dist/signify-ts.cjs.development.js +0 -9501
- package/dist/signify-ts.cjs.development.js.map +0 -1
- package/dist/signify-ts.cjs.map +0 -7
- package/dist/signify-ts.cjs.production.min.js +0 -2
- package/dist/signify-ts.cjs.production.min.js.map +0 -1
- package/dist/signify-ts.esm.js +0 -9345
- package/dist/signify-ts.esm.js.map +0 -1
- package/dist/signify-ts.mjs +0 -7818
- package/dist/signify-ts.mjs.map +0 -7
- package/src/buffer-polyfill.ts +0 -5
- package/src/exports.ts +0 -44
- package/src/index.ts +0 -4
- package/src/keri/app/credentialing.ts +0 -841
- package/src/keri/app/habery.ts +0 -185
- package/src/keri/core/cigar.ts +0 -18
- package/src/keri/core/core.ts +0 -326
- package/src/keri/core/counter.ts +0 -273
- package/src/keri/core/indexer.ts +0 -509
- package/src/keri/core/keeping.ts +0 -684
- package/src/keri/core/manager.ts +0 -1183
- package/src/keri/core/matter.ts +0 -521
- package/src/keri/core/prefixer.ts +0 -233
- package/src/keri/core/saider.ts +0 -186
- package/src/keri/core/salter.ts +0 -120
- package/src/keri/core/serder.ts +0 -163
- package/src/keri/core/signer.ts +0 -133
- package/src/keri/core/vdring.ts +0 -94
- package/src/keri/core/verfer.ts +0 -47
- package/src/keri/end/ending.ts +0 -170
- package/src/math.ts +0 -3
|
@@ -1,82 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Serder } from '../core/serder';
|
|
8
|
-
import { parseRangeHeaders } from '../core/httping';
|
|
9
|
-
import { KeyManager } from '../core/keeping';
|
|
10
|
-
|
|
11
|
-
/** Arguments required to create an identfier */
|
|
12
|
-
export interface CreateIdentiferArgs {
|
|
13
|
-
transferable?: boolean;
|
|
14
|
-
isith?: string | number | string[];
|
|
15
|
-
nsith?: string | number | string[];
|
|
16
|
-
wits?: string[];
|
|
17
|
-
toad?: number;
|
|
18
|
-
proxy?: string;
|
|
19
|
-
delpre?: string;
|
|
20
|
-
dcode?: string;
|
|
21
|
-
data?: any;
|
|
22
|
-
algo?: Algos;
|
|
23
|
-
pre?: string;
|
|
24
|
-
states?: any[];
|
|
25
|
-
rstates?: any[];
|
|
26
|
-
prxs?: any[];
|
|
27
|
-
nxts?: any[];
|
|
28
|
-
mhab?: any;
|
|
29
|
-
keys?: any[];
|
|
30
|
-
ndigs?: any[];
|
|
31
|
-
bran?: string;
|
|
32
|
-
count?: number;
|
|
33
|
-
ncount?: number;
|
|
34
|
-
tier?: Tier;
|
|
35
|
-
extern_type?: string;
|
|
36
|
-
extern?: any;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Arguments required to rotate an identfier */
|
|
40
|
-
export interface RotateIdentifierArgs {
|
|
41
|
-
transferable?: boolean;
|
|
42
|
-
nsith?: string | number | string[];
|
|
43
|
-
toad?: number;
|
|
44
|
-
cuts?: string[];
|
|
45
|
-
adds?: string[];
|
|
46
|
-
data?: Array<object>;
|
|
47
|
-
ncode?: string;
|
|
48
|
-
ncount?: number;
|
|
49
|
-
ncodes?: string[];
|
|
50
|
-
states?: any[];
|
|
51
|
-
rstates?: any[];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Reducing the SignifyClient dependencies used by Identifier class
|
|
56
|
-
*/
|
|
57
|
-
export interface IdentifierDeps {
|
|
58
|
-
fetch(
|
|
59
|
-
pathname: string,
|
|
60
|
-
method: string,
|
|
61
|
-
body: unknown,
|
|
62
|
-
headers?: Headers
|
|
63
|
-
): Promise<Response>;
|
|
64
|
-
pidx: number;
|
|
65
|
-
manager: KeyManager | null;
|
|
66
|
-
}
|
|
67
|
-
|
|
1
|
+
import { Algos } from "../core/manager.js";
|
|
2
|
+
import { incept, interact, reply, rotate } from "../core/eventing.js";
|
|
3
|
+
import { b, Ilks, Serials, Vrsn_1_0 } from "../core/core.js";
|
|
4
|
+
import { Tholder } from "../core/tholder.js";
|
|
5
|
+
import { MtrDex } from "../core/matter.js";
|
|
6
|
+
import { parseRangeHeaders } from "../core/httping.js";
|
|
68
7
|
/** Identifier */
|
|
69
8
|
export class Identifier {
|
|
70
|
-
public client: IdentifierDeps;
|
|
71
|
-
|
|
72
9
|
/**
|
|
73
10
|
* Identifier
|
|
74
11
|
* @param {IdentifierDeps} client
|
|
75
12
|
*/
|
|
76
|
-
constructor(client
|
|
13
|
+
constructor(client) {
|
|
77
14
|
this.client = client;
|
|
78
15
|
}
|
|
79
|
-
|
|
80
16
|
/**
|
|
81
17
|
* List managed identifiers
|
|
82
18
|
* @async
|
|
@@ -84,19 +20,16 @@ export class Identifier {
|
|
|
84
20
|
* @param {number} [end=24] End index of list of notifications, defaults to 24
|
|
85
21
|
* @returns {Promise<any>} A promise to the list of managed identifiers
|
|
86
22
|
*/
|
|
87
|
-
async list(start
|
|
23
|
+
async list(start = 0, end = 24) {
|
|
88
24
|
const extraHeaders = new Headers();
|
|
89
25
|
extraHeaders.append('Range', `aids=${start}-${end}`);
|
|
90
|
-
|
|
91
26
|
const path = `/identifiers`;
|
|
92
27
|
const data = null;
|
|
93
28
|
const method = 'GET';
|
|
94
29
|
const res = await this.client.fetch(path, method, data, extraHeaders);
|
|
95
|
-
|
|
96
30
|
const cr = res.headers.get('content-range');
|
|
97
31
|
const range = parseRangeHeaders(cr, 'aids');
|
|
98
32
|
const aids = await res.json();
|
|
99
|
-
|
|
100
33
|
return {
|
|
101
34
|
start: range.start,
|
|
102
35
|
end: range.end,
|
|
@@ -104,21 +37,32 @@ export class Identifier {
|
|
|
104
37
|
aids: aids,
|
|
105
38
|
};
|
|
106
39
|
}
|
|
107
|
-
|
|
108
40
|
/**
|
|
109
41
|
* Get information for a managed identifier
|
|
110
42
|
* @async
|
|
111
|
-
* @param {string} name
|
|
112
|
-
* @returns {Promise<
|
|
43
|
+
* @param {string} name Prefix or alias of the identifier
|
|
44
|
+
* @returns {Promise<HabState>} A promise to the identifier information
|
|
113
45
|
*/
|
|
114
|
-
async get(name
|
|
115
|
-
const path = `/identifiers/${name}`;
|
|
46
|
+
async get(name) {
|
|
47
|
+
const path = `/identifiers/${encodeURIComponent(name)}`;
|
|
116
48
|
const data = null;
|
|
117
49
|
const method = 'GET';
|
|
118
50
|
const res = await this.client.fetch(path, method, data);
|
|
119
51
|
return await res.json();
|
|
120
52
|
}
|
|
121
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Update managed identifier
|
|
55
|
+
* @async
|
|
56
|
+
* @param {string} name Prefix or alias of the identifier
|
|
57
|
+
* @param {IdentifierInfo} info Information to update for the given identifier
|
|
58
|
+
* @returns {Promise<HabState>} A promise to the identifier information after updating
|
|
59
|
+
*/
|
|
60
|
+
async update(name, info) {
|
|
61
|
+
const path = `/identifiers/${name}`;
|
|
62
|
+
const method = 'PUT';
|
|
63
|
+
const res = await this.client.fetch(path, method, info);
|
|
64
|
+
return await res.json();
|
|
65
|
+
}
|
|
122
66
|
/**
|
|
123
67
|
* Create a managed identifier
|
|
124
68
|
* @async
|
|
@@ -126,18 +70,15 @@ export class Identifier {
|
|
|
126
70
|
* @param {CreateIdentiferArgs} [kargs] Optional parameters to create the identifier
|
|
127
71
|
* @returns {EventResult} The inception result
|
|
128
72
|
*/
|
|
129
|
-
async create(
|
|
130
|
-
|
|
131
|
-
kargs: CreateIdentiferArgs = {}
|
|
132
|
-
): Promise<EventResult> {
|
|
73
|
+
async create(name, kargs = {}) {
|
|
74
|
+
var _a, _b, _c, _d, _e, _f;
|
|
133
75
|
const algo = kargs.algo == undefined ? Algos.salty : kargs.algo;
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const dcode = kargs.dcode ?? MtrDex.Blake3_256;
|
|
76
|
+
const transferable = (_a = kargs.transferable) !== null && _a !== void 0 ? _a : true;
|
|
77
|
+
const isith = (_b = kargs.isith) !== null && _b !== void 0 ? _b : '1';
|
|
78
|
+
let nsith = (_c = kargs.nsith) !== null && _c !== void 0 ? _c : '1';
|
|
79
|
+
let wits = (_d = kargs.wits) !== null && _d !== void 0 ? _d : [];
|
|
80
|
+
const toad = (_e = kargs.toad) !== null && _e !== void 0 ? _e : 0;
|
|
81
|
+
let dcode = (_f = kargs.dcode) !== null && _f !== void 0 ? _f : MtrDex.Blake3_256;
|
|
141
82
|
const proxy = kargs.proxy;
|
|
142
83
|
const delpre = kargs.delpre;
|
|
143
84
|
const data = kargs.data != undefined ? [kargs.data] : [];
|
|
@@ -151,11 +92,15 @@ export class Identifier {
|
|
|
151
92
|
const _ndigs = kargs.ndigs;
|
|
152
93
|
const bran = kargs.bran;
|
|
153
94
|
const count = kargs.count;
|
|
154
|
-
|
|
95
|
+
let ncount = kargs.ncount;
|
|
155
96
|
const tier = kargs.tier;
|
|
156
97
|
const extern_type = kargs.extern_type;
|
|
157
98
|
const extern = kargs.extern;
|
|
158
|
-
|
|
99
|
+
if (!transferable) {
|
|
100
|
+
ncount = 0;
|
|
101
|
+
nsith = 0;
|
|
102
|
+
dcode = MtrDex.Ed25519N;
|
|
103
|
+
}
|
|
159
104
|
const xargs = {
|
|
160
105
|
transferable: transferable,
|
|
161
106
|
isith: isith,
|
|
@@ -182,14 +127,13 @@ export class Identifier {
|
|
|
182
127
|
extern_type: extern_type,
|
|
183
128
|
extern: extern,
|
|
184
129
|
};
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
const [keys, ndigs] = await keeper!.incept(transferable);
|
|
130
|
+
const keeper = this.client.manager.new(algo, this.client.pidx, xargs);
|
|
131
|
+
const [keys, ndigs] = await keeper.incept(transferable);
|
|
188
132
|
wits = wits !== undefined ? wits : [];
|
|
189
|
-
let serder
|
|
133
|
+
let serder = undefined;
|
|
190
134
|
if (delpre == undefined) {
|
|
191
135
|
serder = incept({
|
|
192
|
-
keys: keys
|
|
136
|
+
keys: keys,
|
|
193
137
|
isith: isith,
|
|
194
138
|
ndigs: ndigs,
|
|
195
139
|
nsith: nsith,
|
|
@@ -197,14 +141,15 @@ export class Identifier {
|
|
|
197
141
|
wits: wits,
|
|
198
142
|
cnfg: [],
|
|
199
143
|
data: data,
|
|
200
|
-
version:
|
|
144
|
+
version: Vrsn_1_0,
|
|
201
145
|
kind: Serials.JSON,
|
|
202
146
|
code: dcode,
|
|
203
147
|
intive: false,
|
|
204
148
|
});
|
|
205
|
-
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
206
151
|
serder = incept({
|
|
207
|
-
keys: keys
|
|
152
|
+
keys: keys,
|
|
208
153
|
isith: isith,
|
|
209
154
|
ndigs: ndigs,
|
|
210
155
|
nsith: nsith,
|
|
@@ -212,55 +157,50 @@ export class Identifier {
|
|
|
212
157
|
wits: wits,
|
|
213
158
|
cnfg: [],
|
|
214
159
|
data: data,
|
|
215
|
-
version:
|
|
160
|
+
version: Vrsn_1_0,
|
|
216
161
|
kind: Serials.JSON,
|
|
217
162
|
code: dcode,
|
|
218
163
|
intive: false,
|
|
219
164
|
delpre: delpre,
|
|
220
165
|
});
|
|
221
166
|
}
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
const jsondata: any = {
|
|
167
|
+
const sigs = await keeper.sign(b(serder.raw));
|
|
168
|
+
const jsondata = {
|
|
225
169
|
name: name,
|
|
226
|
-
icp: serder.
|
|
170
|
+
icp: serder.sad,
|
|
227
171
|
sigs: sigs,
|
|
228
172
|
proxy: proxy,
|
|
229
|
-
smids:
|
|
230
|
-
states
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
? rstates.map((state) => state.i)
|
|
236
|
-
: undefined,
|
|
173
|
+
smids: states != undefined
|
|
174
|
+
? states.map((state) => state.i)
|
|
175
|
+
: undefined,
|
|
176
|
+
rmids: rstates != undefined
|
|
177
|
+
? rstates.map((state) => state.i)
|
|
178
|
+
: undefined,
|
|
237
179
|
};
|
|
238
180
|
jsondata[algo] = keeper.params();
|
|
239
|
-
|
|
240
181
|
this.client.pidx = this.client.pidx + 1;
|
|
241
|
-
const res = this.client.fetch('/identifiers', 'POST', jsondata);
|
|
182
|
+
const res = await this.client.fetch('/identifiers', 'POST', jsondata);
|
|
242
183
|
return new EventResult(serder, sigs, res);
|
|
243
184
|
}
|
|
244
|
-
|
|
245
185
|
/**
|
|
246
186
|
* Generate an interaction event in a managed identifier
|
|
247
187
|
* @async
|
|
248
|
-
* @param {string} name
|
|
188
|
+
* @param {string} name Prefix or alias of the identifier
|
|
249
189
|
* @param {any} [data] Option data to be anchored in the interaction event
|
|
250
190
|
* @returns {Promise<EventResult>} A promise to the interaction event result
|
|
251
191
|
*/
|
|
252
|
-
async interact(name
|
|
192
|
+
async interact(name, data) {
|
|
193
|
+
const { serder, sigs, jsondata } = await this.createInteract(name, data);
|
|
194
|
+
const res = await this.client.fetch('/identifiers/' + name + '/events', 'POST', jsondata);
|
|
195
|
+
return new EventResult(serder, sigs, res);
|
|
196
|
+
}
|
|
197
|
+
async createInteract(name, data) {
|
|
253
198
|
const hab = await this.get(name);
|
|
254
|
-
const pre
|
|
255
|
-
|
|
199
|
+
const pre = hab.prefix;
|
|
256
200
|
const state = hab.state;
|
|
257
|
-
const sn =
|
|
201
|
+
const sn = parseInt(state.s, 16);
|
|
258
202
|
const dig = state.d;
|
|
259
|
-
|
|
260
|
-
data = Array.isArray(data) ? data : [data];
|
|
261
|
-
|
|
262
203
|
data = Array.isArray(data) ? data : [data];
|
|
263
|
-
|
|
264
204
|
const serder = interact({
|
|
265
205
|
pre: pre,
|
|
266
206
|
sn: sn + 1,
|
|
@@ -269,81 +209,56 @@ export class Identifier {
|
|
|
269
209
|
version: undefined,
|
|
270
210
|
kind: undefined,
|
|
271
211
|
});
|
|
272
|
-
const keeper = this.client
|
|
212
|
+
const keeper = this.client.manager.get(hab);
|
|
273
213
|
const sigs = await keeper.sign(b(serder.raw));
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
ixn: serder.ked,
|
|
214
|
+
const jsondata = {
|
|
215
|
+
ixn: serder.sad,
|
|
277
216
|
sigs: sigs,
|
|
278
217
|
};
|
|
279
218
|
jsondata[keeper.algo] = keeper.params();
|
|
280
|
-
|
|
281
|
-
const res = await this.client.fetch(
|
|
282
|
-
'/identifiers/' + name + '?type=ixn',
|
|
283
|
-
'PUT',
|
|
284
|
-
jsondata
|
|
285
|
-
);
|
|
286
|
-
return new EventResult(serder, sigs, res);
|
|
219
|
+
return { serder, sigs, jsondata };
|
|
287
220
|
}
|
|
288
|
-
|
|
289
221
|
/**
|
|
290
222
|
* Generate a rotation event in a managed identifier
|
|
291
223
|
* @param {string} name Name or alias of the identifier
|
|
292
224
|
* @param {RotateIdentifierArgs} [kargs] Optional parameters requiered to generate the rotation event
|
|
293
225
|
* @returns {Promise<EventResult>} A promise to the rotation event result
|
|
294
226
|
*/
|
|
295
|
-
async rotate(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
const ncode = kargs.ncode ?? MtrDex.Ed25519_Seed;
|
|
301
|
-
const ncount = kargs.ncount ?? 1;
|
|
302
|
-
|
|
227
|
+
async rotate(name, kargs = {}) {
|
|
228
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
229
|
+
const transferable = (_a = kargs.transferable) !== null && _a !== void 0 ? _a : true;
|
|
230
|
+
const ncode = (_b = kargs.ncode) !== null && _b !== void 0 ? _b : MtrDex.Ed25519_Seed;
|
|
231
|
+
const ncount = (_c = kargs.ncount) !== null && _c !== void 0 ? _c : 1;
|
|
303
232
|
const hab = await this.get(name);
|
|
304
233
|
const pre = hab.prefix;
|
|
305
234
|
const delegated = hab.state.di !== '';
|
|
306
|
-
|
|
307
235
|
const state = hab.state;
|
|
308
236
|
const count = state.k.length;
|
|
309
237
|
const dig = state.d;
|
|
310
|
-
const ridx =
|
|
238
|
+
const ridx = parseInt(state.s, 16) + 1;
|
|
311
239
|
const wits = state.b;
|
|
312
240
|
let isith = state.nt;
|
|
313
|
-
|
|
314
|
-
let nsith = kargs.nsith ?? isith;
|
|
315
|
-
|
|
241
|
+
let nsith = (_d = kargs.nsith) !== null && _d !== void 0 ? _d : isith;
|
|
316
242
|
// if isith is None: # compute default from newly rotated verfers above
|
|
317
243
|
if (isith == undefined)
|
|
318
244
|
isith = `${Math.max(1, Math.ceil(count / 2)).toString(16)}`;
|
|
319
|
-
|
|
320
245
|
// if nsith is None: # compute default from newly rotated digers above
|
|
321
246
|
if (nsith == undefined)
|
|
322
247
|
nsith = `${Math.max(1, Math.ceil(ncount / 2)).toString(16)}`;
|
|
323
|
-
|
|
324
248
|
const cst = new Tholder({ sith: isith }).sith; // current signing threshold
|
|
325
249
|
const nst = new Tholder({ sith: nsith }).sith; // next signing threshold
|
|
326
|
-
|
|
327
250
|
// Regenerate next keys to sign rotation event
|
|
328
|
-
const keeper = this.client.manager
|
|
251
|
+
const keeper = this.client.manager.get(hab);
|
|
329
252
|
// Create new keys for next digests
|
|
330
|
-
const ncodes = kargs.ncodes
|
|
331
|
-
|
|
253
|
+
const ncodes = (_e = kargs.ncodes) !== null && _e !== void 0 ? _e : new Array(ncount).fill(ncode);
|
|
332
254
|
const states = kargs.states == undefined ? [] : kargs.states;
|
|
333
255
|
const rstates = kargs.rstates == undefined ? [] : kargs.rstates;
|
|
334
|
-
const [keys, ndigs] = await keeper
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
states,
|
|
338
|
-
rstates
|
|
339
|
-
);
|
|
340
|
-
|
|
341
|
-
const cuts = kargs.cuts ?? [];
|
|
342
|
-
const adds = kargs.adds ?? [];
|
|
256
|
+
const [keys, ndigs] = await keeper.rotate(ncodes, transferable, states, rstates);
|
|
257
|
+
const cuts = (_f = kargs.cuts) !== null && _f !== void 0 ? _f : [];
|
|
258
|
+
const adds = (_g = kargs.adds) !== null && _g !== void 0 ? _g : [];
|
|
343
259
|
const data = kargs.data != undefined ? [kargs.data] : [];
|
|
344
260
|
const toad = kargs.toad;
|
|
345
261
|
const ilk = delegated ? Ilks.drt : Ilks.rot;
|
|
346
|
-
|
|
347
262
|
const serder = rotate({
|
|
348
263
|
pre: pre,
|
|
349
264
|
ilk: ilk,
|
|
@@ -359,31 +274,21 @@ export class Identifier {
|
|
|
359
274
|
adds: adds,
|
|
360
275
|
data: data,
|
|
361
276
|
});
|
|
362
|
-
|
|
363
277
|
const sigs = await keeper.sign(b(serder.raw));
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
rot: serder.ked,
|
|
278
|
+
const jsondata = {
|
|
279
|
+
rot: serder.sad,
|
|
367
280
|
sigs: sigs,
|
|
368
|
-
smids:
|
|
369
|
-
states
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
? rstates.map((state) => state.i)
|
|
375
|
-
: undefined,
|
|
281
|
+
smids: states != undefined
|
|
282
|
+
? states.map((state) => state.i)
|
|
283
|
+
: undefined,
|
|
284
|
+
rmids: rstates != undefined
|
|
285
|
+
? rstates.map((state) => state.i)
|
|
286
|
+
: undefined,
|
|
376
287
|
};
|
|
377
288
|
jsondata[keeper.algo] = keeper.params();
|
|
378
|
-
|
|
379
|
-
const res = await this.client.fetch(
|
|
380
|
-
'/identifiers/' + name,
|
|
381
|
-
'PUT',
|
|
382
|
-
jsondata
|
|
383
|
-
);
|
|
289
|
+
const res = await this.client.fetch('/identifiers/' + name + '/events', 'POST', jsondata);
|
|
384
290
|
return new EventResult(serder, sigs, res);
|
|
385
291
|
}
|
|
386
|
-
|
|
387
292
|
/**
|
|
388
293
|
* Authorize an endpoint provider in a given role for a managed identifier
|
|
389
294
|
* @remarks
|
|
@@ -395,32 +300,19 @@ export class Identifier {
|
|
|
395
300
|
* @param {string} [stamp=now] Optional date-time-stamp RFC-3339 profile of iso8601 datetime. Now is the default if not provided
|
|
396
301
|
* @returns {Promise<EventResult>} A promise to the result of the authorization
|
|
397
302
|
*/
|
|
398
|
-
async addEndRole(
|
|
399
|
-
name: string,
|
|
400
|
-
role: string,
|
|
401
|
-
eid?: string,
|
|
402
|
-
stamp?: string
|
|
403
|
-
): Promise<EventResult> {
|
|
303
|
+
async addEndRole(name, role, eid, stamp) {
|
|
404
304
|
const hab = await this.get(name);
|
|
405
305
|
const pre = hab.prefix;
|
|
406
|
-
|
|
407
306
|
const rpy = this.makeEndRole(pre, role, eid, stamp);
|
|
408
|
-
const keeper = this.client.manager
|
|
307
|
+
const keeper = this.client.manager.get(hab);
|
|
409
308
|
const sigs = await keeper.sign(b(rpy.raw));
|
|
410
|
-
|
|
411
309
|
const jsondata = {
|
|
412
|
-
rpy: rpy.
|
|
310
|
+
rpy: rpy.sad,
|
|
413
311
|
sigs: sigs,
|
|
414
312
|
};
|
|
415
|
-
|
|
416
|
-
const res = this.client.fetch(
|
|
417
|
-
'/identifiers/' + name + '/endroles',
|
|
418
|
-
'POST',
|
|
419
|
-
jsondata
|
|
420
|
-
);
|
|
313
|
+
const res = await this.client.fetch('/identifiers/' + name + '/endroles', 'POST', jsondata);
|
|
421
314
|
return new EventResult(rpy, sigs, res);
|
|
422
315
|
}
|
|
423
|
-
|
|
424
316
|
/**
|
|
425
317
|
* Generate an /end/role/add reply message
|
|
426
318
|
* @param {string} pre Prefix of the identifier
|
|
@@ -429,13 +321,8 @@ export class Identifier {
|
|
|
429
321
|
* @param {string} [stamp=now] Optional date-time-stamp RFC-3339 profile of iso8601 datetime. Now is the default if not provided
|
|
430
322
|
* @returns {Serder} The reply message
|
|
431
323
|
*/
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
role: string,
|
|
435
|
-
eid?: string,
|
|
436
|
-
stamp?: string
|
|
437
|
-
): Serder {
|
|
438
|
-
const data: any = {
|
|
324
|
+
makeEndRole(pre, role, eid, stamp) {
|
|
325
|
+
const data = {
|
|
439
326
|
cid: pre,
|
|
440
327
|
role: role,
|
|
441
328
|
};
|
|
@@ -445,49 +332,31 @@ export class Identifier {
|
|
|
445
332
|
const route = '/end/role/add';
|
|
446
333
|
return reply(route, data, stamp, undefined, Serials.JSON);
|
|
447
334
|
}
|
|
448
|
-
|
|
449
335
|
/**
|
|
450
336
|
* Get the members of a group identifier
|
|
451
337
|
* @async
|
|
452
338
|
* @param {string} name - Name or alias of the identifier
|
|
453
339
|
* @returns {Promise<any>} - A promise to the list of members
|
|
454
340
|
*/
|
|
455
|
-
async members(name
|
|
456
|
-
const res = await this.client.fetch(
|
|
457
|
-
'/identifiers/' + name + '/members',
|
|
458
|
-
'GET',
|
|
459
|
-
undefined
|
|
460
|
-
);
|
|
341
|
+
async members(name) {
|
|
342
|
+
const res = await this.client.fetch('/identifiers/' + name + '/members', 'GET', undefined);
|
|
461
343
|
return await res.json();
|
|
462
344
|
}
|
|
463
345
|
}
|
|
464
|
-
|
|
465
346
|
/** Event Result */
|
|
466
347
|
export class EventResult {
|
|
467
|
-
|
|
468
|
-
private readonly _sigs: string[];
|
|
469
|
-
private readonly promise: Promise<Response> | Response;
|
|
470
|
-
|
|
471
|
-
constructor(
|
|
472
|
-
serder: Serder,
|
|
473
|
-
sigs: string[],
|
|
474
|
-
promise: Promise<Response> | Response
|
|
475
|
-
) {
|
|
348
|
+
constructor(serder, sigs, response) {
|
|
476
349
|
this._serder = serder;
|
|
477
350
|
this._sigs = sigs;
|
|
478
|
-
this.
|
|
351
|
+
this.response = response;
|
|
479
352
|
}
|
|
480
|
-
|
|
481
353
|
get serder() {
|
|
482
354
|
return this._serder;
|
|
483
355
|
}
|
|
484
|
-
|
|
485
356
|
get sigs() {
|
|
486
357
|
return this._sigs;
|
|
487
358
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const res = await this.promise;
|
|
491
|
-
return await res.json();
|
|
359
|
+
async op() {
|
|
360
|
+
return await this.response.json();
|
|
492
361
|
}
|
|
493
362
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Oobis, Operations, KeyEvents, KeyStates } from './coring';
|
|
8
|
-
import { Credentials, Ipex, Registries, Schemas } from './credentialing';
|
|
9
|
-
import {
|
|
10
|
-
import { Escrows } from './escrowing';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
1
|
+
import { Authenticater } from '../core/authing.ts';
|
|
2
|
+
import { ExternalModule, IdentifierManagerFactory } from '../core/keeping.ts';
|
|
3
|
+
import { Tier } from '../core/salter.ts';
|
|
4
|
+
import { Identifier } from './aiding.ts';
|
|
5
|
+
import { Contacts, Challenges } from './contacting.ts';
|
|
6
|
+
import { Agent, Controller } from './controller.ts';
|
|
7
|
+
import { Oobis, Operations, KeyEvents, KeyStates, Config } from './coring.ts';
|
|
8
|
+
import { Credentials, Ipex, Registries, Schemas } from './credentialing.ts';
|
|
9
|
+
import { Delegations } from './delegating.ts';
|
|
10
|
+
import { Escrows } from './escrowing.ts';
|
|
11
|
+
import { Exchanges } from './exchanging.ts';
|
|
12
|
+
import { Groups } from './grouping.ts';
|
|
13
|
+
import { Notifications } from './notifying.ts';
|
|
13
14
|
declare class State {
|
|
14
15
|
agent: any | null;
|
|
15
16
|
controller: any | null;
|
|
@@ -17,7 +18,10 @@ declare class State {
|
|
|
17
18
|
pidx: number;
|
|
18
19
|
constructor();
|
|
19
20
|
}
|
|
20
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* An in-memory key manager that can connect to a KERIA Agent and use it to
|
|
23
|
+
* receive messages and act as a proxy for multi-signature operations and delegation operations.
|
|
24
|
+
*/
|
|
21
25
|
export declare class SignifyClient {
|
|
22
26
|
controller: Controller;
|
|
23
27
|
url: string;
|
|
@@ -25,10 +29,27 @@ export declare class SignifyClient {
|
|
|
25
29
|
pidx: number;
|
|
26
30
|
agent: Agent | null;
|
|
27
31
|
authn: Authenticater | null;
|
|
28
|
-
manager:
|
|
32
|
+
manager: IdentifierManagerFactory | null;
|
|
29
33
|
tier: Tier;
|
|
30
34
|
bootUrl: string;
|
|
31
35
|
exteralModules: ExternalModule[];
|
|
36
|
+
private _identifiers;
|
|
37
|
+
private _operations;
|
|
38
|
+
private _keyEvents;
|
|
39
|
+
private _keyStates;
|
|
40
|
+
private _oobis;
|
|
41
|
+
private _config;
|
|
42
|
+
private _delegations;
|
|
43
|
+
private _exchanges;
|
|
44
|
+
private _groups;
|
|
45
|
+
private _escrows;
|
|
46
|
+
private _credentials;
|
|
47
|
+
private _registries;
|
|
48
|
+
private _ipex;
|
|
49
|
+
private _notifications;
|
|
50
|
+
private _contacts;
|
|
51
|
+
private _challenges;
|
|
52
|
+
private _schemas;
|
|
32
53
|
/**
|
|
33
54
|
* SignifyClient constructor
|
|
34
55
|
* @param {string} url KERIA admin interface URL
|
|
@@ -66,16 +87,20 @@ export declare class SignifyClient {
|
|
|
66
87
|
*/
|
|
67
88
|
fetch(path: string, method: string, data: any, extraHeaders?: Headers): Promise<Response>;
|
|
68
89
|
/**
|
|
69
|
-
*
|
|
90
|
+
* Create a Signed Request to fetch a resource from an external URL with headers signed by an AID
|
|
70
91
|
* @async
|
|
71
|
-
* @param {string} url URL of the resource
|
|
72
|
-
* @param {string} path Path to the resource
|
|
73
|
-
* @param {string} method HTTP method
|
|
74
|
-
* @param {any} data Data to be sent in the body of the resource
|
|
75
92
|
* @param {string} aidName Name or alias of the AID to be used for signing
|
|
76
|
-
* @
|
|
77
|
-
|
|
78
|
-
|
|
93
|
+
* @param {string} url URL of the requested resource
|
|
94
|
+
* @param {RequestInit} req Request options should include:
|
|
95
|
+
* - method: HTTP method
|
|
96
|
+
* - data Data to be sent in the body of the resource.
|
|
97
|
+
* If the data is a CESR JSON string then you should also set contentType to 'application/json+cesr'
|
|
98
|
+
* If the data is a FormData object then you should not set the contentType and the browser will set it to 'multipart/form-data'
|
|
99
|
+
* If the data is an object then you should use JSON.stringify to convert it to a string and set the contentType to 'application/json'
|
|
100
|
+
* - contentType Content type of the request.
|
|
101
|
+
* @returns {Promise<Request>} A promise to the created Request
|
|
102
|
+
*/
|
|
103
|
+
createSignedRequest(aidName: string, url: string, req: RequestInit): Promise<Request>;
|
|
79
104
|
/**
|
|
80
105
|
* Approve the delegation of the client AID to the KERIA agent
|
|
81
106
|
* @async
|
|
@@ -178,5 +203,15 @@ export declare class SignifyClient {
|
|
|
178
203
|
* @returns {Exchanges}
|
|
179
204
|
*/
|
|
180
205
|
exchanges(): Exchanges;
|
|
206
|
+
/**
|
|
207
|
+
* Get delegations resource
|
|
208
|
+
* @returns {Delegations}
|
|
209
|
+
*/
|
|
210
|
+
delegations(): Delegations;
|
|
211
|
+
/**
|
|
212
|
+
* Get agent config resource
|
|
213
|
+
* @returns {Config}
|
|
214
|
+
*/
|
|
215
|
+
config(): Config;
|
|
181
216
|
}
|
|
182
217
|
export {};
|