@usecapsule/core-sdk
Advanced tools
Comparing version 1.24.1 to 2.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CURRENT_WALLET_IDS_CHANGE_EVENT = exports.EXTERNAL_WALLET_CHANGE_EVENT = exports.getPortalBaseURL = exports.getPortalDomain = exports.getNetwork = exports.getProviderAssetInverse = exports.getProviderNetworkAndAssetCode = exports.WalletSchemeMap = exports.getAsset = exports.getProvider = exports.OnRampMethod = exports.OnRampProviderAssetMap = exports.OnRampProviderNetworkMap = exports.EnabledFlow = exports.OnRampAssetMap = exports.OnRampProviderMap = exports.SupportedOnRamps = exports.NetworkMap = exports.OAuthMethod = exports.Environment = exports.is2FAEnabled = exports.OnRampPurchaseStatus = exports.OnRampProvider = exports.OnRampAsset = exports.Network = void 0; | ||
exports.getOnRampAssets = exports.getOnRampNetworks = exports.toAssetInfoArray = exports.CURRENT_WALLET_IDS_CHANGE_EVENT = exports.EXTERNAL_WALLET_CHANGE_EVENT = exports.getPortalBaseURL = exports.getPortalDomain = exports.getProviderAssetInverse = exports.getProviderNetworkAndAssetCode = exports.WalletSchemeTypeMap = exports.OnRampMethod = exports.OnRampProviderAssetMap = exports.OnRampProviderNetworkMap = exports.EnabledFlow = exports.SupportedOnRamps = exports.WalletSchemeMap = exports.OAuthMethod = exports.Environment = exports.is2FAEnabled = exports.OnRampPurchaseStatus = exports.OnRampProvider = exports.OnRampAsset = exports.Network = void 0; | ||
const buffer_1 = require("buffer"); | ||
@@ -43,13 +43,6 @@ if (typeof global !== 'undefined') { | ||
})(OAuthMethod || (exports.OAuthMethod = OAuthMethod = {})); | ||
exports.NetworkMap = { | ||
ethereum: user_management_client_1.Network.ETHEREUM, | ||
ETHEREUM: user_management_client_1.Network.ETHEREUM, | ||
arbitrum: user_management_client_1.Network.ARBITRUM, | ||
ARBITRUM: user_management_client_1.Network.ARBITRUM, | ||
base: user_management_client_1.Network.BASE, | ||
BASE: user_management_client_1.Network.BASE, | ||
optimism: user_management_client_1.Network.OPTIMISM, | ||
OPTIMISM: user_management_client_1.Network.OPTIMISM, | ||
POLYGON: user_management_client_1.Network.POLYGON, | ||
polygon: user_management_client_1.Network.POLYGON, | ||
exports.WalletSchemeMap = { | ||
DKLS: user_management_client_1.WalletScheme.DKLS, | ||
CGGMP: user_management_client_1.WalletScheme.CGGMP, | ||
ED25519: user_management_client_1.WalletScheme.ED25519, | ||
}; | ||
@@ -102,20 +95,2 @@ exports.SupportedOnRamps = { | ||
}; | ||
exports.OnRampProviderMap = { | ||
STRIPE: user_management_client_1.OnRampProvider.STRIPE, | ||
stripe: user_management_client_1.OnRampProvider.STRIPE, | ||
RAMP: user_management_client_1.OnRampProvider.RAMP, | ||
ramp: user_management_client_1.OnRampProvider.RAMP, | ||
}; | ||
exports.OnRampAssetMap = { | ||
eth: user_management_client_1.OnRampAsset.ETHEREUM, | ||
ETH: user_management_client_1.OnRampAsset.ETHEREUM, | ||
ethereum: user_management_client_1.OnRampAsset.ETHEREUM, | ||
ETHEREUM: user_management_client_1.OnRampAsset.ETHEREUM, | ||
usdc: user_management_client_1.OnRampAsset.USDC, | ||
USDC: user_management_client_1.OnRampAsset.USDC, | ||
polygon: user_management_client_1.OnRampAsset.POLYGON, | ||
POLYGON: user_management_client_1.OnRampAsset.POLYGON, | ||
matic: user_management_client_1.OnRampAsset.POLYGON, | ||
MATIC: user_management_client_1.OnRampAsset.POLYGON, | ||
}; | ||
var EnabledFlow; | ||
@@ -125,2 +100,3 @@ (function (EnabledFlow) { | ||
EnabledFlow["RECEIVE"] = "RECEIVE"; | ||
EnabledFlow["WITHDRAW"] = "WITHDRAW"; | ||
})(EnabledFlow || (exports.EnabledFlow = EnabledFlow = {})); | ||
@@ -159,11 +135,3 @@ exports.OnRampProviderNetworkMap = { | ||
})(OnRampMethod || (exports.OnRampMethod = OnRampMethod = {})); | ||
function getProvider(key) { | ||
return exports.OnRampProviderMap[key]; | ||
} | ||
exports.getProvider = getProvider; | ||
function getAsset(key) { | ||
return exports.OnRampAssetMap[key]; | ||
} | ||
exports.getAsset = getAsset; | ||
exports.WalletSchemeMap = { | ||
exports.WalletSchemeTypeMap = { | ||
[user_management_client_1.WalletScheme.DKLS]: { | ||
@@ -182,3 +150,3 @@ [user_management_client_1.WalletType.EVM]: true, | ||
const getProviderNetworkAndAssetCode = (networkProp, assetProp, providerProp, testMode = false) => { | ||
const [network, asset, provider] = [getNetwork(networkProp), getAsset(assetProp), getProvider(providerProp)]; | ||
const [network, asset, provider] = [user_management_client_1.Network[networkProp], user_management_client_1.OnRampAsset[assetProp], user_management_client_1.OnRampProvider[providerProp]]; | ||
if (!exports.SupportedOnRamps[network][asset][provider]) { | ||
@@ -199,10 +167,6 @@ throw new Error(`Provider ${provider} does not support asset ${asset} on ${network}`); | ||
function getProviderAssetInverse(provider, asset) { | ||
const match = Object.entries(exports.OnRampProviderAssetMap[getProvider(provider)]).find(([, theirAssetCode]) => asset === theirAssetCode); | ||
const match = Object.entries(exports.OnRampProviderAssetMap[user_management_client_1.OnRampProvider[provider]]).find(([, theirAssetCode]) => asset === theirAssetCode); | ||
return match ? match[0] : undefined; | ||
} | ||
exports.getProviderAssetInverse = getProviderAssetInverse; | ||
function getNetwork(networkProp) { | ||
return exports.NetworkMap[networkProp]; | ||
} | ||
exports.getNetwork = getNetwork; | ||
function getPortalDomain(env) { | ||
@@ -236,1 +200,34 @@ switch (env) { | ||
exports.CURRENT_WALLET_IDS_CHANGE_EVENT = 'capsuleCurrentWalletIdsChange'; | ||
function toAssetInfoArray(data) { | ||
const result = []; | ||
Object.keys(data).forEach(walletType => { | ||
const networks = data[walletType]; | ||
Object.keys(networks).forEach(network => { | ||
const assets = networks[network]; | ||
Object.keys(assets).forEach(asset => { | ||
const providerInfo = assets[asset]; | ||
result.push([walletType, network, asset, providerInfo]); | ||
}); | ||
}); | ||
}); | ||
return result; | ||
} | ||
exports.toAssetInfoArray = toAssetInfoArray; | ||
function getOnRampNetworks(data, { walletType, allowed } = {}) { | ||
return [ | ||
...new Set(toAssetInfoArray(data) | ||
.filter(([type, network]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network))) | ||
.map(([_, network]) => network)), | ||
]; | ||
} | ||
exports.getOnRampNetworks = getOnRampNetworks; | ||
function getOnRampAssets(data, { walletType, network, allowed, } = {}) { | ||
return [ | ||
...new Set(toAssetInfoArray(data) | ||
.filter(([t, n, a]) => (!walletType || t === walletType) && | ||
(!network || n === network) && | ||
(!Array.isArray(allowed) || allowed.includes(a))) | ||
.map(([, , asset]) => asset)), | ||
]; | ||
} | ||
exports.getOnRampAssets = getOnRampAssets; |
@@ -43,3 +43,3 @@ "use strict"; | ||
userManagementHost: getBaseUrl(env), | ||
version: env === definitions_js_1.Environment.DEV ? 'dev' : version, | ||
version: [definitions_js_1.Environment.DEV, definitions_js_1.Environment.SANDBOX].includes(env) ? 'dev' : version, | ||
apiKey: apiKey, | ||
@@ -46,0 +46,0 @@ opts: { useFetchAdapter }, |
@@ -29,10 +29,14 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.capsuleVersion = exports.EmailTheme = exports.getSchemes = exports.PregenIdentifierType = exports.STORAGE_PREFIX = exports.transmissionUtilsRetrieve = exports.decryptPrivateKeyAndDecryptShare = exports.decryptPrivateKey = exports.encryptPrivateKey = exports.getSHA256HashHex = exports.getPublicKeyFromSignature = exports.getDerivedPrivateKeyAndDecrypt = exports.encodePrivateKeyToPemHex = exports.encryptWithDerivedPublicKey = exports.getPublicKeyHex = exports.getAsymmetricKeyPair = exports.decryptWithPrivateKey = exports.decryptWithKeyPair = exports.getBaseUrl = exports.mpcComputationClient = exports.initClient = exports.ExternalWalletType = exports.stringToPhoneNumber = exports.RecoveryStatus = exports.KeyContainer = exports.distributeNewShare = exports.NON_ED25519 = exports.WalletScheme = exports.WalletType = void 0; | ||
exports.capsuleVersion = exports.isTypeRequired = exports.isTypeOptional = exports.isWalletSupported = exports.PregenIdentifierType = exports.STORAGE_PREFIX = exports.transmissionUtilsRetrieve = exports.decryptPrivateKeyAndDecryptShare = exports.decryptPrivateKey = exports.encryptPrivateKey = exports.getSHA256HashHex = exports.getPublicKeyFromSignature = exports.getDerivedPrivateKeyAndDecrypt = exports.encodePrivateKeyToPemHex = exports.encryptWithDerivedPublicKey = exports.getPublicKeyHex = exports.getAsymmetricKeyPair = exports.decryptWithPrivateKey = exports.decryptWithKeyPair = exports.getBaseUrl = exports.mpcComputationClient = exports.initClient = exports.entityToWallet = exports.stringToPhoneNumber = exports.RecoveryStatus = exports.KeyContainer = exports.distributeNewShare = exports.NON_ED25519 = exports.OnRampPurchaseType = exports.WalletScheme = exports.WalletType = exports.EmailTheme = void 0; | ||
const CoreCapsule_js_1 = require("./CoreCapsule.js"); | ||
Object.defineProperty(exports, "STORAGE_PREFIX", { enumerable: true, get: function () { return CoreCapsule_js_1.PREFIX; } }); | ||
Object.defineProperty(exports, "PregenIdentifierType", { enumerable: true, get: function () { return CoreCapsule_js_1.PregenIdentifierType; } }); | ||
Object.defineProperty(exports, "getSchemes", { enumerable: true, get: function () { return CoreCapsule_js_1.getSchemes; } }); | ||
Object.defineProperty(exports, "isWalletSupported", { enumerable: true, get: function () { return CoreCapsule_js_1.isWalletSupported; } }); | ||
Object.defineProperty(exports, "isTypeOptional", { enumerable: true, get: function () { return CoreCapsule_js_1.isTypeOptional; } }); | ||
Object.defineProperty(exports, "isTypeRequired", { enumerable: true, get: function () { return CoreCapsule_js_1.isTypeRequired; } }); | ||
var user_management_client_1 = require("@usecapsule/user-management-client"); | ||
Object.defineProperty(exports, "EmailTheme", { enumerable: true, get: function () { return user_management_client_1.EmailTheme; } }); | ||
Object.defineProperty(exports, "WalletType", { enumerable: true, get: function () { return user_management_client_1.WalletType; } }); | ||
Object.defineProperty(exports, "WalletScheme", { enumerable: true, get: function () { return user_management_client_1.WalletScheme; } }); | ||
Object.defineProperty(exports, "OnRampPurchaseType", { enumerable: true, get: function () { return user_management_client_1.OnRampPurchaseType; } }); | ||
Object.defineProperty(exports, "NON_ED25519", { enumerable: true, get: function () { return user_management_client_1.NON_ED25519; } }); | ||
@@ -48,3 +52,3 @@ __exportStar(require("./definitions.js"), exports); | ||
Object.defineProperty(exports, "stringToPhoneNumber", { enumerable: true, get: function () { return CoreCapsule_js_2.stringToPhoneNumber; } }); | ||
Object.defineProperty(exports, "ExternalWalletType", { enumerable: true, get: function () { return CoreCapsule_js_2.ExternalWalletType; } }); | ||
Object.defineProperty(exports, "entityToWallet", { enumerable: true, get: function () { return CoreCapsule_js_2.entityToWallet; } }); | ||
var capsuleClient_js_1 = require("./external/capsuleClient.js"); | ||
@@ -74,5 +78,3 @@ Object.defineProperty(exports, "initClient", { enumerable: true, get: function () { return capsuleClient_js_1.initClient; } }); | ||
Object.defineProperty(exports, "transmissionUtilsRetrieve", { enumerable: true, get: function () { return transmissionUtils_js_1.retrieve; } }); | ||
var user_management_client_2 = require("@usecapsule/user-management-client"); | ||
Object.defineProperty(exports, "EmailTheme", { enumerable: true, get: function () { return user_management_client_2.EmailTheme; } }); | ||
exports.capsuleVersion = CoreCapsule_js_1.CoreCapsule.version; | ||
exports.default = CoreCapsule_js_1.CoreCapsule; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getCosmosAddress = exports.isCosmosWithPrefix = exports.decimalToHex = exports.hexToDecimal = exports.hexToUint8Array = exports.hexToSignature = exports.hexStringToBase64 = void 0; | ||
exports.truncateAddress = exports.getCosmosAddress = exports.isCosmosWithPrefix = exports.decimalToHex = exports.hexToDecimal = exports.hexToUint8Array = exports.hexToSignature = exports.hexStringToBase64 = void 0; | ||
const user_management_client_1 = require("@usecapsule/user-management-client"); | ||
@@ -74,1 +74,6 @@ const encoding_1 = require("@cosmjs/encoding"); | ||
exports.getCosmosAddress = getCosmosAddress; | ||
function truncateAddress(str, addressType, { prefix = addressType === 'COSMOS' ? 'cosmos' : undefined } = {}) { | ||
const headLength = (addressType === 'COSMOS' ? prefix.length : addressType === 'SOLANA' ? 0 : 2) + 4; | ||
return `${str.slice(0, headLength)}...${str.slice(-4)}`; | ||
} | ||
exports.truncateAddress = truncateAddress; |
@@ -37,13 +37,6 @@ import { Buffer as NodeBuffer } from 'buffer'; | ||
})(OAuthMethod || (OAuthMethod = {})); | ||
export const NetworkMap = { | ||
ethereum: Network.ETHEREUM, | ||
ETHEREUM: Network.ETHEREUM, | ||
arbitrum: Network.ARBITRUM, | ||
ARBITRUM: Network.ARBITRUM, | ||
base: Network.BASE, | ||
BASE: Network.BASE, | ||
optimism: Network.OPTIMISM, | ||
OPTIMISM: Network.OPTIMISM, | ||
POLYGON: Network.POLYGON, | ||
polygon: Network.POLYGON, | ||
export const WalletSchemeMap = { | ||
DKLS: WalletScheme.DKLS, | ||
CGGMP: WalletScheme.CGGMP, | ||
ED25519: WalletScheme.ED25519, | ||
}; | ||
@@ -96,20 +89,2 @@ export const SupportedOnRamps = { | ||
}; | ||
export const OnRampProviderMap = { | ||
STRIPE: OnRampProvider.STRIPE, | ||
stripe: OnRampProvider.STRIPE, | ||
RAMP: OnRampProvider.RAMP, | ||
ramp: OnRampProvider.RAMP, | ||
}; | ||
export const OnRampAssetMap = { | ||
eth: OnRampAsset.ETHEREUM, | ||
ETH: OnRampAsset.ETHEREUM, | ||
ethereum: OnRampAsset.ETHEREUM, | ||
ETHEREUM: OnRampAsset.ETHEREUM, | ||
usdc: OnRampAsset.USDC, | ||
USDC: OnRampAsset.USDC, | ||
polygon: OnRampAsset.POLYGON, | ||
POLYGON: OnRampAsset.POLYGON, | ||
matic: OnRampAsset.POLYGON, | ||
MATIC: OnRampAsset.POLYGON, | ||
}; | ||
export var EnabledFlow; | ||
@@ -119,2 +94,3 @@ (function (EnabledFlow) { | ||
EnabledFlow["RECEIVE"] = "RECEIVE"; | ||
EnabledFlow["WITHDRAW"] = "WITHDRAW"; | ||
})(EnabledFlow || (EnabledFlow = {})); | ||
@@ -153,9 +129,3 @@ export const OnRampProviderNetworkMap = { | ||
})(OnRampMethod || (OnRampMethod = {})); | ||
export function getProvider(key) { | ||
return OnRampProviderMap[key]; | ||
} | ||
export function getAsset(key) { | ||
return OnRampAssetMap[key]; | ||
} | ||
export const WalletSchemeMap = { | ||
export const WalletSchemeTypeMap = { | ||
[WalletScheme.DKLS]: { | ||
@@ -174,3 +144,3 @@ [WalletType.EVM]: true, | ||
export const getProviderNetworkAndAssetCode = (networkProp, assetProp, providerProp, testMode = false) => { | ||
const [network, asset, provider] = [getNetwork(networkProp), getAsset(assetProp), getProvider(providerProp)]; | ||
const [network, asset, provider] = [Network[networkProp], OnRampAsset[assetProp], OnRampProvider[providerProp]]; | ||
if (!SupportedOnRamps[network][asset][provider]) { | ||
@@ -190,8 +160,5 @@ throw new Error(`Provider ${provider} does not support asset ${asset} on ${network}`); | ||
export function getProviderAssetInverse(provider, asset) { | ||
const match = Object.entries(OnRampProviderAssetMap[getProvider(provider)]).find(([, theirAssetCode]) => asset === theirAssetCode); | ||
const match = Object.entries(OnRampProviderAssetMap[OnRampProvider[provider]]).find(([, theirAssetCode]) => asset === theirAssetCode); | ||
return match ? match[0] : undefined; | ||
} | ||
export function getNetwork(networkProp) { | ||
return NetworkMap[networkProp]; | ||
} | ||
export function getPortalDomain(env) { | ||
@@ -223,1 +190,31 @@ switch (env) { | ||
export const CURRENT_WALLET_IDS_CHANGE_EVENT = 'capsuleCurrentWalletIdsChange'; | ||
export function toAssetInfoArray(data) { | ||
const result = []; | ||
Object.keys(data).forEach(walletType => { | ||
const networks = data[walletType]; | ||
Object.keys(networks).forEach(network => { | ||
const assets = networks[network]; | ||
Object.keys(assets).forEach(asset => { | ||
const providerInfo = assets[asset]; | ||
result.push([walletType, network, asset, providerInfo]); | ||
}); | ||
}); | ||
}); | ||
return result; | ||
} | ||
export function getOnRampNetworks(data, { walletType, allowed } = {}) { | ||
return [ | ||
...new Set(toAssetInfoArray(data) | ||
.filter(([type, network]) => (!walletType || type === walletType) && (!allowed || allowed.includes(network))) | ||
.map(([_, network]) => network)), | ||
]; | ||
} | ||
export function getOnRampAssets(data, { walletType, network, allowed, } = {}) { | ||
return [ | ||
...new Set(toAssetInfoArray(data) | ||
.filter(([t, n, a]) => (!walletType || t === walletType) && | ||
(!network || n === network) && | ||
(!Array.isArray(allowed) || allowed.includes(a))) | ||
.map(([, , asset]) => asset)), | ||
]; | ||
} |
@@ -35,3 +35,3 @@ import Client from '@usecapsule/user-management-client'; | ||
userManagementHost: getBaseUrl(env), | ||
version: env === Environment.DEV ? 'dev' : version, | ||
version: [Environment.DEV, Environment.SANDBOX].includes(env) ? 'dev' : version, | ||
apiKey: apiKey, | ||
@@ -38,0 +38,0 @@ opts: { useFetchAdapter }, |
@@ -1,3 +0,3 @@ | ||
import { CoreCapsule, PREFIX as STORAGE_PREFIX, PregenIdentifierType, getSchemes } from './CoreCapsule.js'; | ||
export { WalletType, WalletScheme, NON_ED25519 } from '@usecapsule/user-management-client'; | ||
import { CoreCapsule, PREFIX as STORAGE_PREFIX, PregenIdentifierType, isWalletSupported, isTypeOptional, isTypeRequired, } from './CoreCapsule.js'; | ||
export { EmailTheme, WalletType, WalletScheme, OnRampPurchaseType, NON_ED25519, } from '@usecapsule/user-management-client'; | ||
export * from './definitions.js'; | ||
@@ -7,3 +7,3 @@ export * from './types/index.js'; | ||
export { KeyContainer } from './shares/KeyContainer.js'; | ||
export { RecoveryStatus, stringToPhoneNumber, ExternalWalletType } from './CoreCapsule.js'; | ||
export { RecoveryStatus, stringToPhoneNumber, entityToWallet } from './CoreCapsule.js'; | ||
export { initClient } from './external/capsuleClient.js'; | ||
@@ -19,5 +19,4 @@ import * as mpcComputationClient_1 from './external/mpcComputationClient.js'; | ||
export { retrieve as transmissionUtilsRetrieve } from './transmission/transmissionUtils.js'; | ||
export { STORAGE_PREFIX, PregenIdentifierType, getSchemes }; | ||
export { EmailTheme } from '@usecapsule/user-management-client'; | ||
export { STORAGE_PREFIX, PregenIdentifierType, isWalletSupported, isTypeOptional, isTypeRequired }; | ||
export const capsuleVersion = CoreCapsule.version; | ||
export default CoreCapsule; |
@@ -60,1 +60,5 @@ import { WalletType } from '@usecapsule/user-management-client'; | ||
} | ||
export function truncateAddress(str, addressType, { prefix = addressType === 'COSMOS' ? 'cosmos' : undefined } = {}) { | ||
const headLength = (addressType === 'COSMOS' ? prefix.length : addressType === 'SOLANA' ? 0 : 2) + 4; | ||
return `${str.slice(0, headLength)}...${str.slice(-4)}`; | ||
} |
@@ -1,17 +0,24 @@ | ||
import { BackupKitEmailProps, EmailTheme, OnRampPurchase, PartnerEntity, WalletEntity, WalletType, WalletScheme } from '@usecapsule/user-management-client'; | ||
import { BackupKitEmailProps, CurrentWalletIds, EmailTheme, OnRampPurchase, PartnerEntity, WalletEntity, WalletType, WalletScheme } from '@usecapsule/user-management-client'; | ||
import type { pki as pkiType } from 'node-forge'; | ||
import { Ctx, NetworkProp, OnRampAssetProp, OnRampProviderProp, Environment, OAuthMethod } from './definitions.js'; | ||
import { Ctx, Environment, OAuthMethod, WalletFilters, WalletTypeProp, NetworkProp, OnRampAssetProp, OnRampProviderProp } from './definitions.js'; | ||
import { Theme, FullSignatureRes } from './types/index.js'; | ||
import { PlatformUtils } from './PlatformUtils.js'; | ||
import { CountryCallingCode } from 'libphonenumber-js'; | ||
export declare function getSchemes(supportedWalletTypes: SupportedWalletTypes): WalletScheme[]; | ||
type WalletFilters = { | ||
type?: WalletType[]; | ||
scheme?: WalletScheme[]; | ||
forbidPregen?: boolean; | ||
export declare function entityToWallet(w: WalletEntity): Omit<Wallet, 'signer'>; | ||
export type EmbeddedWalletType = Exclude<WalletType, never>; | ||
export type ExternalWalletType = Exclude<WalletType, never>; | ||
export type SupportedWalletTypeConfig = { | ||
optional?: boolean; | ||
}; | ||
export type SupportedWalletTypesOpt = { | ||
[WalletType.EVM]?: boolean | SupportedWalletTypeConfig; | ||
[WalletType.SOLANA]?: boolean | SupportedWalletTypeConfig; | ||
[WalletType.COSMOS]?: boolean | (SupportedWalletTypeConfig & { | ||
prefix?: string; | ||
}); | ||
}; | ||
export type SupportedWalletTypes = { | ||
[WalletType.EVM]?: true; | ||
[WalletType.SOLANA]?: true; | ||
[WalletType.COSMOS]?: true | { | ||
[WalletType.EVM]?: SupportedWalletTypeConfig; | ||
[WalletType.SOLANA]?: SupportedWalletTypeConfig; | ||
[WalletType.COSMOS]?: SupportedWalletTypeConfig & { | ||
prefix?: string; | ||
@@ -31,7 +38,2 @@ }; | ||
} | ||
export declare enum ExternalWalletType { | ||
EVM = "EVM", | ||
SOLANA = "SOLANA", | ||
COSMOS = "COSMOS" | ||
} | ||
export interface Wallet { | ||
@@ -46,3 +48,3 @@ createdAt?: string; | ||
scheme?: WalletScheme; | ||
type?: WalletType; | ||
type?: EmbeddedWalletType | ExternalWalletType; | ||
isPregen?: boolean; | ||
@@ -57,7 +59,4 @@ pregenIdentifier?: string; | ||
lastUsedPartnerId?: string; | ||
isExternal?: boolean; | ||
} | ||
export interface ExternalWallet { | ||
address: string; | ||
type: ExternalWalletType; | ||
} | ||
export interface ConstructorOpts { | ||
@@ -140,7 +139,7 @@ useStorageOverrides?: boolean; | ||
/** | ||
* Which type of wallet your application supports, in the form `{ [WalletType]: true }`. Currently allowed values for `WalletType` are `'evm'`, `'solana'`, or `'cosmos'` (case insensitive). | ||
* Which type of wallet your application supports, in the form `{ [WalletType]: true }`. Currently allowed values for `WalletType` are `'EVM'`, `'SOLANA'`, or `'COSMOS'`. | ||
* | ||
* To specify which prefix to use for new Cosmos wallets, pass `{ cosmos: { prefix: 'your-prefix' } }`. Defaults to `'cosmos'`. | ||
* To specify which prefix to use for new Cosmos wallets, pass `{ COSMOS: { prefix: 'your-prefix' } }`. Defaults to `'cosmos'`. | ||
*/ | ||
supportedWalletTypes?: SupportedWalletTypes; | ||
supportedWalletTypes?: SupportedWalletTypesOpt; | ||
/** | ||
@@ -154,2 +153,11 @@ * If `true`, the SDK will use the device's temporary session storage instead of saving user and wallet data to local storage. | ||
export declare function normalizePhoneNumber(countryCode: string, number: string): string | undefined; | ||
export declare function isWalletSupported(types: SupportedWalletTypes | WalletType[], wallet: Omit<Wallet, 'signer'>): boolean; | ||
export declare function getWalletTypes(schemes: WalletScheme[]): WalletType[]; | ||
export declare function getEquivalentTypes(types: WalletTypeProp[] | WalletTypeProp): WalletType[]; | ||
export declare function isTypeRequired(value: undefined | boolean | SupportedWalletTypeConfig): value is true | { | ||
optional: false; | ||
}; | ||
export declare function isTypeOptional(value: undefined | boolean | SupportedWalletTypeConfig): value is { | ||
optional: true; | ||
}; | ||
export declare abstract class CoreCapsule { | ||
@@ -169,9 +177,11 @@ static version?: string; | ||
/** | ||
* The IDs of the currently active wallets. Any signer integrations will default to the first viable wallet ID in this list. | ||
* The IDs of the currently active wallets, for each supported wallet type. Any signer integrations will default to the first viable wallet ID in this dictionary. | ||
*/ | ||
currentWalletIds?: string[]; | ||
currentWalletIds: CurrentWalletIds; | ||
get currentWalletIdsArray(): [string, WalletType][]; | ||
get currentWalletIdsUnique(): string[]; | ||
/** | ||
* Wallets associated with the `CoreCapsule` instance. | ||
* Wallets associated with the `CoreCapsule` instance. Retrieve a particular wallet using `capsule.wallets[walletId]`. | ||
*/ | ||
wallets?: Record<string, Wallet>; | ||
wallets: Record<string, Wallet>; | ||
/** | ||
@@ -184,4 +194,8 @@ * The addresses of the currently active external wallets. | ||
*/ | ||
externalWallets?: Record<string, ExternalWallet>; | ||
externalWallets: Record<string, Wallet>; | ||
/** | ||
* Whether the instance has multiple wallets connected. | ||
*/ | ||
get isMultiWallet(): boolean; | ||
/** | ||
* Base theme for the emails sent from this Capsule instance. | ||
@@ -278,9 +292,19 @@ * @default - dark | ||
* Returns the formatted address for the desired wallet ID, depending on your app settings. | ||
* @param walletId - the ID of the wallet address to display. | ||
* @param options.truncate - whether to truncate the address. | ||
* @returns - the formatted address string. | ||
* @param {string} walletId the ID of the wallet address to display. | ||
* @param {object} options additional options for formatting the address. | ||
* @param {boolean} options.truncate whether to truncate the address. | ||
* @param {WalletType} options.addressType the type of address to display. | ||
* @returns the formatted address | ||
*/ | ||
getDisplayAddress(walletId: string, { truncate }?: { | ||
getDisplayAddress(walletId: string, options?: { | ||
truncate?: boolean; | ||
addressType?: WalletTypeProp | undefined; | ||
} | undefined): string; | ||
/** | ||
* Returns a unique hash for a wallet suitable for use as an identicon seed. | ||
* @param {string} walletId the ID of the wallet. | ||
* @param {boolean} options.addressType used to format the hash for another wallet type. | ||
* @returns the identicon hash string | ||
*/ | ||
getIdenticonHash(walletId: string, overrideType?: WalletType): string | undefined; | ||
getWallets(): Record<string, Wallet>; | ||
@@ -341,3 +365,3 @@ getAddress(walletId?: string): string | undefined; | ||
*/ | ||
setExternalWallets(externalWallets: Record<string, ExternalWallet>): Promise<void>; | ||
setExternalWallets(externalWallets: Record<string, Wallet>): Promise<void>; | ||
setCurrentExternalWalletAddresses(currentExternalWalletAddresses: string[]): Promise<void>; | ||
@@ -373,3 +397,3 @@ /** | ||
getPhoneNumber(): string | undefined; | ||
setCurrentWalletIds(currentWalletIds: string[], sessionLookupId?: string, needsWallet?: boolean): Promise<void>; | ||
setCurrentWalletIds(currentWalletIds: CurrentWalletIds, sessionLookupId?: string, needsWallet?: boolean): Promise<void>; | ||
/** | ||
@@ -387,4 +411,22 @@ * The prefix for the instance's managed Cosmos wallets. Defaults to `'cosmos'`. | ||
findWalletId(walletId?: string, filter?: WalletFilters): string; | ||
/** | ||
* Retrieves a wallet with the given address, if present. | ||
* If no ID is passed, this will instead return the first valid, usable wallet ID that matches the filters. | ||
* @param {string} [walletId] the wallet ID to validate. | ||
* @param {WalletFilters} [filter={}] a `WalletFilters` object specifying allowed types, schemes, and whether to forbid unclaimed pregen wallets. | ||
* @returns {string} the wallet ID originally passed, or the one found. | ||
*/ | ||
findWalletByAddress(address: string, filter?: WalletFilters | undefined): any; | ||
findWallet(idOrAddress?: string, overrideType?: WalletTypeProp, filter?: WalletFilters): Omit<Wallet, 'signer'> | undefined; | ||
get availableWallets(): Pick<Wallet, 'id' | 'type' | 'name' | 'address' | 'isExternal'>[]; | ||
/** | ||
* Retrieves all usable wallets with the provided type (`'EVM' | 'COSMOS' | 'SOLANA'`) | ||
* @param {string} type the wallet type to filter by. | ||
* @returns {Wallet[]} an array of matching wallets. | ||
*/ | ||
getWalletsByType(type: WalletTypeProp): Wallet[]; | ||
private assertIsValidWalletId; | ||
private assertIsValidWalletType; | ||
private getMissingTypes; | ||
private getTypesToCreate; | ||
private getPartnerURL; | ||
@@ -557,3 +599,3 @@ /** | ||
waitForPasskeyAndCreateWallet(): Promise<{ | ||
walletIds: string[]; | ||
walletIds: CurrentWalletIds; | ||
recoverySecret?: string; | ||
@@ -632,6 +674,30 @@ }>; | ||
private waitForPregenWalletAddress; | ||
createWalletPerMissingType(skipDistribute?: boolean): Promise<{ | ||
/** | ||
* Creates several new wallets with the desired types. If no types are provided, this method | ||
* will create one for each of the non-optional types specified in the instance's `supportedWalletTypes` | ||
* object that are not already present. This is automatically called upon account creation to ensure that | ||
* the user has a wallet of each required type. | ||
* | ||
* @deprecated alias for `createWalletPerType` | ||
**/ | ||
createWalletPerMissingType: (skipDistribute?: boolean, types?: WalletType[]) => Promise<{ | ||
wallets: Wallet[]; | ||
walletIds: CurrentWalletIds; | ||
recoverySecret?: string; | ||
}>; | ||
/** | ||
* Creates several new wallets with the desired types. If no types are provided, this method | ||
* will create one for each of the non-optional types specified in the instance's `supportedWalletTypes` | ||
* object that are not already present. This is automatically called upon account creation to ensure that | ||
* the user has a wallet of each required type. | ||
* | ||
* @param {boolean} [skipDistribute] if `true`, the wallets' recovery share will not be distributed. | ||
* @param {WalletType[]} [types] the types of wallets to create. | ||
* @returns the wallets created, their ids, and the recovery secret. | ||
**/ | ||
createWalletPerType(skipDistribute?: boolean, types?: WalletType[]): Promise<{ | ||
wallets: Wallet[]; | ||
walletIds: CurrentWalletIds; | ||
recoverySecret?: string; | ||
}>; | ||
refreshShare({ walletId, share, oldPartnerId, newPartnerId, redistributeBackupEncryptedShares, }: { | ||
@@ -665,2 +731,13 @@ walletId: string; | ||
/** | ||
* Creates new pregenerated wallets for each desired type. | ||
* If no types are provided, this method will create one for each of the non-optional types | ||
* specified in the instance's `supportedWalletTypes` object that are not already present. | ||
* | ||
* @param {string} pregenIdentifier the identifier to associate each wallet with. | ||
* @param {PregenIdentifierType} pregenIdentifierType - either `'EMAIL'` or `'PHONE'`. | ||
* @param {WalletType[]} [types] the wallet types to create. Defaults to any types the instance supports that are not already present. | ||
* @returns an array containing the created wallets. | ||
**/ | ||
createPregenWalletPerType(pregenIdentifier: string, pregenIdentifierType?: PregenIdentifierType, types?: WalletType[]): Promise<Wallet[]>; | ||
/** | ||
* Claims a pregenerated wallet. | ||
@@ -809,2 +886,1 @@ * | ||
} | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import Client, { Network, OnRampAsset, OnRampProvider, OnRampPurchase, OnRampPurchaseStatus, WalletScheme, WalletType } from '@usecapsule/user-management-client'; | ||
import Client, { Network, OnRampAsset, OnRampProvider, OnRampPurchase, OnRampPurchaseStatus, OnRampPurchaseType, WalletScheme, WalletType } from '@usecapsule/user-management-client'; | ||
import { AxiosInstance } from 'axios'; | ||
@@ -34,23 +34,17 @@ export { Network, OnRampAsset, OnRampProvider, OnRampPurchaseStatus, type OnRampPurchase }; | ||
} | ||
export declare const NetworkMap: { | ||
ethereum: Network; | ||
ETHEREUM: Network; | ||
arbitrum: Network; | ||
ARBITRUM: Network; | ||
base: Network; | ||
BASE: Network; | ||
optimism: Network; | ||
OPTIMISM: Network; | ||
POLYGON: Network; | ||
polygon: Network; | ||
export type NetworkProp = keyof typeof Network | Network; | ||
export type WalletTypeProp = keyof typeof WalletType | WalletType; | ||
export declare const WalletSchemeMap: { | ||
DKLS: WalletScheme; | ||
CGGMP: WalletScheme; | ||
ED25519: WalletScheme; | ||
}; | ||
export type NetworkProp = keyof typeof NetworkMap | Network; | ||
export declare const SupportedOnRamps: Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, boolean>>>>>; | ||
export declare const OnRampProviderMap: { | ||
STRIPE: OnRampProvider; | ||
stripe: OnRampProvider; | ||
RAMP: OnRampProvider; | ||
ramp: OnRampProvider; | ||
export type WalletSchemeProp = keyof typeof WalletScheme | WalletScheme; | ||
export type WalletFilters = { | ||
type?: WalletTypeProp[]; | ||
scheme?: WalletSchemeProp[]; | ||
forbidPregen?: boolean; | ||
}; | ||
export type OnRampProviderProp = keyof typeof OnRampProviderMap | OnRampProvider; | ||
export declare const SupportedOnRamps: Partial<Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, boolean>>>>>>; | ||
export type OnRampProviderProp = keyof typeof OnRampProvider | OnRampProvider; | ||
export type RampConfig = { | ||
@@ -63,19 +57,8 @@ id: OnRampProviderProp; | ||
}; | ||
export declare const OnRampAssetMap: { | ||
eth: OnRampAsset; | ||
ETH: OnRampAsset; | ||
ethereum: OnRampAsset; | ||
ETHEREUM: OnRampAsset; | ||
usdc: OnRampAsset; | ||
USDC: OnRampAsset; | ||
polygon: OnRampAsset; | ||
POLYGON: OnRampAsset; | ||
matic: OnRampAsset; | ||
MATIC: OnRampAsset; | ||
}; | ||
export type OnRampAssetProp = keyof typeof OnRampAssetMap | OnRampAsset; | ||
export type OnRampAssetProp = keyof typeof OnRampAsset | OnRampAsset; | ||
export type OnRampConfigProvider = RampConfig | StripeConfig; | ||
export declare enum EnabledFlow { | ||
BUY = "BUY", | ||
RECEIVE = "RECEIVE" | ||
RECEIVE = "RECEIVE", | ||
WITHDRAW = "WITHDRAW" | ||
} | ||
@@ -121,8 +104,5 @@ export type EnabledFlowProp = keyof typeof EnabledFlow | EnabledFlow; | ||
} | ||
export declare function getProvider(key: OnRampProviderProp): OnRampProvider; | ||
export declare function getAsset(key: OnRampAssetProp): OnRampAsset; | ||
export declare const WalletSchemeMap: Record<WalletScheme, Partial<Record<WalletType, true>>>; | ||
export declare const WalletSchemeTypeMap: Record<WalletScheme, Partial<Record<WalletType, true>>>; | ||
export declare const getProviderNetworkAndAssetCode: (networkProp: NetworkProp, assetProp: OnRampAssetProp, providerProp: OnRampProviderProp, testMode?: boolean) => [string, string?]; | ||
export declare function getProviderAssetInverse(provider: OnRampProviderProp, asset: string): OnRampAsset; | ||
export declare function getNetwork(networkProp: NetworkProp): Network; | ||
export declare function getPortalDomain(env: Environment): "localhost" | "app.sandbox.usecapsule.com" | "app.beta.usecapsule.com" | "app.usecapsule.com"; | ||
@@ -134,1 +114,14 @@ export declare function getPortalBaseURL({ env }: { | ||
export declare const CURRENT_WALLET_IDS_CHANGE_EVENT = "capsuleCurrentWalletIdsChange"; | ||
type ProviderAssetInfo = [string, Partial<Record<OnRampPurchaseType, boolean>>]; | ||
export type OnRampAssetInfo = Record<WalletType, Partial<Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>>>>>>; | ||
export type OnRampAssetInfoRow = [WalletType, Network, OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>]; | ||
export declare function toAssetInfoArray(data: OnRampAssetInfo): OnRampAssetInfoRow[]; | ||
export declare function getOnRampNetworks(data: OnRampAssetInfo, { walletType, allowed }?: { | ||
walletType?: WalletType; | ||
allowed?: Network[]; | ||
}): Network[]; | ||
export declare function getOnRampAssets(data: OnRampAssetInfo, { walletType, network, allowed, }?: { | ||
walletType?: WalletTypeProp; | ||
network?: NetworkProp; | ||
allowed?: OnRampAssetProp[]; | ||
}): OnRampAsset[]; |
@@ -1,3 +0,3 @@ | ||
import { CoreCapsule, PREFIX as STORAGE_PREFIX, PregenIdentifierType, getSchemes } from './CoreCapsule.js'; | ||
export { WalletType, WalletScheme, NON_ED25519 } from '@usecapsule/user-management-client'; | ||
import { CoreCapsule, PREFIX as STORAGE_PREFIX, PregenIdentifierType, isWalletSupported, isTypeOptional, isTypeRequired } from './CoreCapsule.js'; | ||
export { type CurrentWalletIds, EmailTheme, type PartnerEntity, type WalletEntity, WalletType, WalletScheme, OnRampPurchaseType, NON_ED25519, } from '@usecapsule/user-management-client'; | ||
export * from './definitions.js'; | ||
@@ -8,4 +8,4 @@ export type { Ctx } from './definitions.js'; | ||
export { KeyContainer } from './shares/KeyContainer.js'; | ||
export { RecoveryStatus, stringToPhoneNumber, ExternalWalletType } from './CoreCapsule.js'; | ||
export type { Wallet, ConstructorOpts, SupportedWalletTypes } from './CoreCapsule.js'; | ||
export { RecoveryStatus, stringToPhoneNumber, entityToWallet } from './CoreCapsule.js'; | ||
export type { Wallet, ConstructorOpts, SupportedWalletTypes, ExternalWalletType } from './CoreCapsule.js'; | ||
export type { PlatformUtils } from './PlatformUtils.js'; | ||
@@ -22,5 +22,4 @@ export type { StorageUtils } from './StorageUtils.js'; | ||
export { retrieve as transmissionUtilsRetrieve } from './transmission/transmissionUtils.js'; | ||
export { STORAGE_PREFIX, PregenIdentifierType, getSchemes }; | ||
export { EmailTheme } from '@usecapsule/user-management-client'; | ||
export { STORAGE_PREFIX, PregenIdentifierType, isWalletSupported, isTypeOptional, isTypeRequired }; | ||
export declare const capsuleVersion: string; | ||
export default CoreCapsule; |
import { WalletType } from '@usecapsule/user-management-client'; | ||
import { SupportedWalletTypes } from '../CoreCapsule'; | ||
import { SupportedWalletTypeConfig, SupportedWalletTypes } from '../CoreCapsule'; | ||
import { WalletTypeProp } from '../definitions'; | ||
export type Hex = `0x${string}`; | ||
@@ -15,3 +16,3 @@ export interface Signature { | ||
export declare function isCosmosWithPrefix(supportedWalletTypes: SupportedWalletTypes): supportedWalletTypes is { | ||
[WalletType.COSMOS]: { | ||
[WalletType.COSMOS]: SupportedWalletTypeConfig & { | ||
prefix: string; | ||
@@ -21,1 +22,4 @@ }; | ||
export declare function getCosmosAddress(publicKey: string, prefix: string): string; | ||
export declare function truncateAddress(str: string, addressType: WalletTypeProp, { prefix }?: { | ||
prefix?: string; | ||
}): string; |
{ | ||
"name": "@usecapsule/core-sdk", | ||
"version": "1.24.1", | ||
"version": "2.0.0", | ||
"main": "dist/cjs/index.js", | ||
@@ -13,3 +13,3 @@ "module": "dist/esm/index.js", | ||
"@noble/hashes": "^1.5.0", | ||
"@usecapsule/user-management-client": "1.21.1", | ||
"@usecapsule/user-management-client": "1.22.0", | ||
"base64url": "^3.0.1", | ||
@@ -43,3 +43,3 @@ "buffer": "6.0.3", | ||
}, | ||
"gitHead": "e360ffa87553d566b73df627fbcc114e6e737391" | ||
"gitHead": "6ba94d306d6770db6cfe9b3feb0de84d94c3b26e" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
337712
7124
+ Added@usecapsule/user-management-client@1.22.0(transitive)
- Removed@usecapsule/user-management-client@1.21.1(transitive)