@coinbase/cdp-sdk 1.48.0 → 1.48.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +5 -0
  3. package/_cjs/actions/webhooks/createWebhookSubscription.js.map +1 -1
  4. package/_cjs/client/end-user/endUser.js +23 -0
  5. package/_cjs/client/end-user/endUser.js.map +1 -1
  6. package/_cjs/client/end-user/toEndUserAccount.js +4 -0
  7. package/_cjs/client/end-user/toEndUserAccount.js.map +1 -1
  8. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +3 -0
  9. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  10. package/_cjs/openapi-client/generated/embedded-wallets/embedded-wallets.js +9 -1
  11. package/_cjs/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -1
  12. package/_cjs/version.js +1 -1
  13. package/_esm/actions/webhooks/createWebhookSubscription.js.map +1 -1
  14. package/_esm/client/end-user/endUser.js +23 -0
  15. package/_esm/client/end-user/endUser.js.map +1 -1
  16. package/_esm/client/end-user/toEndUserAccount.js +4 -0
  17. package/_esm/client/end-user/toEndUserAccount.js.map +1 -1
  18. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +3 -0
  19. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  20. package/_esm/openapi-client/generated/embedded-wallets/embedded-wallets.js +7 -0
  21. package/_esm/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -1
  22. package/_esm/version.js +1 -1
  23. package/_types/actions/webhooks/createWebhookSubscription.d.ts +1 -1
  24. package/_types/actions/webhooks/createWebhookSubscription.d.ts.map +1 -1
  25. package/_types/client/end-user/endUser.d.ts +18 -1
  26. package/_types/client/end-user/endUser.d.ts.map +1 -1
  27. package/_types/client/end-user/endUser.types.d.ts +28 -1
  28. package/_types/client/end-user/endUser.types.d.ts.map +1 -1
  29. package/_types/client/end-user/toEndUserAccount.d.ts.map +1 -1
  30. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +14 -0
  31. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  32. package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts +7 -1
  33. package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts.map +1 -1
  34. package/_types/openapi-client/index.d.ts +1 -0
  35. package/_types/openapi-client/index.d.ts.map +1 -1
  36. package/_types/version.d.ts +1 -1
  37. package/actions/webhooks/createWebhookSubscription.ts +6 -1
  38. package/client/end-user/endUser.ts +30 -0
  39. package/client/end-user/endUser.types.ts +31 -0
  40. package/client/end-user/toEndUserAccount.ts +6 -0
  41. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +16 -0
  42. package/openapi-client/generated/embedded-wallets/embedded-wallets.ts +19 -0
  43. package/package.json +1 -1
  44. package/version.ts +1 -1
@@ -10,7 +10,12 @@ export type WebhookEventType =
10
10
  | "wallet.transaction.replaced"
11
11
  | "wallet.transaction.confirmed"
12
12
  | "wallet.transaction.failed"
13
- | "wallet.transaction.signed";
13
+ | "wallet.transaction.signed"
14
+ | "wallet.typed_data.signed"
15
+ | "wallet.message.signed"
16
+ | "wallet.hash.signed"
17
+ | "wallet.delegation.created"
18
+ | "wallet.delegation.revoked";
14
19
 
