@crossmint/wallets-sdk 0.20.2 → 0.21.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 (161) 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 +4 -4
  24. package/dist/chains/chains.js +3 -3
  25. package/dist/{chunk-6FG5QXII.cjs → chunk-2YGFMFQH.cjs} +20 -11
  26. package/dist/{chunk-47R3UV3J.cjs → chunk-357M7AYZ.cjs} +11 -6
  27. package/dist/chunk-4MEGQR3I.js +40 -0
  28. package/dist/chunk-5IC7UWND.cjs +1 -0
  29. package/dist/{chunk-ZAX22GSI.cjs → chunk-5NWGYER3.cjs} +18 -18
  30. package/dist/{chunk-RYQI3RXL.cjs → chunk-67C2QSRT.cjs} +18 -12
  31. package/dist/{chunk-CMBFV325.js → chunk-772Z6PBD.js} +3 -3
  32. package/dist/{chunk-JREZWZ2S.cjs → chunk-BJQHHI7K.cjs} +3 -3
  33. package/dist/chunk-BR4UVMIC.js +332 -0
  34. package/dist/chunk-BUBSPQ7U.cjs +332 -0
  35. package/dist/{chunk-FHMKNG62.js → chunk-CUE4X7Y4.js} +24 -8
  36. package/dist/chunk-DDNG224J.cjs +45 -0
  37. package/dist/{chunk-FICVKSXZ.js → chunk-FBUGIHIP.js} +2 -2
  38. package/dist/{chunk-HXJ3YPAN.js → chunk-GIHJEXL7.js} +13 -4
  39. package/dist/chunk-GJT2JD3E.js +45 -0
  40. package/dist/chunk-H6WV5NRT.js +10 -0
  41. package/dist/chunk-HWTWDQYT.cjs +42 -0
  42. package/dist/{chunk-66UY53KP.cjs → chunk-I3KIMQEV.cjs} +80 -37
  43. package/dist/chunk-IGRPHTXZ.cjs +1 -0
  44. package/dist/{chunk-IDKGJO2G.cjs → chunk-IL6J7SYU.cjs} +21 -11
  45. package/dist/chunk-IXDC5JR2.js +316 -0
  46. package/dist/{chunk-7TT3VUDF.cjs → chunk-IZQHJM2P.cjs} +6 -6
  47. package/dist/chunk-J65ILI3Y.cjs +44 -0
  48. package/dist/chunk-JD77GNRZ.cjs +40 -0
  49. package/dist/{chunk-PUO4QNXH.js → chunk-JO7QKDU4.js} +2 -2
  50. package/dist/{chunk-KQH5ZXJ4.js → chunk-JP6227LZ.js} +61 -18
  51. package/dist/{chunk-POG76HDD.cjs → chunk-JUS5BKF2.cjs} +64 -48
  52. package/dist/chunk-K6LSGLG6.js +42 -0
  53. package/dist/chunk-KEDMRERX.cjs +29 -0
  54. package/dist/{chunk-W7K5E64Q.js → chunk-KSN7G2DH.js} +8 -2
  55. package/dist/chunk-L52GDMSH.js +0 -0
  56. package/dist/{chunk-U3NV7UY7.js → chunk-LDVEJ2XZ.js} +1 -1
  57. package/dist/{chunk-PM7BGATN.cjs → chunk-LIUDLEBE.cjs} +34 -25
  58. package/dist/{chunk-6UMJYMAY.js → chunk-LQWOPRRW.js} +2 -2
  59. package/dist/chunk-M6E6A543.cjs +316 -0
  60. package/dist/chunk-MNHK6EQK.cjs +57 -0
  61. package/dist/{chunk-2WBSPOWU.js → chunk-NBBOYFQW.js} +1 -1
  62. package/dist/{chunk-A6E67ZZP.js → chunk-OBKOVQQJ.js} +14 -5
  63. package/dist/{chunk-TYQ4YIP7.js → chunk-PC3YMFJM.js} +1 -1
  64. package/dist/chunk-Q52MMQSC.js +57 -0
  65. package/dist/chunk-QM3BB4E2.js +0 -0
  66. package/dist/{chunk-R6DH4V7S.cjs → chunk-QMSFEJPD.cjs} +7 -7
  67. package/dist/{chunk-T2XUADHW.js → chunk-QPVKMB34.js} +10 -5
  68. package/dist/chunk-RUQYXEEG.cjs +10 -0
  69. package/dist/{chunk-WHTECI7J.cjs → chunk-RZYHYTWY.cjs} +6 -6
  70. package/dist/{chunk-ABMZ3ZVN.js → chunk-SIP7NNGL.js} +1 -1
  71. package/dist/{chunk-WDZY4PP4.cjs → chunk-UBWFRFQ6.cjs} +3 -3
  72. package/dist/{chunk-R4AW5ADG.cjs → chunk-WATHSVAQ.cjs} +1 -1
  73. package/dist/chunk-WQZLYIIG.js +44 -0
  74. package/dist/chunk-WXIYTJDM.js +29 -0
  75. package/dist/{chunk-WWW6IGZ7.js → chunk-Y2DLCE7H.js} +14 -4
  76. package/dist/{chunk-MRZXYVQO.cjs → chunk-ZXQHWKZN.cjs} +6 -6
  77. package/dist/index.cjs +26 -16
  78. package/dist/index.d.cts +1 -1
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.js +25 -15
  81. package/dist/logger/index.cjs +3 -3
  82. package/dist/logger/index.js +2 -2
  83. package/dist/logger/init.cjs +3 -3
  84. package/dist/logger/init.js +2 -2
  85. package/dist/sdk.cjs +23 -13
  86. package/dist/sdk.js +22 -12
  87. package/dist/signers/index.cjs +18 -8
  88. package/dist/signers/index.js +17 -7
  89. package/dist/signers/non-custodial/index.cjs +7 -7
  90. package/dist/signers/non-custodial/index.js +8 -8
  91. package/dist/signers/non-custodial/ncs-evm-signer.cjs +5 -5
  92. package/dist/signers/non-custodial/ncs-evm-signer.js +4 -4
  93. package/dist/signers/non-custodial/ncs-signer.cjs +4 -4
  94. package/dist/signers/non-custodial/ncs-signer.js +3 -3
  95. package/dist/signers/non-custodial/ncs-solana-signer.cjs +5 -5
  96. package/dist/signers/non-custodial/ncs-solana-signer.js +4 -4
  97. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +5 -5
  98. package/dist/signers/non-custodial/ncs-stellar-signer.js +4 -4
  99. package/dist/signers/server/assemble-server-signer.cjs +15 -0
  100. package/dist/signers/server/assemble-server-signer.d.cts +11 -0
  101. package/dist/signers/server/assemble-server-signer.d.ts +11 -0
  102. package/dist/signers/server/assemble-server-signer.js +15 -0
  103. package/dist/signers/server/evm-server-signer.cjs +7 -0
  104. package/dist/signers/server/evm-server-signer.d.cts +25 -0
  105. package/dist/signers/server/evm-server-signer.d.ts +25 -0
  106. package/dist/signers/server/evm-server-signer.js +7 -0
  107. package/dist/signers/server/helpers/derive-server-signer.cjs +12 -0
  108. package/dist/signers/server/helpers/derive-server-signer.d.cts +15 -0
  109. package/dist/signers/server/helpers/derive-server-signer.d.ts +15 -0
  110. package/dist/signers/server/helpers/derive-server-signer.js +12 -0
  111. package/dist/signers/server/helpers/get-chain-type.cjs +7 -0
  112. package/dist/signers/server/helpers/get-chain-type.d.cts +7 -0
  113. package/dist/signers/server/helpers/get-chain-type.d.ts +7 -0
  114. package/dist/signers/server/helpers/get-chain-type.js +7 -0
  115. package/dist/signers/server/helpers/index.cjs +16 -0
  116. package/dist/signers/server/helpers/index.d.cts +9 -0
  117. package/dist/signers/server/helpers/index.d.ts +9 -0
  118. package/dist/signers/server/helpers/index.js +16 -0
  119. package/dist/signers/server/index.cjs +30 -0
  120. package/dist/signers/server/index.d.cts +12 -0
  121. package/dist/signers/server/index.d.ts +12 -0
  122. package/dist/signers/server/index.js +30 -0
  123. package/dist/signers/server/solana-server-signer.cjs +7 -0
  124. package/dist/signers/server/solana-server-signer.d.cts +25 -0
  125. package/dist/signers/server/solana-server-signer.d.ts +25 -0
  126. package/dist/signers/server/solana-server-signer.js +7 -0
  127. package/dist/signers/server/stellar-server-signer.cjs +8 -0
  128. package/dist/signers/server/stellar-server-signer.d.cts +25 -0
  129. package/dist/signers/server/stellar-server-signer.d.ts +25 -0
  130. package/dist/signers/server/stellar-server-signer.js +8 -0
  131. package/dist/signers/types.d.cts +15 -3
  132. package/dist/signers/types.d.ts +15 -3
  133. package/dist/utils/constants.cjs +2 -2
  134. package/dist/utils/constants.js +1 -1
  135. package/dist/utils/server-key-derivation.cjs +9 -0
  136. package/dist/utils/server-key-derivation.d.cts +20 -0
  137. package/dist/utils/server-key-derivation.d.ts +20 -0
  138. package/dist/utils/server-key-derivation.js +9 -0
  139. package/dist/utils/stellar.cjs +11 -0
  140. package/dist/utils/stellar.d.cts +18 -0
  141. package/dist/utils/stellar.d.ts +18 -0
  142. package/dist/utils/stellar.js +11 -0
  143. package/dist/wallets/__tests__/test-helpers.cjs +19 -9
  144. package/dist/wallets/__tests__/test-helpers.js +18 -8
  145. package/dist/wallets/evm.cjs +20 -10
  146. package/dist/wallets/evm.js +19 -9
  147. package/dist/wallets/solana.cjs +20 -10
  148. package/dist/wallets/solana.js +19 -9
  149. package/dist/wallets/stellar.cjs +20 -10
  150. package/dist/wallets/stellar.js +19 -9
  151. package/dist/wallets/types.d.cts +7 -4
  152. package/dist/wallets/types.d.ts +7 -4
  153. package/dist/wallets/wallet-factory.cjs +21 -11
  154. package/dist/wallets/wallet-factory.js +20 -10
  155. package/dist/wallets/wallet.cjs +19 -9
  156. package/dist/wallets/wallet.d.cts +2 -2
  157. package/dist/wallets/wallet.d.ts +2 -2
  158. package/dist/wallets/wallet.js +18 -8
  159. package/package.json +3 -3
  160. package/dist/chunk-BMMZIPXT.js +0 -778
  161. package/dist/chunk-COR3CNRW.cjs +0 -778
