@0xsequence/guard 2.3.17 → 2.3.19

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.
@@ -1,382 +0,0 @@
1
- export declare const WebrpcHeader = "Webrpc";
2
- export declare const WebrpcHeaderValue = "webrpc@v0.25.3;gen-typescript@v0.17.0;sequence-guard@v0.4.0";
3
- export declare const WebRPCVersion = "v1";
4
- export declare const WebRPCSchemaVersion = "v0.4.0";
5
- export declare const WebRPCSchemaHash = "776b307c2145ac7a994eec63240acae042c96067";
6
- type WebrpcGenVersions = {
7
- webrpcGenVersion: string;
8
- codeGenName: string;
9
- codeGenVersion: string;
10
- schemaName: string;
11
- schemaVersion: string;
12
- };
13
- export declare function VersionFromHeader(headers: Headers): WebrpcGenVersions;
14
- export interface Version {
15
- webrpcVersion: string;
16
- schemaVersion: string;
17
- schemaHash: string;
18
- appVersion: string;
19
- }
20
- export interface RuntimeStatus {
21
- healthOK: boolean;
22
- startTime: string;
23
- uptime: number;
24
- ver: string;
25
- branch: string;
26
- commitHash: string;
27
- }
28
- export interface WalletConfig {
29
- address: string;
30
- content: string;
31
- }
32
- export interface WalletSigner {
33
- address: string;
34
- weight: number;
35
- }
36
- export interface SignRequest {
37
- chainId: number;
38
- msg: string;
39
- auxData: string;
40
- }
41
- export interface OwnershipProof {
42
- wallet: string;
43
- timestamp: number;
44
- signer: string;
45
- signature: string;
46
- }
47
- export interface AuthToken {
48
- id: string;
49
- token: string;
50
- }
51
- export interface RecoveryCode {
52
- code: string;
53
- used: boolean;
54
- }
55
- export interface Guard {
56
- ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>;
57
- version(headers?: object, signal?: AbortSignal): Promise<VersionReturn>;
58
- runtimeStatus(headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn>;
59
- getSignerConfig(args: GetSignerConfigArgs, headers?: object, signal?: AbortSignal): Promise<GetSignerConfigReturn>;
60
- /**
61
- * Called by sequence.app when the user signs in, and signs messages/transactions/migrations.
62
- * Requires a valid 2FA token if enabled.
63
- */
64
- sign(args: SignArgs, headers?: object, signal?: AbortSignal): Promise<SignReturn>;
65
- signWith(args: SignWithArgs, headers?: object, signal?: AbortSignal): Promise<SignWithReturn>;
66
- /**
67
- * Internal use only.
68
- * Only ever needs to be called once per chain.
69
- * Signs a preconfigured payload that the caller has no control over.
70
- */
71
- patch(args: PatchArgs, headers?: object, signal?: AbortSignal): Promise<PatchReturn>;
72
- /**
73
- * Called by sequence.app when it needs to check the user's 2FA.
74
- * This happens during sign in, before signing messages and transactions, and when configuring 2FA.
75
- * Requires either a valid JWT or a signature by one of the wallet's signers.
76
- */
77
- authMethods(args: AuthMethodsArgs, headers?: object, signal?: AbortSignal): Promise<AuthMethodsReturn>;
78
- /**
79
- * Not currently called. Requires both a JWT and a wallet signature.
80
- */
81
- setPIN(args: SetPINArgs, headers?: object, signal?: AbortSignal): Promise<SetPINReturn>;
82
- /**
83
- * Not currently called. Requires both a JWT and a wallet signature.
84
- */
85
- resetPIN(args: ResetPINArgs, headers?: object, signal?: AbortSignal): Promise<ResetPINReturn>;
86
- /**
87
- * Called by sequence.app when the user configures their 2FA.
88
- * Requires both a JWT and a wallet signature.
89
- */
90
- createTOTP(args: CreateTOTPArgs, headers?: object, signal?: AbortSignal): Promise<CreateTOTPReturn>;
91
- /**
92
- * Called by sequence.app when the user configures their 2FA.
93
- * Requires both a JWT and a wallet signature.
94
- */
95
- commitTOTP(args: CommitTOTPArgs, headers?: object, signal?: AbortSignal): Promise<CommitTOTPReturn>;
96
- /**
97
- * Called by sequence.app when the user configures their 2FA.
98
- * Requires both a JWT and a wallet signature.
99
- */
100
- resetTOTP(args: ResetTOTPArgs, headers?: object, signal?: AbortSignal): Promise<ResetTOTPReturn>;
101
- /**
102
- * Called by sequence.app when the user uses a recovery code.
103
- * Requires either a valid JWT or a signature by one of the wallet's signers.
104
- */
105
- reset2FA(args: Reset2FAArgs, headers?: object, signal?: AbortSignal): Promise<Reset2FAReturn>;
106
- /**
107
- * Called by sequence.app when the user is viewing their recovery codes.
108
- * Requires both a JWT and a wallet signature.
109
- */
110
- recoveryCodes(args: RecoveryCodesArgs, headers?: object, signal?: AbortSignal): Promise<RecoveryCodesReturn>;
111
- /**
112
- * Called by sequence.app when the user is viewing their recovery codes.
113
- * Requires both a JWT and a wallet signature.
114
- */
115
- resetRecoveryCodes(args: ResetRecoveryCodesArgs, headers?: object, signal?: AbortSignal): Promise<ResetRecoveryCodesReturn>;
116
- }
117
- export interface PingArgs {
118
- }
119
- export interface PingReturn {
120
- status: boolean;
121
- }
122
- export interface VersionArgs {
123
- }
124
- export interface VersionReturn {
125
- version: Version;
126
- }
127
- export interface RuntimeStatusArgs {
128
- }
129
- export interface RuntimeStatusReturn {
130
- status: RuntimeStatus;
131
- }
132
- export interface GetSignerConfigArgs {
133
- signer: string;
134
- }
135
- export interface GetSignerConfigReturn {
136
- signerConfig: WalletConfig;
137
- }
138
- export interface SignArgs {
139
- request: SignRequest;
140
- token?: AuthToken;
141
- }
142
- export interface SignReturn {
143
- sig: string;
144
- }
145
- export interface SignWithArgs {
146
- signer: string;
147
- request: SignRequest;
148
- token?: AuthToken;
149
- }
150
- export interface SignWithReturn {
151
- sig: string;
152
- }
153
- export interface PatchArgs {
154
- signer: string;
155
- chainId: number;
156
- secret: string;
157
- }
158
- export interface PatchReturn {
159
- txs: any;
160
- }
161
- export interface AuthMethodsArgs {
162
- proof?: OwnershipProof;
163
- }
164
- export interface AuthMethodsReturn {
165
- methods: Array<string>;
166
- active: boolean;
167
- }
168
- export interface SetPINArgs {
169
- pin: string;
170
- timestamp: number;
171
- signature: string;
172
- }
173
- export interface SetPINReturn {
174
- }
175
- export interface ResetPINArgs {
176
- timestamp: number;
177
- signature: string;
178
- }
179
- export interface ResetPINReturn {
180
- }
181
- export interface CreateTOTPArgs {
182
- timestamp: number;
183
- signature: string;
184
- }
185
- export interface CreateTOTPReturn {
186
- uri: string;
187
- }
188
- export interface CommitTOTPArgs {
189
- token: string;
190
- }
191
- export interface CommitTOTPReturn {
192
- codes: Array<RecoveryCode>;
193
- }
194
- export interface ResetTOTPArgs {
195
- timestamp: number;
196
- signature: string;
197
- }
198
- export interface ResetTOTPReturn {
199
- }
200
- export interface Reset2FAArgs {
201
- code: string;
202
- proof?: OwnershipProof;
203
- }
204
- export interface Reset2FAReturn {
205
- }
206
- export interface RecoveryCodesArgs {
207
- timestamp: number;
208
- signature: string;
209
- }
210
- export interface RecoveryCodesReturn {
211
- codes: Array<RecoveryCode>;
212
- }
213
- export interface ResetRecoveryCodesArgs {
214
- timestamp: number;
215
- signature: string;
216
- }
217
- export interface ResetRecoveryCodesReturn {
218
- codes: Array<RecoveryCode>;
219
- }
220
- export declare class Guard implements Guard {
221
- protected hostname: string;
222
- protected fetch: Fetch;
223
- protected path: string;
224
- constructor(hostname: string, fetch: Fetch);
225
- private url;
226
- ping: (headers?: object, signal?: AbortSignal) => Promise<PingReturn>;
227
- version: (headers?: object, signal?: AbortSignal) => Promise<VersionReturn>;
228
- runtimeStatus: (headers?: object, signal?: AbortSignal) => Promise<RuntimeStatusReturn>;
229
- getSignerConfig: (args: GetSignerConfigArgs, headers?: object, signal?: AbortSignal) => Promise<GetSignerConfigReturn>;
230
- sign: (args: SignArgs, headers?: object, signal?: AbortSignal) => Promise<SignReturn>;
231
- signWith: (args: SignWithArgs, headers?: object, signal?: AbortSignal) => Promise<SignWithReturn>;
232
- patch: (args: PatchArgs, headers?: object, signal?: AbortSignal) => Promise<PatchReturn>;
233
- authMethods: (args: AuthMethodsArgs, headers?: object, signal?: AbortSignal) => Promise<AuthMethodsReturn>;
234
- setPIN: (args: SetPINArgs, headers?: object, signal?: AbortSignal) => Promise<SetPINReturn>;
235
- resetPIN: (args: ResetPINArgs, headers?: object, signal?: AbortSignal) => Promise<ResetPINReturn>;
236
- createTOTP: (args: CreateTOTPArgs, headers?: object, signal?: AbortSignal) => Promise<CreateTOTPReturn>;
237
- commitTOTP: (args: CommitTOTPArgs, headers?: object, signal?: AbortSignal) => Promise<CommitTOTPReturn>;
238
- resetTOTP: (args: ResetTOTPArgs, headers?: object, signal?: AbortSignal) => Promise<ResetTOTPReturn>;
239
- reset2FA: (args: Reset2FAArgs, headers?: object, signal?: AbortSignal) => Promise<Reset2FAReturn>;
240
- recoveryCodes: (args: RecoveryCodesArgs, headers?: object, signal?: AbortSignal) => Promise<RecoveryCodesReturn>;
241
- resetRecoveryCodes: (args: ResetRecoveryCodesArgs, headers?: object, signal?: AbortSignal) => Promise<ResetRecoveryCodesReturn>;
242
- }
243
- export declare class WebrpcError extends Error {
244
- name: string;
245
- code: number;
246
- message: string;
247
- status: number;
248
- cause?: string;
249
- /** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
250
- msg: string;
251
- constructor(name: string, code: number, message: string, status: number, cause?: string);
252
- static new(payload: any): WebrpcError;
253
- }
254
- export declare class WebrpcEndpointError extends WebrpcError {
255
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
256
- }
257
- export declare class WebrpcRequestFailedError extends WebrpcError {
258
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
259
- }
260
- export declare class WebrpcBadRouteError extends WebrpcError {
261
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
262
- }
263
- export declare class WebrpcBadMethodError extends WebrpcError {
264
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
265
- }
266
- export declare class WebrpcBadRequestError extends WebrpcError {
267
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
268
- }
269
- export declare class WebrpcBadResponseError extends WebrpcError {
270
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
271
- }
272
- export declare class WebrpcServerPanicError extends WebrpcError {
273
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
274
- }
275
- export declare class WebrpcInternalErrorError extends WebrpcError {
276
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
277
- }
278
- export declare class WebrpcClientDisconnectedError extends WebrpcError {
279
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
280
- }
281
- export declare class WebrpcStreamLostError extends WebrpcError {
282
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
283
- }
284
- export declare class WebrpcStreamFinishedError extends WebrpcError {
285
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
286
- }
287
- export declare class UnauthorizedError extends WebrpcError {
288
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
289
- }
290
- export declare class PermissionDeniedError extends WebrpcError {
291
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
292
- }
293
- export declare class SessionExpiredError extends WebrpcError {
294
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
295
- }
296
- export declare class MethodNotFoundError extends WebrpcError {
297
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
298
- }
299
- export declare class RequestConflictError extends WebrpcError {
300
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
301
- }
302
- export declare class AbortedError extends WebrpcError {
303
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
304
- }
305
- export declare class GeoblockedError extends WebrpcError {
306
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
307
- }
308
- export declare class RateLimitedError extends WebrpcError {
309
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
310
- }
311
- export declare class InvalidArgumentError extends WebrpcError {
312
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
313
- }
314
- export declare class UnavailableError extends WebrpcError {
315
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
316
- }
317
- export declare class QueryFailedError extends WebrpcError {
318
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
319
- }
320
- export declare class ValidationFailedError extends WebrpcError {
321
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
322
- }
323
- export declare class NotFoundError extends WebrpcError {
324
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
325
- }
326
- export declare enum errors {
327
- WebrpcEndpoint = "WebrpcEndpoint",
328
- WebrpcRequestFailed = "WebrpcRequestFailed",
329
- WebrpcBadRoute = "WebrpcBadRoute",
330
- WebrpcBadMethod = "WebrpcBadMethod",
331
- WebrpcBadRequest = "WebrpcBadRequest",
332
- WebrpcBadResponse = "WebrpcBadResponse",
333
- WebrpcServerPanic = "WebrpcServerPanic",
334
- WebrpcInternalError = "WebrpcInternalError",
335
- WebrpcClientDisconnected = "WebrpcClientDisconnected",
336
- WebrpcStreamLost = "WebrpcStreamLost",
337
- WebrpcStreamFinished = "WebrpcStreamFinished",
338
- Unauthorized = "Unauthorized",
339
- PermissionDenied = "PermissionDenied",
340
- SessionExpired = "SessionExpired",
341
- MethodNotFound = "MethodNotFound",
342
- RequestConflict = "RequestConflict",
343
- Aborted = "Aborted",
344
- Geoblocked = "Geoblocked",
345
- RateLimited = "RateLimited",
346
- InvalidArgument = "InvalidArgument",
347
- Unavailable = "Unavailable",
348
- QueryFailed = "QueryFailed",
349
- ValidationFailed = "ValidationFailed",
350
- NotFound = "NotFound"
351
- }
352
- export declare enum WebrpcErrorCodes {
353
- WebrpcEndpoint = 0,
354
- WebrpcRequestFailed = -1,
355
- WebrpcBadRoute = -2,
356
- WebrpcBadMethod = -3,
357
- WebrpcBadRequest = -4,
358
- WebrpcBadResponse = -5,
359
- WebrpcServerPanic = -6,
360
- WebrpcInternalError = -7,
361
- WebrpcClientDisconnected = -8,
362
- WebrpcStreamLost = -9,
363
- WebrpcStreamFinished = -10,
364
- Unauthorized = 1000,
365
- PermissionDenied = 1001,
366
- SessionExpired = 1002,
367
- MethodNotFound = 1003,
368
- RequestConflict = 1004,
369
- Aborted = 1005,
370
- Geoblocked = 1006,
371
- RateLimited = 1007,
372
- InvalidArgument = 2001,
373
- Unavailable = 2002,
374
- QueryFailed = 2003,
375
- ValidationFailed = 2004,
376
- NotFound = 3000
377
- }
378
- export declare const webrpcErrorByCode: {
379
- [code: number]: any;
380
- };
381
- export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
382
- export {};
@@ -1,2 +0,0 @@
1
- export { Guard } from "./guard.gen.js";
2
- export * from "./signer.js";
@@ -1,66 +0,0 @@
1
- import { Account } from '@0xsequence/account';
2
- import { commons } from '@0xsequence/core';
3
- import { signers, Status } from '@0xsequence/signhub';
4
- import { TypedData } from '@0xsequence/utils';
5
- import { ethers } from 'ethers';
6
- import { RecoveryCode as GuardRecoveryCode } from "./guard.gen.js";
7
- export declare class GuardSigner implements signers.SapientSigner {
8
- readonly address: string;
9
- readonly url: string;
10
- readonly appendSuffix: boolean;
11
- readonly projectAccessKey?: string | undefined;
12
- private guard;
13
- constructor(address: string, url: string, appendSuffix?: boolean, projectAccessKey?: string | undefined);
14
- _fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
15
- getAddress(): Promise<string>;
16
- buildDeployTransaction(_metadata: object): Promise<commons.transaction.TransactionBundle | undefined>;
17
- predecorateSignedTransactions(_metadata: object): Promise<commons.transaction.SignedTransactionBundle[]>;
18
- decorateTransactions(bundle: commons.transaction.IntendedTransactionBundle, _metadata: object): Promise<commons.transaction.IntendedTransactionBundle>;
19
- sign(message: ethers.BytesLike, metadata: object): Promise<ethers.BytesLike>;
20
- notifyStatusChange(_id: string, _status: Status, _metadata: object): void;
21
- getAuthMethods(proof: OwnershipProof): Promise<{
22
- methods: AuthMethod[];
23
- active: boolean;
24
- }>;
25
- setPin(pin: string | undefined, proof: AuthUpdateProof): Promise<void>;
26
- resetPin(proof: AuthUpdateProof): Promise<void>;
27
- createTotp(proof: AuthUpdateProof): Promise<URL>;
28
- commitTotp(token: string, jwt: string): Promise<RecoveryCode[]>;
29
- resetTotp(proof: AuthUpdateProof): Promise<void>;
30
- reset2fa(recoveryCode: string, proof: OwnershipProof): Promise<void>;
31
- getRecoveryCodes(proof: AuthUpdateProof): Promise<RecoveryCode[]>;
32
- resetRecoveryCodes(proof: AuthUpdateProof): Promise<RecoveryCode[]>;
33
- private packMsgAndSig;
34
- suffix(): ethers.BytesLike;
35
- }
36
- export type RecoveryCode = GuardRecoveryCode;
37
- export declare enum AuthMethod {
38
- PIN = "PIN",
39
- TOTP = "TOTP"
40
- }
41
- export type SignedOwnershipProof = {
42
- walletAddress: string;
43
- timestamp: Date;
44
- signerAddress: string;
45
- signature: string;
46
- };
47
- export type OwnershipProof = SignedOwnershipProof | {
48
- jwt: string;
49
- } | {
50
- walletAddress: string;
51
- signer: ethers.Signer | signers.SapientSigner;
52
- };
53
- export declare function isSignedOwnershipProof(proof: OwnershipProof): proof is SignedOwnershipProof;
54
- export declare function signOwnershipProof(proof: Exclude<OwnershipProof, {
55
- jwt: string;
56
- }>): Promise<SignedOwnershipProof>;
57
- export type AuthUpdateProof = {
58
- jwt: string;
59
- } & ({
60
- timestamp: Date;
61
- signature: string;
62
- } | {
63
- wallet: Account;
64
- });
65
- export declare function getOwnershipProofTypedData(wallet: string, timestamp: Date): TypedData;
66
- export declare function getAuthUpdateProofTypedData(timestamp: Date): TypedData;