@getpara/user-management-client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ export type AuthType = 'email' | 'phone' | 'farcaster' | 'telegram' | 'userId';
2
+ export type $ExtractAuth<T extends AuthType> = {
3
+ auth: Auth<T>;
4
+ authType: T;
5
+ identifier: string;
6
+ publicKeyIdentifier: string;
7
+ };
8
+ export type ExtractAuth = $ExtractAuth<'email'> | $ExtractAuth<'phone'> | $ExtractAuth<'farcaster'> | $ExtractAuth<'telegram'> | $ExtractAuth<'userId'>;
9
+ export type AuthParams = Record<string, any> & {
10
+ email?: string;
11
+ phone?: string;
12
+ countryCode?: string;
13
+ farcasterUsername?: string;
14
+ telegramUserId?: string;
15
+ userId?: string;
16
+ };
17
+ export type Auth<T extends AuthType = AuthType> = T extends 'email' ? {
18
+ email: string;
19
+ } : T extends 'phone' ? {
20
+ phone: string;
21
+ countryCode: string;
22
+ } : T extends 'farcaster' ? {
23
+ farcasterUsername: string;
24
+ } : T extends 'telegram' ? {
25
+ telegramUserId: string;
26
+ } : {
27
+ userId: string;
28
+ };
29
+ export declare enum EncryptorType {
30
+ USER = "USER",
31
+ RECOVERY = "RECOVERY",
32
+ BIOMETRICS = "BIOMETRICS",
33
+ PASSWORD = "PASSWORD"
34
+ }
35
+ export declare enum KeyShareType {
36
+ USER = "USER",
37
+ RECOVERY = "RECOVERY"
38
+ }
39
+ export declare enum PasswordStatus {
40
+ PENDING = "PENDING",
41
+ COMPLETE = "COMPLETE"
42
+ }
43
+ export declare enum PublicKeyStatus {
44
+ PENDING = "PENDING",
45
+ COMPLETE = "COMPLETE"
46
+ }
47
+ export declare enum PublicKeyType {
48
+ MOBILE = "MOBILE",
49
+ WEB = "WEB"
50
+ }
51
+ export interface EncryptedKeyShare {
52
+ encryptedShare: string;
53
+ encryptedKey?: string;
54
+ type: KeyShareType;
55
+ biometricPublicKey?: string;
56
+ encryptor: EncryptorType;
57
+ recoveryPublicKeyId?: string;
58
+ partnerId?: string;
59
+ protocolId?: string;
60
+ }
61
+ export declare enum OAuthMethod {
62
+ GOOGLE = "GOOGLE",
63
+ TWITTER = "TWITTER",
64
+ APPLE = "APPLE",
65
+ DISCORD = "DISCORD",
66
+ FACEBOOK = "FACEBOOK",
67
+ FARCASTER = "FARCASTER",
68
+ TELEGRAM = "TELEGRAM"
69
+ }
70
+ export declare enum AuthMethod {
71
+ PASSWORD = "PASSWORD",
72
+ PASSKEY = "PASSKEY"
73
+ }
74
+ export type BiometricLocationHint = {
75
+ useragent?: string;
76
+ aaguid?: string;
77
+ };
78
+ export type TelegramAuthResponse = {
79
+ auth_date: number;
80
+ first_name?: string;
81
+ hash: string;
82
+ id: number;
83
+ last_name?: string;
84
+ photo_url?: string;
85
+ username?: string;
86
+ };
@@ -0,0 +1,22 @@
1
+ export declare enum EmailTheme {
2
+ LIGHT = "light",
3
+ DARK = "dark"
4
+ }
5
+ export interface VerificationEmailProps {
6
+ theme?: EmailTheme;
7
+ homepageUrl?: string;
8
+ xUrl?: string;
9
+ linkedinUrl?: string;
10
+ githubUrl?: string;
11
+ supportUrl?: string;
12
+ brandColor?: string;
13
+ }
14
+ export interface BackupKitEmailProps {
15
+ theme?: EmailTheme;
16
+ homepageUrl?: string;
17
+ xUrl?: string;
18
+ linkedinUrl?: string;
19
+ githubUrl?: string;
20
+ supportUrl?: string;
21
+ brandColor?: string;
22
+ }
@@ -0,0 +1,5 @@
1
+ export * from './auth.js';
2
+ export * from './email.js';
3
+ export * from './onRamp.js';
4
+ export * from './partner.js';
5
+ export * from './wallet.js';
@@ -0,0 +1,68 @@
1
+ import { Network, WalletType } from './wallet.js';
2
+ export declare enum OnRampProvider {
3
+ RAMP = "RAMP",
4
+ STRIPE = "STRIPE",
5
+ MOONPAY = "MOONPAY"
6
+ }
7
+ export declare enum OnRampAsset {
8
+ ETHEREUM = "ETHEREUM",
9
+ USDC = "USDC",
10
+ TETHER = "TETHER",
11
+ POLYGON = "POLYGON",
12
+ SOLANA = "SOLANA",
13
+ ATOM = "ATOM",
14
+ CELO = "CELO",
15
+ CUSD = "CUSD",
16
+ CEUR = "CEUR",
17
+ CREAL = "CREAL"
18
+ }
19
+ export declare enum OnRampPurchaseStatus {
20
+ INITIATED = "INITIATED",
21
+ FINISHED = "FINISHED",
22
+ CANCELLED = "CANCELLED"
23
+ }
24
+ export declare enum OnRampPurchaseType {
25
+ BUY = "BUY",
26
+ SELL = "SELL"
27
+ }
28
+ export interface OnRampPurchase {
29
+ id: string;
30
+ userId: string;
31
+ type?: OnRampPurchaseType;
32
+ walletId?: string | null;
33
+ walletType?: WalletType;
34
+ externalWalletAddress?: string | null;
35
+ address?: string | null;
36
+ status?: OnRampPurchaseStatus;
37
+ provider?: OnRampProvider;
38
+ providerKey?: string | null;
39
+ fiat?: string | null;
40
+ fiatQuantity?: string | null;
41
+ asset?: OnRampAsset;
42
+ assetQuantity?: string | null;
43
+ network?: Network | null;
44
+ testMode?: boolean;
45
+ }
46
+ export type OnRampPurchaseCreateParams = Omit<OnRampPurchase, 'id' | 'userId'> & {
47
+ networks?: Network[] | 'all';
48
+ assets?: OnRampAsset[] | 'all';
49
+ defaultNetwork?: Network;
50
+ defaultAsset?: OnRampAsset;
51
+ };
52
+ export type OnRampPurchaseUpdateParams = Omit<OnRampPurchase, 'id' | 'userId'>;
53
+ type ProviderAssetInfo = [string, Partial<Record<OnRampPurchaseType, boolean>>];
54
+ export type OnRampAssetInfo = Record<WalletType, Partial<Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>>>>>>;
55
+ export type OnRampAllowedAssets = Partial<Record<Network, true | OnRampAsset[]>>;
56
+ export type OnRampConfig = {
57
+ isBuyEnabled: boolean;
58
+ isReceiveEnabled: boolean;
59
+ isWithdrawEnabled: boolean;
60
+ assetInfo: OnRampAssetInfo;
61
+ providers: OnRampProvider[];
62
+ allowedAssets?: OnRampAllowedAssets;
63
+ rampApiKey?: string;
64
+ defaultOnRampAsset?: OnRampAsset;
65
+ defaultOnRampNetwork?: Network;
66
+ defaultBuyAmount?: [string, string];
67
+ };
68
+ export {};
@@ -0,0 +1,13 @@
1
+ export interface PartnerEntity {
2
+ id: string;
3
+ displayName: string;
4
+ logoUrl?: string;
5
+ iconUrl?: string;
6
+ portalHeaderLogoUrl?: string;
7
+ policiesEnabled: boolean;
8
+ backgroundColor?: string;
9
+ foregroundColor?: string;
10
+ accentColor?: string;
11
+ font?: string;
12
+ themeMode?: 'light' | 'dark';
13
+ }
@@ -0,0 +1,59 @@
1
+ import { OAuthMethod } from './auth.js';
2
+ import { PartnerEntity } from './partner.js';
3
+ export declare enum WalletScheme {
4
+ DKLS = "DKLS",
5
+ CGGMP = "CGGMP",
6
+ ED25519 = "ED25519"
7
+ }
8
+ export declare enum WalletType {
9
+ EVM = "EVM",
10
+ SOLANA = "SOLANA",
11
+ COSMOS = "COSMOS"
12
+ }
13
+ export declare enum Chain {
14
+ ETH = "ETH",
15
+ CELO = "CELO",
16
+ MATIC = "MATIC"
17
+ }
18
+ export declare enum Network {
19
+ ETHEREUM = "ETHEREUM",
20
+ SEPOLIA = "SEPOLIA",
21
+ ARBITRUM = "ARBITRUM",
22
+ BASE = "BASE",
23
+ OPTIMISM = "OPTIMISM",
24
+ POLYGON = "POLYGON",
25
+ SOLANA = "SOLANA",
26
+ COSMOS = "COSMOS",
27
+ CELO = "CELO",
28
+ NOBLE = "NOBLE"
29
+ }
30
+ export type WalletRef = 'walletId' | 'externalWalletAddress';
31
+ export type WalletParams = Partial<{
32
+ walletId?: string;
33
+ externalWalletAddress?: string;
34
+ }>;
35
+ export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", OAuthMethod.DISCORD, OAuthMethod.TWITTER, OAuthMethod.TELEGRAM];
36
+ export type TPregenIdentifierType = (typeof PREGEN_IDENTIFIER_TYPES)[number];
37
+ export type PregenIds = Partial<Record<TPregenIdentifierType, string[]>>;
38
+ export interface WalletEntity {
39
+ address: string | null;
40
+ createdAt: string;
41
+ isPregen?: boolean;
42
+ pregenIdentifier: string;
43
+ pregenIdentifierType: TPregenIdentifierType;
44
+ id: string;
45
+ keyGenComplete: boolean;
46
+ name: string | null;
47
+ partnerId: string;
48
+ partner?: PartnerEntity;
49
+ publicKey: string | null;
50
+ scheme: string;
51
+ type: WalletType;
52
+ updatedAt: string;
53
+ userId: string | null;
54
+ lastUsedAt: string | null;
55
+ lastUsedPartnerId?: string;
56
+ lastUsedPartner?: PartnerEntity;
57
+ }
58
+ export type CurrentWalletIds = Partial<Record<WalletType, string[]>>;
59
+ export declare const NON_ED25519: WalletScheme[];
@@ -0,0 +1,19 @@
1
+ import { Auth, AuthParams, ExtractAuth, WalletParams, WalletRef } from './types/index.js';
2
+ export declare function isWalletId(params: WalletParams): params is {
3
+ walletId: string;
4
+ };
5
+ export declare function isExternalWalletAddress(params: WalletParams): params is {
6
+ externalWalletAddress: string;
7
+ };
8
+ export declare function extractWalletRef(params: WalletParams): [WalletRef, string];
9
+ export declare function isEmail(params: AuthParams): params is Auth<'email'>;
10
+ export declare function isPhone(params: AuthParams): params is Auth<'phone'>;
11
+ export declare function isFarcaster(params: AuthParams): params is Auth<'farcaster'>;
12
+ export declare function isTelegram(params: AuthParams): params is Auth<'telegram'>;
13
+ export declare function isUserId(params: AuthParams): params is Auth<'userId'>;
14
+ export declare function extractAuthInfo(obj: AuthParams, { allowUserId }?: {
15
+ allowUserId?: boolean;
16
+ }): ExtractAuth;
17
+ export declare function extractAuth(obj: AuthParams, opts?: Parameters<typeof extractAuthInfo>[1] & {
18
+ optional?: boolean;
19
+ }): Auth | undefined;
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@getpara/user-management-client",
3
+ "version": "0.1.0",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "typings": "dist/types/index.d.ts",
8
+ "sideEffects": false,
9
+ "scripts": {
10
+ "build": "yarn build:cjs && yarn build:esm && yarn build:types",
11
+ "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
12
+ "build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/esm/package.json",
13
+ "build:types": "rm -rf dist/types && tsc --module es6 --declarationDir dist/types --emitDeclarationOnly --declaration",
14
+ "test": "vitest run --coverage"
15
+ },
16
+ "dependencies": {
17
+ "axios": "^1.6.3",
18
+ "libphonenumber-js": "1.11.2",
19
+ "qs": "^6.12.0"
20
+ },
21
+ "devDependencies": {
22
+ "typescript": "^5.0.4"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "package.json"
27
+ ],
28
+ "exports": {
29
+ ".": {
30
+ "import": "./dist/esm/index.js",
31
+ "require": "./dist/cjs/index.js",
32
+ "types": "./dist/types/index.d.ts"
33
+ }
34
+ },
35
+ "gitHead": "625aaa94001a5461dcde8d6775c3b73f3862c76c"
36
+ }