@crossmint/wallets-sdk 0.20.2 → 0.21.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.
Files changed (155) hide show
  1. package/dist/api/__tests__/test-utils.cjs +8 -8
  2. package/dist/api/__tests__/test-utils.d.cts +3 -3
  3. package/dist/api/__tests__/test-utils.d.ts +3 -3
  4. package/dist/api/__tests__/test-utils.js +6 -6
  5. package/dist/api/client.cjs +4 -4
  6. package/dist/api/client.d.cts +1 -0
  7. package/dist/api/client.d.ts +1 -0
  8. package/dist/api/client.js +3 -3
  9. package/dist/api/gen/index.cjs +3 -103
  10. package/dist/api/gen/index.d.cts +2 -2
  11. package/dist/api/gen/index.d.ts +2 -2
  12. package/dist/api/gen/index.js +6 -106
  13. package/dist/api/gen/sdk.gen.cjs +2 -102
  14. package/dist/api/gen/sdk.gen.d.cts +22 -370
  15. package/dist/api/gen/sdk.gen.d.ts +22 -370
  16. package/dist/api/gen/sdk.gen.js +5 -105
  17. package/dist/api/gen/types.gen.d.cts +2558 -5712
  18. package/dist/api/gen/types.gen.d.ts +2558 -5712
  19. package/dist/api/index.cjs +4 -4
  20. package/dist/api/index.js +3 -3
  21. package/dist/api/types.d.cts +12 -12
  22. package/dist/api/types.d.ts +12 -12
  23. package/dist/chains/chains.cjs +5 -5
  24. package/dist/chains/chains.js +4 -4
  25. package/dist/{chunk-JREZWZ2S.cjs → chunk-2M32LBCA.cjs} +3 -3
  26. package/dist/{chunk-KQH5ZXJ4.js → chunk-2PSAUSOG.js} +61 -18
  27. package/dist/chunk-2RG6642I.js +39 -0
  28. package/dist/{chunk-R4AW5ADG.cjs → chunk-3WZUNLYI.cjs} +1 -1
  29. package/dist/{chunk-6UMJYMAY.js → chunk-4Z3YDHHG.js} +2 -2
  30. package/dist/{chunk-POG76HDD.cjs → chunk-4ZWUI6LE.cjs} +64 -48
  31. package/dist/chunk-5IC7UWND.cjs +1 -0
  32. package/dist/{chunk-HXJ3YPAN.js → chunk-65KPNJ77.js} +13 -4
  33. package/dist/{chunk-IDKGJO2G.cjs → chunk-7EZDSDKA.cjs} +21 -11
  34. package/dist/{chunk-PM7BGATN.cjs → chunk-7SUWMK4J.cjs} +34 -25
  35. package/dist/{chunk-47R3UV3J.cjs → chunk-7W4HGN3H.cjs} +11 -6
  36. package/dist/chunk-BR4UVMIC.js +332 -0
  37. package/dist/chunk-BUBSPQ7U.cjs +332 -0
  38. package/dist/{chunk-MRZXYVQO.cjs → chunk-CPZQ7BK5.cjs} +6 -6
  39. package/dist/chunk-CTOLL4BK.js +29 -0
  40. package/dist/chunk-DDNG224J.cjs +45 -0
  41. package/dist/{chunk-T2XUADHW.js → chunk-EVR4CD53.js} +8 -3
  42. package/dist/{chunk-U3NV7UY7.js → chunk-FZQG6OX2.js} +1 -1
  43. package/dist/chunk-GJT2JD3E.js +45 -0
  44. package/dist/{chunk-TYQ4YIP7.js → chunk-GLUD6EBN.js} +1 -1
  45. package/dist/chunk-H6WV5NRT.js +10 -0
  46. package/dist/{chunk-FICVKSXZ.js → chunk-HFEF2URB.js} +2 -2
  47. package/dist/chunk-HWTWDQYT.cjs +42 -0
  48. package/dist/{chunk-CMBFV325.js → chunk-HYA3ESUA.js} +3 -3
  49. package/dist/chunk-IGRPHTXZ.cjs +1 -0
  50. package/dist/chunk-K6LSGLG6.js +42 -0
  51. package/dist/chunk-KHY5FXO4.cjs +37 -0
  52. package/dist/chunk-L52GDMSH.js +0 -0
  53. package/dist/{chunk-A6E67ZZP.js → chunk-M47ZHA7Q.js} +14 -5
  54. package/dist/{chunk-6FG5QXII.cjs → chunk-M4HCASMG.cjs} +20 -11
  55. package/dist/chunk-M6IPPGXQ.cjs +29 -0
  56. package/dist/{chunk-R6DH4V7S.cjs → chunk-M7OPRXZH.cjs} +7 -7
  57. package/dist/{chunk-WDZY4PP4.cjs → chunk-MIKWTXUA.cjs} +6 -6
  58. package/dist/chunk-MNHK6EQK.cjs +57 -0
  59. package/dist/{chunk-66UY53KP.cjs → chunk-NO2KMGS2.cjs} +80 -37
  60. package/dist/chunk-OPKFMXPI.cjs +39 -0
  61. package/dist/{chunk-WWW6IGZ7.js → chunk-OXB6RTW7.js} +14 -4
  62. package/dist/{chunk-RYQI3RXL.cjs → chunk-P4XJHOLW.cjs} +18 -12
  63. package/dist/chunk-Q52MMQSC.js +57 -0
  64. package/dist/chunk-QM3BB4E2.js +0 -0
  65. package/dist/{chunk-ZAX22GSI.cjs → chunk-QQNDLR6E.cjs} +18 -18
  66. package/dist/chunk-RUQYXEEG.cjs +10 -0
  67. package/dist/chunk-S2L5Z2ZT.js +37 -0
  68. package/dist/{chunk-PUO4QNXH.js → chunk-T5NKL6F4.js} +2 -2
  69. package/dist/{chunk-WHTECI7J.cjs → chunk-U56Z2EOR.cjs} +6 -6
  70. package/dist/{chunk-W7K5E64Q.js → chunk-VLZ5ZS5U.js} +8 -2
  71. package/dist/{chunk-7TT3VUDF.cjs → chunk-VTF3WCXG.cjs} +6 -6
  72. package/dist/{chunk-FHMKNG62.js → chunk-VVPGO564.js} +24 -8
  73. package/dist/{chunk-2WBSPOWU.js → chunk-X4SPF4KJ.js} +4 -4
  74. package/dist/{chunk-ABMZ3ZVN.js → chunk-XEPUH4XH.js} +1 -1
  75. package/dist/index.cjs +26 -17
  76. package/dist/index.d.cts +1 -1
  77. package/dist/index.d.ts +1 -1
  78. package/dist/index.js +25 -16
  79. package/dist/logger/index.cjs +3 -3
  80. package/dist/logger/index.js +2 -2
  81. package/dist/logger/init.cjs +3 -3
  82. package/dist/logger/init.js +2 -2
  83. package/dist/sdk.cjs +23 -14
  84. package/dist/sdk.js +22 -13
  85. package/dist/signers/index.cjs +17 -8
  86. package/dist/signers/index.js +16 -7
  87. package/dist/signers/non-custodial/index.cjs +7 -7
  88. package/dist/signers/non-custodial/index.js +6 -6
  89. package/dist/signers/non-custodial/ncs-evm-signer.cjs +5 -5
  90. package/dist/signers/non-custodial/ncs-evm-signer.js +4 -4
  91. package/dist/signers/non-custodial/ncs-signer.cjs +4 -4
  92. package/dist/signers/non-custodial/ncs-signer.js +3 -3
  93. package/dist/signers/non-custodial/ncs-solana-signer.cjs +5 -5
  94. package/dist/signers/non-custodial/ncs-solana-signer.js +4 -4
  95. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +5 -5
  96. package/dist/signers/non-custodial/ncs-stellar-signer.js +4 -4
  97. package/dist/signers/server/assemble-server-signer.cjs +14 -0
  98. package/dist/signers/server/assemble-server-signer.d.cts +11 -0
  99. package/dist/signers/server/assemble-server-signer.d.ts +11 -0
  100. package/dist/signers/server/assemble-server-signer.js +14 -0
  101. package/dist/signers/server/evm-server-signer.cjs +7 -0
  102. package/dist/signers/server/evm-server-signer.d.cts +25 -0
  103. package/dist/signers/server/evm-server-signer.d.ts +25 -0
  104. package/dist/signers/server/evm-server-signer.js +7 -0
  105. package/dist/signers/server/helpers/derive-server-signer.cjs +11 -0
  106. package/dist/signers/server/helpers/derive-server-signer.d.cts +15 -0
  107. package/dist/signers/server/helpers/derive-server-signer.d.ts +15 -0
  108. package/dist/signers/server/helpers/derive-server-signer.js +11 -0
  109. package/dist/signers/server/helpers/get-chain-type.cjs +7 -0
  110. package/dist/signers/server/helpers/get-chain-type.d.cts +7 -0
  111. package/dist/signers/server/helpers/get-chain-type.d.ts +7 -0
  112. package/dist/signers/server/helpers/get-chain-type.js +7 -0
  113. package/dist/signers/server/helpers/index.cjs +15 -0
  114. package/dist/signers/server/helpers/index.d.cts +9 -0
  115. package/dist/signers/server/helpers/index.d.ts +9 -0
  116. package/dist/signers/server/helpers/index.js +15 -0
  117. package/dist/signers/server/index.cjs +29 -0
  118. package/dist/signers/server/index.d.cts +12 -0
  119. package/dist/signers/server/index.d.ts +12 -0
  120. package/dist/signers/server/index.js +29 -0
  121. package/dist/signers/server/solana-server-signer.cjs +7 -0
  122. package/dist/signers/server/solana-server-signer.d.cts +25 -0
  123. package/dist/signers/server/solana-server-signer.d.ts +25 -0
  124. package/dist/signers/server/solana-server-signer.js +7 -0
  125. package/dist/signers/server/stellar-server-signer.cjs +7 -0
  126. package/dist/signers/server/stellar-server-signer.d.cts +25 -0
  127. package/dist/signers/server/stellar-server-signer.d.ts +25 -0
  128. package/dist/signers/server/stellar-server-signer.js +7 -0
  129. package/dist/signers/types.d.cts +15 -3
  130. package/dist/signers/types.d.ts +15 -3
  131. package/dist/utils/constants.cjs +2 -2
  132. package/dist/utils/constants.js +1 -1
  133. package/dist/utils/server-key-derivation.cjs +9 -0
  134. package/dist/utils/server-key-derivation.d.cts +20 -0
  135. package/dist/utils/server-key-derivation.d.ts +20 -0
  136. package/dist/utils/server-key-derivation.js +9 -0
  137. package/dist/wallets/__tests__/test-helpers.cjs +19 -10
  138. package/dist/wallets/__tests__/test-helpers.js +18 -9
  139. package/dist/wallets/evm.cjs +20 -11
  140. package/dist/wallets/evm.js +19 -10
  141. package/dist/wallets/solana.cjs +20 -11
  142. package/dist/wallets/solana.js +19 -10
  143. package/dist/wallets/stellar.cjs +20 -11
  144. package/dist/wallets/stellar.js +19 -10
  145. package/dist/wallets/types.d.cts +7 -4
  146. package/dist/wallets/types.d.ts +7 -4
  147. package/dist/wallets/wallet-factory.cjs +21 -12
  148. package/dist/wallets/wallet-factory.js +20 -11
  149. package/dist/wallets/wallet.cjs +19 -10
  150. package/dist/wallets/wallet.d.cts +2 -2
  151. package/dist/wallets/wallet.d.ts +2 -2
  152. package/dist/wallets/wallet.js +18 -9
  153. package/package.json +3 -2
  154. package/dist/chunk-BMMZIPXT.js +0 -778
  155. package/dist/chunk-COR3CNRW.cjs +0 -778
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  Wallet
3
- } from "./chunk-FHMKNG62.js";
3
+ } from "./chunk-VVPGO564.js";
4
+ import {
5
+ deriveServerSignerDetails
6
+ } from "./chunk-S2L5Z2ZT.js";
4
7
  import {
5
8
  SolanaExternalWalletSigner
6
9
  } from "./chunk-PIFD6KNH.js";
