@dfns/sdk 0.8.24 → 0.8.25

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.
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelegatedVaultsClient = void 0;
4
+ const baseAuthApi_1 = require("../../baseAuthApi");
5
+ const fetch_1 = require("../../utils/fetch");
6
+ const url_1 = require("../../utils/url");
7
+ class DelegatedVaultsClient {
8
+ constructor(apiOptions) {
9
+ this.apiOptions = apiOptions;
10
+ }
11
+ async createVaultInit(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/vaults', {
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 createVaultComplete(request, signedChallenge) {
25
+ const path = (0, url_1.buildPathAndQuery)('/vaults', {
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 createVaultAddressInit(request) {
39
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/addresses', {
40
+ path: request ?? {},
41
+ query: {},
42
+ });
43
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
44
+ userActionHttpMethod: 'POST',
45
+ userActionHttpPath: path,
46
+ userActionPayload: JSON.stringify(request.body),
47
+ userActionServerKind: 'Api',
48
+ }, this.apiOptions);
49
+ return challenge;
50
+ }
51
+ async createVaultAddressComplete(request, signedChallenge) {
52
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/addresses', {
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: 'POST',
59
+ body: request.body,
60
+ headers: { 'x-dfns-useraction': userAction },
61
+ apiOptions: this.apiOptions,
62
+ });
63
+ return response.json();
64
+ }
65
+ async createVaultTransferInit(request) {
66
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/transfers', {
67
+ path: request ?? {},
68
+ query: {},
69
+ });
70
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
71
+ userActionHttpMethod: 'POST',
72
+ userActionHttpPath: path,
73
+ userActionPayload: JSON.stringify(request.body),
74
+ userActionServerKind: 'Api',
75
+ }, this.apiOptions);
76
+ return challenge;
77
+ }
78
+ async createVaultTransferComplete(request, signedChallenge) {
79
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/transfers', {
80
+ path: request ?? {},
81
+ query: {},
82
+ });
83
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
84
+ const response = await (0, fetch_1.simpleFetch)(path, {
85
+ method: 'POST',
86
+ body: request.body,
87
+ headers: { 'x-dfns-useraction': userAction },
88
+ apiOptions: this.apiOptions,
89
+ });
90
+ return response.json();
91
+ }
92
+ async getVault(request) {
93
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId', {
94
+ path: request ?? {},
95
+ query: {},
96
+ });
97
+ const response = await (0, fetch_1.simpleFetch)(path, {
98
+ method: 'GET',
99
+ apiOptions: this.apiOptions,
100
+ });
101
+ return response.json();
102
+ }
103
+ async listVaultAssets(request) {
104
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/assets', {
105
+ path: request ?? {},
106
+ query: request.query ?? {},
107
+ });
108
+ const response = await (0, fetch_1.simpleFetch)(path, {
109
+ method: 'GET',
110
+ apiOptions: this.apiOptions,
111
+ });
112
+ return response.json();
113
+ }
114
+ async listVaultBalances(request) {
115
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/balances', {
116
+ path: request ?? {},
117
+ query: request.query ?? {},
118
+ });
119
+ const response = await (0, fetch_1.simpleFetch)(path, {
120
+ method: 'GET',
121
+ apiOptions: this.apiOptions,
122
+ });
123
+ return response.json();
124
+ }
125
+ async listVaults(request) {
126
+ const path = (0, url_1.buildPathAndQuery)('/vaults', {
127
+ path: request ?? {},
128
+ query: request?.query ?? {},
129
+ });
130
+ const response = await (0, fetch_1.simpleFetch)(path, {
131
+ method: 'GET',
132
+ apiOptions: this.apiOptions,
133
+ });
134
+ return response.json();
135
+ }
136
+ async tagVaultInit(request) {
137
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/tags', {
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 tagVaultComplete(request, signedChallenge) {
150
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/tags', {
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
+ async unquarantineInit(request) {
164
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/quarantines/:quarantineId', {
165
+ path: request ?? {},
166
+ query: {},
167
+ });
168
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
169
+ userActionHttpMethod: 'DELETE',
170
+ userActionHttpPath: path,
171
+ userActionPayload: JSON.stringify(request.body),
172
+ userActionServerKind: 'Api',
173
+ }, this.apiOptions);
174
+ return challenge;
175
+ }
176
+ async unquarantineComplete(request, signedChallenge) {
177
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/quarantines/:quarantineId', {
178
+ path: request ?? {},
179
+ query: {},
180
+ });
181
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
182
+ const response = await (0, fetch_1.simpleFetch)(path, {
183
+ method: 'DELETE',
184
+ body: request.body,
185
+ headers: { 'x-dfns-useraction': userAction },
186
+ apiOptions: this.apiOptions,
187
+ });
188
+ return response.json();
189
+ }
190
+ async untagVaultInit(request) {
191
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/tags', {
192
+ path: request ?? {},
193
+ query: {},
194
+ });
195
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
196
+ userActionHttpMethod: 'DELETE',
197
+ userActionHttpPath: path,
198
+ userActionPayload: JSON.stringify(request.body),
199
+ userActionServerKind: 'Api',
200
+ }, this.apiOptions);
201
+ return challenge;
202
+ }
203
+ async untagVaultComplete(request, signedChallenge) {
204
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId/tags', {
205
+ path: request ?? {},
206
+ query: {},
207
+ });
208
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
209
+ const response = await (0, fetch_1.simpleFetch)(path, {
210
+ method: 'DELETE',
211
+ body: request.body,
212
+ headers: { 'x-dfns-useraction': userAction },
213
+ apiOptions: this.apiOptions,
214
+ });
215
+ return response.json();
216
+ }
217
+ async updateVaultInit(request) {
218
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId', {
219
+ path: request ?? {},
220
+ query: {},
221
+ });
222
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
223
+ userActionHttpMethod: 'PUT',
224
+ userActionHttpPath: path,
225
+ userActionPayload: JSON.stringify(request.body),
226
+ userActionServerKind: 'Api',
227
+ }, this.apiOptions);
228
+ return challenge;
229
+ }
230
+ async updateVaultComplete(request, signedChallenge) {
231
+ const path = (0, url_1.buildPathAndQuery)('/vaults/:vaultId', {
232
+ path: request ?? {},
233
+ query: {},
234
+ });
235
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
236
+ const response = await (0, fetch_1.simpleFetch)(path, {
237
+ method: 'PUT',
238
+ body: request.body,
239
+ headers: { 'x-dfns-useraction': userAction },
240
+ apiOptions: this.apiOptions,
241
+ });
242
+ return response.json();
243
+ }
244
+ }
245
+ exports.DelegatedVaultsClient = DelegatedVaultsClient;
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './client';
3
+ export * from './delegatedClient';
@@ -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);