@usecapsule/user-management-client
Advanced tools
Comparing version 1.26.4 to 1.27.0
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OnRampPurchaseType = 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; | ||
exports.PasswordStatus = exports.OnRampPurchaseType = 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")); | ||
@@ -73,2 +73,3 @@ const qs_1 = __importDefault(require("qs")); | ||
EncryptorType["BIOMETRICS"] = "BIOMETRICS"; | ||
EncryptorType["PASSWORD"] = "PASSWORD"; | ||
})(EncryptorType || (exports.EncryptorType = EncryptorType = {})); | ||
@@ -121,2 +122,7 @@ exports.KeyType = { | ||
})(OnRampPurchaseType || (exports.OnRampPurchaseType = OnRampPurchaseType = {})); | ||
var PasswordStatus; | ||
(function (PasswordStatus) { | ||
PasswordStatus["PENDING"] = "PENDING"; | ||
PasswordStatus["COMPLETE"] = "COMPLETE"; | ||
})(PasswordStatus || (exports.PasswordStatus = PasswordStatus = {})); | ||
const SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid'; | ||
@@ -334,2 +340,11 @@ const VERSION_HEADER_NAME = 'x-capsule-version'; | ||
}); | ||
// PATCH /users/:userId/biometrics/:biometricId | ||
this.patchSessionPassword = (partnerId, userId, passwordId, body) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.patch(`/users/${userId}/passwords/${passwordId}`, body, { | ||
headers: { | ||
'X-Partner-ID': partnerId, | ||
}, | ||
}); | ||
return res; | ||
}); | ||
// TODO remove after this is not optional anymore | ||
@@ -428,2 +443,9 @@ const headers = apiKey ? { 'X-External-API-Key': apiKey } : undefined; | ||
} | ||
// GET /users/:userId/key-shares | ||
getPasswordKeyshares(userId, passwordId, getAll) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/users/${userId}/passwords/key-shares?passwordId=${passwordId}&all=${!!getAll}`); | ||
return res; | ||
}); | ||
} | ||
// POST '/users/:userId/temporary-shares', | ||
@@ -708,5 +730,5 @@ uploadTransmissionKeyshares(userId, shares) { | ||
} | ||
uploadEncryptedWalletPrivateKey(userId, encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey) { | ||
uploadEncryptedWalletPrivateKey(userId, encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const body = { encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey }; | ||
const body = { encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId }; | ||
const res = yield this.baseRequest.post(`/users/${userId}/encrypted-wallet-private-keys`, body); | ||
@@ -756,2 +778,58 @@ return res.data; | ||
} | ||
// POST /users/:userId/passwords/key | ||
addSessionPasswordPublicKey(userId, body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/users/${userId}/passwords/key`, body); | ||
return res; | ||
}); | ||
} | ||
getSupportedAuthMethods(userId, email, phone, countryCode, farcasterUsername) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/users/supported-auth-methods?userId=${userId}&email=${encodeURIComponent(email)}&phone=${encodeURIComponent(phone)}&countryCode=${encodeURIComponent(countryCode)}&farcasterUsername=${encodeURIComponent(farcasterUsername)}`); | ||
return res.data; | ||
}); | ||
} | ||
getPasswords(userId, email, phone, countryCode, farcasterUsername) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const queryParams = {}; | ||
if (userId) { | ||
queryParams['userId'] = userId; | ||
} | ||
if (email) { | ||
queryParams['email'] = email; | ||
} | ||
if (phone) { | ||
queryParams['phone'] = phone; | ||
} | ||
if (countryCode) { | ||
queryParams['countryCode'] = countryCode; | ||
} | ||
if (farcasterUsername) { | ||
queryParams['farcasterUsername'] = farcasterUsername; | ||
} | ||
const query = qs_1.default.stringify(queryParams); | ||
const res = yield this.baseRequest.get(`/users/passwords${query === '' ? '' : `?${query}`}`); | ||
return res.data.passwords; | ||
}); | ||
} | ||
// POST /passwords/verify | ||
verifyPasswordChallenge(partnerId, body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/passwords/verify`, body, { | ||
headers: { | ||
'X-Partner-ID': partnerId, | ||
}, | ||
}); | ||
return res; | ||
}); | ||
} | ||
getEncryptedWalletPrivateKey(passwordId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const queryParams = {}; | ||
queryParams['passwordId'] = passwordId; | ||
const query = qs_1.default.stringify(queryParams); | ||
const res = yield this.baseRequest.get(`/encrypted-wallet-private-keys?${query}`); | ||
return res; | ||
}); | ||
} | ||
} | ||
@@ -758,0 +836,0 @@ exports.default = Client; |
@@ -66,2 +66,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
EncryptorType["BIOMETRICS"] = "BIOMETRICS"; | ||
EncryptorType["PASSWORD"] = "PASSWORD"; | ||
})(EncryptorType || (EncryptorType = {})); | ||
@@ -114,2 +115,7 @@ export const KeyType = { | ||
})(OnRampPurchaseType || (OnRampPurchaseType = {})); | ||
export var PasswordStatus; | ||
(function (PasswordStatus) { | ||
PasswordStatus["PENDING"] = "PENDING"; | ||
PasswordStatus["COMPLETE"] = "COMPLETE"; | ||
})(PasswordStatus || (PasswordStatus = {})); | ||
const SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid'; | ||
@@ -327,2 +333,11 @@ const VERSION_HEADER_NAME = 'x-capsule-version'; | ||
}); | ||
// PATCH /users/:userId/biometrics/:biometricId | ||
this.patchSessionPassword = (partnerId, userId, passwordId, body) => __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.patch(`/users/${userId}/passwords/${passwordId}`, body, { | ||
headers: { | ||
'X-Partner-ID': partnerId, | ||
}, | ||
}); | ||
return res; | ||
}); | ||
// TODO remove after this is not optional anymore | ||
@@ -421,2 +436,9 @@ const headers = apiKey ? { 'X-External-API-Key': apiKey } : undefined; | ||
} | ||
// GET /users/:userId/key-shares | ||
getPasswordKeyshares(userId, passwordId, getAll) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/users/${userId}/passwords/key-shares?passwordId=${passwordId}&all=${!!getAll}`); | ||
return res; | ||
}); | ||
} | ||
// POST '/users/:userId/temporary-shares', | ||
@@ -701,5 +723,5 @@ uploadTransmissionKeyshares(userId, shares) { | ||
} | ||
uploadEncryptedWalletPrivateKey(userId, encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey) { | ||
uploadEncryptedWalletPrivateKey(userId, encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const body = { encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey }; | ||
const body = { encryptedWalletPrivateKey, encryptionKeyHash, biometricPublicKey, passwordId }; | ||
const res = yield this.baseRequest.post(`/users/${userId}/encrypted-wallet-private-keys`, body); | ||
@@ -749,2 +771,58 @@ return res.data; | ||
} | ||
// POST /users/:userId/passwords/key | ||
addSessionPasswordPublicKey(userId, body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/users/${userId}/passwords/key`, body); | ||
return res; | ||
}); | ||
} | ||
getSupportedAuthMethods(userId, email, phone, countryCode, farcasterUsername) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.get(`/users/supported-auth-methods?userId=${userId}&email=${encodeURIComponent(email)}&phone=${encodeURIComponent(phone)}&countryCode=${encodeURIComponent(countryCode)}&farcasterUsername=${encodeURIComponent(farcasterUsername)}`); | ||
return res.data; | ||
}); | ||
} | ||
getPasswords(userId, email, phone, countryCode, farcasterUsername) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const queryParams = {}; | ||
if (userId) { | ||
queryParams['userId'] = userId; | ||
} | ||
if (email) { | ||
queryParams['email'] = email; | ||
} | ||
if (phone) { | ||
queryParams['phone'] = phone; | ||
} | ||
if (countryCode) { | ||
queryParams['countryCode'] = countryCode; | ||
} | ||
if (farcasterUsername) { | ||
queryParams['farcasterUsername'] = farcasterUsername; | ||
} | ||
const query = qs.stringify(queryParams); | ||
const res = yield this.baseRequest.get(`/users/passwords${query === '' ? '' : `?${query}`}`); | ||
return res.data.passwords; | ||
}); | ||
} | ||
// POST /passwords/verify | ||
verifyPasswordChallenge(partnerId, body) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.baseRequest.post(`/passwords/verify`, body, { | ||
headers: { | ||
'X-Partner-ID': partnerId, | ||
}, | ||
}); | ||
return res; | ||
}); | ||
} | ||
getEncryptedWalletPrivateKey(passwordId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const queryParams = {}; | ||
queryParams['passwordId'] = passwordId; | ||
const query = qs.stringify(queryParams); | ||
const res = yield this.baseRequest.get(`/encrypted-wallet-private-keys?${query}`); | ||
return res; | ||
}); | ||
} | ||
} | ||
@@ -751,0 +829,0 @@ export default Client; |
@@ -105,2 +105,13 @@ import { AxiosResponse } from 'axios'; | ||
} | ||
interface verifyPasswordChallengeBody { | ||
userId?: string; | ||
email?: string; | ||
phone?: string; | ||
countryCode?: string; | ||
farcasterUsername?: string; | ||
sessionLookupId?: string; | ||
signature: string; | ||
publicKey?: string; | ||
newDeviceSessionLookupId?: string; | ||
} | ||
interface verifySessionChallengeBody { | ||
@@ -158,2 +169,9 @@ signature: MobileSignature | WebSignature; | ||
} | ||
export interface PasswordEntity { | ||
id: string; | ||
userId: string; | ||
status: PasswordStatus; | ||
sigDerivedPublicKey: string; | ||
salt: string; | ||
} | ||
interface createWalletBody { | ||
@@ -214,3 +232,4 @@ useTwoSigners?: boolean; | ||
RECOVERY = "RECOVERY", | ||
BIOMETRICS = "BIOMETRICS" | ||
BIOMETRICS = "BIOMETRICS", | ||
PASSWORD = "PASSWORD" | ||
} | ||
@@ -298,2 +317,11 @@ export declare const KeyType: { | ||
}; | ||
export declare enum PasswordStatus { | ||
PENDING = "PENDING", | ||
COMPLETE = "COMPLETE" | ||
} | ||
interface sessionPasswordBody { | ||
status?: PasswordStatus; | ||
sigDerivedPublicKey?: string; | ||
salt?: string; | ||
} | ||
export type BiometricLocationHint = { | ||
@@ -353,2 +381,3 @@ useragent?: string; | ||
getBiometricKeyshares(userId: string, biometricPublicKey: string, getAll?: boolean): Promise<any>; | ||
getPasswordKeyshares(userId: string, passwordId: string, getAll?: boolean): Promise<any>; | ||
uploadTransmissionKeyshares(userId: string, shares: { | ||
@@ -454,3 +483,3 @@ walletId: string; | ||
}>; | ||
uploadEncryptedWalletPrivateKey(userId: string, encryptedWalletPrivateKey: string, encryptionKeyHash: string, biometricPublicKey: string): Promise<any>; | ||
uploadEncryptedWalletPrivateKey(userId: string, encryptedWalletPrivateKey: string, encryptionKeyHash: string, biometricPublicKey?: string, passwordId?: string): Promise<any>; | ||
getEncryptedWalletPrivateKeys(userId: string, encryptionKeyHash: string): Promise<any>; | ||
@@ -464,3 +493,9 @@ getConversionRate(chainId: string, symbol: string, currency: string): Promise<any>; | ||
deletePendingTransaction(userId: string, pendingTransactionId: string): Promise<any>; | ||
addSessionPasswordPublicKey(userId: string, body: sessionPasswordBody): Promise<any>; | ||
patchSessionPassword: (partnerId: string, userId: string, passwordId: string, body: sessionPasswordBody) => Promise<any>; | ||
getSupportedAuthMethods(userId: string, email: string, phone: string, countryCode: string, farcasterUsername: string): Promise<any>; | ||
getPasswords(userId?: string, email?: string, phone?: string, countryCode?: string, farcasterUsername?: string): Promise<PasswordEntity[]>; | ||
verifyPasswordChallenge(partnerId: string, body: verifyPasswordChallengeBody): Promise<any>; | ||
getEncryptedWalletPrivateKey(passwordId: string): Promise<any>; | ||
} | ||
export default Client; |
{ | ||
"name": "@usecapsule/user-management-client", | ||
"version": "1.26.4", | ||
"version": "1.27.0", | ||
"main": "dist/cjs/index.js", | ||
@@ -33,3 +33,3 @@ "module": "dist/esm/index.js", | ||
}, | ||
"gitHead": "ad61f04764b52adae17eb9cc1b0d6afb890d161b" | ||
"gitHead": "8bdc9e8ead0d317c9210b92db8bf0458d0879251" | ||
} |
100468
2248