@@ -0,0 +1,316 @@
1
+ // src/utils/stellar.ts
2
+ import nacl from "tweetnacl";
3
+ var ED25519_PUBLIC_KEY_VERSION_BYTE = 6 << 3;
4
+ var BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
5
+ var CRC16_TABLE = [
6
+ 0,
7
+ 4129,
8
+ 8258,
9
+ 12387,
10
+ 16516,
11
+ 20645,
12
+ 24774,
13
+ 28903,
14
+ 33032,
15
+ 37161,
16
+ 41290,
17
+ 45419,
18
+ 49548,
19
+ 53677,
20
+ 57806,
21
+ 61935,
22
+ 4657,
23
+ 528,
24
+ 12915,
25
+ 8786,
26
+ 21173,
27
+ 17044,
28
+ 29431,
29
+ 25302,
30
+ 37689,
31
+ 33560,
32
+ 45947,
33
+ 41818,
34
+ 54205,
35
+ 50076,
36
+ 62463,
37
+ 58334,
38
+ 9314,
39
+ 13379,
40
+ 1056,
41
+ 5121,
42
+ 25830,
43
+ 29895,
44
+ 17572,
45
+ 21637,
46
+ 42346,
47
+ 46411,
48
+ 34088,
49
+ 38153,
50
+ 58862,
51
+ 62927,
52
+ 50604,
53
+ 54669,
54
+ 13907,
55
+ 9842,
56
+ 5649,
57
+ 1584,
58
+ 30423,
59
+ 26358,
60
+ 22165,
61
+ 18100,
62
+ 46939,
63
+ 42874,
64
+ 38681,
65
+ 34616,
66
+ 63455,
67
+ 59390,
68
+ 55197,
69
+ 51132,
70
+ 18628,
71
+ 22757,
72
+ 26758,
73
+ 30887,
74
+ 2112,
75
+ 6241,
76
+ 10242,
77
+ 14371,
78
+ 51660,
79
+ 55789,
80
+ 59790,
81
+ 63919,
82
+ 35144,
83
+ 39273,
84
+ 43274,
85
+ 47403,
86
+ 23285,
87
+ 19156,
88
+ 31415,
89
+ 27286,
90
+ 6769,
91
+ 2640,
92
+ 14899,
93
+ 10770,
94
+ 56317,
95
+ 52188,
96
+ 64447,
97
+ 60318,
98
+ 39801,
99
+ 35672,
100
+ 47931,
101
+ 43802,
102
+ 27814,
103
+ 31879,
104
+ 19684,
105
+ 23749,
106
+ 11298,
107
+ 15363,
108
+ 3168,
109
+ 7233,
110
+ 60846,
111
+ 64911,
112
+ 52716,
113
+ 56781,
114
+ 44330,
115
+ 48395,
116
+ 36200,
117
+ 40265,
118
+ 32407,
119
+ 28342,
120
+ 24277,
121
+ 20212,
122
+ 15891,
123
+ 11826,
124
+ 7761,
125
+ 3696,
126
+ 65439,
127
+ 61374,
128
+ 57309,
129
+ 53244,
130
+ 48923,
131
+ 44858,
132
+ 40793,
133
+ 36728,
134
+ 37256,
135
+ 33193,
136
+ 45514,
137
+ 41451,
138
+ 53516,
139
+ 49453,
140
+ 61774,
141
+ 57711,
142
+ 4224,
143
+ 161,
144
+ 12482,
145
+ 8419,
146
+ 20484,
147
+ 16421,
148
+ 28742,
149
+ 24679,
150
+ 33721,
151
+ 37784,
152
+ 41979,
153
+ 46042,
154
+ 49981,
155
+ 54044,
156
+ 58239,
157
+ 62302,
158
+ 689,
159
+ 4752,
160
+ 8947,
161
+ 13010,
162
+ 16949,
163
+ 21012,
164
+ 25207,
165
+ 29270,
166
+ 46570,
167
+ 42443,
168
+ 38312,
169
+ 34185,
170
+ 62830,
171
+ 58703,
172
+ 54572,
173
+ 50445,
174
+ 13538,
175
+ 9411,
176
+ 5280,
177
+ 1153,
178
+ 29798,
179
+ 25671,
180
+ 21540,
181
+ 17413,
182
+ 42971,
183
+ 47098,
184
+ 34713,
185
+ 38840,
186
+ 59231,
187
+ 63358,
188
+ 50973,
189
+ 55100,
190
+ 9939,
191
+ 14066,
192
+ 1681,
193
+ 5808,
194
+ 26199,
195
+ 30326,
196
+ 17941,
197
+ 22068,
198
+ 55628,
199
+ 51565,
200
+ 63758,
201
+ 59695,
202
+ 39368,
203
+ 35305,
204
+ 47498,
205
+ 43435,
206
+ 22596,
207
+ 18533,
208
+ 30726,
209
+ 26663,
210
+ 6336,
211
+ 2273,
212
+ 14466,
213
+ 10403,
214
+ 52093,
215
+ 56156,
216
+ 60223,
217
+ 64286,
218
+ 35833,
219
+ 39896,
220
+ 43963,
221
+ 48026,
222
+ 19061,
223
+ 23124,
224
+ 27191,
225
+ 31254,
226
+ 2801,
227
+ 6864,
228
+ 10931,
229
+ 14994,
230
+ 64814,
231
+ 60687,
232
+ 56684,
233
+ 52557,
234
+ 48554,
235
+ 44427,
236
+ 40424,
237
+ 36297,
238
+ 31782,
239
+ 27655,
240
+ 23652,
241
+ 19525,
242
+ 15522,
243
+ 11395,
244
+ 7392,
245
+ 3265,
246
+ 61215,
247
+ 65342,
248
+ 53085,
249
+ 57212,
250
+ 44955,
251
+ 49082,
252
+ 36825,
253
+ 40952,
254
+ 28183,
255
+ 32310,
256
+ 20053,
257
+ 24180,
258
+ 11923,
259
+ 16050,
260
+ 3793,
261
+ 7920
262
+ ];
263
+ function crc16Xmodem(data) {
264
+ let crc = 0;
265
+ for (let i = 0; i < data.length; i++) {
266
+ const byte = data[i];
267
+ crc = (crc << 8 ^ CRC16_TABLE[crc >> 8 ^ byte]) & 65535;
268
+ }
269
+ const checksum = new Uint8Array(2);
270
+ checksum[0] = crc & 255;
271
+ checksum[1] = crc >> 8 & 255;
272
+ return checksum;
273
+ }
274
+ function base32Encode(data) {
275
+ let bits = 0;
276
+ let value = 0;
277
+ let output = "";
278
+ for (let i = 0; i < data.length; i++) {
279
+ value = value << 8 | data[i];
280
+ bits += 8;
281
+ while (bits >= 5) {
282
+ output += BASE32_ALPHABET[value >>> bits - 5 & 31];
283
+ bits -= 5;
284
+ }
285
+ }
286
+ if (bits > 0) {
287
+ output += BASE32_ALPHABET[value << 5 - bits & 31];
288
+ }
289
+ while (output.length % 8 !== 0) {
290
+ output += "=";
291
+ }
292
+ return output;
293
+ }
294
+ function encodeStellarPublicKey(publicKeyBytes) {
295
+ const payload = new Uint8Array(1 + publicKeyBytes.length);
296
+ payload[0] = ED25519_PUBLIC_KEY_VERSION_BYTE;
297
+ payload.set(publicKeyBytes, 1);
298
+ const checksum = crc16Xmodem(payload);
299
+ const unencoded = new Uint8Array(payload.length + 2);
300
+ unencoded.set(payload, 0);
301
+ unencoded.set(checksum, payload.length);
302
+ return base32Encode(unencoded);
303
+ }
304
+ function ed25519KeypairFromSeed(seed) {
305
+ const keypair = nacl.sign.keyPair.fromSeed(seed);
306
+ return { publicKey: keypair.publicKey, secretKey: keypair.secretKey };
307
+ }
308
+ function ed25519Sign(message, secretKey) {
309
+ return nacl.sign.detached(message, secretKey);
310
+ }
311
+
312
+ export {
313
+ encodeStellarPublicKey,
314
+ ed25519KeypairFromSeed,
315
+ ed25519Sign
316
+ };
@@ -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 _chunk5NWGYER3cjs = require('./chunk-5NWGYER3.cjs');
5
5
 
