@coinbase/cdp-sdk 1.47.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 (76) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +287 -0
  3. package/_cjs/actions/webhooks/createWebhookSubscription.js.map +1 -1
  4. package/_cjs/client/cdp.js +1 -4
  5. package/_cjs/client/cdp.js.map +1 -1
  6. package/_cjs/client/end-user/endUser.js +42 -89
  7. package/_cjs/client/end-user/endUser.js.map +1 -1
  8. package/_cjs/client/end-user/toEndUserAccount.js +17 -43
  9. package/_cjs/client/end-user/toEndUserAccount.js.map +1 -1
  10. package/_cjs/index.js.map +1 -1
  11. package/_cjs/openapi-client/cdpApiClient.js +0 -32
  12. package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
  13. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +57 -10
  14. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  15. package/_cjs/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.js → embedded-wallets/embedded-wallets.js} +45 -97
  16. package/_cjs/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -0
  17. package/_cjs/openapi-client/generated/webhooks/webhooks.js +6 -6
  18. package/_cjs/openapi-client/index.js +2 -2
  19. package/_cjs/openapi-client/index.js.map +1 -1
  20. package/_cjs/version.js +1 -1
  21. package/_esm/actions/webhooks/createWebhookSubscription.js.map +1 -1
  22. package/_esm/client/cdp.js +2 -5
  23. package/_esm/client/cdp.js.map +1 -1
  24. package/_esm/client/end-user/endUser.js +40 -87
  25. package/_esm/client/end-user/endUser.js.map +1 -1
  26. package/_esm/client/end-user/toEndUserAccount.js +17 -43
  27. package/_esm/client/end-user/toEndUserAccount.js.map +1 -1
  28. package/_esm/index.js.map +1 -1
  29. package/_esm/openapi-client/cdpApiClient.js +0 -32
  30. package/_esm/openapi-client/cdpApiClient.js.map +1 -1
  31. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +55 -8
  32. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  33. package/_esm/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.js → embedded-wallets/embedded-wallets.js} +43 -93
  34. package/_esm/openapi-client/generated/embedded-wallets/embedded-wallets.js.map +1 -0
  35. package/_esm/openapi-client/generated/webhooks/webhooks.js +6 -6
  36. package/_esm/openapi-client/index.js +2 -2
  37. package/_esm/openapi-client/index.js.map +1 -1
  38. package/_esm/version.js +1 -1
  39. package/_types/actions/webhooks/createWebhookSubscription.d.ts +1 -1
  40. package/_types/actions/webhooks/createWebhookSubscription.d.ts.map +1 -1
  41. package/_types/client/cdp.d.ts +2 -6
  42. package/_types/client/cdp.d.ts.map +1 -1
  43. package/_types/client/end-user/endUser.d.ts +19 -52
  44. package/_types/client/end-user/endUser.d.ts.map +1 -1
  45. package/_types/client/end-user/endUser.types.d.ts +26 -61
  46. package/_types/client/end-user/endUser.types.d.ts.map +1 -1
  47. package/_types/client/end-user/toEndUserAccount.d.ts +0 -2
  48. package/_types/client/end-user/toEndUserAccount.d.ts.map +1 -1
  49. package/_types/index.d.ts +1 -1
  50. package/_types/index.d.ts.map +1 -1
  51. package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
  52. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +490 -79
  53. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  54. package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts +151 -0
  55. package/_types/openapi-client/generated/embedded-wallets/embedded-wallets.d.ts.map +1 -0
  56. package/_types/openapi-client/generated/webhooks/webhooks.d.ts +6 -6
  57. package/_types/openapi-client/index.d.ts +14 -45
  58. package/_types/openapi-client/index.d.ts.map +1 -1
  59. package/_types/version.d.ts +1 -1
  60. package/actions/webhooks/createWebhookSubscription.ts +6 -1
  61. package/client/cdp.ts +3 -8
  62. package/client/end-user/endUser.ts +85 -187
  63. package/client/end-user/endUser.types.ts +28 -69
  64. package/client/end-user/toEndUserAccount.ts +63 -152
  65. package/index.ts +0 -4
  66. package/openapi-client/cdpApiClient.ts +0 -34
  67. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +551 -85
  68. package/openapi-client/generated/{embedded-wallets-core-functionality/embedded-wallets-core-functionality.ts → embedded-wallets/embedded-wallets.ts} +86 -249
  69. package/openapi-client/generated/webhooks/webhooks.ts +6 -6
  70. package/openapi-client/index.ts +2 -2
  71. package/package.json +1 -1
  72. package/version.ts +1 -1
  73. package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +0 -1
  74. package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +0 -1
  75. package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts +0 -312
  76. package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # CDP SDK Changelog
2
2
 
