@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,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.API_KEY_HEADER_NAME = exports.PARTNER_ID_HEADER_NAME = exports.VERSION_HEADER_NAME = exports.SESSION_COOKIE_HEADER_NAME = void 0;
4
+ exports.SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid';
5
+ exports.VERSION_HEADER_NAME = 'x-capsule-version';
6
+ exports.PARTNER_ID_HEADER_NAME = 'x-partner-id';
7
+ exports.API_KEY_HEADER_NAME = 'X-External-API-Key';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParaApiError = ParaApiError;
4
+ function ParaApiError(message, code, status, responseURL) {
5
+ Error.call(this);
6
+ if (Error.captureStackTrace) {
7
+ Error.captureStackTrace(this, this.constructor);
8
+ }
9
+ else {
10
+ this.stack = new Error().stack;
11
+ }
12
+ this.message = message;
13
+ this.name = 'ParaApiError';
14
+ code && (this.code = code);
15
+ status && (this.status = status);
16
+ responseURL && (this.responseURL = responseURL);
17
+ }
18
+ const prototype = ParaApiError.prototype;
19
+ Object.defineProperty(prototype, 'isParaApiError', { value: true });
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./client.js"), exports);
21
+ __exportStar(require("./types/index.js"), exports);
22
+ __exportStar(require("./utils.js"), exports);
23
+ const client_js_1 = __importDefault(require("./client.js"));
24
+ exports.default = client_js_1.default;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthMethod = exports.OAuthMethod = exports.PublicKeyType = exports.PublicKeyStatus = exports.PasswordStatus = exports.KeyShareType = exports.EncryptorType = void 0;
4
+ var EncryptorType;
5
+ (function (EncryptorType) {
6
+ EncryptorType["USER"] = "USER";
7
+ EncryptorType["RECOVERY"] = "RECOVERY";
8
+ EncryptorType["BIOMETRICS"] = "BIOMETRICS";
9
+ EncryptorType["PASSWORD"] = "PASSWORD";
10
+ })(EncryptorType || (exports.EncryptorType = EncryptorType = {}));
11
+ var KeyShareType;
12
+ (function (KeyShareType) {
13
+ KeyShareType["USER"] = "USER";
14
+ KeyShareType["RECOVERY"] = "RECOVERY";
15
+ })(KeyShareType || (exports.KeyShareType = KeyShareType = {}));
16
+ var PasswordStatus;
17
+ (function (PasswordStatus) {
18
+ PasswordStatus["PENDING"] = "PENDING";
19
+ PasswordStatus["COMPLETE"] = "COMPLETE";
20
+ })(PasswordStatus || (exports.PasswordStatus = PasswordStatus = {}));
21
+ var PublicKeyStatus;
22
+ (function (PublicKeyStatus) {
23
+ PublicKeyStatus["PENDING"] = "PENDING";
24
+ PublicKeyStatus["COMPLETE"] = "COMPLETE";
25
+ })(PublicKeyStatus || (exports.PublicKeyStatus = PublicKeyStatus = {}));
26
+ var PublicKeyType;
27
+ (function (PublicKeyType) {
28
+ PublicKeyType["MOBILE"] = "MOBILE";
29
+ PublicKeyType["WEB"] = "WEB";
30
+ })(PublicKeyType || (exports.PublicKeyType = PublicKeyType = {}));
31
+ var OAuthMethod;
32
+ (function (OAuthMethod) {
33
+ OAuthMethod["GOOGLE"] = "GOOGLE";
34
+ OAuthMethod["TWITTER"] = "TWITTER";
35
+ OAuthMethod["APPLE"] = "APPLE";
36
+ OAuthMethod["DISCORD"] = "DISCORD";
37
+ OAuthMethod["FACEBOOK"] = "FACEBOOK";
38
+ OAuthMethod["FARCASTER"] = "FARCASTER";
39
+ OAuthMethod["TELEGRAM"] = "TELEGRAM";
40
+ })(OAuthMethod || (exports.OAuthMethod = OAuthMethod = {}));
41
+ var AuthMethod;
42
+ (function (AuthMethod) {
43
+ AuthMethod["PASSWORD"] = "PASSWORD";
44
+ AuthMethod["PASSKEY"] = "PASSKEY";
45
+ })(AuthMethod || (exports.AuthMethod = AuthMethod = {}));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailTheme = void 0;
4
+ var EmailTheme;
5
+ (function (EmailTheme) {
6
+ EmailTheme["LIGHT"] = "light";
7
+ EmailTheme["DARK"] = "dark";
8
+ })(EmailTheme || (exports.EmailTheme = EmailTheme = {}));
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./auth.js"), exports);
18
+ __exportStar(require("./email.js"), exports);
19
+ __exportStar(require("./onRamp.js"), exports);
20
+ __exportStar(require("./partner.js"), exports);
21
+ __exportStar(require("./wallet.js"), exports);
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OnRampPurchaseType = exports.OnRampPurchaseStatus = exports.OnRampAsset = exports.OnRampProvider = void 0;
4
+ var OnRampProvider;
5
+ (function (OnRampProvider) {
6
+ OnRampProvider["RAMP"] = "RAMP";
7
+ OnRampProvider["STRIPE"] = "STRIPE";
8
+ OnRampProvider["MOONPAY"] = "MOONPAY";
9
+ })(OnRampProvider || (exports.OnRampProvider = OnRampProvider = {}));
10
+ var OnRampAsset;
11
+ (function (OnRampAsset) {
12
+ OnRampAsset["ETHEREUM"] = "ETHEREUM";
13
+ OnRampAsset["USDC"] = "USDC";
14
+ OnRampAsset["TETHER"] = "TETHER";
15
+ OnRampAsset["POLYGON"] = "POLYGON";
16
+ OnRampAsset["SOLANA"] = "SOLANA";
17
+ OnRampAsset["ATOM"] = "ATOM";
18
+ OnRampAsset["CELO"] = "CELO";
19
+ OnRampAsset["CUSD"] = "CUSD";
20
+ OnRampAsset["CEUR"] = "CEUR";
21
+ OnRampAsset["CREAL"] = "CREAL";
22
+ })(OnRampAsset || (exports.OnRampAsset = OnRampAsset = {}));
23
+ var OnRampPurchaseStatus;
24
+ (function (OnRampPurchaseStatus) {
25
+ OnRampPurchaseStatus["INITIATED"] = "INITIATED";
26
+ OnRampPurchaseStatus["FINISHED"] = "FINISHED";
27
+ OnRampPurchaseStatus["CANCELLED"] = "CANCELLED";
28
+ })(OnRampPurchaseStatus || (exports.OnRampPurchaseStatus = OnRampPurchaseStatus = {}));
29
+ var OnRampPurchaseType;
30
+ (function (OnRampPurchaseType) {
31
+ OnRampPurchaseType["BUY"] = "BUY";
32
+ OnRampPurchaseType["SELL"] = "SELL";
33
+ })(OnRampPurchaseType || (exports.OnRampPurchaseType = OnRampPurchaseType = {}));
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NON_ED25519 = exports.PREGEN_IDENTIFIER_TYPES = exports.Network = exports.Chain = exports.WalletType = exports.WalletScheme = void 0;
4
+ const auth_js_1 = require("./auth.js");
5
+ var WalletScheme;
6
+ (function (WalletScheme) {
7
+ WalletScheme["DKLS"] = "DKLS";
8
+ WalletScheme["CGGMP"] = "CGGMP";
9
+ WalletScheme["ED25519"] = "ED25519";
10
+ })(WalletScheme || (exports.WalletScheme = WalletScheme = {}));
11
+ var WalletType;
12
+ (function (WalletType) {
13
+ WalletType["EVM"] = "EVM";
14
+ WalletType["SOLANA"] = "SOLANA";
15
+ WalletType["COSMOS"] = "COSMOS";
16
+ })(WalletType || (exports.WalletType = WalletType = {}));
17
+ var Chain;
18
+ (function (Chain) {
19
+ Chain["ETH"] = "ETH";
20
+ Chain["CELO"] = "CELO";
21
+ Chain["MATIC"] = "MATIC";
22
+ })(Chain || (exports.Chain = Chain = {}));
23
+ var Network;
24
+ (function (Network) {
25
+ Network["ETHEREUM"] = "ETHEREUM";
26
+ Network["SEPOLIA"] = "SEPOLIA";
27
+ Network["ARBITRUM"] = "ARBITRUM";
28
+ Network["BASE"] = "BASE";
29
+ Network["OPTIMISM"] = "OPTIMISM";
30
+ Network["POLYGON"] = "POLYGON";
31
+ Network["SOLANA"] = "SOLANA";
32
+ Network["COSMOS"] = "COSMOS";
33
+ Network["CELO"] = "CELO";
34
+ Network["NOBLE"] = "NOBLE";
35
+ })(Network || (exports.Network = Network = {}));
36
+ exports.PREGEN_IDENTIFIER_TYPES = [
37
+ 'EMAIL',
38
+ 'PHONE',
39
+ 'CUSTOM_ID',
40
+ auth_js_1.OAuthMethod.DISCORD,
41
+ auth_js_1.OAuthMethod.TWITTER,
42
+ auth_js_1.OAuthMethod.TELEGRAM,
43
+ ];
44
+ exports.NON_ED25519 = [WalletScheme.DKLS, WalletScheme.CGGMP];
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWalletId = isWalletId;
4
+ exports.isExternalWalletAddress = isExternalWalletAddress;
5
+ exports.extractWalletRef = extractWalletRef;
6
+ exports.isEmail = isEmail;
7
+ exports.isPhone = isPhone;
8
+ exports.isFarcaster = isFarcaster;
9
+ exports.isTelegram = isTelegram;
10
+ exports.isUserId = isUserId;
11
+ exports.extractAuthInfo = extractAuthInfo;
12
+ exports.extractAuth = extractAuth;
13
+ function isWalletId(params) {
14
+ return !!params.walletId && !params.externalWalletAddress;
15
+ }
16
+ function isExternalWalletAddress(params) {
17
+ return !!params.externalWalletAddress && !params.walletId;
18
+ }
19
+ function extractWalletRef(params) {
20
+ if (isWalletId(params)) {
21
+ return ['walletId', params.walletId];
22
+ }
23
+ else if (isExternalWalletAddress(params)) {
24
+ return ['externalWalletAddress', params.externalWalletAddress];
25
+ }
26
+ throw new Error('invalid wallet params');
27
+ }
28
+ function isValid(s) {
29
+ return !!s && s !== 'null' && s !== 'undefined' && s !== '';
30
+ }
31
+ function isEmail(params) {
32
+ return (isValid(params.email) &&
33
+ !isValid(params.phone) &&
34
+ !isValid(params.countryCode) &&
35
+ !isValid(params.farcasterUsername) &&
36
+ !isValid(params.telegramUserId));
37
+ }
38
+ function isPhone(params) {
39
+ return (isValid(params.phone) &&
40
+ isValid(params.countryCode) &&
41
+ !isValid(params.email) &&
42
+ !isValid(params.farcasterUsername) &&
43
+ !isValid(params.telegramUserId));
44
+ }
45
+ function isFarcaster(params) {
46
+ return (isValid(params.farcasterUsername) &&
47
+ !isValid(params.email) &&
48
+ !isValid(params.phone) &&
49
+ !isValid(params.countryCode) &&
50
+ !isValid(params.telegramUserId));
51
+ }
52
+ function isTelegram(params) {
53
+ return (isValid(params.telegramUserId) &&
54
+ !isValid(params.email) &&
55
+ !isValid(params.phone) &&
56
+ !isValid(params.countryCode) &&
57
+ !isValid(params.farcasterUsername));
58
+ }
59
+ function isUserId(params) {
60
+ return (isValid(params.userId) &&
61
+ !isValid(params.email) &&
62
+ !isValid(params.phone) &&
63
+ !isValid(params.countryCode) &&
64
+ !isValid(params.farcasterUsername) &&
65
+ !isValid(params.telegramUserId));
66
+ }
67
+ function extractAuthInfo(obj, { allowUserId } = {}) {
68
+ switch (true) {
69
+ case isEmail(obj):
70
+ return { auth: { email: obj.email }, authType: 'email', identifier: obj.email, publicKeyIdentifier: obj.email };
71
+ case isPhone(obj):
72
+ return {
73
+ auth: { phone: obj.phone, countryCode: obj.countryCode },
74
+ authType: 'phone',
75
+ identifier: `${obj.countryCode}${obj.phone}`,
76
+ publicKeyIdentifier: `${obj.countryCode}${obj.phone}`,
77
+ };
78
+ case isFarcaster(obj):
79
+ return {
80
+ auth: { farcasterUsername: obj.farcasterUsername },
81
+ authType: 'farcaster',
82
+ identifier: obj.farcasterUsername,
83
+ publicKeyIdentifier: `${obj.farcasterUsername}-farcaster`,
84
+ };
85
+ case isTelegram(obj):
86
+ return {
87
+ auth: { telegramUserId: obj.telegramUserId },
88
+ authType: 'telegram',
89
+ identifier: obj.telegramUserId,
90
+ publicKeyIdentifier: `${obj.telegramUserId}-telegram`,
91
+ };
92
+ case isUserId(obj) && allowUserId:
93
+ return { auth: { userId: obj.userId }, authType: 'userId', identifier: obj.userId, publicKeyIdentifier: obj.userId };
94
+ default:
95
+ throw new Error('invalid auth object');
96
+ }
97
+ }
98
+ function extractAuth(obj, opts = {}) {
99
+ try {
100
+ return extractAuthInfo(obj, { allowUserId: opts.allowUserId || false }).auth;
101
+ }
102
+ catch (e) {
103
+ if (opts.optional) {
104
+ return undefined;
105
+ }
106
+ throw e;
107
+ }
108
+ }