@0xsequence/guard 2.3.35 → 3.0.0-beta.2

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,5 +1,5 @@
1
1
  /* eslint-disable */
2
- // sequence-guard v0.4.0 776b307c2145ac7a994eec63240acae042c96067
2
+ // sequence-guard v0.5.0 910e01c32ffb24b42386d4ca6be119b0acc55c5f
3
3
  // --
4
4
  // Code generated by webrpc-gen@v0.25.3 with typescript generator. DO NOT EDIT.
5
5
  //
@@ -7,16 +7,16 @@
7
7
 
8
8
  export const WebrpcHeader = 'Webrpc'
9
9
 
10
- export const WebrpcHeaderValue = 'webrpc@v0.25.3;gen-typescript@v0.17.0;sequence-guard@v0.4.0'
10
+ export const WebrpcHeaderValue = 'webrpc@v0.25.3;gen-typescript@v0.17.0;sequence-guard@v0.5.0'
11
11
 
12
12
  // WebRPC description and code-gen version
13
13
  export const WebRPCVersion = 'v1'
14
14
 
15
15
  // Schema version of your RIDL schema
16
- export const WebRPCSchemaVersion = 'v0.4.0'
16
+ export const WebRPCSchemaVersion = 'v0.5.0'
17
17
 
18
18
  // Schema hash generated from your RIDL schema
19
- export const WebRPCSchemaHash = '776b307c2145ac7a994eec63240acae042c96067'
19
+ export const WebRPCSchemaHash = '910e01c32ffb24b42386d4ca6be119b0acc55c5f'
20
20
 
21
21
  type WebrpcGenVersions = {
22
22
  webrpcGenVersion: string
@@ -34,7 +34,7 @@ export function VersionFromHeader(headers: Headers): WebrpcGenVersions {
34
34
  codeGenName: '',
35
35
  codeGenVersion: '',
36
36
  schemaName: '',
37
- schemaVersion: ''
37
+ schemaVersion: '',
38
38
  }
39
39
  }
40
40
 
@@ -49,7 +49,7 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
49
49
  codeGenName: '',
50
50
  codeGenVersion: '',
51
51
  schemaName: '',
52
- schemaVersion: ''
52
+ schemaVersion: '',
53
53
  }
54
54
  }
55
55
 
@@ -62,7 +62,7 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
62
62
  codeGenName: codeGenName ?? '',
63
63
  codeGenVersion: codeGenVersion ?? '',
64
64
  schemaName: schemaName ?? '',
65
- schemaVersion: schemaVersion ?? ''
65
+ schemaVersion: schemaVersion ?? '',
66
66
  }
67
67
  }
68
68
 