6
6
 
7
- var _chunkJREZWZ2Scjs = require('./chunk-JREZWZ2S.cjs');
7
+ var _chunkBJQHHI7Kcjs = require('./chunk-BJQHHI7K.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 _chunk5NWGYER3cjs.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
+ _chunkBJQHHI7Kcjs.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: _chunk5NWGYER3cjs.DEFAULT_EVENT_OPTIONS
49
49
  });
50
- _chunkJREZWZ2Scjs.walletsLogger.info("sign: response received", {
50
+ _chunkBJQHHI7Kcjs.walletsLogger.info("sign: response received", {
51
51
  status: res == null ? void 0 : res.status,
52
52
  durationMs: Date.now() - startTime
53
53
  });
@@ -0,0 +1,44 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkM6E6A543cjs = require('./chunk-M6E6A543.cjs');
6
+
7
+
8
+ var _chunkUO2J2ZB2cjs = require('./chunk-UO2J2ZB2.cjs');
9
+
10
+ // src/signers/server/stellar-server-signer.ts
11
+ var StellarServerSigner = class {
12
+ constructor(config) {
13
+ this.type = "server";
14
+ const keypair = _chunkM6E6A543cjs.ed25519KeypairFromSeed.call(void 0, config.derivedKeyBytes);
15
+ this._address = _chunkM6E6A543cjs.encodeStellarPublicKey.call(void 0, keypair.publicKey);
16
+ this._locator = config.locator;
17
+ this.secretKey = keypair.secretKey;
18
+ }
19
+ address() {
20
+ return this._address;
21
+ }
22
+ locator() {
23
+ return this._locator;
24
+ }
25
+ signMessage(message) {
26
+ return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
27
+ if (!/^[A-Za-z0-9+/]*={0,2}$/.test(message)) {
28
+ throw new Error("StellarServerSigner.signMessage: expected a base64-encoded string");
29
+ }
30
+ const messageBytes = Buffer.from(message, "base64");
31
+ const signatureBytes = _chunkM6E6A543cjs.ed25519Sign.call(void 0, messageBytes, this.secretKey);
32
+ return { signature: Buffer.from(signatureBytes).toString("base64") };
33
+ });
34
+ }
35
+ signTransaction(transaction) {
36
+ return _chunkUO2J2ZB2cjs.__async.call(void 0, this, null, function* () {
37
+ return yield this.signMessage(transaction);
38
+ });
39
+ }
40
+ };
41
+
42
+
43
+
44
+ exports.StellarServerSigner = StellarServerSigner;
@@ -0,0 +1,40 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkRUQYXEEGcjs = require('./chunk-RUQYXEEG.cjs');
4
+
5
+
6
+ var _chunkMNHK6EQKcjs = require('./chunk-MNHK6EQK.cjs');
7
+
8
+
9
+
10
+ var _chunkM6E6A543cjs = require('./chunk-M6E6A543.cjs');
11
+
12
+ // src/signers/server/helpers/derive-server-signer.ts
13
+ var _accounts = require('viem/accounts');
14
+ var _utils = require('@noble/hashes/utils');
15
+ var _web3js = require('@solana/web3.js');
16
+ function deriveServerSignerAddress(keyBytes, chain) {
17
+ const chainType = _chunkRUQYXEEGcjs.getChainType.call(void 0, chain);
18
+ switch (chainType) {
19
+ case "evm":
20
+ return _accounts.privateKeyToAccount.call(void 0, `0x${_utils.bytesToHex.call(void 0, keyBytes)}`).address;
21
+ case "solana":
22
+ return _web3js.Keypair.fromSeed(keyBytes).publicKey.toBase58();
23
+ case "stellar":
24
+ return _chunkM6E6A543cjs.encodeStellarPublicKey.call(void 0, _chunkM6E6A543cjs.ed25519KeypairFromSeed.call(void 0, keyBytes).publicKey);
25
+ }
26
+ }
27
+ function deriveServerSignerDetails(signer, chain, projectId, environment) {
28
+ if (typeof window !== "undefined") {
29
+ throw new Error("Server signers can only be used from server-side code.");
30
+ }
31
+ const chainStr = typeof chain === "string" ? chain : String(chain);
32
+ const derivedKeyBytes = _chunkMNHK6EQKcjs.deriveKeyBytes.call(void 0, signer.secret, projectId, environment, chainStr);
33
+ const derivedAddress = deriveServerSignerAddress(derivedKeyBytes, chain);
34
+ return { derivedKeyBytes, derivedAddress };
35
+ }
36
+
37
+
38
+
39
+
40
+ exports.deriveServerSignerAddress = deriveServerSignerAddress; exports.deriveServerSignerDetails = deriveServerSignerDetails;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  DEFAULT_EVENT_OPTIONS,
3
3
  NonCustodialSigner