3
+ ## 1.48.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#671](https://github.com/coinbase/cdp-sdk/pull/671) [`04dfba1`](https://github.com/coinbase/cdp-sdk/commit/04dfba190ee410d8f5f52cc340b4039a3e526290) Thanks [@milan-cb](https://github.com/milan-cb)! - Added new webhook events for signing and delegated signing
8
+
9
+ ## 1.48.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#634](https://github.com/coinbase/cdp-sdk/pull/634) [`ed47c82`](https://github.com/coinbase/cdp-sdk/commit/ed47c821eca763742137500e3380371dd1b78ec1) Thanks [@milan-cb](https://github.com/milan-cb)! - Added CreateSubscription for Webhooks Client
14
+
15
+ - [#659](https://github.com/coinbase/cdp-sdk/pull/659) [`48ea200`](https://github.com/coinbase/cdp-sdk/commit/48ea20026283f10aa094af66dab4fc1d8feb051e) Thanks [@sammccord](https://github.com/sammccord)! - Consume refactored end user operations for delegated signing in end user client
16
+
3
17
  ## 1.47.0
4
18
 
5
19
  ### Minor Changes
package/README.md CHANGED
@@ -26,6 +26,13 @@
26
26
  - [Add EVM Smart Account to End User](#add-evm-smart-account-to-end-user)
27
27
  - [Add Solana Account to End User](#add-solana-account-to-end-user)
28
28
  - [Validate Access Token](#validate-access-token)
29
+ - [Delegated Signing Operations](#delegated-signing-operations)
30
+ - [Revoke Delegation](#revoke-delegation)
31
+ - [EVM Signing](#evm-signing)
32
+ - [EVM Sending](#evm-sending)
33
+ - [EVM EIP-7702 Delegation](#evm-eip-7702-delegation)
34
+ - [Solana Signing](#solana-signing)
35
+ - [Solana Sending](#solana-sending)
29
36
  - [Webhooks](#webhooks)
30
37
  - [Create Subscription](#create-subscription)
31
38
  - [Authentication tools](#authentication-tools)
@@ -1336,6 +1343,281 @@ try {
1336
1343
  }
1337
1344
  ```
1338
1345
 
1346
+ ## Delegated Signing Operations
1347
+
1348
+ When an end user has granted a delegation, you can sign and send transactions on their behalf using the `cdp.endUser` client methods or directly on the `EndUserAccount` object.
1349
+
1350
+ All delegated operations are available both as client methods (passing `userId` explicitly) and as convenience methods on the `EndUserAccount` object (where `userId` is automatically bound and `address` defaults to the first account if not specified).
1351
+
1352
+ ### Revoke Delegation
1353
+
1354
+ Revoke all active delegations for an end user:
1355
+
1356
+ ```typescript
1357
+ // Using the client method
1358
+ await cdp.endUser.revokeDelegationForEndUser({
1359
+ userId: "user-123",
1360
+ });
1361
+
1362
+ // Or using the EndUser object
1363
+ const endUser = await cdp.endUser.getEndUser({ userId: "user-123" });
1364
+ await endUser.revokeDelegation();
1365
+ ```
1366
+
1367
+ For a complete example, see [end-users/revokeDelegation.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/end-users/revokeDelegation.ts).
1368
+
1369
+ ### EVM Signing
1370
+
1371
+ #### Sign an EVM Transaction
1372
+
1373
+ ```typescript
1374
+ const result = await cdp.endUser.signEvmTransaction({
1375
+ userId: "user-123",
1376
+ address: "0x1234...",
1377
+ transaction: "0x02...", // RLP-serialized EIP-1559 transaction, hex-encoded
1378
+ });
1379
+ console.log(result.signedTransaction);
1380
+
1381
+ // Or using the EndUser object
1382
+ const result = await endUser.signEvmTransaction({
1383
+ transaction: "0x02...",
1384
+ });
1385
+ console.log(result.signedTransaction);
1386
+ ```
1387
+
1388
+ #### Sign an EVM Message (EIP-191)
1389
+
1390
+ ```typescript
1391
+ const result = await cdp.endUser.signEvmMessage({
1392
+ userId: "user-123",
1393
+ address: "0x1234...",
1394
+ message: "Hello, World!",
1395
+ });
1396
+ console.log(result.signature);
1397
+
1398
+ // Or using the EndUser object
1399
+ const result = await endUser.signEvmMessage({
1400
+ message: "Hello, World!",
1401
+ });
1402
+ console.log(result.signature);
1403
+ ```
1404
+
1405
+ #### Sign EVM Typed Data (EIP-712)
1406
+
1407
+ ```typescript
1408
+ const result = await cdp.endUser.signEvmTypedData({
1409
+ userId: "user-123",
1410
+ address: "0x1234...",
1411
+ typedData: {
1412
+ domain: { name: "Example" },
1413
+ types: { Message: [{ name: "content", type: "string" }] },
1414
+ primaryType: "Message",
1415
+ message: { content: "Hello" },
1416
+ },
1417
+ });
1418
+ console.log(result.signature);
1419
+
1420
+ // Or using the EndUser object
1421
+ const result = await endUser.signEvmTypedData({
1422
+ typedData: {
1423
+ domain: { name: "Example" },
1424
+ types: { Message: [{ name: "content", type: "string" }] },
1425
+ primaryType: "Message",
1426
+ message: { content: "Hello" },
1427
+ },
1428
+ });
1429
+ console.log(result.signature);
1430
+ ```
1431
+
1432
+ ### EVM Sending
1433
+
1434
+ #### Send an EVM Transaction
1435
+
1436
+ ```typescript
1437
+ const result = await cdp.endUser.sendEvmTransaction({
1438
+ userId: "user-123",
1439
+ address: "0x1234...",
1440
+ transaction: "0x02...", // RLP-serialized EIP-1559 transaction, hex-encoded
1441
+ network: "base-sepolia",
1442
+ });
1443
+ console.log(result.transactionHash);
1444
+
1445
+ // Or using the EndUser object
1446
+ const result = await endUser.sendEvmTransaction({
1447
+ transaction: "0x02...",
1448
+ network: "base-sepolia",
1449
+ });
1450
+ console.log(result.transactionHash);
1451
+ ```
1452
+
1453
+ For a complete example, see [end-users/sendEvmTransaction.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/end-users/sendEvmTransaction.ts).
1454
+
1455
+ #### Send an EVM Asset
1456
+
1457
+ Send tokens (e.g. USDC) on behalf of an end user:
1458
+
1459
+ ```typescript
1460
+ const result = await cdp.endUser.sendEvmAsset({
1461
+ userId: "user-123",
1462
+ address: "0x1234...",
1463
+ to: "0xabcd...",
1464
+ amount: "1000000",
1465
+ network: "base-sepolia",
1466
+ asset: "usdc", // optional, defaults to "usdc"
1467
+ useCdpPaymaster: true, // optional
1468
+ });
1469
+ console.log(result.transactionHash);
1470
+
1471
+ // Or using the EndUser object
1472
+ const result = await endUser.sendEvmAsset({
1473
+ to: "0xabcd...",
1474
+ amount: "1000000",
1475
+ network: "base-sepolia",
1476
+ });
1477
+ console.log(result.transactionHash);
1478
+ ```
1479
+
1480
+ For a complete example, see [end-users/sendEvmAsset.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/end-users/sendEvmAsset.ts).
1481
+
1482
+ #### Send a User Operation (Smart Account)
1483
+
1484
+ Send a user operation via an end user's smart account:
1485
+
1486
+ ```typescript
1487
+ const result = await cdp.endUser.sendUserOperation({
1488
+ userId: "user-123",
1489
+ address: "0x1234...", // smart account address
1490
+ network: "base-sepolia",
1491
+ calls: [
1492
+ {
1493
+ to: "0xabcd...",
1494
+ value: "0",
1495
+ data: "0x",
1496
+ },
1497
+ ],
1498
+ useCdpPaymaster: true,
1499
+ });
1500
+
1501
+ // Or using the EndUser object (address defaults to the first smart account)
1502
+ const result = await endUser.sendUserOperation({
1503
+ network: "base-sepolia",
1504
+ calls: [
1505
+ {
1506
+ to: "0xabcd...",
1507
+ value: "0",
1508
+ data: "0x",
1509
+ },
1510
+ ],
1511
+ useCdpPaymaster: true,
1512
+ });
1513
+ ```
1514
+
1515
+ For a complete example, see [end-users/sendUserOperation.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/end-users/sendUserOperation.ts).
1516
+
1517
+ ### EVM EIP-7702 Delegation
1518
+
1519
+ Create an EIP-7702 delegation on behalf of an end user, upgrading their EOA with smart account capabilities:
1520
+
1521
+ ```typescript
1522
+ const result = await cdp.endUser.createEvmEip7702Delegation({
1523
+ userId: "user-123",
1524
+ address: "0x1234...",
1525
+ network: "base-sepolia",
1526
+ enableSpendPermissions: false, // optional
1527
+ });
1528
+ console.log(result.delegationOperationId);
1529
+
1530
+ // Or using the EndUser object
1531
+ const result = await endUser.createEvmEip7702Delegation({
1532
+ network: "base-sepolia",
1533
+ });
1534
+ console.log(result.delegationOperationId);
1535
+ ```
1536
+
1537
+ For a complete example, see [end-users/createEvmEip7702Delegation.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/end-users/createEvmEip7702Delegation.ts).
1538
+
1539
+ ### Solana Signing
1540
+
1541
+ #### Sign a Solana Message
1542
+
1543
+ ```typescript
1544
+ const result = await cdp.endUser.signSolanaMessage({
1545
+ userId: "user-123",
1546
+ address: "So1ana...",
1547
+ message: "base64message...",
1548
+ });
1549
+ console.log(result.signature);
1550
+
1551
+ // Or using the EndUser object
1552
+ const result = await endUser.signSolanaMessage({
1553
+ message: "base64message...",
1554
+ });
1555
+ console.log(result.signature);
1556
+ ```
1557
+
1558
+ For a complete example, see [end-users/signSolanaMessage.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/end-users/signSolanaMessage.ts).
1559
+
1560
+ #### Sign a Solana Transaction
1561
+
1562
+ ```typescript
1563
+ const result = await cdp.endUser.signSolanaTransaction({
1564
+ userId: "user-123",
1565
+ address: "So1ana...",
1566
+ transaction: "base64tx...",
1567
+ });
1568
+ console.log(result.signedTransaction);
1569
+
1570
+ // Or using the EndUser object
1571
+ const result = await endUser.signSolanaTransaction({
1572
+ transaction: "base64tx...",
1573
+ });
1574
+ console.log(result.signedTransaction);
1575
+ ```
1576
+
1577
+ ### Solana Sending
1578
+
1579
+ #### Send a Solana Transaction
1580
+
1581
+ ```typescript
1582
+ const result = await cdp.endUser.sendSolanaTransaction({
1583
+ userId: "user-123",
1584
+ address: "So1ana...",
1585
+ transaction: "base64tx...",
1586
+ network: "solana-devnet",
1587
+ });
1588
+ console.log(result.transactionSignature);
1589
+
1590
+ // Or using the EndUser object
1591
+ const result = await endUser.sendSolanaTransaction({
1592
+ transaction: "base64tx...",
1593
+ network: "solana-devnet",
1594
+ });
1595
+ console.log(result.transactionSignature);
1596
+ ```
1597
+
1598
+ #### Send a Solana Asset
1599
+
1600
+ ```typescript
1601
+ const result = await cdp.endUser.sendSolanaAsset({
1602
+ userId: "user-123",
1603
+ address: "So1ana...",
1604
+ to: "Recipi...",
1605
+ amount: "1000000",
1606
+ network: "solana-devnet",
1607
+ asset: "usdc", // optional, defaults to "usdc"
1608
+ createRecipientAta: true, // optional, creates recipient's associated token account
1609
+ });
1610
+ console.log(result.transactionSignature);
1611
+
1612
+ // Or using the EndUser object
1613
+ const result = await endUser.sendSolanaAsset({
1614
+ to: "Recipi...",
1615
+ amount: "1000000",
1616
+ network: "solana-devnet",
1617
+ });
1618
+ console.log(result.transactionSignature);
1619
+ ```
1620
+
1339
1621
  ## Webhooks
1340
1622
 
1341
1623
  You can use the webhooks SDK to subscribe to on-chain and wallet events and receive notifications at a URL of your choice.
@@ -1371,6 +1653,11 @@ The available wallet event types are:
1371
1653
  - `wallet.transaction.confirmed`
1372
1654
  - `wallet.transaction.failed`
1373
1655
  - `wallet.transaction.signed`
1656
+ - `wallet.typed_data.signed`
1657
+ - `wallet.message.signed`
1658
+ - `wallet.hash.signed`
1659
+ - `wallet.delegation.created`
1660
+ - `wallet.delegation.revoked`
1374
1661
 
1375
1662
  For a complete working example, see [webhooks/createWebhookSubscription.ts](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/webhooks/createWebhookSubscription.ts).
1376
1663
 
@@ -1 +1 @@
1
- {"version":3,"file":"createWebhookSubscription.js","sourceRoot":"","sources":["../../../actions/webhooks/createWebhookSubscription.ts"],"names":[],"mappings":";;AA6EA,8DA0BC;AA/CD;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,yBAAyB,CAC7C,MAA4B,EAC5B,OAAyC;IAEzC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC;QACtD,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,MAAM,EAAE;YACN,GAAG,EAAE,OAAO,CAAC,SAAS;YACtB,OAAO,EAAE,OAAO,CAAC,aAAa;SAC/B;QACD,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;QACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;IAEH,OAAO;QACL,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG;QAC9B,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO;QACtC,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,SAAS,EAAE,QAAQ,CAAC,SAAS;KAC9B,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"createWebhookSubscription.js","sourceRoot":"","sources":["../../../actions/webhooks/createWebhookSubscription.ts"],"names":[],"mappings":";;AAkFA,8DA0BC;AA/CD;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,yBAAyB,CAC7C,MAA4B,EAC5B,OAAyC;IAEzC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC;QACtD,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,MAAM,EAAE;YACN,GAAG,EAAE,OAAO,CAAC,SAAS;YACtB,OAAO,EAAE,OAAO,CAAC,aAAa;SAC/B;QACD,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;QACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,CAAC;IAEH,OAAO;QACL,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG;QAC9B,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO;QACtC,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,SAAS,EAAE,QAAQ,CAAC,SAAS;KAC9B,CAAC;AACJ,CAAC"}
@@ -38,7 +38,6 @@ class CdpClient {
38
38
  * CDP_API_KEY_ID=your-api-key-id
39
39
  * CDP_API_KEY_SECRET=your-api-key-secret
40
40
  * CDP_WALLET_SECRET=your-wallet-secret
41
- * CDP_PROJECT_ID=your-project-id
42
41
  * ```
43
42
  *
44
43
  * Or passed as options to the constructor:
@@ -48,7 +47,6 @@ class CdpClient {
48
47
  * apiKeyId: "your-api-key-id",
49
48
  * apiKeySecret: "your-api-key-secret",
50
49
  * walletSecret: "your-wallet-secret",
51
- * projectId: "your-project-id",
52
50
  * });
53
51
  * ```
54
52
  *
@@ -70,7 +68,6 @@ We recommend using https://github.com/Schniz/fnm for managing your Node.js versi
70
68
  const apiKeyId = options.apiKeyId ?? process.env.CDP_API_KEY_ID ?? process.env.CDP_API_KEY_NAME;
71
69
  const apiKeySecret = options.apiKeySecret ?? process.env.CDP_API_KEY_SECRET;
72
70
  const walletSecret = options.walletSecret ?? process.env.CDP_WALLET_SECRET;
73
- const projectId = options.projectId ?? process.env.CDP_PROJECT_ID;
74
71
  if (!apiKeyId || !apiKeySecret) {
75
72
  throw new Error(`
76
73
  \nMissing required CDP Secret API Key configuration parameters.
@@ -117,7 +114,7 @@ For more information, see: https://github.com/coinbase/cdp-sdk/blob/main/typescr
117
114
  this.evm = new evm_js_1.EvmClient();
118
115
  this.solana = new solana_js_1.SolanaClient();
119
116
  this.policies = new policies_js_1.PoliciesClient();
120
- this.endUser = new endUser_js_1.CDPEndUserClient(projectId);
117
+ this.endUser = new endUser_js_1.EndUserClient();
121
118
  this.webhooks = new webhooks_js_1.WebhooksClient();
122
119
  }
123
120
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cdp.js","sourceRoot":"","sources":["../../client/cdp.ts"],"names":[],"mappings":";;;AAAA,kDAA4C;AAC5C,yDAA8D;AAC9D,8CAAwC;AACxC,sDAAyD;AACzD,yCAAyC;AACzC,wDAAwD;AACxD,kDAAkD;AAClD,wDAAwD;AAiBxD;;GAEG;AACH,MAAa,SAAS;IACpB,4CAA4C;IACrC,GAAG,CAAY;IAEtB,+CAA+C;IACxC,MAAM,CAAe;IAE5B,iDAAiD;IAC1C,QAAQ,CAAiB;IAEhC,iDAAiD;IAC1C,OAAO,CAAmB;IAEjC,gDAAgD;IACzC,QAAQ,CAAiB;IAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,YAAY,UAA4B,EAAE;QACxC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CACb;kBACU,OAAO,CAAC,QAAQ,CAAC,IAAI;;SAE9B,CACF,CAAC;QACJ,CAAC;QAED,MAAM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vB,CAAC,CAAC;QAEH,IACE,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,MAAM;YAClD,OAAO,CAAC,GAAG,CAAC,0BAA0B,KAAK,MAAM,EACjD,CAAC;YACD,wBAAS,CAAC,UAAU,GAAG,QAAQ,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,IAAI,kBAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAY,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,4BAAc,EAAE,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,0BAAa,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,4BAAc,EAAE,CAAC;IACvC,CAAC;CACF;AAvHD,8BAuHC"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CDPEndUserClient = void 0;
6
+ exports.EndUserClient = void 0;
7
7
  const crypto_1 = require("crypto");
8
8
  const bs58_1 = __importDefault(require("bs58"));
9
9
  const toEndUserAccount_js_1 = require("./toEndUserAccount.js");
@@ -14,16 +14,7 @@ const index_js_1 = require("../../openapi-client/index.js");
14
14
  /**
15
15
  * The CDP end user client.
16
16
  */
17
- class CDPEndUserClient {
18
- projectId;
19
- /**
20
- * Creates a new CDPEndUserClient.
21
- *
22
- * @param projectId - The CDP project ID. Required for delegation operations (signing, sending).
23
- */
24
- constructor(projectId) {
25
- this.projectId = projectId;
26
- }
17
+ class EndUserClient {
27
18
  /**
28
19
  * Creates an end user. An end user is an entity that can own CDP EVM accounts,
29
20
  * EVM smart accounts, and/or Solana accounts.
@@ -61,7 +52,7 @@ class CDPEndUserClient {
61
52
  ...options,
62
53
  userId,
63
54
  });
64
- return (0, toEndUserAccount_js_1.toEndUserAccount)(index_js_1.CdpOpenApiClient, { endUser, projectId: this.projectId });
55
+ return (0, toEndUserAccount_js_1.toEndUserAccount)(index_js_1.CdpOpenApiClient, { endUser });
65
56
  }
66
57
  /**
67
58
  * Lists end users belonging to the developer's CDP Project.
@@ -127,7 +118,7 @@ class CDPEndUserClient {
127
118
  });
128
119
  const { userId } = options;
129
120
  const endUser = await index_js_1.CdpOpenApiClient.getEndUser(userId);
130
- return (0, toEndUserAccount_js_1.toEndUserAccount)(index_js_1.CdpOpenApiClient, { endUser, projectId: this.projectId });
121
+ return (0, toEndUserAccount_js_1.toEndUserAccount)(index_js_1.CdpOpenApiClient, { endUser });
131
122
  }
132
123
  /**
133
124
  * Adds an EVM EOA (Externally Owned Account) to an existing end user. End users can have up to 10 EVM accounts.
@@ -207,6 +198,29 @@ class CDPEndUserClient {
207
198
  const { userId } = options;
208
199
  return index_js_1.CdpOpenApiClient.addEndUserSolanaAccount(userId, {});
209
200
  }
201
+ /**
202
+ * Gets the active delegation for the specified end user, if one exists.
203
+ * This operation can be performed by the end user themselves or by a developer using their API key.
204
+ *
205
+ * @param options - The options for getting the delegation.
206
+ *
207
+ * @returns A promise that resolves to the delegation details including its expiry.
208
+ *
209
+ * @example **Get the active delegation for an end user**
210
+ * ```ts
211
+ * const delegation = await cdp.endUser.getDelegationForEndUser({
212
+ * userId: "user-123"
213
+ * });
214
+ * console.log(delegation.expiresAt);
215
+ * ```
216
+ */
217
+ async getDelegationForEndUser(options) {
218
+ analytics_js_1.Analytics.trackAction({
219
+ action: "get_delegation_for_end_user",
220
+ });
221
+ const { userId } = options;
222
+ return index_js_1.CdpOpenApiClient.getDelegationForEndUser(userId);
223
+ }
210
224
  /**
211
225
  * Revokes all active delegations for the specified end user.
212
226
  * This operation can be performed by the end user themselves or by a developer using their API key.
@@ -227,34 +241,9 @@ class CDPEndUserClient {
227
241
  action: "revoke_delegation_for_end_user",
228
242
  });
229
243
  const { userId } = options;
230
- await index_js_1.CdpOpenApiClient.revokeDelegationForEndUser(this.requireProjectId(), userId, {});
244
+ await index_js_1.CdpOpenApiClient.revokeDelegationForEndUser(userId, {});
231
245
  }
232
246
  // ─── Delegated EVM Sign Methods ───
233
- /**
234
- * Signs an EVM hash on behalf of an end user using a delegation.
235
- * The end user must have previously created a delegation granting signing permissions.
236
- *
237
- * @param options - The options for signing an EVM hash.
238
- *
239
- * @returns A promise that resolves to the signature.
240
- *
241
- * @example
242
- * ```ts
243
- * const result = await cdp.endUser.signEvmHash({
244
- * userId: "user-123",
245
- * hash: "0xabcdef...",
246
- * address: "0x1234..."
247
- * });
248
- * console.log(result.signature);
249
- * ```
250
- */
251
- async signEvmHash(options) {
252
- analytics_js_1.Analytics.trackAction({ action: "end_user_sign_evm_hash" });
253
- return index_js_1.CdpOpenApiClient.signEvmHashWithEndUserAccount(this.requireProjectId(), options.userId, {
254
- hash: options.hash,
255
- address: options.address,
256
- });
257
- }
258
247
  /**
259
248
  * Signs an EVM transaction on behalf of an end user using a delegation.
260
249
  *
@@ -274,7 +263,7 @@ class CDPEndUserClient {
274
263
  */
275
264
  async signEvmTransaction(options) {
276
265
  analytics_js_1.Analytics.trackAction({ action: "end_user_sign_evm_transaction" });
277
- return index_js_1.CdpOpenApiClient.signEvmTransactionWithEndUserAccount(this.requireProjectId(), options.userId, {
266
+ return index_js_1.CdpOpenApiClient.signEvmTransactionWithEndUserAccount(options.userId, {
278
267
  address: options.address,
279
268
  transaction: options.transaction,
280
269
  });
@@ -298,7 +287,7 @@ class CDPEndUserClient {
298
287
  */
299
288
  async signEvmMessage(options) {
300
289
  analytics_js_1.Analytics.trackAction({ action: "end_user_sign_evm_message" });
301
- return index_js_1.CdpOpenApiClient.signEvmMessageWithEndUserAccount(this.requireProjectId(), options.userId, {
290
+ return index_js_1.CdpOpenApiClient.signEvmMessageWithEndUserAccount(options.userId, {
302
291
  address: options.address,
303
292
  message: options.message,
304
293
  });
@@ -322,7 +311,7 @@ class CDPEndUserClient {
322
311
  */
323
312
  async signEvmTypedData(options) {
324
313
  analytics_js_1.Analytics.trackAction({ action: "end_user_sign_evm_typed_data" });
325
- return index_js_1.CdpOpenApiClient.signEvmTypedDataWithEndUserAccount(this.requireProjectId(), options.userId, {
314
+ return index_js_1.CdpOpenApiClient.signEvmTypedDataWithEndUserAccount(options.userId, {
326
315
  address: options.address,
327
316
  typedData: options.typedData,
328
317
  });
@@ -348,7 +337,7 @@ class CDPEndUserClient {
348
337
  */
349
338
  async sendEvmTransaction(options) {
350
339
  analytics_js_1.Analytics.trackAction({ action: "end_user_send_evm_transaction" });
351
- return index_js_1.CdpOpenApiClient.sendEvmTransactionWithEndUserAccount(this.requireProjectId(), options.userId, {
340
+ return index_js_1.CdpOpenApiClient.sendEvmTransactionWithEndUserAccount(options.userId, {
352
341
  address: options.address,
353
342
  transaction: options.transaction,
354
343
  network: options.network,
@@ -376,7 +365,7 @@ class CDPEndUserClient {
376
365
  async sendEvmAsset(options) {
377
366
  analytics_js_1.Analytics.trackAction({ action: "end_user_send_evm_asset" });
378
367
  const asset = options.asset ?? "usdc";
379
- return index_js_1.CdpOpenApiClient.sendEvmAssetWithEndUserAccount(this.requireProjectId(), options.userId, options.address, asset, {
368
+ return index_js_1.CdpOpenApiClient.sendEvmAssetWithEndUserAccount(options.userId, options.address, asset, {
380
369
  to: options.to,
381
370
  amount: options.amount,
382
371
  network: options.network,
@@ -404,7 +393,7 @@ class CDPEndUserClient {
404
393
  */
405
394
  async sendUserOperation(options) {
406
395
  analytics_js_1.Analytics.trackAction({ action: "end_user_send_user_operation" });
407
- return index_js_1.CdpOpenApiClient.sendUserOperationWithEndUserAccount(this.requireProjectId(), options.userId, options.address, {
396
+ return index_js_1.CdpOpenApiClient.sendUserOperationWithEndUserAccount(options.userId, options.address, {
408
397
  network: options.network,
409
398
  calls: options.calls,
410
399
  useCdpPaymaster: options.useCdpPaymaster,
@@ -432,37 +421,13 @@ class CDPEndUserClient {
432
421
  */
433
422
  async createEvmEip7702Delegation(options) {
434
423
  analytics_js_1.Analytics.trackAction({ action: "end_user_create_evm_eip7702_delegation" });
435
- return index_js_1.CdpOpenApiClient.createEvmEip7702DelegationWithEndUserAccount(this.requireProjectId(), options.userId, {
424
+ return index_js_1.CdpOpenApiClient.createEvmEip7702DelegationWithEndUserAccount(options.userId, {
436
425
  address: options.address,
437
426
  network: options.network,
438
427
  enableSpendPermissions: options.enableSpendPermissions,
439
428
  });
440
429
  }
441
430
  // ─── Delegated Solana Sign Methods ───
442
- /**
443
- * Signs a Solana hash on behalf of an end user using a delegation.
444
- *
445
- * @param options - The options for signing a Solana hash.
446
- *
447
- * @returns A promise that resolves to the signature.
448
- *
449
- * @example
450
- * ```ts
451
- * const result = await cdp.endUser.signSolanaHash({
452
- * userId: "user-123",
453
- * hash: "base64hash...",
454
- * address: "So1ana..."
455
- * });
456
- * console.log(result.signature);
457
- * ```
458
- */
459
- async signSolanaHash(options) {
460
- analytics_js_1.Analytics.trackAction({ action: "end_user_sign_solana_hash" });
461
- return index_js_1.CdpOpenApiClient.signSolanaHashWithEndUserAccount(this.requireProjectId(), options.userId, {
462
- hash: options.hash,
463
- address: options.address,
464
- });
465
- }
466
431
  /**
467
432
  * Signs a Solana message on behalf of an end user using a delegation.
468
433
  *
@@ -482,7 +447,7 @@ class CDPEndUserClient {
482
447
  */
483
448
  async signSolanaMessage(options) {
484
449
  analytics_js_1.Analytics.trackAction({ action: "end_user_sign_solana_message" });
485
- return index_js_1.CdpOpenApiClient.signSolanaMessageWithEndUserAccount(this.requireProjectId(), options.userId, {
450
+ return index_js_1.CdpOpenApiClient.signSolanaMessageWithEndUserAccount(options.userId, {
486
451
  address: options.address,
487
452
  message: options.message,
488
453
  });
@@ -506,7 +471,7 @@ class CDPEndUserClient {
506
471
  */
507
472
  async signSolanaTransaction(options) {
508
473
  analytics_js_1.Analytics.trackAction({ action: "end_user_sign_solana_transaction" });
509
- return index_js_1.CdpOpenApiClient.signSolanaTransactionWithEndUserAccount(this.requireProjectId(), options.userId, {
474
+ return index_js_1.CdpOpenApiClient.signSolanaTransactionWithEndUserAccount(options.userId, {
510
475
  address: options.address,
511
476
  transaction: options.transaction,
512
477
  });
@@ -532,7 +497,7 @@ class CDPEndUserClient {
532
497
  */
533
498
  async sendSolanaTransaction(options) {
534
499
  analytics_js_1.Analytics.trackAction({ action: "end_user_send_solana_transaction" });
535
- return index_js_1.CdpOpenApiClient.sendSolanaTransactionWithEndUserAccount(this.requireProjectId(), options.userId, {
500
+ return index_js_1.CdpOpenApiClient.sendSolanaTransactionWithEndUserAccount(options.userId, {
536
501
  address: options.address,
537
502
  transaction: options.transaction,
538
503
  network: options.network,
@@ -560,7 +525,7 @@ class CDPEndUserClient {
560
525
  async sendSolanaAsset(options) {
561
526
  analytics_js_1.Analytics.trackAction({ action: "end_user_send_solana_asset" });
562
527
  const asset = options.asset ?? "usdc";
563
- return index_js_1.CdpOpenApiClient.sendSolanaAssetWithEndUserAccount(this.requireProjectId(), options.userId, options.address, asset, {
528
+ return index_js_1.CdpOpenApiClient.sendSolanaAssetWithEndUserAccount(options.userId, options.address, asset, {
564
529
  to: options.to,
565
530
  amount: options.amount,
566
531
  network: options.network,
@@ -582,7 +547,7 @@ class CDPEndUserClient {
582
547
  const endUser = await index_js_1.CdpOpenApiClient.validateEndUserAccessToken({
583
548
  accessToken,
584
549
  });
585
- return (0, toEndUserAccount_js_1.toEndUserAccount)(index_js_1.CdpOpenApiClient, { endUser, projectId: this.projectId });
550
+ return (0, toEndUserAccount_js_1.toEndUserAccount)(index_js_1.CdpOpenApiClient, { endUser });
586
551
  }
587
552
  /**
588
553
  * Imports an existing private key for an end user.
@@ -659,20 +624,8 @@ class CDPEndUserClient {
659
624
  encryptedPrivateKey: encryptedPrivateKey.toString("base64"),
660
625
  keyType: options.keyType,
661
626
  });
662
- return (0, toEndUserAccount_js_1.toEndUserAccount)(index_js_1.CdpOpenApiClient, { endUser, projectId: this.projectId });
663
- }
664
- /**
665
- * Returns the configured project ID or throws if not configured.
666
- *
667
- * @returns The project ID.
668
- */
669
- requireProjectId() {
670
- if (!this.projectId) {
671
- throw new errors_js_1.UserInputValidationError("Missing required project ID for delegation operation. " +
672
- "Set the CDP_PROJECT_ID environment variable or pass projectId to the CdpClient constructor.");
673
- }
674
- return this.projectId;
627
+ return (0, toEndUserAccount_js_1.toEndUserAccount)(index_js_1.CdpOpenApiClient, { endUser });
675
628
  }
676
629
  }
677
- exports.CDPEndUserClient = CDPEndUserClient;
630
+ exports.EndUserClient = EndUserClient;
678
631
  //# sourceMappingURL=endUser.js.map