signify-ts 0.2.0 → 0.3.0-dev.e31e78d
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 +54 -18
- package/{src/keri/app/aiding.ts → dist/keri/app/aiding.js} +130 -236
- package/dist/keri/app/clienting.d.ts +59 -22
- package/{src/keri/app/clienting.ts → dist/keri/app/clienting.js} +146 -235
- package/dist/keri/app/contacting.d.ts +30 -23
- package/{src/keri/app/contacting.ts → dist/keri/app/contacting.js} +26 -63
- 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 +134 -25
- package/{src/keri/app/coring.ts → dist/keri/app/coring.js} +83 -56
- package/dist/keri/app/credentialing.d.ts +191 -67
- 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 +5 -3
- package/{src/keri/app/escrowing.ts → dist/keri/app/escrowing.js} +3 -9
- package/dist/keri/app/exchanging.d.ts +243 -11
- 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 +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 +6 -6
- package/dist/keri/core/eventing.js +383 -0
- 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 +113 -46
- 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/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} +26 -32
- 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 +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} +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 +1158 -0
- package/dist/types/keria-api-schema.js +34 -0
- package/package.json +53 -52
- package/dist/math.d.ts +0 -1
- package/dist/signify-ts.cjs +0 -7835
- 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 -7811
- 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 -820
- package/src/keri/app/exchanging.ts +0 -220
- 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/eventing.ts +0 -581
- 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
- /package/dist/{buffer-polyfill.d.ts → keri/core/keyState.js} +0 -0
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Oobis, Operations, KeyEvents, KeyStates } from
|
|
9
|
-
import { Credentials, Ipex, Registries, Schemas } from
|
|
10
|
-
import {
|
|
11
|
-
import { Escrows } from
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
1
|
+
import { Authenticater } from "../core/authing.js";
|
|
2
|
+
import { HEADER_SIG_TIME } from "../core/httping.js";
|
|
3
|
+
import { IdentifierManagerFactory } from "../core/keeping.js";
|
|
4
|
+
import { Tier } from "../core/salter.js";
|
|
5
|
+
import { Identifier } from "./aiding.js";
|
|
6
|
+
import { Contacts, Challenges } from "./contacting.js";
|
|
7
|
+
import { Agent, Controller } from "./controller.js";
|
|
8
|
+
import { Oobis, Operations, KeyEvents, KeyStates, Config } from "./coring.js";
|
|
9
|
+
import { Credentials, Ipex, Registries, Schemas } from "./credentialing.js";
|
|
10
|
+
import { Delegations } from "./delegating.js";
|
|
11
|
+
import { Escrows } from "./escrowing.js";
|
|
12
|
+
import { Exchanges } from "./exchanging.js";
|
|
13
|
+
import { Groups } from "./grouping.js";
|
|
14
|
+
import { Notifications } from "./notifying.js";
|
|
15
15
|
const DEFAULT_BOOT_URL = 'http://localhost:3903';
|
|
16
|
-
|
|
17
16
|
class State {
|
|
18
|
-
agent: any | null;
|
|
19
|
-
controller: any | null;
|
|
20
|
-
ridx: number;
|
|
21
|
-
pidx: number;
|
|
22
|
-
|
|
23
17
|
constructor() {
|
|
24
18
|
this.agent = null;
|
|
25
19
|
this.controller = null;
|
|
@@ -27,20 +21,11 @@ class State {
|
|
|
27
21
|
this.ridx = 0;
|
|
28
22
|
}
|
|
29
23
|
}
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
/**
|
|
25
|
+
* An in-memory key manager that can connect to a KERIA Agent and use it to
|
|
26
|
+
* receive messages and act as a proxy for multi-signature operations and delegation operations.
|
|
27
|
+
*/
|
|
32
28
|
export class SignifyClient {
|
|
33
|
-
public controller: Controller;
|
|
34
|
-
public url: string;
|
|
35
|
-
public bran: string;
|
|
36
|
-
public pidx: number;
|
|
37
|
-
public agent: Agent | null;
|
|
38
|
-
public authn: Authenticater | null;
|
|
39
|
-
public manager: KeyManager | null;
|
|
40
|
-
public tier: Tier;
|
|
41
|
-
public bootUrl: string;
|
|
42
|
-
public exteralModules: ExternalModule[];
|
|
43
|
-
|
|
44
29
|
/**
|
|
45
30
|
* SignifyClient constructor
|
|
46
31
|
* @param {string} url KERIA admin interface URL
|
|
@@ -49,13 +34,24 @@ export class SignifyClient {
|
|
|
49
34
|
* @param {string} bootUrl KERIA boot interface URL
|
|
50
35
|
* @param {ExternalModule[]} externalModules list of external modules to load
|
|
51
36
|
*/
|
|
52
|
-
constructor(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
constructor(url, bran, tier = Tier.low, bootUrl = DEFAULT_BOOT_URL, externalModules = []) {
|
|
38
|
+
this._identifiers = new Identifier(this);
|
|
39
|
+
this._operations = new Operations(this);
|
|
40
|
+
this._keyEvents = new KeyEvents(this);
|
|
41
|
+
this._keyStates = new KeyStates(this);
|
|
42
|
+
this._oobis = new Oobis(this);
|
|
43
|
+
this._config = new Config(this);
|
|
44
|
+
this._delegations = new Delegations(this);
|
|
45
|
+
this._exchanges = new Exchanges(this);
|
|
46
|
+
this._groups = new Groups(this);
|
|
47
|
+
this._escrows = new Escrows(this);
|
|
48
|
+
this._credentials = new Credentials(this);
|
|
49
|
+
this._registries = new Registries(this);
|
|
50
|
+
this._ipex = new Ipex(this);
|
|
51
|
+
this._notifications = new Notifications(this);
|
|
52
|
+
this._contacts = new Contacts(this);
|
|
53
|
+
this._challenges = new Challenges(this);
|
|
54
|
+
this._schemas = new Schemas(this);
|
|
59
55
|
this.url = url;
|
|
60
56
|
if (bran.length < 21) {
|
|
61
57
|
throw Error('bran must be 21 characters');
|
|
@@ -70,26 +66,24 @@ export class SignifyClient {
|
|
|
70
66
|
this.bootUrl = bootUrl;
|
|
71
67
|
this.exteralModules = externalModules;
|
|
72
68
|
}
|
|
73
|
-
|
|
74
69
|
get data() {
|
|
75
70
|
return [this.url, this.bran, this.pidx, this.authn];
|
|
76
71
|
}
|
|
77
|
-
|
|
78
72
|
/**
|
|
79
73
|
* Boot a KERIA agent
|
|
80
74
|
* @async
|
|
81
75
|
* @returns {Promise<Response>} A promise to the result of the boot
|
|
82
76
|
*/
|
|
83
|
-
async boot()
|
|
84
|
-
|
|
77
|
+
async boot() {
|
|
78
|
+
var _a, _b, _c, _d;
|
|
79
|
+
const [evt, sign] = (_b = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.event) !== null && _b !== void 0 ? _b : [];
|
|
85
80
|
const data = {
|
|
86
|
-
icp: evt.
|
|
81
|
+
icp: evt.sad,
|
|
87
82
|
sig: sign.qb64,
|
|
88
|
-
stem: this.controller
|
|
83
|
+
stem: (_c = this.controller) === null || _c === void 0 ? void 0 : _c.stem,
|
|
89
84
|
pidx: 1,
|
|
90
|
-
tier: this.controller
|
|
85
|
+
tier: (_d = this.controller) === null || _d === void 0 ? void 0 : _d.tier,
|
|
91
86
|
};
|
|
92
|
-
|
|
93
87
|
return await fetch(this.bootUrl + '/boot', {
|
|
94
88
|
method: 'POST',
|
|
95
89
|
body: JSON.stringify(data),
|
|
@@ -98,29 +92,26 @@ export class SignifyClient {
|
|
|
98
92
|
},
|
|
99
93
|
});
|
|
100
94
|
}
|
|
101
|
-
|
|
102
95
|
/**
|
|
103
96
|
* Get state of the agent and the client
|
|
104
97
|
* @async
|
|
105
98
|
* @returns {Promise<Response>} A promise to the state
|
|
106
99
|
*/
|
|
107
|
-
async state()
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
async state() {
|
|
101
|
+
var _a, _b, _c, _d, _e;
|
|
102
|
+
const caid = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.pre;
|
|
110
103
|
const res = await fetch(this.url + `/agent/${caid}`);
|
|
111
104
|
if (res.status == 404) {
|
|
112
105
|
throw new Error(`agent does not exist for controller ${caid}`);
|
|
113
106
|
}
|
|
114
|
-
|
|
115
|
-
const data = await res.json();
|
|
107
|
+
const data = (await res.json());
|
|
116
108
|
const state = new State();
|
|
117
|
-
state.agent = data.agent
|
|
118
|
-
state.controller = data.controller
|
|
119
|
-
state.ridx = data.ridx
|
|
120
|
-
state.pidx = data.pidx
|
|
109
|
+
state.agent = (_b = data.agent) !== null && _b !== void 0 ? _b : {};
|
|
110
|
+
state.controller = (_c = data.controller) !== null && _c !== void 0 ? _c : {};
|
|
111
|
+
state.ridx = (_d = data.ridx) !== null && _d !== void 0 ? _d : 0;
|
|
112
|
+
state.pidx = (_e = data.pidx) !== null && _e !== void 0 ? _e : 0;
|
|
121
113
|
return state;
|
|
122
114
|
}
|
|
123
|
-
|
|
124
115
|
/** Connect to a KERIA agent
|
|
125
116
|
* @async
|
|
126
117
|
*/
|
|
@@ -128,33 +119,19 @@ export class SignifyClient {
|
|
|
128
119
|
const state = await this.state();
|
|
129
120
|
this.pidx = state.pidx;
|
|
130
121
|
//Create controller representing the local client AID
|
|
131
|
-
this.controller = new Controller(
|
|
132
|
-
this.bran,
|
|
133
|
-
this.tier,
|
|
134
|
-
0,
|
|
135
|
-
state.controller
|
|
136
|
-
);
|
|
122
|
+
this.controller = new Controller(this.bran, this.tier, 0, state.controller);
|
|
137
123
|
this.controller.ridx = state.ridx !== undefined ? state.ridx : 0;
|
|
138
124
|
// Create agent representing the AID of KERIA cloud agent
|
|
139
125
|
this.agent = new Agent(state.agent);
|
|
140
126
|
if (this.agent.anchor != this.controller.pre) {
|
|
141
|
-
throw Error(
|
|
142
|
-
'commitment to controller AID missing in agent inception event'
|
|
143
|
-
);
|
|
127
|
+
throw Error('commitment to controller AID missing in agent inception event');
|
|
144
128
|
}
|
|
145
|
-
if (this.controller.serder.
|
|
129
|
+
if (this.controller.serder.sad.s == 0) {
|
|
146
130
|
await this.approveDelegation();
|
|
147
131
|
}
|
|
148
|
-
this.manager = new
|
|
149
|
-
|
|
150
|
-
this.exteralModules
|
|
151
|
-
);
|
|
152
|
-
this.authn = new Authenticater(
|
|
153
|
-
this.controller.signer,
|
|
154
|
-
this.agent.verfer!
|
|
155
|
-
);
|
|
132
|
+
this.manager = new IdentifierManagerFactory(this.controller.salter, this.exteralModules);
|
|
133
|
+
this.authn = new Authenticater(this.controller.signer, this.agent.verfer);
|
|
156
134
|
}
|
|
157
|
-
|
|
158
135
|
/**
|
|
159
136
|
* Fetch a resource from the KERIA agent
|
|
160
137
|
* @async
|
|
@@ -164,37 +141,21 @@ export class SignifyClient {
|
|
|
164
141
|
* @param {Headers} [extraHeaders] Optional extra headers to be sent with the request
|
|
165
142
|
* @returns {Promise<Response>} A promise to the result of the fetch
|
|
166
143
|
*/
|
|
167
|
-
async fetch(
|
|
168
|
-
|
|
169
|
-
method: string,
|
|
170
|
-
data: any,
|
|
171
|
-
extraHeaders?: Headers
|
|
172
|
-
): Promise<Response> {
|
|
144
|
+
async fetch(path, method, data, extraHeaders) {
|
|
145
|
+
var _a;
|
|
173
146
|
const headers = new Headers();
|
|
174
147
|
let signed_headers = new Headers();
|
|
175
148
|
const final_headers = new Headers();
|
|
176
|
-
|
|
177
149
|
headers.set('Signify-Resource', this.controller.pre);
|
|
178
|
-
headers.set(
|
|
179
|
-
'Signify-Timestamp',
|
|
180
|
-
new Date().toISOString().replace('Z', '000+00:00')
|
|
181
|
-
);
|
|
150
|
+
headers.set(HEADER_SIG_TIME, new Date().toISOString().replace('Z', '000+00:00'));
|
|
182
151
|
headers.set('Content-Type', 'application/json');
|
|
183
|
-
|
|
184
152
|
const _body = method == 'GET' ? null : JSON.stringify(data);
|
|
185
|
-
if (_body !== null) {
|
|
186
|
-
headers.set('Content-Length', String(_body.length));
|
|
187
|
-
}
|
|
188
153
|
if (this.authn) {
|
|
189
|
-
signed_headers = this.authn.sign(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
path.split('?')[0]
|
|
193
|
-
);
|
|
194
|
-
} else {
|
|
154
|
+
signed_headers = this.authn.sign(headers, method, path.split('?')[0]);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
195
157
|
throw new Error('client need to call connect first');
|
|
196
158
|
}
|
|
197
|
-
|
|
198
159
|
signed_headers.forEach((value, key) => {
|
|
199
160
|
final_headers.set(key, value);
|
|
200
161
|
});
|
|
@@ -213,120 +174,72 @@ export class SignifyClient {
|
|
|
213
174
|
const message = `HTTP ${method} ${path} - ${res.status} ${res.statusText} - ${error}`;
|
|
214
175
|
throw new Error(message);
|
|
215
176
|
}
|
|
216
|
-
const isSameAgent =
|
|
217
|
-
this.agent?.pre === res.headers.get('signify-resource');
|
|
177
|
+
const isSameAgent = ((_a = this.agent) === null || _a === void 0 ? void 0 : _a.pre) === res.headers.get('signify-resource');
|
|
218
178
|
if (!isSameAgent) {
|
|
219
179
|
throw new Error('message from a different remote agent');
|
|
220
180
|
}
|
|
221
|
-
|
|
222
|
-
const verification = this.authn.verify(
|
|
223
|
-
res.headers,
|
|
224
|
-
method,
|
|
225
|
-
path.split('?')[0]
|
|
226
|
-
);
|
|
181
|
+
const verification = this.authn.verify(res.headers, method, path.split('?')[0]);
|
|
227
182
|
if (verification) {
|
|
228
183
|
return res;
|
|
229
|
-
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
230
186
|
throw new Error('response verification failed');
|
|
231
187
|
}
|
|
232
188
|
}
|
|
233
|
-
|
|
234
189
|
/**
|
|
235
|
-
*
|
|
190
|
+
* Create a Signed Request to fetch a resource from an external URL with headers signed by an AID
|
|
236
191
|
* @async
|
|
237
|
-
* @param {string} url URL of the resource
|
|
238
|
-
* @param {string} path Path to the resource
|
|
239
|
-
* @param {string} method HTTP method
|
|
240
|
-
* @param {any} data Data to be sent in the body of the resource
|
|
241
192
|
* @param {string} aidName Name or alias of the AID to be used for signing
|
|
242
|
-
* @
|
|
193
|
+
* @param {string} url URL of the requested resource
|
|
194
|
+
* @param {RequestInit} req Request options should include:
|
|
195
|
+
* - method: HTTP method
|
|
196
|
+
* - data Data to be sent in the body of the resource.
|
|
197
|
+
* If the data is a CESR JSON string then you should also set contentType to 'application/json+cesr'
|
|
198
|
+
* If the data is a FormData object then you should not set the contentType and the browser will set it to 'multipart/form-data'
|
|
199
|
+
* 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'
|
|
200
|
+
* - contentType Content type of the request.
|
|
201
|
+
* @returns {Promise<Request>} A promise to the created Request
|
|
243
202
|
*/
|
|
244
|
-
async
|
|
245
|
-
|
|
246
|
-
path: string,
|
|
247
|
-
method: string,
|
|
248
|
-
data: any,
|
|
249
|
-
aidName: string
|
|
250
|
-
): Promise<Response> {
|
|
203
|
+
async createSignedRequest(aidName, url, req) {
|
|
204
|
+
var _a;
|
|
251
205
|
const hab = await this.identifiers().get(aidName);
|
|
252
|
-
const keeper = this.manager
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
headers.set('Signify-Resource', hab.prefix);
|
|
261
|
-
headers.set(
|
|
262
|
-
'Signify-Timestamp',
|
|
263
|
-
new Date().toISOString().replace('Z', '000+00:00')
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
if (data !== null) {
|
|
267
|
-
headers.set('Content-Length', data.length);
|
|
268
|
-
} else {
|
|
269
|
-
headers.set('Content-Length', '0');
|
|
270
|
-
}
|
|
271
|
-
const signed_headers = authenticator.sign(
|
|
272
|
-
headers,
|
|
273
|
-
method,
|
|
274
|
-
path.split('?')[0]
|
|
275
|
-
);
|
|
276
|
-
let _body = null;
|
|
277
|
-
if (method != 'GET') {
|
|
278
|
-
if (data instanceof FormData) {
|
|
279
|
-
_body = data;
|
|
280
|
-
// do not set the content type, let the browser do it
|
|
281
|
-
// headers.set('Content-Type', 'multipart/form-data')
|
|
282
|
-
} else {
|
|
283
|
-
_body = JSON.stringify(data);
|
|
284
|
-
headers.set('Content-Type', 'application/json');
|
|
285
|
-
}
|
|
286
|
-
} else {
|
|
287
|
-
headers.set('Content-Type', 'application/json');
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return await fetch(url + path, {
|
|
291
|
-
method: method,
|
|
292
|
-
body: _body,
|
|
293
|
-
headers: signed_headers,
|
|
294
|
-
});
|
|
206
|
+
const keeper = this.manager.get(hab);
|
|
207
|
+
const authenticator = new Authenticater(keeper.signers[0], keeper.signers[0].verfer);
|
|
208
|
+
const headers = new Headers(req.headers);
|
|
209
|
+
headers.set('Signify-Resource', hab['prefix']);
|
|
210
|
+
headers.set(HEADER_SIG_TIME, new Date().toISOString().replace('Z', '000+00:00'));
|
|
211
|
+
const signed_headers = authenticator.sign(new Headers(headers), (_a = req.method) !== null && _a !== void 0 ? _a : 'GET', new URL(url).pathname);
|
|
212
|
+
req.headers = signed_headers;
|
|
213
|
+
return new Request(url, req);
|
|
295
214
|
}
|
|
296
|
-
|
|
297
215
|
/**
|
|
298
216
|
* Approve the delegation of the client AID to the KERIA agent
|
|
299
217
|
* @async
|
|
300
218
|
* @returns {Promise<Response>} A promise to the result of the approval
|
|
301
219
|
*/
|
|
302
|
-
async approveDelegation()
|
|
303
|
-
const sigs = this.controller.approveDelegation(this.agent
|
|
304
|
-
|
|
220
|
+
async approveDelegation() {
|
|
221
|
+
const sigs = this.controller.approveDelegation(this.agent);
|
|
305
222
|
const data = {
|
|
306
|
-
ixn: this.controller.serder.
|
|
223
|
+
ixn: this.controller.serder.sad,
|
|
307
224
|
sigs: sigs,
|
|
308
225
|
};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
{
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
'Content-Type': 'application/json',
|
|
317
|
-
},
|
|
318
|
-
}
|
|
319
|
-
);
|
|
226
|
+
return await fetch(this.url + '/agent/' + this.controller.pre + '?type=ixn', {
|
|
227
|
+
method: 'PUT',
|
|
228
|
+
body: JSON.stringify(data),
|
|
229
|
+
headers: {
|
|
230
|
+
'Content-Type': 'application/json',
|
|
231
|
+
},
|
|
232
|
+
});
|
|
320
233
|
}
|
|
321
|
-
|
|
322
234
|
/**
|
|
323
235
|
* Save old client passcode in KERIA agent
|
|
324
236
|
* @async
|
|
325
237
|
* @param {string} passcode Passcode to be saved
|
|
326
238
|
* @returns {Promise<Response>} A promise to the result of the save
|
|
327
239
|
*/
|
|
328
|
-
async saveOldPasscode(passcode
|
|
329
|
-
|
|
240
|
+
async saveOldPasscode(passcode) {
|
|
241
|
+
var _a;
|
|
242
|
+
const caid = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.pre;
|
|
330
243
|
const body = { salt: passcode };
|
|
331
244
|
return await fetch(this.url + '/salt/' + caid, {
|
|
332
245
|
method: 'PUT',
|
|
@@ -336,14 +249,14 @@ export class SignifyClient {
|
|
|
336
249
|
},
|
|
337
250
|
});
|
|
338
251
|
}
|
|
339
|
-
|
|
340
252
|
/**
|
|
341
253
|
* Delete a saved passcode from KERIA agent
|
|
342
254
|
* @async
|
|
343
255
|
* @returns {Promise<Response>} A promise to the result of the deletion
|
|
344
256
|
*/
|
|
345
|
-
async deletePasscode()
|
|
346
|
-
|
|
257
|
+
async deletePasscode() {
|
|
258
|
+
var _a;
|
|
259
|
+
const caid = (_a = this.controller) === null || _a === void 0 ? void 0 : _a.pre;
|
|
347
260
|
return await fetch(this.url + '/salt/' + caid, {
|
|
348
261
|
method: 'DELETE',
|
|
349
262
|
headers: {
|
|
@@ -351,7 +264,6 @@ export class SignifyClient {
|
|
|
351
264
|
},
|
|
352
265
|
});
|
|
353
266
|
}
|
|
354
|
-
|
|
355
267
|
/**
|
|
356
268
|
* Rotate the client AID
|
|
357
269
|
* @async
|
|
@@ -359,7 +271,7 @@ export class SignifyClient {
|
|
|
359
271
|
* @param {Array<string>} aids List of managed AIDs to be rotated
|
|
360
272
|
* @returns {Promise<Response>} A promise to the result of the rotation
|
|
361
273
|
*/
|
|
362
|
-
async rotate(nbran
|
|
274
|
+
async rotate(nbran, aids) {
|
|
363
275
|
const data = this.controller.rotate(nbran, aids);
|
|
364
276
|
return await fetch(this.url + '/agent/' + this.controller.pre, {
|
|
365
277
|
method: 'PUT',
|
|
@@ -369,124 +281,123 @@ export class SignifyClient {
|
|
|
369
281
|
},
|
|
370
282
|
});
|
|
371
283
|
}
|
|
372
|
-
|
|
373
284
|
/**
|
|
374
285
|
* Get identifiers resource
|
|
375
286
|
* @returns {Identifier}
|
|
376
287
|
*/
|
|
377
|
-
identifiers()
|
|
378
|
-
return
|
|
288
|
+
identifiers() {
|
|
289
|
+
return this._identifiers;
|
|
379
290
|
}
|
|
380
|
-
|
|
381
291
|
/**
|
|
382
292
|
* Get OOBIs resource
|
|
383
293
|
* @returns {Oobis}
|
|
384
294
|
*/
|
|
385
|
-
oobis()
|
|
386
|
-
return
|
|
295
|
+
oobis() {
|
|
296
|
+
return this._oobis;
|
|
387
297
|
}
|
|
388
|
-
|
|
389
298
|
/**
|
|
390
299
|
* Get operations resource
|
|
391
300
|
* @returns {Operations}
|
|
392
301
|
*/
|
|
393
|
-
operations()
|
|
394
|
-
return
|
|
302
|
+
operations() {
|
|
303
|
+
return this._operations;
|
|
395
304
|
}
|
|
396
|
-
|
|
397
305
|
/**
|
|
398
306
|
* Get keyEvents resource
|
|
399
307
|
* @returns {KeyEvents}
|
|
400
308
|
*/
|
|
401
|
-
keyEvents()
|
|
402
|
-
return
|
|
309
|
+
keyEvents() {
|
|
310
|
+
return this._keyEvents;
|
|
403
311
|
}
|
|
404
|
-
|
|
405
312
|
/**
|
|
406
313
|
* Get keyStates resource
|
|
407
314
|
* @returns {KeyStates}
|
|
408
315
|
*/
|
|
409
|
-
keyStates()
|
|
410
|
-
return
|
|
316
|
+
keyStates() {
|
|
317
|
+
return this._keyStates;
|
|
411
318
|
}
|
|
412
|
-
|
|
413
319
|
/**
|
|
414
320
|
* Get credentials resource
|
|
415
321
|
* @returns {Credentials}
|
|
416
322
|
*/
|
|
417
|
-
credentials()
|
|
418
|
-
return
|
|
323
|
+
credentials() {
|
|
324
|
+
return this._credentials;
|
|
419
325
|
}
|
|
420
|
-
|
|
421
326
|
/**
|
|
422
327
|
* Get IPEX resource
|
|
423
328
|
* @returns {Ipex}
|
|
424
329
|
*/
|
|
425
|
-
ipex()
|
|
426
|
-
return
|
|
330
|
+
ipex() {
|
|
331
|
+
return this._ipex;
|
|
427
332
|
}
|
|
428
|
-
|
|
429
333
|
/**
|
|
430
334
|
* Get registries resource
|
|
431
335
|
* @returns {Registries}
|
|
432
336
|
*/
|
|
433
|
-
registries()
|
|
434
|
-
return
|
|
337
|
+
registries() {
|
|
338
|
+
return this._registries;
|
|
435
339
|
}
|
|
436
|
-
|
|
437
340
|
/**
|
|
438
341
|
* Get schemas resource
|
|
439
342
|
* @returns {Schemas}
|
|
440
343
|
*/
|
|
441
|
-
schemas()
|
|
442
|
-
return
|
|
344
|
+
schemas() {
|
|
345
|
+
return this._schemas;
|
|
443
346
|
}
|
|
444
|
-
|
|
445
347
|
/**
|
|
446
348
|
* Get challenges resource
|
|
447
349
|
* @returns {Challenges}
|
|
448
350
|
*/
|
|
449
|
-
challenges()
|
|
450
|
-
return
|
|
351
|
+
challenges() {
|
|
352
|
+
return this._challenges;
|
|
451
353
|
}
|
|
452
|
-
|
|
453
354
|
/**
|
|
454
355
|
* Get contacts resource
|
|
455
356
|
* @returns {Contacts}
|
|
456
357
|
*/
|
|
457
|
-
contacts()
|
|
458
|
-
return
|
|
358
|
+
contacts() {
|
|
359
|
+
return this._contacts;
|
|
459
360
|
}
|
|
460
|
-
|
|
461
361
|
/**
|
|
462
362
|
* Get notifications resource
|
|
463
363
|
* @returns {Notifications}
|
|
464
364
|
*/
|
|
465
|
-
notifications()
|
|
466
|
-
return
|
|
365
|
+
notifications() {
|
|
366
|
+
return this._notifications;
|
|
467
367
|
}
|
|
468
|
-
|
|
469
368
|
/**
|
|
470
369
|
* Get escrows resource
|
|
471
370
|
* @returns {Escrows}
|
|
472
371
|
*/
|
|
473
|
-
escrows()
|
|
474
|
-
return
|
|
372
|
+
escrows() {
|
|
373
|
+
return this._escrows;
|
|
475
374
|
}
|
|
476
|
-
|
|
477
375
|
/**
|
|
478
376
|
* Get groups resource
|
|
479
377
|
* @returns {Groups}
|
|
480
378
|
*/
|
|
481
|
-
groups()
|
|
482
|
-
return
|
|
379
|
+
groups() {
|
|
380
|
+
return this._groups;
|
|
483
381
|
}
|
|
484
|
-
|
|
485
382
|
/**
|
|
486
383
|
* Get exchange resource
|
|
487
384
|
* @returns {Exchanges}
|
|
488
385
|
*/
|
|
489
|
-
exchanges()
|
|
490
|
-
return
|
|
386
|
+
exchanges() {
|
|
387
|
+
return this._exchanges;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Get delegations resource
|
|
391
|
+
* @returns {Delegations}
|
|
392
|
+
*/
|
|
393
|
+
delegations() {
|
|
394
|
+
return this._delegations;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Get agent config resource
|
|
398
|
+
* @returns {Config}
|
|
399
|
+
*/
|
|
400
|
+
config() {
|
|
401
|
+
return this._config;
|
|
491
402
|
}
|
|
492
403
|
}
|