4
- } from "./chunk-U3NV7UY7.js";
4
+ } from "./chunk-LDVEJ2XZ.js";
5
5
  import {
6
6
  walletsLogger
7
- } from "./chunk-ABMZ3ZVN.js";
7
+ } from "./chunk-SIP7NNGL.js";
8
8
  import {
9
9
  __async
10
10
  } from "./chunk-ASE2FXWP.js";
@@ -4,20 +4,23 @@ import {
4
4
  } from "./chunk-ZP4ZZCIE.js";
5
5
  import {
6
6
  Wallet
7
- } from "./chunk-FHMKNG62.js";
7
+ } from "./chunk-CUE4X7Y4.js";
8
8
  import {
9
9
  assembleSigner
10
- } from "./chunk-T2XUADHW.js";
10
+ } from "./chunk-QPVKMB34.js";
11
+ import {
12
+ deriveServerSignerDetails
13
+ } from "./chunk-4MEGQR3I.js";
11
14
  import {
12
15
  validateChainForEnvironment
13
- } from "./chunk-2WBSPOWU.js";
16
+ } from "./chunk-NBBOYFQW.js";
14
17
  import {
15
18
  WalletCreationError,
16
19
  WalletNotAvailableError
17
20
  } from "./chunk-SGINWAB6.js";
