@dfns/sdk 0.5.6-alpha.6 → 0.5.6-alpha.7
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/generated/auth/client.d.ts +1 -1
- package/generated/auth/client.js +29 -28
- package/generated/exchanges/client.d.ts +1 -1
- package/generated/exchanges/client.js +5 -4
- package/generated/exchanges/types.d.ts +44 -84
- package/generated/networks/client.d.ts +1 -1
- package/generated/permissions/client.d.ts +1 -1
- package/generated/permissions/client.js +6 -5
- package/generated/policies/client.d.ts +1 -1
- package/generated/policies/client.js +5 -4
- package/generated/signers/client.d.ts +1 -1
- package/generated/wallets/client.d.ts +1 -1
- package/generated/wallets/client.js +11 -10
- package/generated/webhooks/client.d.ts +1 -1
- package/generated/webhooks/client.js +5 -4
- package/package.json +1 -1
- package/types/generic.d.ts +13 -0
- package/types/generic.js +2 -0
- package/utils/fetch.d.ts +6 -3
- package/utils/fetch.js +8 -38
- package/utils/userActionFetch.d.ts +3 -0
- package/utils/userActionFetch.js +41 -0
package/generated/auth/client.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AuthClient = void 0;
|
|
4
4
|
const fetch_1 = require("../../utils/fetch");
|
|
5
|
+
const userActionFetch_1 = require("../../utils/userActionFetch");
|
|
5
6
|
const url_1 = require("../../utils/url");
|
|
6
7
|
class AuthClient {
|
|
7
8
|
constructor(apiOptions) {
|
|
@@ -12,7 +13,7 @@ class AuthClient {
|
|
|
12
13
|
path: request ?? {},
|
|
13
14
|
query: {},
|
|
14
15
|
});
|
|
15
|
-
const response = await (0,
|
|
16
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
16
17
|
method: 'PUT',
|
|
17
18
|
body: {},
|
|
18
19
|
apiOptions: this.apiOptions,
|
|
@@ -24,7 +25,7 @@ class AuthClient {
|
|
|
24
25
|
path: request ?? {},
|
|
25
26
|
query: {},
|
|
26
27
|
});
|
|
27
|
-
const response = await (0,
|
|
28
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
28
29
|
method: 'PUT',
|
|
29
30
|
body: request.body,
|
|
30
31
|
apiOptions: this.apiOptions,
|
|
@@ -36,7 +37,7 @@ class AuthClient {
|
|
|
36
37
|
path: request ?? {},
|
|
37
38
|
query: {},
|
|
38
39
|
});
|
|
39
|
-
const response = await (0,
|
|
40
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
40
41
|
method: 'PUT',
|
|
41
42
|
body: {},
|
|
42
43
|
apiOptions: this.apiOptions,
|
|
@@ -48,7 +49,7 @@ class AuthClient {
|
|
|
48
49
|
path: request ?? {},
|
|
49
50
|
query: {},
|
|
50
51
|
});
|
|
51
|
-
const response = await (0,
|
|
52
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
52
53
|
method: 'PUT',
|
|
53
54
|
body: {},
|
|
54
55
|
apiOptions: this.apiOptions,
|
|
@@ -60,7 +61,7 @@ class AuthClient {
|
|
|
60
61
|
path: request ?? {},
|
|
61
62
|
query: {},
|
|
62
63
|
});
|
|
63
|
-
const response = await (0,
|
|
64
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
64
65
|
method: 'PUT',
|
|
65
66
|
body: {},
|
|
66
67
|
apiOptions: this.apiOptions,
|
|
@@ -72,7 +73,7 @@ class AuthClient {
|
|
|
72
73
|
path: request ?? {},
|
|
73
74
|
query: {},
|
|
74
75
|
});
|
|
75
|
-
const response = await (0,
|
|
76
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
76
77
|
method: 'DELETE',
|
|
77
78
|
body: {},
|
|
78
79
|
apiOptions: this.apiOptions,
|
|
@@ -84,7 +85,7 @@ class AuthClient {
|
|
|
84
85
|
path: request ?? {},
|
|
85
86
|
query: {},
|
|
86
87
|
});
|
|
87
|
-
const response = await (0,
|
|
88
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
88
89
|
method: 'DELETE',
|
|
89
90
|
body: {},
|
|
90
91
|
apiOptions: this.apiOptions,
|
|
@@ -96,7 +97,7 @@ class AuthClient {
|
|
|
96
97
|
path: request ?? {},
|
|
97
98
|
query: {},
|
|
98
99
|
});
|
|
99
|
-
const response = await (0,
|
|
100
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
100
101
|
method: 'DELETE',
|
|
101
102
|
body: {},
|
|
102
103
|
apiOptions: this.apiOptions,
|
|
@@ -108,7 +109,7 @@ class AuthClient {
|
|
|
108
109
|
path: request ?? {},
|
|
109
110
|
query: {},
|
|
110
111
|
});
|
|
111
|
-
const response = await (0,
|
|
112
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
112
113
|
method: 'DELETE',
|
|
113
114
|
body: {},
|
|
114
115
|
apiOptions: this.apiOptions,
|
|
@@ -120,7 +121,7 @@ class AuthClient {
|
|
|
120
121
|
path: request ?? {},
|
|
121
122
|
query: {},
|
|
122
123
|
});
|
|
123
|
-
const response = await (0,
|
|
124
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
124
125
|
method: 'POST',
|
|
125
126
|
body: request.body,
|
|
126
127
|
apiOptions: this.apiOptions,
|
|
@@ -132,7 +133,7 @@ class AuthClient {
|
|
|
132
133
|
path: request ?? {},
|
|
133
134
|
query: {},
|
|
134
135
|
});
|
|
135
|
-
const response = await (0,
|
|
136
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
136
137
|
method: 'POST',
|
|
137
138
|
body: request.body,
|
|
138
139
|
apiOptions: this.apiOptions,
|
|
@@ -176,7 +177,7 @@ class AuthClient {
|
|
|
176
177
|
path: request ?? {},
|
|
177
178
|
query: {},
|
|
178
179
|
});
|
|
179
|
-
const response = await (0,
|
|
180
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
180
181
|
method: 'POST',
|
|
181
182
|
body: request.body,
|
|
182
183
|
apiOptions: this.apiOptions,
|
|
@@ -200,7 +201,7 @@ class AuthClient {
|
|
|
200
201
|
path: request ?? {},
|
|
201
202
|
query: {},
|
|
202
203
|
});
|
|
203
|
-
const response = await (0,
|
|
204
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
204
205
|
method: 'POST',
|
|
205
206
|
body: request.body,
|
|
206
207
|
apiOptions: this.apiOptions,
|
|
@@ -216,7 +217,7 @@ class AuthClient {
|
|
|
216
217
|
path: request ?? {},
|
|
217
218
|
query: {},
|
|
218
219
|
});
|
|
219
|
-
const response = await (0,
|
|
220
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
220
221
|
method: 'POST',
|
|
221
222
|
body: request.body,
|
|
222
223
|
apiOptions: this.apiOptions,
|
|
@@ -244,7 +245,7 @@ class AuthClient {
|
|
|
244
245
|
path: request ?? {},
|
|
245
246
|
query: {},
|
|
246
247
|
});
|
|
247
|
-
const response = await (0,
|
|
248
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
248
249
|
method: 'POST',
|
|
249
250
|
body: request.body,
|
|
250
251
|
apiOptions: this.apiOptions,
|
|
@@ -280,7 +281,7 @@ class AuthClient {
|
|
|
280
281
|
path: request ?? {},
|
|
281
282
|
query: {},
|
|
282
283
|
});
|
|
283
|
-
const response = await (0,
|
|
284
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
284
285
|
method: 'POST',
|
|
285
286
|
body: request.body,
|
|
286
287
|
apiOptions: this.apiOptions,
|
|
@@ -304,7 +305,7 @@ class AuthClient {
|
|
|
304
305
|
path: request ?? {},
|
|
305
306
|
query: {},
|
|
306
307
|
});
|
|
307
|
-
const response = await (0,
|
|
308
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
308
309
|
method: 'POST',
|
|
309
310
|
body: request.body,
|
|
310
311
|
apiOptions: this.apiOptions,
|
|
@@ -344,7 +345,7 @@ class AuthClient {
|
|
|
344
345
|
path: request ?? {},
|
|
345
346
|
query: {},
|
|
346
347
|
});
|
|
347
|
-
const response = await (0,
|
|
348
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
348
349
|
method: 'PUT',
|
|
349
350
|
body: {},
|
|
350
351
|
apiOptions: this.apiOptions,
|
|
@@ -356,7 +357,7 @@ class AuthClient {
|
|
|
356
357
|
path: request ?? {},
|
|
357
358
|
query: {},
|
|
358
359
|
});
|
|
359
|
-
const response = await (0,
|
|
360
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
360
361
|
method: 'PUT',
|
|
361
362
|
body: request.body,
|
|
362
363
|
apiOptions: this.apiOptions,
|
|
@@ -368,7 +369,7 @@ class AuthClient {
|
|
|
368
369
|
path: request ?? {},
|
|
369
370
|
query: {},
|
|
370
371
|
});
|
|
371
|
-
const response = await (0,
|
|
372
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
372
373
|
method: 'PUT',
|
|
373
374
|
body: {},
|
|
374
375
|
apiOptions: this.apiOptions,
|
|
@@ -380,7 +381,7 @@ class AuthClient {
|
|
|
380
381
|
path: request ?? {},
|
|
381
382
|
query: {},
|
|
382
383
|
});
|
|
383
|
-
const response = await (0,
|
|
384
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
384
385
|
method: 'PUT',
|
|
385
386
|
body: {},
|
|
386
387
|
apiOptions: this.apiOptions,
|
|
@@ -392,7 +393,7 @@ class AuthClient {
|
|
|
392
393
|
path: request ?? {},
|
|
393
394
|
query: {},
|
|
394
395
|
});
|
|
395
|
-
const response = await (0,
|
|
396
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
396
397
|
method: 'PUT',
|
|
397
398
|
body: {},
|
|
398
399
|
apiOptions: this.apiOptions,
|
|
@@ -404,7 +405,7 @@ class AuthClient {
|
|
|
404
405
|
path: request ?? {},
|
|
405
406
|
query: {},
|
|
406
407
|
});
|
|
407
|
-
const response = await (0,
|
|
408
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
408
409
|
method: 'POST',
|
|
409
410
|
body: request.body,
|
|
410
411
|
apiOptions: this.apiOptions,
|
|
@@ -562,7 +563,7 @@ class AuthClient {
|
|
|
562
563
|
path: request ?? {},
|
|
563
564
|
query: {},
|
|
564
565
|
});
|
|
565
|
-
const response = await (0,
|
|
566
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
566
567
|
method: 'POST',
|
|
567
568
|
body: request.body,
|
|
568
569
|
apiOptions: this.apiOptions,
|
|
@@ -606,7 +607,7 @@ class AuthClient {
|
|
|
606
607
|
path: request ?? {},
|
|
607
608
|
query: {},
|
|
608
609
|
});
|
|
609
|
-
const response = await (0,
|
|
610
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
610
611
|
method: 'PUT',
|
|
611
612
|
body: request.body,
|
|
612
613
|
apiOptions: this.apiOptions,
|
|
@@ -654,7 +655,7 @@ class AuthClient {
|
|
|
654
655
|
path: request ?? {},
|
|
655
656
|
query: {},
|
|
656
657
|
});
|
|
657
|
-
const response = await (0,
|
|
658
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
658
659
|
method: 'POST',
|
|
659
660
|
body: request.body,
|
|
660
661
|
apiOptions: this.apiOptions,
|
|
@@ -666,7 +667,7 @@ class AuthClient {
|
|
|
666
667
|
path: request ?? {},
|
|
667
668
|
query: {},
|
|
668
669
|
});
|
|
669
|
-
const response = await (0,
|
|
670
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
670
671
|
method: 'PUT',
|
|
671
672
|
body: request.body,
|
|
672
673
|
apiOptions: this.apiOptions,
|
|
@@ -678,7 +679,7 @@ class AuthClient {
|
|
|
678
679
|
path: request ?? {},
|
|
679
680
|
query: {},
|
|
680
681
|
});
|
|
681
|
-
const response = await (0,
|
|
682
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
682
683
|
method: 'PUT',
|
|
683
684
|
body: request.body,
|
|
684
685
|
apiOptions: this.apiOptions,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExchangesClient = void 0;
|
|
4
4
|
const fetch_1 = require("../../utils/fetch");
|
|
5
|
+
const userActionFetch_1 = require("../../utils/userActionFetch");
|
|
5
6
|
const url_1 = require("../../utils/url");
|
|
6
7
|
class ExchangesClient {
|
|
7
8
|
constructor(apiOptions) {
|
|
@@ -12,7 +13,7 @@ class ExchangesClient {
|
|
|
12
13
|
path: request ?? {},
|
|
13
14
|
query: {},
|
|
14
15
|
});
|
|
15
|
-
const response = await (0,
|
|
16
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
16
17
|
method: 'POST',
|
|
17
18
|
body: request.body,
|
|
18
19
|
apiOptions: this.apiOptions,
|
|
@@ -24,7 +25,7 @@ class ExchangesClient {
|
|
|
24
25
|
path: request ?? {},
|
|
25
26
|
query: {},
|
|
26
27
|
});
|
|
27
|
-
const response = await (0,
|
|
28
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
28
29
|
method: 'POST',
|
|
29
30
|
body: request.body,
|
|
30
31
|
apiOptions: this.apiOptions,
|
|
@@ -36,7 +37,7 @@ class ExchangesClient {
|
|
|
36
37
|
path: request ?? {},
|
|
37
38
|
query: {},
|
|
38
39
|
});
|
|
39
|
-
const response = await (0,
|
|
40
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
40
41
|
method: 'POST',
|
|
41
42
|
body: request.body,
|
|
42
43
|
apiOptions: this.apiOptions,
|
|
@@ -48,7 +49,7 @@ class ExchangesClient {
|
|
|
48
49
|
path: request ?? {},
|
|
49
50
|
query: {},
|
|
50
51
|
});
|
|
51
|
-
const response = await (0,
|
|
52
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
52
53
|
method: 'DELETE',
|
|
53
54
|
body: {},
|
|
54
55
|
apiOptions: this.apiOptions,
|
|
@@ -56,8 +56,12 @@ export type CreateDepositParams = {
|
|
|
56
56
|
};
|
|
57
57
|
export type CreateDepositResponse = {
|
|
58
58
|
id: string;
|
|
59
|
+
exchangeId: string;
|
|
60
|
+
accountId: string;
|
|
61
|
+
externalId?: string | undefined;
|
|
62
|
+
transferId?: string | undefined;
|
|
63
|
+
kind: "Withdrawal" | "Deposit";
|
|
59
64
|
walletId: string;
|
|
60
|
-
network: "Algorand" | "AlgorandTestnet" | "ArbitrumOne" | "ArbitrumGoerli" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseGoerli" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Cardano" | "CardanoPreprod" | "Celo" | "CeloAlfajores" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "EthereumHolesky" | "FantomOpera" | "FantomTestnet" | "InternetComputer" | "Kusama" | "Litecoin" | "LitecoinTestnet" | "Optimism" | "OptimismGoerli" | "OptimismSepolia" | "Origyn" | "Polkadot" | "Westend" | "Polygon" | "PolygonAmoy" | "PolygonMumbai" | "Solana" | "SolanaDevnet" | "Stellar" | "StellarTestnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "Ton" | "TonTestnet" | "XrpLedger" | "XrpLedgerTestnet" | "KeyECDSA" | "KeyECDSAStark" | "KeyEdDSA";
|
|
61
65
|
requester: {
|
|
62
66
|
userId: string;
|
|
63
67
|
tokenId?: string | undefined;
|
|
@@ -65,81 +69,57 @@ export type CreateDepositResponse = {
|
|
|
65
69
|
};
|
|
66
70
|
requestBody: {
|
|
67
71
|
kind: "Native";
|
|
68
|
-
to: string | string | string | string | string | string | string | string | string | string | string | string | string;
|
|
69
72
|
amount: string;
|
|
70
|
-
memo?: string | undefined;
|
|
71
73
|
priority?: ("Slow" | "Standard" | "Fast") | undefined;
|
|
74
|
+
walletId: string;
|
|
75
|
+
otp?: string | undefined;
|
|
72
76
|
} | {
|
|
73
77
|
kind: "Erc20";
|
|
74
78
|
contract: string;
|
|
75
|
-
to: string;
|
|
76
79
|
amount: string;
|
|
77
80
|
priority?: ("Slow" | "Standard" | "Fast") | undefined;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
contract: string;
|
|
81
|
-
to: string;
|
|
82
|
-
tokenId: string;
|
|
83
|
-
priority?: ("Slow" | "Standard" | "Fast") | undefined;
|
|
81
|
+
walletId: string;
|
|
82
|
+
otp?: string | undefined;
|
|
84
83
|
} | {
|
|
85
84
|
kind: "Trc10";
|
|
86
85
|
tokenId: string;
|
|
87
|
-
to: string;
|
|
88
86
|
amount: string;
|
|
87
|
+
walletId: string;
|
|
88
|
+
otp?: string | undefined;
|
|
89
89
|
} | {
|
|
90
90
|
kind: "Trc20";
|
|
91
91
|
contract: string;
|
|
92
|
-
to: string;
|
|
93
92
|
amount: string;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
contract: string;
|
|
97
|
-
to: string;
|
|
98
|
-
tokenId: string;
|
|
93
|
+
walletId: string;
|
|
94
|
+
otp?: string | undefined;
|
|
99
95
|
} | {
|
|
100
96
|
kind: "Asa";
|
|
101
97
|
assetId: string;
|
|
102
|
-
to: string;
|
|
103
98
|
amount: string;
|
|
99
|
+
walletId: string;
|
|
100
|
+
otp?: string | undefined;
|
|
104
101
|
} | {
|
|
105
102
|
kind: "Sep41";
|
|
106
103
|
issuer: string;
|
|
107
104
|
assetCode: string;
|
|
108
|
-
to: string;
|
|
109
105
|
amount: string;
|
|
110
|
-
|
|
106
|
+
walletId: string;
|
|
107
|
+
otp?: string | undefined;
|
|
111
108
|
} | {
|
|
112
109
|
kind: "Spl" | "Spl2022";
|
|
113
|
-
to: string;
|
|
114
110
|
amount: string;
|
|
115
111
|
mint: string;
|
|
116
112
|
createDestinationAccount?: boolean | undefined;
|
|
113
|
+
walletId: string;
|
|
114
|
+
otp?: string | undefined;
|
|
117
115
|
} | {
|
|
118
116
|
kind: "Tep74";
|
|
119
|
-
to: string;
|
|
120
117
|
master: string;
|
|
121
118
|
amount: string;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
metadata: {
|
|
125
|
-
asset: {
|
|
126
|
-
symbol?: string | undefined;
|
|
127
|
-
decimals?: number | undefined;
|
|
128
|
-
verified?: boolean | undefined;
|
|
129
|
-
quotes?: {
|
|
130
|
-
[x: string]: number;
|
|
131
|
-
} | undefined;
|
|
132
|
-
};
|
|
119
|
+
walletId: string;
|
|
120
|
+
otp?: string | undefined;
|
|
133
121
|
};
|
|
134
|
-
|
|
135
|
-
reason?: string | undefined;
|
|
136
|
-
txHash?: string | undefined;
|
|
137
|
-
fee?: string | undefined;
|
|
138
|
-
dateRequested: string;
|
|
139
|
-
datePolicyResolved?: string | undefined;
|
|
140
|
-
dateBroadcasted?: string | undefined;
|
|
141
|
-
dateConfirmed?: string | undefined;
|
|
142
|
-
approvalId?: string | undefined;
|
|
122
|
+
dateCreated: string;
|
|
143
123
|
};
|
|
144
124
|
export type CreateDepositRequest = CreateDepositParams & {
|
|
145
125
|
body: CreateDepositBody;
|
|
@@ -227,8 +207,12 @@ export type CreateWithdrawalParams = {
|
|
|
227
207
|
};
|
|
228
208
|
export type CreateWithdrawalResponse = {
|
|
229
209
|
id: string;
|
|
210
|
+
exchangeId: string;
|
|
211
|
+
accountId: string;
|
|
212
|
+
externalId?: string | undefined;
|
|
213
|
+
transferId?: string | undefined;
|
|
214
|
+
kind: "Withdrawal" | "Deposit";
|
|
230
215
|
walletId: string;
|
|
231
|
-
network: "Algorand" | "AlgorandTestnet" | "ArbitrumOne" | "ArbitrumGoerli" | "ArbitrumSepolia" | "AvalancheC" | "AvalancheCFuji" | "Base" | "BaseGoerli" | "BaseSepolia" | "Bitcoin" | "BitcoinTestnet3" | "Bsc" | "BscTestnet" | "Cardano" | "CardanoPreprod" | "Celo" | "CeloAlfajores" | "Ethereum" | "EthereumGoerli" | "EthereumSepolia" | "EthereumHolesky" | "FantomOpera" | "FantomTestnet" | "InternetComputer" | "Kusama" | "Litecoin" | "LitecoinTestnet" | "Optimism" | "OptimismGoerli" | "OptimismSepolia" | "Origyn" | "Polkadot" | "Westend" | "Polygon" | "PolygonAmoy" | "PolygonMumbai" | "Solana" | "SolanaDevnet" | "Stellar" | "StellarTestnet" | "Tezos" | "TezosGhostnet" | "Tron" | "TronNile" | "Ton" | "TonTestnet" | "XrpLedger" | "XrpLedgerTestnet" | "KeyECDSA" | "KeyECDSAStark" | "KeyEdDSA";
|
|
232
216
|
requester: {
|
|
233
217
|
userId: string;
|
|
234
218
|
tokenId?: string | undefined;
|
|
@@ -236,81 +220,57 @@ export type CreateWithdrawalResponse = {
|
|
|
236
220
|
};
|
|
237
221
|
requestBody: {
|
|
238
222
|
kind: "Native";
|
|
239
|
-
to: string | string | string | string | string | string | string | string | string | string | string | string | string;
|
|
240
223
|
amount: string;
|
|
241
|
-
memo?: string | undefined;
|
|
242
224
|
priority?: ("Slow" | "Standard" | "Fast") | undefined;
|
|
225
|
+
walletId: string;
|
|
226
|
+
otp?: string | undefined;
|
|
243
227
|
} | {
|
|
244
228
|
kind: "Erc20";
|
|
245
229
|
contract: string;
|
|
246
|
-
to: string;
|
|
247
230
|
amount: string;
|
|
248
231
|
priority?: ("Slow" | "Standard" | "Fast") | undefined;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
contract: string;
|
|
252
|
-
to: string;
|
|
253
|
-
tokenId: string;
|
|
254
|
-
priority?: ("Slow" | "Standard" | "Fast") | undefined;
|
|
232
|
+
walletId: string;
|
|
233
|
+
otp?: string | undefined;
|
|
255
234
|
} | {
|
|
256
235
|
kind: "Trc10";
|
|
257
236
|
tokenId: string;
|
|
258
|
-
to: string;
|
|
259
237
|
amount: string;
|
|
238
|
+
walletId: string;
|
|
239
|
+
otp?: string | undefined;
|
|
260
240
|
} | {
|
|
261
241
|
kind: "Trc20";
|
|
262
242
|
contract: string;
|
|
263
|
-
to: string;
|
|
264
243
|
amount: string;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
contract: string;
|
|
268
|
-
to: string;
|
|
269
|
-
tokenId: string;
|
|
244
|
+
walletId: string;
|
|
245
|
+
otp?: string | undefined;
|
|
270
246
|
} | {
|
|
271
247
|
kind: "Asa";
|
|
272
248
|
assetId: string;
|
|
273
|
-
to: string;
|
|
274
249
|
amount: string;
|
|
250
|
+
walletId: string;
|
|
251
|
+
otp?: string | undefined;
|
|
275
252
|
} | {
|
|
276
253
|
kind: "Sep41";
|
|
277
254
|
issuer: string;
|
|
278
255
|
assetCode: string;
|
|
279
|
-
to: string;
|
|
280
256
|
amount: string;
|
|
281
|
-
|
|
257
|
+
walletId: string;
|
|
258
|
+
otp?: string | undefined;
|
|
282
259
|
} | {
|
|
283
260
|
kind: "Spl" | "Spl2022";
|
|
284
|
-
to: string;
|
|
285
261
|
amount: string;
|
|
286
262
|
mint: string;
|
|
287
263
|
createDestinationAccount?: boolean | undefined;
|
|
264
|
+
walletId: string;
|
|
265
|
+
otp?: string | undefined;
|
|
288
266
|
} | {
|
|
289
267
|
kind: "Tep74";
|
|
290
|
-
to: string;
|
|
291
268
|
master: string;
|
|
292
269
|
amount: string;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
metadata: {
|
|
296
|
-
asset: {
|
|
297
|
-
symbol?: string | undefined;
|
|
298
|
-
decimals?: number | undefined;
|
|
299
|
-
verified?: boolean | undefined;
|
|
300
|
-
quotes?: {
|
|
301
|
-
[x: string]: number;
|
|
302
|
-
} | undefined;
|
|
303
|
-
};
|
|
270
|
+
walletId: string;
|
|
271
|
+
otp?: string | undefined;
|
|
304
272
|
};
|
|
305
|
-
|
|
306
|
-
reason?: string | undefined;
|
|
307
|
-
txHash?: string | undefined;
|
|
308
|
-
fee?: string | undefined;
|
|
309
|
-
dateRequested: string;
|
|
310
|
-
datePolicyResolved?: string | undefined;
|
|
311
|
-
dateBroadcasted?: string | undefined;
|
|
312
|
-
dateConfirmed?: string | undefined;
|
|
313
|
-
approvalId?: string | undefined;
|
|
273
|
+
dateCreated: string;
|
|
314
274
|
};
|
|
315
275
|
export type CreateWithdrawalRequest = CreateWithdrawalParams & {
|
|
316
276
|
body: CreateWithdrawalBody;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PermissionsClient = void 0;
|
|
4
4
|
const fetch_1 = require("../../utils/fetch");
|
|
5
|
+
const userActionFetch_1 = require("../../utils/userActionFetch");
|
|
5
6
|
const url_1 = require("../../utils/url");
|
|
6
7
|
class PermissionsClient {
|
|
7
8
|
constructor(apiOptions) {
|
|
@@ -12,7 +13,7 @@ class PermissionsClient {
|
|
|
12
13
|
path: request ?? {},
|
|
13
14
|
query: {},
|
|
14
15
|
});
|
|
15
|
-
const response = await (0,
|
|
16
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
16
17
|
method: 'PUT',
|
|
17
18
|
body: request.body,
|
|
18
19
|
apiOptions: this.apiOptions,
|
|
@@ -24,7 +25,7 @@ class PermissionsClient {
|
|
|
24
25
|
path: request ?? {},
|
|
25
26
|
query: {},
|
|
26
27
|
});
|
|
27
|
-
const response = await (0,
|
|
28
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
28
29
|
method: 'POST',
|
|
29
30
|
body: request.body,
|
|
30
31
|
apiOptions: this.apiOptions,
|
|
@@ -36,7 +37,7 @@ class PermissionsClient {
|
|
|
36
37
|
path: request ?? {},
|
|
37
38
|
query: {},
|
|
38
39
|
});
|
|
39
|
-
const response = await (0,
|
|
40
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
40
41
|
method: 'POST',
|
|
41
42
|
body: request.body,
|
|
42
43
|
apiOptions: this.apiOptions,
|
|
@@ -48,7 +49,7 @@ class PermissionsClient {
|
|
|
48
49
|
path: request ?? {},
|
|
49
50
|
query: {},
|
|
50
51
|
});
|
|
51
|
-
const response = await (0,
|
|
52
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
52
53
|
method: 'DELETE',
|
|
53
54
|
body: {},
|
|
54
55
|
apiOptions: this.apiOptions,
|
|
@@ -93,7 +94,7 @@ class PermissionsClient {
|
|
|
93
94
|
path: request ?? {},
|
|
94
95
|
query: {},
|
|
95
96
|
});
|
|
96
|
-
const response = await (0,
|
|
97
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
97
98
|
method: 'PUT',
|
|
98
99
|
body: request.body,
|
|
99
100
|
apiOptions: this.apiOptions,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PoliciesClient = void 0;
|
|
4
4
|
const fetch_1 = require("../../utils/fetch");
|
|
5
|
+
const userActionFetch_1 = require("../../utils/userActionFetch");
|
|
5
6
|
const url_1 = require("../../utils/url");
|
|
6
7
|
class PoliciesClient {
|
|
7
8
|
constructor(apiOptions) {
|
|
@@ -12,7 +13,7 @@ class PoliciesClient {
|
|
|
12
13
|
path: request ?? {},
|
|
13
14
|
query: {},
|
|
14
15
|
});
|
|
15
|
-
const response = await (0,
|
|
16
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
16
17
|
method: 'DELETE',
|
|
17
18
|
body: {},
|
|
18
19
|
apiOptions: this.apiOptions,
|
|
@@ -24,7 +25,7 @@ class PoliciesClient {
|
|
|
24
25
|
path: request ?? {},
|
|
25
26
|
query: {},
|
|
26
27
|
});
|
|
27
|
-
const response = await (0,
|
|
28
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
28
29
|
method: 'POST',
|
|
29
30
|
body: request.body,
|
|
30
31
|
apiOptions: this.apiOptions,
|
|
@@ -36,7 +37,7 @@ class PoliciesClient {
|
|
|
36
37
|
path: request ?? {},
|
|
37
38
|
query: {},
|
|
38
39
|
});
|
|
39
|
-
const response = await (0,
|
|
40
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
40
41
|
method: 'POST',
|
|
41
42
|
body: request.body,
|
|
42
43
|
apiOptions: this.apiOptions,
|
|
@@ -92,7 +93,7 @@ class PoliciesClient {
|
|
|
92
93
|
path: request ?? {},
|
|
93
94
|
query: {},
|
|
94
95
|
});
|
|
95
|
-
const response = await (0,
|
|
96
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
96
97
|
method: 'PUT',
|
|
97
98
|
body: request.body,
|
|
98
99
|
apiOptions: this.apiOptions,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WalletsClient = void 0;
|
|
4
4
|
const fetch_1 = require("../../utils/fetch");
|
|
5
|
+
const userActionFetch_1 = require("../../utils/userActionFetch");
|
|
5
6
|
const url_1 = require("../../utils/url");
|
|
6
7
|
class WalletsClient {
|
|
7
8
|
constructor(apiOptions) {
|
|
@@ -12,7 +13,7 @@ class WalletsClient {
|
|
|
12
13
|
path: request ?? {},
|
|
13
14
|
query: {},
|
|
14
15
|
});
|
|
15
|
-
const response = await (0,
|
|
16
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
16
17
|
method: 'POST',
|
|
17
18
|
body: request.body,
|
|
18
19
|
apiOptions: this.apiOptions,
|
|
@@ -24,7 +25,7 @@ class WalletsClient {
|
|
|
24
25
|
path: request ?? {},
|
|
25
26
|
query: {},
|
|
26
27
|
});
|
|
27
|
-
const response = await (0,
|
|
28
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
28
29
|
method: 'POST',
|
|
29
30
|
body: request.body,
|
|
30
31
|
apiOptions: this.apiOptions,
|
|
@@ -36,7 +37,7 @@ class WalletsClient {
|
|
|
36
37
|
path: request ?? {},
|
|
37
38
|
query: {},
|
|
38
39
|
});
|
|
39
|
-
const response = await (0,
|
|
40
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
40
41
|
method: 'POST',
|
|
41
42
|
body: request.body,
|
|
42
43
|
apiOptions: this.apiOptions,
|
|
@@ -48,7 +49,7 @@ class WalletsClient {
|
|
|
48
49
|
path: request ?? {},
|
|
49
50
|
query: {},
|
|
50
51
|
});
|
|
51
|
-
const response = await (0,
|
|
52
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
52
53
|
method: 'POST',
|
|
53
54
|
body: request.body,
|
|
54
55
|
apiOptions: this.apiOptions,
|
|
@@ -60,7 +61,7 @@ class WalletsClient {
|
|
|
60
61
|
path: request ?? {},
|
|
61
62
|
query: {},
|
|
62
63
|
});
|
|
63
|
-
const response = await (0,
|
|
64
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
64
65
|
method: 'POST',
|
|
65
66
|
body: request.body,
|
|
66
67
|
apiOptions: this.apiOptions,
|
|
@@ -149,7 +150,7 @@ class WalletsClient {
|
|
|
149
150
|
path: request ?? {},
|
|
150
151
|
query: {},
|
|
151
152
|
});
|
|
152
|
-
const response = await (0,
|
|
153
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
153
154
|
method: 'POST',
|
|
154
155
|
body: request.body,
|
|
155
156
|
apiOptions: this.apiOptions,
|
|
@@ -205,7 +206,7 @@ class WalletsClient {
|
|
|
205
206
|
path: request ?? {},
|
|
206
207
|
query: {},
|
|
207
208
|
});
|
|
208
|
-
const response = await (0,
|
|
209
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
209
210
|
method: 'PUT',
|
|
210
211
|
body: request.body,
|
|
211
212
|
apiOptions: this.apiOptions,
|
|
@@ -217,7 +218,7 @@ class WalletsClient {
|
|
|
217
218
|
path: request ?? {},
|
|
218
219
|
query: {},
|
|
219
220
|
});
|
|
220
|
-
const response = await (0,
|
|
221
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
221
222
|
method: 'POST',
|
|
222
223
|
body: request.body,
|
|
223
224
|
apiOptions: this.apiOptions,
|
|
@@ -229,7 +230,7 @@ class WalletsClient {
|
|
|
229
230
|
path: request ?? {},
|
|
230
231
|
query: {},
|
|
231
232
|
});
|
|
232
|
-
const response = await (0,
|
|
233
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
233
234
|
method: 'DELETE',
|
|
234
235
|
body: request.body,
|
|
235
236
|
apiOptions: this.apiOptions,
|
|
@@ -241,7 +242,7 @@ class WalletsClient {
|
|
|
241
242
|
path: request ?? {},
|
|
242
243
|
query: {},
|
|
243
244
|
});
|
|
244
|
-
const response = await (0,
|
|
245
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
245
246
|
method: 'PUT',
|
|
246
247
|
body: request.body,
|
|
247
248
|
apiOptions: this.apiOptions,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebhooksClient = void 0;
|
|
4
4
|
const fetch_1 = require("../../utils/fetch");
|
|
5
|
+
const userActionFetch_1 = require("../../utils/userActionFetch");
|
|
5
6
|
const url_1 = require("../../utils/url");
|
|
6
7
|
class WebhooksClient {
|
|
7
8
|
constructor(apiOptions) {
|
|
@@ -12,7 +13,7 @@ class WebhooksClient {
|
|
|
12
13
|
path: request ?? {},
|
|
13
14
|
query: {},
|
|
14
15
|
});
|
|
15
|
-
const response = await (0,
|
|
16
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
16
17
|
method: 'POST',
|
|
17
18
|
body: request.body,
|
|
18
19
|
apiOptions: this.apiOptions,
|
|
@@ -24,7 +25,7 @@ class WebhooksClient {
|
|
|
24
25
|
path: request ?? {},
|
|
25
26
|
query: {},
|
|
26
27
|
});
|
|
27
|
-
const response = await (0,
|
|
28
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
28
29
|
method: 'DELETE',
|
|
29
30
|
body: {},
|
|
30
31
|
apiOptions: this.apiOptions,
|
|
@@ -80,7 +81,7 @@ class WebhooksClient {
|
|
|
80
81
|
path: request ?? {},
|
|
81
82
|
query: {},
|
|
82
83
|
});
|
|
83
|
-
const response = await (0,
|
|
84
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
84
85
|
method: 'POST',
|
|
85
86
|
body: {},
|
|
86
87
|
apiOptions: this.apiOptions,
|
|
@@ -92,7 +93,7 @@ class WebhooksClient {
|
|
|
92
93
|
path: request ?? {},
|
|
93
94
|
query: {},
|
|
94
95
|
});
|
|
95
|
-
const response = await (0,
|
|
96
|
+
const response = await (0, userActionFetch_1.userActionFetch)(path, {
|
|
96
97
|
method: 'PUT',
|
|
97
98
|
body: request.body,
|
|
98
99
|
apiOptions: this.apiOptions,
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CredentialSigner } from '../signer';
|
|
2
|
+
export type DfnsBaseApiOptions = {
|
|
3
|
+
appId: string;
|
|
4
|
+
/** Needs to be specified to use any endpoint that requires authentication */
|
|
5
|
+
authToken?: string;
|
|
6
|
+
/** Only needs to be specified when using another API environment */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
appSecret?: string;
|
|
9
|
+
};
|
|
10
|
+
export type DfnsApiClientOptions = DfnsBaseApiOptions & {
|
|
11
|
+
/** Needs to be specified to use any endpoint that required User Action Signing flow */
|
|
12
|
+
signer?: CredentialSigner;
|
|
13
|
+
};
|
package/types/generic.js
ADDED
package/utils/fetch.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { DfnsBaseApiOptions } from '../
|
|
2
|
-
import { DfnsApiClientOptions } from '../dfnsApiClient';
|
|
1
|
+
import { DfnsBaseApiOptions } from '../types/generic';
|
|
3
2
|
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
4
3
|
export type FetchOptions<T> = {
|
|
5
4
|
method: HttpMethod;
|
|
@@ -8,5 +7,9 @@ export type FetchOptions<T> = {
|
|
|
8
7
|
apiOptions: T;
|
|
9
8
|
};
|
|
10
9
|
export type Fetch<T> = (resource: string | URL, options: FetchOptions<T>) => Promise<Response>;
|
|
10
|
+
export declare const fullUrl: <T extends DfnsBaseApiOptions>(fetch: Fetch<T>) => Fetch<T>;
|
|
11
|
+
export declare const jsonSerializer: <T>(fetch: Fetch<T>) => Fetch<T>;
|
|
12
|
+
export declare const errorHandler: <T>(fetch: Fetch<T>) => Fetch<T>;
|
|
13
|
+
export declare const catchPolicyPending: <T>(fetch: Fetch<T>) => Fetch<T>;
|
|
14
|
+
export declare const dfnsAuth: <T extends DfnsBaseApiOptions>(fetch: Fetch<T>) => Fetch<T>;
|
|
11
15
|
export declare const simpleFetch: Fetch<DfnsBaseApiOptions>;
|
|
12
|
-
export declare const userActionFetch: Fetch<DfnsApiClientOptions>;
|
package/utils/fetch.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.simpleFetch = exports.dfnsAuth = exports.catchPolicyPending = exports.errorHandler = exports.jsonSerializer = exports.fullUrl = void 0;
|
|
4
4
|
const cross_fetch_1 = require("cross-fetch");
|
|
5
|
-
const dfnsError_1 = require("../dfnsError");
|
|
6
|
-
const baseAuthApi_1 = require("../baseAuthApi");
|
|
7
5
|
const nonce_1 = require("./nonce");
|
|
6
|
+
const dfnsError_1 = require("../dfnsError");
|
|
8
7
|
const DEFAULT_DFNS_BASE_URL = 'https://api.dfns.io';
|
|
9
8
|
const fullUrl = (fetch) => {
|
|
10
9
|
return async (resource, options) => {
|
|
@@ -13,6 +12,7 @@ const fullUrl = (fetch) => {
|
|
|
13
12
|
return fetch(resource, options);
|
|
14
13
|
};
|
|
15
14
|
};
|
|
15
|
+
exports.fullUrl = fullUrl;
|
|
16
16
|
const jsonSerializer = (fetch) => {
|
|
17
17
|
return async (resource, options) => {
|
|
18
18
|
if (options.body) {
|
|
@@ -25,6 +25,7 @@ const jsonSerializer = (fetch) => {
|
|
|
25
25
|
return fetch(resource, options);
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
+
exports.jsonSerializer = jsonSerializer;
|
|
28
29
|
const errorHandler = (fetch) => {
|
|
29
30
|
return async (resource, options) => {
|
|
30
31
|
const response = await fetch(resource, options);
|
|
@@ -42,6 +43,7 @@ const errorHandler = (fetch) => {
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
};
|
|
46
|
+
exports.errorHandler = errorHandler;
|
|
45
47
|
// raise a 202 response by policy execution as error
|
|
46
48
|
const catchPolicyPending = (fetch) => {
|
|
47
49
|
return async (resource, options) => {
|
|
@@ -54,6 +56,7 @@ const catchPolicyPending = (fetch) => {
|
|
|
54
56
|
}
|
|
55
57
|
};
|
|
56
58
|
};
|
|
59
|
+
exports.catchPolicyPending = catchPolicyPending;
|
|
57
60
|
const dfnsAuth = (fetch) => {
|
|
58
61
|
return async (resource, options) => {
|
|
59
62
|
const { appId, appSecret, authToken } = options.apiOptions;
|
|
@@ -77,38 +80,5 @@ const dfnsAuth = (fetch) => {
|
|
|
77
80
|
return fetch(resource, options);
|
|
78
81
|
};
|
|
79
82
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (options.method !== 'GET') {
|
|
83
|
-
const apiOptions = {
|
|
84
|
-
...options.apiOptions,
|
|
85
|
-
baseUrl: options.apiOptions.baseAuthUrl || options.apiOptions.baseUrl,
|
|
86
|
-
};
|
|
87
|
-
if (!apiOptions.signer) {
|
|
88
|
-
throw new dfnsError_1.DfnsError(-1, 'A "signer" needs to be passed to Dfns client.', {
|
|
89
|
-
detail: `Most non-readonly endpoints require "User Action Signing" flow.` +
|
|
90
|
-
` During that flow, the credential "signer" that you passed will handle signing` +
|
|
91
|
-
` the user action challenge, using your credential.`,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
|
|
95
|
-
userActionPayload: options.body ?? '',
|
|
96
|
-
userActionHttpMethod: options.method,
|
|
97
|
-
userActionHttpPath: resource.pathname,
|
|
98
|
-
userActionServerKind: apiOptions?.userActionServerKind || 'Api',
|
|
99
|
-
}, apiOptions);
|
|
100
|
-
const assertion = await apiOptions.signer.sign(challenge);
|
|
101
|
-
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge({
|
|
102
|
-
challengeIdentifier: challenge.challengeIdentifier,
|
|
103
|
-
firstFactor: assertion,
|
|
104
|
-
}, apiOptions);
|
|
105
|
-
options.headers = {
|
|
106
|
-
'x-dfns-useraction': userAction,
|
|
107
|
-
...(options.headers ?? {}),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return fetch(resource, options);
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
exports.simpleFetch = fullUrl(jsonSerializer(dfnsAuth(catchPolicyPending(errorHandler(cross_fetch_1.fetch)))));
|
|
114
|
-
exports.userActionFetch = fullUrl(jsonSerializer(dfnsAuth(userAction(catchPolicyPending(errorHandler(cross_fetch_1.fetch))))));
|
|
83
|
+
exports.dfnsAuth = dfnsAuth;
|
|
84
|
+
exports.simpleFetch = (0, exports.fullUrl)((0, exports.jsonSerializer)((0, exports.dfnsAuth)((0, exports.catchPolicyPending)((0, exports.errorHandler)(cross_fetch_1.fetch)))));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userActionFetch = void 0;
|
|
4
|
+
const cross_fetch_1 = require("cross-fetch");
|
|
5
|
+
const fetch_1 = require("./fetch");
|
|
6
|
+
const baseAuthApi_1 = require("../baseAuthApi");
|
|
7
|
+
const dfnsError_1 = require("../dfnsError");
|
|
8
|
+
const userAction = (fetch) => {
|
|
9
|
+
return async (resource, options) => {
|
|
10
|
+
if (options.method !== 'GET') {
|
|
11
|
+
const apiOptions = {
|
|
12
|
+
...options.apiOptions,
|
|
13
|
+
baseUrl: options.apiOptions.baseAuthUrl || options.apiOptions.baseUrl,
|
|
14
|
+
};
|
|
15
|
+
if (!apiOptions.signer) {
|
|
16
|
+
throw new dfnsError_1.DfnsError(-1, 'A "signer" needs to be passed to Dfns client.', {
|
|
17
|
+
detail: `Most non-readonly endpoints require "User Action Signing" flow.` +
|
|
18
|
+
` During that flow, the credential "signer" that you passed will handle signing` +
|
|
19
|
+
` the user action challenge, using your credential.`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
|
|
23
|
+
userActionPayload: options.body ?? '',
|
|
24
|
+
userActionHttpMethod: options.method,
|
|
25
|
+
userActionHttpPath: resource.pathname,
|
|
26
|
+
userActionServerKind: apiOptions?.userActionServerKind || 'Api',
|
|
27
|
+
}, apiOptions);
|
|
28
|
+
const assertion = await apiOptions.signer.sign(challenge);
|
|
29
|
+
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge({
|
|
30
|
+
challengeIdentifier: challenge.challengeIdentifier,
|
|
31
|
+
firstFactor: assertion,
|
|
32
|
+
}, apiOptions);
|
|
33
|
+
options.headers = {
|
|
34
|
+
'x-dfns-useraction': userAction,
|
|
35
|
+
...(options.headers ?? {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return fetch(resource, options);
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.userActionFetch = (0, fetch_1.fullUrl)((0, fetch_1.jsonSerializer)((0, fetch_1.dfnsAuth)(userAction((0, fetch_1.catchPolicyPending)((0, fetch_1.errorHandler)(cross_fetch_1.fetch))))));
|