@coinbase/cdp-sdk 1.47.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +282 -0
- package/_cjs/client/cdp.js +1 -4
- package/_cjs/client/cdp.js.map +1 -1
- package/_cjs/client/end-user/endUser.js +19 -89
- package/_cjs/client/end-user/endUser.js.map +1 -1
- package/_cjs/client/end-user/toEndUserAccount.js +13 -43
- package/_cjs/client/end-user/toEndUserAccount.js.map +1 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/cdpApiClient.js +0 -32
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +54 -10
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.js → embedded-wallets/embedded-wallets.js} +37 -97
- package/_cjs/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -0
- package/_cjs/openapi-client/generated/webhooks/webhooks.js +6 -6
- package/_cjs/openapi-client/index.js +2 -2
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/client/cdp.js +2 -5
- package/_esm/client/cdp.js.map +1 -1
- package/_esm/client/end-user/endUser.js +17 -87
- package/_esm/client/end-user/endUser.js.map +1 -1
- package/_esm/client/end-user/toEndUserAccount.js +13 -43
- package/_esm/client/end-user/toEndUserAccount.js.map +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/cdpApiClient.js +0 -32
- package/_esm/openapi-client/cdpApiClient.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +52 -8
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.js → embedded-wallets/embedded-wallets.js} +36 -93
- package/_esm/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -0
- package/_esm/openapi-client/generated/webhooks/webhooks.js +6 -6
- package/_esm/openapi-client/index.js +2 -2
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/client/cdp.d.ts +2 -6
- package/_types/client/cdp.d.ts.map +1 -1
- package/_types/client/end-user/endUser.d.ts +2 -52
- package/_types/client/end-user/endUser.d.ts.map +1 -1
- package/_types/client/end-user/endUser.types.d.ts +1 -63
- package/_types/client/end-user/endUser.types.d.ts.map +1 -1
- package/_types/client/end-user/toEndUserAccount.d.ts +0 -2
- package/_types/client/end-user/toEndUserAccount.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +476 -79
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts +145 -0
- package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts.map +1 -0
- package/_types/openapi-client/generated/webhooks/webhooks.d.ts +6 -6
- package/_types/openapi-client/index.d.ts +13 -45
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/client/cdp.ts +3 -8
- package/client/end-user/endUser.ts +55 -187
- package/client/end-user/endUser.types.ts +0 -72
- package/client/end-user/toEndUserAccount.ts +57 -152
- package/index.ts +0 -4
- package/openapi-client/cdpApiClient.ts +0 -34
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +535 -85
- package/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.ts → embedded-wallets/embedded-wallets.ts} +67 -249
- package/openapi-client/generated/webhooks/webhooks.ts +6 -6
- package/openapi-client/index.ts +2 -2
- package/package.json +1 -1
- package/version.ts +1 -1
- package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +0 -1
- package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +0 -1
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts +0 -312
- package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts.map +0 -1
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
AddEndUserEvmSmartAccountResult,
|
|
7
7
|
AddEndUserSolanaAccountResult,
|
|
8
8
|
AddEvmSmartAccountOptions,
|
|
9
|
-
SignEvmHashResult,
|
|
10
9
|
SignEvmTransactionResult,
|
|
11
10
|
SignEvmMessageResult,
|
|
12
11
|
SignEvmTypedDataResult,
|
|
@@ -14,12 +13,10 @@ import type {
|
|
|
14
13
|
SendEvmAssetResult,
|
|
15
14
|
SendUserOperationResult,
|
|
16
15
|
CreateEvmEip7702DelegationForEndUserResult,
|
|
17
|
-
SignSolanaHashResult,
|
|
18
16
|
SignSolanaMessageResult,
|
|
19
17
|
SignSolanaTransactionResult,
|
|
20
18
|
SendSolanaTransactionResult,
|
|
21
19
|
SendSolanaAssetResult,
|
|
22
|
-
AccountSignEvmHashOptions,
|
|
23
20
|
AccountSignEvmTransactionOptions,
|
|
24
21
|
AccountSignEvmMessageOptions,
|
|
25
22
|
AccountSignEvmTypedDataOptions,
|
|
@@ -27,7 +24,6 @@ import type {
|
|
|
27
24
|
AccountSendEvmAssetOptions,
|
|
28
25
|
AccountSendUserOperationOptions,
|
|
29
26
|
AccountCreateEvmEip7702DelegationOptions,
|
|
30
|
-
AccountSignSolanaHashOptions,
|
|
31
27
|
AccountSignSolanaMessageOptions,
|
|
32
28
|
AccountSignSolanaTransactionOptions,
|
|
33
29
|
AccountSendSolanaTransactionOptions,
|
|
@@ -44,28 +40,8 @@ import type {
|
|
|
44
40
|
export type ToEndUserAccountOptions = {
|
|
45
41
|
/** The end user from the API response. */
|
|
46
42
|
endUser: OpenAPIEndUser;
|
|
47
|
-
/** The CDP project ID. Required for delegation operations (signing, sending). */
|
|
48
|
-
projectId?: string;
|
|
49
43
|
};
|
|
50
44
|
|
|
51
|
-
/**
|
|
52
|
-
* Returns the project ID or throws if not configured.
|
|
53
|
-
* Used by delegation operations that require a project ID.
|
|
54
|
-
*
|
|
55
|
-
* @param projectId - The project ID to validate.
|
|
56
|
-
* @returns The validated project ID.
|
|
57
|
-
*/
|
|
58
|
-
function requireProjectId(projectId: string | undefined): string {
|
|
59
|
-
if (!projectId) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
"Missing required project ID for delegation operation. " +
|
|
62
|
-
"Set the CDP_PROJECT_ID environment variable or pass projectId to the CdpClient constructor.",
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return projectId;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
45
|
/**
|
|
70
46
|
* Resolves the first EVM EOA address for this end user, or throws if none exist and no override was provided.
|
|
71
47
|
*
|
|
@@ -131,7 +107,7 @@ export function toEndUserAccount(
|
|
|
131
107
|
apiClient: CdpOpenApiClientType,
|
|
132
108
|
options: ToEndUserAccountOptions,
|
|
133
109
|
): EndUserAccount {
|
|
134
|
-
const { endUser
|
|
110
|
+
const { endUser } = options;
|
|
135
111
|
|
|
136
112
|
const endUserAccount: EndUserAccount = {
|
|
137
113
|
// Pass through all properties from the OpenAPI EndUser
|
|
@@ -169,59 +145,38 @@ export function toEndUserAccount(
|
|
|
169
145
|
|
|
170
146
|
async revokeDelegation(): Promise<void> {
|
|
171
147
|
Analytics.trackAction({ action: "end_user_revoke_delegation" });
|
|
172
|
-
await apiClient.revokeDelegationForEndUser(
|
|
148
|
+
await apiClient.revokeDelegationForEndUser(endUser.userId, {});
|
|
173
149
|
},
|
|
174
150
|
|
|
175
151
|
// ─── Delegated EVM Sign Methods ───
|
|
176
152
|
|
|
177
|
-
async signEvmHash(opts: AccountSignEvmHashOptions): Promise<SignEvmHashResult> {
|
|
178
|
-
Analytics.trackAction({ action: "end_user_sign_evm_hash" });
|
|
179
|
-
const address = resolveEvmAddress(endUser, opts.address);
|
|
180
|
-
return apiClient.signEvmHashWithEndUserAccount(requireProjectId(projectId), endUser.userId, {
|
|
181
|
-
hash: opts.hash,
|
|
182
|
-
address,
|
|
183
|
-
});
|
|
184
|
-
},
|
|
185
|
-
|
|
186
153
|
async signEvmTransaction(
|
|
187
154
|
opts: AccountSignEvmTransactionOptions,
|
|
188
155
|
): Promise<SignEvmTransactionResult> {
|
|
189
156
|
Analytics.trackAction({ action: "end_user_sign_evm_transaction" });
|
|
190
157
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
191
|
-
return apiClient.signEvmTransactionWithEndUserAccount(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
address,
|
|
196
|
-
transaction: opts.transaction,
|
|
197
|
-
},
|
|
198
|
-
);
|
|
158
|
+
return apiClient.signEvmTransactionWithEndUserAccount(endUser.userId, {
|
|
159
|
+
address,
|
|
160
|
+
transaction: opts.transaction,
|
|
161
|
+
});
|
|
199
162
|
},
|
|
200
163
|
|
|
201
164
|
async signEvmMessage(opts: AccountSignEvmMessageOptions): Promise<SignEvmMessageResult> {
|
|
202
165
|
Analytics.trackAction({ action: "end_user_sign_evm_message" });
|
|
203
166
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
204
|
-
return apiClient.signEvmMessageWithEndUserAccount(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
address,
|
|
209
|
-
message: opts.message,
|
|
210
|
-
},
|
|
211
|
-
);
|
|
167
|
+
return apiClient.signEvmMessageWithEndUserAccount(endUser.userId, {
|
|
168
|
+
address,
|
|
169
|
+
message: opts.message,
|
|
170
|
+
});
|
|
212
171
|
},
|
|
213
172
|
|
|
214
173
|
async signEvmTypedData(opts: AccountSignEvmTypedDataOptions): Promise<SignEvmTypedDataResult> {
|
|
215
174
|
Analytics.trackAction({ action: "end_user_sign_evm_typed_data" });
|
|
216
175
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
217
|
-
return apiClient.signEvmTypedDataWithEndUserAccount(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
address,
|
|
222
|
-
typedData: opts.typedData,
|
|
223
|
-
},
|
|
224
|
-
);
|
|
176
|
+
return apiClient.signEvmTypedDataWithEndUserAccount(endUser.userId, {
|
|
177
|
+
address,
|
|
178
|
+
typedData: opts.typedData,
|
|
179
|
+
});
|
|
225
180
|
},
|
|
226
181
|
|
|
227
182
|
// ─── Delegated EVM Send Methods ───
|
|
@@ -231,34 +186,24 @@ export function toEndUserAccount(
|
|
|
231
186
|
): Promise<SendEvmTransactionResult> {
|
|
232
187
|
Analytics.trackAction({ action: "end_user_send_evm_transaction" });
|
|
233
188
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
234
|
-
return apiClient.sendEvmTransactionWithEndUserAccount(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
transaction: opts.transaction,
|
|
240
|
-
network: opts.network,
|
|
241
|
-
},
|
|
242
|
-
);
|
|
189
|
+
return apiClient.sendEvmTransactionWithEndUserAccount(endUser.userId, {
|
|
190
|
+
address,
|
|
191
|
+
transaction: opts.transaction,
|
|
192
|
+
network: opts.network,
|
|
193
|
+
});
|
|
243
194
|
},
|
|
244
195
|
|
|
245
196
|
async sendEvmAsset(opts: AccountSendEvmAssetOptions): Promise<SendEvmAssetResult> {
|
|
246
197
|
Analytics.trackAction({ action: "end_user_send_evm_asset" });
|
|
247
198
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
248
199
|
const asset = opts.asset ?? "usdc";
|
|
249
|
-
return apiClient.sendEvmAssetWithEndUserAccount(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
amount: opts.amount,
|
|
257
|
-
network: opts.network,
|
|
258
|
-
useCdpPaymaster: opts.useCdpPaymaster,
|
|
259
|
-
paymasterUrl: opts.paymasterUrl,
|
|
260
|
-
},
|
|
261
|
-
);
|
|
200
|
+
return apiClient.sendEvmAssetWithEndUserAccount(endUser.userId, address, asset, {
|
|
201
|
+
to: opts.to,
|
|
202
|
+
amount: opts.amount,
|
|
203
|
+
network: opts.network,
|
|
204
|
+
useCdpPaymaster: opts.useCdpPaymaster,
|
|
205
|
+
paymasterUrl: opts.paymasterUrl,
|
|
206
|
+
});
|
|
262
207
|
},
|
|
263
208
|
|
|
264
209
|
async sendUserOperation(
|
|
@@ -266,18 +211,13 @@ export function toEndUserAccount(
|
|
|
266
211
|
): Promise<SendUserOperationResult> {
|
|
267
212
|
Analytics.trackAction({ action: "end_user_send_user_operation" });
|
|
268
213
|
const address = resolveEvmSmartAccountAddress(endUser, opts.address);
|
|
269
|
-
return apiClient.sendUserOperationWithEndUserAccount(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
useCdpPaymaster: opts.useCdpPaymaster,
|
|
277
|
-
paymasterUrl: opts.paymasterUrl,
|
|
278
|
-
dataSuffix: opts.dataSuffix,
|
|
279
|
-
},
|
|
280
|
-
);
|
|
214
|
+
return apiClient.sendUserOperationWithEndUserAccount(endUser.userId, address, {
|
|
215
|
+
network: opts.network,
|
|
216
|
+
calls: opts.calls,
|
|
217
|
+
useCdpPaymaster: opts.useCdpPaymaster,
|
|
218
|
+
paymasterUrl: opts.paymasterUrl,
|
|
219
|
+
dataSuffix: opts.dataSuffix,
|
|
220
|
+
});
|
|
281
221
|
},
|
|
282
222
|
|
|
283
223
|
// ─── Delegated EVM EIP-7702 Delegation Method ───
|
|
@@ -287,45 +227,24 @@ export function toEndUserAccount(
|
|
|
287
227
|
): Promise<CreateEvmEip7702DelegationForEndUserResult> {
|
|
288
228
|
Analytics.trackAction({ action: "end_user_create_evm_eip7702_delegation" });
|
|
289
229
|
const address = resolveEvmAddress(endUser, opts.address);
|
|
290
|
-
return apiClient.createEvmEip7702DelegationWithEndUserAccount(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
network: opts.network,
|
|
296
|
-
enableSpendPermissions: opts.enableSpendPermissions,
|
|
297
|
-
},
|
|
298
|
-
);
|
|
230
|
+
return apiClient.createEvmEip7702DelegationWithEndUserAccount(endUser.userId, {
|
|
231
|
+
address,
|
|
232
|
+
network: opts.network,
|
|
233
|
+
enableSpendPermissions: opts.enableSpendPermissions,
|
|
234
|
+
});
|
|
299
235
|
},
|
|
300
236
|
|
|
301
237
|
// ─── Delegated Solana Sign Methods ───
|
|
302
238
|
|
|
303
|
-
async signSolanaHash(opts: AccountSignSolanaHashOptions): Promise<SignSolanaHashResult> {
|
|
304
|
-
Analytics.trackAction({ action: "end_user_sign_solana_hash" });
|
|
305
|
-
const address = resolveSolanaAddress(endUser, opts.address);
|
|
306
|
-
return apiClient.signSolanaHashWithEndUserAccount(
|
|
307
|
-
requireProjectId(projectId),
|
|
308
|
-
endUser.userId,
|
|
309
|
-
{
|
|
310
|
-
hash: opts.hash,
|
|
311
|
-
address,
|
|
312
|
-
},
|
|
313
|
-
);
|
|
314
|
-
},
|
|
315
|
-
|
|
316
239
|
async signSolanaMessage(
|
|
317
240
|
opts: AccountSignSolanaMessageOptions,
|
|
318
241
|
): Promise<SignSolanaMessageResult> {
|
|
319
242
|
Analytics.trackAction({ action: "end_user_sign_solana_message" });
|
|
320
243
|
const address = resolveSolanaAddress(endUser, opts.address);
|
|
321
|
-
return apiClient.signSolanaMessageWithEndUserAccount(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
address,
|
|
326
|
-
message: opts.message,
|
|
327
|
-
},
|
|
328
|
-
);
|
|
244
|
+
return apiClient.signSolanaMessageWithEndUserAccount(endUser.userId, {
|
|
245
|
+
address,
|
|
246
|
+
message: opts.message,
|
|
247
|
+
});
|
|
329
248
|
},
|
|
330
249
|
|
|
331
250
|
async signSolanaTransaction(
|
|
@@ -333,14 +252,10 @@ export function toEndUserAccount(
|
|
|
333
252
|
): Promise<SignSolanaTransactionResult> {
|
|
334
253
|
Analytics.trackAction({ action: "end_user_sign_solana_transaction" });
|
|
335
254
|
const address = resolveSolanaAddress(endUser, opts.address);
|
|
336
|
-
return apiClient.signSolanaTransactionWithEndUserAccount(
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
address,
|
|
341
|
-
transaction: opts.transaction,
|
|
342
|
-
},
|
|
343
|
-
);
|
|
255
|
+
return apiClient.signSolanaTransactionWithEndUserAccount(endUser.userId, {
|
|
256
|
+
address,
|
|
257
|
+
transaction: opts.transaction,
|
|
258
|
+
});
|
|
344
259
|
},
|
|
345
260
|
|
|
346
261
|
// ─── Delegated Solana Send Methods ───
|
|
@@ -350,33 +265,23 @@ export function toEndUserAccount(
|
|
|
350
265
|
): Promise<SendSolanaTransactionResult> {
|
|
351
266
|
Analytics.trackAction({ action: "end_user_send_solana_transaction" });
|
|
352
267
|
const address = resolveSolanaAddress(endUser, opts.address);
|
|
353
|
-
return apiClient.sendSolanaTransactionWithEndUserAccount(
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
transaction: opts.transaction,
|
|
359
|
-
network: opts.network,
|
|
360
|
-
},
|
|
361
|
-
);
|
|
268
|
+
return apiClient.sendSolanaTransactionWithEndUserAccount(endUser.userId, {
|
|
269
|
+
address,
|
|
270
|
+
transaction: opts.transaction,
|
|
271
|
+
network: opts.network,
|
|
272
|
+
});
|
|
362
273
|
},
|
|
363
274
|
|
|
364
275
|
async sendSolanaAsset(opts: AccountSendSolanaAssetOptions): Promise<SendSolanaAssetResult> {
|
|
365
276
|
Analytics.trackAction({ action: "end_user_send_solana_asset" });
|
|
366
277
|
const address = resolveSolanaAddress(endUser, opts.address);
|
|
367
278
|
const asset = opts.asset ?? "usdc";
|
|
368
|
-
return apiClient.sendSolanaAssetWithEndUserAccount(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
to: opts.to,
|
|
375
|
-
amount: opts.amount,
|
|
376
|
-
network: opts.network,
|
|
377
|
-
createRecipientAta: opts.createRecipientAta,
|
|
378
|
-
},
|
|
379
|
-
);
|
|
279
|
+
return apiClient.sendSolanaAssetWithEndUserAccount(endUser.userId, address, asset, {
|
|
280
|
+
to: opts.to,
|
|
281
|
+
amount: opts.amount,
|
|
282
|
+
network: opts.network,
|
|
283
|
+
createRecipientAta: opts.createRecipientAta,
|
|
284
|
+
});
|
|
380
285
|
},
|
|
381
286
|
};
|
|
382
287
|
|
package/index.ts
CHANGED
|
@@ -19,8 +19,6 @@ export type {
|
|
|
19
19
|
ListEndUsersOptions,
|
|
20
20
|
EndUserAccount,
|
|
21
21
|
RevokeDelegationForEndUserOptions,
|
|
22
|
-
SignEvmHashOptions,
|
|
23
|
-
SignEvmHashResult,
|
|
24
22
|
SignEvmTransactionOptions,
|
|
25
23
|
SignEvmTransactionResult,
|
|
26
24
|
SignEvmMessageOptions,
|
|
@@ -35,8 +33,6 @@ export type {
|
|
|
35
33
|
SendUserOperationResult,
|
|
36
34
|
CreateEvmEip7702DelegationOptions as CreateEvmEip7702DelegationForEndUserOptions,
|
|
37
35
|
CreateEvmEip7702DelegationForEndUserResult,
|
|
38
|
-
SignSolanaHashOptions,
|
|
39
|
-
SignSolanaHashResult,
|
|
40
36
|
SignSolanaMessageOptions,
|
|
41
37
|
SignSolanaMessageResult,
|
|
42
38
|
SignSolanaTransactionOptions,
|
|
@@ -85,26 +85,6 @@ export const configure = (options: CdpOptions) => {
|
|
|
85
85
|
expiresIn: options.expiresIn,
|
|
86
86
|
debug: options.debugging,
|
|
87
87
|
});
|
|
88
|
-
|
|
89
|
-
/*
|
|
90
|
-
* Delegated routing interceptor.
|
|
91
|
-
* Embedded Wallet API's are exposed to the developer for delegated signing
|
|
92
|
-
* via the /delegated path, which properly forwards the Authorization and
|
|
93
|
-
* X-Wallet-Auth headers from the edge.
|
|
94
|
-
*
|
|
95
|
-
* Registered after withAuth so it runs BEFORE the auth interceptor (LIFO order).
|
|
96
|
-
* This rewrites the URL first, then the auth interceptor computes JWT headers
|
|
97
|
-
* (Authorization and X-Wallet-Auth) against the rewritten URL path, ensuring
|
|
98
|
-
* the `uris` claim matches the actual request URL.
|
|
99
|
-
* The API gateway validates the JWT, strips the /delegated prefix, and forwards
|
|
100
|
-
* to the backend.
|
|
101
|
-
*/
|
|
102
|
-
axiosInstance.interceptors.request.use(config => {
|
|
103
|
-
if (config.url && isDelegatedEndUserPath(config.url)) {
|
|
104
|
-
config.url = `/delegated${config.url}`;
|
|
105
|
-
}
|
|
106
|
-
return config;
|
|
107
|
-
});
|
|
108
88
|
};
|
|
109
89
|
|
|
110
90
|
/**
|
|
@@ -327,20 +307,6 @@ export const cdpApiClient = async <T>(
|
|
|
327
307
|
}
|
|
328
308
|
};
|
|
329
309
|
|
|
330
|
-
/**
|
|
331
|
-
* Checks if the given request URL is a delegated end-user operation that should
|
|
332
|
-
* be routed through the /platform/delegated gateway prefix.
|
|
333
|
-
*
|
|
334
|
-
* These endpoints require both Authorization and X-Wallet-Auth headers to be
|
|
335
|
-
* forwarded by the API gateway, which the /delegated prefix enables.
|
|
336
|
-
*
|
|
337
|
-
* @param url - The request URL (relative, without base path).
|
|
338
|
-
* @returns True if the path should be routed through /platform/delegated.
|
|
339
|
-
*/
|
|
340
|
-
const isDelegatedEndUserPath = (url: string): boolean => {
|
|
341
|
-
return /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/end-users\//.test(url);
|
|
342
|
-
};
|
|
343
|
-
|
|
344
310
|
/**
|
|
345
311
|
* Validates the call to the cdpApiClient.
|
|
346
312
|
*
|