18
21
  import {
19
22
  walletsLogger
20
- } from "./chunk-ABMZ3ZVN.js";
23
+ } from "./chunk-SIP7NNGL.js";
21
24
  import {
22
25
  __async,
23
26
  __decorateClass,
@@ -88,19 +91,35 @@ var WalletFactory = class {
88
91
  }
89
92
  createWalletInternal(args) {
90
93
  return __async(this, null, function* () {
91
- var _a, _b, _c, _d, _e;
94
+ var _a, _b, _c, _d, _e, _f;
92
95
  yield (_c = (_b = (_a = args.options) == null ? void 0 : _a.experimental_callbacks) == null ? void 0 : _b.onWalletCreationStart) == null ? void 0 : _c.call(_b);
93
96
  walletsLogger.info("walletFactory.createWallet.start");
94
97
  this.mutateSignerFromCustomAuth(args, true);
95
- const adminSigner = args.signer.type === "passkey" ? yield this.createPasskeyAdminSigner(args.signer) : args.signer;
98
+ let adminSigner;
99
+ const delegatedSigners = (_d = args.delegatedSigners) == null ? void 0 : _d.map((ds) => ({
100
+ signer: typeof ds.signer === "object" && ds.signer.type === "server" ? `server:${deriveServerSignerDetails(ds.signer, args.chain, this.apiClient.projectId, this.apiClient.environment).derivedAddress}` : ds.signer
101
+ }));
102
+ if (args.signer.type === "passkey") {
103
+ adminSigner = yield this.createPasskeyAdminSigner(args.signer);
104
+ } else if (args.signer.type === "server") {
105
+ const { derivedAddress } = deriveServerSignerDetails(
106
+ args.signer,
107
+ args.chain,
108
+ this.apiClient.projectId,
109
+ this.apiClient.environment
110
+ );
111
+ adminSigner = { type: "server", address: derivedAddress };
112
+ } else {
113
+ adminSigner = args.signer;
114
+ }
96
115
  const walletResponse = yield this.apiClient.createWallet({
97
116
  type: "smart",
98
117
  chainType: this.getChainType(args.chain),
99
118
  config: __spreadValues(__spreadValues({
100
119
  adminSigner
101
- }, (args == null ? void 0 : args.plugins) ? { plugins: args.plugins } : {}), args.delegatedSigners != null ? { delegatedSigners: args.delegatedSigners } : {}),
102
- owner: (_d = args.owner) != null ? _d : void 0,
103
- alias: (_e = args.alias) != null ? _e : void 0
120
+ }, (args == null ? void 0 : args.plugins) ? { plugins: args.plugins } : {}), delegatedSigners != null ? { delegatedSigners } : {}),
121
+ owner: (_e = args.owner) != null ? _e : void 0,
122
+ alias: (_f = args.alias) != null ? _f : void 0
104
123
  });
105
124
  if ("error" in walletResponse) {
106
125
  walletsLogger.error("walletFactory.createWallet.error", {
@@ -116,7 +135,7 @@ var WalletFactory = class {
116
135
  }
117
136
  createWalletInstance(walletResponse, args) {
118
137
  this.validateExistingWalletConfig(walletResponse, args);
119
- const signerConfig = this.toInternalSignerConfig(walletResponse, args.signer, args.options);
138
+ const signerConfig = this.toInternalSignerConfig(walletResponse, args.signer, args.chain, args.options);
120
139
  return new Wallet(
121
140
  {
122
141
  chain: args.chain,
@@ -129,8 +148,8 @@ var WalletFactory = class {
129
148
  this.apiClient
130
149
  );
131
150
  }
132
- toInternalSignerConfig(walletResponse, signerArgs, options) {
133
- var _a, _b, _c, _d, _e, _f;
151
+ toInternalSignerConfig(walletResponse, signerArgs, chain, options) {
152
+ var _a, _b, _c, _d, _e, _f, _g;
134
153
  if (!(walletResponse.chainType === "evm" || walletResponse.chainType === "solana" || walletResponse.chainType === "stellar")) {
135
154
  throw new WalletCreationError(`Wallet type ${walletResponse.chainType} is not supported`);
136
155
  }
@@ -165,8 +184,31 @@ var WalletFactory = class {
165
184
  onCreatePasskey: signerArgs.onCreatePasskey,
166
185
  onSignWithPasskey: signerArgs.onSignWithPasskey
167
186
  };
187
+ case "server": {
188
+ const serverAdminSigner = (_e = walletResponse.config) == null ? void 0 : _e.adminSigner;
189
+ if ((serverAdminSigner == null ? void 0 : serverAdminSigner.type) !== "server") {
190
+ throw new WalletCreationError("Server signer expects a server admin signer on the wallet");
191
+ }
192
+ const { derivedKeyBytes, derivedAddress } = deriveServerSignerDetails(
193
+ signerArgs,
194
+ chain,
195
+ this.apiClient.projectId,
196
+ this.apiClient.environment
197
+ );
198
+ if (serverAdminSigner.address !== derivedAddress) {
199
+ throw new WalletCreationError(
200
+ `Server signer address ${derivedAddress} does not match the wallet's admin signer address`
201
+ );
202
+ }
203
+ return {
204
+ type: "server",
205
+ derivedKeyBytes,
206
+ locator: serverAdminSigner.locator,
207
+ address: derivedAddress
208
+ };
209
+ }
168
210
  case "email": {
169
- if (((_e = walletResponse.config) == null ? void 0 : _e.adminSigner.type) !== "email") {
211
+ if (((_f = walletResponse.config) == null ? void 0 : _f.adminSigner.type) !== "email") {
170
212
  throw new WalletCreationError("Email signer does not match the wallet's signer type");
171
213
  }
172
214
  const { locator, email, address } = walletResponse.config.adminSigner;
@@ -181,7 +223,7 @@ var WalletFactory = class {
181
223
  };
182
224
  }
183
225
  case "phone": {
184
- if (((_f = walletResponse.config) == null ? void 0 : _f.adminSigner.type) !== "phone") {
226
+ if (((_g = walletResponse.config) == null ? void 0 : _g.adminSigner.type) !== "phone") {
185
227
  throw new WalletCreationError("Phone signer does not match the wallet's signer type");
186
228
  }
187
229
  const { locator, phone, address } = walletResponse.config.adminSigner;
@@ -263,10 +305,10 @@ var WalletFactory = class {
263
305
  compareSignerConfigs(adminSignerArgs, existingWalletSigner);
264
306
  }
265
307
  if (args.delegatedSigners != null) {
266
- this.validateDelegatedSigners(existingWallet, args.delegatedSigners);
308
+ this.validateDelegatedSigners(existingWallet, args.delegatedSigners, args.chain);
267
309
  }
268
310
  }
269
- validateDelegatedSigners(existingWallet, inputDelegatedSigners) {
311
+ validateDelegatedSigners(existingWallet, inputDelegatedSigners, chain) {
270
312
  var _a;
271
313
  const existingDelegatedSigners = (_a = existingWallet == null ? void 0 : existingWallet.config) == null ? void 0 : _a.delegatedSigners;
272
314
  if (inputDelegatedSigners.length === 0) {
@@ -278,13 +320,14 @@ var WalletFactory = class {
278
320
  );
279
321
  }
280
322
  for (const argSigner of inputDelegatedSigners) {
323
+ const resolvedSigner = typeof argSigner.signer === "object" && argSigner.signer.type === "server" ? `server:${deriveServerSignerDetails(argSigner.signer, chain, this.apiClient.projectId, this.apiClient.environment).derivedAddress}` : argSigner.signer;
281
324
  const matchingExistingSigner = existingDelegatedSigners.find(
282
- (existingSigner) => existingSigner.locator === argSigner.signer
325
+ (existingSigner) => existingSigner.locator === resolvedSigner
283
326
  );
284
327
  if (matchingExistingSigner == null) {
285
328
  const walletSigners = existingDelegatedSigners.map((s) => s.locator).join(", ");
286
329
  throw new WalletCreationError(
287
- `Delegated signer '${argSigner.signer}' does not exist in wallet "${existingWallet.address}". Available delegated signers: ${walletSigners}. ${DELEGATED_SIGNER_MISMATCH_ERROR}`
330
+ `Delegated signer '${resolvedSigner}' does not exist in wallet "${existingWallet.address}". Available delegated signers: ${walletSigners}. ${DELEGATED_SIGNER_MISMATCH_ERROR}`
288
331
  );
289
332
  }
290
333
  }