@crossmint/wallets-sdk 0.18.2 → 0.18.4

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 (191) hide show
  1. package/dist/api/client.cjs +9 -1
  2. package/dist/api/client.d.cts +4 -4
  3. package/dist/api/client.d.ts +4 -4
  4. package/dist/api/client.js +9 -1
  5. package/dist/api/gen/client.gen.cjs +7 -1
  6. package/dist/api/gen/client.gen.js +7 -1
  7. package/dist/api/gen/index.cjs +179 -1
  8. package/dist/api/gen/index.js +179 -1
  9. package/dist/api/gen/sdk.gen.cjs +178 -1
  10. package/dist/api/gen/sdk.gen.js +178 -1
  11. package/dist/api/gen/types.gen.js +1 -1
  12. package/dist/api/index.cjs +11 -1
  13. package/dist/api/index.d.cts +1 -1
  14. package/dist/api/index.d.ts +1 -1
  15. package/dist/api/index.js +11 -1
  16. package/dist/api/types.d.cts +4 -2
  17. package/dist/api/types.d.ts +4 -2
  18. package/dist/api/types.js +1 -1
  19. package/dist/chains/chains.cjs +9 -1
  20. package/dist/chains/chains.js +9 -1
  21. package/dist/chains/definitions/story.cjs +7 -1
  22. package/dist/chains/definitions/story.js +7 -1
  23. package/dist/chains/definitions/storyTestnet.cjs +7 -1
  24. package/dist/chains/definitions/storyTestnet.js +7 -1
  25. package/dist/chunk-2DHIAP2S.js +58 -0
  26. package/dist/chunk-2T5HHKUI.js +19 -0
  27. package/dist/chunk-2VOEAAFA.cjs +200 -0
  28. package/dist/chunk-3U6UAYOV.js +25 -0
  29. package/dist/chunk-4BMNDPJ4.cjs +92 -0
  30. package/dist/chunk-4QGBVHV3.js +629 -0
  31. package/dist/chunk-55V4VMTX.cjs +25 -0
  32. package/dist/chunk-5H5YHSCK.js +200 -0
  33. package/dist/chunk-7ECQJFYM.cjs +63 -0
  34. package/dist/chunk-7GHQBCRV.cjs +57 -0
  35. package/dist/chunk-7JFVG4IY.js +59 -0
  36. package/dist/chunk-7QL5JVK4.js +262 -0
  37. package/dist/chunk-AJCWEEWH.js +73 -0
  38. package/dist/chunk-AL77JANE.js +36 -0
  39. package/dist/chunk-BAHU3KZE.cjs +75 -0
  40. package/dist/chunk-BAULM7A2.js +289 -0
  41. package/dist/chunk-BFAU2NL6.js +175 -0
  42. package/dist/chunk-BSC55MYK.cjs +43 -0
  43. package/dist/chunk-CHGPNMRL.cjs +36 -0
  44. package/dist/chunk-CN2GVFBU.cjs +138 -0
  45. package/dist/chunk-COVOGZ4S.js +80 -0
  46. package/dist/chunk-DPERJZBG.js +63 -0
  47. package/dist/chunk-DQCXGBZM.js +59 -0
  48. package/dist/chunk-E4LJ7252.cjs +289 -0
  49. package/dist/chunk-EM6H7EUU.cjs +80 -0
  50. package/dist/chunk-EYJQSDDI.js +43 -0
  51. package/dist/chunk-FAGFW4AR.js +16 -0
  52. package/dist/chunk-FK23BDCU.js +87 -0
  53. package/dist/chunk-FPMW7Q5O.js +55 -0
  54. package/dist/chunk-G5NYLGM5.cjs +55 -0
  55. package/dist/chunk-HHDDI3CS.js +75 -0
  56. package/dist/chunk-HNRM45KF.cjs +87 -0
  57. package/dist/chunk-JICSSJOK.js +57 -0
  58. package/dist/chunk-KS63YEQ4.js +138 -0
  59. package/dist/chunk-KT3CVXFG.js +9 -0
  60. package/dist/chunk-LLFD22UQ.cjs +36 -0
  61. package/dist/chunk-MPGPBFUZ.cjs +16 -0
  62. package/dist/chunk-MYKPHXUR.cjs +629 -0
  63. package/dist/chunk-MZBFXUHT.js +63 -0
  64. package/dist/chunk-NIBKCMQ2.cjs +19 -0
  65. package/dist/chunk-OD5RGQ4Z.js +92 -0
  66. package/dist/chunk-PSPNZEG4.cjs +175 -0
  67. package/dist/chunk-R2OY54EJ.cjs +59 -0
  68. package/dist/chunk-RHR6P2KP.cjs +15 -0
  69. package/dist/chunk-RSPJPRQW.cjs +262 -0
  70. package/dist/chunk-RTRDZB52.js +778 -0
  71. package/dist/chunk-SG7WIZLK.cjs +63 -0
  72. package/dist/chunk-SGINWAB6.js +155 -0
  73. package/dist/chunk-TK3EUCQ4.cjs +59 -0
  74. package/dist/chunk-V3QJQUT7.cjs +778 -0
  75. package/dist/chunk-WC7T2CR4.js +44 -0
  76. package/dist/chunk-WJUPOCKJ.js +15 -0
  77. package/dist/chunk-XC2V34TS.cjs +155 -0
  78. package/dist/chunk-XH3ARVJG.cjs +58 -0
  79. package/dist/chunk-YBA7WO32.cjs +44 -0
  80. package/dist/chunk-YOJETSLN.cjs +73 -0
  81. package/dist/chunk-ZT7EGOCI.cjs +9 -0
  82. package/dist/chunk-ZTGRDOOH.js +36 -0
  83. package/dist/index.cjs +55 -1
  84. package/dist/index.js +55 -1
  85. package/dist/sdk.cjs +31 -1
  86. package/dist/sdk.js +31 -1
  87. package/dist/signers/evm-api-key.cjs +7 -1
  88. package/dist/signers/evm-api-key.js +7 -1
  89. package/dist/signers/evm-external-wallet.cjs +7 -1
  90. package/dist/signers/evm-external-wallet.js +7 -1
  91. package/dist/signers/index.cjs +21 -1
  92. package/dist/signers/index.js +21 -1
  93. package/dist/signers/non-custodial/index.cjs +24 -1
  94. package/dist/signers/non-custodial/index.js +24 -1
  95. package/dist/signers/non-custodial/ncs-evm-signer.cjs +10 -1
  96. package/dist/signers/non-custodial/ncs-evm-signer.js +10 -1
  97. package/dist/signers/non-custodial/ncs-iframe-manager.cjs +7 -1
  98. package/dist/signers/non-custodial/ncs-iframe-manager.js +7 -1
  99. package/dist/signers/non-custodial/ncs-signer.cjs +11 -1
  100. package/dist/signers/non-custodial/ncs-signer.js +11 -1
  101. package/dist/signers/non-custodial/ncs-solana-signer.cjs +10 -1
  102. package/dist/signers/non-custodial/ncs-solana-signer.js +10 -1
  103. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +10 -1
  104. package/dist/signers/non-custodial/ncs-stellar-signer.js +10 -1
  105. package/dist/signers/passkey.cjs +7 -1
  106. package/dist/signers/passkey.js +7 -1
  107. package/dist/signers/solana-api-key.cjs +7 -1
  108. package/dist/signers/solana-api-key.js +7 -1
  109. package/dist/signers/solana-external-wallet.cjs +8 -1
  110. package/dist/signers/solana-external-wallet.js +8 -1
  111. package/dist/signers/stellar-external-wallet.cjs +7 -1
  112. package/dist/signers/stellar-external-wallet.js +7 -1
  113. package/dist/signers/types.cjs +9 -1
  114. package/dist/signers/types.js +9 -1
  115. package/dist/utils/constants.cjs +13 -1
  116. package/dist/utils/constants.js +13 -1
  117. package/dist/utils/errors.cjs +55 -1
  118. package/dist/utils/errors.js +55 -1
  119. package/dist/utils/signer-validation.cjs +8 -1
  120. package/dist/utils/signer-validation.js +8 -1
  121. package/dist/wallets/evm.cjs +20 -1
  122. package/dist/wallets/evm.js +20 -1
  123. package/dist/wallets/solana.cjs +18 -1
  124. package/dist/wallets/solana.js +18 -1
  125. package/dist/wallets/stellar.cjs +17 -1
  126. package/dist/wallets/stellar.js +17 -1
  127. package/dist/wallets/wallet-factory.cjs +25 -1
  128. package/dist/wallets/wallet-factory.js +25 -1
  129. package/dist/wallets/wallet.cjs +16 -1
  130. package/dist/wallets/wallet.d.cts +12 -1
  131. package/dist/wallets/wallet.d.ts +12 -1
  132. package/dist/wallets/wallet.js +16 -1
  133. package/package.json +4 -4
  134. package/dist/chunk-23ZHV3VD.js +0 -1
  135. package/dist/chunk-2SHDBC47.js +0 -1
  136. package/dist/chunk-2XVV7Z43.cjs +0 -1
  137. package/dist/chunk-2YH3NVVK.cjs +0 -1
  138. package/dist/chunk-3APSOOE3.js +0 -1
  139. package/dist/chunk-3IZNWAZE.cjs +0 -1
  140. package/dist/chunk-4AJT6I6Q.js +0 -1
  141. package/dist/chunk-4KXOWU5E.cjs +0 -1
  142. package/dist/chunk-5M7IRODB.js +0 -1
  143. package/dist/chunk-5QIW67NU.cjs +0 -1
  144. package/dist/chunk-6PVKL5RC.js +0 -1
  145. package/dist/chunk-73RCBQG5.js +0 -1
  146. package/dist/chunk-7JIPYRKX.js +0 -1
  147. package/dist/chunk-7WKKOG6H.cjs +0 -3
  148. package/dist/chunk-BQZES4ST.js +0 -1
  149. package/dist/chunk-BW7YYVZE.js +0 -1
  150. package/dist/chunk-C3T63EC7.cjs +0 -1
  151. package/dist/chunk-CVZ3RNWV.cjs +0 -1
  152. package/dist/chunk-GEY574TH.cjs +0 -1
  153. package/dist/chunk-H4T4IXCF.js +0 -1
  154. package/dist/chunk-HJ5EDMTA.js +0 -1
  155. package/dist/chunk-HMPMFEPS.cjs +0 -1
  156. package/dist/chunk-HPHVJ6BA.cjs +0 -1
  157. package/dist/chunk-HRSVFJND.cjs +0 -1
  158. package/dist/chunk-IGBQEAD5.js +0 -1
  159. package/dist/chunk-IR5WN6FQ.cjs +0 -1
  160. package/dist/chunk-JUSY5XEE.js +0 -1
  161. package/dist/chunk-KHSWQE6W.js +0 -1
  162. package/dist/chunk-KKQBZXFE.js +0 -1
  163. package/dist/chunk-KO6QYKDX.cjs +0 -1
  164. package/dist/chunk-KRV3IXJU.cjs +0 -1
  165. package/dist/chunk-L5L64FWM.js +0 -1
  166. package/dist/chunk-LW6JSI4J.js +0 -1
  167. package/dist/chunk-M4TOGGLV.cjs +0 -1
  168. package/dist/chunk-MQP5VZCA.cjs +0 -1
  169. package/dist/chunk-NEJPPLYW.cjs +0 -1
  170. package/dist/chunk-NIKULSJK.cjs +0 -1
  171. package/dist/chunk-NT4EICOB.cjs +0 -1
  172. package/dist/chunk-O4FVTK7X.cjs +0 -1
  173. package/dist/chunk-P6JJHAAV.js +0 -1
  174. package/dist/chunk-PONCGT2H.cjs +0 -1
  175. package/dist/chunk-PSXRNSOE.js +0 -1
  176. package/dist/chunk-R6VFNNAA.js +0 -3
  177. package/dist/chunk-RJZV72YF.js +0 -1
  178. package/dist/chunk-S3DYQVRD.js +0 -1
  179. package/dist/chunk-SHVVA55W.js +0 -1
  180. package/dist/chunk-STYSP6KL.cjs +0 -1
  181. package/dist/chunk-UBOWSXW3.js +0 -1
  182. package/dist/chunk-UNBXKCNN.js +0 -1
  183. package/dist/chunk-VXFSSEA4.js +0 -1
  184. package/dist/chunk-VY634F3J.js +0 -1
  185. package/dist/chunk-WQP2FSVI.js +0 -1
  186. package/dist/chunk-WYYAPI4G.cjs +0 -1
  187. package/dist/chunk-WZFHEUWT.cjs +0 -1
  188. package/dist/chunk-XALFCQKD.cjs +0 -1
  189. package/dist/chunk-XIRT2EZN.cjs +0 -1
  190. package/dist/chunk-YWPTI2QO.cjs +0 -1
  191. package/dist/chunk-YZ4HRYSL.cjs +0 -1
