@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.
- package/dist/api/client.cjs +10 -1
- package/dist/api/client.js +10 -1
- package/dist/api/gen/client.gen.cjs +7 -1
- package/dist/api/gen/client.gen.js +7 -1
- package/dist/api/gen/index.cjs +179 -1
- package/dist/api/gen/index.js +179 -1
- package/dist/api/gen/sdk.gen.cjs +178 -1
- package/dist/api/gen/sdk.gen.js +178 -1
- package/dist/api/gen/types.gen.js +1 -1
- package/dist/api/index.cjs +12 -1
- package/dist/api/index.js +12 -1
- package/dist/api/types.js +1 -1
- package/dist/chains/chains.cjs +9 -1
- package/dist/chains/chains.js +9 -1
- package/dist/chains/definitions/story.cjs +7 -1
- package/dist/chains/definitions/story.js +7 -1
- package/dist/chains/definitions/storyTestnet.cjs +7 -1
- package/dist/chains/definitions/storyTestnet.js +7 -1
- package/dist/chunk-2T5HHKUI.js +19 -0
- package/dist/chunk-34FDYDOM.cjs +87 -0
- package/dist/chunk-3U6UAYOV.js +25 -0
- package/dist/chunk-454RYNSZ.js +80 -0
- package/dist/chunk-455NK5LB.js +0 -0
- package/dist/chunk-55V4VMTX.cjs +25 -0
- package/dist/chunk-5BP6CVYY.cjs +58 -0
- package/dist/chunk-5YR2ILEW.js +69 -0
- package/dist/chunk-6G7ZWCCG.js +247 -0
- package/dist/chunk-7ECQJFYM.cjs +63 -0
- package/dist/chunk-7JFVG4IY.js +59 -0
- package/dist/chunk-AL77JANE.js +36 -0
- package/dist/chunk-B6JOIWRH.cjs +289 -0
- package/dist/chunk-BSC55MYK.cjs +43 -0
- package/dist/chunk-CCIGWTAO.cjs +1 -0
- package/dist/chunk-CHGPNMRL.cjs +36 -0
- package/dist/chunk-CL44FTXR.js +289 -0
- package/dist/chunk-CN2GVFBU.cjs +138 -0
- package/dist/chunk-DQCXGBZM.js +59 -0
- package/dist/chunk-E3OS753T.js +175 -0
- package/dist/chunk-EYJQSDDI.js +43 -0
- package/dist/chunk-F6E3ZDRG.cjs +175 -0
- package/dist/chunk-FPMW7Q5O.js +55 -0
- package/dist/chunk-G3LEJR3P.cjs +53 -0
- package/dist/chunk-G5NYLGM5.cjs +55 -0
- package/dist/chunk-GLRDLJS5.js +92 -0
- package/dist/chunk-GNF2U7IX.cjs +69 -0
- package/dist/chunk-GQIZWD4F.cjs +301 -0
- package/dist/chunk-HYKMSBCT.cjs +75 -0
- package/dist/chunk-IVNYZDI5.cjs +73 -0
- package/dist/chunk-K3HFAPSV.js +73 -0
- package/dist/chunk-KS63YEQ4.js +138 -0
- package/dist/chunk-KT3CVXFG.js +9 -0
- package/dist/chunk-LGONZW4W.cjs +629 -0
- package/dist/chunk-LHYSCUKJ.cjs +16 -0
- package/dist/chunk-LKAO2MV2.cjs +80 -0
- package/dist/chunk-LLFD22UQ.cjs +36 -0
- package/dist/chunk-MZBFXUHT.js +63 -0
- package/dist/chunk-NIBKCMQ2.cjs +19 -0
- package/dist/chunk-OKXSUK63.js +87 -0
- package/dist/chunk-R2OY54EJ.cjs +59 -0
- package/dist/chunk-RAWKXOHR.js +53 -0
- package/dist/chunk-RBHGZDDX.cjs +58 -0
- package/dist/chunk-RHR6P2KP.cjs +15 -0
- package/dist/chunk-RTRDZB52.js +778 -0
- package/dist/chunk-S5YXROL6.js +301 -0
- package/dist/chunk-SGINWAB6.js +155 -0
- package/dist/chunk-TK3EUCQ4.cjs +59 -0
- package/dist/chunk-TOHXQVLS.js +58 -0
- package/dist/chunk-UKBWSQ7R.js +629 -0
- package/dist/chunk-UMGB3Q7I.cjs +92 -0
- package/dist/chunk-V3QJQUT7.cjs +778 -0
- package/dist/chunk-WC7T2CR4.js +44 -0
- package/dist/chunk-WJUPOCKJ.js +15 -0
- package/dist/chunk-WQVJM3PG.js +16 -0
- package/dist/chunk-XC2V34TS.cjs +155 -0
- package/dist/chunk-XRA5GFH3.js +75 -0
- package/dist/chunk-YBA7WO32.cjs +44 -0
- package/dist/chunk-ZP4ZZCIE.js +58 -0
- package/dist/chunk-ZT7EGOCI.cjs +9 -0
- package/dist/chunk-ZTGRDOOH.js +36 -0
- package/dist/chunk-ZZJ7U5G3.cjs +247 -0
- package/dist/index.cjs +57 -1
- package/dist/index.js +57 -1
- package/dist/logger/index.cjs +11 -0
- package/dist/logger/index.d.cts +2 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.js +11 -0
- package/dist/logger/init.cjs +10 -0
- package/dist/logger/init.d.cts +15 -0
- package/dist/logger/init.d.ts +15 -0
- package/dist/logger/init.js +10 -0
- package/dist/sdk.cjs +33 -1
- package/dist/sdk.js +33 -1
- package/dist/signers/evm-api-key.cjs +7 -1
- package/dist/signers/evm-api-key.js +7 -1
- package/dist/signers/evm-external-wallet.cjs +7 -1
- package/dist/signers/evm-external-wallet.js +7 -1
- package/dist/signers/index.cjs +21 -1
- package/dist/signers/index.js +21 -1
- package/dist/signers/non-custodial/index.cjs +24 -1
- package/dist/signers/non-custodial/index.js +24 -1
- package/dist/signers/non-custodial/ncs-evm-signer.cjs +10 -1
- package/dist/signers/non-custodial/ncs-evm-signer.js +10 -1
- package/dist/signers/non-custodial/ncs-iframe-manager.cjs +7 -1
- package/dist/signers/non-custodial/ncs-iframe-manager.js +7 -1
- package/dist/signers/non-custodial/ncs-signer.cjs +11 -1
- package/dist/signers/non-custodial/ncs-signer.js +11 -1
- package/dist/signers/non-custodial/ncs-solana-signer.cjs +10 -1
- package/dist/signers/non-custodial/ncs-solana-signer.js +10 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.cjs +10 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.js +10 -1
- package/dist/signers/passkey.cjs +7 -1
- package/dist/signers/passkey.js +7 -1
- package/dist/signers/solana-api-key.cjs +7 -1
- package/dist/signers/solana-api-key.js +7 -1
- package/dist/signers/solana-external-wallet.cjs +8 -1
- package/dist/signers/solana-external-wallet.js +8 -1
- package/dist/signers/stellar-external-wallet.cjs +7 -1
- package/dist/signers/stellar-external-wallet.js +7 -1
- package/dist/signers/types.cjs +9 -1
- package/dist/signers/types.js +9 -1
- package/dist/utils/constants.cjs +13 -1
- package/dist/utils/constants.js +13 -1
- package/dist/utils/errors.cjs +55 -1
- package/dist/utils/errors.js +55 -1
- package/dist/utils/signer-validation.cjs +10 -1
- package/dist/utils/signer-validation.d.cts +7 -1
- package/dist/utils/signer-validation.d.ts +7 -1
- package/dist/utils/signer-validation.js +10 -1
- package/dist/wallets/evm.cjs +20 -1
- package/dist/wallets/evm.js +20 -1
- package/dist/wallets/solana.cjs +18 -1
- package/dist/wallets/solana.js +18 -1
- package/dist/wallets/stellar.cjs +17 -1
- package/dist/wallets/stellar.js +17 -1
- package/dist/wallets/wallet-factory.cjs +27 -1
- package/dist/wallets/wallet-factory.js +27 -1
- package/dist/wallets/wallet.cjs +16 -1
- package/dist/wallets/wallet.js +16 -1
- package/package.json +6 -5
- package/dist/chunk-2SHDBC47.js +0 -1
- package/dist/chunk-2XVV7Z43.cjs +0 -1
- package/dist/chunk-2YH3NVVK.cjs +0 -1
- package/dist/chunk-3APSOOE3.js +0 -1
- package/dist/chunk-3SW6AJSG.cjs +0 -1
- package/dist/chunk-4KXOWU5E.cjs +0 -1
- package/dist/chunk-5M7IRODB.js +0 -1
- package/dist/chunk-5QIW67NU.cjs +0 -1
- package/dist/chunk-6PVKL5RC.js +0 -1
- package/dist/chunk-7HTB7WKD.cjs +0 -1
- package/dist/chunk-7JIPYRKX.js +0 -1
- package/dist/chunk-BQZES4ST.js +0 -1
- package/dist/chunk-BW7YYVZE.js +0 -1
- package/dist/chunk-C3T63EC7.cjs +0 -1
- package/dist/chunk-CXTC3YDL.cjs +0 -1
- package/dist/chunk-DV6ZRFKV.js +0 -1
- package/dist/chunk-DX7VVXY5.cjs +0 -1
- package/dist/chunk-FATVK26C.js +0 -1
- package/dist/chunk-GEY574TH.cjs +0 -1
- package/dist/chunk-GKZFI322.js +0 -1
- package/dist/chunk-H4T4IXCF.js +0 -1
- package/dist/chunk-HJ5EDMTA.js +0 -1
- package/dist/chunk-HPHVJ6BA.cjs +0 -1
- package/dist/chunk-HQAKCIYM.js +0 -1
- package/dist/chunk-HRSVFJND.cjs +0 -1
- package/dist/chunk-IGBQEAD5.js +0 -1
- package/dist/chunk-IR5WN6FQ.cjs +0 -1
- package/dist/chunk-JUSY5XEE.js +0 -1
- package/dist/chunk-KFJLRIY7.js +0 -1
- package/dist/chunk-KKQBZXFE.js +0 -1
- package/dist/chunk-KO6QYKDX.cjs +0 -1
- package/dist/chunk-KRV3IXJU.cjs +0 -1
- package/dist/chunk-LW6JSI4J.js +0 -1
- package/dist/chunk-M2UBZY5S.cjs +0 -1
- package/dist/chunk-M4TOGGLV.cjs +0 -1
- package/dist/chunk-MQP5VZCA.cjs +0 -1
- package/dist/chunk-NP32UO2G.cjs +0 -1
- package/dist/chunk-O4FVTK7X.cjs +0 -1
- package/dist/chunk-P6JJHAAV.js +0 -1
- package/dist/chunk-PONCGT2H.cjs +0 -1
- package/dist/chunk-PSXRNSOE.js +0 -1
- package/dist/chunk-QMXG67T3.cjs +0 -1
- package/dist/chunk-RJZV72YF.js +0 -1
- package/dist/chunk-S3DYQVRD.js +0 -1
- package/dist/chunk-SLG7HGGL.js +0 -1
- package/dist/chunk-STYSP6KL.cjs +0 -1
- package/dist/chunk-UBOWSXW3.js +0 -1
- package/dist/chunk-UNBXKCNN.js +0 -1
- package/dist/chunk-VY634F3J.js +0 -1
- package/dist/chunk-WQP2FSVI.js +0 -1
- package/dist/chunk-WYYAPI4G.cjs +0 -1
- package/dist/chunk-WZFHEUWT.cjs +0 -1
- package/dist/chunk-XALFCQKD.cjs +0 -1
- package/dist/chunk-YWPTI2QO.cjs +0 -1
- package/dist/chunk-YWXQIFVZ.js +0 -3
- package/dist/chunk-YZ4HRYSL.cjs +0 -1
- package/dist/chunk-Z54LVUDS.js +0 -1
- package/dist/chunk-ZWMB3QLR.cjs +0 -3
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkGQIZWD4Fcjs = require('./chunk-GQIZWD4F.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkZZJ7U5G3cjs = require('./chunk-ZZJ7U5G3.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkG3LEJR3Pcjs = require('./chunk-G3LEJR3P.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
|
|
14
|
+
|
|
15
|
+
// src/sdk.ts
|
|
16
|
+
var _commonsdkbase = require('@crossmint/common-sdk-base');
|
|
17
|
+
var CrossmintWallets = class _CrossmintWallets {
|
|
18
|
+
constructor(crossmint) {
|
|
19
|
+
_chunkG3LEJR3Pcjs.initWalletsLogger.call(void 0, crossmint.apiKey);
|
|
20
|
+
const apiClient = new (0, _chunkZZJ7U5G3cjs.ApiClient)(crossmint);
|
|
21
|
+
this.walletFactory = new (0, _chunkGQIZWD4Fcjs.WalletFactory)(apiClient);
|
|
22
|
+
_chunkG3LEJR3Pcjs.walletsLogger.info("wallets.sdk.initialized");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the Wallets SDK
|
|
26
|
+
* @param crossmint - Crossmint data (use `createCrossmint` to initialize)
|
|
27
|
+
* @returns A new CrossmintWallets instance
|
|
28
|
+
*/
|
|
29
|
+
static from(crossmint) {
|
|
30
|
+
return new _CrossmintWallets(crossmint);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get or create a wallet, can only be called on the client side
|
|
34
|
+
* @param args - Wallet data
|
|
35
|
+
* @param options - Wallet options
|
|
36
|
+
* @returns An existing wallet or a new wallet
|
|
37
|
+
*/
|
|
38
|
+
getOrCreateWallet(options) {
|
|
39
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
40
|
+
return yield this.walletFactory.getOrCreateWallet(options);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get an existing wallet by its locator, can only be called on the server side
|
|
45
|
+
* @param walletLocator - Wallet locator
|
|
46
|
+
* @param options - Wallet options
|
|
47
|
+
* @returns A wallet if found, throws WalletNotAvailableError if not found
|
|
48
|
+
*/
|
|
49
|
+
getWallet(walletLocator, options) {
|
|
50
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
51
|
+
return yield this.walletFactory.getWallet(walletLocator, options);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a new wallet, can only be called on the server side
|
|
56
|
+
* @param options - Wallet options
|
|
57
|
+
* @returns A new wallet
|
|
58
|
+
*/
|
|
59
|
+
createWallet(options) {
|
|
60
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
61
|
+
return yield this.walletFactory.createWallet(options);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.createCrossmint = _commonsdkbase.createCrossmint; exports.CrossmintWallets = CrossmintWallets;
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkRBHGZDDXcjs = require('./chunk-RBHGZDDX.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkLGONZW4Wcjs = require('./chunk-LGONZW4W.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunk5BP6CVYYcjs = require('./chunk-5BP6CVYY.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkXC2V34TScjs = require('./chunk-XC2V34TS.cjs');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunkG3LEJR3Pcjs = require('./chunk-G3LEJR3P.cjs');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
|
|
22
|
+
|
|
23
|
+
// src/wallets/wallet-factory.ts
|
|
24
|
+
var _ox = require('ox');
|
|
25
|
+
var DELEGATED_SIGNER_MISMATCH_ERROR = "When 'delegatedSigners' is provided to a method that may fetch an existing wallet, each specified delegated signer must exist in that wallet's configuration.";
|
|
26
|
+
var WalletFactory = class {
|
|
27
|
+
constructor(apiClient) {
|
|
28
|
+
this.apiClient = apiClient;
|
|
29
|
+
}
|
|
30
|
+
getOrCreateWallet(args) {
|
|
31
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
32
|
+
if (this.apiClient.isServerSide) {
|
|
33
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)(
|
|
34
|
+
"getOrCreateWallet can only be called from client-side code.\n- Make sure you're running this in the browser (or another client environment), not on your server.\n- Use your Crossmint Client API Key (not a server key)."
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
const locator = this.getWalletLocator(args);
|
|
38
|
+
_chunkG3LEJR3Pcjs.walletsLogger.info("wallet.getOrCreate.start", {
|
|
39
|
+
chain: args.chain,
|
|
40
|
+
signerType: args.signer.type
|
|
41
|
+
});
|
|
42
|
+
const existingWallet = yield this.apiClient.getWallet(locator);
|
|
43
|
+
if (existingWallet != null && !("error" in existingWallet)) {
|
|
44
|
+
_chunkG3LEJR3Pcjs.walletsLogger.info("wallet.getOrCreate.existing", {
|
|
45
|
+
chain: args.chain,
|
|
46
|
+
address: existingWallet.address
|
|
47
|
+
});
|
|
48
|
+
return this.createWalletInstance(existingWallet, args);
|
|
49
|
+
}
|
|
50
|
+
_chunkG3LEJR3Pcjs.walletsLogger.info("wallet.getOrCreate.creating", {
|
|
51
|
+
chain: args.chain
|
|
52
|
+
});
|
|
53
|
+
return this.createWallet(args);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
getWallet(walletLocator, args) {
|
|
57
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
58
|
+
if (!this.apiClient.isServerSide) {
|
|
59
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)("getWallet is not supported on client side, use getOrCreateWallet instead");
|
|
60
|
+
}
|
|
61
|
+
_chunkG3LEJR3Pcjs.walletsLogger.info("wallet.get.start", {
|
|
62
|
+
walletLocator,
|
|
63
|
+
chain: args.chain
|
|
64
|
+
});
|
|
65
|
+
const existingWallet = yield this.apiClient.getWallet(walletLocator);
|
|
66
|
+
if ("error" in existingWallet) {
|
|
67
|
+
_chunkG3LEJR3Pcjs.walletsLogger.warn("wallet.get.notFound", {
|
|
68
|
+
walletLocator,
|
|
69
|
+
error: existingWallet.error
|
|
70
|
+
});
|
|
71
|
+
throw new (0, _chunkXC2V34TScjs.WalletNotAvailableError)(JSON.stringify(existingWallet));
|
|
72
|
+
}
|
|
73
|
+
_chunkG3LEJR3Pcjs.walletsLogger.info("wallet.get.success", {
|
|
74
|
+
walletLocator,
|
|
75
|
+
address: existingWallet.address
|
|
76
|
+
});
|
|
77
|
+
return this.createWalletInstance(existingWallet, args);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
createWallet(args) {
|
|
81
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
82
|
+
var _a, _b, _c, _d, _e;
|
|
83
|
+
yield (_c = (_b = (_a = args.options) == null ? void 0 : _a.experimental_callbacks) == null ? void 0 : _b.onWalletCreationStart) == null ? void 0 : _c.call(_b);
|
|
84
|
+
_chunkG3LEJR3Pcjs.walletsLogger.info("wallet.create.start", {
|
|
85
|
+
chain: args.chain,
|
|
86
|
+
signerType: args.signer.type
|
|
87
|
+
});
|
|
88
|
+
this.mutateSignerFromCustomAuth(args, true);
|
|
89
|
+
const adminSigner = args.signer.type === "passkey" ? yield this.createPasskeyAdminSigner(args.signer) : args.signer;
|
|
90
|
+
const walletResponse = yield this.apiClient.createWallet({
|
|
91
|
+
type: "smart",
|
|
92
|
+
chainType: this.getChainType(args.chain),
|
|
93
|
+
config: _chunkG5NYLGM5cjs.__spreadValues.call(void 0, _chunkG5NYLGM5cjs.__spreadValues.call(void 0, {
|
|
94
|
+
adminSigner
|
|
95
|
+
}, (args == null ? void 0 : args.plugins) ? { plugins: args.plugins } : {}), args.delegatedSigners != null ? { delegatedSigners: args.delegatedSigners } : {}),
|
|
96
|
+
owner: (_d = args.owner) != null ? _d : void 0,
|
|
97
|
+
alias: (_e = args.alias) != null ? _e : void 0
|
|
98
|
+
});
|
|
99
|
+
if ("error" in walletResponse) {
|
|
100
|
+
_chunkG3LEJR3Pcjs.walletsLogger.error("wallet.create.error", {
|
|
101
|
+
chain: args.chain,
|
|
102
|
+
error: walletResponse.error
|
|
103
|
+
});
|
|
104
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)(JSON.stringify(walletResponse));
|
|
105
|
+
}
|
|
106
|
+
_chunkG3LEJR3Pcjs.walletsLogger.info("wallet.create.success", {
|
|
107
|
+
chain: args.chain,
|
|
108
|
+
address: walletResponse.address
|
|
109
|
+
});
|
|
110
|
+
return this.createWalletInstance(walletResponse, args);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
createWalletInstance(walletResponse, args) {
|
|
114
|
+
this.validateExistingWalletConfig(walletResponse, args);
|
|
115
|
+
const signerConfig = this.toInternalSignerConfig(walletResponse, args.signer, args.options);
|
|
116
|
+
return new (0, _chunkLGONZW4Wcjs.Wallet)(
|
|
117
|
+
{
|
|
118
|
+
chain: args.chain,
|
|
119
|
+
address: walletResponse.address,
|
|
120
|
+
owner: walletResponse.owner,
|
|
121
|
+
signer: _chunk5BP6CVYYcjs.assembleSigner.call(void 0, args.chain, signerConfig),
|
|
122
|
+
options: args.options,
|
|
123
|
+
alias: args.alias
|
|
124
|
+
},
|
|
125
|
+
this.apiClient
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
toInternalSignerConfig(walletResponse, signerArgs, options) {
|
|
129
|
+
var _a, _b, _c, _d, _e, _f;
|
|
130
|
+
if (!(walletResponse.chainType === "evm" || walletResponse.chainType === "solana" || walletResponse.chainType === "stellar")) {
|
|
131
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)(`Wallet type ${walletResponse.chainType} is not supported`);
|
|
132
|
+
}
|
|
133
|
+
if (signerArgs == null && ((_a = walletResponse.config) == null ? void 0 : _a.adminSigner) == null) {
|
|
134
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)("Signer is required to create a wallet");
|
|
135
|
+
}
|
|
136
|
+
switch (signerArgs.type) {
|
|
137
|
+
case "api-key": {
|
|
138
|
+
if (((_b = walletResponse.config) == null ? void 0 : _b.adminSigner.type) !== "api-key") {
|
|
139
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)("API key signer does not match the wallet's signer type");
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
type: "api-key",
|
|
143
|
+
address: walletResponse.config.adminSigner.address,
|
|
144
|
+
locator: walletResponse.config.adminSigner.locator
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
case "external-wallet":
|
|
148
|
+
if (((_c = walletResponse.config) == null ? void 0 : _c.adminSigner.type) !== "external-wallet") {
|
|
149
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)("External wallet signer does not match the wallet's signer type");
|
|
150
|
+
}
|
|
151
|
+
return _chunkG5NYLGM5cjs.__spreadValues.call(void 0, _chunkG5NYLGM5cjs.__spreadValues.call(void 0, {}, walletResponse.config.adminSigner), signerArgs);
|
|
152
|
+
case "passkey":
|
|
153
|
+
if (((_d = walletResponse.config) == null ? void 0 : _d.adminSigner.type) !== "passkey") {
|
|
154
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)("Passkey signer does not match the wallet's signer type");
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
type: "passkey",
|
|
158
|
+
id: walletResponse.config.adminSigner.id,
|
|
159
|
+
name: walletResponse.config.adminSigner.name,
|
|
160
|
+
locator: walletResponse.config.adminSigner.locator,
|
|
161
|
+
onCreatePasskey: signerArgs.onCreatePasskey,
|
|
162
|
+
onSignWithPasskey: signerArgs.onSignWithPasskey
|
|
163
|
+
};
|
|
164
|
+
case "email": {
|
|
165
|
+
if (((_e = walletResponse.config) == null ? void 0 : _e.adminSigner.type) !== "email") {
|
|
166
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)("Email signer does not match the wallet's signer type");
|
|
167
|
+
}
|
|
168
|
+
const { locator, email, address } = walletResponse.config.adminSigner;
|
|
169
|
+
return {
|
|
170
|
+
type: "email",
|
|
171
|
+
email,
|
|
172
|
+
locator,
|
|
173
|
+
address,
|
|
174
|
+
crossmint: this.apiClient.crossmint,
|
|
175
|
+
onAuthRequired: signerArgs.onAuthRequired,
|
|
176
|
+
clientTEEConnection: options == null ? void 0 : options.clientTEEConnection
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
case "phone": {
|
|
180
|
+
if (((_f = walletResponse.config) == null ? void 0 : _f.adminSigner.type) !== "phone") {
|
|
181
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)("Phone signer does not match the wallet's signer type");
|
|
182
|
+
}
|
|
183
|
+
const { locator, phone, address } = walletResponse.config.adminSigner;
|
|
184
|
+
return {
|
|
185
|
+
type: "phone",
|
|
186
|
+
phone,
|
|
187
|
+
locator,
|
|
188
|
+
address,
|
|
189
|
+
crossmint: this.apiClient.crossmint,
|
|
190
|
+
onAuthRequired: signerArgs.onAuthRequired,
|
|
191
|
+
clientTEEConnection: options == null ? void 0 : options.clientTEEConnection
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
default:
|
|
195
|
+
throw new Error("Invalid signer type");
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
getWalletLocator(args) {
|
|
199
|
+
return `me:${this.getChainType(args.chain)}:smart` + (args.alias != null ? `:alias:${args.alias}` : "");
|
|
200
|
+
}
|
|
201
|
+
createPasskeyAdminSigner(signer) {
|
|
202
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
203
|
+
var _a;
|
|
204
|
+
if (signer.type !== "passkey") {
|
|
205
|
+
throw new Error("Signer is not a passkey");
|
|
206
|
+
}
|
|
207
|
+
const passkeyName = (_a = signer.name) != null ? _a : `Crossmint Wallet ${Date.now()}`;
|
|
208
|
+
const passkeyCredential = signer.onCreatePasskey ? yield signer.onCreatePasskey(passkeyName) : yield _ox.WebAuthnP256.createCredential({ name: passkeyName });
|
|
209
|
+
return {
|
|
210
|
+
type: "passkey",
|
|
211
|
+
id: passkeyCredential.id,
|
|
212
|
+
name: passkeyName,
|
|
213
|
+
publicKey: {
|
|
214
|
+
x: passkeyCredential.publicKey.x.toString(),
|
|
215
|
+
y: passkeyCredential.publicKey.y.toString()
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
mutateSignerFromCustomAuth(args, isNewWalletSigner = false) {
|
|
221
|
+
var _a, _b;
|
|
222
|
+
const { experimental_customAuth } = this.apiClient.crossmint;
|
|
223
|
+
if (args.signer.type === "email" && (experimental_customAuth == null ? void 0 : experimental_customAuth.email) != null) {
|
|
224
|
+
args.signer.email = (_a = args.signer.email) != null ? _a : experimental_customAuth.email;
|
|
225
|
+
}
|
|
226
|
+
if (args.signer.type === "phone" && (experimental_customAuth == null ? void 0 : experimental_customAuth.phone) != null) {
|
|
227
|
+
args.signer.phone = (_b = args.signer.phone) != null ? _b : experimental_customAuth.phone;
|
|
228
|
+
}
|
|
229
|
+
if (args.signer.type === "external-wallet" && (experimental_customAuth == null ? void 0 : experimental_customAuth.externalWalletSigner) != null) {
|
|
230
|
+
args.signer = isNewWalletSigner ? {
|
|
231
|
+
type: "external-wallet",
|
|
232
|
+
address: experimental_customAuth.externalWalletSigner.address
|
|
233
|
+
} : experimental_customAuth.externalWalletSigner;
|
|
234
|
+
}
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
validateExistingWalletConfig(existingWallet, args) {
|
|
238
|
+
var _a;
|
|
239
|
+
this.mutateSignerFromCustomAuth(args);
|
|
240
|
+
if (args.owner != null && existingWallet.owner != null && _chunkRBHGZDDXcjs.normalizeValueForComparison.call(void 0, args.owner) !== _chunkRBHGZDDXcjs.normalizeValueForComparison.call(void 0, existingWallet.owner)) {
|
|
241
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)("Wallet owner does not match existing wallet's linked user");
|
|
242
|
+
}
|
|
243
|
+
if (args.chain === "solana" && existingWallet.chainType !== "solana" || args.chain !== "solana" && existingWallet.chainType === "solana" || args.chain === "stellar" && existingWallet.chainType !== "stellar" || args.chain !== "stellar" && existingWallet.chainType === "stellar") {
|
|
244
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)(
|
|
245
|
+
`Wallet chain does not match existing wallet's chain. You must use chain: ${existingWallet.chainType}.`
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
if (existingWallet.type !== "smart") {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const adminSignerArgs = args.signer;
|
|
252
|
+
const existingWalletSigner = (_a = existingWallet == null ? void 0 : existingWallet.config) == null ? void 0 : _a.adminSigner;
|
|
253
|
+
if (adminSignerArgs != null && existingWalletSigner != null) {
|
|
254
|
+
if (adminSignerArgs.type !== existingWalletSigner.type) {
|
|
255
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)(
|
|
256
|
+
"The wallet signer type provided in the wallet config does not match the existing wallet's adminSigner type"
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
_chunkRBHGZDDXcjs.compareSignerConfigs.call(void 0, adminSignerArgs, existingWalletSigner);
|
|
260
|
+
}
|
|
261
|
+
if (args.delegatedSigners != null) {
|
|
262
|
+
this.validateDelegatedSigners(existingWallet, args.delegatedSigners);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
validateDelegatedSigners(existingWallet, inputDelegatedSigners) {
|
|
266
|
+
var _a;
|
|
267
|
+
const existingDelegatedSigners = (_a = existingWallet == null ? void 0 : existingWallet.config) == null ? void 0 : _a.delegatedSigners;
|
|
268
|
+
if (inputDelegatedSigners.length === 0) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (existingDelegatedSigners == null || existingDelegatedSigners.length === 0) {
|
|
272
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)(
|
|
273
|
+
`${inputDelegatedSigners.length} delegated signer(s) specified, but wallet "${existingWallet.address}" has no delegated signers. ${DELEGATED_SIGNER_MISMATCH_ERROR}`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
for (const argSigner of inputDelegatedSigners) {
|
|
277
|
+
const matchingExistingSigner = existingDelegatedSigners.find(
|
|
278
|
+
(existingSigner) => existingSigner.locator === argSigner.signer
|
|
279
|
+
);
|
|
280
|
+
if (matchingExistingSigner == null) {
|
|
281
|
+
const walletSigners = existingDelegatedSigners.map((s) => s.locator).join(", ");
|
|
282
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)(
|
|
283
|
+
`Delegated signer '${argSigner.signer}' does not exist in wallet "${existingWallet.address}". Available delegated signers: ${walletSigners}. ${DELEGATED_SIGNER_MISMATCH_ERROR}`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
getChainType(chain) {
|
|
289
|
+
if (chain === "solana") {
|
|
290
|
+
return "solana";
|
|
291
|
+
}
|
|
292
|
+
if (chain === "stellar") {
|
|
293
|
+
return "stellar";
|
|
294
|
+
}
|
|
295
|
+
return "evm";
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
exports.WalletFactory = WalletFactory;
|
|
@@ -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 _chunkB6JOIWRHcjs = require('./chunk-B6JOIWRH.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 _chunkB6JOIWRHcjs.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: _chunkB6JOIWRHcjs.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,73 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkB6JOIWRHcjs = require('./chunk-B6JOIWRH.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
|
|
8
|
+
|
|
9
|
+
// src/signers/non-custodial/ncs-stellar-signer.ts
|
|
10
|
+
var StellarNonCustodialSigner = class _StellarNonCustodialSigner extends _chunkB6JOIWRHcjs.NonCustodialSigner {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
super(config);
|
|
13
|
+
}
|
|
14
|
+
signMessage() {
|
|
15
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
16
|
+
return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
signTransaction(payload) {
|
|
20
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, 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: _chunkB6JOIWRHcjs.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
|
+
|
|
72
|
+
|
|
73
|
+
exports.StellarNonCustodialSigner = StellarNonCustodialSigner;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_EVENT_OPTIONS,
|
|
3
|
+
NonCustodialSigner
|
|
4
|
+
} from "./chunk-CL44FTXR.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
|
+
};
|