@dfns/sdk 0.1.0 → 0.1.2-rc.1
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/codegen/Assets/AssetsClient.js +1 -2
- package/codegen/Assets/DelegatedAssetsClient.js +1 -2
- package/codegen/Permissions/DelegatedPermissionsClient.js +1 -2
- package/codegen/Permissions/PermissionsClient.js +1 -2
- package/codegen/PolicyExecution/DelegatedPolicyExecutionClient.js +1 -2
- package/codegen/PolicyExecution/PolicyExecutionClient.js +1 -2
- package/codegen/PolicyManagement/DelegatedPolicyManagementClient.js +1 -2
- package/codegen/PolicyManagement/PolicyManagementClient.js +1 -2
- package/codegen/PublicKeys/DelegatedPublicKeysClient.js +2 -4
- package/codegen/PublicKeys/PublicKeysClient.js +2 -4
- package/codegen/Wallets/DelegatedWalletsClient.d.ts +2 -0
- package/codegen/Wallets/DelegatedWalletsClient.js +32 -10
- package/codegen/Wallets/WalletsClient.d.ts +1 -0
- package/codegen/Wallets/WalletsClient.js +17 -10
- package/codegen/Wallets/types.d.ts +5 -0
- package/codegen/datamodel/Wallets/responses.d.ts +6 -1
- package/codegen/datamodel/Wallets/types.d.ts +13 -0
- package/codegen/datamodel/Wallets/types.js +6 -0
- package/dfnsApiClient.d.ts +2 -0
- package/dfnsApiClient.js +4 -0
- package/dfnsDelegatedApiClient.d.ts +2 -0
- package/dfnsDelegatedApiClient.js +4 -0
- package/generated/webhooks/client.d.ts +14 -0
- package/generated/webhooks/client.js +101 -0
- package/generated/webhooks/delegatedClient.d.ts +19 -0
- package/generated/webhooks/delegatedClient.js +164 -0
- package/generated/webhooks/index.d.ts +3 -0
- package/generated/webhooks/index.js +19 -0
- package/generated/webhooks/types.d.ts +171 -0
- package/generated/webhooks/types.js +2 -0
- package/package.json +1 -1
- package/utils/fetch.js +6 -10
- package/utils/url.d.ts +1 -1
- package/utils/url.js +2 -1
|
@@ -68,10 +68,9 @@ class AssetsClient {
|
|
|
68
68
|
return response.json();
|
|
69
69
|
}
|
|
70
70
|
async listAssetAccounts(request) {
|
|
71
|
-
var _a;
|
|
72
71
|
const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', {
|
|
73
72
|
path: {},
|
|
74
|
-
query:
|
|
73
|
+
query: request.query ?? {},
|
|
75
74
|
});
|
|
76
75
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
77
76
|
method: 'GET',
|
|
@@ -99,10 +99,9 @@ class DelegatedAssetsClient {
|
|
|
99
99
|
return response.json();
|
|
100
100
|
}
|
|
101
101
|
async listAssetAccounts(request) {
|
|
102
|
-
var _a;
|
|
103
102
|
const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', {
|
|
104
103
|
path: {},
|
|
105
|
-
query:
|
|
104
|
+
query: request.query ?? {},
|
|
106
105
|
});
|
|
107
106
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
108
107
|
method: 'GET',
|
|
@@ -270,10 +270,9 @@ class DelegatedPermissionsClient {
|
|
|
270
270
|
return response.json();
|
|
271
271
|
}
|
|
272
272
|
async listPermissionAssignments(request) {
|
|
273
|
-
var _a;
|
|
274
273
|
const path = (0, url_1.buildPathAndQuery)('/permissions/assignments', {
|
|
275
274
|
path: {},
|
|
276
|
-
query:
|
|
275
|
+
query: request.query ?? {},
|
|
277
276
|
});
|
|
278
277
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
279
278
|
method: 'GET',
|
|
@@ -142,10 +142,9 @@ class PermissionsClient {
|
|
|
142
142
|
return response.json();
|
|
143
143
|
}
|
|
144
144
|
async listPermissionAssignments(request) {
|
|
145
|
-
var _a;
|
|
146
145
|
const path = (0, url_1.buildPathAndQuery)('/permissions/assignments', {
|
|
147
146
|
path: {},
|
|
148
|
-
query:
|
|
147
|
+
query: request.query ?? {},
|
|
149
148
|
});
|
|
150
149
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
151
150
|
method: 'GET',
|
|
@@ -9,10 +9,9 @@ class DelegatedPolicyExecutionClient {
|
|
|
9
9
|
this.apiOptions = apiOptions;
|
|
10
10
|
}
|
|
11
11
|
async listPolicyControlExecutions(request) {
|
|
12
|
-
var _a;
|
|
13
12
|
const path = (0, url_1.buildPathAndQuery)('/policies/policy-control-executions', {
|
|
14
13
|
path: {},
|
|
15
|
-
query:
|
|
14
|
+
query: request.query ?? {},
|
|
16
15
|
});
|
|
17
16
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
18
17
|
method: 'GET',
|
|
@@ -8,10 +8,9 @@ class PolicyExecutionClient {
|
|
|
8
8
|
this.apiOptions = apiOptions;
|
|
9
9
|
}
|
|
10
10
|
async listPolicyControlExecutions(request) {
|
|
11
|
-
var _a;
|
|
12
11
|
const path = (0, url_1.buildPathAndQuery)('/policies/policy-control-executions', {
|
|
13
12
|
path: {},
|
|
14
|
-
query:
|
|
13
|
+
query: request.query ?? {},
|
|
15
14
|
});
|
|
16
15
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
17
16
|
method: 'GET',
|
|
@@ -199,10 +199,9 @@ class DelegatedPolicyManagementClient {
|
|
|
199
199
|
return response.json();
|
|
200
200
|
}
|
|
201
201
|
async listPolicyRules(request) {
|
|
202
|
-
var _a;
|
|
203
202
|
const path = (0, url_1.buildPathAndQuery)('/policies/policy-rules', {
|
|
204
203
|
path: {},
|
|
205
|
-
query:
|
|
204
|
+
query: request.query ?? {},
|
|
206
205
|
});
|
|
207
206
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
208
207
|
method: 'GET',
|
|
@@ -121,10 +121,9 @@ class PolicyManagementClient {
|
|
|
121
121
|
return response.json();
|
|
122
122
|
}
|
|
123
123
|
async listPolicyRules(request) {
|
|
124
|
-
var _a;
|
|
125
124
|
const path = (0, url_1.buildPathAndQuery)('/policies/policy-rules', {
|
|
126
125
|
path: {},
|
|
127
|
-
query:
|
|
126
|
+
query: request.query ?? {},
|
|
128
127
|
});
|
|
129
128
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
130
129
|
method: 'GET',
|
|
@@ -58,10 +58,9 @@ class DelegatedPublicKeysClient {
|
|
|
58
58
|
return response.json();
|
|
59
59
|
}
|
|
60
60
|
async getAddressForNetwork(request) {
|
|
61
|
-
var _a;
|
|
62
61
|
const path = (0, url_1.buildPathAndQuery)('/public-keys/:publicKeyId/address', {
|
|
63
62
|
path: { publicKeyId: request.publicKeyId },
|
|
64
|
-
query:
|
|
63
|
+
query: request.query ?? {},
|
|
65
64
|
});
|
|
66
65
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
67
66
|
method: 'GET',
|
|
@@ -138,10 +137,9 @@ class DelegatedPublicKeysClient {
|
|
|
138
137
|
return response.json();
|
|
139
138
|
}
|
|
140
139
|
async listTransactions(request) {
|
|
141
|
-
var _a;
|
|
142
140
|
const path = (0, url_1.buildPathAndQuery)('/public-keys/:publicKeyId/transactions', {
|
|
143
141
|
path: { publicKeyId: request.publicKeyId },
|
|
144
|
-
query:
|
|
142
|
+
query: request.query ?? {},
|
|
145
143
|
});
|
|
146
144
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
147
145
|
method: 'GET',
|
|
@@ -42,10 +42,9 @@ class PublicKeysClient {
|
|
|
42
42
|
return response.json();
|
|
43
43
|
}
|
|
44
44
|
async getAddressForNetwork(request) {
|
|
45
|
-
var _a;
|
|
46
45
|
const path = (0, url_1.buildPathAndQuery)('/public-keys/:publicKeyId/address', {
|
|
47
46
|
path: { publicKeyId: request.publicKeyId },
|
|
48
|
-
query:
|
|
47
|
+
query: request.query ?? {},
|
|
49
48
|
});
|
|
50
49
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
51
50
|
method: 'GET',
|
|
@@ -92,10 +91,9 @@ class PublicKeysClient {
|
|
|
92
91
|
return response.json();
|
|
93
92
|
}
|
|
94
93
|
async listTransactions(request) {
|
|
95
|
-
var _a;
|
|
96
94
|
const path = (0, url_1.buildPathAndQuery)('/public-keys/:publicKeyId/transactions', {
|
|
97
95
|
path: { publicKeyId: request.publicKeyId },
|
|
98
|
-
query:
|
|
96
|
+
query: request.query ?? {},
|
|
99
97
|
});
|
|
100
98
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
101
99
|
method: 'GET',
|
|
@@ -27,4 +27,6 @@ export declare class DelegatedWalletsClient {
|
|
|
27
27
|
importWalletComplete(request: T.ImportWalletRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.ImportWalletResponse>;
|
|
28
28
|
exportWalletInit(request: T.ExportWalletRequest): Promise<UserActionChallengeResponse>;
|
|
29
29
|
exportWalletComplete(request: T.ExportWalletRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.ExportWalletResponse>;
|
|
30
|
+
delegateWalletInit(request: T.DelegateWalletRequest): Promise<UserActionChallengeResponse>;
|
|
31
|
+
delegateWalletComplete(request: T.DelegateWalletRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.DelegateWalletResponse>;
|
|
30
32
|
}
|
|
@@ -69,10 +69,9 @@ class DelegatedWalletsClient {
|
|
|
69
69
|
return response.json();
|
|
70
70
|
}
|
|
71
71
|
async listWallets(request) {
|
|
72
|
-
var _a;
|
|
73
72
|
const path = (0, url_1.buildPathAndQuery)('/wallets', {
|
|
74
73
|
path: {},
|
|
75
|
-
query:
|
|
74
|
+
query: request.query ?? {},
|
|
76
75
|
});
|
|
77
76
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
78
77
|
method: 'GET',
|
|
@@ -81,10 +80,9 @@ class DelegatedWalletsClient {
|
|
|
81
80
|
return response.json();
|
|
82
81
|
}
|
|
83
82
|
async getWalletHistory(request) {
|
|
84
|
-
var _a;
|
|
85
83
|
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/history', {
|
|
86
84
|
path: { walletId: request.walletId },
|
|
87
|
-
query:
|
|
85
|
+
query: request.query ?? {},
|
|
88
86
|
});
|
|
89
87
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
90
88
|
method: 'GET',
|
|
@@ -131,10 +129,9 @@ class DelegatedWalletsClient {
|
|
|
131
129
|
return response.json();
|
|
132
130
|
}
|
|
133
131
|
async listTransfers(request) {
|
|
134
|
-
var _a;
|
|
135
132
|
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/transfers', {
|
|
136
133
|
path: { walletId: request.walletId },
|
|
137
|
-
query:
|
|
134
|
+
query: request.query ?? {},
|
|
138
135
|
});
|
|
139
136
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
140
137
|
method: 'GET',
|
|
@@ -184,10 +181,9 @@ class DelegatedWalletsClient {
|
|
|
184
181
|
return response.json();
|
|
185
182
|
}
|
|
186
183
|
async listTransactions(request) {
|
|
187
|
-
var _a;
|
|
188
184
|
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/transactions', {
|
|
189
185
|
path: { walletId: request.walletId },
|
|
190
|
-
query:
|
|
186
|
+
query: request.query ?? {},
|
|
191
187
|
});
|
|
192
188
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
193
189
|
method: 'GET',
|
|
@@ -234,10 +230,9 @@ class DelegatedWalletsClient {
|
|
|
234
230
|
return response.json();
|
|
235
231
|
}
|
|
236
232
|
async listSignatures(request) {
|
|
237
|
-
var _a;
|
|
238
233
|
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/signatures', {
|
|
239
234
|
path: { walletId: request.walletId },
|
|
240
|
-
query:
|
|
235
|
+
query: request.query ?? {},
|
|
241
236
|
});
|
|
242
237
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
243
238
|
method: 'GET',
|
|
@@ -299,5 +294,32 @@ class DelegatedWalletsClient {
|
|
|
299
294
|
});
|
|
300
295
|
return response.json();
|
|
301
296
|
}
|
|
297
|
+
async delegateWalletInit(request) {
|
|
298
|
+
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/delegate', {
|
|
299
|
+
path: { walletId: request.walletId },
|
|
300
|
+
query: {},
|
|
301
|
+
});
|
|
302
|
+
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
|
|
303
|
+
userActionHttpMethod: 'POST',
|
|
304
|
+
userActionHttpPath: path,
|
|
305
|
+
userActionPayload: JSON.stringify(request.body),
|
|
306
|
+
userActionServerKind: 'Api',
|
|
307
|
+
}, this.apiOptions);
|
|
308
|
+
return challenge;
|
|
309
|
+
}
|
|
310
|
+
async delegateWalletComplete(request, signedChallenge) {
|
|
311
|
+
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/delegate', {
|
|
312
|
+
path: { walletId: request.walletId },
|
|
313
|
+
query: {},
|
|
314
|
+
});
|
|
315
|
+
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
|
|
316
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
317
|
+
method: 'POST',
|
|
318
|
+
body: request.body,
|
|
319
|
+
headers: { 'x-dfns-useraction': userAction },
|
|
320
|
+
apiOptions: this.apiOptions,
|
|
321
|
+
});
|
|
322
|
+
return response.json();
|
|
323
|
+
}
|
|
302
324
|
}
|
|
303
325
|
exports.DelegatedWalletsClient = DelegatedWalletsClient;
|
|
@@ -20,4 +20,5 @@ export declare class WalletsClient {
|
|
|
20
20
|
listSignatures(request: T.ListSignaturesRequest): Promise<T.ListSignaturesResponse>;
|
|
21
21
|
importWallet(request: T.ImportWalletRequest): Promise<T.ImportWalletResponse>;
|
|
22
22
|
exportWallet(request: T.ExportWalletRequest): Promise<T.ExportWalletResponse>;
|
|
23
|
+
delegateWallet(request: T.DelegateWalletRequest): Promise<T.DelegateWalletResponse>;
|
|
23
24
|
}
|
|
@@ -53,10 +53,9 @@ class WalletsClient {
|
|
|
53
53
|
return response.json();
|
|
54
54
|
}
|
|
55
55
|
async listWallets(request) {
|
|
56
|
-
var _a;
|
|
57
56
|
const path = (0, url_1.buildPathAndQuery)('/wallets', {
|
|
58
57
|
path: {},
|
|
59
|
-
query:
|
|
58
|
+
query: request.query ?? {},
|
|
60
59
|
});
|
|
61
60
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
62
61
|
method: 'GET',
|
|
@@ -65,10 +64,9 @@ class WalletsClient {
|
|
|
65
64
|
return response.json();
|
|
66
65
|
}
|
|
67
66
|
async getWalletHistory(request) {
|
|
68
|
-
var _a;
|
|
69
67
|
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/history', {
|
|
70
68
|
path: { walletId: request.walletId },
|
|
71
|
-
query:
|
|
69
|
+
query: request.query ?? {},
|
|
72
70
|
});
|
|
73
71
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
74
72
|
method: 'GET',
|
|
@@ -100,10 +98,9 @@ class WalletsClient {
|
|
|
100
98
|
return response.json();
|
|
101
99
|
}
|
|
102
100
|
async listTransfers(request) {
|
|
103
|
-
var _a;
|
|
104
101
|
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/transfers', {
|
|
105
102
|
path: { walletId: request.walletId },
|
|
106
|
-
query:
|
|
103
|
+
query: request.query ?? {},
|
|
107
104
|
});
|
|
108
105
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
109
106
|
method: 'GET',
|
|
@@ -138,10 +135,9 @@ class WalletsClient {
|
|
|
138
135
|
return response.json();
|
|
139
136
|
}
|
|
140
137
|
async listTransactions(request) {
|
|
141
|
-
var _a;
|
|
142
138
|
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/transactions', {
|
|
143
139
|
path: { walletId: request.walletId },
|
|
144
|
-
query:
|
|
140
|
+
query: request.query ?? {},
|
|
145
141
|
});
|
|
146
142
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
147
143
|
method: 'GET',
|
|
@@ -173,10 +169,9 @@ class WalletsClient {
|
|
|
173
169
|
return response.json();
|
|
174
170
|
}
|
|
175
171
|
async listSignatures(request) {
|
|
176
|
-
var _a;
|
|
177
172
|
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/signatures', {
|
|
178
173
|
path: { walletId: request.walletId },
|
|
179
|
-
query:
|
|
174
|
+
query: request.query ?? {},
|
|
180
175
|
});
|
|
181
176
|
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
182
177
|
method: 'GET',
|
|
@@ -208,5 +203,17 @@ class WalletsClient {
|
|
|
208
203
|
});
|
|
209
204
|
return response.json();
|
|
210
205
|
}
|
|
206
|
+
async delegateWallet(request) {
|
|
207
|
+
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/delegate', {
|
|
208
|
+
path: { walletId: request.walletId },
|
|
209
|
+
query: {},
|
|
210
|
+
});
|
|
211
|
+
const response = await (0, fetch_1.userActionFetch)(path, {
|
|
212
|
+
method: 'POST',
|
|
213
|
+
body: request.body,
|
|
214
|
+
apiOptions: this.apiOptions,
|
|
215
|
+
});
|
|
216
|
+
return response.json();
|
|
217
|
+
}
|
|
211
218
|
}
|
|
212
219
|
exports.WalletsClient = WalletsClient;
|
|
@@ -94,3 +94,8 @@ export type ExportWalletRequest = {
|
|
|
94
94
|
body: Wallets.ExportWalletBody;
|
|
95
95
|
};
|
|
96
96
|
export type ExportWalletResponse = Wallets.ExportedSigningKey;
|
|
97
|
+
export type DelegateWalletRequest = {
|
|
98
|
+
walletId: Foundations.EntityId;
|
|
99
|
+
body: Wallets.DelegateWalletBody;
|
|
100
|
+
};
|
|
101
|
+
export type DelegateWalletResponse = Wallets.DelegateWalletResult;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BadRequestError, EntityNotFoundError, ForbiddenError, UnauthorizedError } from '../Foundations';
|
|
2
|
-
import { ExportedSigningKey, PaginatedEventHistory, PaginatedSignatureList, PaginatedTransactionList, PaginatedTransferList, PaginatedWalletList, SignatureRequest, TransactionRequest, TransferRequest, Wallet, WalletAssets, WalletNfts } from './types';
|
|
2
|
+
import { DelegateWalletResult, ExportedSigningKey, PaginatedEventHistory, PaginatedSignatureList, PaginatedTransactionList, PaginatedTransferList, PaginatedWalletList, SignatureRequest, TransactionRequest, TransferRequest, Wallet, WalletAssets, WalletNfts } from './types';
|
|
3
3
|
export type CreateWalletSuccess = Wallet;
|
|
4
4
|
export type CreateWalletError = {
|
|
5
5
|
error: BadRequestError | ForbiddenError | UnauthorizedError | ForbiddenError | BadRequestError | EntityNotFoundError;
|
|
@@ -85,3 +85,8 @@ export type ExportWalletError = {
|
|
|
85
85
|
error: BadRequestError | ForbiddenError | UnauthorizedError | ForbiddenError | BadRequestError | EntityNotFoundError;
|
|
86
86
|
};
|
|
87
87
|
export type ExportWalletResponse = ExportWalletSuccess | ExportWalletError;
|
|
88
|
+
export type DelegateWalletSuccess = DelegateWalletResult;
|
|
89
|
+
export type DelegateWalletError = {
|
|
90
|
+
error: BadRequestError | ForbiddenError | UnauthorizedError | ForbiddenError | BadRequestError | EntityNotFoundError;
|
|
91
|
+
};
|
|
92
|
+
export type DelegateWalletResponse = DelegateWalletSuccess | DelegateWalletError;
|
|
@@ -309,6 +309,10 @@ export type ExportedSigningKey = {
|
|
|
309
309
|
*/
|
|
310
310
|
encryptedKeyShares: EncryptedKeyShare[];
|
|
311
311
|
};
|
|
312
|
+
export type DelegateWalletResult = {
|
|
313
|
+
walletId: EntityId;
|
|
314
|
+
status: string;
|
|
315
|
+
};
|
|
312
316
|
export type CreateWalletBody = {
|
|
313
317
|
network: BlockchainNetwork;
|
|
314
318
|
externalId?: string;
|
|
@@ -335,6 +339,12 @@ export type ExportWalletBody = {
|
|
|
335
339
|
*/
|
|
336
340
|
supportedSchemes: SupportedExportScheme[];
|
|
337
341
|
};
|
|
342
|
+
export type DelegateWalletBody = {
|
|
343
|
+
/**
|
|
344
|
+
* Encryption public key that will be used by signers to encrypt the exported wallet key shares. The purpose of encrypting key shares is to have them extra-safe and not usable in any place in the system until they are safely returned back to the client issuing the export command.
|
|
345
|
+
*/
|
|
346
|
+
userId: EntityId;
|
|
347
|
+
};
|
|
338
348
|
export type TransferAssetBody = TransferNativeAsset | TransferErc20Asset | TransferErc721Asset;
|
|
339
349
|
export type BroadcastTransactionBody = BroadcastTransaction | BroadcastEvmTransaction | BroadcastEip1559Transaction | BroadcastEvmLegacyTransaction | BroadcastPsbt;
|
|
340
350
|
export type GenerateSignatureBody = SignHash | SignMessage | SignTransaction | SignEip712TypedData | SignPsbt;
|
|
@@ -412,8 +422,11 @@ export declare enum SignatureStatus {
|
|
|
412
422
|
export declare enum BlockchainNetwork {
|
|
413
423
|
ArbitrumOne = "ArbitrumOne",
|
|
414
424
|
ArbitrumGoerli = "ArbitrumGoerli",
|
|
425
|
+
ArbitrumSepolia = "ArbitrumSepolia",
|
|
415
426
|
AvalancheC = "AvalancheC",
|
|
416
427
|
AvalancheCFuji = "AvalancheCFuji",
|
|
428
|
+
Base = "Base",
|
|
429
|
+
BaseGoerli = "BaseGoerli",
|
|
417
430
|
Bitcoin = "Bitcoin",
|
|
418
431
|
BitcoinTestnet3 = "BitcoinTestnet3",
|
|
419
432
|
Bsc = "Bsc",
|
|
@@ -148,10 +148,16 @@ var BlockchainNetwork;
|
|
|
148
148
|
BlockchainNetwork["ArbitrumOne"] = "ArbitrumOne";
|
|
149
149
|
// FIXME: Missing documentation for ArbitrumGoerli
|
|
150
150
|
BlockchainNetwork["ArbitrumGoerli"] = "ArbitrumGoerli";
|
|
151
|
+
// FIXME: Missing documentation for ArbitrumSepolia
|
|
152
|
+
BlockchainNetwork["ArbitrumSepolia"] = "ArbitrumSepolia";
|
|
151
153
|
// FIXME: Missing documentation for AvalancheC
|
|
152
154
|
BlockchainNetwork["AvalancheC"] = "AvalancheC";
|
|
153
155
|
// FIXME: Missing documentation for AvalancheCFuji
|
|
154
156
|
BlockchainNetwork["AvalancheCFuji"] = "AvalancheCFuji";
|
|
157
|
+
// FIXME: Missing documentation for Base
|
|
158
|
+
BlockchainNetwork["Base"] = "Base";
|
|
159
|
+
// FIXME: Missing documentation for BaseGoerli
|
|
160
|
+
BlockchainNetwork["BaseGoerli"] = "BaseGoerli";
|
|
155
161
|
// FIXME: Missing documentation for Bitcoin
|
|
156
162
|
BlockchainNetwork["Bitcoin"] = "Bitcoin";
|
|
157
163
|
// FIXME: Missing documentation for BitcoinTestnet3
|
package/dfnsApiClient.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { PolicyManagementClient } from './codegen/PolicyManagement';
|
|
|
9
9
|
import { PublicKeysClient } from './codegen/PublicKeys';
|
|
10
10
|
import { WalletsClient } from './codegen/Wallets';
|
|
11
11
|
import { SignersClient } from './codegen/Signers';
|
|
12
|
+
import { WebhooksClient } from './generated/webhooks';
|
|
12
13
|
import { CredentialSigner } from './signer';
|
|
13
14
|
export type DfnsApiClientOptions = DfnsBaseApiOptions & {
|
|
14
15
|
signer: CredentialSigner;
|
|
@@ -25,5 +26,6 @@ export declare class DfnsApiClient {
|
|
|
25
26
|
get policyManagement(): PolicyManagementClient;
|
|
26
27
|
get publicKeys(): PublicKeysClient;
|
|
27
28
|
get wallets(): WalletsClient;
|
|
29
|
+
get webhooks(): WebhooksClient;
|
|
28
30
|
get signers(): SignersClient;
|
|
29
31
|
}
|
package/dfnsApiClient.js
CHANGED
|
@@ -11,6 +11,7 @@ const PolicyManagement_1 = require("./codegen/PolicyManagement");
|
|
|
11
11
|
const PublicKeys_1 = require("./codegen/PublicKeys");
|
|
12
12
|
const Wallets_1 = require("./codegen/Wallets");
|
|
13
13
|
const Signers_1 = require("./codegen/Signers");
|
|
14
|
+
const webhooks_1 = require("./generated/webhooks");
|
|
14
15
|
class DfnsApiClient {
|
|
15
16
|
constructor(apiOptions) {
|
|
16
17
|
this.apiOptions = apiOptions;
|
|
@@ -42,6 +43,9 @@ class DfnsApiClient {
|
|
|
42
43
|
get wallets() {
|
|
43
44
|
return new Wallets_1.WalletsClient(this.apiOptions);
|
|
44
45
|
}
|
|
46
|
+
get webhooks() {
|
|
47
|
+
return new webhooks_1.WebhooksClient(this.apiOptions);
|
|
48
|
+
}
|
|
45
49
|
get signers() {
|
|
46
50
|
return new Signers_1.SignersClient(this.apiOptions);
|
|
47
51
|
}
|
|
@@ -8,6 +8,7 @@ import { DelegatedPolicyExecutionClient } from './codegen/PolicyExecution';
|
|
|
8
8
|
import { DelegatedPolicyManagementClient } from './codegen/PolicyManagement';
|
|
9
9
|
import { DelegatedPublicKeysClient } from './codegen/PublicKeys';
|
|
10
10
|
import { DelegatedSignersClient } from './codegen/Signers';
|
|
11
|
+
import { DelegatedWebhooksClient } from './generated/webhooks';
|
|
11
12
|
import { DelegatedWalletsClient } from './codegen/Wallets';
|
|
12
13
|
export type DfnsDelegatedApiClientOptions = DfnsBaseApiOptions & {
|
|
13
14
|
authToken: string;
|
|
@@ -24,5 +25,6 @@ export declare class DfnsDelegatedApiClient {
|
|
|
24
25
|
get policyManagement(): DelegatedPolicyManagementClient;
|
|
25
26
|
get publicKeys(): DelegatedPublicKeysClient;
|
|
26
27
|
get wallets(): DelegatedWalletsClient;
|
|
28
|
+
get webhooks(): DelegatedWebhooksClient;
|
|
27
29
|
get signers(): DelegatedSignersClient;
|
|
28
30
|
}
|
|
@@ -10,6 +10,7 @@ const PolicyExecution_1 = require("./codegen/PolicyExecution");
|
|
|
10
10
|
const PolicyManagement_1 = require("./codegen/PolicyManagement");
|
|
11
11
|
const PublicKeys_1 = require("./codegen/PublicKeys");
|
|
12
12
|
const Signers_1 = require("./codegen/Signers");
|
|
13
|
+
const webhooks_1 = require("./generated/webhooks");
|
|
13
14
|
const Wallets_1 = require("./codegen/Wallets");
|
|
14
15
|
class DfnsDelegatedApiClient {
|
|
15
16
|
constructor(apiOptions) {
|
|
@@ -42,6 +43,9 @@ class DfnsDelegatedApiClient {
|
|
|
42
43
|
get wallets() {
|
|
43
44
|
return new Wallets_1.DelegatedWalletsClient(this.apiOptions);
|
|
44
45
|
}
|
|
46
|
+
get webhooks() {
|
|
47
|
+
return new webhooks_1.DelegatedWebhooksClient(this.apiOptions);
|
|
48
|
+
}
|
|
45
49
|
get signers() {
|
|
46
50
|
return new Signers_1.DelegatedSignersClient(this.apiOptions);
|
|
47
51
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DfnsApiClientOptions } from '../../dfnsApiClient';
|
|
2
|
+
import * as T from './types';
|
|
3
|
+
export declare class WebhooksClient {
|
|
4
|
+
private apiOptions;
|
|
5
|
+
constructor(apiOptions: DfnsApiClientOptions);
|
|
6
|
+
createWebhook(request: T.CreateWebhookRequest): Promise<T.CreateWebhookResponse>;
|
|
7
|
+
deleteWebhook(request: T.DeleteWebhookRequest): Promise<T.DeleteWebhookResponse>;
|
|
8
|
+
getWebhook(request: T.GetWebhookRequest): Promise<T.GetWebhookResponse>;
|
|
9
|
+
getWebhookEvent(request: T.GetWebhookEventRequest): Promise<T.GetWebhookEventResponse>;
|
|
10
|
+
listWebhookEvents(request: T.ListWebhookEventsRequest): Promise<T.ListWebhookEventsResponse>;
|
|
11
|
+
listWebhooks(request?: T.ListWebhooksRequest): Promise<T.ListWebhooksResponse>;
|
|
12
|
+
pingWebhook(request: T.PingWebhookRequest): Promise<T.PingWebhookResponse>;
|
|
13
|
+
updateWebhook(request: T.UpdateWebhookRequest): Promise<T.UpdateWebhookResponse>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhooksClient = void 0;
|
|
4
|
+
const fetch_1 = require("../../utils/fetch");
|
|
5
|
+
const url_1 = require("../../utils/url");
|
|
6
|
+
class WebhooksClient {
|
|
7
|
+
constructor(apiOptions) {
|
|
8
|
+
this.apiOptions = apiOptions;
|
|
9
|
+
}
|
|
10
|
+
async createWebhook(request) {
|
|
11
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks', {
|
|
12
|
+
path: request ?? {},
|
|
13
|
+
query: {},
|
|
14
|
+
});
|
|
15
|
+
const response = await (0, fetch_1.userActionFetch)(path, {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body: request.body,
|
|
18
|
+
apiOptions: this.apiOptions,
|
|
19
|
+
});
|
|
20
|
+
return response.json();
|
|
21
|
+
}
|
|
22
|
+
async deleteWebhook(request) {
|
|
23
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId', {
|
|
24
|
+
path: request ?? {},
|
|
25
|
+
query: {},
|
|
26
|
+
});
|
|
27
|
+
const response = await (0, fetch_1.userActionFetch)(path, {
|
|
28
|
+
method: 'DELETE',
|
|
29
|
+
apiOptions: this.apiOptions,
|
|
30
|
+
});
|
|
31
|
+
return response.json();
|
|
32
|
+
}
|
|
33
|
+
async getWebhook(request) {
|
|
34
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId', {
|
|
35
|
+
path: request ?? {},
|
|
36
|
+
query: {},
|
|
37
|
+
});
|
|
38
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
39
|
+
method: 'GET',
|
|
40
|
+
apiOptions: this.apiOptions,
|
|
41
|
+
});
|
|
42
|
+
return response.json();
|
|
43
|
+
}
|
|
44
|
+
async getWebhookEvent(request) {
|
|
45
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId/events/:webhookEventId', {
|
|
46
|
+
path: request ?? {},
|
|
47
|
+
query: {},
|
|
48
|
+
});
|
|
49
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
50
|
+
method: 'GET',
|
|
51
|
+
apiOptions: this.apiOptions,
|
|
52
|
+
});
|
|
53
|
+
return response.json();
|
|
54
|
+
}
|
|
55
|
+
async listWebhookEvents(request) {
|
|
56
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId/events', {
|
|
57
|
+
path: request ?? {},
|
|
58
|
+
query: request.query ?? {},
|
|
59
|
+
});
|
|
60
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
61
|
+
method: 'GET',
|
|
62
|
+
apiOptions: this.apiOptions,
|
|
63
|
+
});
|
|
64
|
+
return response.json();
|
|
65
|
+
}
|
|
66
|
+
async listWebhooks(request) {
|
|
67
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks', {
|
|
68
|
+
path: request ?? {},
|
|
69
|
+
query: request?.query ?? {},
|
|
70
|
+
});
|
|
71
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
72
|
+
method: 'GET',
|
|
73
|
+
apiOptions: this.apiOptions,
|
|
74
|
+
});
|
|
75
|
+
return response.json();
|
|
76
|
+
}
|
|
77
|
+
async pingWebhook(request) {
|
|
78
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId/ping', {
|
|
79
|
+
path: request ?? {},
|
|
80
|
+
query: {},
|
|
81
|
+
});
|
|
82
|
+
const response = await (0, fetch_1.userActionFetch)(path, {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
apiOptions: this.apiOptions,
|
|
85
|
+
});
|
|
86
|
+
return response.json();
|
|
87
|
+
}
|
|
88
|
+
async updateWebhook(request) {
|
|
89
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId', {
|
|
90
|
+
path: request ?? {},
|
|
91
|
+
query: {},
|
|
92
|
+
});
|
|
93
|
+
const response = await (0, fetch_1.userActionFetch)(path, {
|
|
94
|
+
method: 'PUT',
|
|
95
|
+
body: request.body,
|
|
96
|
+
apiOptions: this.apiOptions,
|
|
97
|
+
});
|
|
98
|
+
return response.json();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.WebhooksClient = WebhooksClient;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SignUserActionChallengeRequest, UserActionChallengeResponse } from '../../baseAuthApi';
|
|
2
|
+
import { DfnsDelegatedApiClientOptions } from '../../dfnsDelegatedApiClient';
|
|
3
|
+
import * as T from './types';
|
|
4
|
+
export declare class DelegatedWebhooksClient {
|
|
5
|
+
private apiOptions;
|
|
6
|
+
constructor(apiOptions: DfnsDelegatedApiClientOptions);
|
|
7
|
+
createWebhookInit(request: T.CreateWebhookRequest): Promise<UserActionChallengeResponse>;
|
|
8
|
+
createWebhookComplete(request: T.CreateWebhookRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateWebhookResponse>;
|
|
9
|
+
deleteWebhookInit(request: T.DeleteWebhookRequest): Promise<UserActionChallengeResponse>;
|
|
10
|
+
deleteWebhookComplete(request: T.DeleteWebhookRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.DeleteWebhookResponse>;
|
|
11
|
+
getWebhook(request: T.GetWebhookRequest): Promise<T.GetWebhookResponse>;
|
|
12
|
+
getWebhookEvent(request: T.GetWebhookEventRequest): Promise<T.GetWebhookEventResponse>;
|
|
13
|
+
listWebhookEvents(request: T.ListWebhookEventsRequest): Promise<T.ListWebhookEventsResponse>;
|
|
14
|
+
listWebhooks(request?: T.ListWebhooksRequest): Promise<T.ListWebhooksResponse>;
|
|
15
|
+
pingWebhookInit(request: T.PingWebhookRequest): Promise<UserActionChallengeResponse>;
|
|
16
|
+
pingWebhookComplete(request: T.PingWebhookRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.PingWebhookResponse>;
|
|
17
|
+
updateWebhookInit(request: T.UpdateWebhookRequest): Promise<UserActionChallengeResponse>;
|
|
18
|
+
updateWebhookComplete(request: T.UpdateWebhookRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.UpdateWebhookResponse>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DelegatedWebhooksClient = void 0;
|
|
4
|
+
const baseAuthApi_1 = require("../../baseAuthApi");
|
|
5
|
+
const fetch_1 = require("../../utils/fetch");
|
|
6
|
+
const url_1 = require("../../utils/url");
|
|
7
|
+
class DelegatedWebhooksClient {
|
|
8
|
+
constructor(apiOptions) {
|
|
9
|
+
this.apiOptions = apiOptions;
|
|
10
|
+
}
|
|
11
|
+
async createWebhookInit(request) {
|
|
12
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks', {
|
|
13
|
+
path: request ?? {},
|
|
14
|
+
query: {},
|
|
15
|
+
});
|
|
16
|
+
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
|
|
17
|
+
userActionHttpMethod: 'POST',
|
|
18
|
+
userActionHttpPath: path,
|
|
19
|
+
userActionPayload: JSON.stringify(request.body),
|
|
20
|
+
userActionServerKind: 'Api',
|
|
21
|
+
}, this.apiOptions);
|
|
22
|
+
return challenge;
|
|
23
|
+
}
|
|
24
|
+
async createWebhookComplete(request, signedChallenge) {
|
|
25
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks', {
|
|
26
|
+
path: request ?? {},
|
|
27
|
+
query: {},
|
|
28
|
+
});
|
|
29
|
+
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
|
|
30
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
body: request.body,
|
|
33
|
+
headers: { 'x-dfns-useraction': userAction },
|
|
34
|
+
apiOptions: this.apiOptions,
|
|
35
|
+
});
|
|
36
|
+
return response.json();
|
|
37
|
+
}
|
|
38
|
+
async deleteWebhookInit(request) {
|
|
39
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId', {
|
|
40
|
+
path: request ?? {},
|
|
41
|
+
query: {},
|
|
42
|
+
});
|
|
43
|
+
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
|
|
44
|
+
userActionHttpMethod: 'DELETE',
|
|
45
|
+
userActionHttpPath: path,
|
|
46
|
+
userActionPayload: JSON.stringify({}),
|
|
47
|
+
userActionServerKind: 'Api',
|
|
48
|
+
}, this.apiOptions);
|
|
49
|
+
return challenge;
|
|
50
|
+
}
|
|
51
|
+
async deleteWebhookComplete(request, signedChallenge) {
|
|
52
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId', {
|
|
53
|
+
path: request ?? {},
|
|
54
|
+
query: {},
|
|
55
|
+
});
|
|
56
|
+
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
|
|
57
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
58
|
+
method: 'DELETE',
|
|
59
|
+
body: {},
|
|
60
|
+
headers: { 'x-dfns-useraction': userAction },
|
|
61
|
+
apiOptions: this.apiOptions,
|
|
62
|
+
});
|
|
63
|
+
return response.json();
|
|
64
|
+
}
|
|
65
|
+
async getWebhook(request) {
|
|
66
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId', {
|
|
67
|
+
path: request ?? {},
|
|
68
|
+
query: {},
|
|
69
|
+
});
|
|
70
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
71
|
+
method: 'GET',
|
|
72
|
+
apiOptions: this.apiOptions,
|
|
73
|
+
});
|
|
74
|
+
return response.json();
|
|
75
|
+
}
|
|
76
|
+
async getWebhookEvent(request) {
|
|
77
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId/events/:webhookEventId', {
|
|
78
|
+
path: request ?? {},
|
|
79
|
+
query: {},
|
|
80
|
+
});
|
|
81
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
82
|
+
method: 'GET',
|
|
83
|
+
apiOptions: this.apiOptions,
|
|
84
|
+
});
|
|
85
|
+
return response.json();
|
|
86
|
+
}
|
|
87
|
+
async listWebhookEvents(request) {
|
|
88
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId/events', {
|
|
89
|
+
path: request ?? {},
|
|
90
|
+
query: request.query ?? {},
|
|
91
|
+
});
|
|
92
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
93
|
+
method: 'GET',
|
|
94
|
+
apiOptions: this.apiOptions,
|
|
95
|
+
});
|
|
96
|
+
return response.json();
|
|
97
|
+
}
|
|
98
|
+
async listWebhooks(request) {
|
|
99
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks', {
|
|
100
|
+
path: request ?? {},
|
|
101
|
+
query: request?.query ?? {},
|
|
102
|
+
});
|
|
103
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
104
|
+
method: 'GET',
|
|
105
|
+
apiOptions: this.apiOptions,
|
|
106
|
+
});
|
|
107
|
+
return response.json();
|
|
108
|
+
}
|
|
109
|
+
async pingWebhookInit(request) {
|
|
110
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId/ping', {
|
|
111
|
+
path: request ?? {},
|
|
112
|
+
query: {},
|
|
113
|
+
});
|
|
114
|
+
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
|
|
115
|
+
userActionHttpMethod: 'POST',
|
|
116
|
+
userActionHttpPath: path,
|
|
117
|
+
userActionPayload: JSON.stringify({}),
|
|
118
|
+
userActionServerKind: 'Api',
|
|
119
|
+
}, this.apiOptions);
|
|
120
|
+
return challenge;
|
|
121
|
+
}
|
|
122
|
+
async pingWebhookComplete(request, signedChallenge) {
|
|
123
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId/ping', {
|
|
124
|
+
path: request ?? {},
|
|
125
|
+
query: {},
|
|
126
|
+
});
|
|
127
|
+
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
|
|
128
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
129
|
+
method: 'POST',
|
|
130
|
+
body: {},
|
|
131
|
+
headers: { 'x-dfns-useraction': userAction },
|
|
132
|
+
apiOptions: this.apiOptions,
|
|
133
|
+
});
|
|
134
|
+
return response.json();
|
|
135
|
+
}
|
|
136
|
+
async updateWebhookInit(request) {
|
|
137
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId', {
|
|
138
|
+
path: request ?? {},
|
|
139
|
+
query: {},
|
|
140
|
+
});
|
|
141
|
+
const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
|
|
142
|
+
userActionHttpMethod: 'PUT',
|
|
143
|
+
userActionHttpPath: path,
|
|
144
|
+
userActionPayload: JSON.stringify(request.body),
|
|
145
|
+
userActionServerKind: 'Api',
|
|
146
|
+
}, this.apiOptions);
|
|
147
|
+
return challenge;
|
|
148
|
+
}
|
|
149
|
+
async updateWebhookComplete(request, signedChallenge) {
|
|
150
|
+
const path = (0, url_1.buildPathAndQuery)('/webhooks/:webhookId', {
|
|
151
|
+
path: request ?? {},
|
|
152
|
+
query: {},
|
|
153
|
+
});
|
|
154
|
+
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
|
|
155
|
+
const response = await (0, fetch_1.simpleFetch)(path, {
|
|
156
|
+
method: 'PUT',
|
|
157
|
+
body: request.body,
|
|
158
|
+
headers: { 'x-dfns-useraction': userAction },
|
|
159
|
+
apiOptions: this.apiOptions,
|
|
160
|
+
});
|
|
161
|
+
return response.json();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.DelegatedWebhooksClient = DelegatedWebhooksClient;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./client"), exports);
|
|
19
|
+
__exportStar(require("./delegatedClient"), exports);
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
export type CreateWebhookBody = {
|
|
2
|
+
url: string;
|
|
3
|
+
/** Webhook status */
|
|
4
|
+
status?: ("Enabled" | "Disabled") | undefined;
|
|
5
|
+
description?: string | undefined;
|
|
6
|
+
events: ("*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected")[];
|
|
7
|
+
};
|
|
8
|
+
export type CreateWebhookResponse = {
|
|
9
|
+
/** Webhook ID */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Webhook url */
|
|
12
|
+
url: string;
|
|
13
|
+
/** All events this webhook is subscribed to. */
|
|
14
|
+
events: ("*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected")[];
|
|
15
|
+
/** Webhook status */
|
|
16
|
+
status: "Enabled" | "Disabled";
|
|
17
|
+
/** Short description this webhook's purpose */
|
|
18
|
+
description?: string | undefined;
|
|
19
|
+
/** Date when webhook was created */
|
|
20
|
+
dateCreated: string;
|
|
21
|
+
/** Date when webhook was last updated */
|
|
22
|
+
dateUpdated: string;
|
|
23
|
+
/** The secret associated with this webhook, with which webhook requests will be signed. */
|
|
24
|
+
secret: string;
|
|
25
|
+
};
|
|
26
|
+
export type CreateWebhookRequest = {
|
|
27
|
+
body: CreateWebhookBody;
|
|
28
|
+
};
|
|
29
|
+
export type DeleteWebhookParams = {
|
|
30
|
+
webhookId: string;
|
|
31
|
+
};
|
|
32
|
+
export type DeleteWebhookResponse = {
|
|
33
|
+
deleted: true;
|
|
34
|
+
};
|
|
35
|
+
export type DeleteWebhookRequest = DeleteWebhookParams;
|
|
36
|
+
export type GetWebhookParams = {
|
|
37
|
+
webhookId: string;
|
|
38
|
+
};
|
|
39
|
+
export type GetWebhookResponse = {
|
|
40
|
+
/** Webhook ID */
|
|
41
|
+
id: string;
|
|
42
|
+
/** Webhook url */
|
|
43
|
+
url: string;
|
|
44
|
+
/** All events this webhook is subscribed to. */
|
|
45
|
+
events: ("*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected")[];
|
|
46
|
+
/** Webhook status */
|
|
47
|
+
status: "Enabled" | "Disabled";
|
|
48
|
+
/** Short description this webhook's purpose */
|
|
49
|
+
description?: string | undefined;
|
|
50
|
+
/** Date when webhook was created */
|
|
51
|
+
dateCreated: string;
|
|
52
|
+
/** Date when webhook was last updated */
|
|
53
|
+
dateUpdated: string;
|
|
54
|
+
};
|
|
55
|
+
export type GetWebhookRequest = GetWebhookParams;
|
|
56
|
+
export type GetWebhookEventParams = {
|
|
57
|
+
webhookId: string;
|
|
58
|
+
webhookEventId: string;
|
|
59
|
+
};
|
|
60
|
+
export type GetWebhookEventResponse = {
|
|
61
|
+
/** WebhookEvent ID */
|
|
62
|
+
id: string;
|
|
63
|
+
/** ISO date string when event was raised */
|
|
64
|
+
date: string;
|
|
65
|
+
/** Webhook event */
|
|
66
|
+
kind: "*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected";
|
|
67
|
+
data: {
|
|
68
|
+
[x: string]: any;
|
|
69
|
+
};
|
|
70
|
+
/** Status code of the webhook request */
|
|
71
|
+
status: string;
|
|
72
|
+
/** Error message if any error happened during the webhook request. */
|
|
73
|
+
error?: string | undefined;
|
|
74
|
+
/** Unix timestamp when the event was forwarded to the webhook url by our servers. */
|
|
75
|
+
timestampSent: number;
|
|
76
|
+
};
|
|
77
|
+
export type GetWebhookEventRequest = GetWebhookEventParams;
|
|
78
|
+
export type ListWebhookEventsParams = {
|
|
79
|
+
webhookId: string;
|
|
80
|
+
};
|
|
81
|
+
export type ListWebhookEventsQuery = {
|
|
82
|
+
kind?: ("*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected") | undefined;
|
|
83
|
+
limit?: number | undefined;
|
|
84
|
+
paginationToken?: string | undefined;
|
|
85
|
+
};
|
|
86
|
+
export type ListWebhookEventsResponse = {
|
|
87
|
+
items: {
|
|
88
|
+
/** WebhookEvent ID */
|
|
89
|
+
id: string;
|
|
90
|
+
/** ISO date string when event was raised */
|
|
91
|
+
date: string;
|
|
92
|
+
/** Webhook event */
|
|
93
|
+
kind: "*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected";
|
|
94
|
+
data: {
|
|
95
|
+
[x: string]: any;
|
|
96
|
+
};
|
|
97
|
+
/** Status code of the webhook request */
|
|
98
|
+
status: string;
|
|
99
|
+
/** Error message if any error happened during the webhook request. */
|
|
100
|
+
error?: string | undefined;
|
|
101
|
+
/** Unix timestamp when the event was forwarded to the webhook url by our servers. */
|
|
102
|
+
timestampSent: number;
|
|
103
|
+
}[];
|
|
104
|
+
nextPageToken?: string | undefined;
|
|
105
|
+
};
|
|
106
|
+
export type ListWebhookEventsRequest = ListWebhookEventsParams & {
|
|
107
|
+
query?: ListWebhookEventsQuery;
|
|
108
|
+
};
|
|
109
|
+
export type ListWebhooksQuery = {
|
|
110
|
+
limit?: number | undefined;
|
|
111
|
+
paginationToken?: string | undefined;
|
|
112
|
+
};
|
|
113
|
+
export type ListWebhooksResponse = {
|
|
114
|
+
items: {
|
|
115
|
+
/** Webhook ID */
|
|
116
|
+
id: string;
|
|
117
|
+
/** Webhook url */
|
|
118
|
+
url: string;
|
|
119
|
+
/** All events this webhook is subscribed to. */
|
|
120
|
+
events: ("*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected")[];
|
|
121
|
+
/** Webhook status */
|
|
122
|
+
status: "Enabled" | "Disabled";
|
|
123
|
+
/** Short description this webhook's purpose */
|
|
124
|
+
description?: string | undefined;
|
|
125
|
+
/** Date when webhook was created */
|
|
126
|
+
dateCreated: string;
|
|
127
|
+
/** Date when webhook was last updated */
|
|
128
|
+
dateUpdated: string;
|
|
129
|
+
}[];
|
|
130
|
+
nextPageToken?: string | undefined;
|
|
131
|
+
};
|
|
132
|
+
export type ListWebhooksRequest = {
|
|
133
|
+
query?: ListWebhooksQuery;
|
|
134
|
+
};
|
|
135
|
+
export type PingWebhookParams = {
|
|
136
|
+
webhookId: string;
|
|
137
|
+
};
|
|
138
|
+
export type PingWebhookResponse = {
|
|
139
|
+
status: string;
|
|
140
|
+
error?: string | undefined;
|
|
141
|
+
};
|
|
142
|
+
export type PingWebhookRequest = PingWebhookParams;
|
|
143
|
+
export type UpdateWebhookBody = {
|
|
144
|
+
url?: string | undefined;
|
|
145
|
+
description?: (string | undefined) | undefined;
|
|
146
|
+
events?: ("*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected")[] | undefined;
|
|
147
|
+
/** Webhook status */
|
|
148
|
+
status?: (("Enabled" | "Disabled") | undefined) | undefined;
|
|
149
|
+
};
|
|
150
|
+
export type UpdateWebhookParams = {
|
|
151
|
+
webhookId: string;
|
|
152
|
+
};
|
|
153
|
+
export type UpdateWebhookResponse = {
|
|
154
|
+
/** Webhook ID */
|
|
155
|
+
id: string;
|
|
156
|
+
/** Webhook url */
|
|
157
|
+
url: string;
|
|
158
|
+
/** All events this webhook is subscribed to. */
|
|
159
|
+
events: ("*" | "wallet.created" | "wallet.exported" | "wallet.delegated" | "wallet.signature.requested" | "wallet.signature.failed" | "wallet.signature.rejected" | "wallet.signature.signed" | "wallet.transaction.requested" | "wallet.transaction.failed" | "wallet.transaction.rejected" | "wallet.transaction.broadcasted" | "wallet.transaction.confirmed" | "wallet.transfer.requested" | "wallet.transfer.failed" | "wallet.transfer.rejected" | "wallet.transfer.broadcasted" | "wallet.transfer.confirmed" | "wallet.blockchainevent.detected")[];
|
|
160
|
+
/** Webhook status */
|
|
161
|
+
status: "Enabled" | "Disabled";
|
|
162
|
+
/** Short description this webhook's purpose */
|
|
163
|
+
description?: string | undefined;
|
|
164
|
+
/** Date when webhook was created */
|
|
165
|
+
dateCreated: string;
|
|
166
|
+
/** Date when webhook was last updated */
|
|
167
|
+
dateUpdated: string;
|
|
168
|
+
};
|
|
169
|
+
export type UpdateWebhookRequest = UpdateWebhookParams & {
|
|
170
|
+
body: UpdateWebhookBody;
|
|
171
|
+
};
|
package/package.json
CHANGED
package/utils/fetch.js
CHANGED
|
@@ -14,12 +14,11 @@ const fullUrl = (fetch) => {
|
|
|
14
14
|
};
|
|
15
15
|
const jsonSerializer = (fetch) => {
|
|
16
16
|
return async (resource, options) => {
|
|
17
|
-
var _a;
|
|
18
17
|
if (options.body) {
|
|
19
18
|
options.body = JSON.stringify(options.body);
|
|
20
19
|
options.headers = {
|
|
21
20
|
'content-type': 'application/json',
|
|
22
|
-
...(
|
|
21
|
+
...(options.headers ?? {}),
|
|
23
22
|
};
|
|
24
23
|
}
|
|
25
24
|
return fetch(resource, options);
|
|
@@ -27,21 +26,19 @@ const jsonSerializer = (fetch) => {
|
|
|
27
26
|
};
|
|
28
27
|
const errorHandler = (fetch) => {
|
|
29
28
|
return async (resource, options) => {
|
|
30
|
-
var _a;
|
|
31
29
|
const response = await fetch(resource, options);
|
|
32
30
|
if (response.ok) {
|
|
33
31
|
return response;
|
|
34
32
|
}
|
|
35
33
|
else {
|
|
36
34
|
const body = await response.json();
|
|
37
|
-
const errorMessage =
|
|
35
|
+
const errorMessage = body?.error?.message || body?.message || JSON.stringify(body);
|
|
38
36
|
throw new dfnsError_1.DfnsError(response.status, errorMessage, body.error);
|
|
39
37
|
}
|
|
40
38
|
};
|
|
41
39
|
};
|
|
42
40
|
const dfnsAuth = (fetch) => {
|
|
43
41
|
return async (resource, options) => {
|
|
44
|
-
var _a;
|
|
45
42
|
const { appId, appSecret, authToken } = options.apiOptions;
|
|
46
43
|
const authorization = authToken
|
|
47
44
|
? {
|
|
@@ -58,24 +55,23 @@ const dfnsAuth = (fetch) => {
|
|
|
58
55
|
'x-dfns-nonce': (0, nonce_1.generateNonce)(),
|
|
59
56
|
...dfnsAppSecret,
|
|
60
57
|
...authorization,
|
|
61
|
-
...(
|
|
58
|
+
...(options.headers ?? {}),
|
|
62
59
|
};
|
|
63
60
|
return fetch(resource, options);
|
|
64
61
|
};
|
|
65
62
|
};
|
|
66
63
|
const userAction = (fetch) => {
|
|
67
64
|
return async (resource, options) => {
|
|
68
|
-
var _a, _b;
|
|
69
65
|
if (options.method !== 'GET') {
|
|
70
66
|
const apiOptions = {
|
|
71
67
|
...options.apiOptions,
|
|
72
68
|
baseUrl: options.apiOptions.baseAuthUrl || options.apiOptions.baseUrl,
|
|
73
69
|
};
|
|
74
70
|
const { challenge, challengeIdentifier, allowCredentials } = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
|
|
75
|
-
userActionPayload:
|
|
71
|
+
userActionPayload: options.body ?? '',
|
|
76
72
|
userActionHttpMethod: options.method,
|
|
77
73
|
userActionHttpPath: resource.pathname,
|
|
78
|
-
userActionServerKind:
|
|
74
|
+
userActionServerKind: apiOptions?.userActionServerKind || 'Api',
|
|
79
75
|
}, apiOptions);
|
|
80
76
|
const assertion = await apiOptions.signer.sign(challenge, allowCredentials);
|
|
81
77
|
const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge({
|
|
@@ -84,7 +80,7 @@ const userAction = (fetch) => {
|
|
|
84
80
|
}, apiOptions);
|
|
85
81
|
options.headers = {
|
|
86
82
|
'x-dfns-useraction': userAction,
|
|
87
|
-
...(
|
|
83
|
+
...(options.headers ?? {}),
|
|
88
84
|
};
|
|
89
85
|
}
|
|
90
86
|
return fetch(resource, options);
|
package/utils/url.d.ts
CHANGED
package/utils/url.js
CHANGED
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildPathAndQuery = void 0;
|
|
4
4
|
const buildPathAndQuery = (pattern, params) => {
|
|
5
5
|
let path = pattern;
|
|
6
|
-
|
|
6
|
+
const paramsToReplace = path.match(new RegExp(`:[a-zA-Z]+`, 'g')) || [];
|
|
7
|
+
for (const key of paramsToReplace) {
|
|
7
8
|
path = path.replace(new RegExp(`:${key}`, 'g'), encodeURIComponent(params.path[key]));
|
|
8
9
|
}
|
|
9
10
|
const query = Object.entries(params.query)
|