@crossmint/wallets-sdk 0.18.3 → 0.18.6

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 (197) hide show
  1. package/dist/api/client.cjs +10 -1
  2. package/dist/api/client.js +10 -1
  3. package/dist/api/gen/client.gen.cjs +7 -1
  4. package/dist/api/gen/client.gen.js +7 -1
  5. package/dist/api/gen/index.cjs +179 -1
  6. package/dist/api/gen/index.js +179 -1
  7. package/dist/api/gen/sdk.gen.cjs +178 -1
  8. package/dist/api/gen/sdk.gen.js +178 -1
  9. package/dist/api/gen/types.gen.js +1 -1
  10. package/dist/api/index.cjs +12 -1
  11. package/dist/api/index.js +12 -1
  12. package/dist/api/types.js +1 -1
  13. package/dist/chains/chains.cjs +9 -1
  14. package/dist/chains/chains.js +9 -1
  15. package/dist/chains/definitions/story.cjs +7 -1
  16. package/dist/chains/definitions/story.js +7 -1
  17. package/dist/chains/definitions/storyTestnet.cjs +7 -1
  18. package/dist/chains/definitions/storyTestnet.js +7 -1
  19. package/dist/chunk-2T5HHKUI.js +19 -0
  20. package/dist/chunk-34FDYDOM.cjs +87 -0
  21. package/dist/chunk-3U6UAYOV.js +25 -0
  22. package/dist/chunk-454RYNSZ.js +80 -0
  23. package/dist/chunk-455NK5LB.js +0 -0
  24. package/dist/chunk-55V4VMTX.cjs +25 -0
  25. package/dist/chunk-5BP6CVYY.cjs +58 -0
  26. package/dist/chunk-5YR2ILEW.js +69 -0
  27. package/dist/chunk-6G7ZWCCG.js +247 -0
  28. package/dist/chunk-7ECQJFYM.cjs +63 -0
  29. package/dist/chunk-7JFVG4IY.js +59 -0
  30. package/dist/chunk-AL77JANE.js +36 -0
  31. package/dist/chunk-B6JOIWRH.cjs +289 -0
  32. package/dist/chunk-BSC55MYK.cjs +43 -0
  33. package/dist/chunk-CCIGWTAO.cjs +1 -0
  34. package/dist/chunk-CHGPNMRL.cjs +36 -0
  35. package/dist/chunk-CL44FTXR.js +289 -0
  36. package/dist/chunk-CN2GVFBU.cjs +138 -0
  37. package/dist/chunk-DQCXGBZM.js +59 -0
  38. package/dist/chunk-E3OS753T.js +175 -0
  39. package/dist/chunk-EYJQSDDI.js +43 -0
  40. package/dist/chunk-F6E3ZDRG.cjs +175 -0
  41. package/dist/chunk-FPMW7Q5O.js +55 -0
  42. package/dist/chunk-G3LEJR3P.cjs +53 -0
  43. package/dist/chunk-G5NYLGM5.cjs +55 -0
  44. package/dist/chunk-GLRDLJS5.js +92 -0
  45. package/dist/chunk-GNF2U7IX.cjs +69 -0
  46. package/dist/chunk-GQIZWD4F.cjs +301 -0
  47. package/dist/chunk-HYKMSBCT.cjs +75 -0
  48. package/dist/chunk-IVNYZDI5.cjs +73 -0
  49. package/dist/chunk-K3HFAPSV.js +73 -0
  50. package/dist/chunk-KS63YEQ4.js +138 -0
  51. package/dist/chunk-KT3CVXFG.js +9 -0
  52. package/dist/chunk-LGONZW4W.cjs +629 -0
  53. package/dist/chunk-LHYSCUKJ.cjs +16 -0
  54. package/dist/chunk-LKAO2MV2.cjs +80 -0
  55. package/dist/chunk-LLFD22UQ.cjs +36 -0
  56. package/dist/chunk-MZBFXUHT.js +63 -0
  57. package/dist/chunk-NIBKCMQ2.cjs +19 -0
  58. package/dist/chunk-OKXSUK63.js +87 -0
  59. package/dist/chunk-R2OY54EJ.cjs +59 -0
  60. package/dist/chunk-RAWKXOHR.js +53 -0
  61. package/dist/chunk-RBHGZDDX.cjs +58 -0
  62. package/dist/chunk-RHR6P2KP.cjs +15 -0
  63. package/dist/chunk-RTRDZB52.js +778 -0
  64. package/dist/chunk-S5YXROL6.js +301 -0
  65. package/dist/chunk-SGINWAB6.js +155 -0
  66. package/dist/chunk-TK3EUCQ4.cjs +59 -0
  67. package/dist/chunk-TOHXQVLS.js +58 -0
  68. package/dist/chunk-UKBWSQ7R.js +629 -0
  69. package/dist/chunk-UMGB3Q7I.cjs +92 -0
  70. package/dist/chunk-V3QJQUT7.cjs +778 -0
  71. package/dist/chunk-WC7T2CR4.js +44 -0
  72. package/dist/chunk-WJUPOCKJ.js +15 -0
  73. package/dist/chunk-WQVJM3PG.js +16 -0
  74. package/dist/chunk-XC2V34TS.cjs +155 -0
  75. package/dist/chunk-XRA5GFH3.js +75 -0
  76. package/dist/chunk-YBA7WO32.cjs +44 -0
  77. package/dist/chunk-ZP4ZZCIE.js +58 -0
  78. package/dist/chunk-ZT7EGOCI.cjs +9 -0
  79. package/dist/chunk-ZTGRDOOH.js +36 -0
  80. package/dist/chunk-ZZJ7U5G3.cjs +247 -0
  81. package/dist/index.cjs +57 -1
  82. package/dist/index.js +57 -1
  83. package/dist/logger/index.cjs +11 -0
  84. package/dist/logger/index.d.cts +2 -0
  85. package/dist/logger/index.d.ts +2 -0
  86. package/dist/logger/index.js +11 -0
  87. package/dist/logger/init.cjs +10 -0
  88. package/dist/logger/init.d.cts +15 -0
  89. package/dist/logger/init.d.ts +15 -0
  90. package/dist/logger/init.js +10 -0
  91. package/dist/sdk.cjs +33 -1
  92. package/dist/sdk.js +33 -1
  93. package/dist/signers/evm-api-key.cjs +7 -1
  94. package/dist/signers/evm-api-key.js +7 -1
  95. package/dist/signers/evm-external-wallet.cjs +7 -1
  96. package/dist/signers/evm-external-wallet.js +7 -1
  97. package/dist/signers/index.cjs +21 -1
  98. package/dist/signers/index.js +21 -1
  99. package/dist/signers/non-custodial/index.cjs +24 -1
  100. package/dist/signers/non-custodial/index.js +24 -1
  101. package/dist/signers/non-custodial/ncs-evm-signer.cjs +10 -1
  102. package/dist/signers/non-custodial/ncs-evm-signer.js +10 -1
  103. package/dist/signers/non-custodial/ncs-iframe-manager.cjs +7 -1
  104. package/dist/signers/non-custodial/ncs-iframe-manager.js +7 -1
  105. package/dist/signers/non-custodial/ncs-signer.cjs +11 -1
  106. package/dist/signers/non-custodial/ncs-signer.js +11 -1
  107. package/dist/signers/non-custodial/ncs-solana-signer.cjs +10 -1
  108. package/dist/signers/non-custodial/ncs-solana-signer.js +10 -1
  109. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +10 -1
  110. package/dist/signers/non-custodial/ncs-stellar-signer.js +10 -1
  111. package/dist/signers/passkey.cjs +7 -1
  112. package/dist/signers/passkey.js +7 -1
  113. package/dist/signers/solana-api-key.cjs +7 -1
  114. package/dist/signers/solana-api-key.js +7 -1
  115. package/dist/signers/solana-external-wallet.cjs +8 -1
  116. package/dist/signers/solana-external-wallet.js +8 -1
  117. package/dist/signers/stellar-external-wallet.cjs +7 -1
  118. package/dist/signers/stellar-external-wallet.js +7 -1
  119. package/dist/signers/types.cjs +9 -1
  120. package/dist/signers/types.js +9 -1
  121. package/dist/utils/constants.cjs +13 -1
  122. package/dist/utils/constants.js +13 -1
  123. package/dist/utils/errors.cjs +55 -1
  124. package/dist/utils/errors.js +55 -1
  125. package/dist/utils/signer-validation.cjs +10 -1
  126. package/dist/utils/signer-validation.d.cts +7 -1
  127. package/dist/utils/signer-validation.d.ts +7 -1
  128. package/dist/utils/signer-validation.js +10 -1
  129. package/dist/wallets/evm.cjs +20 -1
  130. package/dist/wallets/evm.js +20 -1
  131. package/dist/wallets/solana.cjs +18 -1
  132. package/dist/wallets/solana.js +18 -1
  133. package/dist/wallets/stellar.cjs +17 -1
  134. package/dist/wallets/stellar.js +17 -1
  135. package/dist/wallets/wallet-factory.cjs +27 -1
  136. package/dist/wallets/wallet-factory.js +27 -1
  137. package/dist/wallets/wallet.cjs +16 -1
  138. package/dist/wallets/wallet.js +16 -1
  139. package/package.json +6 -5
  140. package/dist/chunk-2SHDBC47.js +0 -1
  141. package/dist/chunk-2XVV7Z43.cjs +0 -1
  142. package/dist/chunk-2YH3NVVK.cjs +0 -1
  143. package/dist/chunk-3APSOOE3.js +0 -1
  144. package/dist/chunk-3SW6AJSG.cjs +0 -1
  145. package/dist/chunk-4KXOWU5E.cjs +0 -1
  146. package/dist/chunk-5M7IRODB.js +0 -1
  147. package/dist/chunk-5QIW67NU.cjs +0 -1
  148. package/dist/chunk-6PVKL5RC.js +0 -1
  149. package/dist/chunk-7HTB7WKD.cjs +0 -1
  150. package/dist/chunk-7JIPYRKX.js +0 -1
  151. package/dist/chunk-BQZES4ST.js +0 -1
  152. package/dist/chunk-BW7YYVZE.js +0 -1
  153. package/dist/chunk-C3T63EC7.cjs +0 -1
  154. package/dist/chunk-CXTC3YDL.cjs +0 -1
  155. package/dist/chunk-DV6ZRFKV.js +0 -1
  156. package/dist/chunk-DX7VVXY5.cjs +0 -1
  157. package/dist/chunk-FATVK26C.js +0 -1
  158. package/dist/chunk-GEY574TH.cjs +0 -1
  159. package/dist/chunk-GKZFI322.js +0 -1
  160. package/dist/chunk-H4T4IXCF.js +0 -1
  161. package/dist/chunk-HJ5EDMTA.js +0 -1
  162. package/dist/chunk-HPHVJ6BA.cjs +0 -1
  163. package/dist/chunk-HQAKCIYM.js +0 -1
  164. package/dist/chunk-HRSVFJND.cjs +0 -1
  165. package/dist/chunk-IGBQEAD5.js +0 -1
  166. package/dist/chunk-IR5WN6FQ.cjs +0 -1
  167. package/dist/chunk-JUSY5XEE.js +0 -1
  168. package/dist/chunk-KFJLRIY7.js +0 -1
  169. package/dist/chunk-KKQBZXFE.js +0 -1
  170. package/dist/chunk-KO6QYKDX.cjs +0 -1
  171. package/dist/chunk-KRV3IXJU.cjs +0 -1
  172. package/dist/chunk-LW6JSI4J.js +0 -1
  173. package/dist/chunk-M2UBZY5S.cjs +0 -1
  174. package/dist/chunk-M4TOGGLV.cjs +0 -1
  175. package/dist/chunk-MQP5VZCA.cjs +0 -1
  176. package/dist/chunk-NP32UO2G.cjs +0 -1
  177. package/dist/chunk-O4FVTK7X.cjs +0 -1
  178. package/dist/chunk-P6JJHAAV.js +0 -1
  179. package/dist/chunk-PONCGT2H.cjs +0 -1
  180. package/dist/chunk-PSXRNSOE.js +0 -1
  181. package/dist/chunk-QMXG67T3.cjs +0 -1
  182. package/dist/chunk-RJZV72YF.js +0 -1
  183. package/dist/chunk-S3DYQVRD.js +0 -1
  184. package/dist/chunk-SLG7HGGL.js +0 -1
  185. package/dist/chunk-STYSP6KL.cjs +0 -1
  186. package/dist/chunk-UBOWSXW3.js +0 -1
  187. package/dist/chunk-UNBXKCNN.js +0 -1
  188. package/dist/chunk-VY634F3J.js +0 -1
  189. package/dist/chunk-WQP2FSVI.js +0 -1
  190. package/dist/chunk-WYYAPI4G.cjs +0 -1
  191. package/dist/chunk-WZFHEUWT.cjs +0 -1
  192. package/dist/chunk-XALFCQKD.cjs +0 -1
  193. package/dist/chunk-YWPTI2QO.cjs +0 -1
  194. package/dist/chunk-YWXQIFVZ.js +0 -3
  195. package/dist/chunk-YZ4HRYSL.cjs +0 -1
  196. package/dist/chunk-Z54LVUDS.js +0 -1
  197. package/dist/chunk-ZWMB3QLR.cjs +0 -3