15
20
  /**
16
21
  * Options for creating a webhook subscription.
@@ -14,6 +14,8 @@ import {
14
14
  type AddEndUserEvmSmartAccountResult,
15
15
  type AddEndUserSolanaAccountOptions,
16
16
  type AddEndUserSolanaAccountResult,
17
+ type GetDelegationForEndUserOptions,
18
+ type GetDelegationForEndUserResult,
17
19
  type RevokeDelegationForEndUserOptions,
18
20
  type SignEvmTransactionOptions,
19
21
  type SignEvmTransactionResult,
@@ -258,6 +260,34 @@ export class EndUserClient {
258
260
  return CdpOpenApiClient.addEndUserSolanaAccount(userId, {});
259
261
  }
260
262
 
263
+ /**
264
+ * Gets the active delegation for the specified end user, if one exists.
265
+ * This operation can be performed by the end user themselves or by a developer using their API key.
266
+ *
267
+ * @param options - The options for getting the delegation.
268
+ *
269
+ * @returns A promise that resolves to the delegation details including its expiry.
270
+ *
271
+ * @example **Get the active delegation for an end user**
272
+ * ```ts
273
+ * const delegation = await cdp.endUser.getDelegationForEndUser({
274
+ * userId: "user-123"
275
+ * });
276
+ * console.log(delegation.expiresAt);
277
+ * ```
278
+ */
279
+ async getDelegationForEndUser(
280
+ options: GetDelegationForEndUserOptions,
281
+ ): Promise<GetDelegationForEndUserResult> {
282
+ Analytics.trackAction({
283
+ action: "get_delegation_for_end_user",
284
+ });
285
+
286
+ const { userId } = options;
287
+
288
+ return CdpOpenApiClient.getDelegationForEndUser(userId);
289
+ }
290
+
261
291
  /**
262
292
  * Revokes all active delegations for the specified end user.
263
293
  * This operation can be performed by the end user themselves or by a developer using their API key.
@@ -7,6 +7,7 @@ import type {
7
7
  AddEndUserEvmSmartAccount201,
8
8
  AddEndUserSolanaAccount201,
9
9
  EndUser as OpenAPIEndUser,
10
+ GetDelegationForEndUser200,
10
11
  SignEvmTransactionWithEndUserAccount200,
11
12
  SignEvmMessageWithEndUserAccount200,
12
13
  SignEvmTypedDataWithEndUserAccount200,
@@ -139,6 +140,21 @@ export interface ImportEndUserOptions {
139
140
  encryptionPublicKey?: string;
140
141
  }
141
142
 
143
+ /**
144
+ * The options for getting the active delegation for an end user.
145
+ */
146
+ export interface GetDelegationForEndUserOptions {
147
+ /**
148
+ * The unique identifier of the end user.
149
+ */
150
+ userId: string;
151
+ }
152
+
153
+ /**
154
+ * The result of getting the active delegation for an end user.
155
+ */
156
+ export type GetDelegationForEndUserResult = GetDelegationForEndUser200;
157
+
142
158
  /**
143
159
  * The options for revoking all active delegations for an end user.
144
160
  */
