@usecapsule/user-management-client
Advanced tools
Comparing version 1.39.0 to 1.40.0
@@ -26,2 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.handleResponseError = exports.handleResponseSuccess = void 0; | ||
const axios_1 = __importDefault(require("axios")); | ||
@@ -31,4 +32,31 @@ const qs_1 = __importDefault(require("qs")); | ||
const consts_js_1 = require("./consts.js"); | ||
const error_js_1 = require("./error.js"); | ||
const handleResponseSuccess = (response) => { | ||
if (response.status === 200) { | ||
return response; | ||
} | ||
throw new error_js_1.CapsuleApiError('Invalid status code'); | ||
}; | ||
exports.handleResponseSuccess = handleResponseSuccess; | ||
const handleResponseError = (error) => { | ||
var _a, _b, _c; | ||
if (error === null) | ||
throw new error_js_1.CapsuleApiError('Error is null'); | ||
if (axios_1.default.isAxiosError(error)) { | ||
let message = (_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : 'Unknown error'; | ||
// Add meaningful messages to connection errors | ||
// Can do this for other Axios codes as well in the future if we need: https://github.com/axios/axios/blob/v1.x/lib/core/AxiosError.js#L61 | ||
if (error.code === 'ERR_NETWORK') { | ||
message = 'Connection error'; | ||
} | ||
else if (error.code === 'ERR_CANCELED') { | ||
message = 'Connection canceled'; | ||
} | ||
throw new error_js_1.CapsuleApiError(message, error.code, error.status, (_c = error.request) === null || _c === void 0 ? void 0 : _c.responseURL); | ||
} | ||
throw new error_js_1.CapsuleApiError('Unknown error'); | ||
}; | ||
exports.handleResponseError = handleResponseError; | ||
class Client { | ||
constructor({ userManagementHost, apiKey, version, opts, retrieveSessionCookie, persistSessionCookie }) { | ||
constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, }) { | ||
this.createUser = (body) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -44,2 +72,7 @@ const res = yield this.baseRequest.post(`/users`, body); | ||
}); | ||
this.verifyTelegram = (authObject) => __awaiter(this, void 0, void 0, function* () { | ||
return (yield this.baseRequest.post('/users/telegram', { | ||
authObject, | ||
})).data; | ||
}); | ||
this.externalWalletLogin = (body) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -134,4 +167,6 @@ const res = yield this.baseRequest.post(`/users/external-wallets/login`, body); | ||
// GET /wallets/pregen?pregenIdentifier={pregenIdentifier}&pregenIdentifierType={pregenIdentifierType} | ||
this.getPregenWallets = (pregenIds_1, ...args_1) => __awaiter(this, [pregenIds_1, ...args_1], void 0, function* (pregenIds, expand = false) { | ||
const res = yield this.baseRequest.get('/wallets/pregen', { params: { ids: pregenIds, expand } }); | ||
this.getPregenWallets = (pregenIds_1, ...args_1) => __awaiter(this, [pregenIds_1, ...args_1], void 0, function* (pregenIds, isPortal = false, userId) { | ||
const res = yield this.baseRequest.get('/wallets/pregen', { | ||
params: { ids: pregenIds, expand: isPortal, userId }, | ||
}); | ||
return res.data; | ||
@@ -245,3 +280,3 @@ }); | ||
// TODO remove after this is not optional anymore | ||
const headers = apiKey ? { 'X-External-API-Key': apiKey } : undefined; | ||
const headers = Object.assign(Object.assign({}, (apiKey && { [consts_js_1.API_KEY_HEADER_NAME]: apiKey })), (partnerId && { [consts_js_1.PARTNER_ID_HEADER_NAME]: partnerId })); | ||
const axiosConfig = { | ||
@@ -306,2 +341,4 @@ baseURL: userManagementHost, | ||
} | ||
// Intercept response to add more concise errors rather than returning the entire AxiosError | ||
this.baseRequest.interceptors.response.use(exports.handleResponseSuccess, exports.handleResponseError); | ||
} | ||
@@ -308,0 +345,0 @@ // DEPRECATED: use uploadUserKeyShares instead |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PARTNER_ID_HEADER_NAME = exports.VERSION_HEADER_NAME = exports.SESSION_COOKIE_HEADER_NAME = void 0; | ||
exports.API_KEY_HEADER_NAME = exports.PARTNER_ID_HEADER_NAME = exports.VERSION_HEADER_NAME = exports.SESSION_COOKIE_HEADER_NAME = void 0; | ||
exports.SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid'; | ||
exports.VERSION_HEADER_NAME = 'x-capsule-version'; | ||
exports.PARTNER_ID_HEADER_NAME = 'x-partner-id'; | ||
exports.API_KEY_HEADER_NAME = 'X-External-API-Key'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OAuthMethod = exports.PublicKeyType = exports.PublicKeyStatus = exports.PasswordStatus = exports.KeyShareType = exports.EncryptorType = void 0; | ||
exports.AuthMethod = exports.OAuthMethod = exports.PublicKeyType = exports.PublicKeyStatus = exports.PasswordStatus = exports.KeyShareType = exports.EncryptorType = void 0; | ||
var EncryptorType; | ||
@@ -39,2 +39,8 @@ (function (EncryptorType) { | ||
OAuthMethod["FARCASTER"] = "FARCASTER"; | ||
OAuthMethod["TELEGRAM"] = "TELEGRAM"; | ||
})(OAuthMethod || (exports.OAuthMethod = OAuthMethod = {})); | ||
var AuthMethod; | ||
(function (AuthMethod) { | ||
AuthMethod["PASSWORD"] = "PASSWORD"; | ||
AuthMethod["PASSKEY"] = "PASSKEY"; | ||
})(AuthMethod || (exports.AuthMethod = AuthMethod = {})); |
@@ -34,4 +34,12 @@ "use strict"; | ||
Network["CELO"] = "CELO"; | ||
Network["NOBLE"] = "NOBLE"; | ||
})(Network || (exports.Network = Network = {})); | ||
exports.PREGEN_IDENTIFIER_TYPES = ['EMAIL', 'PHONE', 'CUSTOM_ID', auth_js_1.OAuthMethod.DISCORD, auth_js_1.OAuthMethod.TWITTER]; | ||
exports.PREGEN_IDENTIFIER_TYPES = [ | ||
'EMAIL', | ||
'PHONE', | ||
'CUSTOM_ID', | ||
auth_js_1.OAuthMethod.DISCORD, | ||
auth_js_1.OAuthMethod.TWITTER, | ||
auth_js_1.OAuthMethod.TELEGRAM, | ||
]; | ||
exports.NON_ED25519 = [WalletScheme.DKLS, WalletScheme.CGGMP]; |
@@ -9,2 +9,3 @@ "use strict"; | ||
exports.isFarcaster = isFarcaster; | ||
exports.isTelegram = isTelegram; | ||
exports.isUserId = isUserId; | ||
@@ -28,13 +29,40 @@ exports.extractAuthInfo = extractAuthInfo; | ||
} | ||
function isValid(s) { | ||
return !!s && s !== 'null' && s !== 'undefined' && s !== ''; | ||
} | ||
function isEmail(params) { | ||
return !!params.email && !params.phone && !params.countryCode && !params.farcasterUsername; | ||
return (isValid(params.email) && | ||
!isValid(params.phone) && | ||
!isValid(params.countryCode) && | ||
!isValid(params.farcasterUsername) && | ||
!isValid(params.telegramUserId)); | ||
} | ||
function isPhone(params) { | ||
return !!params.phone && !!params.countryCode && !params.email && !params.farcasterUsername; | ||
return (isValid(params.phone) && | ||
isValid(params.countryCode) && | ||
!isValid(params.email) && | ||
!isValid(params.farcasterUsername) && | ||
!isValid(params.telegramUserId)); | ||
} | ||
function isFarcaster(params) { | ||
return !!params.farcasterUsername && !params.email && !params.phone && !params.countryCode; | ||
return (isValid(params.farcasterUsername) && | ||
!isValid(params.email) && | ||
!isValid(params.phone) && | ||
!isValid(params.countryCode) && | ||
!isValid(params.telegramUserId)); | ||
} | ||
function isTelegram(params) { | ||
return (isValid(params.telegramUserId) && | ||
!isValid(params.email) && | ||
!isValid(params.phone) && | ||
!isValid(params.countryCode) && | ||
!isValid(params.farcasterUsername)); | ||
} | ||
function isUserId(params) { | ||
return !!params.userId; | ||
return (isValid(params.userId) && | ||
!isValid(params.email) && | ||
!isValid(params.phone) && | ||
!isValid(params.countryCode) && | ||
!isValid(params.farcasterUsername) && | ||
!isValid(params.telegramUserId)); | ||
} | ||
@@ -44,3 +72,3 @@ function extractAuthInfo(obj, { allowUserId } = {}) { | ||
case isEmail(obj): | ||
return { auth: { email: obj.email }, authType: 'email', identifier: obj.email }; | ||
return { auth: { email: obj.email }, authType: 'email', identifier: obj.email, publicKeyIdentifier: obj.email }; | ||
case isPhone(obj): | ||
@@ -51,2 +79,3 @@ return { | ||
identifier: `${obj.countryCode}${obj.phone}`, | ||
publicKeyIdentifier: `${obj.countryCode}${obj.phone}`, | ||
}; | ||
@@ -56,7 +85,15 @@ case isFarcaster(obj): | ||
auth: { farcasterUsername: obj.farcasterUsername }, | ||
authType: 'farcasterUsername', | ||
authType: 'farcaster', | ||
identifier: obj.farcasterUsername, | ||
publicKeyIdentifier: `${obj.farcasterUsername}-farcaster`, | ||
}; | ||
case isTelegram(obj): | ||
return { | ||
auth: { telegramUserId: obj.telegramUserId }, | ||
authType: 'telegram', | ||
identifier: obj.telegramUserId, | ||
publicKeyIdentifier: `${obj.telegramUserId}-telegram`, | ||
}; | ||
case isUserId(obj) && allowUserId: | ||
return { auth: { userId: obj.userId }, authType: 'userId', identifier: obj.userId }; | ||
return { auth: { userId: obj.userId }, authType: 'userId', identifier: obj.userId, publicKeyIdentifier: obj.userId }; | ||
default: | ||
@@ -63,0 +100,0 @@ throw new Error('invalid auth object'); |
@@ -24,5 +24,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { extractWalletRef } from './utils.js'; | ||
import { SESSION_COOKIE_HEADER_NAME, VERSION_HEADER_NAME, PARTNER_ID_HEADER_NAME } from './consts.js'; | ||
import { SESSION_COOKIE_HEADER_NAME, VERSION_HEADER_NAME, PARTNER_ID_HEADER_NAME, API_KEY_HEADER_NAME } from './consts.js'; | ||
import { CapsuleApiError } from './error.js'; | ||
export const handleResponseSuccess = (response) => { | ||
if (response.status === 200) { | ||
return response; | ||
} | ||
throw new CapsuleApiError('Invalid status code'); | ||
}; | ||
export const handleResponseError = (error) => { | ||
var _a, _b, _c; | ||
if (error === null) | ||
throw new CapsuleApiError('Error is null'); | ||
if (axios.isAxiosError(error)) { | ||
let message = (_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : 'Unknown error'; | ||
// Add meaningful messages to connection errors | ||
// Can do this for other Axios codes as well in the future if we need: https://github.com/axios/axios/blob/v1.x/lib/core/AxiosError.js#L61 | ||
if (error.code === 'ERR_NETWORK') { | ||
message = 'Connection error'; | ||
} | ||
else if (error.code === 'ERR_CANCELED') { | ||
message = 'Connection canceled'; | ||
} | ||
throw new CapsuleApiError(message, error.code, error.status, (_c = error.request) === null || _c === void 0 ? void 0 : _c.responseURL); | ||
} | ||
throw new CapsuleApiError('Unknown error'); | ||
}; | ||
class Client { | ||
constructor({ userManagementHost, apiKey, version, opts, retrieveSessionCookie, persistSessionCookie }) { | ||
constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, }) { | ||
this.createUser = (body) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -38,2 +63,7 @@ const res = yield this.baseRequest.post(`/users`, body); | ||
}); | ||
this.verifyTelegram = (authObject) => __awaiter(this, void 0, void 0, function* () { | ||
return (yield this.baseRequest.post('/users/telegram', { | ||
authObject, | ||
})).data; | ||
}); | ||
this.externalWalletLogin = (body) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -128,4 +158,6 @@ const res = yield this.baseRequest.post(`/users/external-wallets/login`, body); | ||
// GET /wallets/pregen?pregenIdentifier={pregenIdentifier}&pregenIdentifierType={pregenIdentifierType} | ||
this.getPregenWallets = (pregenIds_1, ...args_1) => __awaiter(this, [pregenIds_1, ...args_1], void 0, function* (pregenIds, expand = false) { | ||
const res = yield this.baseRequest.get('/wallets/pregen', { params: { ids: pregenIds, expand } }); | ||
this.getPregenWallets = (pregenIds_1, ...args_1) => __awaiter(this, [pregenIds_1, ...args_1], void 0, function* (pregenIds, isPortal = false, userId) { | ||
const res = yield this.baseRequest.get('/wallets/pregen', { | ||
params: { ids: pregenIds, expand: isPortal, userId }, | ||
}); | ||
return res.data; | ||
@@ -239,3 +271,3 @@ }); | ||
// TODO remove after this is not optional anymore | ||
const headers = apiKey ? { 'X-External-API-Key': apiKey } : undefined; | ||
const headers = Object.assign(Object.assign({}, (apiKey && { [API_KEY_HEADER_NAME]: apiKey })), (partnerId && { [PARTNER_ID_HEADER_NAME]: partnerId })); | ||
const axiosConfig = { | ||
@@ -300,2 +332,4 @@ baseURL: userManagementHost, | ||
} | ||
// Intercept response to add more concise errors rather than returning the entire AxiosError | ||
this.baseRequest.interceptors.response.use(handleResponseSuccess, handleResponseError); | ||
} | ||
@@ -302,0 +336,0 @@ // DEPRECATED: use uploadUserKeyShares instead |
export const SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid'; | ||
export const VERSION_HEADER_NAME = 'x-capsule-version'; | ||
export const PARTNER_ID_HEADER_NAME = 'x-partner-id'; | ||
export const API_KEY_HEADER_NAME = 'X-External-API-Key'; |
@@ -36,2 +36,8 @@ export var EncryptorType; | ||
OAuthMethod["FARCASTER"] = "FARCASTER"; | ||
OAuthMethod["TELEGRAM"] = "TELEGRAM"; | ||
})(OAuthMethod || (OAuthMethod = {})); | ||
export var AuthMethod; | ||
(function (AuthMethod) { | ||
AuthMethod["PASSWORD"] = "PASSWORD"; | ||
AuthMethod["PASSKEY"] = "PASSKEY"; | ||
})(AuthMethod || (AuthMethod = {})); |
@@ -31,4 +31,12 @@ import { OAuthMethod } from './auth.js'; | ||
Network["CELO"] = "CELO"; | ||
Network["NOBLE"] = "NOBLE"; | ||
})(Network || (Network = {})); | ||
export const PREGEN_IDENTIFIER_TYPES = ['EMAIL', 'PHONE', 'CUSTOM_ID', OAuthMethod.DISCORD, OAuthMethod.TWITTER]; | ||
export const PREGEN_IDENTIFIER_TYPES = [ | ||
'EMAIL', | ||
'PHONE', | ||
'CUSTOM_ID', | ||
OAuthMethod.DISCORD, | ||
OAuthMethod.TWITTER, | ||
OAuthMethod.TELEGRAM, | ||
]; | ||
export const NON_ED25519 = [WalletScheme.DKLS, WalletScheme.CGGMP]; |
@@ -16,13 +16,40 @@ export function isWalletId(params) { | ||
} | ||
function isValid(s) { | ||
return !!s && s !== 'null' && s !== 'undefined' && s !== ''; | ||
} | ||
export function isEmail(params) { | ||
return !!params.email && !params.phone && !params.countryCode && !params.farcasterUsername; | ||
return (isValid(params.email) && | ||
!isValid(params.phone) && | ||
!isValid(params.countryCode) && | ||
!isValid(params.farcasterUsername) && | ||
!isValid(params.telegramUserId)); | ||
} | ||
export function isPhone(params) { | ||
return !!params.phone && !!params.countryCode && !params.email && !params.farcasterUsername; | ||
return (isValid(params.phone) && | ||
isValid(params.countryCode) && | ||
!isValid(params.email) && | ||
!isValid(params.farcasterUsername) && | ||
!isValid(params.telegramUserId)); | ||
} | ||
export function isFarcaster(params) { | ||
return !!params.farcasterUsername && !params.email && !params.phone && !params.countryCode; | ||
return (isValid(params.farcasterUsername) && | ||
!isValid(params.email) && | ||
!isValid(params.phone) && | ||
!isValid(params.countryCode) && | ||
!isValid(params.telegramUserId)); | ||
} | ||
export function isTelegram(params) { | ||
return (isValid(params.telegramUserId) && | ||
!isValid(params.email) && | ||
!isValid(params.phone) && | ||
!isValid(params.countryCode) && | ||
!isValid(params.farcasterUsername)); | ||
} | ||
export function isUserId(params) { | ||
return !!params.userId; | ||
return (isValid(params.userId) && | ||
!isValid(params.email) && | ||
!isValid(params.phone) && | ||
!isValid(params.countryCode) && | ||
!isValid(params.farcasterUsername) && | ||
!isValid(params.telegramUserId)); | ||
} | ||
@@ -32,3 +59,3 @@ export function extractAuthInfo(obj, { allowUserId } = {}) { | ||
case isEmail(obj): | ||
return { auth: { email: obj.email }, authType: 'email', identifier: obj.email }; | ||
return { auth: { email: obj.email }, authType: 'email', identifier: obj.email, publicKeyIdentifier: obj.email }; | ||
case isPhone(obj): | ||
@@ -39,2 +66,3 @@ return { | ||
identifier: `${obj.countryCode}${obj.phone}`, | ||
publicKeyIdentifier: `${obj.countryCode}${obj.phone}`, | ||
}; | ||
@@ -44,7 +72,15 @@ case isFarcaster(obj): | ||
auth: { farcasterUsername: obj.farcasterUsername }, | ||
authType: 'farcasterUsername', | ||
authType: 'farcaster', | ||
identifier: obj.farcasterUsername, | ||
publicKeyIdentifier: `${obj.farcasterUsername}-farcaster`, | ||
}; | ||
case isTelegram(obj): | ||
return { | ||
auth: { telegramUserId: obj.telegramUserId }, | ||
authType: 'telegram', | ||
identifier: obj.telegramUserId, | ||
publicKeyIdentifier: `${obj.telegramUserId}-telegram`, | ||
}; | ||
case isUserId(obj) && allowUserId: | ||
return { auth: { userId: obj.userId }, authType: 'userId', identifier: obj.userId }; | ||
return { auth: { userId: obj.userId }, authType: 'userId', identifier: obj.userId, publicKeyIdentifier: obj.userId }; | ||
default: | ||
@@ -51,0 +87,0 @@ throw new Error('invalid auth object'); |
import { AxiosResponse } from 'axios'; | ||
import { $Auth, Auth, AuthParams, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, PasswordStatus, PregenIds, PublicKeyStatus, PublicKeyType, TPregenIdentifierType, VerificationEmailProps, WalletEntity, WalletParams, WalletScheme, WalletType } from './types/index.js'; | ||
import { $Auth, Auth, AuthMethod, AuthParams, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, PasswordStatus, PregenIds, PublicKeyStatus, PublicKeyType, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, WalletEntity, WalletParams, WalletScheme, WalletType } from './types/index.js'; | ||
interface ConfigOpts { | ||
@@ -9,2 +9,3 @@ useFetchAdapter?: boolean; | ||
version?: string; | ||
partnerId?: string; | ||
apiKey?: string; | ||
@@ -130,7 +131,20 @@ opts?: ConfigOpts; | ||
type BiometricLocationHintParams = AuthParams; | ||
export type VerifyTelegramRes = { | ||
isValid: true; | ||
userId: string; | ||
telegramUserId: string; | ||
isNewUser: boolean; | ||
biometricHints?: BiometricLocationHint[]; | ||
supportedAuthMethods: AuthMethod[]; | ||
} | { | ||
isValid: false; | ||
}; | ||
export declare const handleResponseSuccess: (response: AxiosResponse<any, any>) => AxiosResponse<any, any>; | ||
export declare const handleResponseError: (error: any) => never; | ||
declare class Client { | ||
private baseRequest; | ||
constructor({ userManagementHost, apiKey, version, opts, retrieveSessionCookie, persistSessionCookie }: ClientConfig); | ||
constructor({ userManagementHost, apiKey, partnerId, version, opts, retrieveSessionCookie, persistSessionCookie, }: ClientConfig); | ||
createUser: (body: (createUserBody | createUserBodyForPhone) & VerificationEmailProps) => Promise<createUserIdRes>; | ||
checkUserExists: (auth: $Auth<"email" | "phone">) => Promise<any>; | ||
verifyTelegram: (authObject: TelegramAuthResponse) => Promise<VerifyTelegramRes>; | ||
externalWalletLogin: (body: ExternalWalletLoginBody) => Promise<ExternalWalletLoginRes>; | ||
@@ -156,3 +170,3 @@ verifyEmail: (userId: string, body: verifyBody) => Promise<any>; | ||
wallets: WalletEntity[]; | ||
}>(pregenIds: PregenIds, expand?: boolean) => Promise<ReturnType>; | ||
}>(pregenIds: PregenIds, isPortal?: boolean, userId?: string) => Promise<ReturnType>; | ||
claimPregenWallets: <ReturnType = { | ||
@@ -159,0 +173,0 @@ walletIds?: string[]; |
export declare const SESSION_COOKIE_HEADER_NAME = "x-capsule-sid"; | ||
export declare const VERSION_HEADER_NAME = "x-capsule-version"; | ||
export declare const PARTNER_ID_HEADER_NAME = "x-partner-id"; | ||
export declare const API_KEY_HEADER_NAME = "X-External-API-Key"; |
@@ -1,3 +0,3 @@ | ||
export type AuthType = 'email' | 'phone' | 'farcasterUsername' | 'userId'; | ||
export type ExtractAuth = $ExtractAuth<'email'> | $ExtractAuth<'phone'> | $ExtractAuth<'farcasterUsername'> | $ExtractAuth<'userId'>; | ||
export type AuthType = 'email' | 'phone' | 'farcaster' | 'telegram' | 'userId'; | ||
export type ExtractAuth = $ExtractAuth<'email'> | $ExtractAuth<'phone'> | $ExtractAuth<'farcaster'> | $ExtractAuth<'telegram'> | $ExtractAuth<'userId'>; | ||
export type $ExtractAuth<T extends AuthType> = { | ||
@@ -7,2 +7,3 @@ auth: $Auth<T>; | ||
identifier: string; | ||
publicKeyIdentifier: string; | ||
}; | ||
@@ -14,2 +15,3 @@ export type AuthParams = Record<string, any> & { | ||
farcasterUsername?: string; | ||
telegramUserId?: string; | ||
userId?: string; | ||
@@ -22,8 +24,10 @@ }; | ||
countryCode: string; | ||
} : T extends 'farcasterUsername' ? { | ||
} : T extends 'farcaster' ? { | ||
farcasterUsername: string; | ||
} : T extends 'telegram' ? { | ||
telegramUserId: string; | ||
} : { | ||
userId: string; | ||
}; | ||
export type Auth = $Auth<'email'> | $Auth<'phone'> | $Auth<'farcasterUsername'> | $Auth<'userId'>; | ||
export type Auth = $Auth<'email'> | $Auth<'phone'> | $Auth<'farcaster'> | $Auth<'telegram'> | $Auth<'userId'>; | ||
export declare enum EncryptorType { | ||
@@ -67,4 +71,9 @@ USER = "USER", | ||
FACEBOOK = "FACEBOOK", | ||
FARCASTER = "FARCASTER" | ||
FARCASTER = "FARCASTER", | ||
TELEGRAM = "TELEGRAM" | ||
} | ||
export declare enum AuthMethod { | ||
PASSWORD = "PASSWORD", | ||
PASSKEY = "PASSKEY" | ||
} | ||
export type BiometricLocationHint = { | ||
@@ -74,1 +83,10 @@ useragent?: string; | ||
}; | ||
export type TelegramAuthResponse = { | ||
auth_date: number; | ||
first_name?: string; | ||
hash: string; | ||
id: number; | ||
last_name?: string; | ||
photo_url?: string; | ||
username?: string; | ||
}; |
@@ -27,3 +27,4 @@ import { OAuthMethod } from './auth.js'; | ||
COSMOS = "COSMOS", | ||
CELO = "CELO" | ||
CELO = "CELO", | ||
NOBLE = "NOBLE" | ||
} | ||
@@ -35,3 +36,3 @@ export type WalletRef = 'walletId' | 'externalWalletAddress'; | ||
}>; | ||
export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", OAuthMethod.DISCORD, OAuthMethod.TWITTER]; | ||
export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", OAuthMethod.DISCORD, OAuthMethod.TWITTER, OAuthMethod.TELEGRAM]; | ||
export type TPregenIdentifierType = (typeof PREGEN_IDENTIFIER_TYPES)[number]; | ||
@@ -38,0 +39,0 @@ export type PregenIds = Partial<Record<TPregenIdentifierType, string[]>>; |
@@ -11,6 +11,5 @@ import { $Auth, Auth, AuthParams, ExtractAuth, WalletParams, WalletRef } from './types/index.js'; | ||
export declare function isPhone(params: AuthParams): params is $Auth<'phone'>; | ||
export declare function isFarcaster(params: AuthParams): params is $Auth<'farcasterUsername'>; | ||
export declare function isUserId(params: AuthParams): params is { | ||
userId: string; | ||
}; | ||
export declare function isFarcaster(params: AuthParams): params is $Auth<'farcaster'>; | ||
export declare function isTelegram(params: AuthParams): params is $Auth<'telegram'>; | ||
export declare function isUserId(params: AuthParams): params is $Auth<'userId'>; | ||
export declare function extractAuthInfo(obj: AuthParams, { allowUserId }?: { | ||
@@ -17,0 +16,0 @@ allowUserId?: boolean; |
{ | ||
"name": "@usecapsule/user-management-client", | ||
"version": "1.39.0", | ||
"version": "1.40.0", | ||
"main": "dist/cjs/index.js", | ||
@@ -35,3 +35,3 @@ "module": "dist/esm/index.js", | ||
}, | ||
"gitHead": "7627e822579b7765792098c263d1ac8f4becbc51" | ||
"gitHead": "2b653b92148fda4a455720dfd23dcc150d9ac908" | ||
} |
117501
36
2698