@@ -0,0 +1,73 @@
1
+ import {
2
+ DEFAULT_EVENT_OPTIONS,
3
+ NonCustodialSigner
4
+ } from "./chunk-BAULM7A2.js";
5
+ import {
6
+ __async
7
+ } from "./chunk-FPMW7Q5O.js";
8
+
9
+ // src/signers/non-custodial/ncs-stellar-signer.ts
10
+ var StellarNonCustodialSigner = class _StellarNonCustodialSigner extends NonCustodialSigner {
11
+ constructor(config) {
12
+ super(config);
13
+ }
14
+ signMessage() {
15
+ return __async(this, null, function* () {
16
+ return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"));
17
+ });
18
+ }
19
+ signTransaction(payload) {
20
+ return __async(this, null, function* () {
21
+ var _a;
22
+ yield this.handleAuthRequired();
23
+ const jwt = this.getJwtOrThrow();
24
+ const res = yield (_a = this.config.clientTEEConnection) == null ? void 0 : _a.sendAction({
25
+ event: "request:sign",
26
+ responseEvent: "response:sign",
27
+ data: {
28
+ authData: {
29
+ jwt,
30
+ apiKey: this.config.crossmint.apiKey
31
+ },
32
+ data: {
33
+ keyType: "ed25519",
34
+ bytes: payload,
35
+ encoding: "base64"
36
+ }
37
+ },
38
+ options: DEFAULT_EVENT_OPTIONS
39
+ });
40
+ if ((res == null ? void 0 : res.status) === "error") {
41
+ throw new Error(res.error);
42
+ }
43
+ if ((res == null ? void 0 : res.signature) == null) {
44
+ throw new Error("Failed to sign transaction");
45
+ }
46
+ _StellarNonCustodialSigner.verifyPublicKeyFormat(res.publicKey);
47
+ if (res.signature.encoding !== "base64") {
48
+ throw new Error("Wrong encoding for signature. Expected base64, got " + res.signature.encoding);
49
+ }
50
+ return { signature: res.signature.bytes };
51
+ });
52
+ }
53
+ static verifyPublicKeyFormat(publicKey) {
54
+ if (publicKey == null) {
55
+ throw new Error("No public key found");
56
+ }
57
+ if (publicKey.encoding !== "base64" || publicKey.keyType !== "ed25519" || publicKey.bytes == null) {
58
+ throw new Error(
59
+ "Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: " + JSON.stringify(publicKey)
60
+ );
61
+ }
62
+ }
63
+ getChainKeyParams() {
64
+ return {
65
+ scheme: "ed25519",
66
+ encoding: "strkey"
67
+ };
68
+ }
69
+ };
70
+
71
+ export {
72
+ StellarNonCustodialSigner
73
+ };
@@ -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,75 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
+
3
+
4
+ var _chunkE4LJ7252cjs = require('./chunk-E4LJ7252.cjs');
5
+
6
+
7
+ var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
8
+
9
+ // src/signers/non-custodial/ncs-solana-signer.ts
10
+ var _web3js = require('@solana/web3.js');
11
+ var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);
12
+ var SolanaNonCustodialSigner = class _SolanaNonCustodialSigner extends _chunkE4LJ7252cjs.NonCustodialSigner {
13
+ constructor(config) {
14
+ super(config);
15
+ }
16
+ signMessage() {
17
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
18
+ return yield Promise.reject(new Error("signMessage method not implemented for email signer"));
19
+ });
20
+ }
21
+ signTransaction(transaction) {
22
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
23
+ var _a;
24
+ yield this.handleAuthRequired();
25
+ const jwt = this.getJwtOrThrow();
26
+ const transactionBytes = _bs582.default.decode(transaction);
27
+ const deserializedTransaction = _web3js.VersionedTransaction.deserialize(transactionBytes);
28
+ const messageData = deserializedTransaction.message.serialize();
29
+ const res = yield (_a = this.config.clientTEEConnection) == null ? void 0 : _a.sendAction({
30
+ event: "request:sign",
31
+ responseEvent: "response:sign",
32
+ data: {
33
+ authData: {
34
+ jwt,
35
+ apiKey: this.config.crossmint.apiKey
36
+ },
37
+ data: {
38
+ keyType: "ed25519",
39
+ bytes: _bs582.default.encode(messageData),
40
+ encoding: "base58"
41
+ }
42
+ },
43
+ options: _chunkE4LJ7252cjs.DEFAULT_EVENT_OPTIONS
44
+ });
45
+ if ((res == null ? void 0 : res.status) === "error") {
46
+ throw new Error(res.error);
47
+ }
48
+ if ((res == null ? void 0 : res.signature) == null) {
49
+ throw new Error("Failed to sign transaction");
50
+ }
51
+ _SolanaNonCustodialSigner.verifyPublicKeyFormat(res.publicKey);
52
+ return { signature: res.signature.bytes };
53
+ });
54
+ }
55
+ static verifyPublicKeyFormat(publicKey) {
56
+ if (publicKey == null) {
57
+ throw new Error("No public key found");
58
+ }
59
+ if (publicKey.encoding !== "base58" || publicKey.keyType !== "ed25519" || publicKey.bytes == null) {
60
+ throw new Error(
61
+ "Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: " + JSON.stringify(publicKey)
62
+ );
63
+ }
64
+ }
65
+ getChainKeyParams() {
66
+ return {
67
+ scheme: "ed25519",
68
+ encoding: "base58"
69
+ };
70
+ }
71
+ };
72
+
73
+
74
+
75
+ exports.SolanaNonCustodialSigner = SolanaNonCustodialSigner;
@@ -0,0 +1,289 @@
1
+ import {
2
+ NcsIframeManager
3
+ } from "./chunk-7JFVG4IY.js";
4
+ import {
5
+ AuthRejectedError
6
+ } from "./chunk-WJUPOCKJ.js";
7
+ import {
8
+ __async,
9
+ __spreadProps,
10
+ __spreadValues
11
+ } from "./chunk-FPMW7Q5O.js";
12
+
13
+ // src/signers/non-custodial/ncs-signer.ts
14
+ import { validateAPIKey } from "@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 __async(this, null, function* () {
34
+ if (this.config.clientTEEConnection == null) {
35
+ const parsedAPIKey = validateAPIKey(this.config.crossmint.apiKey);
36
+ if (!parsedAPIKey.isValid) {
37
+ throw new Error("Invalid API key");
38
+ }
39
+ const iframeManager = new NcsIframeManager({ environment: parsedAPIKey.environment });
40
+ this.config.clientTEEConnection = yield iframeManager.initialize();
41
+ }
42
+ });
43
+ }
44
+ getTEEConnection() {
45
+ return __async(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 __async(this, null, function* () {
63
+ console.warn("TEE connection is not initialized, initializing now...");
64
+ const parsedAPIKey = validateAPIKey(this.config.crossmint.apiKey);
65
+ if (!parsedAPIKey.isValid) {
66
+ throw new Error("Invalid API key");
67
+ }
68
+ const iframeManager = new 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 __async(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: __spreadProps(__spreadValues({}, 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
+ () => __async(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 AuthRejectedError());
125
+ }
126
+ );
127
+ }
128
+ reject(new 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 __async(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 __async(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: __spreadProps(__spreadValues({}, 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 __async(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: __spreadProps(__spreadValues({}, 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 AuthRejectedError());
237
+ }
238
+ );
239
+ }
240
+ (_d = this._authPromise) == null ? void 0 : _d.resolve();
241
+ return;
242
+ }
243
+ console.error("[verifyOtp] Failed to validate OTP:", response);
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 __async(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
+ export {
287
+ NonCustodialSigner,
288
+ DEFAULT_EVENT_OPTIONS
289
+ };
@@ -0,0 +1,175 @@
1
+ import {
2
+ Wallet
3
+ } from "./chunk-4QGBVHV3.js";
4
+ import {
5
+ InvalidTypedDataError,
6
+ SignatureNotCreatedError,
7
+ TransactionNotCreatedError
8
+ } from "./chunk-SGINWAB6.js";
9
+ import {
10
+ toViemChain
11
+ } from "./chunk-KS63YEQ4.js";
12
+ import {
13
+ __async
14
+ } from "./chunk-FPMW7Q5O.js";
15
+
16
+ // src/wallets/evm.ts
17
+ import { createPublicClient, encodeFunctionData, http } from "viem";
18
+ import { isValidEvmAddress } from "@crossmint/common-sdk-base";
19
+ var EVMWallet = class _EVMWallet extends Wallet {
20
+ constructor(wallet) {
21
+ super(
22
+ {
23
+ chain: wallet.chain,
24
+ address: wallet.address,
25
+ owner: wallet.owner,
26
+ signer: wallet.signer,
27
+ options: Wallet.getOptions(wallet),
28
+ alias: wallet.alias
29
+ },
30
+ Wallet.getApiClient(wallet)
31
+ );
32
+ }
33
+ static from(wallet) {
34
+ if (!isValidEvmAddress(wallet.address)) {
35
+ throw new Error("Wallet is not an EVM wallet");
36
+ }
37
+ return new _EVMWallet(wallet);
38
+ }
39
+ sendTransaction(params) {
40
+ return __async(this, null, function* () {
41
+ var _a;
42
+ yield this.preAuthIfNeeded();
43
+ const builtTransaction = this.buildTransaction(params);
44
+ const createdTransaction = yield this.createTransaction(builtTransaction, params.options);
45
+ if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
46
+ return {
47
+ hash: void 0,
48
+ explorerLink: void 0,
49
+ transactionId: createdTransaction.id
50
+ };
51
+ }
52
+ return yield this.approveTransactionAndWait(createdTransaction.id);
53
+ });
54
+ }
55
+ signMessage(params) {
56
+ return __async(this, null, function* () {
57
+ var _a;
58
+ yield this.preAuthIfNeeded();
59
+ const signatureCreationResponse = yield this.apiClient.createSignature(this.walletLocator, {
60
+ type: "message",
61
+ params: {
62
+ message: params.message,
63
+ signer: this.signer.locator(),
64
+ chain: this.chain
65
+ }
66
+ });
67
+ if ("error" in signatureCreationResponse) {
68
+ throw new SignatureNotCreatedError(JSON.stringify(signatureCreationResponse));
69
+ }
70
+ if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
71
+ return {
72
+ signature: void 0,
73
+ signatureId: signatureCreationResponse.id
74
+ };
75
+ }
76
+ return yield this.approveSignatureAndWait(signatureCreationResponse.id);
77
+ });
78
+ }
79
+ signTypedData(params) {
80
+ return __async(this, null, function* () {
81
+ var _a;
82
+ yield this.preAuthIfNeeded();
83
+ const { domain, message, primaryType, types, chain } = params;
84
+ if (!domain || !message || !types || !chain) {
85
+ throw new InvalidTypedDataError("Invalid typed data");
86
+ }
87
+ const { name, version, chainId, verifyingContract, salt } = domain;
88
+ if (!name || !version || !chainId || !verifyingContract) {
89
+ throw new InvalidTypedDataError("Invalid typed data domain");
90
+ }
91
+ const signatureCreationResponse = yield this.apiClient.createSignature(this.walletLocator, {
92
+ type: "typed-data",
93
+ params: {
94
+ typedData: {
95
+ domain: {
96
+ name,
97
+ version,
98
+ chainId: Number(chainId),
99
+ verifyingContract,
100
+ salt
101
+ },
102
+ message,
103
+ primaryType,
104
+ types
105
+ },
106
+ signer: this.signer.locator(),
107
+ chain
108
+ }
109
+ });
110
+ if ("error" in signatureCreationResponse) {
111
+ throw new SignatureNotCreatedError(JSON.stringify(signatureCreationResponse));
112
+ }
113
+ if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
114
+ return {
115
+ signature: void 0,
116
+ signatureId: signatureCreationResponse.id
117
+ };
118
+ }
119
+ return yield this.approveSignatureAndWait(signatureCreationResponse.id);
120
+ });
121
+ }
122
+ getViemClient(params) {
123
+ var _a;
124
+ return createPublicClient({
125
+ transport: (_a = params == null ? void 0 : params.transport) != null ? _a : http(),
126
+ chain: toViemChain(this.chain)
127
+ });
128
+ }
129
+ createTransaction(transaction, options) {
130
+ return __async(this, null, function* () {
131
+ var _a;
132
+ const signer = (_a = options == null ? void 0 : options.experimental_signer) != null ? _a : this.signer.locator();
133
+ const transactionCreationResponse = yield this.apiClient.createTransaction(this.walletLocator, {
134
+ params: {
135
+ signer,
136
+ chain: this.chain,
137
+ calls: [transaction]
138
+ }
139
+ });
140
+ if ("error" in transactionCreationResponse) {
141
+ throw new TransactionNotCreatedError(JSON.stringify(transactionCreationResponse));
142
+ }
143
+ return transactionCreationResponse;
144
+ });
145
+ }
146
+ buildTransaction(params) {
147
+ var _a, _b, _c, _d, _e;
148
+ if ("transaction" in params) {
149
+ return { transaction: params.transaction };
150
+ }
151
+ if (params.abi == null) {
152
+ return {
153
+ to: params.to,
154
+ value: (_b = (_a = params.value) == null ? void 0 : _a.toString()) != null ? _b : "0",
155
+ data: (_c = params.data) != null ? _c : "0x"
156
+ };
157
+ }
158
+ if (!params.functionName) {
159
+ throw new Error("Function name is required");
160
+ }
161
+ return {
162
+ to: params.to,
163
+ value: (_e = (_d = params.value) == null ? void 0 : _d.toString()) != null ? _e : "0",
164
+ data: encodeFunctionData({
165
+ abi: params.abi,
166
+ functionName: params.functionName,
167
+ args: params.args
168
+ })
169
+ };
170
+ }
171
+ };
172
+
173
+ export {
174
+ EVMWallet
175
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
4
+
5
+ // src/signers/passkey.ts
6
+ var _ox = require('ox');
7
+ var PasskeySigner = class {
8
+ constructor(config) {
9
+ this.config = config;
10
+ this.type = "passkey";
11
+ this.id = config.id;
12
+ }
13
+ locator() {
14
+ return this.config.locator;
15
+ }
16
+ signMessage(message) {
17
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
18
+ if (this.config.onSignWithPasskey) {
19
+ return yield this.config.onSignWithPasskey(message);
20
+ }
21
+ const { signature, metadata } = yield _ox.WebAuthnP256.sign({
22
+ credentialId: this.id,
23
+ challenge: message
24
+ });
25
+ return {
26
+ signature: {
27
+ r: `0x${signature.r.toString(16)}`,
28
+ s: `0x${signature.s.toString(16)}`
29
+ },
30
+ metadata
31
+ };
32
+ });
33
+ }
34
+ signTransaction(transaction) {
35
+ return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
36
+ return yield this.signMessage(transaction);
37
+ });
38
+ }
39
+ };
40
+
41
+
42
+
43
+ exports.PasskeySigner = PasskeySigner;