@usecapsule/user-management-client
Advanced tools
Comparing version 1.18.0 to 1.19.0
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OnRampPurchaseStatus = exports.OnRampAsset = exports.OnRampProvider = exports.Network = exports.KeyType = exports.EncryptorType = exports.Chain = exports.SignatureScheme = exports.PublicKeyType = exports.PublicKeyStatus = exports.EmailTheme = exports.USER_NOT_MATCHING_ERROR = exports.USER_NOT_AUTHENTICATED_ERROR = exports.USER_NOT_VERIFIED = void 0; | ||
exports.OnRampPurchaseStatus = exports.OnRampAsset = exports.OnRampProvider = exports.Network = exports.KeyType = exports.EncryptorType = exports.Chain = exports.NON_ED25519 = exports.WalletType = exports.WalletScheme = exports.PublicKeyType = exports.PublicKeyStatus = exports.EmailTheme = exports.USER_NOT_MATCHING_ERROR = exports.USER_NOT_AUTHENTICATED_ERROR = exports.USER_NOT_VERIFIED = void 0; | ||
const axios_1 = __importDefault(require("axios")); | ||
@@ -48,8 +48,15 @@ const qs_1 = __importDefault(require("qs")); | ||
})(PublicKeyType || (exports.PublicKeyType = PublicKeyType = {})); | ||
var SignatureScheme; | ||
(function (SignatureScheme) { | ||
SignatureScheme["DKLS"] = "DKLS"; | ||
SignatureScheme["CGGMP"] = "CGGMP"; | ||
SignatureScheme["ED25519"] = "ED25519"; | ||
})(SignatureScheme || (exports.SignatureScheme = SignatureScheme = {})); | ||
var WalletScheme; | ||
(function (WalletScheme) { | ||
WalletScheme["DKLS"] = "DKLS"; | ||
WalletScheme["CGGMP"] = "CGGMP"; | ||
WalletScheme["ED25519"] = "ED25519"; | ||
})(WalletScheme || (exports.WalletScheme = WalletScheme = {})); | ||
var WalletType; | ||
(function (WalletType) { | ||
WalletType["EVM"] = "EVM"; | ||
WalletType["SOLANA"] = "SOLANA"; | ||
WalletType["COSMOS"] = "COSMOS"; | ||
})(WalletType || (exports.WalletType = WalletType = {})); | ||
exports.NON_ED25519 = [WalletScheme.DKLS, WalletScheme.CGGMP]; | ||
var Chain; | ||
@@ -97,4 +104,5 @@ (function (Chain) { | ||
const SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid'; | ||
const VERSION_HEADER_NAME = 'x-capsule-version'; | ||
class Client { | ||
constructor({ userManagementHost, apiKey, opts, retrieveSessionCookie, persistSessionCookie }) { | ||
constructor({ userManagementHost, apiKey, version, opts, retrieveSessionCookie, persistSessionCookie }) { | ||
this.createUser = (body) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -193,3 +201,3 @@ const res = yield this.baseRequest.post(`/users`, body); | ||
// POST /wallets/pregen | ||
this.createPregenWallet = (body) => __awaiter(this, void 0, void 0, function* () { | ||
this.createWalletPreGen = (body) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/wallets/pregen`, body); | ||
@@ -199,4 +207,4 @@ return res.data; | ||
// GET /wallets/pregen?pregenIdentifier={pregenIdentifier}&pregenIdentifierType={pregenIdentifierType} | ||
this.getPregenWallets = (pregenIdentifier, pregenIdentifierType) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/wallets/pregen?pregenIdentifier=${encodeURIComponent(pregenIdentifier)}&pregenIdentifierType=${encodeURIComponent(pregenIdentifierType)}`); | ||
this.getPregenWallets = (pregenIdentifier_1, pregenIdentifierType_1, ...args_1) => __awaiter(this, [pregenIdentifier_1, pregenIdentifierType_1, ...args_1], void 0, function* (pregenIdentifier, pregenIdentifierType, expand = false) { | ||
const res = yield this.baseRequest.get(`/wallets/pregen?pregenIdentifier=${encodeURIComponent(pregenIdentifier)}&pregenIdentifierType=${encodeURIComponent(pregenIdentifierType)}${expand ? '&expand=true' : ''}`); | ||
return res.data; | ||
@@ -234,2 +242,12 @@ }); | ||
}); | ||
// GET /users/:userId/all-wallets | ||
this.getAllWallets = (userId) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/users/${userId}/all-wallets`); | ||
return res; | ||
}); | ||
// POST /users/:userId/wallets/set | ||
this.setCurrentWalletIds = (userId, walletIds, sessionLookupId) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/users/${userId}/wallets/set`, { walletIds, sessionLookupId }); | ||
return res; | ||
}); | ||
// POST /login | ||
@@ -301,2 +319,5 @@ this.login = (props) => __awaiter(this, void 0, void 0, function* () { | ||
} | ||
if (version) { | ||
headers[VERSION_HEADER_NAME] = version; | ||
} | ||
return data; | ||
@@ -330,3 +351,3 @@ }, | ||
}) | ||
.then((response) => response.text().then((text) => ({ | ||
.then(response => response.text().then(text => ({ | ||
data: text, | ||
@@ -393,4 +414,4 @@ status: response.status, | ||
resendVerificationCode(_a) { | ||
var { userId } = _a, rest = __rest(_a, ["userId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
var { userId } = _a, rest = __rest(_a, ["userId"]); | ||
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`, rest); | ||
@@ -402,4 +423,4 @@ return res; | ||
resendVerificationCodeByPhone(_a) { | ||
var { userId } = _a, rest = __rest(_a, ["userId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
var { userId } = _a, rest = __rest(_a, ["userId"]); | ||
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code-by-phone`, rest); | ||
@@ -530,5 +551,5 @@ return res; | ||
} | ||
acceptScopes(userId, body) { | ||
acceptScopes(userId, walletId, body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/users/${userId}/scopes/accept`, body); | ||
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/scopes/accept`, body); | ||
return res; | ||
@@ -549,10 +570,4 @@ }); | ||
} | ||
getPolicyPermissions(userId, policyId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/users/${userId}/policies/${policyId}/permissions`); | ||
return res; | ||
}); | ||
} | ||
createOnRampPurchase(userId, walletId, provider, network, asset, testMode = false) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
createOnRampPurchase(userId_1, walletId_1, provider_1, network_1, asset_1) { | ||
return __awaiter(this, arguments, void 0, function* (userId, walletId, provider, network, asset, testMode = false) { | ||
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/purchases`, { | ||
@@ -580,4 +595,4 @@ provider, | ||
distributeCapsuleShare(_a) { | ||
var { userId, walletId } = _a, rest = __rest(_a, ["userId", "walletId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
var { userId, walletId } = _a, rest = __rest(_a, ["userId", "walletId"]); | ||
const body = rest; | ||
@@ -619,2 +634,8 @@ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/capsule-share/distribute`, body); | ||
} | ||
getEthToUsdConversionRate() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get('/ethToUsdConversionRate'); | ||
return res.data; | ||
}); | ||
} | ||
} | ||
@@ -631,3 +652,2 @@ exports.default = Client; | ||
// GET /users/:userId/configurations | ||
// POST /users/:userId/permissions | ||
// GET / |
@@ -41,8 +41,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
})(PublicKeyType || (PublicKeyType = {})); | ||
export var SignatureScheme; | ||
(function (SignatureScheme) { | ||
SignatureScheme["DKLS"] = "DKLS"; | ||
SignatureScheme["CGGMP"] = "CGGMP"; | ||
SignatureScheme["ED25519"] = "ED25519"; | ||
})(SignatureScheme || (SignatureScheme = {})); | ||
export var WalletScheme; | ||
(function (WalletScheme) { | ||
WalletScheme["DKLS"] = "DKLS"; | ||
WalletScheme["CGGMP"] = "CGGMP"; | ||
WalletScheme["ED25519"] = "ED25519"; | ||
})(WalletScheme || (WalletScheme = {})); | ||
export var WalletType; | ||
(function (WalletType) { | ||
WalletType["EVM"] = "EVM"; | ||
WalletType["SOLANA"] = "SOLANA"; | ||
WalletType["COSMOS"] = "COSMOS"; | ||
})(WalletType || (WalletType = {})); | ||
export const NON_ED25519 = [WalletScheme.DKLS, WalletScheme.CGGMP]; | ||
export var Chain; | ||
@@ -90,4 +97,5 @@ (function (Chain) { | ||
const SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid'; | ||
const VERSION_HEADER_NAME = 'x-capsule-version'; | ||
class Client { | ||
constructor({ userManagementHost, apiKey, opts, retrieveSessionCookie, persistSessionCookie }) { | ||
constructor({ userManagementHost, apiKey, version, opts, retrieveSessionCookie, persistSessionCookie }) { | ||
this.createUser = (body) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -186,3 +194,3 @@ const res = yield this.baseRequest.post(`/users`, body); | ||
// POST /wallets/pregen | ||
this.createPregenWallet = (body) => __awaiter(this, void 0, void 0, function* () { | ||
this.createWalletPreGen = (body) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/wallets/pregen`, body); | ||
@@ -192,4 +200,4 @@ return res.data; | ||
// GET /wallets/pregen?pregenIdentifier={pregenIdentifier}&pregenIdentifierType={pregenIdentifierType} | ||
this.getPregenWallets = (pregenIdentifier, pregenIdentifierType) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/wallets/pregen?pregenIdentifier=${encodeURIComponent(pregenIdentifier)}&pregenIdentifierType=${encodeURIComponent(pregenIdentifierType)}`); | ||
this.getPregenWallets = (pregenIdentifier_1, pregenIdentifierType_1, ...args_1) => __awaiter(this, [pregenIdentifier_1, pregenIdentifierType_1, ...args_1], void 0, function* (pregenIdentifier, pregenIdentifierType, expand = false) { | ||
const res = yield this.baseRequest.get(`/wallets/pregen?pregenIdentifier=${encodeURIComponent(pregenIdentifier)}&pregenIdentifierType=${encodeURIComponent(pregenIdentifierType)}${expand ? '&expand=true' : ''}`); | ||
return res.data; | ||
@@ -227,2 +235,12 @@ }); | ||
}); | ||
// GET /users/:userId/all-wallets | ||
this.getAllWallets = (userId) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/users/${userId}/all-wallets`); | ||
return res; | ||
}); | ||
// POST /users/:userId/wallets/set | ||
this.setCurrentWalletIds = (userId, walletIds, sessionLookupId) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/users/${userId}/wallets/set`, { walletIds, sessionLookupId }); | ||
return res; | ||
}); | ||
// POST /login | ||
@@ -294,2 +312,5 @@ this.login = (props) => __awaiter(this, void 0, void 0, function* () { | ||
} | ||
if (version) { | ||
headers[VERSION_HEADER_NAME] = version; | ||
} | ||
return data; | ||
@@ -323,3 +344,3 @@ }, | ||
}) | ||
.then((response) => response.text().then((text) => ({ | ||
.then(response => response.text().then(text => ({ | ||
data: text, | ||
@@ -386,4 +407,4 @@ status: response.status, | ||
resendVerificationCode(_a) { | ||
var { userId } = _a, rest = __rest(_a, ["userId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
var { userId } = _a, rest = __rest(_a, ["userId"]); | ||
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`, rest); | ||
@@ -395,4 +416,4 @@ return res; | ||
resendVerificationCodeByPhone(_a) { | ||
var { userId } = _a, rest = __rest(_a, ["userId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
var { userId } = _a, rest = __rest(_a, ["userId"]); | ||
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code-by-phone`, rest); | ||
@@ -523,5 +544,5 @@ return res; | ||
} | ||
acceptScopes(userId, body) { | ||
acceptScopes(userId, walletId, body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/users/${userId}/scopes/accept`, body); | ||
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/scopes/accept`, body); | ||
return res; | ||
@@ -542,10 +563,4 @@ }); | ||
} | ||
getPolicyPermissions(userId, policyId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/users/${userId}/policies/${policyId}/permissions`); | ||
return res; | ||
}); | ||
} | ||
createOnRampPurchase(userId, walletId, provider, network, asset, testMode = false) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
createOnRampPurchase(userId_1, walletId_1, provider_1, network_1, asset_1) { | ||
return __awaiter(this, arguments, void 0, function* (userId, walletId, provider, network, asset, testMode = false) { | ||
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/purchases`, { | ||
@@ -573,4 +588,4 @@ provider, | ||
distributeCapsuleShare(_a) { | ||
var { userId, walletId } = _a, rest = __rest(_a, ["userId", "walletId"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
var { userId, walletId } = _a, rest = __rest(_a, ["userId", "walletId"]); | ||
const body = rest; | ||
@@ -612,2 +627,8 @@ const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/capsule-share/distribute`, body); | ||
} | ||
getEthToUsdConversionRate() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get('/ethToUsdConversionRate'); | ||
return res.data; | ||
}); | ||
} | ||
} | ||
@@ -624,3 +645,2 @@ export default Client; | ||
// GET /users/:userId/configurations | ||
// POST /users/:userId/permissions | ||
// GET / |
@@ -10,2 +10,3 @@ import { AxiosResponse } from 'axios'; | ||
userManagementHost: string; | ||
version?: string; | ||
apiKey?: string; | ||
@@ -99,3 +100,3 @@ opts?: ConfigOpts; | ||
} | ||
export declare enum SignatureScheme { | ||
export declare enum WalletScheme { | ||
DKLS = "DKLS", | ||
@@ -105,5 +106,19 @@ CGGMP = "CGGMP", | ||
} | ||
export declare enum WalletType { | ||
EVM = "EVM", | ||
SOLANA = "SOLANA", | ||
COSMOS = "COSMOS" | ||
} | ||
export declare const NON_ED25519: WalletScheme[]; | ||
export interface PartnerEntity { | ||
id: string; | ||
displayName: string; | ||
logoUrl?: string; | ||
portalHeaderLogoUrl?: string; | ||
policiesEnabled: boolean; | ||
} | ||
export interface WalletEntity { | ||
address: string | null; | ||
createdAt: string; | ||
isPregen?: boolean; | ||
pregenIdentifier: string; | ||
@@ -115,2 +130,3 @@ pregenIdentifierType: string; | ||
partnerId: string; | ||
partner?: PartnerEntity; | ||
publicKey: string | null; | ||
@@ -121,2 +137,5 @@ scheme: string; | ||
userId: string | null; | ||
lastUsedAt: string | null; | ||
lastUsedPartnerId?: string; | ||
lastUsedPartner?: PartnerEntity; | ||
} | ||
@@ -128,3 +147,4 @@ interface getWalletsRes { | ||
useTwoSigners?: boolean; | ||
scheme: SignatureScheme; | ||
scheme: WalletScheme; | ||
type: WalletType; | ||
} | ||
@@ -139,6 +159,7 @@ interface updatePregenWalletBody { | ||
} | ||
interface createPreGenWalletBody { | ||
interface createWalletPreGenBody { | ||
pregenIdentifier: string; | ||
pregenIdentifierType: string; | ||
scheme?: SignatureScheme; | ||
scheme?: WalletScheme; | ||
type: WalletType; | ||
} | ||
@@ -219,3 +240,3 @@ interface claimPreGenWalletBody { | ||
private baseRequest; | ||
constructor({ userManagementHost, apiKey, opts, retrieveSessionCookie, persistSessionCookie }: ClientConfig); | ||
constructor({ userManagementHost, apiKey, version, opts, retrieveSessionCookie, persistSessionCookie }: ClientConfig); | ||
createUser: (body: (createUserBody | createUserBodyForPhone) & VerificationEmailProps) => Promise<createUserIdRes>; | ||
@@ -235,4 +256,4 @@ checkUserExists: (email: string, phone: string, countryCode: string) => Promise<any>; | ||
createWallet: (userId: string, body?: createWalletBody) => Promise<createWalletRes>; | ||
createPregenWallet: (body?: createPreGenWalletBody) => Promise<createWalletRes>; | ||
getPregenWallets: (pregenIdentifier: string, pregenIdentifierType: string) => Promise<getWalletsRes>; | ||
createWalletPreGen: (body?: createWalletPreGenBody) => Promise<createWalletRes>; | ||
getPregenWallets: (pregenIdentifier: string, pregenIdentifierType: string, expand?: boolean) => Promise<getWalletsRes>; | ||
claimPregenWallet: (body?: claimPreGenWalletBody) => Promise<void>; | ||
@@ -244,2 +265,4 @@ sendTransaction: (userId: string, walletId: string, body: sendTransactionBody) => Promise<any>; | ||
getWallets: (userId: string) => Promise<AxiosResponse<getWalletsRes, any>>; | ||
getAllWallets: (userId: string) => Promise<AxiosResponse<getWalletsRes, any>>; | ||
setCurrentWalletIds: (userId: string, walletIds: string[], sessionLookupId?: string) => Promise<any>; | ||
login: (props: { | ||
@@ -252,3 +275,3 @@ email: string; | ||
recoveryInit: (email: string) => Promise<any>; | ||
preSignMessage: (userId: string, walletId: string, message: string, scheme?: SignatureScheme) => Promise<any>; | ||
preSignMessage: (userId: string, walletId: string, message: string, scheme?: WalletScheme) => Promise<any>; | ||
deleteSelf: (userId: string) => Promise<any>; | ||
@@ -293,6 +316,5 @@ uploadKeyshares(userId: string, walletId: string, encryptedKeyshares: encryptedKeyshare[]): Promise<any>; | ||
getPartner(partnerId: string): Promise<AxiosResponse<any, any>>; | ||
acceptScopes(userId: string, body: AcceptScopesBody): Promise<AxiosResponse<any, any>>; | ||
acceptScopes(userId: string, walletId: string, body: AcceptScopesBody): Promise<AxiosResponse<any, any>>; | ||
getPendingTransaction(userId: string, pendingTransactionid: string): Promise<AxiosResponse<any, any>>; | ||
acceptPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<any, any>>; | ||
getPolicyPermissions(userId: string, policyId: string): Promise<AxiosResponse<any, any>>; | ||
createOnRampPurchase(userId: string, walletId: string, provider: OnRampProvider, network: Network, asset: OnRampAsset, testMode?: boolean): Promise<AxiosResponse<OnRampPurchase, any>>; | ||
@@ -321,3 +343,4 @@ updateOnRampPurchase(userId: string, walletId: string, purchaseId: string, updates: Partial<Pick<OnRampPurchase, 'status' | 'fiatCurrency' | 'fiatQuantity' | 'providerKey'>>): Promise<AxiosResponse<OnRampPurchase, any>>; | ||
getEncryptedWalletPrivateKeys(userId: string, encryptionKeyHash: string): Promise<any>; | ||
getEthToUsdConversionRate(): Promise<any>; | ||
} | ||
export default Client; |
{ | ||
"name": "@usecapsule/user-management-client", | ||
"version": "1.18.0", | ||
"version": "1.19.0", | ||
"main": "dist/cjs/index.js", | ||
@@ -33,3 +33,3 @@ "module": "dist/esm/index.js", | ||
}, | ||
"gitHead": "becb455c08a189bd8bc049df1f80e6095912bf55" | ||
"gitHead": "2f9f59b43c147849f37d50a136970f56dce05be9" | ||
} |
74348
1632