@dfns/sdk 0.4.0-alpha.1 → 0.4.0

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/baseAuthApi.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { FirstFactorAttestation, RecoveryFactorAttestation, SecondFactorAttestation, UserRegistrationChallenge } from './store';
2
- import { AllowCredential, CredentialKind, FirstFactorAssertion, RecoveryKeyAssertion, SecondFactorAssertion } from './signer';
2
+ import { CredentialKind, FirstFactorAssertion, RecoveryKeyAssertion, SecondFactorAssertion, UserActionChallenge } from './signer';
3
3
  import { HttpMethod } from './utils/fetch';
4
4
  export type DfnsBaseApiOptions = {
5
5
  appId: string;
@@ -13,21 +13,7 @@ export type CreateUserActionChallengeRequest = {
13
13
  userActionHttpPath: string;
14
14
  userActionServerKind: 'Api';
15
15
  };
16
- export type CredentialFactor = 'first' | 'second' | 'either';
17
- export type UserActionChallengeResponse = {
18
- supportedCredentialKinds: {
19
- kind: CredentialKind;
20
- factor: CredentialFactor;
21
- requiresSecondFactor: boolean;
22
- }[];
23
- challenge: string;
24
- challengeIdentifier: string;
25
- externalAuthenticationUrl: string;
26
- allowCredentials: {
27
- key: AllowCredential[];
28
- webauthn: AllowCredential[];
29
- };
30
- };
16
+ export type UserActionChallengeResponse = UserActionChallenge;
31
17
  export type SignUserActionChallengeRequest = {
32
18
  challengeIdentifier: string;
33
19
  firstFactor: FirstFactorAssertion;
@@ -29,6 +29,8 @@ export type UserLoginChallenge = {
29
29
  challengeIdentifier: Jwt;
30
30
  externalAuthenticationUrl: string;
31
31
  allowCredentials: AllowCredentials;
32
+ attestation: AuthenticatorAttestationOptions;
33
+ userVerification: AuthenticatorRequirementOptions;
32
34
  };
33
35
  export type UserLogin = {
34
36
  token: Jwt;
@@ -7,10 +7,10 @@ class DfnsAuthenticator {
7
7
  this.apiOptions = apiOptions;
8
8
  }
9
9
  async login(request) {
10
- const { challenge, challengeIdentifier, allowCredentials } = await baseAuthApi_1.BaseAuthApi.createUserLoginChallenge(request, this.apiOptions);
11
- const assertion = await this.apiOptions.signer.sign(challenge, allowCredentials);
10
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserLoginChallenge(request, this.apiOptions);
11
+ const assertion = await this.apiOptions.signer.sign(challenge);
12
12
  return baseAuthApi_1.BaseAuthApi.createUserLogin({
13
- challengeIdentifier,
13
+ challengeIdentifier: challenge.challengeIdentifier,
14
14
  firstFactor: assertion,
15
15
  }, this.apiOptions);
16
16
  }
@@ -3,21 +3,16 @@ export type ArchivePolicyParams = {
3
3
  };
4
4
  export type ArchivePolicyResponse = ({
5
5
  name: string;
6
- action: {
7
- kind: "RequestApproval";
8
- approvalGroups: {
9
- name?: string | undefined;
10
- quorum: number;
11
- approvers: {
12
- [x: string]: {
13
- [x: string]: string[];
14
- };
6
+ approvalGroups: {
7
+ name?: string | undefined;
8
+ quorum: number;
9
+ approvers: {
10
+ [x: string]: {
11
+ [x: string]: string[];
15
12
  };
16
- }[];
17
- autoRejectTimeout?: (number | undefined) | null;
18
- } | {
19
- kind: "Block";
20
- };
13
+ };
14
+ }[];
15
+ autoRejectTimeout?: (number | undefined) | null;
21
16
  activityKind: "Permissions:Assign";
22
17
  rule: {
23
18
  kind: "AlwaysRequireApproval";
@@ -30,21 +25,16 @@ export type ArchivePolicyResponse = ({
30
25
  } | undefined;
31
26
  } | {
32
27
  name: string;
33
- action: {
34
- kind: "RequestApproval";
35
- approvalGroups: {
36
- name?: string | undefined;
37
- quorum: number;
38
- approvers: {
39
- [x: string]: {
40
- [x: string]: string[];
41
- };
28
+ approvalGroups: {
29
+ name?: string | undefined;
30
+ quorum: number;
31
+ approvers: {
32
+ [x: string]: {
33
+ [x: string]: string[];
42
34
  };
43
- }[];
44
- autoRejectTimeout?: (number | undefined) | null;
45
- } | {
46
- kind: "Block";
47
- };
35
+ };
36
+ }[];
37
+ autoRejectTimeout?: (number | undefined) | null;
48
38
  activityKind: "Permissions:Modify";
49
39
  rule: {
50
40
  kind: "AlwaysRequireApproval";
@@ -57,21 +47,16 @@ export type ArchivePolicyResponse = ({
57
47
  } | undefined;
58
48
  } | {
59
49
  name: string;
60
- action: {
61
- kind: "RequestApproval";
62
- approvalGroups: {
63
- name?: string | undefined;
64
- quorum: number;
65
- approvers: {
66
- [x: string]: {
67
- [x: string]: string[];
68
- };
50
+ approvalGroups: {
51
+ name?: string | undefined;
52
+ quorum: number;
53
+ approvers: {
54
+ [x: string]: {
55
+ [x: string]: string[];
69
56
  };
70
- }[];
71
- autoRejectTimeout?: (number | undefined) | null;
72
- } | {
73
- kind: "Block";
74
- };
57
+ };
58
+ }[];
59
+ autoRejectTimeout?: (number | undefined) | null;
75
60
  activityKind: "Policies:Modify";
76
61
  rule: {
77
62
  kind: "AlwaysRequireApproval";
@@ -84,30 +69,20 @@ export type ArchivePolicyResponse = ({
84
69
  } | undefined;
85
70
  } | {
86
71
  name: string;
87
- action: {
88
- kind: "RequestApproval";
89
- approvalGroups: {
90
- name?: string | undefined;
91
- quorum: number;
92
- approvers: {
93
- [x: string]: {
94
- [x: string]: string[];
95
- };
72
+ approvalGroups: {
73
+ name?: string | undefined;
74
+ quorum: number;
75
+ approvers: {
76
+ [x: string]: {
77
+ [x: string]: string[];
96
78
  };
97
- }[];
98
- autoRejectTimeout?: (number | undefined) | null;
99
- } | {
100
- kind: "Block";
101
- };
79
+ };
80
+ }[];
81
+ autoRejectTimeout?: (number | undefined) | null;
102
82
  activityKind: "Wallets:Sign";
103
83
  rule: {
104
84
  kind: "AlwaysRequireApproval";
105
85
  configuration: {};
106
- } | {
107
- kind: "TransactionRecipientWhitelist";
108
- configuration: {
109
- addresses: string[];
110
- };
111
86
  } | {
112
87
  kind: "TransactionAmountLimit";
113
88
  configuration: {
@@ -155,7 +130,7 @@ export type CreateApprovalDecisionResponse = {
155
130
  activity: {
156
131
  [x: string]: unknown;
157
132
  };
158
- status: "Pending" | "Approved" | "Denied" | "AutoApproved" | "AutoDenied" | "Expired";
133
+ status: "Pending" | "Approved" | "Denied" | "AutoApproved" | "Expired";
159
134
  expirationDate?: string | undefined;
160
135
  dateCreated?: string | undefined;
161
136
  dateUpdated: string;
@@ -177,21 +152,16 @@ export type CreateApprovalDecisionRequest = CreateApprovalDecisionParams & {
177
152
  };
178
153
  export type CreatePolicyBody = {
179
154
  name: string;
180
- action: {
181
- kind: "RequestApproval";
182
- approvalGroups: {
183
- name?: string | undefined;
184
- quorum: number;
185
- approvers: {
186
- [x: string]: {
187
- [x: string]: string[];
188
- };
155
+ approvalGroups: {
156
+ name?: string | undefined;
157
+ quorum: number;
158
+ approvers: {
159
+ [x: string]: {
160
+ [x: string]: string[];
189
161
  };
190
- }[];
191
- autoRejectTimeout?: (number | undefined) | null;
192
- } | {
193
- kind: "Block";
194
- };
162
+ };
163
+ }[];
164
+ autoRejectTimeout?: (number | undefined) | null;
195
165
  activityKind: "Permissions:Assign";
196
166
  rule: {
197
167
  kind: "AlwaysRequireApproval";
@@ -204,21 +174,16 @@ export type CreatePolicyBody = {
204
174
  } | undefined;
205
175
  } | {
206
176
  name: string;
207
- action: {
208
- kind: "RequestApproval";
209
- approvalGroups: {
210
- name?: string | undefined;
211
- quorum: number;
212
- approvers: {
213
- [x: string]: {
214
- [x: string]: string[];
215
- };
177
+ approvalGroups: {
178
+ name?: string | undefined;
179
+ quorum: number;
180
+ approvers: {
181
+ [x: string]: {
182
+ [x: string]: string[];
216
183
  };
217
- }[];
218
- autoRejectTimeout?: (number | undefined) | null;
219
- } | {
220
- kind: "Block";
221
- };
184
+ };
185
+ }[];
186
+ autoRejectTimeout?: (number | undefined) | null;
222
187
  activityKind: "Permissions:Modify";
223
188
  rule: {
224
189
  kind: "AlwaysRequireApproval";
@@ -231,21 +196,16 @@ export type CreatePolicyBody = {
231
196
  } | undefined;
232
197
  } | {
233
198
  name: string;
234
- action: {
235
- kind: "RequestApproval";
236
- approvalGroups: {
237
- name?: string | undefined;
238
- quorum: number;
239
- approvers: {
240
- [x: string]: {
241
- [x: string]: string[];
242
- };
199
+ approvalGroups: {
200
+ name?: string | undefined;
201
+ quorum: number;
202
+ approvers: {
203
+ [x: string]: {
204
+ [x: string]: string[];
243
205
  };
244
- }[];
245
- autoRejectTimeout?: (number | undefined) | null;
246
- } | {
247
- kind: "Block";
248
- };
206
+ };
207
+ }[];
208
+ autoRejectTimeout?: (number | undefined) | null;
249
209
  activityKind: "Policies:Modify";
250
210
  rule: {
251
211
  kind: "AlwaysRequireApproval";
@@ -258,30 +218,20 @@ export type CreatePolicyBody = {
258
218
  } | undefined;
259
219
  } | {
260
220
  name: string;
261
- action: {
262
- kind: "RequestApproval";
263
- approvalGroups: {
264
- name?: string | undefined;
265
- quorum: number;
266
- approvers: {
267
- [x: string]: {
268
- [x: string]: string[];
269
- };
221
+ approvalGroups: {
222
+ name?: string | undefined;
223
+ quorum: number;
224
+ approvers: {
225
+ [x: string]: {
226
+ [x: string]: string[];
270
227
  };
271
- }[];
272
- autoRejectTimeout?: (number | undefined) | null;
273
- } | {
274
- kind: "Block";
275
- };
228
+ };
229
+ }[];
230
+ autoRejectTimeout?: (number | undefined) | null;
276
231
  activityKind: "Wallets:Sign";
277
232
  rule: {
278
233
  kind: "AlwaysRequireApproval";
279
234
  configuration: {};
280
- } | {
281
- kind: "TransactionRecipientWhitelist";
282
- configuration: {
283
- addresses: string[];
284
- };
285
235
  } | {
286
236
  kind: "TransactionAmountLimit";
287
237
  configuration: {
@@ -310,21 +260,16 @@ export type CreatePolicyBody = {
310
260
  };
311
261
  export type CreatePolicyResponse = ({
312
262
  name: string;
313
- action: {
314
- kind: "RequestApproval";
315
- approvalGroups: {
316
- name?: string | undefined;
317
- quorum: number;
318
- approvers: {
319
- [x: string]: {
320
- [x: string]: string[];
321
- };
263
+ approvalGroups: {
264
+ name?: string | undefined;
265
+ quorum: number;
266
+ approvers: {
267
+ [x: string]: {
268
+ [x: string]: string[];
322
269
  };
323
- }[];
324
- autoRejectTimeout?: (number | undefined) | null;
325
- } | {
326
- kind: "Block";
327
- };
270
+ };
271
+ }[];
272
+ autoRejectTimeout?: (number | undefined) | null;
328
273
  activityKind: "Permissions:Assign";
329
274
  rule: {
330
275
  kind: "AlwaysRequireApproval";
@@ -337,21 +282,16 @@ export type CreatePolicyResponse = ({
337
282
  } | undefined;
338
283
  } | {
339
284
  name: string;
340
- action: {
341
- kind: "RequestApproval";
342
- approvalGroups: {
343
- name?: string | undefined;
344
- quorum: number;
345
- approvers: {
346
- [x: string]: {
347
- [x: string]: string[];
348
- };
285
+ approvalGroups: {
286
+ name?: string | undefined;
287
+ quorum: number;
288
+ approvers: {
289
+ [x: string]: {
290
+ [x: string]: string[];
349
291
  };
350
- }[];
351
- autoRejectTimeout?: (number | undefined) | null;
352
- } | {
353
- kind: "Block";
354
- };
292
+ };
293
+ }[];
294
+ autoRejectTimeout?: (number | undefined) | null;
355
295
  activityKind: "Permissions:Modify";
356
296
  rule: {
357
297
  kind: "AlwaysRequireApproval";
@@ -364,21 +304,16 @@ export type CreatePolicyResponse = ({
364
304
  } | undefined;
365
305
  } | {
366
306
  name: string;
367
- action: {
368
- kind: "RequestApproval";
369
- approvalGroups: {
370
- name?: string | undefined;
371
- quorum: number;
372
- approvers: {
373
- [x: string]: {
374
- [x: string]: string[];
375
- };
307
+ approvalGroups: {
308
+ name?: string | undefined;
309
+ quorum: number;
310
+ approvers: {
311
+ [x: string]: {
312
+ [x: string]: string[];
376
313
  };
377
- }[];
378
- autoRejectTimeout?: (number | undefined) | null;
379
- } | {
380
- kind: "Block";
381
- };
314
+ };
315
+ }[];
316
+ autoRejectTimeout?: (number | undefined) | null;
382
317
  activityKind: "Policies:Modify";
383
318
  rule: {
384
319
  kind: "AlwaysRequireApproval";
@@ -391,30 +326,20 @@ export type CreatePolicyResponse = ({
391
326
  } | undefined;
392
327
  } | {
393
328
  name: string;
394
- action: {
395
- kind: "RequestApproval";
396
- approvalGroups: {
397
- name?: string | undefined;
398
- quorum: number;
399
- approvers: {
400
- [x: string]: {
401
- [x: string]: string[];
402
- };
329
+ approvalGroups: {
330
+ name?: string | undefined;
331
+ quorum: number;
332
+ approvers: {
333
+ [x: string]: {
334
+ [x: string]: string[];
403
335
  };
404
- }[];
405
- autoRejectTimeout?: (number | undefined) | null;
406
- } | {
407
- kind: "Block";
408
- };
336
+ };
337
+ }[];
338
+ autoRejectTimeout?: (number | undefined) | null;
409
339
  activityKind: "Wallets:Sign";
410
340
  rule: {
411
341
  kind: "AlwaysRequireApproval";
412
342
  configuration: {};
413
- } | {
414
- kind: "TransactionRecipientWhitelist";
415
- configuration: {
416
- addresses: string[];
417
- };
418
343
  } | {
419
344
  kind: "TransactionAmountLimit";
420
345
  configuration: {
@@ -454,21 +379,16 @@ export type GetPolicyParams = {
454
379
  };
455
380
  export type GetPolicyResponse = (({
456
381
  name: string;
457
- action: {
458
- kind: "RequestApproval";
459
- approvalGroups: {
460
- name?: string | undefined;
461
- quorum: number;
462
- approvers: {
463
- [x: string]: {
464
- [x: string]: string[];
465
- };
382
+ approvalGroups: {
383
+ name?: string | undefined;
384
+ quorum: number;
385
+ approvers: {
386
+ [x: string]: {
387
+ [x: string]: string[];
466
388
  };
467
- }[];
468
- autoRejectTimeout?: (number | undefined) | null;
469
- } | {
470
- kind: "Block";
471
- };
389
+ };
390
+ }[];
391
+ autoRejectTimeout?: (number | undefined) | null;
472
392
  activityKind: "Permissions:Assign";
473
393
  rule: {
474
394
  kind: "AlwaysRequireApproval";
@@ -481,21 +401,16 @@ export type GetPolicyResponse = (({
481
401
  } | undefined;
482
402
  } | {
483
403
  name: string;
484
- action: {
485
- kind: "RequestApproval";
486
- approvalGroups: {
487
- name?: string | undefined;
488
- quorum: number;
489
- approvers: {
490
- [x: string]: {
491
- [x: string]: string[];
492
- };
404
+ approvalGroups: {
405
+ name?: string | undefined;
406
+ quorum: number;
407
+ approvers: {
408
+ [x: string]: {
409
+ [x: string]: string[];
493
410
  };
494
- }[];
495
- autoRejectTimeout?: (number | undefined) | null;
496
- } | {
497
- kind: "Block";
498
- };
411
+ };
412
+ }[];
413
+ autoRejectTimeout?: (number | undefined) | null;
499
414
  activityKind: "Permissions:Modify";
500
415
  rule: {
501
416
  kind: "AlwaysRequireApproval";
@@ -508,21 +423,16 @@ export type GetPolicyResponse = (({
508
423
  } | undefined;
509
424
  } | {
510
425
  name: string;
511
- action: {
512
- kind: "RequestApproval";
513
- approvalGroups: {
514
- name?: string | undefined;
515
- quorum: number;
516
- approvers: {
517
- [x: string]: {
518
- [x: string]: string[];
519
- };
426
+ approvalGroups: {
427
+ name?: string | undefined;
428
+ quorum: number;
429
+ approvers: {
430
+ [x: string]: {
431
+ [x: string]: string[];
520
432
  };
521
- }[];
522
- autoRejectTimeout?: (number | undefined) | null;
523
- } | {
524
- kind: "Block";
525
- };
433
+ };
434
+ }[];
435
+ autoRejectTimeout?: (number | undefined) | null;
526
436
  activityKind: "Policies:Modify";
527
437
  rule: {
528
438
  kind: "AlwaysRequireApproval";
@@ -535,30 +445,20 @@ export type GetPolicyResponse = (({
535
445
  } | undefined;
536
446
  } | {
537
447
  name: string;
538
- action: {
539
- kind: "RequestApproval";
540
- approvalGroups: {
541
- name?: string | undefined;
542
- quorum: number;
543
- approvers: {
544
- [x: string]: {
545
- [x: string]: string[];
546
- };
448
+ approvalGroups: {
449
+ name?: string | undefined;
450
+ quorum: number;
451
+ approvers: {
452
+ [x: string]: {
453
+ [x: string]: string[];
547
454
  };
548
- }[];
549
- autoRejectTimeout?: (number | undefined) | null;
550
- } | {
551
- kind: "Block";
552
- };
455
+ };
456
+ }[];
457
+ autoRejectTimeout?: (number | undefined) | null;
553
458
  activityKind: "Wallets:Sign";
554
459
  rule: {
555
460
  kind: "AlwaysRequireApproval";
556
461
  configuration: {};
557
- } | {
558
- kind: "TransactionRecipientWhitelist";
559
- configuration: {
560
- addresses: string[];
561
- };
562
462
  } | {
563
463
  kind: "TransactionAmountLimit";
564
464
  configuration: {
@@ -603,21 +503,16 @@ export type GetPolicyResponse = (({
603
503
  entityId: string;
604
504
  body: ({
605
505
  name: string;
606
- action: {
607
- kind: "RequestApproval";
608
- approvalGroups: {
609
- name?: string | undefined;
610
- quorum: number;
611
- approvers: {
612
- [x: string]: {
613
- [x: string]: string[];
614
- };
506
+ approvalGroups: {
507
+ name?: string | undefined;
508
+ quorum: number;
509
+ approvers: {
510
+ [x: string]: {
511
+ [x: string]: string[];
615
512
  };
616
- }[];
617
- autoRejectTimeout?: (number | undefined) | null;
618
- } | {
619
- kind: "Block";
620
- };
513
+ };
514
+ }[];
515
+ autoRejectTimeout?: (number | undefined) | null;
621
516
  activityKind: "Permissions:Assign";
622
517
  rule: {
623
518
  kind: "AlwaysRequireApproval";
@@ -630,21 +525,16 @@ export type GetPolicyResponse = (({
630
525
  } | undefined;
631
526
  } | {
632
527
  name: string;
633
- action: {
634
- kind: "RequestApproval";
635
- approvalGroups: {
636
- name?: string | undefined;
637
- quorum: number;
638
- approvers: {
639
- [x: string]: {
640
- [x: string]: string[];
641
- };
528
+ approvalGroups: {
529
+ name?: string | undefined;
530
+ quorum: number;
531
+ approvers: {
532
+ [x: string]: {
533
+ [x: string]: string[];
642
534
  };
643
- }[];
644
- autoRejectTimeout?: (number | undefined) | null;
645
- } | {
646
- kind: "Block";
647
- };
535
+ };
536
+ }[];
537
+ autoRejectTimeout?: (number | undefined) | null;
648
538
  activityKind: "Permissions:Modify";
649
539
  rule: {
650
540
  kind: "AlwaysRequireApproval";
@@ -657,21 +547,16 @@ export type GetPolicyResponse = (({
657
547
  } | undefined;
658
548
  } | {
659
549
  name: string;
660
- action: {
661
- kind: "RequestApproval";
662
- approvalGroups: {
663
- name?: string | undefined;
664
- quorum: number;
665
- approvers: {
666
- [x: string]: {
667
- [x: string]: string[];
668
- };
550
+ approvalGroups: {
551
+ name?: string | undefined;
552
+ quorum: number;
553
+ approvers: {
554
+ [x: string]: {
555
+ [x: string]: string[];
669
556
  };
670
- }[];
671
- autoRejectTimeout?: (number | undefined) | null;
672
- } | {
673
- kind: "Block";
674
- };
557
+ };
558
+ }[];
559
+ autoRejectTimeout?: (number | undefined) | null;
675
560
  activityKind: "Policies:Modify";
676
561
  rule: {
677
562
  kind: "AlwaysRequireApproval";
@@ -684,30 +569,20 @@ export type GetPolicyResponse = (({
684
569
  } | undefined;
685
570
  } | {
686
571
  name: string;
687
- action: {
688
- kind: "RequestApproval";
689
- approvalGroups: {
690
- name?: string | undefined;
691
- quorum: number;
692
- approvers: {
693
- [x: string]: {
694
- [x: string]: string[];
695
- };
572
+ approvalGroups: {
573
+ name?: string | undefined;
574
+ quorum: number;
575
+ approvers: {
576
+ [x: string]: {
577
+ [x: string]: string[];
696
578
  };
697
- }[];
698
- autoRejectTimeout?: (number | undefined) | null;
699
- } | {
700
- kind: "Block";
701
- };
579
+ };
580
+ }[];
581
+ autoRejectTimeout?: (number | undefined) | null;
702
582
  activityKind: "Wallets:Sign";
703
583
  rule: {
704
584
  kind: "AlwaysRequireApproval";
705
585
  configuration: {};
706
- } | {
707
- kind: "TransactionRecipientWhitelist";
708
- configuration: {
709
- addresses: string[];
710
- };
711
586
  } | {
712
587
  kind: "TransactionAmountLimit";
713
588
  configuration: {
@@ -747,7 +622,7 @@ export type GetPolicyRequest = GetPolicyParams;
747
622
  export type ListApprovalsQuery = {
748
623
  limit?: string | undefined;
749
624
  paginationToken?: string | undefined;
750
- status?: ("Pending" | "Approved" | "Denied" | "AutoApproved" | "AutoDenied" | "Expired") | undefined;
625
+ status?: ("Pending" | "Approved" | "Denied" | "AutoApproved" | "Expired") | undefined;
751
626
  triggerStatus?: ("Triggered" | "Skipped") | undefined;
752
627
  initiatorId?: string | undefined;
753
628
  approverId?: string | undefined;
@@ -761,7 +636,7 @@ export type ListApprovalsResponse = {
761
636
  activity: {
762
637
  [x: string]: unknown;
763
638
  };
764
- status: "Pending" | "Approved" | "Denied" | "AutoApproved" | "AutoDenied" | "Expired";
639
+ status: "Pending" | "Approved" | "Denied" | "AutoApproved" | "Expired";
765
640
  expirationDate?: string | undefined;
766
641
  dateCreated?: string | undefined;
767
642
  dateUpdated: string;
@@ -791,21 +666,16 @@ export type ListPoliciesQuery = {
791
666
  export type ListPoliciesResponse = {
792
667
  items: ((({
793
668
  name: string;
794
- action: {
795
- kind: "RequestApproval";
796
- approvalGroups: {
797
- name?: string | undefined;
798
- quorum: number;
799
- approvers: {
800
- [x: string]: {
801
- [x: string]: string[];
802
- };
669
+ approvalGroups: {
670
+ name?: string | undefined;
671
+ quorum: number;
672
+ approvers: {
673
+ [x: string]: {
674
+ [x: string]: string[];
803
675
  };
804
- }[];
805
- autoRejectTimeout?: (number | undefined) | null;
806
- } | {
807
- kind: "Block";
808
- };
676
+ };
677
+ }[];
678
+ autoRejectTimeout?: (number | undefined) | null;
809
679
  activityKind: "Permissions:Assign";
810
680
  rule: {
811
681
  kind: "AlwaysRequireApproval";
@@ -818,21 +688,16 @@ export type ListPoliciesResponse = {
818
688
  } | undefined;
819
689
  } | {
820
690
  name: string;
821
- action: {
822
- kind: "RequestApproval";
823
- approvalGroups: {
824
- name?: string | undefined;
825
- quorum: number;
826
- approvers: {
827
- [x: string]: {
828
- [x: string]: string[];
829
- };
691
+ approvalGroups: {
692
+ name?: string | undefined;
693
+ quorum: number;
694
+ approvers: {
695
+ [x: string]: {
696
+ [x: string]: string[];
830
697
  };
831
- }[];
832
- autoRejectTimeout?: (number | undefined) | null;
833
- } | {
834
- kind: "Block";
835
- };
698
+ };
699
+ }[];
700
+ autoRejectTimeout?: (number | undefined) | null;
836
701
  activityKind: "Permissions:Modify";
837
702
  rule: {
838
703
  kind: "AlwaysRequireApproval";
@@ -845,21 +710,16 @@ export type ListPoliciesResponse = {
845
710
  } | undefined;
846
711
  } | {
847
712
  name: string;
848
- action: {
849
- kind: "RequestApproval";
850
- approvalGroups: {
851
- name?: string | undefined;
852
- quorum: number;
853
- approvers: {
854
- [x: string]: {
855
- [x: string]: string[];
856
- };
713
+ approvalGroups: {
714
+ name?: string | undefined;
715
+ quorum: number;
716
+ approvers: {
717
+ [x: string]: {
718
+ [x: string]: string[];
857
719
  };
858
- }[];
859
- autoRejectTimeout?: (number | undefined) | null;
860
- } | {
861
- kind: "Block";
862
- };
720
+ };
721
+ }[];
722
+ autoRejectTimeout?: (number | undefined) | null;
863
723
  activityKind: "Policies:Modify";
864
724
  rule: {
865
725
  kind: "AlwaysRequireApproval";
@@ -872,30 +732,20 @@ export type ListPoliciesResponse = {
872
732
  } | undefined;
873
733
  } | {
874
734
  name: string;
875
- action: {
876
- kind: "RequestApproval";
877
- approvalGroups: {
878
- name?: string | undefined;
879
- quorum: number;
880
- approvers: {
881
- [x: string]: {
882
- [x: string]: string[];
883
- };
735
+ approvalGroups: {
736
+ name?: string | undefined;
737
+ quorum: number;
738
+ approvers: {
739
+ [x: string]: {
740
+ [x: string]: string[];
884
741
  };
885
- }[];
886
- autoRejectTimeout?: (number | undefined) | null;
887
- } | {
888
- kind: "Block";
889
- };
742
+ };
743
+ }[];
744
+ autoRejectTimeout?: (number | undefined) | null;
890
745
  activityKind: "Wallets:Sign";
891
746
  rule: {
892
747
  kind: "AlwaysRequireApproval";
893
748
  configuration: {};
894
- } | {
895
- kind: "TransactionRecipientWhitelist";
896
- configuration: {
897
- addresses: string[];
898
- };
899
749
  } | {
900
750
  kind: "TransactionAmountLimit";
901
751
  configuration: {
@@ -940,21 +790,16 @@ export type ListPoliciesResponse = {
940
790
  entityId: string;
941
791
  body: ({
942
792
  name: string;
943
- action: {
944
- kind: "RequestApproval";
945
- approvalGroups: {
946
- name?: string | undefined;
947
- quorum: number;
948
- approvers: {
949
- [x: string]: {
950
- [x: string]: string[];
951
- };
793
+ approvalGroups: {
794
+ name?: string | undefined;
795
+ quorum: number;
796
+ approvers: {
797
+ [x: string]: {
798
+ [x: string]: string[];
952
799
  };
953
- }[];
954
- autoRejectTimeout?: (number | undefined) | null;
955
- } | {
956
- kind: "Block";
957
- };
800
+ };
801
+ }[];
802
+ autoRejectTimeout?: (number | undefined) | null;
958
803
  activityKind: "Permissions:Assign";
959
804
  rule: {
960
805
  kind: "AlwaysRequireApproval";
@@ -967,21 +812,16 @@ export type ListPoliciesResponse = {
967
812
  } | undefined;
968
813
  } | {
969
814
  name: string;
970
- action: {
971
- kind: "RequestApproval";
972
- approvalGroups: {
973
- name?: string | undefined;
974
- quorum: number;
975
- approvers: {
976
- [x: string]: {
977
- [x: string]: string[];
978
- };
815
+ approvalGroups: {
816
+ name?: string | undefined;
817
+ quorum: number;
818
+ approvers: {
819
+ [x: string]: {
820
+ [x: string]: string[];
979
821
  };
980
- }[];
981
- autoRejectTimeout?: (number | undefined) | null;
982
- } | {
983
- kind: "Block";
984
- };
822
+ };
823
+ }[];
824
+ autoRejectTimeout?: (number | undefined) | null;
985
825
  activityKind: "Permissions:Modify";
986
826
  rule: {
987
827
  kind: "AlwaysRequireApproval";
@@ -994,21 +834,16 @@ export type ListPoliciesResponse = {
994
834
  } | undefined;
995
835
  } | {
996
836
  name: string;
997
- action: {
998
- kind: "RequestApproval";
999
- approvalGroups: {
1000
- name?: string | undefined;
1001
- quorum: number;
1002
- approvers: {
1003
- [x: string]: {
1004
- [x: string]: string[];
1005
- };
837
+ approvalGroups: {
838
+ name?: string | undefined;
839
+ quorum: number;
840
+ approvers: {
841
+ [x: string]: {
842
+ [x: string]: string[];
1006
843
  };
1007
- }[];
1008
- autoRejectTimeout?: (number | undefined) | null;
1009
- } | {
1010
- kind: "Block";
1011
- };
844
+ };
845
+ }[];
846
+ autoRejectTimeout?: (number | undefined) | null;
1012
847
  activityKind: "Policies:Modify";
1013
848
  rule: {
1014
849
  kind: "AlwaysRequireApproval";
@@ -1021,30 +856,20 @@ export type ListPoliciesResponse = {
1021
856
  } | undefined;
1022
857
  } | {
1023
858
  name: string;
1024
- action: {
1025
- kind: "RequestApproval";
1026
- approvalGroups: {
1027
- name?: string | undefined;
1028
- quorum: number;
1029
- approvers: {
1030
- [x: string]: {
1031
- [x: string]: string[];
1032
- };
859
+ approvalGroups: {
860
+ name?: string | undefined;
861
+ quorum: number;
862
+ approvers: {
863
+ [x: string]: {
864
+ [x: string]: string[];
1033
865
  };
1034
- }[];
1035
- autoRejectTimeout?: (number | undefined) | null;
1036
- } | {
1037
- kind: "Block";
1038
- };
866
+ };
867
+ }[];
868
+ autoRejectTimeout?: (number | undefined) | null;
1039
869
  activityKind: "Wallets:Sign";
1040
870
  rule: {
1041
871
  kind: "AlwaysRequireApproval";
1042
872
  configuration: {};
1043
- } | {
1044
- kind: "TransactionRecipientWhitelist";
1045
- configuration: {
1046
- addresses: string[];
1047
- };
1048
873
  } | {
1049
874
  kind: "TransactionAmountLimit";
1050
875
  configuration: {
@@ -1087,21 +912,16 @@ export type ListPoliciesRequest = {
1087
912
  };
1088
913
  export type UpdatePolicyBody = {
1089
914
  name: string;
1090
- action: {
1091
- kind: "RequestApproval";
1092
- approvalGroups: {
1093
- name?: string | undefined;
1094
- quorum: number;
1095
- approvers: {
1096
- [x: string]: {
1097
- [x: string]: string[];
1098
- };
915
+ approvalGroups: {
916
+ name?: string | undefined;
917
+ quorum: number;
918
+ approvers: {
919
+ [x: string]: {
920
+ [x: string]: string[];
1099
921
  };
1100
- }[];
1101
- autoRejectTimeout?: (number | undefined) | null;
1102
- } | {
1103
- kind: "Block";
1104
- };
922
+ };
923
+ }[];
924
+ autoRejectTimeout?: (number | undefined) | null;
1105
925
  activityKind: "Permissions:Assign";
1106
926
  rule: {
1107
927
  kind: "AlwaysRequireApproval";
@@ -1114,21 +934,16 @@ export type UpdatePolicyBody = {
1114
934
  } | undefined;
1115
935
  } | {
1116
936
  name: string;
1117
- action: {
1118
- kind: "RequestApproval";
1119
- approvalGroups: {
1120
- name?: string | undefined;
1121
- quorum: number;
1122
- approvers: {
1123
- [x: string]: {
1124
- [x: string]: string[];
1125
- };
937
+ approvalGroups: {
938
+ name?: string | undefined;
939
+ quorum: number;
940
+ approvers: {
941
+ [x: string]: {
942
+ [x: string]: string[];
1126
943
  };
1127
- }[];
1128
- autoRejectTimeout?: (number | undefined) | null;
1129
- } | {
1130
- kind: "Block";
1131
- };
944
+ };
945
+ }[];
946
+ autoRejectTimeout?: (number | undefined) | null;
1132
947
  activityKind: "Permissions:Modify";
1133
948
  rule: {
1134
949
  kind: "AlwaysRequireApproval";
@@ -1141,21 +956,16 @@ export type UpdatePolicyBody = {
1141
956
  } | undefined;
1142
957
  } | {
1143
958
  name: string;
1144
- action: {
1145
- kind: "RequestApproval";
1146
- approvalGroups: {
1147
- name?: string | undefined;
1148
- quorum: number;
1149
- approvers: {
1150
- [x: string]: {
1151
- [x: string]: string[];
1152
- };
959
+ approvalGroups: {
960
+ name?: string | undefined;
961
+ quorum: number;
962
+ approvers: {
963
+ [x: string]: {
964
+ [x: string]: string[];
1153
965
  };
1154
- }[];
1155
- autoRejectTimeout?: (number | undefined) | null;
1156
- } | {
1157
- kind: "Block";
1158
- };
966
+ };
967
+ }[];
968
+ autoRejectTimeout?: (number | undefined) | null;
1159
969
  activityKind: "Policies:Modify";
1160
970
  rule: {
1161
971
  kind: "AlwaysRequireApproval";
@@ -1168,30 +978,20 @@ export type UpdatePolicyBody = {
1168
978
  } | undefined;
1169
979
  } | {
1170
980
  name: string;
1171
- action: {
1172
- kind: "RequestApproval";
1173
- approvalGroups: {
1174
- name?: string | undefined;
1175
- quorum: number;
1176
- approvers: {
1177
- [x: string]: {
1178
- [x: string]: string[];
1179
- };
981
+ approvalGroups: {
982
+ name?: string | undefined;
983
+ quorum: number;
984
+ approvers: {
985
+ [x: string]: {
986
+ [x: string]: string[];
1180
987
  };
1181
- }[];
1182
- autoRejectTimeout?: (number | undefined) | null;
1183
- } | {
1184
- kind: "Block";
1185
- };
988
+ };
989
+ }[];
990
+ autoRejectTimeout?: (number | undefined) | null;
1186
991
  activityKind: "Wallets:Sign";
1187
992
  rule: {
1188
993
  kind: "AlwaysRequireApproval";
1189
994
  configuration: {};
1190
- } | {
1191
- kind: "TransactionRecipientWhitelist";
1192
- configuration: {
1193
- addresses: string[];
1194
- };
1195
995
  } | {
1196
996
  kind: "TransactionAmountLimit";
1197
997
  configuration: {
@@ -1223,21 +1023,16 @@ export type UpdatePolicyParams = {
1223
1023
  };
1224
1024
  export type UpdatePolicyResponse = ({
1225
1025
  name: string;
1226
- action: {
1227
- kind: "RequestApproval";
1228
- approvalGroups: {
1229
- name?: string | undefined;
1230
- quorum: number;
1231
- approvers: {
1232
- [x: string]: {
1233
- [x: string]: string[];
1234
- };
1026
+ approvalGroups: {
1027
+ name?: string | undefined;
1028
+ quorum: number;
1029
+ approvers: {
1030
+ [x: string]: {
1031
+ [x: string]: string[];
1235
1032
  };
1236
- }[];
1237
- autoRejectTimeout?: (number | undefined) | null;
1238
- } | {
1239
- kind: "Block";
1240
- };
1033
+ };
1034
+ }[];
1035
+ autoRejectTimeout?: (number | undefined) | null;
1241
1036
  activityKind: "Permissions:Assign";
1242
1037
  rule: {
1243
1038
  kind: "AlwaysRequireApproval";
@@ -1250,21 +1045,16 @@ export type UpdatePolicyResponse = ({
1250
1045
  } | undefined;
1251
1046
  } | {
1252
1047
  name: string;
1253
- action: {
1254
- kind: "RequestApproval";
1255
- approvalGroups: {
1256
- name?: string | undefined;
1257
- quorum: number;
1258
- approvers: {
1259
- [x: string]: {
1260
- [x: string]: string[];
1261
- };
1048
+ approvalGroups: {
1049
+ name?: string | undefined;
1050
+ quorum: number;
1051
+ approvers: {
1052
+ [x: string]: {
1053
+ [x: string]: string[];
1262
1054
  };
1263
- }[];
1264
- autoRejectTimeout?: (number | undefined) | null;
1265
- } | {
1266
- kind: "Block";
1267
- };
1055
+ };
1056
+ }[];
1057
+ autoRejectTimeout?: (number | undefined) | null;
1268
1058
  activityKind: "Permissions:Modify";
1269
1059
  rule: {
1270
1060
  kind: "AlwaysRequireApproval";
@@ -1277,21 +1067,16 @@ export type UpdatePolicyResponse = ({
1277
1067
  } | undefined;
1278
1068
  } | {
1279
1069
  name: string;
1280
- action: {
1281
- kind: "RequestApproval";
1282
- approvalGroups: {
1283
- name?: string | undefined;
1284
- quorum: number;
1285
- approvers: {
1286
- [x: string]: {
1287
- [x: string]: string[];
1288
- };
1070
+ approvalGroups: {
1071
+ name?: string | undefined;
1072
+ quorum: number;
1073
+ approvers: {
1074
+ [x: string]: {
1075
+ [x: string]: string[];
1289
1076
  };
1290
- }[];
1291
- autoRejectTimeout?: (number | undefined) | null;
1292
- } | {
1293
- kind: "Block";
1294
- };
1077
+ };
1078
+ }[];
1079
+ autoRejectTimeout?: (number | undefined) | null;
1295
1080
  activityKind: "Policies:Modify";
1296
1081
  rule: {
1297
1082
  kind: "AlwaysRequireApproval";
@@ -1304,30 +1089,20 @@ export type UpdatePolicyResponse = ({
1304
1089
  } | undefined;
1305
1090
  } | {
1306
1091
  name: string;
1307
- action: {
1308
- kind: "RequestApproval";
1309
- approvalGroups: {
1310
- name?: string | undefined;
1311
- quorum: number;
1312
- approvers: {
1313
- [x: string]: {
1314
- [x: string]: string[];
1315
- };
1092
+ approvalGroups: {
1093
+ name?: string | undefined;
1094
+ quorum: number;
1095
+ approvers: {
1096
+ [x: string]: {
1097
+ [x: string]: string[];
1316
1098
  };
1317
- }[];
1318
- autoRejectTimeout?: (number | undefined) | null;
1319
- } | {
1320
- kind: "Block";
1321
- };
1099
+ };
1100
+ }[];
1101
+ autoRejectTimeout?: (number | undefined) | null;
1322
1102
  activityKind: "Wallets:Sign";
1323
1103
  rule: {
1324
1104
  kind: "AlwaysRequireApproval";
1325
1105
  configuration: {};
1326
- } | {
1327
- kind: "TransactionRecipientWhitelist";
1328
- configuration: {
1329
- addresses: string[];
1330
- };
1331
1106
  } | {
1332
1107
  kind: "TransactionAmountLimit";
1333
1108
  configuration: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfns/sdk",
3
- "version": "0.4.0-alpha.1",
3
+ "version": "0.4.0",
4
4
  "dependencies": {
5
5
  "buffer": "6.0.3",
6
6
  "cross-fetch": "3.1.6",
package/signer.d.ts CHANGED
@@ -1,10 +1,32 @@
1
+ export type CredentialFactor = 'first' | 'second' | 'either';
1
2
  export type CredentialKind = 'Key' | 'Fido2' | 'Password' | 'Totp' | 'RecoveryKey';
2
3
  export type CredentialTransport = 'usb' | 'nfc' | 'ble' | 'internal';
4
+ export type UserVerificationRequirement = 'required' | 'preferred' | 'discouraged';
3
5
  export type AllowCredential = {
4
6
  type: 'public-key';
5
7
  id: string;
6
8
  transports: CredentialTransport[];
7
9
  };
10
+ export type SupportedCredential = {
11
+ kind: CredentialKind;
12
+ factor: CredentialFactor;
13
+ requiresSecondFactor: boolean;
14
+ };
15
+ export type UserActionChallenge = {
16
+ supportedCredentialKinds: SupportedCredential[];
17
+ rp: {
18
+ id: string;
19
+ name: string;
20
+ };
21
+ challenge: string;
22
+ challengeIdentifier: string;
23
+ externalAuthenticationUrl: string;
24
+ allowCredentials: {
25
+ key: AllowCredential[];
26
+ webauthn: AllowCredential[];
27
+ };
28
+ userVerification: UserVerificationRequirement;
29
+ };
8
30
  export type KeyAssertion = {
9
31
  kind: 'Key';
10
32
  credentialAssertion: {
@@ -45,8 +67,5 @@ export type FirstFactorAssertion = KeyAssertion | Fido2Assertion | PasswordAsser
45
67
  export type SecondFactorAssertion = KeyAssertion | Fido2Assertion | TotpAssertion;
46
68
  export type CredentialAssertion = KeyAssertion | Fido2Assertion | PasswordAssertion | TotpAssertion;
47
69
  export interface CredentialSigner<T extends CredentialAssertion = FirstFactorAssertion> {
48
- sign(challenge: string, allowCredentials: {
49
- key: AllowCredential[];
50
- webauthn: AllowCredential[];
51
- }): Promise<T>;
70
+ sign(challenge: UserActionChallenge): Promise<T>;
52
71
  }
package/store.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { AllowCredential, CredentialKind } from './signer';
1
+ import { AllowCredential, CredentialKind, UserVerificationRequirement } from './signer';
2
2
  export type AuthenticatorAttachment = 'platform' | 'cross-platform';
3
3
  export type ResidentKeyRequirement = 'required' | 'preferred' | 'discouraged';
4
- export type UserVerificationRequirement = 'required' | 'preferred' | 'discouraged';
5
4
  export type AttestationConveyancePreference = 'none' | 'indirect' | 'direct' | 'enterprise';
6
5
  export type UserRegistrationChallenge = {
7
6
  temporaryAuthenticationToken: string;
package/utils/fetch.js CHANGED
@@ -83,15 +83,15 @@ const userAction = (fetch) => {
83
83
  ...options.apiOptions,
84
84
  baseUrl: options.apiOptions.baseAuthUrl || options.apiOptions.baseUrl,
85
85
  };
86
- const { challenge, challengeIdentifier, allowCredentials } = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
86
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
87
87
  userActionPayload: options.body ?? '',
88
88
  userActionHttpMethod: options.method,
89
89
  userActionHttpPath: resource.pathname,
90
90
  userActionServerKind: apiOptions?.userActionServerKind || 'Api',
91
91
  }, apiOptions);
92
- const assertion = await apiOptions.signer.sign(challenge, allowCredentials);
92
+ const assertion = await apiOptions.signer.sign(challenge);
93
93
  const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge({
94
- challengeIdentifier,
94
+ challengeIdentifier: challenge.challengeIdentifier,
95
95
  firstFactor: assertion,
96
96
  }, apiOptions);
97
97
  options.headers = {