@@ -595,6 +611,21 @@ export type EndUserAccountActions = {
595
611
  */
596
612
  addSolanaAccount: () => Promise<AddEndUserSolanaAccountResult>;
597
613
 
614
+ /**
615
+ * Gets the active delegation for this end user, if one exists.
616
+ *
617
+ * @returns A promise that resolves to the delegation details including its expiry.
618
+ *
619
+ * @example
620
+ * ```ts
621
+ * const endUser = await cdp.endUser.getEndUser({ userId: "user-123" });
622
+ *
623
+ * const delegation = await endUser.getDelegation();
624
+ * console.log(delegation.expiresAt);
625
+ * ```
626
+ */
627
+ getDelegation: () => Promise<GetDelegationForEndUserResult>;
628
+
598
629
  /**
599
630
  * Revokes all active delegations for this end user.
600
631
  * This operation can be performed by the end user themselves or by a developer using their API key.
@@ -6,6 +6,7 @@ import type {
6
6
  AddEndUserEvmSmartAccountResult,
7
7
  AddEndUserSolanaAccountResult,
8
8
  AddEvmSmartAccountOptions,
9
+ GetDelegationForEndUserResult,
9
10
  SignEvmTransactionResult,
10
11
  SignEvmMessageResult,
11
12
  SignEvmTypedDataResult,
@@ -143,6 +144,11 @@ export function toEndUserAccount(
143
144
  return apiClient.addEndUserSolanaAccount(endUser.userId, {});
144
145
  },
145
146
 
147
+ async getDelegation(): Promise<GetDelegationForEndUserResult> {
148
+ Analytics.trackAction({ action: "end_user_get_delegation" });
149
+ return apiClient.getDelegationForEndUser(endUser.userId);
150
+ },
151
+
146
152
  async revokeDelegation(): Promise<void> {
147
153
  Analytics.trackAction({ action: "end_user_revoke_delegation" });
148
154
  await apiClient.revokeDelegationForEndUser(endUser.userId, {});
@@ -284,7 +284,9 @@ export type ErrorType = (typeof ErrorType)[keyof typeof ErrorType];
284
284
  // eslint-disable-next-line @typescript-eslint/no-redeclare
285
285
  export const ErrorType = {
286
286
  already_exists: "already_exists",
287
+ authorization_expired: "authorization_expired",
287
288
  bad_gateway: "bad_gateway",
289
+ capture_expired: "capture_expired",
288
290
  client_closed_request: "client_closed_request",
289
291
  faucet_limit_exceeded: "faucet_limit_exceeded",
290
292
  forbidden: "forbidden",
@@ -315,6 +317,7 @@ export const ErrorType = {
315
317
  document_verification_failed: "document_verification_failed",
316
318
  recipient_allowlist_violation: "recipient_allowlist_violation",
317
319
  recipient_allowlist_pending: "recipient_allowlist_pending",
320
+ refund_expired: "refund_expired",
318
321
  travel_rules_recipient_violation: "travel_rules_recipient_violation",
319
322
  source_account_invalid: "source_account_invalid",
320
323
  target_account_invalid: "target_account_invalid",
@@ -4602,6 +4605,19 @@ export type SignEvmTypedDataWithEndUserAccount200 = {
4602
4605
  signature: string;
4603
4606
  };
4604
4607
 
4608
+ export type GetDelegationForEndUserParams = {
4609
+ /**
4610
+ * The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
4611
+ * @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
4612
+ */
4613
+ projectID?: ProjectIDOptionalParameter;
4614
+ };
4615
+
4616
+ export type GetDelegationForEndUser200 = {
4617
+ /** The date until which the delegation is valid. */
4618
+ expiresAt: string;
4619
+ };
4620
+
4605
4621
  export type RevokeDelegationForEndUserBody = {
4606
4622
  /**
4607
4623
  * When revoking with a wallet authentication scheme, the ID of the Temporary Wallet Secret that was used to sign the X-Wallet-Auth Header.
@@ -11,6 +11,8 @@ import type {
11
11
  CreateEvmEip7702DelegationWithEndUserAccountBody,
12
12
  CreateEvmEip7702DelegationWithEndUserAccountParams,
13
13
  EvmUserOperation,
14
+ GetDelegationForEndUser200,
15
+ GetDelegationForEndUserParams,
14
16
  RevokeDelegationForEndUserBody,
15
17
  SendEvmAssetWithEndUserAccount200,
16
18
  SendEvmAssetWithEndUserAccountBody,
@@ -185,6 +187,20 @@ export const signEvmTypedDataWithEndUserAccount = (
185
187
  options,
186
188
  );
187
189
  };
190
+ /**
191
+ * Returns the active delegation for the specified end user, if one exists. This operation can be performed by the end user themselves or by a developer using their API key.
192
+ * @summary Get delegation for end user
193
+ */
194
+ export const getDelegationForEndUser = (
195
+ userId: string,
196
+ params?: GetDelegationForEndUserParams,
197
+ options?: SecondParameter<typeof cdpApiClient<GetDelegationForEndUser200>>,
198
+ ) => {
199
+ return cdpApiClient<GetDelegationForEndUser200>(
200
+ { url: `/v2/embedded-wallet-api/end-users/${userId}/delegation`, method: "GET", params },
201
+ options,
202
+ );
203
+ };
188
204
  /**
189
205
  * Revokes all active delegations for the specified end user. This operation can be performed by the end user themselves or by a developer using their API key.
190
206
  * @summary Revoke delegation for end user
@@ -378,6 +394,9 @@ export type SignEvmMessageWithEndUserAccountResult = NonNullable<
378
394
  export type SignEvmTypedDataWithEndUserAccountResult = NonNullable<
379
395
  Awaited<ReturnType<typeof signEvmTypedDataWithEndUserAccount>>
380
396
  >;
397
+ export type GetDelegationForEndUserResult = NonNullable<
398
+ Awaited<ReturnType<typeof getDelegationForEndUser>>
399
+ >;
381
400
  export type RevokeDelegationForEndUserResult = NonNullable<
382
401
  Awaited<ReturnType<typeof revokeDelegationForEndUser>>
383
402
  >;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-sdk",
3
- "version": "1.48.0",
3
+ "version": "1.48.1",
4
4
  "description": "SDK for interacting with the Coinbase Developer Platform Wallet API",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
package/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.48.0";
1
+ export const version = "1.48.1";