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