@getpara/user-management-client 2.0.0-alpha.3 → 2.0.0-alpha.6
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.
- package/dist/cjs/client.js +916 -0
- package/dist/cjs/consts.js +36 -0
- package/dist/cjs/error.js +41 -0
- package/dist/cjs/index.js +12 -1289
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types/auth.js +98 -0
- package/dist/cjs/types/email.js +31 -0
- package/dist/cjs/types/index.js +29 -0
- package/dist/cjs/types/onRamp.js +62 -0
- package/dist/cjs/types/partner.js +15 -0
- package/dist/cjs/types/wallet.js +85 -0
- package/dist/cjs/utils.js +270 -0
- package/dist/esm/chunk-BBZEL7EG.js +58 -0
- package/dist/esm/client.js +839 -0
- package/dist/esm/consts.js +11 -0
- package/dist/esm/error.js +19 -0
- package/dist/esm/index.js +8 -1248
- package/dist/esm/package.json +4 -0
- package/dist/esm/types/auth.js +68 -0
- package/dist/esm/types/email.js +9 -0
- package/dist/esm/types/index.js +5 -0
- package/dist/esm/types/onRamp.js +37 -0
- package/dist/esm/types/partner.js +0 -0
- package/dist/esm/types/wallet.js +56 -0
- package/dist/esm/utils.js +204 -0
- package/dist/types/client.d.ts +34 -12
- package/dist/types/types/auth.d.ts +15 -2
- package/dist/types/types/onRamp.d.ts +3 -3
- package/dist/types/types/wallet.d.ts +17 -8
- package/dist/types/utils.d.ts +7 -2
- package/package.json +4 -5
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import "../chunk-BBZEL7EG.js";
|
|
2
|
+
const AUTH_TYPES = [
|
|
3
|
+
"email",
|
|
4
|
+
"phone",
|
|
5
|
+
"phoneLegacy",
|
|
6
|
+
"farcaster",
|
|
7
|
+
"telegram",
|
|
8
|
+
"userId",
|
|
9
|
+
"externalWallet",
|
|
10
|
+
"discord",
|
|
11
|
+
"x",
|
|
12
|
+
"customId",
|
|
13
|
+
"guestId"
|
|
14
|
+
];
|
|
15
|
+
var EncryptorType = /* @__PURE__ */ ((EncryptorType2) => {
|
|
16
|
+
EncryptorType2["USER"] = "USER";
|
|
17
|
+
EncryptorType2["RECOVERY"] = "RECOVERY";
|
|
18
|
+
EncryptorType2["BIOMETRICS"] = "BIOMETRICS";
|
|
19
|
+
EncryptorType2["PASSWORD"] = "PASSWORD";
|
|
20
|
+
return EncryptorType2;
|
|
21
|
+
})(EncryptorType || {});
|
|
22
|
+
var KeyShareType = /* @__PURE__ */ ((KeyShareType2) => {
|
|
23
|
+
KeyShareType2["USER"] = "USER";
|
|
24
|
+
KeyShareType2["RECOVERY"] = "RECOVERY";
|
|
25
|
+
return KeyShareType2;
|
|
26
|
+
})(KeyShareType || {});
|
|
27
|
+
var PasswordStatus = /* @__PURE__ */ ((PasswordStatus2) => {
|
|
28
|
+
PasswordStatus2["PENDING"] = "PENDING";
|
|
29
|
+
PasswordStatus2["COMPLETE"] = "COMPLETE";
|
|
30
|
+
return PasswordStatus2;
|
|
31
|
+
})(PasswordStatus || {});
|
|
32
|
+
var PublicKeyStatus = /* @__PURE__ */ ((PublicKeyStatus2) => {
|
|
33
|
+
PublicKeyStatus2["PENDING"] = "PENDING";
|
|
34
|
+
PublicKeyStatus2["COMPLETE"] = "COMPLETE";
|
|
35
|
+
return PublicKeyStatus2;
|
|
36
|
+
})(PublicKeyStatus || {});
|
|
37
|
+
var PublicKeyType = /* @__PURE__ */ ((PublicKeyType2) => {
|
|
38
|
+
PublicKeyType2["MOBILE"] = "MOBILE";
|
|
39
|
+
PublicKeyType2["WEB"] = "WEB";
|
|
40
|
+
return PublicKeyType2;
|
|
41
|
+
})(PublicKeyType || {});
|
|
42
|
+
var OAuthMethod = /* @__PURE__ */ ((OAuthMethod2) => {
|
|
43
|
+
OAuthMethod2["GOOGLE"] = "GOOGLE";
|
|
44
|
+
OAuthMethod2["TWITTER"] = "TWITTER";
|
|
45
|
+
OAuthMethod2["APPLE"] = "APPLE";
|
|
46
|
+
OAuthMethod2["DISCORD"] = "DISCORD";
|
|
47
|
+
OAuthMethod2["FACEBOOK"] = "FACEBOOK";
|
|
48
|
+
OAuthMethod2["FARCASTER"] = "FARCASTER";
|
|
49
|
+
OAuthMethod2["TELEGRAM"] = "TELEGRAM";
|
|
50
|
+
return OAuthMethod2;
|
|
51
|
+
})(OAuthMethod || {});
|
|
52
|
+
const OAUTH_METHODS = ["GOOGLE", "TWITTER", "APPLE", "DISCORD", "FACEBOOK", "FARCASTER", "TELEGRAM"];
|
|
53
|
+
var AuthMethod = /* @__PURE__ */ ((AuthMethod2) => {
|
|
54
|
+
AuthMethod2["PASSWORD"] = "PASSWORD";
|
|
55
|
+
AuthMethod2["PASSKEY"] = "PASSKEY";
|
|
56
|
+
return AuthMethod2;
|
|
57
|
+
})(AuthMethod || {});
|
|
58
|
+
export {
|
|
59
|
+
AUTH_TYPES,
|
|
60
|
+
AuthMethod,
|
|
61
|
+
EncryptorType,
|
|
62
|
+
KeyShareType,
|
|
63
|
+
OAUTH_METHODS,
|
|
64
|
+
OAuthMethod,
|
|
65
|
+
PasswordStatus,
|
|
66
|
+
PublicKeyStatus,
|
|
67
|
+
PublicKeyType
|
|
68
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "../chunk-BBZEL7EG.js";
|
|
2
|
+
var OnRampProvider = /* @__PURE__ */ ((OnRampProvider2) => {
|
|
3
|
+
OnRampProvider2["RAMP"] = "RAMP";
|
|
4
|
+
OnRampProvider2["STRIPE"] = "STRIPE";
|
|
5
|
+
OnRampProvider2["MOONPAY"] = "MOONPAY";
|
|
6
|
+
return OnRampProvider2;
|
|
7
|
+
})(OnRampProvider || {});
|
|
8
|
+
var OnRampAsset = /* @__PURE__ */ ((OnRampAsset2) => {
|
|
9
|
+
OnRampAsset2["ETHEREUM"] = "ETHEREUM";
|
|
10
|
+
OnRampAsset2["USDC"] = "USDC";
|
|
11
|
+
OnRampAsset2["TETHER"] = "TETHER";
|
|
12
|
+
OnRampAsset2["POLYGON"] = "POLYGON";
|
|
13
|
+
OnRampAsset2["SOLANA"] = "SOLANA";
|
|
14
|
+
OnRampAsset2["ATOM"] = "ATOM";
|
|
15
|
+
OnRampAsset2["CELO"] = "CELO";
|
|
16
|
+
OnRampAsset2["CUSD"] = "CUSD";
|
|
17
|
+
OnRampAsset2["CEUR"] = "CEUR";
|
|
18
|
+
OnRampAsset2["CREAL"] = "CREAL";
|
|
19
|
+
return OnRampAsset2;
|
|
20
|
+
})(OnRampAsset || {});
|
|
21
|
+
var OnRampPurchaseStatus = /* @__PURE__ */ ((OnRampPurchaseStatus2) => {
|
|
22
|
+
OnRampPurchaseStatus2["INITIATED"] = "INITIATED";
|
|
23
|
+
OnRampPurchaseStatus2["FINISHED"] = "FINISHED";
|
|
24
|
+
OnRampPurchaseStatus2["CANCELLED"] = "CANCELLED";
|
|
25
|
+
return OnRampPurchaseStatus2;
|
|
26
|
+
})(OnRampPurchaseStatus || {});
|
|
27
|
+
var OnRampPurchaseType = /* @__PURE__ */ ((OnRampPurchaseType2) => {
|
|
28
|
+
OnRampPurchaseType2["BUY"] = "BUY";
|
|
29
|
+
OnRampPurchaseType2["SELL"] = "SELL";
|
|
30
|
+
return OnRampPurchaseType2;
|
|
31
|
+
})(OnRampPurchaseType || {});
|
|
32
|
+
export {
|
|
33
|
+
OnRampAsset,
|
|
34
|
+
OnRampProvider,
|
|
35
|
+
OnRampPurchaseStatus,
|
|
36
|
+
OnRampPurchaseType
|
|
37
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import "../chunk-BBZEL7EG.js";
|
|
2
|
+
var WalletScheme = /* @__PURE__ */ ((WalletScheme2) => {
|
|
3
|
+
WalletScheme2["DKLS"] = "DKLS";
|
|
4
|
+
WalletScheme2["CGGMP"] = "CGGMP";
|
|
5
|
+
WalletScheme2["ED25519"] = "ED25519";
|
|
6
|
+
return WalletScheme2;
|
|
7
|
+
})(WalletScheme || {});
|
|
8
|
+
const WALLET_SCHEMES = ["DKLS", "CGGMP", "ED25519"];
|
|
9
|
+
var WalletType = /* @__PURE__ */ ((WalletType2) => {
|
|
10
|
+
WalletType2["EVM"] = "EVM";
|
|
11
|
+
WalletType2["SOLANA"] = "SOLANA";
|
|
12
|
+
WalletType2["COSMOS"] = "COSMOS";
|
|
13
|
+
return WalletType2;
|
|
14
|
+
})(WalletType || {});
|
|
15
|
+
const WALLET_TYPES = ["EVM", "SOLANA", "COSMOS"];
|
|
16
|
+
var Chain = /* @__PURE__ */ ((Chain2) => {
|
|
17
|
+
Chain2["ETH"] = "ETH";
|
|
18
|
+
Chain2["CELO"] = "CELO";
|
|
19
|
+
Chain2["MATIC"] = "MATIC";
|
|
20
|
+
return Chain2;
|
|
21
|
+
})(Chain || {});
|
|
22
|
+
var Network = /* @__PURE__ */ ((Network2) => {
|
|
23
|
+
Network2["ETHEREUM"] = "ETHEREUM";
|
|
24
|
+
Network2["SEPOLIA"] = "SEPOLIA";
|
|
25
|
+
Network2["ARBITRUM"] = "ARBITRUM";
|
|
26
|
+
Network2["BASE"] = "BASE";
|
|
27
|
+
Network2["OPTIMISM"] = "OPTIMISM";
|
|
28
|
+
Network2["POLYGON"] = "POLYGON";
|
|
29
|
+
Network2["SOLANA"] = "SOLANA";
|
|
30
|
+
Network2["COSMOS"] = "COSMOS";
|
|
31
|
+
Network2["CELO"] = "CELO";
|
|
32
|
+
Network2["NOBLE"] = "NOBLE";
|
|
33
|
+
Network2["SOLANA_DEVNET"] = "SOLANA_DEVNET";
|
|
34
|
+
return Network2;
|
|
35
|
+
})(Network || {});
|
|
36
|
+
const PREGEN_IDENTIFIER_TYPES = [
|
|
37
|
+
"EMAIL",
|
|
38
|
+
"PHONE",
|
|
39
|
+
"CUSTOM_ID",
|
|
40
|
+
"GUEST_ID",
|
|
41
|
+
"DISCORD",
|
|
42
|
+
"TWITTER",
|
|
43
|
+
"TELEGRAM",
|
|
44
|
+
"FARCASTER"
|
|
45
|
+
];
|
|
46
|
+
const NON_ED25519 = ["DKLS", "CGGMP"];
|
|
47
|
+
export {
|
|
48
|
+
Chain,
|
|
49
|
+
NON_ED25519,
|
|
50
|
+
Network,
|
|
51
|
+
PREGEN_IDENTIFIER_TYPES,
|
|
52
|
+
WALLET_SCHEMES,
|
|
53
|
+
WALLET_TYPES,
|
|
54
|
+
WalletScheme,
|
|
55
|
+
WalletType
|
|
56
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-BBZEL7EG.js";
|
|
5
|
+
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
6
|
+
function isWalletId(params) {
|
|
7
|
+
return !!params.walletId && !params.externalWalletAddress;
|
|
8
|
+
}
|
|
9
|
+
function isExternalWalletAddress(params) {
|
|
10
|
+
return !!params.externalWalletAddress && !params.walletId;
|
|
11
|
+
}
|
|
12
|
+
function extractWalletRef(params) {
|
|
13
|
+
if (isWalletId(params)) {
|
|
14
|
+
return ["walletId", params.walletId];
|
|
15
|
+
} else if (isExternalWalletAddress(params)) {
|
|
16
|
+
return ["externalWalletAddress", params.externalWalletAddress];
|
|
17
|
+
}
|
|
18
|
+
throw new Error("invalid wallet params");
|
|
19
|
+
}
|
|
20
|
+
function isValid(s) {
|
|
21
|
+
return !!s && s !== "null" && s !== "undefined" && s !== "";
|
|
22
|
+
}
|
|
23
|
+
function isEmail(params) {
|
|
24
|
+
return !!params && isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.externalWalletAddress);
|
|
25
|
+
}
|
|
26
|
+
function isPhone(params) {
|
|
27
|
+
return !!params && isValid(params.phone) && /^\+\d+$/.test(params.phone) && !isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.userId) && !isValid(params.externalWalletAddress);
|
|
28
|
+
}
|
|
29
|
+
function isPhoneLegacy(params) {
|
|
30
|
+
return !!params && isValid(params.phone) && isValid(params.countryCode) && !isValid(params.email) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.externalWalletAddress);
|
|
31
|
+
}
|
|
32
|
+
function isFarcaster(params) {
|
|
33
|
+
return !!params && isValid(params.farcasterUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.telegramUserId) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.externalWalletAddress);
|
|
34
|
+
}
|
|
35
|
+
function isTelegram(params) {
|
|
36
|
+
return !!params && isValid(params.telegramUserId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.externalWalletAddress);
|
|
37
|
+
}
|
|
38
|
+
function isExternalWallet(params) {
|
|
39
|
+
return !!params && isValid(params.externalWalletAddress) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId);
|
|
40
|
+
}
|
|
41
|
+
function isX(params) {
|
|
42
|
+
return !!params && isValid(params.xUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.externalWalletAddress);
|
|
43
|
+
}
|
|
44
|
+
function isDiscord(params) {
|
|
45
|
+
return !!params && isValid(params.discordUsername) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.xUsername) && !isValid(params.customId) && !isValid(params.externalWalletAddress);
|
|
46
|
+
}
|
|
47
|
+
function isCustomId(params) {
|
|
48
|
+
return !!params && isValid(params.customId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.telegramUserId) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.externalWalletAddress);
|
|
49
|
+
}
|
|
50
|
+
function isGuestId(params) {
|
|
51
|
+
return !!params && isValid(params.guestId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.externalWalletAddress);
|
|
52
|
+
}
|
|
53
|
+
function isUserId(params) {
|
|
54
|
+
return !!params && isValid(params.userId) && !isValid(params.email) && !isValid(params.phone) && !isValid(params.countryCode) && !isValid(params.farcasterUsername) && !isValid(params.xUsername) && !isValid(params.discordUsername) && !isValid(params.customId) && !isValid(params.telegramUserId) && !isValid(params.externalWalletAddress);
|
|
55
|
+
}
|
|
56
|
+
function isPrimary(params) {
|
|
57
|
+
return isEmail(params) || isPhone(params) || isFarcaster(params) || isTelegram(params) || isExternalWallet(params);
|
|
58
|
+
}
|
|
59
|
+
function isVerifiedAuth(params) {
|
|
60
|
+
return isEmail(params) || isPhone(params);
|
|
61
|
+
}
|
|
62
|
+
function isPregenAuth(params) {
|
|
63
|
+
return isPrimary(params) && !isExternalWallet(params) || isX(params) || isDiscord(params) || isCustomId(params);
|
|
64
|
+
}
|
|
65
|
+
function extractAuthInfo(obj, { allowUserId = false, allowPregen = false, isRequired = false } = {}) {
|
|
66
|
+
obj = Object.entries(obj || {}).reduce((acc, [k, v]) => {
|
|
67
|
+
return __spreadValues(__spreadValues({}, acc), !!v && v !== "null" && v !== "undefined" && v !== "" ? { [k]: v } : {});
|
|
68
|
+
}, {});
|
|
69
|
+
let error;
|
|
70
|
+
switch (true) {
|
|
71
|
+
case isEmail(obj):
|
|
72
|
+
return {
|
|
73
|
+
auth: { email: obj.email },
|
|
74
|
+
authType: "email",
|
|
75
|
+
identifier: obj.email
|
|
76
|
+
};
|
|
77
|
+
case isPhone(obj):
|
|
78
|
+
if (!parsePhoneNumberFromString(obj.phone)) {
|
|
79
|
+
error = "invalid phone number";
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
auth: { phone: obj.phone },
|
|
84
|
+
authType: "phone",
|
|
85
|
+
identifier: obj.phone
|
|
86
|
+
};
|
|
87
|
+
case isPhoneLegacy(obj):
|
|
88
|
+
const identifier = `${obj.countryCode.startsWith("+") ? "" : "+"}${obj.countryCode}${obj.phone}`;
|
|
89
|
+
if (!parsePhoneNumberFromString(identifier)) {
|
|
90
|
+
error = "invalid phone number";
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
auth: { phone: identifier },
|
|
95
|
+
authType: "phone",
|
|
96
|
+
identifier
|
|
97
|
+
};
|
|
98
|
+
case isFarcaster(obj):
|
|
99
|
+
return {
|
|
100
|
+
auth: { farcasterUsername: obj.farcasterUsername },
|
|
101
|
+
authType: "farcaster",
|
|
102
|
+
identifier: obj.farcasterUsername
|
|
103
|
+
};
|
|
104
|
+
case isTelegram(obj):
|
|
105
|
+
return {
|
|
106
|
+
auth: { telegramUserId: obj.telegramUserId },
|
|
107
|
+
authType: "telegram",
|
|
108
|
+
identifier: obj.telegramUserId
|
|
109
|
+
};
|
|
110
|
+
case isExternalWallet(obj):
|
|
111
|
+
return {
|
|
112
|
+
auth: { externalWalletAddress: obj.externalWalletAddress },
|
|
113
|
+
authType: "externalWallet",
|
|
114
|
+
identifier: obj.externalWalletAddress
|
|
115
|
+
};
|
|
116
|
+
case (allowPregen && isX(obj)):
|
|
117
|
+
return {
|
|
118
|
+
auth: { xUsername: obj.xUsername },
|
|
119
|
+
authType: "x",
|
|
120
|
+
identifier: obj.xUsername
|
|
121
|
+
};
|
|
122
|
+
case (allowPregen && isDiscord(obj)):
|
|
123
|
+
return {
|
|
124
|
+
auth: { discordUsername: obj.discordUsername },
|
|
125
|
+
authType: "discord",
|
|
126
|
+
identifier: obj.discordUsername
|
|
127
|
+
};
|
|
128
|
+
case (allowPregen && isCustomId(obj)):
|
|
129
|
+
return {
|
|
130
|
+
auth: { customId: obj.customId },
|
|
131
|
+
authType: "customId",
|
|
132
|
+
identifier: obj.customId
|
|
133
|
+
};
|
|
134
|
+
case (allowPregen && isGuestId(obj)):
|
|
135
|
+
return {
|
|
136
|
+
auth: { guestId: obj.guestId },
|
|
137
|
+
authType: "guestId",
|
|
138
|
+
identifier: obj.guestId
|
|
139
|
+
};
|
|
140
|
+
case (isUserId(obj) && allowUserId):
|
|
141
|
+
return {
|
|
142
|
+
auth: { userId: obj.userId },
|
|
143
|
+
authType: "userId",
|
|
144
|
+
identifier: obj.userId
|
|
145
|
+
};
|
|
146
|
+
default:
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
if (isRequired) {
|
|
150
|
+
throw new Error(error != null ? error : "invalid auth object");
|
|
151
|
+
}
|
|
152
|
+
return void 0;
|
|
153
|
+
}
|
|
154
|
+
function toPregenTypeAndId(auth) {
|
|
155
|
+
const { authType, identifier: pregenIdentifier } = extractAuthInfo(auth, { isRequired: true, allowPregen: true });
|
|
156
|
+
const pregenIdentifierType = {
|
|
157
|
+
email: "EMAIL",
|
|
158
|
+
phone: "PHONE",
|
|
159
|
+
farcaster: "FARCASTER",
|
|
160
|
+
telegram: "TELEGRAM",
|
|
161
|
+
discord: "DISCORD",
|
|
162
|
+
x: "TWITTER",
|
|
163
|
+
customId: "CUSTOM_ID",
|
|
164
|
+
guestId: "GUEST_ID"
|
|
165
|
+
}[authType];
|
|
166
|
+
return [pregenIdentifierType, pregenIdentifier];
|
|
167
|
+
}
|
|
168
|
+
function toPregenIds(auth) {
|
|
169
|
+
const [pregenIdentifierType, pregenIdentifier] = toPregenTypeAndId(auth);
|
|
170
|
+
return { [pregenIdentifierType]: [pregenIdentifier] };
|
|
171
|
+
}
|
|
172
|
+
function fromAccountMetadata(obj) {
|
|
173
|
+
return Object.entries(obj || {}).reduce(
|
|
174
|
+
(acc, [method, obj2]) => __spreadProps(__spreadValues({}, acc), {
|
|
175
|
+
[method]: __spreadProps(__spreadValues({}, obj2), {
|
|
176
|
+
date: new Date(obj2.date)
|
|
177
|
+
})
|
|
178
|
+
}),
|
|
179
|
+
{}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
export {
|
|
183
|
+
extractAuthInfo,
|
|
184
|
+
extractWalletRef,
|
|
185
|
+
fromAccountMetadata,
|
|
186
|
+
isCustomId,
|
|
187
|
+
isDiscord,
|
|
188
|
+
isEmail,
|
|
189
|
+
isExternalWallet,
|
|
190
|
+
isExternalWalletAddress,
|
|
191
|
+
isFarcaster,
|
|
192
|
+
isGuestId,
|
|
193
|
+
isPhone,
|
|
194
|
+
isPhoneLegacy,
|
|
195
|
+
isPregenAuth,
|
|
196
|
+
isPrimary,
|
|
197
|
+
isTelegram,
|
|
198
|
+
isUserId,
|
|
199
|
+
isVerifiedAuth,
|
|
200
|
+
isWalletId,
|
|
201
|
+
isX,
|
|
202
|
+
toPregenIds,
|
|
203
|
+
toPregenTypeAndId
|
|
204
|
+
};
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, ExternalWalletInfo, LoginExternalWalletResponse, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, PasswordStatus, PregenIds, PrimaryAuth, PublicKeyStatus, PublicKeyType, ServerAuthStateSignup, SessionInfo, Setup2faResponse, SignUpOrLogInResponse, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, VerifyFarcasterResponse, VerifyTelegramResponse, VerifyThirdPartyAuth, WalletEntity, WalletParams,
|
|
2
|
+
import { AccountMetadata, Auth, AuthIdentifier, AuthMethod, BackupKitEmailProps, BiometricLocationHint, Chain, CurrentWalletIds, EncryptedKeyShare, EncryptorType, ExternalWalletInfo, LoginExternalWalletResponse, KeyShareType, Network, OnRampAsset, OnRampConfig, OnRampProvider, OnRampPurchase, OnRampPurchaseCreateParams, OnRampPurchaseUpdateParams, PasswordStatus, PregenIds, PrimaryAuth, PublicKeyStatus, PublicKeyType, ServerAuthStateSignup, SessionInfo, Setup2faResponse, SignUpOrLogInResponse, TelegramAuthResponse, TPregenIdentifierType, VerificationEmailProps, VerifiedAuth, VerifyFarcasterResponse, VerifyTelegramResponse, VerifyThirdPartyAuth, WalletEntity, WalletParams, TWalletScheme, TWalletType, VerifyExternalWalletParams } from './types/index.js';
|
|
3
3
|
interface ConfigOpts {
|
|
4
4
|
useFetchAdapter?: boolean;
|
|
5
5
|
}
|
|
@@ -70,8 +70,8 @@ interface PasswordEntity {
|
|
|
70
70
|
}
|
|
71
71
|
interface createWalletBody {
|
|
72
72
|
useTwoSigners?: boolean;
|
|
73
|
-
scheme:
|
|
74
|
-
type:
|
|
73
|
+
scheme: TWalletScheme;
|
|
74
|
+
type: TWalletType;
|
|
75
75
|
cosmosPrefix?: string;
|
|
76
76
|
}
|
|
77
77
|
interface updatePregenWalletBody {
|
|
@@ -82,11 +82,14 @@ interface createWalletRes {
|
|
|
82
82
|
protocolId: string;
|
|
83
83
|
walletId: string;
|
|
84
84
|
}
|
|
85
|
+
interface GetWalletBalanceRes {
|
|
86
|
+
balance: string;
|
|
87
|
+
}
|
|
85
88
|
interface createPregenWalletBody {
|
|
86
89
|
pregenIdentifier: string;
|
|
87
90
|
pregenIdentifierType: TPregenIdentifierType;
|
|
88
|
-
scheme?:
|
|
89
|
-
type:
|
|
91
|
+
scheme?: TWalletScheme;
|
|
92
|
+
type: TWalletType;
|
|
90
93
|
cosmosPrefix?: string;
|
|
91
94
|
}
|
|
92
95
|
interface claimPreGenWalletsBody {
|
|
@@ -113,6 +116,7 @@ interface sessionPasswordBody {
|
|
|
113
116
|
encryptedWalletPrivateKey?: string;
|
|
114
117
|
encryptionKeyHash?: string;
|
|
115
118
|
}
|
|
119
|
+
export type SDKType = 'WEB' | 'SERVER' | 'BRIDGE' | 'REACT_NATIVE';
|
|
116
120
|
export type VerifyTelegramRes = {
|
|
117
121
|
isValid: true;
|
|
118
122
|
userId: string;
|
|
@@ -185,7 +189,7 @@ declare class Client {
|
|
|
185
189
|
logout: () => Promise<any>;
|
|
186
190
|
recoveryVerification: (email: string, verificationCode: string) => Promise<any>;
|
|
187
191
|
recoveryInit: (email: string) => Promise<any>;
|
|
188
|
-
preSignMessage: (userId: string, walletId: string, message: string, scheme?:
|
|
192
|
+
preSignMessage: (userId: string, walletId: string, message: string, scheme?: TWalletScheme, cosmosSignDoc?: string) => Promise<any>;
|
|
189
193
|
deleteSelf: (userId: string) => Promise<any>;
|
|
190
194
|
uploadKeyshares(userId: string, walletId: string, encryptedKeyshares: EncryptedKeyShare[]): Promise<any>;
|
|
191
195
|
uploadUserKeyShares(userId: string, encryptedKeyshares: (EncryptedKeyShare & {
|
|
@@ -202,7 +206,7 @@ declare class Client {
|
|
|
202
206
|
}[]): Promise<any>;
|
|
203
207
|
getTransmissionKeyshares(userId: string, sessionLookupId: string): Promise<any>;
|
|
204
208
|
getParaShare: (userId: string, walletId: string) => Promise<string>;
|
|
205
|
-
getBackupKit: (userId: string) => Promise<any>;
|
|
209
|
+
getBackupKit: (userId: string, walletId: string) => Promise<any>;
|
|
206
210
|
resendVerificationCode({ userId, ...rest }: {
|
|
207
211
|
userId: string;
|
|
208
212
|
} & VerificationEmailProps): Promise<AxiosResponse<any, any>>;
|
|
@@ -246,7 +250,7 @@ declare class Client {
|
|
|
246
250
|
getPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<any, any>>;
|
|
247
251
|
acceptPendingTransaction(userId: string, pendingTransactionId: string): Promise<AxiosResponse<any, any>>;
|
|
248
252
|
getOnRampConfig(): Promise<OnRampConfig>;
|
|
249
|
-
createOnRampPurchase({ userId, params
|
|
253
|
+
createOnRampPurchase({ userId, params, ...walletParams }: {
|
|
250
254
|
userId: string;
|
|
251
255
|
params: OnRampPurchaseCreateParams;
|
|
252
256
|
} & WalletParams): Promise<OnRampPurchase>;
|
|
@@ -261,7 +265,7 @@ declare class Client {
|
|
|
261
265
|
} & WalletParams): Promise<AxiosResponse<OnRampPurchase, any>>;
|
|
262
266
|
signMoonPayUrl(userId: string, { url, type, cosmosPrefix, testMode, walletId, externalWalletAddress, }: {
|
|
263
267
|
url: string;
|
|
264
|
-
type:
|
|
268
|
+
type: TWalletType;
|
|
265
269
|
cosmosPrefix: string;
|
|
266
270
|
testMode?: boolean;
|
|
267
271
|
walletId?: string;
|
|
@@ -271,6 +275,7 @@ declare class Client {
|
|
|
271
275
|
}, any>>;
|
|
272
276
|
generateOffRampTx<ReturnType = {
|
|
273
277
|
tx: string;
|
|
278
|
+
message?: string;
|
|
274
279
|
asset: OnRampAsset;
|
|
275
280
|
network: Network;
|
|
276
281
|
}>(userId: string, { provider, chainId, contractAddress, testMode, walletId, walletType, destinationAddress, sourceAddress, assetQuantity, }: {
|
|
@@ -279,19 +284,20 @@ declare class Client {
|
|
|
279
284
|
contractAddress?: string;
|
|
280
285
|
testMode?: boolean;
|
|
281
286
|
walletId: string;
|
|
282
|
-
walletType:
|
|
287
|
+
walletType: TWalletType;
|
|
283
288
|
destinationAddress: string;
|
|
284
289
|
sourceAddress?: string;
|
|
285
290
|
assetQuantity: string | number;
|
|
286
291
|
}): Promise<ReturnType>;
|
|
287
292
|
sendOffRampTx<ReturnType = {
|
|
288
293
|
txHash: string;
|
|
289
|
-
}>(userId: string, { tx, signature, network, walletId, walletType, }: {
|
|
294
|
+
}>(userId: string, { tx, signature, sourceAddress, network, walletId, walletType, }: {
|
|
290
295
|
tx: string;
|
|
291
296
|
signature: string;
|
|
297
|
+
sourceAddress?: string;
|
|
292
298
|
network: Network;
|
|
293
299
|
walletId: string;
|
|
294
|
-
walletType:
|
|
300
|
+
walletType: TWalletType;
|
|
295
301
|
}): Promise<ReturnType>;
|
|
296
302
|
distributeParaShare({ userId, walletId, ...rest }: {
|
|
297
303
|
userId: string;
|
|
@@ -327,5 +333,21 @@ declare class Client {
|
|
|
327
333
|
verifyPasswordChallenge(partnerId: string, body: verifyPasswordChallengeBody): Promise<any>;
|
|
328
334
|
getEncryptedWalletPrivateKey(passwordId: string): Promise<any>;
|
|
329
335
|
getUser(userId: string): Promise<any>;
|
|
336
|
+
getAccountMetadata(userId: string, partnerId: string): Promise<{
|
|
337
|
+
accountMetadata: AccountMetadata;
|
|
338
|
+
}>;
|
|
339
|
+
getWalletBalance: ({ walletId, rpcUrl }: {
|
|
340
|
+
walletId: string;
|
|
341
|
+
rpcUrl?: string;
|
|
342
|
+
}) => Promise<GetWalletBalanceRes>;
|
|
343
|
+
trackError: (opts: {
|
|
344
|
+
methodName: string;
|
|
345
|
+
error: {
|
|
346
|
+
name: string;
|
|
347
|
+
message: string;
|
|
348
|
+
};
|
|
349
|
+
sdkType: SDKType;
|
|
350
|
+
userId: string;
|
|
351
|
+
}) => Promise<void>;
|
|
330
352
|
}
|
|
331
353
|
export default Client;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CurrentWalletIds, ExternalWalletType, SupportedWalletTypes } from './wallet.js';
|
|
2
|
-
export declare const AUTH_TYPES: readonly ["email", "phone", "phoneLegacy", "farcaster", "telegram", "userId", "externalWallet", "discord", "x", "customId"];
|
|
3
|
-
export type AuthType = 'email' | 'phone' | 'phoneLegacy' | 'farcaster' | 'telegram' | 'userId' | 'externalWallet' | 'discord' | 'x' | 'customId';
|
|
2
|
+
export declare const AUTH_TYPES: readonly ["email", "phone", "phoneLegacy", "farcaster", "telegram", "userId", "externalWallet", "discord", "x", "customId", "guestId"];
|
|
3
|
+
export type AuthType = 'email' | 'phone' | 'phoneLegacy' | 'farcaster' | 'telegram' | 'userId' | 'externalWallet' | 'discord' | 'x' | 'customId' | 'guestId';
|
|
4
4
|
export type PrimaryAuthType = Extract<AuthType, 'email' | 'phone' | 'farcaster' | 'telegram' | 'externalWallet'>;
|
|
5
5
|
export type VerifiedAuthType = Extract<PrimaryAuthType, 'email' | 'phone' | 'externalWallet'>;
|
|
6
6
|
export type PregenAuthType = Exclude<PrimaryAuthType, 'externalWallet'> | Extract<AuthType, 'discord' | 'x' | 'customId'>;
|
|
@@ -41,12 +41,15 @@ export type Auth<T extends AuthType = AuthType> = T extends 'email' ? {
|
|
|
41
41
|
discordUsername: AuthIdentifier<'discord'>;
|
|
42
42
|
} : T extends 'customId' ? {
|
|
43
43
|
customId: AuthIdentifier<'customId'>;
|
|
44
|
+
} : T extends 'guestId' ? {
|
|
45
|
+
guestId: AuthIdentifier<'guestId'>;
|
|
44
46
|
} : {
|
|
45
47
|
userId: AuthIdentifier<'userId'>;
|
|
46
48
|
};
|
|
47
49
|
export type PrimaryAuth = Auth<PrimaryAuthType>;
|
|
48
50
|
export type VerifiedAuth = Auth<VerifiedAuthType>;
|
|
49
51
|
export type PregenAuth = Auth<PregenAuthType>;
|
|
52
|
+
export type PregenOrGuestAuth = Auth<PregenAuthType | 'guestId'>;
|
|
50
53
|
export type AuthExtras = {
|
|
51
54
|
/**
|
|
52
55
|
* The current user's third-party username.
|
|
@@ -97,6 +100,7 @@ export interface EncryptedKeyShare {
|
|
|
97
100
|
partnerId?: string;
|
|
98
101
|
protocolId?: string;
|
|
99
102
|
}
|
|
103
|
+
/** @deprecated use the string union type `TOAuthMethod` instead */
|
|
100
104
|
export declare enum OAuthMethod {
|
|
101
105
|
GOOGLE = "GOOGLE",
|
|
102
106
|
TWITTER = "TWITTER",
|
|
@@ -106,6 +110,8 @@ export declare enum OAuthMethod {
|
|
|
106
110
|
FARCASTER = "FARCASTER",
|
|
107
111
|
TELEGRAM = "TELEGRAM"
|
|
108
112
|
}
|
|
113
|
+
export declare const OAUTH_METHODS: readonly ["GOOGLE", "TWITTER", "APPLE", "DISCORD", "FACEBOOK", "FARCASTER", "TELEGRAM"];
|
|
114
|
+
export type TOAuthMethod = (typeof OAUTH_METHODS)[number];
|
|
109
115
|
export declare enum AuthMethod {
|
|
110
116
|
PASSWORD = "PASSWORD",
|
|
111
117
|
PASSKEY = "PASSKEY"
|
|
@@ -161,6 +167,8 @@ export type ExternalWalletInfo = {
|
|
|
161
167
|
provider?: string;
|
|
162
168
|
addressBech32?: string;
|
|
163
169
|
withFullParaAuth?: boolean;
|
|
170
|
+
ensName?: string | null;
|
|
171
|
+
ensAvatar?: string | null;
|
|
164
172
|
};
|
|
165
173
|
export type VerifyExternalWalletParams = {
|
|
166
174
|
/**
|
|
@@ -200,3 +208,8 @@ export type Setup2faResponse = {
|
|
|
200
208
|
*/
|
|
201
209
|
uri: string;
|
|
202
210
|
};
|
|
211
|
+
export type AccountMetadataKey = Lowercase<Exclude<TOAuthMethod, 'TWITTER'> | 'X'>;
|
|
212
|
+
export type AccountMetadata = Partial<Record<AccountMetadataKey, {
|
|
213
|
+
date: Date;
|
|
214
|
+
metadata: Record<string, any>;
|
|
215
|
+
}>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Network,
|
|
1
|
+
import { Network, TWalletType } from './wallet.js';
|
|
2
2
|
export declare enum OnRampProvider {
|
|
3
3
|
RAMP = "RAMP",
|
|
4
4
|
STRIPE = "STRIPE",
|
|
@@ -30,7 +30,7 @@ export interface OnRampPurchase {
|
|
|
30
30
|
userId: string;
|
|
31
31
|
type?: OnRampPurchaseType;
|
|
32
32
|
walletId?: string | null;
|
|
33
|
-
walletType?:
|
|
33
|
+
walletType?: TWalletType;
|
|
34
34
|
externalWalletAddress?: string | null;
|
|
35
35
|
address?: string | null;
|
|
36
36
|
status?: OnRampPurchaseStatus;
|
|
@@ -51,7 +51,7 @@ export type OnRampPurchaseCreateParams = Omit<OnRampPurchase, 'id' | 'userId'> &
|
|
|
51
51
|
};
|
|
52
52
|
export type OnRampPurchaseUpdateParams = Omit<OnRampPurchase, 'id' | 'userId'>;
|
|
53
53
|
type ProviderAssetInfo = [string, Partial<Record<OnRampPurchaseType, boolean>>];
|
|
54
|
-
export type OnRampAssetInfo = Record<
|
|
54
|
+
export type OnRampAssetInfo = Record<TWalletType, Partial<Record<Network, Partial<Record<OnRampAsset, Partial<Record<OnRampProvider, ProviderAssetInfo>>>>>>>;
|
|
55
55
|
export type OnRampAllowedAssets = Partial<Record<Network, true | OnRampAsset[]>>;
|
|
56
56
|
export type OnRampConfig = {
|
|
57
57
|
isBuyEnabled: boolean;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { PartnerEntity } from './partner.js';
|
|
2
|
+
/** @deprecated use the string union type `TWalletScheme` instead */
|
|
2
3
|
export declare enum WalletScheme {
|
|
3
4
|
DKLS = "DKLS",
|
|
4
5
|
CGGMP = "CGGMP",
|
|
5
6
|
ED25519 = "ED25519"
|
|
6
7
|
}
|
|
8
|
+
export declare const WALLET_SCHEMES: readonly ["DKLS", "CGGMP", "ED25519"];
|
|
9
|
+
export type TWalletScheme = (typeof WALLET_SCHEMES)[number];
|
|
10
|
+
/** @deprecated use the string union type `TWalletType` instead */
|
|
7
11
|
export declare enum WalletType {
|
|
8
12
|
EVM = "EVM",
|
|
9
13
|
SOLANA = "SOLANA",
|
|
10
14
|
COSMOS = "COSMOS"
|
|
11
15
|
}
|
|
16
|
+
export declare const WALLET_TYPES: readonly ["EVM", "SOLANA", "COSMOS"];
|
|
17
|
+
export type TWalletType = (typeof WALLET_TYPES)[number];
|
|
12
18
|
export declare enum Chain {
|
|
13
19
|
ETH = "ETH",
|
|
14
20
|
CELO = "CELO",
|
|
@@ -24,16 +30,17 @@ export declare enum Network {
|
|
|
24
30
|
SOLANA = "SOLANA",
|
|
25
31
|
COSMOS = "COSMOS",
|
|
26
32
|
CELO = "CELO",
|
|
27
|
-
NOBLE = "NOBLE"
|
|
33
|
+
NOBLE = "NOBLE",
|
|
34
|
+
SOLANA_DEVNET = "SOLANA_DEVNET"
|
|
28
35
|
}
|
|
29
36
|
export type WalletRef = 'walletId' | 'externalWalletAddress';
|
|
30
37
|
export type WalletParams = Partial<{
|
|
31
38
|
walletId?: string;
|
|
32
39
|
externalWalletAddress?: string;
|
|
33
40
|
}>;
|
|
34
|
-
export type EmbeddedWalletType = Exclude<
|
|
35
|
-
export type ExternalWalletType = Exclude<
|
|
36
|
-
export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", "DISCORD", "TWITTER", "TELEGRAM", "FARCASTER"];
|
|
41
|
+
export type EmbeddedWalletType = Exclude<TWalletType, never>;
|
|
42
|
+
export type ExternalWalletType = Exclude<TWalletType, never>;
|
|
43
|
+
export declare const PREGEN_IDENTIFIER_TYPES: readonly ["EMAIL", "PHONE", "CUSTOM_ID", "GUEST_ID", "DISCORD", "TWITTER", "TELEGRAM", "FARCASTER"];
|
|
37
44
|
export type TPregenIdentifierType = (typeof PREGEN_IDENTIFIER_TYPES)[number];
|
|
38
45
|
export type PregenIds = Partial<Record<TPregenIdentifierType, string[]>>;
|
|
39
46
|
export interface WalletEntity {
|
|
@@ -49,16 +56,18 @@ export interface WalletEntity {
|
|
|
49
56
|
partner?: PartnerEntity;
|
|
50
57
|
publicKey: string | null;
|
|
51
58
|
scheme: string;
|
|
52
|
-
type:
|
|
59
|
+
type: TWalletType;
|
|
53
60
|
updatedAt: string;
|
|
54
61
|
userId: string | null;
|
|
55
62
|
lastUsedAt: string | null;
|
|
56
63
|
lastUsedPartnerId?: string;
|
|
57
64
|
lastUsedPartner?: PartnerEntity;
|
|
65
|
+
ensName?: string | null;
|
|
66
|
+
ensAvatar?: string | null;
|
|
58
67
|
}
|
|
59
|
-
export type CurrentWalletIds = Partial<Record<
|
|
60
|
-
export declare const NON_ED25519:
|
|
68
|
+
export type CurrentWalletIds = Partial<Record<TWalletType, string[]>>;
|
|
69
|
+
export declare const NON_ED25519: string[];
|
|
61
70
|
export type SupportedWalletTypes = {
|
|
62
|
-
type:
|
|
71
|
+
type: TWalletType;
|
|
63
72
|
optional?: boolean;
|
|
64
73
|
}[];
|