@@ -0,0 +1,247 @@
1
+ import {
2
+ InvalidApiKeyError
3
+ } from "./chunk-SGINWAB6.js";
4
+ import {
5
+ walletsLogger
6
+ } from "./chunk-RAWKXOHR.js";
7
+ import {
8
+ SDK_NAME,
9
+ SDK_VERSION
10
+ } from "./chunk-WQVJM3PG.js";
11
+ import {
12
+ __async
13
+ } from "./chunk-FPMW7Q5O.js";
14
+
15
+ // src/api/client.ts
16
+ import {
17
+ APIKeyEnvironmentPrefix,
18
+ APIKeyUsageOrigin,
19
+ CrossmintApiClient
20
+ } from "@crossmint/common-sdk-base";
21
+ var ApiClient = class extends CrossmintApiClient {
22
+ constructor(crossmint) {
23
+ super(crossmint, {
24
+ internalConfig: {
25
+ sdkMetadata: { name: SDK_NAME, version: SDK_VERSION }
26
+ }
27
+ });
28
+ this.apiPrefix = "api/2025-06-09/wallets";
29
+ this.legacyApiPrefix = "api/2022-06-09/wallets";
30
+ }
31
+ createWallet(params) {
32
+ return __async(this, null, function* () {
33
+ const path = this.isServerSide ? `${this.apiPrefix}` : `${this.apiPrefix}/me`;
34
+ walletsLogger.info("wallets.api.createWallet", {
35
+ chainType: params.chainType,
36
+ walletType: params.type
37
+ });
38
+ const response = yield this.post(path, {
39
+ body: JSON.stringify(params),
40
+ headers: this.headers
41
+ });
42
+ const result = yield response.json();
43
+ if ("error" in result) {
44
+ walletsLogger.error("wallets.api.createWallet.error", {
45
+ error: result.error,
46
+ chainType: params.chainType
47
+ });
48
+ } else if ("address" in result) {
49
+ walletsLogger.info("wallets.api.createWallet.success", {
50
+ address: result.address,
51
+ chainType: params.chainType
52
+ });
53
+ }
54
+ return result;
55
+ });
56
+ }
57
+ getWallet(locator) {
58
+ return __async(this, null, function* () {
59
+ walletsLogger.info("wallets.api.getWallet", { locator });
60
+ const response = yield this.get(`${this.apiPrefix}/${locator}`, {
61
+ headers: this.headers
62
+ });
63
+ const result = yield response.json();
64
+ if ("error" in result) {
65
+ walletsLogger.warn("wallets.api.getWallet.error", {
66
+ locator,
67
+ error: result.error
68
+ });
69
+ } else if ("address" in result) {
70
+ walletsLogger.info("wallets.api.getWallet.success", result);
71
+ }
72
+ return result;
73
+ });
74
+ }
75
+ createTransaction(walletLocator, params) {
76
+ return __async(this, null, function* () {
77
+ const response = yield this.post(`${this.apiPrefix}/${walletLocator}/transactions`, {
78
+ body: JSON.stringify(params),
79
+ headers: this.headers
80
+ });
81
+ return response.json();
82
+ });
83
+ }
84
+ approveTransaction(walletLocator, transactionId, params) {
85
+ return __async(this, null, function* () {
86
+ const response = yield this.post(`${this.apiPrefix}/${walletLocator}/transactions/${transactionId}/approvals`, {
87
+ body: JSON.stringify(params),
88
+ headers: this.headers
89
+ });
90
+ return response.json();
91
+ });
92
+ }
93
+ getTransaction(walletLocator, transactionId) {
94
+ return __async(this, null, function* () {
95
+ const response = yield this.get(`${this.apiPrefix}/${walletLocator}/transactions/${transactionId}`, {
96
+ headers: this.headers
97
+ });
98
+ return response.json();
99
+ });
100
+ }
101
+ createSignature(walletLocator, params) {
102
+ return __async(this, null, function* () {
103
+ const response = yield this.post(`${this.apiPrefix}/${walletLocator}/signatures`, {
104
+ body: JSON.stringify(params),
105
+ headers: this.headers
106
+ });
107
+ return response.json();
108
+ });
109
+ }
110
+ approveSignature(walletLocator, signatureId, params) {
111
+ return __async(this, null, function* () {
112
+ const response = yield this.post(`${this.apiPrefix}/${walletLocator}/signatures/${signatureId}/approvals`, {
113
+ body: JSON.stringify(params),
114
+ headers: this.headers
115
+ });
116
+ return response.json();
117
+ });
118
+ }
119
+ getSignature(walletLocator, signatureId) {
120
+ return __async(this, null, function* () {
121
+ const response = yield this.get(`${this.apiPrefix}/${walletLocator}/signatures/${signatureId}`, {
122
+ headers: this.headers
123
+ });
124
+ return response.json();
125
+ });
126
+ }
127
+ getTransactions(walletLocator) {
128
+ return __async(this, null, function* () {
129
+ const response = yield this.get(`${this.apiPrefix}/${walletLocator}/transactions`, {
130
+ headers: this.headers
131
+ });
132
+ return response.json();
133
+ });
134
+ }
135
+ experimental_getNfts(params) {
136
+ return __async(this, null, function* () {
137
+ const queryParams = new URLSearchParams();
138
+ queryParams.append("page", params.page.toString());
139
+ queryParams.append("perPage", params.perPage.toString());
140
+ const identifier = `${params.chain}:${params.address}`;
141
+ const response = yield this.get(`${this.apiPrefix}/${identifier}/nfts?${queryParams.toString()}`, {
142
+ headers: this.headers
143
+ });
144
+ return response.json();
145
+ });
146
+ }
147
+ experimental_activity(walletLocator, params) {
148
+ return __async(this, null, function* () {
149
+ let legacyLocator = walletLocator;
150
+ if (!this.isServerSide) {
151
+ legacyLocator = `me:${params.chain === "solana" ? "solana-smart-wallet" : "evm-smart-wallet"}`;
152
+ }
153
+ const queryParams = new URLSearchParams();
154
+ queryParams.append("chain", params.chain.toString());
155
+ const response = yield this.get(`${this.legacyApiPrefix}/${legacyLocator}/activity?${queryParams.toString()}`, {
156
+ headers: this.headers
157
+ });
158
+ return response.json();
159
+ });
160
+ }
161
+ getBalance(walletLocator, params) {
162
+ return __async(this, null, function* () {
163
+ const queryParams = new URLSearchParams();
164
+ queryParams.append("tokens", params.tokens.join(","));
165
+ queryParams.append("chains", params.chains.join(","));
166
+ const response = yield this.get(`${this.apiPrefix}/${walletLocator}/balances?${queryParams.toString()}`, {
167
+ headers: this.headers
168
+ });
169
+ return response.json();
170
+ });
171
+ }
172
+ fundWallet(walletLocator, params) {
173
+ return __async(this, null, function* () {
174
+ if (this.environment === APIKeyEnvironmentPrefix.PRODUCTION) {
175
+ throw new Error("Funding wallets is only supported in staging environment");
176
+ }
177
+ const response = yield this.post(`api/v1-alpha2/wallets/${walletLocator}/balances`, {
178
+ body: JSON.stringify(params),
179
+ headers: this.headers
180
+ });
181
+ return response.json();
182
+ });
183
+ }
184
+ registerSigner(walletLocator, params) {
185
+ return __async(this, null, function* () {
186
+ const response = yield this.post(`${this.apiPrefix}/${walletLocator}/signers`, {
187
+ body: JSON.stringify(params),
188
+ headers: this.headers
189
+ });
190
+ return response.json();
191
+ });
192
+ }
193
+ getSigner(walletLocator, signer) {
194
+ return __async(this, null, function* () {
195
+ const response = yield this.get(`${this.apiPrefix}/${walletLocator}/signers/${signer}`, {
196
+ headers: this.headers
197
+ });
198
+ return response.json();
199
+ });
200
+ }
201
+ send(walletLocator, tokenLocator, params) {
202
+ return __async(this, null, function* () {
203
+ walletsLogger.info("wallets.api.send", {
204
+ walletLocator,
205
+ tokenLocator,
206
+ recipient: params.recipient
207
+ });
208
+ const response = yield this.post(`${this.apiPrefix}/${walletLocator}/tokens/${tokenLocator}/transfers`, {
209
+ body: JSON.stringify(params),
210
+ headers: this.headers
211
+ });
212
+ const result = yield response.json();
213
+ if ("error" in result) {
214
+ walletsLogger.error("wallets.api.send.error", {
215
+ walletLocator,
216
+ tokenLocator,
217
+ error: result.error
218
+ });
219
+ } else if ("id" in result) {
220
+ walletsLogger.info("wallets.api.send.success", {
221
+ walletLocator,
222
+ transactionId: result.id
223
+ });
224
+ }
225
+ return result;
226
+ });
227
+ }
228
+ get isServerSide() {
229
+ return this.parsedAPIKey.usageOrigin === APIKeyUsageOrigin.SERVER;
230
+ }
231
+ get environment() {
232
+ if (!this.parsedAPIKey.isValid) {
233
+ throw new InvalidApiKeyError("Invalid API key");
234
+ }
235
+ return this.parsedAPIKey.environment;
236
+ }
237
+ get headers() {
238
+ const headers = {
239
+ "Content-Type": "application/json"
240
+ };
241
+ return headers;
242
+ }
243
+ };
244
+
245
+ export {
246
+ ApiClient
247
+ };
@@ -0,0 +1,63 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
4
+
5
+ // src/signers/evm-external-wallet.ts
6
+ var EVMExternalWalletSigner = class {
7
+ constructor(config) {
8
+ this.config = config;
9
+ this.type = "external-wallet";
10
+ if (config.address == null) {
11
+ throw new Error("Please provide an address for the External Wallet Signer");
12
+ }
13
+ this._address = config.address;
14
+ this.provider = config.provider;
15
+ this.viemAccount = config.viemAccount;
16
+ }
17
+ address() {
18
+ return this._address;
19
+ }
20
+ locator() {
21
+ return this.config.locator;
22
+ }
23
+ signMessage(message) {
24
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
25
+ var _a;
26
+ if (this.provider != null) {
27
+ const signature = yield this.provider.request({
28
+ method: "personal_sign",
29
+ params: [message, this._address]
30
+ });
31
+ if (signature == null) {
32
+ throw new Error(
33
+ "[EVMExternalWalletSigner] Failed to sign message: EIP1193 provider signMessage returned null"
34
+ );
35
+ }
36
+ return { signature };
37
+ }
38
+ if (((_a = this.viemAccount) == null ? void 0 : _a.signMessage) != null) {
39
+ const signature = yield this.viemAccount.signMessage({
40
+ message: {
41
+ raw: message
42
+ }
43
+ });
44
+ if (signature == null) {
45
+ throw new Error(
46
+ "[EVMExternalWalletSigner] Failed to sign message: Viem account signMessage returned null"
47
+ );
48
+ }
49
+ return { signature };
50
+ }
51
+ throw new Error("No signer provider or viem account provided");
52
+ });
53
+ }
54
+ signTransaction(transaction) {
55
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
56
+ return yield this.signMessage(transaction);
57
+ });
58
+ }
59
+ };
60
+
61
+
62
+
63
+ exports.EVMExternalWalletSigner = EVMExternalWalletSigner;
@@ -0,0 +1,59 @@
1
+ import {
2
+ __async
3
+ } from "./chunk-FPMW7Q5O.js";
4
+
5
+ // src/signers/non-custodial/ncs-iframe-manager.ts
6
+ import { IFrameWindow, SignersWindowTransport } from "@crossmint/client-sdk-window";
7
+ import { environmentUrlConfig, signerInboundEvents, signerOutboundEvents } from "@crossmint/client-signers";
8
+ var NcsIframeManager = class {
9
+ constructor(config) {
10
+ this.config = config;
11
+ this.handshakeParent = null;
12
+ }
13
+ initialize() {
14
+ return __async(this, null, function* () {
15
+ if (this.handshakeParent) {
16
+ return this.handshakeParent;
17
+ }
18
+ const iframeUrl = new URL(environmentUrlConfig[this.config.environment]);
19
+ iframeUrl.searchParams.set("targetOrigin", window.location.origin);
20
+ const iframeElement = yield this.createInvisibleIFrame(iframeUrl.toString());
21
+ this.handshakeParent = yield IFrameWindow.init(
22
+ iframeElement,
23
+ {
24
+ targetOrigin: iframeUrl.origin,
25
+ incomingEvents: signerOutboundEvents,
26
+ outgoingEvents: signerInboundEvents
27
+ },
28
+ SignersWindowTransport
29
+ );
30
+ yield this.handshakeParent.handshakeWithChild();
31
+ return this.handshakeParent;
32
+ });
33
+ }
34
+ createInvisibleIFrame(url) {
35
+ return __async(this, null, function* () {
36
+ const iframe = document.createElement("iframe");
37
+ iframe.src = url;
38
+ Object.assign(iframe.style, {
39
+ position: "absolute",
40
+ opacity: "0",
41
+ pointerEvents: "none",
42
+ width: "0",
43
+ height: "0",
44
+ border: "none",
45
+ top: "-9999px",
46
+ left: "-9999px"
47
+ });
48
+ return new Promise((resolve, reject) => {
49
+ iframe.onload = () => resolve(iframe);
50
+ iframe.onerror = () => reject(new Error("Failed to load iframe content"));
51
+ document.body.appendChild(iframe);
52
+ });
53
+ });
54
+ }
55
+ };
56
+
57
+ export {
58
+ NcsIframeManager
59
+ };
@@ -0,0 +1,36 @@
1
+ import {
2
+ __async
3
+ } from "./chunk-FPMW7Q5O.js";
4
+
5
+ // src/signers/evm-api-key.ts
6
+ var EVMApiKeySigner = class {
7
+ constructor(config) {
8
+ this.config = config;
9
+ this.type = "api-key";
10
+ }
11
+ locator() {
12
+ return this.config.locator;
13
+ }
14
+ signMessage() {
15
+ return __async(this, null, function* () {
16
+ return yield Promise.reject(
17
+ new Error(
18
+ "API key signers do not support direct message signing - signatures are handled automatically by the backend"
19
+ )
20
+ );
21
+ });
22
+ }
23
+ signTransaction() {
24
+ return __async(this, null, function* () {
25
+ return yield Promise.reject(
26
+ new Error(
27
+ "API key signers do not support direct transaction signing - transaction are handled automatically by the backend"
28
+ )
29
+ );
30
+ });
31
+ }
32
+ };
33
+
34
+ export {
35
+ EVMApiKeySigner
36
+ };
@@ -0,0 +1,289 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkTK3EUCQ4cjs = require('./chunk-TK3EUCQ4.cjs');
4
+
5
+
6
+ var _chunkRHR6P2KPcjs = require('./chunk-RHR6P2KP.cjs');
7
+
8
+
9
+
10
+
11
+ var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
12
+
13
+ // src/signers/non-custodial/ncs-signer.ts
14
+ var _commonsdkbase = require('@crossmint/common-sdk-base');
15
+ var NonCustodialSigner = class {
16
+ constructor(config) {
17
+ this.config = config;
18
+ this._needsAuth = true;
19
+ this._authPromise = null;
20
+ this._initializationPromise = null;
21
+ if (typeof window !== "undefined") {
22
+ this.initialize();
23
+ }
24
+ this.type = this.config.type;
25
+ }
26
+ locator() {
27
+ return this.config.locator;
28
+ }
29
+ address() {
30
+ return this.config.address;
31
+ }
32
+ initialize() {
33
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
34
+ if (this.config.clientTEEConnection == null) {
35
+ const parsedAPIKey = _commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);
36
+ if (!parsedAPIKey.isValid) {
37
+ throw new Error("Invalid API key");
38
+ }
39
+ const iframeManager = new (0, _chunkTK3EUCQ4cjs.NcsIframeManager)({ environment: parsedAPIKey.environment });
40
+ this.config.clientTEEConnection = yield iframeManager.initialize();
41
+ }
42
+ });
43
+ }
44
+ getTEEConnection() {
45
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
46
+ if (this.config.clientTEEConnection == null) {
47
+ if (this._initializationPromise) {
48
+ yield this._initializationPromise;
49
+ return this.config.clientTEEConnection;
50
+ }
51
+ this._initializationPromise = this.initializeTEEConnection();
52
+ try {
53
+ yield this._initializationPromise;
54
+ } finally {
55
+ this._initializationPromise = null;
56
+ }
57
+ }
58
+ return this.config.clientTEEConnection;
59
+ });
60
+ }
61
+ initializeTEEConnection() {
62
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
63
+ console.warn("TEE connection is not initialized, initializing now...");
64
+ const parsedAPIKey = _commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);
65
+ if (!parsedAPIKey.isValid) {
66
+ throw new Error("Invalid API key");
67
+ }
68
+ const iframeManager = new (0, _chunkTK3EUCQ4cjs.NcsIframeManager)({ environment: parsedAPIKey.environment });
69
+ this.config.clientTEEConnection = yield iframeManager.initialize();
70
+ if (this.config.clientTEEConnection == null) {
71
+ throw new Error("Failed to initialize TEE connection");
72
+ }
73
+ console.log("TEE connection initialized successfully");
74
+ });
75
+ }
76
+ handleAuthRequired() {
77
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
78
+ var _a, _b;
79
+ const clientTEEConnection = yield this.getTEEConnection();
80
+ if (this.config.onAuthRequired == null) {
81
+ throw new Error(
82
+ `${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 */ }`
83
+ );
84
+ }
85
+ const signerResponse = yield clientTEEConnection.sendAction({
86
+ event: "request:get-status",
87
+ responseEvent: "response:get-status",
88
+ data: {
89
+ authData: {
90
+ jwt: (_b = (_a = this.config.crossmint.experimental_customAuth) == null ? void 0 : _a.jwt) != null ? _b : "",
91
+ apiKey: this.config.crossmint.apiKey
92
+ }
93
+ },
94
+ options: _chunkG5NYLGM5cjs.__spreadProps.call(void 0, _chunkG5NYLGM5cjs.__spreadValues.call(void 0, {}, DEFAULT_EVENT_OPTIONS), {
95
+ maxRetries: 5
96
+ })
97
+ });
98
+ if ((signerResponse == null ? void 0 : signerResponse.status) !== "success") {
99
+ throw new Error(signerResponse == null ? void 0 : signerResponse.error);
100
+ }
101
+ if (signerResponse.signerStatus === "ready") {
102
+ this._needsAuth = false;
103
+ return;
104
+ } else {
105
+ this._needsAuth = true;
106
+ }
107
+ const { promise, resolve, reject } = this.createAuthPromise();
108
+ this._authPromise = { promise, resolve, reject };
109
+ if (this.config.onAuthRequired) {
110
+ try {
111
+ yield this.config.onAuthRequired(
112
+ this._needsAuth,
113
+ () => this.sendMessageWithOtp(),
114
+ (otp) => this.verifyOtp(otp),
115
+ () => _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
116
+ this._needsAuth = false;
117
+ if (this.config.onAuthRequired != null) {
118
+ yield this.config.onAuthRequired(
119
+ this._needsAuth,
120
+ () => this.sendMessageWithOtp(),
121
+ (otp) => this.verifyOtp(otp),
122
+ () => {
123
+ var _a2;
124
+ return (_a2 = this._authPromise) == null ? void 0 : _a2.reject(new (0, _chunkRHR6P2KPcjs.AuthRejectedError)());
125
+ }
126
+ );
127
+ }
128
+ reject(new (0, _chunkRHR6P2KPcjs.AuthRejectedError)());
129
+ })
130
+ );
131
+ } catch (error) {
132
+ reject(error);
133
+ }
134
+ }
135
+ try {
136
+ yield promise;
137
+ } catch (error) {
138
+ throw error;
139
+ }
140
+ });
141
+ }
142
+ ensureAuthenticated() {
143
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
144
+ yield this.handleAuthRequired();
145
+ });
146
+ }
147
+ getJwtOrThrow() {
148
+ var _a;
149
+ const jwt = (_a = this.config.crossmint.experimental_customAuth) == null ? void 0 : _a.jwt;
150
+ if (jwt == null) {
151
+ throw new Error("JWT is required");
152
+ }
153
+ return jwt;
154
+ }
155
+ createAuthPromise() {
156
+ let resolvePromise;
157
+ let rejectPromise;
158
+ const promise = new Promise((resolve, reject) => {
159
+ resolvePromise = resolve;
160
+ rejectPromise = reject;
161
+ });
162
+ return { promise, resolve: resolvePromise, reject: rejectPromise };
163
+ }
164
+ sendMessageWithOtp() {
165
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
166
+ var _a, _b, _c;
167
+ const handshakeParent = yield this.getTEEConnection();
168
+ const authId = this.getAuthId();
169
+ const response = yield handshakeParent.sendAction({
170
+ event: "request:start-onboarding",
171
+ responseEvent: "response:start-onboarding",
172
+ data: {
173
+ authData: {
174
+ jwt: (_b = (_a = this.config.crossmint.experimental_customAuth) == null ? void 0 : _a.jwt) != null ? _b : "",
175
+ apiKey: this.config.crossmint.apiKey
176
+ },
177
+ data: { authId }
178
+ },
179
+ options: _chunkG5NYLGM5cjs.__spreadProps.call(void 0, _chunkG5NYLGM5cjs.__spreadValues.call(void 0, {}, DEFAULT_EVENT_OPTIONS), {
180
+ maxRetries: 3
181
+ })
182
+ });
183
+ if ((response == null ? void 0 : response.status) === "success" && response.signerStatus === "ready") {
184
+ this._needsAuth = false;
185
+ return;
186
+ }
187
+ if ((response == null ? void 0 : response.status) === "error") {
188
+ console.error("[sendMessageWithOtp] Failed to send OTP:", response);
189
+ (_c = this._authPromise) == null ? void 0 : _c.reject(new Error(response.error || "Failed to initiate OTP process."));
190
+ }
191
+ });
192
+ }
193
+ getAuthId() {
194
+ if (this.config.type === "email") {
195
+ return `email:${this.config.email}`;
196
+ }
197
+ return `phone:${this.config.phone}`;
198
+ }
199
+ verifyOtp(encryptedOtp) {
200
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
201
+ var _a, _b, _c, _d, _e;
202
+ let response;
203
+ try {
204
+ const handshakeParent = yield this.getTEEConnection();
205
+ response = yield handshakeParent.sendAction({
206
+ event: "request:complete-onboarding",
207
+ responseEvent: "response:complete-onboarding",
208
+ data: {
209
+ authData: {
210
+ jwt: (_b = (_a = this.config.crossmint.experimental_customAuth) == null ? void 0 : _a.jwt) != null ? _b : "",
211
+ apiKey: this.config.crossmint.apiKey
212
+ },
213
+ data: {
214
+ onboardingAuthentication: { encryptedOtp }
215
+ }
216
+ },
217
+ options: _chunkG5NYLGM5cjs.__spreadProps.call(void 0, _chunkG5NYLGM5cjs.__spreadValues.call(void 0, {}, DEFAULT_EVENT_OPTIONS), {
218
+ maxRetries: 3
219
+ })
220
+ });
221
+ } catch (err) {
222
+ console.error("[verifyOtp] Error sending OTP validation request:", err);
223
+ this._needsAuth = true;
224
+ (_c = this._authPromise) == null ? void 0 : _c.reject(err);
225
+ throw err;
226
+ }
227
+ if ((response == null ? void 0 : response.status) === "success") {
228
+ this._needsAuth = false;
229
+ if (this.config.onAuthRequired != null) {
230
+ yield this.config.onAuthRequired(
231
+ this._needsAuth,
232
+ () => this.sendMessageWithOtp(),
233
+ (otp) => this.verifyOtp(otp),
234
+ () => {
235
+ var _a2;
236
+ return (_a2 = this._authPromise) == null ? void 0 : _a2.reject(new (0, _chunkRHR6P2KPcjs.AuthRejectedError)());
237
+ }
238
+ );
239
+ }
240
+ (_d = this._authPromise) == null ? void 0 : _d.resolve();
241
+ return;
242
+ }
243
+ console.error("[verifyOtp] Failed to validate OTP:", JSON.stringify(response, null, 2));
244
+ this._needsAuth = true;
245
+ const errorMessage = (response == null ? void 0 : response.status) === "error" ? response.error : "Failed to validate encrypted OTP";
246
+ const error = new Error(errorMessage);
247
+ (_e = this._authPromise) == null ? void 0 : _e.reject(error);
248
+ throw error;
249
+ });
250
+ }
251
+ /**
252
+ * Export the private key for this signer
253
+ * @throws {Error} If signer is not authenticated
254
+ */
255
+ _exportPrivateKey(exportTEEConnection) {
256
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
257
+ yield this.handleAuthRequired();
258
+ const jwt = this.getJwtOrThrow();
259
+ const { scheme, encoding } = this.getChainKeyParams();
260
+ const response = yield exportTEEConnection.sendAction({
261
+ event: "request:export-signer",
262
+ responseEvent: "response:export-signer",
263
+ data: {
264
+ authData: {
265
+ jwt,
266
+ apiKey: this.config.crossmint.apiKey
267
+ },
268
+ data: {
269
+ scheme,
270
+ encoding
271
+ }
272
+ },
273
+ options: DEFAULT_EVENT_OPTIONS
274
+ });
275
+ if ((response == null ? void 0 : response.status) === "error") {
276
+ throw new Error(response.error || "Failed to export private key");
277
+ }
278
+ });
279
+ }
280
+ };
281
+ var DEFAULT_EVENT_OPTIONS = {
282
+ timeoutMs: 1e4,
283
+ intervalMs: 5e3
284
+ };
285
+
286
+
287
+
288
+
289
+ exports.NonCustodialSigner = NonCustodialSigner; exports.DEFAULT_EVENT_OPTIONS = DEFAULT_EVENT_OPTIONS;