@@ -9,7 +12,7 @@ import {
9
12
  } from "./chunk-SGINWAB6.js";
10
13
  import {
11
14
  walletsLogger
12
- } from "./chunk-ABMZ3ZVN.js";
15
+ } from "./chunk-XEPUH4XH.js";
13
16
  import {
14
17
  __async,
15
18
  __decorateClass
@@ -78,8 +81,15 @@ var _SolanaWallet = class _SolanaWallet extends Wallet {
78
81
  }
79
82
  createTransaction(params) {
80
83
  return __async(this, null, function* () {
81
- var _a, _b;
82
- const signer = (_b = (_a = params.options) == null ? void 0 : _a.experimental_signer) != null ? _b : this.signer.locator();
84
+ var _a;
85
+ let signer;
86
+ if (((_a = params.options) == null ? void 0 : _a.experimental_signer) == null) {
87
+ signer = this.signer.locator();
88
+ } else if (typeof params.options.experimental_signer === "string") {
89
+ signer = params.options.experimental_signer;
90
+ } else {
91
+ signer = `server:${deriveServerSignerDetails(params.options.experimental_signer, this.chain, this.apiClient.projectId, this.apiClient.environment).derivedAddress}`;
92
+ }
83
93
  let serializedTransaction;
84
94
  if ("serializedTransaction" in params) {
85
95
  serializedTransaction = params.serializedTransaction;
@@ -3,11 +3,11 @@
3
3
  var _chunkXC2V34TScjs = require('./chunk-XC2V34TS.cjs');
4
4
 
5
5
 
6
- var _chunkJREZWZ2Scjs = require('./chunk-JREZWZ2S.cjs');
6
+ var _chunk2M32LBCAcjs = require('./chunk-2M32LBCA.cjs');
7
7
 
8
8
 
9
9
 
10
- var _chunkR4AW5ADGcjs = require('./chunk-R4AW5ADG.cjs');
10
+ var _chunk3WZUNLYIcjs = require('./chunk-3WZUNLYI.cjs');
11
11
 
12
12
 
13
13
  var _chunkUO2J2ZB2cjs = require('./chunk-UO2J2ZB2.cjs');
@@ -22,7 +22,7 @@ var ApiClient = class extends _commonsdkbase.CrossmintApiClient {
22
22
  constructor(crossmint) {
23
23
  super(crossmint, {
24
24
  internalConfig: {
25
- sdkMetadata: { name: _chunkR4AW5ADGcjs.SDK_NAME, version: _chunkR4AW5ADGcjs.SDK_VERSION }
25
+ sdkMetadata: { name: _chunk3WZUNLYIcjs.SDK_NAME, version: _chunk3WZUNLYIcjs.SDK_VERSION }
26
26
  }
27
27
  });
28
28
  this.apiPrefix = "api/2025-06-09/wallets";
@@ -31,7 +31,7 @@ var ApiClient = class extends _commonsdkbase.CrossmintApiClient {
31
31
  createWallet(params) {
32
32
  return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
33
33
  const path = this.isServerSide ? `${this.apiPrefix}` : `${this.apiPrefix}/me`;
34
- _chunkJREZWZ2Scjs.walletsLogger.info("wallets.api.createWallet", {
34
+ _chunk2M32LBCAcjs.walletsLogger.info("wallets.api.createWallet", {
35
35
  chainType: params.chainType,
36
36
  walletType: params.type
37
37
  });
@@ -41,12 +41,12 @@ var ApiClient = class extends _commonsdkbase.CrossmintApiClient {
41
41
  });
42
42
  const result = yield response.json();
43
43
  if ("error" in result) {
44
- _chunkJREZWZ2Scjs.walletsLogger.error("wallets.api.createWallet.error", {
44
+ _chunk2M32LBCAcjs.walletsLogger.error("wallets.api.createWallet.error", {
45
45
  error: result.error,
46
46
  chainType: params.chainType
47
47
  });
48
48
  } else if ("address" in result) {
49
- _chunkJREZWZ2Scjs.walletsLogger.info("wallets.api.createWallet.success", {
49
+ _chunk2M32LBCAcjs.walletsLogger.info("wallets.api.createWallet.success", {
50
50
  address: result.address,
51
51
  chainType: params.chainType
52
52
  });
@@ -56,18 +56,18 @@ var ApiClient = class extends _commonsdkbase.CrossmintApiClient {
56
56
  }
57
57
  getWallet(locator) {
58
58
  return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
59
- _chunkJREZWZ2Scjs.walletsLogger.info("wallets.api.getWallet", { locator });
59
+ _chunk2M32LBCAcjs.walletsLogger.info("wallets.api.getWallet", { locator });
60
60
  const response = yield this.get(`${this.apiPrefix}/${locator}`, {
61
61
  headers: this.headers
62
62
  });
63
63
  const result = yield response.json();
64
64
  if ("error" in result) {
65
- _chunkJREZWZ2Scjs.walletsLogger.warn("wallets.api.getWallet.error", {
65
+ _chunk2M32LBCAcjs.walletsLogger.warn("wallets.api.getWallet.error", {
66
66
  locator,
67
67
  error: result.error
68
68
  });
69
69
  } else if ("address" in result) {
70
- _chunkJREZWZ2Scjs.walletsLogger.info("wallets.api.getWallet.success", result);
70
+ _chunk2M32LBCAcjs.walletsLogger.info("wallets.api.getWallet.success", result);
71
71
  }
72
72
  return result;
73
73
  });
@@ -200,7 +200,7 @@ var ApiClient = class extends _commonsdkbase.CrossmintApiClient {
200
200
  }
201
201
  send(walletLocator, tokenLocator, params) {
202
202
  return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
203
- _chunkJREZWZ2Scjs.walletsLogger.info("wallets.api.send", {
203
+ _chunk2M32LBCAcjs.walletsLogger.info("wallets.api.send", {
204
204
  walletLocator,
205
205
  tokenLocator,
206
206
  recipient: params.recipient
@@ -211,13 +211,13 @@ var ApiClient = class extends _commonsdkbase.CrossmintApiClient {
211
211
  });
212
212
  const result = yield response.json();
213
213
  if ("error" in result) {
214
- _chunkJREZWZ2Scjs.walletsLogger.error("wallets.api.send.error", {
214
+ _chunk2M32LBCAcjs.walletsLogger.error("wallets.api.send.error", {
215
215
  walletLocator,
216
216
  tokenLocator,
217
217
  error: result.error
218
218
  });
219
219
  } else if ("id" in result) {
220
- _chunkJREZWZ2Scjs.walletsLogger.info("wallets.api.send.success", {
220
+ _chunk2M32LBCAcjs.walletsLogger.info("wallets.api.send.success", {
221
221
  walletLocator,
222
222
  transactionId: result.id
223
223
  });
@@ -234,6 +234,12 @@ var ApiClient = class extends _commonsdkbase.CrossmintApiClient {
234
234
  }
235
235
  return this.parsedAPIKey.environment;
236
236
  }
237
+ get projectId() {
238
+ if (!this.parsedAPIKey.isValid) {
239
+ throw new (0, _chunkXC2V34TScjs.InvalidApiKeyError)("Invalid API key");
240
+ }
241
+ return this.parsedAPIKey.projectId;
242
+ }
237
243
  get headers() {
238
244
  const headers = {
239
245
  "Content-Type": "application/json"
@@ -0,0 +1,57 @@
1
+ // src/utils/server-key-derivation.ts
2
+ import { hkdf } from "@noble/hashes/hkdf";
3
+ import { sha256 } from "@noble/hashes/sha2";
4
+ import { bytesToHex } from "@noble/hashes/utils";
5
+ var HKDF_SALT = "crossmint";
6
+ var SECRET_PREFIX = "xmsk1_";
7
+ function deriveKeyBytes(secret, projectId, environment, chain) {
8
+ const rawSecret = stripAndValidateSecret(secret);
9
+ const ikm = hexToBytes(rawSecret);
10
+ const algorithm = getAlgorithmForChain(chain);
11
+ const info = `${projectId}:${environment}:${chain}-${algorithm}`;
12
+ return hkdf(sha256, ikm, HKDF_SALT, info, 32);
13
+ }
14
+ function deriveAlias(secret, projectId, environment, chain) {
15
+ const rawSecret = stripAndValidateSecret(secret);
16
+ const ikm = hexToBytes(rawSecret);
17
+ const info = `${projectId}:${environment}:${chain}-alias`;
18
+ const derived = hkdf(sha256, ikm, HKDF_SALT, info, 17);
19
+ return `s-${bytesToHex(derived).slice(0, 34)}`;
20
+ }
21
+ var EXPECTED_SECRET_LENGTH = 64;
22
+ function stripAndValidateSecret(secret) {
23
+ const rawSecret = secret.startsWith(SECRET_PREFIX) ? secret.slice(SECRET_PREFIX.length) : secret;
24
+ if (rawSecret.length !== EXPECTED_SECRET_LENGTH) {
25
+ throw new Error(
26
+ `Invalid server signer secret: expected ${EXPECTED_SECRET_LENGTH}-char hex string (256-bit), got ${rawSecret.length} chars`
27
+ );
28
+ }
29
+ return rawSecret;
30
+ }
31
+ function getAlgorithmForChain(chain) {
32
+ if (chain === "solana") {
33
+ return "ed25519";
34
+ }
35
+ if (chain === "stellar") {
36
+ return "ed25519";
37
+ }
38
+ return "secp256k1";
39
+ }
40
+ function hexToBytes(hex) {
41
+ if (hex.length % 2 !== 0) {
42
+ throw new Error(`Invalid hex string: odd length (${hex.length})`);
43
+ }
44
+ if (!/^[0-9a-fA-F]+$/.test(hex)) {
45
+ throw new Error("Invalid hex string: contains non-hex characters");
46
+ }
47
+ const bytes = new Uint8Array(hex.length / 2);
48
+ for (let i = 0; i < hex.length; i += 2) {
49
+ bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
50
+ }
51
+ return bytes;
52
+ }
53
+
54
+ export {
55
+ deriveKeyBytes,
56
+ deriveAlias
57
+ };
File without changes
@@ -6,7 +6,7 @@ var _chunk4GFSUI2Icjs = require('./chunk-4GFSUI2I.cjs');
6
6
  var _chunkRHR6P2KPcjs = require('./chunk-RHR6P2KP.cjs');
7
7
 
8
8
 
9
- var _chunkJREZWZ2Scjs = require('./chunk-JREZWZ2S.cjs');
9
+ var _chunk2M32LBCAcjs = require('./chunk-2M32LBCA.cjs');
10
10
 
11
11
 
12
12
 
@@ -64,7 +64,7 @@ var NonCustodialSigner = class {
64
64
  }
65
65
  initializeTEEConnection() {
66
66
  return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
67
- _chunkJREZWZ2Scjs.walletsLogger.info("TEE connection not initialized, initializing now");
67
+ _chunk2M32LBCAcjs.walletsLogger.info("TEE connection not initialized, initializing now");
68
68
  const parsedAPIKey = _commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);
69
69
  if (!parsedAPIKey.isValid) {
70
70
  throw new Error("Invalid API key");
@@ -76,7 +76,7 @@ var NonCustodialSigner = class {
76
76
  if (this.config.clientTEEConnection == null) {
77
77
  throw new Error("Failed to initialize TEE connection");
78
78
  }
79
- _chunkJREZWZ2Scjs.walletsLogger.info("TEE connection initialized successfully");
79
+ _chunk2M32LBCAcjs.walletsLogger.info("TEE connection initialized successfully");
80
80
  });
81
81
  }
82
82
  handleAuthRequired() {
@@ -88,7 +88,7 @@ var NonCustodialSigner = class {
88
88
  `${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendEmailWithOtp, verifyOtp, reject) => { /* your UI logic */ }`
89
89
  );
90
90
  }
91
- _chunkJREZWZ2Scjs.walletsLogger.info("get-status: sending request");
91
+ _chunk2M32LBCAcjs.walletsLogger.info("get-status: sending request");
92
92
  const startTime = Date.now();
93
93
  const signerResponse = yield clientTEEConnection.sendAction({
94
94
  event: "request:get-status",
@@ -103,14 +103,14 @@ var NonCustodialSigner = class {
103
103
  });
104
104
  const durationMs = Date.now() - startTime;
105
105
  if ((signerResponse == null ? void 0 : signerResponse.status) !== "success") {
106
- _chunkJREZWZ2Scjs.walletsLogger.error("get-status: failed", {
106
+ _chunk2M32LBCAcjs.walletsLogger.error("get-status: failed", {
107
107
  status: signerResponse == null ? void 0 : signerResponse.status,
108
108
  error: signerResponse == null ? void 0 : signerResponse.error,
109
109
  durationMs
110
110
  });
111
111
  throw new Error(signerResponse == null ? void 0 : signerResponse.error);
112
112
  }
113
- _chunkJREZWZ2Scjs.walletsLogger.info("get-status: response received", {
113
+ _chunk2M32LBCAcjs.walletsLogger.info("get-status: response received", {
114
114
  signerStatus: signerResponse.signerStatus,
115
115
  durationMs
116
116
  });
@@ -120,7 +120,7 @@ var NonCustodialSigner = class {
120
120
  } else {
121
121
  this._needsAuth = true;
122
122
  }
123
- _chunkJREZWZ2Scjs.walletsLogger.info("Auth required, initiating OTP flow", { needsAuth: this._needsAuth });
123
+ _chunk2M32LBCAcjs.walletsLogger.info("Auth required, initiating OTP flow", { needsAuth: this._needsAuth });
124
124
  const { promise, resolve, reject } = this.createAuthPromise();
125
125
  this._authPromise = { promise, resolve, reject };
126
126
  if (this.config.onAuthRequired) {
@@ -130,7 +130,7 @@ var NonCustodialSigner = class {
130
130
  () => this.sendMessageWithOtp(),
131
131
  (otp) => this.verifyOtp(otp),
132
132
  () => _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
133
- _chunkJREZWZ2Scjs.walletsLogger.info("Auth rejected", { authRejected: true });
133
+ _chunk2M32LBCAcjs.walletsLogger.info("Auth rejected", { authRejected: true });
134
134
  this._needsAuth = false;
135
135
  if (this.config.onAuthRequired != null) {
136
136
  yield this.config.onAuthRequired(
@@ -147,14 +147,14 @@ var NonCustodialSigner = class {
147
147
  })
148
148
  );
149
149
  } catch (error) {
150
- _chunkJREZWZ2Scjs.walletsLogger.error("handleAuthRequired error", { error });
150
+ _chunk2M32LBCAcjs.walletsLogger.error("handleAuthRequired error", { error });
151
151
  reject(error);
152
152
  }
153
153
  }
154
154
  try {
155
155
  yield promise;
156
156
  } catch (error) {
157
- _chunkJREZWZ2Scjs.walletsLogger.error("handleAuthRequired promise error", { error });
157
+ _chunk2M32LBCAcjs.walletsLogger.error("handleAuthRequired promise error", { error });
158
158
  throw error;
159
159
  }
160
160
  });
@@ -186,7 +186,7 @@ var NonCustodialSigner = class {
186
186
  var _a, _b, _c;
187
187
  const handshakeParent = yield this.getTEEConnection();
188
188
  const authId = this.getAuthId();
189
- _chunkJREZWZ2Scjs.walletsLogger.info("start-onboarding: sending request");
189
+ _chunk2M32LBCAcjs.walletsLogger.info("start-onboarding: sending request");
190
190
  const startTime = Date.now();
191
191
  const response = yield handshakeParent.sendAction({
192
192
  event: "request:start-onboarding",
@@ -201,7 +201,7 @@ var NonCustodialSigner = class {
201
201
  options: DEFAULT_EVENT_OPTIONS
202
202
  });
203
203
  const durationMs = Date.now() - startTime;
204
- _chunkJREZWZ2Scjs.walletsLogger.info("start-onboarding: response received", {
204
+ _chunk2M32LBCAcjs.walletsLogger.info("start-onboarding: response received", {
205
205
  status: response == null ? void 0 : response.status,
206
206
  durationMs
207
207
  });
@@ -210,7 +210,7 @@ var NonCustodialSigner = class {
210
210
  return;
211
211
  }
212
212
  if ((response == null ? void 0 : response.status) === "error") {
213
- _chunkJREZWZ2Scjs.walletsLogger.error("start-onboarding: failed", { error: response.error });
213
+ _chunk2M32LBCAcjs.walletsLogger.error("start-onboarding: failed", { error: response.error });
214
214
  (_c = this._authPromise) == null ? void 0 : _c.reject(new Error(response.error || "Failed to initiate OTP process."));
215
215
  }
216
216
  });
@@ -227,7 +227,7 @@ var NonCustodialSigner = class {
227
227
  let response;
228
228
  try {
229
229
  const handshakeParent = yield this.getTEEConnection();
230
- _chunkJREZWZ2Scjs.walletsLogger.info("complete-onboarding: sending request");
230
+ _chunk2M32LBCAcjs.walletsLogger.info("complete-onboarding: sending request");
231
231
  const startTime = Date.now();
232
232
  response = yield handshakeParent.sendAction({
233
233
  event: "request:complete-onboarding",
@@ -243,12 +243,12 @@ var NonCustodialSigner = class {
243
243
  },
244
244
  options: DEFAULT_EVENT_OPTIONS
245
245
  });
246
- _chunkJREZWZ2Scjs.walletsLogger.info("complete-onboarding: response received", {
246
+ _chunk2M32LBCAcjs.walletsLogger.info("complete-onboarding: response received", {
247
247
  status: response == null ? void 0 : response.status,
248
248
  durationMs: Date.now() - startTime
249
249
  });
250
250
  } catch (err) {
251
- _chunkJREZWZ2Scjs.walletsLogger.error("complete-onboarding: error", { error: err });
251
+ _chunk2M32LBCAcjs.walletsLogger.error("complete-onboarding: error", { error: err });
252
252
  this._needsAuth = true;
253
253
  (_c = this._authPromise) == null ? void 0 : _c.reject(err);
254
254
  throw err;
@@ -269,7 +269,7 @@ var NonCustodialSigner = class {
269
269
  (_d = this._authPromise) == null ? void 0 : _d.resolve();
270
270
  return;
271
271
  }
272
- _chunkJREZWZ2Scjs.walletsLogger.error("complete-onboarding: OTP validation failed", { status: response == null ? void 0 : response.status });
272
+ _chunk2M32LBCAcjs.walletsLogger.error("complete-onboarding: OTP validation failed", { status: response == null ? void 0 : response.status });
273
273
  this._needsAuth = true;
274
274
  const errorMessage = (response == null ? void 0 : response.status) === "error" ? response.error : "Failed to validate encrypted OTP";
275
275
  const error = new Error(errorMessage);
@@ -309,7 +309,7 @@ var NonCustodialSigner = class {
309
309
  };
310
310
  _chunkUO2J2ZB2cjs.__decorateClass.call(void 0, [
311
311
  _commonsdkbase.WithLoggerContext.call(void 0, {
312
- logger: _chunkJREZWZ2Scjs.walletsLogger,
312
+ logger: _chunk2M32LBCAcjs.walletsLogger,
313
313
  methodName: "handleAuthRequired"
314
314
  })
315
315
  ], NonCustodialSigner.prototype, "handleAuthRequired", 1);
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/signers/server/helpers/get-chain-type.ts
2
+ function getChainType(chain) {
3
+ if (chain === "solana") return "solana";
4
+ if (chain === "stellar") return "stellar";
5
+ return "evm";
6
+ }
7
+
8
+
9
+
10
+ exports.getChainType = getChainType;
@@ -0,0 +1,37 @@
1
+ import {
2
+ getChainType
3
+ } from "./chunk-H6WV5NRT.js";
4
+ import {
5
+ deriveKeyBytes
6
+ } from "./chunk-Q52MMQSC.js";
7
+
8
+ // src/signers/server/helpers/derive-server-signer.ts
9
+ import { privateKeyToAccount } from "viem/accounts";
10
+ import { bytesToHex } from "@noble/hashes/utils";
11
+ import { Keypair as SolanaKeypair } from "@solana/web3.js";
12
+ import { Keypair as StellarKeypair } from "@stellar/stellar-sdk";
13
+ function deriveServerSignerAddress(keyBytes, chain) {
14
+ const chainType = getChainType(chain);
15
+ switch (chainType) {
16
+ case "evm":
17
+ return privateKeyToAccount(`0x${bytesToHex(keyBytes)}`).address;
18
+ case "solana":
19
+ return SolanaKeypair.fromSeed(keyBytes).publicKey.toBase58();
20
+ case "stellar":
21
+ return StellarKeypair.fromRawEd25519Seed(Buffer.from(keyBytes)).publicKey();
22
+ }
23
+ }
24
+ function deriveServerSignerDetails(signer, chain, projectId, environment) {
25
+ if (typeof window !== "undefined") {
26
+ throw new Error("Server signers can only be used from server-side code.");
27
+ }
28
+ const chainStr = typeof chain === "string" ? chain : String(chain);
29
+ const derivedKeyBytes = deriveKeyBytes(signer.secret, projectId, environment, chainStr);
30
+ const derivedAddress = deriveServerSignerAddress(derivedKeyBytes, chain);
31
+ return { derivedKeyBytes, derivedAddress };
32
+ }
33
+
34
+ export {
35
+ deriveServerSignerAddress,
36
+ deriveServerSignerDetails
37
+ };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  DEFAULT_EVENT_OPTIONS,
3
3
  NonCustodialSigner
4
- } from "./chunk-U3NV7UY7.js";
4
+ } from "./chunk-FZQG6OX2.js";
5
5
  import {
6
6
  walletsLogger
7
- } from "./chunk-ABMZ3ZVN.js";
7
+ } from "./chunk-XEPUH4XH.js";
8
8
  import {
9
9
  __async
10
10
  } from "./chunk-ASE2FXWP.js";
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkZAX22GSIcjs = require('./chunk-ZAX22GSI.cjs');
4
+ var _chunkQQNDLR6Ecjs = require('./chunk-QQNDLR6E.cjs');
5
5
 
6
6
 
7
- var _chunkJREZWZ2Scjs = require('./chunk-JREZWZ2S.cjs');
7
+ var _chunk2M32LBCAcjs = require('./chunk-2M32LBCA.cjs');
8
8
 
9
9
 
10
10
  var _chunkUO2J2ZB2cjs = require('./chunk-UO2J2ZB2.cjs');
@@ -12,7 +12,7 @@ var _chunkUO2J2ZB2cjs = require('./chunk-UO2J2ZB2.cjs');
12
12
  // src/signers/non-custodial/ncs-evm-signer.ts
13
13
  var _ox = require('ox');
14
14
  var _viem = require('viem');
15
- var EVMNonCustodialSigner = class _EVMNonCustodialSigner extends _chunkZAX22GSIcjs.NonCustodialSigner {
15
+ var EVMNonCustodialSigner = class _EVMNonCustodialSigner extends _chunkQQNDLR6Ecjs.NonCustodialSigner {
16
16
  constructor(config) {
17
17
  super(config);
18
18
  }
@@ -34,7 +34,7 @@ var EVMNonCustodialSigner = class _EVMNonCustodialSigner extends _chunkZAX22GSIc
34
34
  yield this.handleAuthRequired();
35
35
  const jwt = this.getJwtOrThrow();
36
36
  const hexString = raw.replace("0x", "");
37
- _chunkJREZWZ2Scjs.walletsLogger.info("sign: sending request", { keyType: "secp256k1" });
37
+ _chunk2M32LBCAcjs.walletsLogger.info("sign: sending request", { keyType: "secp256k1" });
38
38
  const startTime = Date.now();
39
39
  const res = yield (_a = this.config.clientTEEConnection) == null ? void 0 : _a.sendAction({
40
40
  event: "request:sign",
@@ -50,9 +50,9 @@ var EVMNonCustodialSigner = class _EVMNonCustodialSigner extends _chunkZAX22GSIc
50
50
  encoding: "hex"
51
51
  }
52
52
  },
53
- options: _chunkZAX22GSIcjs.DEFAULT_EVENT_OPTIONS
53
+ options: _chunkQQNDLR6Ecjs.DEFAULT_EVENT_OPTIONS
54
54
  });
55
- _chunkJREZWZ2Scjs.walletsLogger.info("sign: response received", {
55
+ _chunk2M32LBCAcjs.walletsLogger.info("sign: response received", {
56
56
  status: res == null ? void 0 : res.status,
57
57
  durationMs: Date.now() - startTime
58
58
  });
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-SGINWAB6.js";
4
4
  import {
5
5
  walletsLogger
6
- } from "./chunk-ABMZ3ZVN.js";
6
+ } from "./chunk-XEPUH4XH.js";
7
7
  import {
8
8
  SDK_NAME,
9
9
  SDK_VERSION
10
- } from "./chunk-TYQ4YIP7.js";
10
+ } from "./chunk-GLUD6EBN.js";
11
11
  import {
12
12
  __async
13
13
  } from "./chunk-ASE2FXWP.js";
@@ -234,6 +234,12 @@ var ApiClient = class extends CrossmintApiClient {
234
234
  }
235
235
  return this.parsedAPIKey.environment;
236
236
  }
237
+ get projectId() {
238
+ if (!this.parsedAPIKey.isValid) {
239
+ throw new InvalidApiKeyError("Invalid API key");
240
+ }
241
+ return this.parsedAPIKey.projectId;
242
+ }
237
243
  get headers() {
238
244
  const headers = {
239
245
  "Content-Type": "application/json"
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
3
 
4
- var _chunkZAX22GSIcjs = require('./chunk-ZAX22GSI.cjs');
4
+ var _chunkQQNDLR6Ecjs = require('./chunk-QQNDLR6E.cjs');
5
5
 
6
6
 
7
- var _chunkJREZWZ2Scjs = require('./chunk-JREZWZ2S.cjs');
7
+ var _chunk2M32LBCAcjs = require('./chunk-2M32LBCA.cjs');
8
8
 
9
9
 
10
10
  var _chunkUO2J2ZB2cjs = require('./chunk-UO2J2ZB2.cjs');
@@ -12,7 +12,7 @@ var _chunkUO2J2ZB2cjs = require('./chunk-UO2J2ZB2.cjs');
12
12
  // src/signers/non-custodial/ncs-solana-signer.ts
13
13
  var _web3js = require('@solana/web3.js');
14
14
  var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);
15
- var SolanaNonCustodialSigner = class _SolanaNonCustodialSigner extends _chunkZAX22GSIcjs.NonCustodialSigner {
15
+ var SolanaNonCustodialSigner = class _SolanaNonCustodialSigner extends _chunkQQNDLR6Ecjs.NonCustodialSigner {
16
16
  constructor(config) {
17
17
  super(config);
18
18
  }
@@ -29,7 +29,7 @@ var SolanaNonCustodialSigner = class _SolanaNonCustodialSigner extends _chunkZAX
29
29
  const transactionBytes = _bs582.default.decode(transaction);
30
30
  const deserializedTransaction = _web3js.VersionedTransaction.deserialize(transactionBytes);
31
31
  const messageData = deserializedTransaction.message.serialize();
32
- _chunkJREZWZ2Scjs.walletsLogger.info("sign: sending request", { keyType: "ed25519" });
32
+ _chunk2M32LBCAcjs.walletsLogger.info("sign: sending request", { keyType: "ed25519" });
33
33
  const startTime = Date.now();
34
34
  const res = yield (_a = this.config.clientTEEConnection) == null ? void 0 : _a.sendAction({
35
35
  event: "request:sign",
@@ -45,9 +45,9 @@ var SolanaNonCustodialSigner = class _SolanaNonCustodialSigner extends _chunkZAX
45
45
  encoding: "base58"
46
46
  }
47
47
  },
48
- options: _chunkZAX22GSIcjs.DEFAULT_EVENT_OPTIONS
48
+ options: _chunkQQNDLR6Ecjs.DEFAULT_EVENT_OPTIONS
49
49
  });
50
- _chunkJREZWZ2Scjs.walletsLogger.info("sign: response received", {
50
+ _chunk2M32LBCAcjs.walletsLogger.info("sign: response received", {
51
51
  status: res == null ? void 0 : res.status,
52
52
  durationMs: Date.now() - startTime
53
53
  });
@@ -1,9 +1,12 @@
1
+ import {
2
+ deriveServerSignerDetails
3
+ } from "./chunk-S2L5Z2ZT.js";
1
4
  import {
2
5
  NonCustodialSigner
3
- } from "./chunk-U3NV7UY7.js";
6
+ } from "./chunk-FZQG6OX2.js";
4
7
  import {
5
8
  validateChainForEnvironment
6
- } from "./chunk-2WBSPOWU.js";
9
+ } from "./chunk-X4SPF4KJ.js";
7
10
  import {
8
11
  InvalidSignerError,
9
12
  SignatureFailedError,
@@ -21,10 +24,10 @@ import {
21
24
  } from "./chunk-SGINWAB6.js";
22
25
  import {
23
26
  walletsLogger
24
- } from "./chunk-ABMZ3ZVN.js";
27
+ } from "./chunk-XEPUH4XH.js";
25
28
  import {
26
29
  STATUS_POLLING_INTERVAL_MS
27
- } from "./chunk-TYQ4YIP7.js";
30
+ } from "./chunk-GLUD6EBN.js";
28
31
  import {
29
32
  __async,
30
33
  __decorateClass,
@@ -250,10 +253,18 @@ var Wallet = class {
250
253
  amount
251
254
  }, (options == null ? void 0 : options.transactionType) != null ? { transactionType: options.transactionType } : {}));
252
255
  yield this.preAuthIfNeeded();
256
+ let signer;
257
+ if ((options == null ? void 0 : options.experimental_signer) != null) {
258
+ if (typeof options.experimental_signer === "string") {
259
+ signer = options.experimental_signer;
260
+ } else {
261
+ signer = `server:${deriveServerSignerDetails(options.experimental_signer, this.chain, __privateGet(this, _apiClient).projectId, __privateGet(this, _apiClient).environment).derivedAddress}`;
262
+ }
263
+ }
253
264
  const sendParams = __spreadValues(__spreadValues({
254
265
  recipient,
255
266
  amount
256
- }, (options == null ? void 0 : options.experimental_signer) != null ? { signer: options.experimental_signer } : {}), (options == null ? void 0 : options.transactionType) != null ? { transactionType: options.transactionType } : {});
267
+ }, signer != null ? { signer } : {}), (options == null ? void 0 : options.transactionType) != null ? { transactionType: options.transactionType } : {});
257
268
  const transactionCreationResponse = yield __privateGet(this, _apiClient).send(this.walletLocator, tokenLocator, sendParams);
258
269
  if ("message" in transactionCreationResponse) {
259
270
  walletsLogger.error("wallet.send.error", {
@@ -333,8 +344,9 @@ var Wallet = class {
333
344
  return __async(this, null, function* () {
334
345
  var _a, _b, _c;
335
346
  walletsLogger.info("wallet.addDelegatedSigner.start");
347
+ const resolvedSigner = typeof params.signer === "object" && params.signer.type === "server" ? `server:${deriveServerSignerDetails(params.signer, this.chain, __privateGet(this, _apiClient).projectId, __privateGet(this, _apiClient).environment).derivedAddress}` : params.signer;
336
348
  const response = yield __privateGet(this, _apiClient).registerSigner(this.walletLocator, {
337
- signer: params.signer,
349
+ signer: resolvedSigner,
338
350
  chain: this.chain === "solana" || this.chain === "stellar" ? void 0 : this.chain
339
351
  });
340
352
  if ("error" in response) {
@@ -508,7 +520,9 @@ var Wallet = class {
508
520
  pendingApprovals.map((pendingApproval) => __async(this, null, function* () {
509
521
  const signer = signers.find((s) => s.locator() === pendingApproval.signer.locator);
510
522
  if (signer == null) {
511
- throw new InvalidSignerError(`Signer ${pendingApproval.signer} not found in pending approvals`);
523
+ throw new InvalidSignerError(
524
+ `Signer ${pendingApproval.signer.locator} not found in pending approvals`
525
+ );
512
526
  }
513
527
  const signature2 = yield signer.signMessage(pendingApproval.message);
514
528
  return __spreadProps(__spreadValues({}, signature2), {
@@ -543,7 +557,9 @@ var Wallet = class {
543
557
  pendingApprovals.map((pendingApproval) => __async(this, null, function* () {
544
558
  const signer = signers.find((s) => s.locator() === pendingApproval.signer.locator);
545
559
  if (signer == null) {
546
- throw new InvalidSignerError(`Signer ${pendingApproval.signer} not found in pending approvals`);
560
+ throw new InvalidSignerError(
561
+ `Signer ${pendingApproval.signer.locator} not found in pending approvals`
562
+ );
547
563
  }
548
564
  const transactionToSign = transaction.chainType === "solana" && "transaction" in transaction.onChain ? transaction.onChain.transaction : pendingApproval.message;
549
565
  const signature = yield signer.signTransaction(transactionToSign);
@@ -1,3 +1,6 @@
1
+ import {
2
+ arcTestnet
3
+ } from "./chunk-ZBLW42YE.js";
1
4
  import {
2
5
  story
3
6
  } from "./chunk-2T5HHKUI.js";
@@ -10,15 +13,12 @@ import {
10
13
  import {
11
14
  tempoTestnet
12
15
  } from "./chunk-JWMQALLN.js";
13
- import {
14
- arcTestnet
15
- } from "./chunk-ZBLW42YE.js";
16
16
  import {
17
17
  InvalidEnvironmentError
18
18
  } from "./chunk-SGINWAB6.js";
19
19
  import {
20
20
  walletsLogger
21
- } from "./chunk-ABMZ3ZVN.js";
21
+ } from "./chunk-XEPUH4XH.js";
22
22
 
23
23
  // src/chains/chains.ts
24
24
  import { APIKeyEnvironmentPrefix, BlockchainIncludingTestnet as Blockchain } from "@crossmint/common-sdk-base";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SDK_NAME,
3
3
  SDK_VERSION
4
- } from "./chunk-TYQ4YIP7.js";
4
+ } from "./chunk-GLUD6EBN.js";
5
5
 
6
6
  // src/logger/init.ts
7
7
  import {