@0xsequence/guard 1.9.24 → 1.9.26
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/dist/0xsequence-guard.cjs.dev.js +272 -39
- package/dist/0xsequence-guard.cjs.prod.js +272 -39
- package/dist/0xsequence-guard.esm.js +272 -39
- package/dist/declarations/src/guard.gen.d.ts +119 -35
- package/package.json +5 -5
- package/src/guard.gen.ts +550 -143
|
@@ -30,132 +30,192 @@ class Guard {
|
|
|
30
30
|
this.hostname = void 0;
|
|
31
31
|
this.fetch = void 0;
|
|
32
32
|
this.path = '/rpc/Guard/';
|
|
33
|
-
this.ping = headers => {
|
|
34
|
-
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
|
|
33
|
+
this.ping = (headers, signal) => {
|
|
34
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
35
35
|
return buildResponse(res).then(_data => {
|
|
36
36
|
return {
|
|
37
37
|
status: _data.status
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
|
+
}, error => {
|
|
41
|
+
throw WebrpcRequestFailedError.new({
|
|
42
|
+
cause: `fetch(): ${error.message || ''}`
|
|
43
|
+
});
|
|
40
44
|
});
|
|
41
45
|
};
|
|
42
|
-
this.version = headers => {
|
|
43
|
-
return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
|
|
46
|
+
this.version = (headers, signal) => {
|
|
47
|
+
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
44
48
|
return buildResponse(res).then(_data => {
|
|
45
49
|
return {
|
|
46
50
|
version: _data.version
|
|
47
51
|
};
|
|
48
52
|
});
|
|
53
|
+
}, error => {
|
|
54
|
+
throw WebrpcRequestFailedError.new({
|
|
55
|
+
cause: `fetch(): ${error.message || ''}`
|
|
56
|
+
});
|
|
49
57
|
});
|
|
50
58
|
};
|
|
51
|
-
this.runtimeStatus = headers => {
|
|
52
|
-
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
|
|
59
|
+
this.runtimeStatus = (headers, signal) => {
|
|
60
|
+
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
53
61
|
return buildResponse(res).then(_data => {
|
|
54
62
|
return {
|
|
55
63
|
status: _data.status
|
|
56
64
|
};
|
|
57
65
|
});
|
|
66
|
+
}, error => {
|
|
67
|
+
throw WebrpcRequestFailedError.new({
|
|
68
|
+
cause: `fetch(): ${error.message || ''}`
|
|
69
|
+
});
|
|
58
70
|
});
|
|
59
71
|
};
|
|
60
|
-
this.getSignerConfig = (args, headers) => {
|
|
61
|
-
return this.fetch(this.url('GetSignerConfig'), createHTTPRequest(args, headers)).then(res => {
|
|
72
|
+
this.getSignerConfig = (args, headers, signal) => {
|
|
73
|
+
return this.fetch(this.url('GetSignerConfig'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
62
74
|
return buildResponse(res).then(_data => {
|
|
63
75
|
return {
|
|
64
76
|
signerConfig: _data.signerConfig
|
|
65
77
|
};
|
|
66
78
|
});
|
|
79
|
+
}, error => {
|
|
80
|
+
throw WebrpcRequestFailedError.new({
|
|
81
|
+
cause: `fetch(): ${error.message || ''}`
|
|
82
|
+
});
|
|
67
83
|
});
|
|
68
84
|
};
|
|
69
|
-
this.sign = (args, headers) => {
|
|
70
|
-
return this.fetch(this.url('Sign'), createHTTPRequest(args, headers)).then(res => {
|
|
85
|
+
this.sign = (args, headers, signal) => {
|
|
86
|
+
return this.fetch(this.url('Sign'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
71
87
|
return buildResponse(res).then(_data => {
|
|
72
88
|
return {
|
|
73
89
|
sig: _data.sig
|
|
74
90
|
};
|
|
75
91
|
});
|
|
92
|
+
}, error => {
|
|
93
|
+
throw WebrpcRequestFailedError.new({
|
|
94
|
+
cause: `fetch(): ${error.message || ''}`
|
|
95
|
+
});
|
|
76
96
|
});
|
|
77
97
|
};
|
|
78
|
-
this.signWith = (args, headers) => {
|
|
79
|
-
return this.fetch(this.url('SignWith'), createHTTPRequest(args, headers)).then(res => {
|
|
98
|
+
this.signWith = (args, headers, signal) => {
|
|
99
|
+
return this.fetch(this.url('SignWith'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
80
100
|
return buildResponse(res).then(_data => {
|
|
81
101
|
return {
|
|
82
102
|
sig: _data.sig
|
|
83
103
|
};
|
|
84
104
|
});
|
|
105
|
+
}, error => {
|
|
106
|
+
throw WebrpcRequestFailedError.new({
|
|
107
|
+
cause: `fetch(): ${error.message || ''}`
|
|
108
|
+
});
|
|
85
109
|
});
|
|
86
110
|
};
|
|
87
|
-
this.authMethods = (args, headers) => {
|
|
88
|
-
return this.fetch(this.url('AuthMethods'), createHTTPRequest(args, headers)).then(res => {
|
|
111
|
+
this.authMethods = (args, headers, signal) => {
|
|
112
|
+
return this.fetch(this.url('AuthMethods'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
89
113
|
return buildResponse(res).then(_data => {
|
|
90
114
|
return {
|
|
91
115
|
methods: _data.methods,
|
|
92
116
|
active: _data.active
|
|
93
117
|
};
|
|
94
118
|
});
|
|
119
|
+
}, error => {
|
|
120
|
+
throw WebrpcRequestFailedError.new({
|
|
121
|
+
cause: `fetch(): ${error.message || ''}`
|
|
122
|
+
});
|
|
95
123
|
});
|
|
96
124
|
};
|
|
97
|
-
this.setPIN = (args, headers) => {
|
|
98
|
-
return this.fetch(this.url('SetPIN'), createHTTPRequest(args, headers)).then(res => {
|
|
125
|
+
this.setPIN = (args, headers, signal) => {
|
|
126
|
+
return this.fetch(this.url('SetPIN'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
99
127
|
return buildResponse(res).then(_data => {
|
|
100
128
|
return {};
|
|
101
129
|
});
|
|
130
|
+
}, error => {
|
|
131
|
+
throw WebrpcRequestFailedError.new({
|
|
132
|
+
cause: `fetch(): ${error.message || ''}`
|
|
133
|
+
});
|
|
102
134
|
});
|
|
103
135
|
};
|
|
104
|
-
this.resetPIN = (args, headers) => {
|
|
105
|
-
return this.fetch(this.url('ResetPIN'), createHTTPRequest(args, headers)).then(res => {
|
|
136
|
+
this.resetPIN = (args, headers, signal) => {
|
|
137
|
+
return this.fetch(this.url('ResetPIN'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
106
138
|
return buildResponse(res).then(_data => {
|
|
107
139
|
return {};
|
|
108
140
|
});
|
|
141
|
+
}, error => {
|
|
142
|
+
throw WebrpcRequestFailedError.new({
|
|
143
|
+
cause: `fetch(): ${error.message || ''}`
|
|
144
|
+
});
|
|
109
145
|
});
|
|
110
146
|
};
|
|
111
|
-
this.createTOTP = (args, headers) => {
|
|
112
|
-
return this.fetch(this.url('CreateTOTP'), createHTTPRequest(args, headers)).then(res => {
|
|
147
|
+
this.createTOTP = (args, headers, signal) => {
|
|
148
|
+
return this.fetch(this.url('CreateTOTP'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
113
149
|
return buildResponse(res).then(_data => {
|
|
114
150
|
return {
|
|
115
151
|
uri: _data.uri
|
|
116
152
|
};
|
|
117
153
|
});
|
|
154
|
+
}, error => {
|
|
155
|
+
throw WebrpcRequestFailedError.new({
|
|
156
|
+
cause: `fetch(): ${error.message || ''}`
|
|
157
|
+
});
|
|
118
158
|
});
|
|
119
159
|
};
|
|
120
|
-
this.commitTOTP = (args, headers) => {
|
|
121
|
-
return this.fetch(this.url('CommitTOTP'), createHTTPRequest(args, headers)).then(res => {
|
|
160
|
+
this.commitTOTP = (args, headers, signal) => {
|
|
161
|
+
return this.fetch(this.url('CommitTOTP'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
122
162
|
return buildResponse(res).then(_data => {
|
|
123
163
|
return {
|
|
124
164
|
codes: _data.codes
|
|
125
165
|
};
|
|
126
166
|
});
|
|
167
|
+
}, error => {
|
|
168
|
+
throw WebrpcRequestFailedError.new({
|
|
169
|
+
cause: `fetch(): ${error.message || ''}`
|
|
170
|
+
});
|
|
127
171
|
});
|
|
128
172
|
};
|
|
129
|
-
this.resetTOTP = (args, headers) => {
|
|
130
|
-
return this.fetch(this.url('ResetTOTP'), createHTTPRequest(args, headers)).then(res => {
|
|
173
|
+
this.resetTOTP = (args, headers, signal) => {
|
|
174
|
+
return this.fetch(this.url('ResetTOTP'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
131
175
|
return buildResponse(res).then(_data => {
|
|
132
176
|
return {};
|
|
133
177
|
});
|
|
178
|
+
}, error => {
|
|
179
|
+
throw WebrpcRequestFailedError.new({
|
|
180
|
+
cause: `fetch(): ${error.message || ''}`
|
|
181
|
+
});
|
|
134
182
|
});
|
|
135
183
|
};
|
|
136
|
-
this.reset2FA = (args, headers) => {
|
|
137
|
-
return this.fetch(this.url('Reset2FA'), createHTTPRequest(args, headers)).then(res => {
|
|
184
|
+
this.reset2FA = (args, headers, signal) => {
|
|
185
|
+
return this.fetch(this.url('Reset2FA'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
138
186
|
return buildResponse(res).then(_data => {
|
|
139
187
|
return {};
|
|
140
188
|
});
|
|
189
|
+
}, error => {
|
|
190
|
+
throw WebrpcRequestFailedError.new({
|
|
191
|
+
cause: `fetch(): ${error.message || ''}`
|
|
192
|
+
});
|
|
141
193
|
});
|
|
142
194
|
};
|
|
143
|
-
this.recoveryCodes = (args, headers) => {
|
|
144
|
-
return this.fetch(this.url('RecoveryCodes'), createHTTPRequest(args, headers)).then(res => {
|
|
195
|
+
this.recoveryCodes = (args, headers, signal) => {
|
|
196
|
+
return this.fetch(this.url('RecoveryCodes'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
145
197
|
return buildResponse(res).then(_data => {
|
|
146
198
|
return {
|
|
147
199
|
codes: _data.codes
|
|
148
200
|
};
|
|
149
201
|
});
|
|
202
|
+
}, error => {
|
|
203
|
+
throw WebrpcRequestFailedError.new({
|
|
204
|
+
cause: `fetch(): ${error.message || ''}`
|
|
205
|
+
});
|
|
150
206
|
});
|
|
151
207
|
};
|
|
152
|
-
this.resetRecoveryCodes = (args, headers) => {
|
|
153
|
-
return this.fetch(this.url('ResetRecoveryCodes'), createHTTPRequest(args, headers)).then(res => {
|
|
208
|
+
this.resetRecoveryCodes = (args, headers, signal) => {
|
|
209
|
+
return this.fetch(this.url('ResetRecoveryCodes'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
154
210
|
return buildResponse(res).then(_data => {
|
|
155
211
|
return {
|
|
156
212
|
codes: _data.codes
|
|
157
213
|
};
|
|
158
214
|
});
|
|
215
|
+
}, error => {
|
|
216
|
+
throw WebrpcRequestFailedError.new({
|
|
217
|
+
cause: `fetch(): ${error.message || ''}`
|
|
218
|
+
});
|
|
159
219
|
});
|
|
160
220
|
};
|
|
161
221
|
this.hostname = hostname;
|
|
@@ -165,13 +225,14 @@ class Guard {
|
|
|
165
225
|
return this.hostname + this.path + name;
|
|
166
226
|
}
|
|
167
227
|
}
|
|
168
|
-
const createHTTPRequest = (body = {}, headers = {}) => {
|
|
228
|
+
const createHTTPRequest = (body = {}, headers = {}, signal = null) => {
|
|
169
229
|
return {
|
|
170
230
|
method: 'POST',
|
|
171
231
|
headers: _extends({}, headers, {
|
|
172
232
|
'Content-Type': 'application/json'
|
|
173
233
|
}),
|
|
174
|
-
body: JSON.stringify(body || {})
|
|
234
|
+
body: JSON.stringify(body || {}),
|
|
235
|
+
signal
|
|
175
236
|
};
|
|
176
237
|
};
|
|
177
238
|
const buildResponse = res => {
|
|
@@ -179,20 +240,192 @@ const buildResponse = res => {
|
|
|
179
240
|
let data;
|
|
180
241
|
try {
|
|
181
242
|
data = JSON.parse(text);
|
|
182
|
-
} catch (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
243
|
+
} catch (error) {
|
|
244
|
+
let message = '';
|
|
245
|
+
if (error instanceof Error) {
|
|
246
|
+
message = error.message;
|
|
247
|
+
}
|
|
248
|
+
throw WebrpcBadResponseError.new({
|
|
249
|
+
status: res.status,
|
|
250
|
+
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
251
|
+
});
|
|
188
252
|
}
|
|
189
253
|
if (!res.ok) {
|
|
190
|
-
|
|
254
|
+
const code = typeof data.code === 'number' ? data.code : 0;
|
|
255
|
+
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
191
256
|
}
|
|
192
257
|
return data;
|
|
193
258
|
});
|
|
194
259
|
};
|
|
195
260
|
|
|
261
|
+
//
|
|
262
|
+
// Errors
|
|
263
|
+
//
|
|
264
|
+
|
|
265
|
+
class WebrpcError extends Error {
|
|
266
|
+
constructor(name, code, message, status, cause) {
|
|
267
|
+
super(message);
|
|
268
|
+
this.name = void 0;
|
|
269
|
+
this.code = void 0;
|
|
270
|
+
this.message = void 0;
|
|
271
|
+
this.status = void 0;
|
|
272
|
+
this.cause = void 0;
|
|
273
|
+
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
274
|
+
this.msg = void 0;
|
|
275
|
+
this.name = name || 'WebrpcError';
|
|
276
|
+
this.code = typeof code === 'number' ? code : 0;
|
|
277
|
+
this.message = message || `endpoint error ${this.code}`;
|
|
278
|
+
this.msg = this.message;
|
|
279
|
+
this.status = typeof status === 'number' ? status : 0;
|
|
280
|
+
this.cause = cause;
|
|
281
|
+
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
282
|
+
}
|
|
283
|
+
static new(payload) {
|
|
284
|
+
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Webrpc errors
|
|
289
|
+
|
|
290
|
+
class WebrpcEndpointError extends WebrpcError {
|
|
291
|
+
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) {
|
|
292
|
+
super(name, code, message, status, cause);
|
|
293
|
+
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
class WebrpcRequestFailedError extends WebrpcError {
|
|
297
|
+
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) {
|
|
298
|
+
super(name, code, message, status, cause);
|
|
299
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
class WebrpcBadRouteError extends WebrpcError {
|
|
303
|
+
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) {
|
|
304
|
+
super(name, code, message, status, cause);
|
|
305
|
+
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
class WebrpcBadMethodError extends WebrpcError {
|
|
309
|
+
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) {
|
|
310
|
+
super(name, code, message, status, cause);
|
|
311
|
+
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
class WebrpcBadRequestError extends WebrpcError {
|
|
315
|
+
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) {
|
|
316
|
+
super(name, code, message, status, cause);
|
|
317
|
+
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
class WebrpcBadResponseError extends WebrpcError {
|
|
321
|
+
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) {
|
|
322
|
+
super(name, code, message, status, cause);
|
|
323
|
+
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
class WebrpcServerPanicError extends WebrpcError {
|
|
327
|
+
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) {
|
|
328
|
+
super(name, code, message, status, cause);
|
|
329
|
+
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
class WebrpcInternalErrorError extends WebrpcError {
|
|
333
|
+
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) {
|
|
334
|
+
super(name, code, message, status, cause);
|
|
335
|
+
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
class WebrpcClientDisconnectedError extends WebrpcError {
|
|
339
|
+
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) {
|
|
340
|
+
super(name, code, message, status, cause);
|
|
341
|
+
Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
class WebrpcStreamLostError extends WebrpcError {
|
|
345
|
+
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) {
|
|
346
|
+
super(name, code, message, status, cause);
|
|
347
|
+
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
class WebrpcStreamFinishedError extends WebrpcError {
|
|
351
|
+
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) {
|
|
352
|
+
super(name, code, message, status, cause);
|
|
353
|
+
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Schema errors
|
|
358
|
+
|
|
359
|
+
class UnauthorizedError extends WebrpcError {
|
|
360
|
+
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) {
|
|
361
|
+
super(name, code, message, status, cause);
|
|
362
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
class SessionExpiredError extends WebrpcError {
|
|
366
|
+
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) {
|
|
367
|
+
super(name, code, message, status, cause);
|
|
368
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
class AbortedError extends WebrpcError {
|
|
372
|
+
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) {
|
|
373
|
+
super(name, code, message, status, cause);
|
|
374
|
+
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
class InvalidArgumentError extends WebrpcError {
|
|
378
|
+
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) {
|
|
379
|
+
super(name, code, message, status, cause);
|
|
380
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
class UnavailableError extends WebrpcError {
|
|
384
|
+
constructor(name = 'Unavailable', code = 2002, message = 'Unavailable resource', status = 0, cause) {
|
|
385
|
+
super(name, code, message, status, cause);
|
|
386
|
+
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
class QueryFailedError extends WebrpcError {
|
|
390
|
+
constructor(name = 'QueryFailed', code = 2003, message = 'Query failed', status = 0, cause) {
|
|
391
|
+
super(name, code, message, status, cause);
|
|
392
|
+
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
class ValidationFailedError extends WebrpcError {
|
|
396
|
+
constructor(name = 'ValidationFailed', code = 2004, message = 'Validation Failed', status = 0, cause) {
|
|
397
|
+
super(name, code, message, status, cause);
|
|
398
|
+
Object.setPrototypeOf(this, ValidationFailedError.prototype);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
class NotFoundError extends WebrpcError {
|
|
402
|
+
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) {
|
|
403
|
+
super(name, code, message, status, cause);
|
|
404
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const webrpcErrorByCode = {
|
|
408
|
+
[0]: WebrpcEndpointError,
|
|
409
|
+
[-1]: WebrpcRequestFailedError,
|
|
410
|
+
[-2]: WebrpcBadRouteError,
|
|
411
|
+
[-3]: WebrpcBadMethodError,
|
|
412
|
+
[-4]: WebrpcBadRequestError,
|
|
413
|
+
[-5]: WebrpcBadResponseError,
|
|
414
|
+
[-6]: WebrpcServerPanicError,
|
|
415
|
+
[-7]: WebrpcInternalErrorError,
|
|
416
|
+
[-8]: WebrpcClientDisconnectedError,
|
|
417
|
+
[-9]: WebrpcStreamLostError,
|
|
418
|
+
[-10]: WebrpcStreamFinishedError,
|
|
419
|
+
[1000]: UnauthorizedError,
|
|
420
|
+
[1002]: SessionExpiredError,
|
|
421
|
+
[1005]: AbortedError,
|
|
422
|
+
[2001]: InvalidArgumentError,
|
|
423
|
+
[2002]: UnavailableError,
|
|
424
|
+
[2003]: QueryFailedError,
|
|
425
|
+
[2004]: ValidationFailedError,
|
|
426
|
+
[3000]: NotFoundError
|
|
427
|
+
};
|
|
428
|
+
|
|
196
429
|
const fetch = typeof global === 'object' ? global.fetch : window.fetch;
|
|
197
430
|
class GuardSigner {
|
|
198
431
|
constructor(address, url, appendSuffix = false) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const WebRPCVersion = "v1";
|
|
2
2
|
export declare const WebRPCSchemaVersion = "v0.4.0";
|
|
3
|
-
export declare const WebRPCSchemaHash = "
|
|
3
|
+
export declare const WebRPCSchemaHash = "12059311f086716f467356ed38189f565d5f172a";
|
|
4
4
|
export interface Version {
|
|
5
5
|
webrpcVersion: string;
|
|
6
6
|
schemaVersion: string;
|
|
@@ -43,21 +43,21 @@ export interface RecoveryCode {
|
|
|
43
43
|
used: boolean;
|
|
44
44
|
}
|
|
45
45
|
export interface Guard {
|
|
46
|
-
ping(headers?: object): Promise<PingReturn>;
|
|
47
|
-
version(headers?: object): Promise<VersionReturn>;
|
|
48
|
-
runtimeStatus(headers?: object): Promise<RuntimeStatusReturn>;
|
|
49
|
-
getSignerConfig(args: GetSignerConfigArgs, headers?: object): Promise<GetSignerConfigReturn>;
|
|
50
|
-
sign(args: SignArgs, headers?: object): Promise<SignReturn>;
|
|
51
|
-
signWith(args: SignWithArgs, headers?: object): Promise<SignWithReturn>;
|
|
52
|
-
authMethods(args: AuthMethodsArgs, headers?: object): Promise<AuthMethodsReturn>;
|
|
53
|
-
setPIN(args: SetPINArgs, headers?: object): Promise<SetPINReturn>;
|
|
54
|
-
resetPIN(args: ResetPINArgs, headers?: object): Promise<ResetPINReturn>;
|
|
55
|
-
createTOTP(args: CreateTOTPArgs, headers?: object): Promise<CreateTOTPReturn>;
|
|
56
|
-
commitTOTP(args: CommitTOTPArgs, headers?: object): Promise<CommitTOTPReturn>;
|
|
57
|
-
resetTOTP(args: ResetTOTPArgs, headers?: object): Promise<ResetTOTPReturn>;
|
|
58
|
-
reset2FA(args: Reset2FAArgs, headers?: object): Promise<Reset2FAReturn>;
|
|
59
|
-
recoveryCodes(args: RecoveryCodesArgs, headers?: object): Promise<RecoveryCodesReturn>;
|
|
60
|
-
resetRecoveryCodes(args: ResetRecoveryCodesArgs, headers?: object): Promise<ResetRecoveryCodesReturn>;
|
|
46
|
+
ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>;
|
|
47
|
+
version(headers?: object, signal?: AbortSignal): Promise<VersionReturn>;
|
|
48
|
+
runtimeStatus(headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn>;
|
|
49
|
+
getSignerConfig(args: GetSignerConfigArgs, headers?: object, signal?: AbortSignal): Promise<GetSignerConfigReturn>;
|
|
50
|
+
sign(args: SignArgs, headers?: object, signal?: AbortSignal): Promise<SignReturn>;
|
|
51
|
+
signWith(args: SignWithArgs, headers?: object, signal?: AbortSignal): Promise<SignWithReturn>;
|
|
52
|
+
authMethods(args: AuthMethodsArgs, headers?: object, signal?: AbortSignal): Promise<AuthMethodsReturn>;
|
|
53
|
+
setPIN(args: SetPINArgs, headers?: object, signal?: AbortSignal): Promise<SetPINReturn>;
|
|
54
|
+
resetPIN(args: ResetPINArgs, headers?: object, signal?: AbortSignal): Promise<ResetPINReturn>;
|
|
55
|
+
createTOTP(args: CreateTOTPArgs, headers?: object, signal?: AbortSignal): Promise<CreateTOTPReturn>;
|
|
56
|
+
commitTOTP(args: CommitTOTPArgs, headers?: object, signal?: AbortSignal): Promise<CommitTOTPReturn>;
|
|
57
|
+
resetTOTP(args: ResetTOTPArgs, headers?: object, signal?: AbortSignal): Promise<ResetTOTPReturn>;
|
|
58
|
+
reset2FA(args: Reset2FAArgs, headers?: object, signal?: AbortSignal): Promise<Reset2FAReturn>;
|
|
59
|
+
recoveryCodes(args: RecoveryCodesArgs, headers?: object, signal?: AbortSignal): Promise<RecoveryCodesReturn>;
|
|
60
|
+
resetRecoveryCodes(args: ResetRecoveryCodesArgs, headers?: object, signal?: AbortSignal): Promise<ResetRecoveryCodesReturn>;
|
|
61
61
|
}
|
|
62
62
|
export interface PingArgs {
|
|
63
63
|
}
|
|
@@ -160,25 +160,109 @@ export declare class Guard implements Guard {
|
|
|
160
160
|
protected path: string;
|
|
161
161
|
constructor(hostname: string, fetch: Fetch);
|
|
162
162
|
private url;
|
|
163
|
-
ping: (headers?: object | undefined) => Promise<PingReturn>;
|
|
164
|
-
version: (headers?: object | undefined) => Promise<VersionReturn>;
|
|
165
|
-
runtimeStatus: (headers?: object | undefined) => Promise<RuntimeStatusReturn>;
|
|
166
|
-
getSignerConfig: (args: GetSignerConfigArgs, headers?: object | undefined) => Promise<GetSignerConfigReturn>;
|
|
167
|
-
sign: (args: SignArgs, headers?: object | undefined) => Promise<SignReturn>;
|
|
168
|
-
signWith: (args: SignWithArgs, headers?: object | undefined) => Promise<SignWithReturn>;
|
|
169
|
-
authMethods: (args: AuthMethodsArgs, headers?: object | undefined) => Promise<AuthMethodsReturn>;
|
|
170
|
-
setPIN: (args: SetPINArgs, headers?: object | undefined) => Promise<SetPINReturn>;
|
|
171
|
-
resetPIN: (args: ResetPINArgs, headers?: object | undefined) => Promise<ResetPINReturn>;
|
|
172
|
-
createTOTP: (args: CreateTOTPArgs, headers?: object | undefined) => Promise<CreateTOTPReturn>;
|
|
173
|
-
commitTOTP: (args: CommitTOTPArgs, headers?: object | undefined) => Promise<CommitTOTPReturn>;
|
|
174
|
-
resetTOTP: (args: ResetTOTPArgs, headers?: object | undefined) => Promise<ResetTOTPReturn>;
|
|
175
|
-
reset2FA: (args: Reset2FAArgs, headers?: object | undefined) => Promise<Reset2FAReturn>;
|
|
176
|
-
recoveryCodes: (args: RecoveryCodesArgs, headers?: object | undefined) => Promise<RecoveryCodesReturn>;
|
|
177
|
-
resetRecoveryCodes: (args: ResetRecoveryCodesArgs, headers?: object | undefined) => Promise<ResetRecoveryCodesReturn>;
|
|
178
|
-
}
|
|
179
|
-
export
|
|
180
|
-
|
|
181
|
-
|
|
163
|
+
ping: (headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<PingReturn>;
|
|
164
|
+
version: (headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<VersionReturn>;
|
|
165
|
+
runtimeStatus: (headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<RuntimeStatusReturn>;
|
|
166
|
+
getSignerConfig: (args: GetSignerConfigArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<GetSignerConfigReturn>;
|
|
167
|
+
sign: (args: SignArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<SignReturn>;
|
|
168
|
+
signWith: (args: SignWithArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<SignWithReturn>;
|
|
169
|
+
authMethods: (args: AuthMethodsArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<AuthMethodsReturn>;
|
|
170
|
+
setPIN: (args: SetPINArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<SetPINReturn>;
|
|
171
|
+
resetPIN: (args: ResetPINArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<ResetPINReturn>;
|
|
172
|
+
createTOTP: (args: CreateTOTPArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<CreateTOTPReturn>;
|
|
173
|
+
commitTOTP: (args: CommitTOTPArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<CommitTOTPReturn>;
|
|
174
|
+
resetTOTP: (args: ResetTOTPArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<ResetTOTPReturn>;
|
|
175
|
+
reset2FA: (args: Reset2FAArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<Reset2FAReturn>;
|
|
176
|
+
recoveryCodes: (args: RecoveryCodesArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<RecoveryCodesReturn>;
|
|
177
|
+
resetRecoveryCodes: (args: ResetRecoveryCodesArgs, headers?: object | undefined, signal?: AbortSignal | undefined) => Promise<ResetRecoveryCodesReturn>;
|
|
178
|
+
}
|
|
179
|
+
export declare class WebrpcError extends Error {
|
|
180
|
+
name: string;
|
|
181
|
+
code: number;
|
|
182
|
+
message: string;
|
|
182
183
|
status: number;
|
|
184
|
+
cause?: string;
|
|
185
|
+
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
186
|
+
msg: string;
|
|
187
|
+
constructor(name: string, code: number, message: string, status: number, cause?: string);
|
|
188
|
+
static new(payload: any): WebrpcError;
|
|
189
|
+
}
|
|
190
|
+
export declare class WebrpcEndpointError extends WebrpcError {
|
|
191
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
192
|
+
}
|
|
193
|
+
export declare class WebrpcRequestFailedError extends WebrpcError {
|
|
194
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
195
|
+
}
|
|
196
|
+
export declare class WebrpcBadRouteError extends WebrpcError {
|
|
197
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
198
|
+
}
|
|
199
|
+
export declare class WebrpcBadMethodError extends WebrpcError {
|
|
200
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
201
|
+
}
|
|
202
|
+
export declare class WebrpcBadRequestError extends WebrpcError {
|
|
203
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
204
|
+
}
|
|
205
|
+
export declare class WebrpcBadResponseError extends WebrpcError {
|
|
206
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
207
|
+
}
|
|
208
|
+
export declare class WebrpcServerPanicError extends WebrpcError {
|
|
209
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
210
|
+
}
|
|
211
|
+
export declare class WebrpcInternalErrorError extends WebrpcError {
|
|
212
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
213
|
+
}
|
|
214
|
+
export declare class WebrpcClientDisconnectedError extends WebrpcError {
|
|
215
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
216
|
+
}
|
|
217
|
+
export declare class WebrpcStreamLostError extends WebrpcError {
|
|
218
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
219
|
+
}
|
|
220
|
+
export declare class WebrpcStreamFinishedError extends WebrpcError {
|
|
221
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
222
|
+
}
|
|
223
|
+
export declare class UnauthorizedError extends WebrpcError {
|
|
224
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
225
|
+
}
|
|
226
|
+
export declare class SessionExpiredError extends WebrpcError {
|
|
227
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
228
|
+
}
|
|
229
|
+
export declare class AbortedError extends WebrpcError {
|
|
230
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
231
|
+
}
|
|
232
|
+
export declare class InvalidArgumentError extends WebrpcError {
|
|
233
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
234
|
+
}
|
|
235
|
+
export declare class UnavailableError extends WebrpcError {
|
|
236
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
237
|
+
}
|
|
238
|
+
export declare class QueryFailedError extends WebrpcError {
|
|
239
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
240
|
+
}
|
|
241
|
+
export declare class ValidationFailedError extends WebrpcError {
|
|
242
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
243
|
+
}
|
|
244
|
+
export declare class NotFoundError extends WebrpcError {
|
|
245
|
+
constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
|
|
246
|
+
}
|
|
247
|
+
export declare enum errors {
|
|
248
|
+
WebrpcEndpoint = "WebrpcEndpoint",
|
|
249
|
+
WebrpcRequestFailed = "WebrpcRequestFailed",
|
|
250
|
+
WebrpcBadRoute = "WebrpcBadRoute",
|
|
251
|
+
WebrpcBadMethod = "WebrpcBadMethod",
|
|
252
|
+
WebrpcBadRequest = "WebrpcBadRequest",
|
|
253
|
+
WebrpcBadResponse = "WebrpcBadResponse",
|
|
254
|
+
WebrpcServerPanic = "WebrpcServerPanic",
|
|
255
|
+
WebrpcInternalError = "WebrpcInternalError",
|
|
256
|
+
WebrpcClientDisconnected = "WebrpcClientDisconnected",
|
|
257
|
+
WebrpcStreamLost = "WebrpcStreamLost",
|
|
258
|
+
WebrpcStreamFinished = "WebrpcStreamFinished",
|
|
259
|
+
Unauthorized = "Unauthorized",
|
|
260
|
+
SessionExpired = "SessionExpired",
|
|
261
|
+
Aborted = "Aborted",
|
|
262
|
+
InvalidArgument = "InvalidArgument",
|
|
263
|
+
Unavailable = "Unavailable",
|
|
264
|
+
QueryFailed = "QueryFailed",
|
|
265
|
+
ValidationFailed = "ValidationFailed",
|
|
266
|
+
NotFound = "NotFound"
|
|
183
267
|
}
|
|
184
268
|
export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsequence/guard",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.26",
|
|
4
4
|
"description": "guard sub-package for Sequence",
|
|
5
5
|
"repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/guard",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"ethers": "^5.7.2",
|
|
13
|
-
"@0xsequence/account": "1.9.
|
|
14
|
-
"@0xsequence/
|
|
15
|
-
"@0xsequence/
|
|
16
|
-
"@0xsequence/core": "1.9.
|
|
13
|
+
"@0xsequence/account": "1.9.26",
|
|
14
|
+
"@0xsequence/utils": "1.9.26",
|
|
15
|
+
"@0xsequence/signhub": "1.9.26",
|
|
16
|
+
"@0xsequence/core": "1.9.26"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"src",
|