@0xsequence/guard 2.3.39 → 3.0.0-beta.10
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/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +3002 -0
- package/LICENSE +0 -17
- package/README.md +1 -2
- package/dist/{declarations/src → client}/guard.gen.d.ts +1 -0
- package/dist/client/guard.gen.d.ts.map +1 -0
- package/dist/client/guard.gen.js +552 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/local.d.ts +14 -0
- package/dist/local.d.ts.map +1 -0
- package/dist/local.js +13 -0
- package/dist/sequence.d.ts +14 -0
- package/dist/sequence.d.ts.map +1 -0
- package/dist/sequence.js +44 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/package.json +23 -19
- package/src/{guard.gen.ts → client/guard.gen.ts} +124 -116
- package/src/index.ts +6 -2
- package/src/local.ts +23 -0
- package/src/sequence.ts +56 -0
- package/src/types.ts +27 -0
- package/test/sequence.test.ts +189 -0
- package/tsconfig.json +10 -0
- package/dist/0xsequence-guard.cjs.d.ts +0 -2
- package/dist/0xsequence-guard.cjs.dev.js +0 -785
- package/dist/0xsequence-guard.cjs.js +0 -7
- package/dist/0xsequence-guard.cjs.prod.js +0 -785
- package/dist/0xsequence-guard.esm.js +0 -775
- package/dist/declarations/src/index.d.ts +0 -2
- package/dist/declarations/src/signer.d.ts +0 -66
- package/src/signer.ts +0 -310
package/LICENSE
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
Copyright (c) 2017-present Horizon Blockchain Games Inc.
|
|
2
|
-
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
See the License for the specific language governing permissions and
|
|
13
|
-
limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
------------------------------------------------------------------------
|
|
17
|
-
|
|
18
1
|
|
|
19
2
|
Apache License
|
|
20
3
|
Version 2.0, January 2004
|
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.gen.d.ts","sourceRoot":"","sources":["../../src/client/guard.gen.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,YAAY,WAAW,CAAA;AAEpC,eAAO,MAAM,iBAAiB,gEAAgE,CAAA;AAG9F,eAAO,MAAM,aAAa,OAAO,CAAA;AAGjC,eAAO,MAAM,mBAAmB,WAAW,CAAA;AAG3C,eAAO,MAAM,gBAAgB,6CAA6C,CAAA;AAE1E,KAAK,iBAAiB,GAAG;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAarE;AA+BD,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,YAAY,iBAAiB;IAC7B,wBAAwB,6BAA6B;CACtD;AAED,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CAC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OAAO;IACtB,OAAO,OAAO;IACd,UAAU,OAAO;IACjB,WAAW,OAAO;IAClB,eAAe,OAAO;IACtB,WAAW,OAAO;IAClB,WAAW,OAAO;IAClB,gBAAgB,OAAO;IACvB,QAAQ,OAAO;IACf,YAAY,OAAO;IACnB,WAAW,OAAO;CACnB;AAED,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAA;CA2BpD,CAAA;AAED,MAAM,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// sequence-guard v0.5.0 910e01c32ffb24b42386d4ca6be119b0acc55c5f
|
|
3
|
+
// --
|
|
4
|
+
// Code generated by webrpc-gen@v0.25.3 with typescript generator. DO NOT EDIT.
|
|
5
|
+
//
|
|
6
|
+
// webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts
|
|
7
|
+
export const WebrpcHeader = 'Webrpc';
|
|
8
|
+
export const WebrpcHeaderValue = 'webrpc@v0.25.3;gen-typescript@v0.17.0;sequence-guard@v0.5.0';
|
|
9
|
+
// WebRPC description and code-gen version
|
|
10
|
+
export const WebRPCVersion = 'v1';
|
|
11
|
+
// Schema version of your RIDL schema
|
|
12
|
+
export const WebRPCSchemaVersion = 'v0.5.0';
|
|
13
|
+
// Schema hash generated from your RIDL schema
|
|
14
|
+
export const WebRPCSchemaHash = '910e01c32ffb24b42386d4ca6be119b0acc55c5f';
|
|
15
|
+
export function VersionFromHeader(headers) {
|
|
16
|
+
const headerValue = headers.get(WebrpcHeader);
|
|
17
|
+
if (!headerValue) {
|
|
18
|
+
return {
|
|
19
|
+
webrpcGenVersion: '',
|
|
20
|
+
codeGenName: '',
|
|
21
|
+
codeGenVersion: '',
|
|
22
|
+
schemaName: '',
|
|
23
|
+
schemaVersion: '',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return parseWebrpcGenVersions(headerValue);
|
|
27
|
+
}
|
|
28
|
+
function parseWebrpcGenVersions(header) {
|
|
29
|
+
const versions = header.split(';');
|
|
30
|
+
if (versions.length < 3) {
|
|
31
|
+
return {
|
|
32
|
+
webrpcGenVersion: '',
|
|
33
|
+
codeGenName: '',
|
|
34
|
+
codeGenVersion: '',
|
|
35
|
+
schemaName: '',
|
|
36
|
+
schemaVersion: '',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const [_, webrpcGenVersion] = versions[0].split('@');
|
|
40
|
+
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
41
|
+
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
42
|
+
return {
|
|
43
|
+
webrpcGenVersion: webrpcGenVersion ?? '',
|
|
44
|
+
codeGenName: codeGenName ?? '',
|
|
45
|
+
codeGenVersion: codeGenVersion ?? '',
|
|
46
|
+
schemaName: schemaName ?? '',
|
|
47
|
+
schemaVersion: schemaVersion ?? '',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//
|
|
51
|
+
// Types
|
|
52
|
+
//
|
|
53
|
+
export var PayloadType;
|
|
54
|
+
(function (PayloadType) {
|
|
55
|
+
PayloadType["Calls"] = "Calls";
|
|
56
|
+
PayloadType["Message"] = "Message";
|
|
57
|
+
PayloadType["ConfigUpdate"] = "ConfigUpdate";
|
|
58
|
+
PayloadType["SessionImplicitAuthorize"] = "SessionImplicitAuthorize";
|
|
59
|
+
})(PayloadType || (PayloadType = {}));
|
|
60
|
+
export var SignatureType;
|
|
61
|
+
(function (SignatureType) {
|
|
62
|
+
SignatureType["Hash"] = "Hash";
|
|
63
|
+
SignatureType["Sapient"] = "Sapient";
|
|
64
|
+
SignatureType["EthSign"] = "EthSign";
|
|
65
|
+
SignatureType["Erc1271"] = "Erc1271";
|
|
66
|
+
})(SignatureType || (SignatureType = {}));
|
|
67
|
+
//
|
|
68
|
+
// Client
|
|
69
|
+
//
|
|
70
|
+
export class Guard {
|
|
71
|
+
hostname;
|
|
72
|
+
fetch;
|
|
73
|
+
path = '/rpc/Guard/';
|
|
74
|
+
constructor(hostname, fetch) {
|
|
75
|
+
this.hostname = hostname.replace(/\/*$/, '');
|
|
76
|
+
this.fetch = (input, init) => fetch(input, init);
|
|
77
|
+
}
|
|
78
|
+
url(name) {
|
|
79
|
+
return this.hostname + this.path + name;
|
|
80
|
+
}
|
|
81
|
+
ping = (headers, signal) => {
|
|
82
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then((res) => {
|
|
83
|
+
return buildResponse(res).then((_data) => {
|
|
84
|
+
return {
|
|
85
|
+
status: _data.status,
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}, (error) => {
|
|
89
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
version = (headers, signal) => {
|
|
93
|
+
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then((res) => {
|
|
94
|
+
return buildResponse(res).then((_data) => {
|
|
95
|
+
return {
|
|
96
|
+
version: _data.version,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}, (error) => {
|
|
100
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
runtimeStatus = (headers, signal) => {
|
|
104
|
+
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then((res) => {
|
|
105
|
+
return buildResponse(res).then((_data) => {
|
|
106
|
+
return {
|
|
107
|
+
status: _data.status,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}, (error) => {
|
|
111
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
getSignerConfig = (args, headers, signal) => {
|
|
115
|
+
return this.fetch(this.url('GetSignerConfig'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
116
|
+
return buildResponse(res).then((_data) => {
|
|
117
|
+
return {
|
|
118
|
+
signerConfig: _data.signerConfig,
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}, (error) => {
|
|
122
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
sign = (args, headers, signal) => {
|
|
126
|
+
return this.fetch(this.url('Sign'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
127
|
+
return buildResponse(res).then((_data) => {
|
|
128
|
+
return {
|
|
129
|
+
sig: _data.sig,
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
}, (error) => {
|
|
133
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
signWith = (args, headers, signal) => {
|
|
137
|
+
return this.fetch(this.url('SignWith'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
138
|
+
return buildResponse(res).then((_data) => {
|
|
139
|
+
return {
|
|
140
|
+
sig: _data.sig,
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}, (error) => {
|
|
144
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
patch = (args, headers, signal) => {
|
|
148
|
+
return this.fetch(this.url('Patch'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
149
|
+
return buildResponse(res).then((_data) => {
|
|
150
|
+
return {
|
|
151
|
+
txs: _data.txs,
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
}, (error) => {
|
|
155
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
authMethods = (args, headers, signal) => {
|
|
159
|
+
return this.fetch(this.url('AuthMethods'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
160
|
+
return buildResponse(res).then((_data) => {
|
|
161
|
+
return {
|
|
162
|
+
methods: _data.methods,
|
|
163
|
+
active: _data.active,
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
}, (error) => {
|
|
167
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
setPIN = (args, headers, signal) => {
|
|
171
|
+
return this.fetch(this.url('SetPIN'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
172
|
+
return buildResponse(res).then((_data) => {
|
|
173
|
+
return {};
|
|
174
|
+
});
|
|
175
|
+
}, (error) => {
|
|
176
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
resetPIN = (args, headers, signal) => {
|
|
180
|
+
return this.fetch(this.url('ResetPIN'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
181
|
+
return buildResponse(res).then((_data) => {
|
|
182
|
+
return {};
|
|
183
|
+
});
|
|
184
|
+
}, (error) => {
|
|
185
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
createTOTP = (args, headers, signal) => {
|
|
189
|
+
return this.fetch(this.url('CreateTOTP'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
190
|
+
return buildResponse(res).then((_data) => {
|
|
191
|
+
return {
|
|
192
|
+
uri: _data.uri,
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
}, (error) => {
|
|
196
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
commitTOTP = (args, headers, signal) => {
|
|
200
|
+
return this.fetch(this.url('CommitTOTP'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
201
|
+
return buildResponse(res).then((_data) => {
|
|
202
|
+
return {
|
|
203
|
+
codes: _data.codes,
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
}, (error) => {
|
|
207
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
resetTOTP = (args, headers, signal) => {
|
|
211
|
+
return this.fetch(this.url('ResetTOTP'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
212
|
+
return buildResponse(res).then((_data) => {
|
|
213
|
+
return {};
|
|
214
|
+
});
|
|
215
|
+
}, (error) => {
|
|
216
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
reset2FA = (args, headers, signal) => {
|
|
220
|
+
return this.fetch(this.url('Reset2FA'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
221
|
+
return buildResponse(res).then((_data) => {
|
|
222
|
+
return {};
|
|
223
|
+
});
|
|
224
|
+
}, (error) => {
|
|
225
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
recoveryCodes = (args, headers, signal) => {
|
|
229
|
+
return this.fetch(this.url('RecoveryCodes'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
230
|
+
return buildResponse(res).then((_data) => {
|
|
231
|
+
return {
|
|
232
|
+
codes: _data.codes,
|
|
233
|
+
};
|
|
234
|
+
});
|
|
235
|
+
}, (error) => {
|
|
236
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
resetRecoveryCodes = (args, headers, signal) => {
|
|
240
|
+
return this.fetch(this.url('ResetRecoveryCodes'), createHTTPRequest(args, headers, signal)).then((res) => {
|
|
241
|
+
return buildResponse(res).then((_data) => {
|
|
242
|
+
return {
|
|
243
|
+
codes: _data.codes,
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
}, (error) => {
|
|
247
|
+
throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` });
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const createHTTPRequest = (body = {}, headers = {}, signal = null) => {
|
|
252
|
+
const reqHeaders = { ...headers, 'Content-Type': 'application/json' };
|
|
253
|
+
reqHeaders[WebrpcHeader] = WebrpcHeaderValue;
|
|
254
|
+
return {
|
|
255
|
+
method: 'POST',
|
|
256
|
+
headers: reqHeaders,
|
|
257
|
+
body: JSON.stringify(body || {}),
|
|
258
|
+
signal,
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
const buildResponse = (res) => {
|
|
262
|
+
return res.text().then((text) => {
|
|
263
|
+
let data;
|
|
264
|
+
try {
|
|
265
|
+
data = JSON.parse(text);
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
let message = '';
|
|
269
|
+
if (error instanceof Error) {
|
|
270
|
+
message = error.message;
|
|
271
|
+
}
|
|
272
|
+
throw WebrpcBadResponseError.new({
|
|
273
|
+
status: res.status,
|
|
274
|
+
cause: `JSON.parse(): ${message}: response text: ${text}`,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
if (!res.ok) {
|
|
278
|
+
const code = typeof data.code === 'number' ? data.code : 0;
|
|
279
|
+
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
280
|
+
}
|
|
281
|
+
return data;
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
//
|
|
285
|
+
// Errors
|
|
286
|
+
//
|
|
287
|
+
export class WebrpcError extends Error {
|
|
288
|
+
name;
|
|
289
|
+
code;
|
|
290
|
+
message;
|
|
291
|
+
status;
|
|
292
|
+
cause;
|
|
293
|
+
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
294
|
+
msg;
|
|
295
|
+
constructor(name, code, message, status, cause) {
|
|
296
|
+
super(message);
|
|
297
|
+
this.name = name || 'WebrpcError';
|
|
298
|
+
this.code = typeof code === 'number' ? code : 0;
|
|
299
|
+
this.message = message || `endpoint error ${this.code}`;
|
|
300
|
+
this.msg = this.message;
|
|
301
|
+
this.status = typeof status === 'number' ? status : 0;
|
|
302
|
+
this.cause = cause;
|
|
303
|
+
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
304
|
+
}
|
|
305
|
+
static new(payload) {
|
|
306
|
+
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// Webrpc errors
|
|
310
|
+
export class WebrpcEndpointError extends WebrpcError {
|
|
311
|
+
constructor(name = 'WebrpcEndpoint', code = 0, message = `endpoint error`, status = 0, cause) {
|
|
312
|
+
super(name, code, message, status, cause);
|
|
313
|
+
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
export class WebrpcRequestFailedError extends WebrpcError {
|
|
317
|
+
constructor(name = 'WebrpcRequestFailed', code = -1, message = `request failed`, status = 0, cause) {
|
|
318
|
+
super(name, code, message, status, cause);
|
|
319
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
export class WebrpcBadRouteError extends WebrpcError {
|
|
323
|
+
constructor(name = 'WebrpcBadRoute', code = -2, message = `bad route`, status = 0, cause) {
|
|
324
|
+
super(name, code, message, status, cause);
|
|
325
|
+
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
export class WebrpcBadMethodError extends WebrpcError {
|
|
329
|
+
constructor(name = 'WebrpcBadMethod', code = -3, message = `bad method`, status = 0, cause) {
|
|
330
|
+
super(name, code, message, status, cause);
|
|
331
|
+
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
export class WebrpcBadRequestError extends WebrpcError {
|
|
335
|
+
constructor(name = 'WebrpcBadRequest', code = -4, message = `bad request`, status = 0, cause) {
|
|
336
|
+
super(name, code, message, status, cause);
|
|
337
|
+
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
export class WebrpcBadResponseError extends WebrpcError {
|
|
341
|
+
constructor(name = 'WebrpcBadResponse', code = -5, message = `bad response`, status = 0, cause) {
|
|
342
|
+
super(name, code, message, status, cause);
|
|
343
|
+
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
export class WebrpcServerPanicError extends WebrpcError {
|
|
347
|
+
constructor(name = 'WebrpcServerPanic', code = -6, message = `server panic`, status = 0, cause) {
|
|
348
|
+
super(name, code, message, status, cause);
|
|
349
|
+
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
export class WebrpcInternalErrorError extends WebrpcError {
|
|
353
|
+
constructor(name = 'WebrpcInternalError', code = -7, message = `internal error`, status = 0, cause) {
|
|
354
|
+
super(name, code, message, status, cause);
|
|
355
|
+
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
export class WebrpcClientDisconnectedError extends WebrpcError {
|
|
359
|
+
constructor(name = 'WebrpcClientDisconnected', code = -8, message = `client disconnected`, status = 0, cause) {
|
|
360
|
+
super(name, code, message, status, cause);
|
|
361
|
+
Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
export class WebrpcStreamLostError extends WebrpcError {
|
|
365
|
+
constructor(name = 'WebrpcStreamLost', code = -9, message = `stream lost`, status = 0, cause) {
|
|
366
|
+
super(name, code, message, status, cause);
|
|
367
|
+
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
export class WebrpcStreamFinishedError extends WebrpcError {
|
|
371
|
+
constructor(name = 'WebrpcStreamFinished', code = -10, message = `stream finished`, status = 0, cause) {
|
|
372
|
+
super(name, code, message, status, cause);
|
|
373
|
+
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
// Schema errors
|
|
377
|
+
export class UnauthorizedError extends WebrpcError {
|
|
378
|
+
constructor(name = 'Unauthorized', code = 1000, message = `Unauthorized access`, status = 0, cause) {
|
|
379
|
+
super(name, code, message, status, cause);
|
|
380
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
export class PermissionDeniedError extends WebrpcError {
|
|
384
|
+
constructor(name = 'PermissionDenied', code = 1001, message = `Permission denied`, status = 0, cause) {
|
|
385
|
+
super(name, code, message, status, cause);
|
|
386
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
export class SessionExpiredError extends WebrpcError {
|
|
390
|
+
constructor(name = 'SessionExpired', code = 1002, message = `Session expired`, status = 0, cause) {
|
|
391
|
+
super(name, code, message, status, cause);
|
|
392
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
export class MethodNotFoundError extends WebrpcError {
|
|
396
|
+
constructor(name = 'MethodNotFound', code = 1003, message = `Method not found`, status = 0, cause) {
|
|
397
|
+
super(name, code, message, status, cause);
|
|
398
|
+
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
export class RequestConflictError extends WebrpcError {
|
|
402
|
+
constructor(name = 'RequestConflict', code = 1004, message = `Conflict with target resource`, status = 0, cause) {
|
|
403
|
+
super(name, code, message, status, cause);
|
|
404
|
+
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
export class AbortedError extends WebrpcError {
|
|
408
|
+
constructor(name = 'Aborted', code = 1005, message = `Request aborted`, status = 0, cause) {
|
|
409
|
+
super(name, code, message, status, cause);
|
|
410
|
+
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
export class GeoblockedError extends WebrpcError {
|
|
414
|
+
constructor(name = 'Geoblocked', code = 1006, message = `Geoblocked region`, status = 0, cause) {
|
|
415
|
+
super(name, code, message, status, cause);
|
|
416
|
+
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
export class RateLimitedError extends WebrpcError {
|
|
420
|
+
constructor(name = 'RateLimited', code = 1007, message = `Rate-limited. Please slow down.`, status = 0, cause) {
|
|
421
|
+
super(name, code, message, status, cause);
|
|
422
|
+
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
export class InvalidArgumentError extends WebrpcError {
|
|
426
|
+
constructor(name = 'InvalidArgument', code = 2001, message = `Invalid argument`, status = 0, cause) {
|
|
427
|
+
super(name, code, message, status, cause);
|
|
428
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
export class UnavailableError extends WebrpcError {
|
|
432
|
+
constructor(name = 'Unavailable', code = 2002, message = `Unavailable resource`, status = 0, cause) {
|
|
433
|
+
super(name, code, message, status, cause);
|
|
434
|
+
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
export class QueryFailedError extends WebrpcError {
|
|
438
|
+
constructor(name = 'QueryFailed', code = 2003, message = `Query failed`, status = 0, cause) {
|
|
439
|
+
super(name, code, message, status, cause);
|
|
440
|
+
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
export class ValidationFailedError extends WebrpcError {
|
|
444
|
+
constructor(name = 'ValidationFailed', code = 2004, message = `Validation Failed`, status = 0, cause) {
|
|
445
|
+
super(name, code, message, status, cause);
|
|
446
|
+
Object.setPrototypeOf(this, ValidationFailedError.prototype);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
export class NotFoundError extends WebrpcError {
|
|
450
|
+
constructor(name = 'NotFound', code = 3000, message = `Resource not found`, status = 0, cause) {
|
|
451
|
+
super(name, code, message, status, cause);
|
|
452
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
export class RequiresTOTPError extends WebrpcError {
|
|
456
|
+
constructor(name = 'RequiresTOTP', code = 6600, message = `TOTP is required`, status = 0, cause) {
|
|
457
|
+
super(name, code, message, status, cause);
|
|
458
|
+
Object.setPrototypeOf(this, RequiresTOTPError.prototype);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
export class RequiresPINError extends WebrpcError {
|
|
462
|
+
constructor(name = 'RequiresPIN', code = 6601, message = `PIN is required`, status = 0, cause) {
|
|
463
|
+
super(name, code, message, status, cause);
|
|
464
|
+
Object.setPrototypeOf(this, RequiresPINError.prototype);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
export var errors;
|
|
468
|
+
(function (errors) {
|
|
469
|
+
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
470
|
+
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
471
|
+
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
|
472
|
+
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
|
473
|
+
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
|
474
|
+
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
475
|
+
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
476
|
+
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
477
|
+
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected";
|
|
478
|
+
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
479
|
+
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
480
|
+
errors["Unauthorized"] = "Unauthorized";
|
|
481
|
+
errors["PermissionDenied"] = "PermissionDenied";
|
|
482
|
+
errors["SessionExpired"] = "SessionExpired";
|
|
483
|
+
errors["MethodNotFound"] = "MethodNotFound";
|
|
484
|
+
errors["RequestConflict"] = "RequestConflict";
|
|
485
|
+
errors["Aborted"] = "Aborted";
|
|
486
|
+
errors["Geoblocked"] = "Geoblocked";
|
|
487
|
+
errors["RateLimited"] = "RateLimited";
|
|
488
|
+
errors["InvalidArgument"] = "InvalidArgument";
|
|
489
|
+
errors["Unavailable"] = "Unavailable";
|
|
490
|
+
errors["QueryFailed"] = "QueryFailed";
|
|
491
|
+
errors["ValidationFailed"] = "ValidationFailed";
|
|
492
|
+
errors["NotFound"] = "NotFound";
|
|
493
|
+
errors["RequiresTOTP"] = "RequiresTOTP";
|
|
494
|
+
errors["RequiresPIN"] = "RequiresPIN";
|
|
495
|
+
})(errors || (errors = {}));
|
|
496
|
+
export var WebrpcErrorCodes;
|
|
497
|
+
(function (WebrpcErrorCodes) {
|
|
498
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcEndpoint"] = 0] = "WebrpcEndpoint";
|
|
499
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcRequestFailed"] = -1] = "WebrpcRequestFailed";
|
|
500
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRoute"] = -2] = "WebrpcBadRoute";
|
|
501
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadMethod"] = -3] = "WebrpcBadMethod";
|
|
502
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRequest"] = -4] = "WebrpcBadRequest";
|
|
503
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
|
504
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
|
505
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
|
506
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientDisconnected"] = -8] = "WebrpcClientDisconnected";
|
|
507
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
|
508
|
+
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
|
509
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
|
510
|
+
WebrpcErrorCodes[WebrpcErrorCodes["PermissionDenied"] = 1001] = "PermissionDenied";
|
|
511
|
+
WebrpcErrorCodes[WebrpcErrorCodes["SessionExpired"] = 1002] = "SessionExpired";
|
|
512
|
+
WebrpcErrorCodes[WebrpcErrorCodes["MethodNotFound"] = 1003] = "MethodNotFound";
|
|
513
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RequestConflict"] = 1004] = "RequestConflict";
|
|
514
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Aborted"] = 1005] = "Aborted";
|
|
515
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Geoblocked"] = 1006] = "Geoblocked";
|
|
516
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RateLimited"] = 1007] = "RateLimited";
|
|
517
|
+
WebrpcErrorCodes[WebrpcErrorCodes["InvalidArgument"] = 2001] = "InvalidArgument";
|
|
518
|
+
WebrpcErrorCodes[WebrpcErrorCodes["Unavailable"] = 2002] = "Unavailable";
|
|
519
|
+
WebrpcErrorCodes[WebrpcErrorCodes["QueryFailed"] = 2003] = "QueryFailed";
|
|
520
|
+
WebrpcErrorCodes[WebrpcErrorCodes["ValidationFailed"] = 2004] = "ValidationFailed";
|
|
521
|
+
WebrpcErrorCodes[WebrpcErrorCodes["NotFound"] = 3000] = "NotFound";
|
|
522
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RequiresTOTP"] = 6600] = "RequiresTOTP";
|
|
523
|
+
WebrpcErrorCodes[WebrpcErrorCodes["RequiresPIN"] = 6601] = "RequiresPIN";
|
|
524
|
+
})(WebrpcErrorCodes || (WebrpcErrorCodes = {}));
|
|
525
|
+
export const webrpcErrorByCode = {
|
|
526
|
+
[0]: WebrpcEndpointError,
|
|
527
|
+
[-1]: WebrpcRequestFailedError,
|
|
528
|
+
[-2]: WebrpcBadRouteError,
|
|
529
|
+
[-3]: WebrpcBadMethodError,
|
|
530
|
+
[-4]: WebrpcBadRequestError,
|
|
531
|
+
[-5]: WebrpcBadResponseError,
|
|
532
|
+
[-6]: WebrpcServerPanicError,
|
|
533
|
+
[-7]: WebrpcInternalErrorError,
|
|
534
|
+
[-8]: WebrpcClientDisconnectedError,
|
|
535
|
+
[-9]: WebrpcStreamLostError,
|
|
536
|
+
[-10]: WebrpcStreamFinishedError,
|
|
537
|
+
[1000]: UnauthorizedError,
|
|
538
|
+
[1001]: PermissionDeniedError,
|
|
539
|
+
[1002]: SessionExpiredError,
|
|
540
|
+
[1003]: MethodNotFoundError,
|
|
541
|
+
[1004]: RequestConflictError,
|
|
542
|
+
[1005]: AbortedError,
|
|
543
|
+
[1006]: GeoblockedError,
|
|
544
|
+
[1007]: RateLimitedError,
|
|
545
|
+
[2001]: InvalidArgumentError,
|
|
546
|
+
[2002]: UnavailableError,
|
|
547
|
+
[2003]: QueryFailedError,
|
|
548
|
+
[2004]: ValidationFailedError,
|
|
549
|
+
[3000]: NotFoundError,
|
|
550
|
+
[6600]: RequiresTOTPError,
|
|
551
|
+
[6601]: RequiresPINError,
|
|
552
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export { PayloadType, SignatureType, type Signature } from './client/guard.gen.js';
|
|
3
|
+
export * as Client from './client/guard.gen.js';
|
|
4
|
+
export * as Sequence from './sequence.js';
|
|
5
|
+
export * as Local from './local.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAElF,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAA;AAC/C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
package/dist/local.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Address, Hex, Bytes } from 'ox';
|
|
2
|
+
import * as Client from './client/guard.gen.js';
|
|
3
|
+
import * as Types from './types.js';
|
|
4
|
+
export declare class Guard implements Types.Guard {
|
|
5
|
+
private readonly privateKey;
|
|
6
|
+
readonly address: Address.Address;
|
|
7
|
+
constructor(privateKey: Hex.Hex);
|
|
8
|
+
signPayload(wallet: Address.Address, chainId: number, type: Client.PayloadType, digest: Bytes.Bytes, message: Bytes.Bytes, signatures?: Client.Signature[]): Promise<{
|
|
9
|
+
r: bigint;
|
|
10
|
+
s: bigint;
|
|
11
|
+
yParity: number;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAmB,MAAM,IAAI,CAAA;AACzD,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC,qBAAa,KAAM,YAAW,KAAK,CAAC,KAAK;IAG3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,SAAgB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAA;gBAEX,UAAU,EAAE,GAAG,CAAC,GAAG;IAK1C,WAAW,CACf,MAAM,EAAE,OAAO,CAAC,OAAO,EACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,WAAW,EACxB,MAAM,EAAE,KAAK,CAAC,KAAK,EACnB,OAAO,EAAE,KAAK,CAAC,KAAK,EACpB,UAAU,CAAC,EAAE,MAAM,CAAC,SAAS,EAAE;;;;;CAIlC"}
|
package/dist/local.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Address, Secp256k1 } from 'ox';
|
|
2
|
+
export class Guard {
|
|
3
|
+
privateKey;
|
|
4
|
+
address;
|
|
5
|
+
constructor(privateKey) {
|
|
6
|
+
this.privateKey = privateKey;
|
|
7
|
+
const publicKey = Secp256k1.getPublicKey({ privateKey: this.privateKey });
|
|
8
|
+
this.address = Address.fromPublicKey(publicKey);
|
|
9
|
+
}
|
|
10
|
+
async signPayload(wallet, chainId, type, digest, message, signatures) {
|
|
11
|
+
return Secp256k1.sign({ privateKey: this.privateKey, payload: digest });
|
|
12
|
+
}
|
|
13
|
+
}
|