@@ -70,6 +70,20 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions {
70
70
  // Types
71
71
  //
72
72
 
73
+ export enum PayloadType {
74
+ Calls = 'Calls',
75
+ Message = 'Message',
76
+ ConfigUpdate = 'ConfigUpdate',
77
+ SessionImplicitAuthorize = 'SessionImplicitAuthorize',
78
+ }
79
+
80
+ export enum SignatureType {
81
+ Hash = 'Hash',
82
+ Sapient = 'Sapient',
83
+ EthSign = 'EthSign',
84
+ Erc1271 = 'Erc1271',
85
+ }
86
+
73
87
  export interface Version {
74
88
  webrpcVersion: string
75
89
  schemaVersion: string
@@ -99,7 +113,11 @@ export interface WalletSigner {
99
113
  export interface SignRequest {
100
114
  chainId: number
101
115
  msg: string
102
- auxData: string
116
+ auxData?: string
117
+ wallet?: string
118
+ payloadType?: PayloadType
119
+ payloadData?: string
120
+ signatures?: Array<Signature>
103
121
  }
104
122
 
105
123
  export interface OwnershipProof {
@@ -107,11 +125,13 @@ export interface OwnershipProof {
107
125
  timestamp: number
108
126
  signer: string
109
127
  signature: string
128
+ chainId: number
110
129
  }
111
130
 
112
131
  export interface AuthToken {
113
132
  id: string
114
133
  token: string
134
+ resetAuth?: boolean
115
135
  }
116
136
 
117
137
  export interface RecoveryCode {
@@ -119,6 +139,13 @@ export interface RecoveryCode {
119
139
  used: boolean
120
140
  }
121
141
 
142
+ export interface Signature {
143
+ address: string
144
+ type: SignatureType
145
+ imageHash?: string
146
+ data: string
147
+ }
148
+
122
149
  export interface Guard {
123
150
  ping(headers?: object, signal?: AbortSignal): Promise<PingReturn>
124
151
  version(headers?: object, signal?: AbortSignal): Promise<VersionReturn>
@@ -179,7 +206,11 @@ export interface Guard {
179
206
  * Called by sequence.app when the user is viewing their recovery codes.
180
207
  * Requires both a JWT and a wallet signature.
181
208
  */
182
- resetRecoveryCodes(args: ResetRecoveryCodesArgs, headers?: object, signal?: AbortSignal): Promise<ResetRecoveryCodesReturn>
209
+ resetRecoveryCodes(
210
+ args: ResetRecoveryCodesArgs,
211
+ headers?: object,
212
+ signal?: AbortSignal,
213
+ ): Promise<ResetRecoveryCodesReturn>
183
214
  }
184
215
 
185
216
  export interface PingArgs {}
@@ -242,18 +273,21 @@ export interface SetPINArgs {
242
273
  pin: string
243
274
  timestamp: number
244
275
  signature: string
276
+ chainId: number
245
277
  }
246
278
 
247
279
  export interface SetPINReturn {}
248
280
  export interface ResetPINArgs {
249
281
  timestamp: number
250
282
  signature: string
283
+ chainId: number
251
284
  }
252
285
 
253
286
  export interface ResetPINReturn {}
254
287
  export interface CreateTOTPArgs {
255
288
  timestamp: number
256
289
  signature: string
290
+ chainId: number
257
291
  }
258
292
 
259
293
  export interface CreateTOTPReturn {
@@ -269,6 +303,7 @@ export interface CommitTOTPReturn {
269
303
  export interface ResetTOTPArgs {
270
304
  timestamp: number
271
305
  signature: string
306
+ chainId: number
272
307
  }
273
308
 
274
309
  export interface ResetTOTPReturn {}
@@ -281,6 +316,7 @@ export interface Reset2FAReturn {}
281
316
  export interface RecoveryCodesArgs {
282
317
  timestamp: number
283
318
  signature: string
319
+ chainId: number
284
320
  }
285
321
 
286
322
  export interface RecoveryCodesReturn {
@@ -289,6 +325,7 @@ export interface RecoveryCodesReturn {
289
325
  export interface ResetRecoveryCodesArgs {
290
326
  timestamp: number
291
327
  signature: string
328
+ chainId: number
292
329
  }
293
330
 
294
331
  export interface ResetRecoveryCodesReturn {
@@ -314,238 +351,242 @@ export class Guard implements Guard {
314
351
 
315
352
  ping = (headers?: object, signal?: AbortSignal): Promise<PingReturn> => {
316
353
  return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(
317
- res => {
318
- return buildResponse(res).then(_data => {
354
+ (res) => {
355
+ return buildResponse(res).then((_data) => {
319
356
  return {
320
- status: <boolean>_data.status
357
+ status: <boolean>_data.status,
321
358
  }
322
359
  })
323
360
  },
324
- error => {
361
+ (error) => {
325
362
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
326
- }
363
+ },
327
364
  )
328
365
  }
329
366
 
330
367
  version = (headers?: object, signal?: AbortSignal): Promise<VersionReturn> => {
331
368
  return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(
332
- res => {
333
- return buildResponse(res).then(_data => {
369
+ (res) => {
370
+ return buildResponse(res).then((_data) => {
334
371
  return {
335
- version: <Version>_data.version
372
+ version: <Version>_data.version,
336
373
  }
337
374
  })
338
375
  },
339
- error => {
376
+ (error) => {
340
377
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
341
- }
378
+ },
342
379
  )
343
380
  }
344
381
 
345
382
  runtimeStatus = (headers?: object, signal?: AbortSignal): Promise<RuntimeStatusReturn> => {
346
383
  return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(
347
- res => {
348
- return buildResponse(res).then(_data => {
384
+ (res) => {
385
+ return buildResponse(res).then((_data) => {
349
386
  return {
350
- status: <RuntimeStatus>_data.status
387
+ status: <RuntimeStatus>_data.status,
351
388
  }
352
389
  })
353
390
  },
354
- error => {
391
+ (error) => {
355
392
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
356
- }
393
+ },
357
394
  )
358
395
  }
359
396
 
360
- getSignerConfig = (args: GetSignerConfigArgs, headers?: object, signal?: AbortSignal): Promise<GetSignerConfigReturn> => {
397
+ getSignerConfig = (
398
+ args: GetSignerConfigArgs,
399
+ headers?: object,
400
+ signal?: AbortSignal,
401
+ ): Promise<GetSignerConfigReturn> => {
361
402
  return this.fetch(this.url('GetSignerConfig'), createHTTPRequest(args, headers, signal)).then(
362
- res => {
363
- return buildResponse(res).then(_data => {
403
+ (res) => {
404
+ return buildResponse(res).then((_data) => {
364
405
  return {
365
- signerConfig: <WalletConfig>_data.signerConfig
406
+ signerConfig: <WalletConfig>_data.signerConfig,
366
407
  }
367
408
  })
368
409
  },
369
- error => {
410
+ (error) => {
370
411
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
371
- }
412
+ },
372
413
  )
373
414
  }
374
415
 
375
416
  sign = (args: SignArgs, headers?: object, signal?: AbortSignal): Promise<SignReturn> => {
376
417
  return this.fetch(this.url('Sign'), createHTTPRequest(args, headers, signal)).then(
377
- res => {
378
- return buildResponse(res).then(_data => {
418
+ (res) => {
419
+ return buildResponse(res).then((_data) => {
379
420
  return {
380
- sig: <string>_data.sig
421
+ sig: <string>_data.sig,
381
422
  }
382
423
  })
383
424
  },
384
- error => {
425
+ (error) => {
385
426
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
386
- }
427
+ },
387
428
  )
388
429
  }
389
430
 
390
431
  signWith = (args: SignWithArgs, headers?: object, signal?: AbortSignal): Promise<SignWithReturn> => {
391
432
  return this.fetch(this.url('SignWith'), createHTTPRequest(args, headers, signal)).then(
392
- res => {
393
- return buildResponse(res).then(_data => {
433
+ (res) => {
434
+ return buildResponse(res).then((_data) => {
394
435
  return {
395
- sig: <string>_data.sig
436
+ sig: <string>_data.sig,
396
437
  }
397
438
  })
398
439
  },
399
- error => {
440
+ (error) => {
400
441
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
401
- }
442
+ },
402
443
  )
403
444
  }
404
445
 
405
446
  patch = (args: PatchArgs, headers?: object, signal?: AbortSignal): Promise<PatchReturn> => {
406
447
  return this.fetch(this.url('Patch'), createHTTPRequest(args, headers, signal)).then(
407
- res => {
408
- return buildResponse(res).then(_data => {
448
+ (res) => {
449
+ return buildResponse(res).then((_data) => {
409
450
  return {
410
- txs: <any>_data.txs
451
+ txs: <any>_data.txs,
411
452
  }
412
453
  })
413
454
  },
414
- error => {
455
+ (error) => {
415
456
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
416
- }
457
+ },
417
458
  )
418
459
  }
419
460
 
420
461
  authMethods = (args: AuthMethodsArgs, headers?: object, signal?: AbortSignal): Promise<AuthMethodsReturn> => {
421
462
  return this.fetch(this.url('AuthMethods'), createHTTPRequest(args, headers, signal)).then(
422
- res => {
423
- return buildResponse(res).then(_data => {
463
+ (res) => {
464
+ return buildResponse(res).then((_data) => {
424
465
  return {
425
466
  methods: <Array<string>>_data.methods,
426
- active: <boolean>_data.active
467
+ active: <boolean>_data.active,
427
468
  }
428
469
  })
429
470
  },
430
- error => {
471
+ (error) => {
431
472
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
432
- }
473
+ },
433
474
  )
434
475
  }
435
476
 
436
477
  setPIN = (args: SetPINArgs, headers?: object, signal?: AbortSignal): Promise<SetPINReturn> => {
437
478
  return this.fetch(this.url('SetPIN'), createHTTPRequest(args, headers, signal)).then(
438
- res => {
439
- return buildResponse(res).then(_data => {
479
+ (res) => {
480
+ return buildResponse(res).then((_data) => {
440
481
  return {}
441
482
  })
442
483
  },
443
- error => {
484
+ (error) => {
444
485
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
445
- }
486
+ },
446
487
  )
447
488
  }
448
489
 
449
490
  resetPIN = (args: ResetPINArgs, headers?: object, signal?: AbortSignal): Promise<ResetPINReturn> => {
450
491
  return this.fetch(this.url('ResetPIN'), createHTTPRequest(args, headers, signal)).then(
451
- res => {
452
- return buildResponse(res).then(_data => {
492
+ (res) => {
493
+ return buildResponse(res).then((_data) => {
453
494
  return {}
454
495
  })
455
496
  },
456
- error => {
497
+ (error) => {
457
498
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
458
- }
499
+ },
459
500
  )
460
501
  }
461
502
 
462
503
  createTOTP = (args: CreateTOTPArgs, headers?: object, signal?: AbortSignal): Promise<CreateTOTPReturn> => {
463
504
  return this.fetch(this.url('CreateTOTP'), createHTTPRequest(args, headers, signal)).then(
464
- res => {
465
- return buildResponse(res).then(_data => {
505
+ (res) => {
506
+ return buildResponse(res).then((_data) => {
466
507
  return {
467
- uri: <string>_data.uri
508
+ uri: <string>_data.uri,
468
509
  }
469
510
  })
470
511
  },
471
- error => {
512
+ (error) => {
472
513
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
473
- }
514
+ },
474
515
  )
475
516
  }
476
517
 
477
518
  commitTOTP = (args: CommitTOTPArgs, headers?: object, signal?: AbortSignal): Promise<CommitTOTPReturn> => {
478
519
  return this.fetch(this.url('CommitTOTP'), createHTTPRequest(args, headers, signal)).then(
479
- res => {
480
- return buildResponse(res).then(_data => {
520
+ (res) => {
521
+ return buildResponse(res).then((_data) => {
481
522
  return {
482
- codes: <Array<RecoveryCode>>_data.codes
523
+ codes: <Array<RecoveryCode>>_data.codes,
483
524
  }
484
525
  })
485
526
  },
486
- error => {
527
+ (error) => {
487
528
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
488
- }
529
+ },
489
530
  )
490
531
  }
491
532
 
492
533
  resetTOTP = (args: ResetTOTPArgs, headers?: object, signal?: AbortSignal): Promise<ResetTOTPReturn> => {
493
534
  return this.fetch(this.url('ResetTOTP'), createHTTPRequest(args, headers, signal)).then(
494
- res => {
495
- return buildResponse(res).then(_data => {
535
+ (res) => {
536
+ return buildResponse(res).then((_data) => {
496
537
  return {}
497
538
  })
498
539
  },
499
- error => {
540
+ (error) => {
500
541
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
501
- }
542
+ },
502
543
  )
503
544
  }
504
545
 
505
546
  reset2FA = (args: Reset2FAArgs, headers?: object, signal?: AbortSignal): Promise<Reset2FAReturn> => {
506
547
  return this.fetch(this.url('Reset2FA'), createHTTPRequest(args, headers, signal)).then(
507
- res => {
508
- return buildResponse(res).then(_data => {
548
+ (res) => {
549
+ return buildResponse(res).then((_data) => {
509
550
  return {}
510
551
  })
511
552
  },
512
- error => {
553
+ (error) => {
513
554
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
514
- }
555
+ },
515
556
  )
516
557
  }
517
558
 
518
559
  recoveryCodes = (args: RecoveryCodesArgs, headers?: object, signal?: AbortSignal): Promise<RecoveryCodesReturn> => {
519
560
  return this.fetch(this.url('RecoveryCodes'), createHTTPRequest(args, headers, signal)).then(
520
- res => {
521
- return buildResponse(res).then(_data => {
561
+ (res) => {
562
+ return buildResponse(res).then((_data) => {
522
563
  return {
523
- codes: <Array<RecoveryCode>>_data.codes
564
+ codes: <Array<RecoveryCode>>_data.codes,
524
565
  }
525
566
  })
526
567
  },
527
- error => {
568
+ (error) => {
528
569
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
529
- }
570
+ },
530
571
  )
531
572
  }
532
573
 
533
574
  resetRecoveryCodes = (
534
575
  args: ResetRecoveryCodesArgs,
535
576
  headers?: object,
536
- signal?: AbortSignal
577
+ signal?: AbortSignal,
537
578
  ): Promise<ResetRecoveryCodesReturn> => {
538
579
  return this.fetch(this.url('ResetRecoveryCodes'), createHTTPRequest(args, headers, signal)).then(
539
- res => {
540
- return buildResponse(res).then(_data => {
580
+ (res) => {
581
+ return buildResponse(res).then((_data) => {
541
582
  return {
542
- codes: <Array<RecoveryCode>>_data.codes
583
+ codes: <Array<RecoveryCode>>_data.codes,
543
584
  }
544
585
  })
545
586
  },
546
- error => {
587
+ (error) => {
547
588
  throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` })
548
- }
589
+ },
549
590
  )
550
591
  }
551
592
  }
@@ -558,12 +599,12 @@ const createHTTPRequest = (body: object = {}, headers: object = {}, signal: Abor
558
599
  method: 'POST',
559
600
  headers: reqHeaders,
560
601
  body: JSON.stringify(body || {}),
561
- signal
602
+ signal,
562
603
  }
563
604
  }
564
605
 
565
606
  const buildResponse = (res: Response): Promise<any> => {
566
- return res.text().then(text => {
607
+ return res.text().then((text) => {
567
608
  let data
568
609
  try {
569
610
  data = JSON.parse(text)
@@ -574,7 +615,7 @@ const buildResponse = (res: Response): Promise<any> => {
574
615
  }
575
616
  throw WebrpcBadResponseError.new({
576
617
  status: res.status,
577
- cause: `JSON.parse(): ${message}: response text: ${text}`
618
+ cause: `JSON.parse(): ${message}: response text: ${text}`,
578
619
  })
579
620
  }
580
621
  if (!res.ok) {
@@ -623,7 +664,7 @@ export class WebrpcEndpointError extends WebrpcError {
623
664
  code: number = 0,
624
665
  message: string = `endpoint error`,
625
666
  status: number = 0,
626
- cause?: string
667
+ cause?: string,
627
668
  ) {
628
669
  super(name, code, message, status, cause)
629
670
  Object.setPrototypeOf(this, WebrpcEndpointError.prototype)
@@ -636,7 +677,7 @@ export class WebrpcRequestFailedError extends WebrpcError {
636
677
  code: number = -1,
637
678
  message: string = `request failed`,
638
679
  status: number = 0,
639
- cause?: string
680
+ cause?: string,
640
681
  ) {
641
682
  super(name, code, message, status, cause)
642
683
  Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype)
@@ -649,7 +690,7 @@ export class WebrpcBadRouteError extends WebrpcError {
649
690
  code: number = -2,
650
691
  message: string = `bad route`,
651
692
  status: number = 0,
652
- cause?: string
693
+ cause?: string,
653
694
  ) {
654
695
  super(name, code, message, status, cause)
655
696
  Object.setPrototypeOf(this, WebrpcBadRouteError.prototype)
@@ -662,7 +703,7 @@ export class WebrpcBadMethodError extends WebrpcError {
662
703
  code: number = -3,
663
704
  message: string = `bad method`,
664
705
  status: number = 0,
665
- cause?: string
706
+ cause?: string,
666
707
  ) {
667
708
  super(name, code, message, status, cause)
668
709
  Object.setPrototypeOf(this, WebrpcBadMethodError.prototype)
@@ -675,7 +716,7 @@ export class WebrpcBadRequestError extends WebrpcError {
675
716
  code: number = -4,
676
717
  message: string = `bad request`,
677
718
  status: number = 0,
678
- cause?: string
719
+ cause?: string,
679
720
  ) {
680
721
  super(name, code, message, status, cause)
681
722
  Object.setPrototypeOf(this, WebrpcBadRequestError.prototype)
@@ -688,7 +729,7 @@ export class WebrpcBadResponseError extends WebrpcError {
688
729
  code: number = -5,
689
730
  message: string = `bad response`,
690
731
  status: number = 0,
691
- cause?: string
732
+ cause?: string,
692
733
  ) {
693
734
  super(name, code, message, status, cause)
694
735
  Object.setPrototypeOf(this, WebrpcBadResponseError.prototype)
@@ -701,7 +742,7 @@ export class WebrpcServerPanicError extends WebrpcError {
701
742
  code: number = -6,
702
743
  message: string = `server panic`,
703
744
  status: number = 0,
704
- cause?: string
745
+ cause?: string,
705
746
  ) {
706
747
  super(name, code, message, status, cause)
707
748
  Object.setPrototypeOf(this, WebrpcServerPanicError.prototype)
@@ -714,7 +755,7 @@ export class WebrpcInternalErrorError extends WebrpcError {
714
755
  code: number = -7,
715
756
  message: string = `internal error`,
716
757
  status: number = 0,
717
- cause?: string
758
+ cause?: string,
718
759
  ) {
719
760
  super(name, code, message, status, cause)
720
761
  Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype)
@@ -727,7 +768,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError {
727
768
  code: number = -8,
728
769
  message: string = `client disconnected`,
729
770
  status: number = 0,
730
- cause?: string
771
+ cause?: string,
731
772
  ) {
732
773
  super(name, code, message, status, cause)
733
774
  Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype)
@@ -740,7 +781,7 @@ export class WebrpcStreamLostError extends WebrpcError {
740
781
  code: number = -9,
741
782
  message: string = `stream lost`,
742
783
  status: number = 0,
743
- cause?: string
784
+ cause?: string,
744
785
  ) {
745
786
  super(name, code, message, status, cause)
746
787
  Object.setPrototypeOf(this, WebrpcStreamLostError.prototype)
@@ -753,7 +794,7 @@ export class WebrpcStreamFinishedError extends WebrpcError {
753
794
  code: number = -10,
754
795
  message: string = `stream finished`,
755
796
  status: number = 0,
756
- cause?: string
797
+ cause?: string,
757
798
  ) {
758
799
  super(name, code, message, status, cause)
759
800
  Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype)
@@ -768,7 +809,7 @@ export class UnauthorizedError extends WebrpcError {
768
809
  code: number = 1000,
769
810
  message: string = `Unauthorized access`,
770
811
  status: number = 0,
771
- cause?: string
812
+ cause?: string,
772
813
  ) {
773
814
  super(name, code, message, status, cause)
774
815
  Object.setPrototypeOf(this, UnauthorizedError.prototype)
@@ -781,7 +822,7 @@ export class PermissionDeniedError extends WebrpcError {
781
822
  code: number = 1001,
782
823
  message: string = `Permission denied`,
783
824
  status: number = 0,
784
- cause?: string
825
+ cause?: string,
785
826
  ) {
786
827
  super(name, code, message, status, cause)
787
828
  Object.setPrototypeOf(this, PermissionDeniedError.prototype)
@@ -794,7 +835,7 @@ export class SessionExpiredError extends WebrpcError {
794
835
  code: number = 1002,
795
836
  message: string = `Session expired`,
796
837
  status: number = 0,
797
- cause?: string
838
+ cause?: string,
798
839
  ) {
799
840
  super(name, code, message, status, cause)
800
841
  Object.setPrototypeOf(this, SessionExpiredError.prototype)
@@ -807,7 +848,7 @@ export class MethodNotFoundError extends WebrpcError {
807
848
  code: number = 1003,
808
849
  message: string = `Method not found`,
809
850
  status: number = 0,
810
- cause?: string
851
+ cause?: string,
811
852
  ) {
812
853
  super(name, code, message, status, cause)
813
854
  Object.setPrototypeOf(this, MethodNotFoundError.prototype)
@@ -820,7 +861,7 @@ export class RequestConflictError extends WebrpcError {
820
861
  code: number = 1004,
821
862
  message: string = `Conflict with target resource`,
822
863
  status: number = 0,
823
- cause?: string
864
+ cause?: string,
824
865
  ) {
825
866
  super(name, code, message, status, cause)
826
867
  Object.setPrototypeOf(this, RequestConflictError.prototype)
@@ -833,7 +874,7 @@ export class AbortedError extends WebrpcError {
833
874
  code: number = 1005,
834
875
  message: string = `Request aborted`,
835
876
  status: number = 0,
836
- cause?: string
877
+ cause?: string,
837
878
  ) {
838
879
  super(name, code, message, status, cause)
839
880
  Object.setPrototypeOf(this, AbortedError.prototype)
@@ -846,7 +887,7 @@ export class GeoblockedError extends WebrpcError {
846
887
  code: number = 1006,
847
888
  message: string = `Geoblocked region`,
848
889
  status: number = 0,
849
- cause?: string
890
+ cause?: string,
850
891
  ) {
851
892
  super(name, code, message, status, cause)
852
893
  Object.setPrototypeOf(this, GeoblockedError.prototype)
@@ -859,7 +900,7 @@ export class RateLimitedError extends WebrpcError {
859
900
  code: number = 1007,
860
901
  message: string = `Rate-limited. Please slow down.`,
861
902
  status: number = 0,
862
- cause?: string
903
+ cause?: string,
863
904
  ) {
864
905
  super(name, code, message, status, cause)
865
906
  Object.setPrototypeOf(this, RateLimitedError.prototype)
@@ -872,7 +913,7 @@ export class InvalidArgumentError extends WebrpcError {
872
913
  code: number = 2001,
873
914
  message: string = `Invalid argument`,
874
915
  status: number = 0,
875
- cause?: string
916
+ cause?: string,
876
917
  ) {
877
918
  super(name, code, message, status, cause)
878
919
  Object.setPrototypeOf(this, InvalidArgumentError.prototype)
@@ -885,7 +926,7 @@ export class UnavailableError extends WebrpcError {
885
926
  code: number = 2002,
886
927
  message: string = `Unavailable resource`,
887
928
  status: number = 0,
888
- cause?: string
929
+ cause?: string,
889
930
  ) {
890
931
  super(name, code, message, status, cause)
891
932
  Object.setPrototypeOf(this, UnavailableError.prototype)
@@ -898,7 +939,7 @@ export class QueryFailedError extends WebrpcError {
898
939
  code: number = 2003,
899
940
  message: string = `Query failed`,
900
941
  status: number = 0,
901
- cause?: string
942
+ cause?: string,
902
943
  ) {
903
944
  super(name, code, message, status, cause)
904
945
  Object.setPrototypeOf(this, QueryFailedError.prototype)
@@ -911,7 +952,7 @@ export class ValidationFailedError extends WebrpcError {
911
952
  code: number = 2004,
912
953
  message: string = `Validation Failed`,
913
954
  status: number = 0,
914
- cause?: string
955
+ cause?: string,
915
956
  ) {
916
957
  super(name, code, message, status, cause)
917
958
  Object.setPrototypeOf(this, ValidationFailedError.prototype)
@@ -924,13 +965,39 @@ export class NotFoundError extends WebrpcError {
924
965
  code: number = 3000,
925
966
  message: string = `Resource not found`,
926
967
  status: number = 0,
927
- cause?: string
968
+ cause?: string,
928
969
  ) {
929
970
  super(name, code, message, status, cause)
930
971
  Object.setPrototypeOf(this, NotFoundError.prototype)
931
972
  }
932
973
  }
933
974
 
975
+ export class RequiresTOTPError extends WebrpcError {
976
+ constructor(
977
+ name: string = 'RequiresTOTP',
978
+ code: number = 6600,
979
+ message: string = `TOTP is required`,
980
+ status: number = 0,
981
+ cause?: string,
982
+ ) {
983
+ super(name, code, message, status, cause)
984
+ Object.setPrototypeOf(this, RequiresTOTPError.prototype)
985
+ }
986
+ }
987
+
988
+ export class RequiresPINError extends WebrpcError {
989
+ constructor(
990
+ name: string = 'RequiresPIN',
991
+ code: number = 6601,
992
+ message: string = `PIN is required`,
993
+ status: number = 0,
994
+ cause?: string,
995
+ ) {
996
+ super(name, code, message, status, cause)
997
+ Object.setPrototypeOf(this, RequiresPINError.prototype)
998
+ }
999
+ }
1000
+
934
1001
  export enum errors {
935
1002
  WebrpcEndpoint = 'WebrpcEndpoint',
936
1003
  WebrpcRequestFailed = 'WebrpcRequestFailed',
@@ -955,7 +1022,9 @@ export enum errors {
955
1022
  Unavailable = 'Unavailable',
956
1023
  QueryFailed = 'QueryFailed',
957
1024
  ValidationFailed = 'ValidationFailed',
958
- NotFound = 'NotFound'
1025
+ NotFound = 'NotFound',
1026
+ RequiresTOTP = 'RequiresTOTP',
1027
+ RequiresPIN = 'RequiresPIN',
959
1028
  }
960
1029
 
961
1030
  export enum WebrpcErrorCodes {
@@ -982,7 +1051,9 @@ export enum WebrpcErrorCodes {
982
1051
  Unavailable = 2002,
983
1052
  QueryFailed = 2003,
984
1053
  ValidationFailed = 2004,
985
- NotFound = 3000
1054
+ NotFound = 3000,
1055
+ RequiresTOTP = 6600,
1056
+ RequiresPIN = 6601,
986
1057
  }
987
1058
 
988
1059
  export const webrpcErrorByCode: { [code: number]: any } = {
@@ -1009,7 +1080,9 @@ export const webrpcErrorByCode: { [code: number]: any } = {
1009
1080
  [2002]: UnavailableError,
1010
1081
  [2003]: QueryFailedError,
1011
1082
  [2004]: ValidationFailedError,
1012
- [3000]: NotFoundError
1083
+ [3000]: NotFoundError,
1084
+ [6600]: RequiresTOTPError,
1085
+ [6601]: RequiresPINError,
1013
1086
  }
1014
1087
 
1015
1088
  export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>