@getpara/user-management-client 1.0.0 → 1.0.2
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/consts.js +1 -1
- package/dist/cjs/utils.js +4 -13
- package/dist/esm/consts.js +1 -1
- package/dist/esm/utils.js +4 -12
- package/dist/types/consts.d.ts +1 -1
- package/dist/types/utils.d.ts +7 -4
- package/package.json +2 -2
package/dist/cjs/consts.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.API_KEY_HEADER_NAME = exports.PARTNER_ID_HEADER_NAME = exports.VERSION_HEADER_NAME = exports.SESSION_COOKIE_HEADER_NAME = void 0;
|
|
4
4
|
exports.SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid';
|
|
5
|
-
exports.VERSION_HEADER_NAME = 'x-
|
|
5
|
+
exports.VERSION_HEADER_NAME = 'x-para-version';
|
|
6
6
|
exports.PARTNER_ID_HEADER_NAME = 'x-partner-id';
|
|
7
7
|
exports.API_KEY_HEADER_NAME = 'X-External-API-Key';
|
package/dist/cjs/utils.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.isFarcaster = isFarcaster;
|
|
|
9
9
|
exports.isTelegram = isTelegram;
|
|
10
10
|
exports.isUserId = isUserId;
|
|
11
11
|
exports.extractAuthInfo = extractAuthInfo;
|
|
12
|
-
exports.extractAuth = extractAuth;
|
|
13
12
|
function isWalletId(params) {
|
|
14
13
|
return !!params.walletId && !params.externalWalletAddress;
|
|
15
14
|
}
|
|
@@ -64,7 +63,7 @@ function isUserId(params) {
|
|
|
64
63
|
!isValid(params.farcasterUsername) &&
|
|
65
64
|
!isValid(params.telegramUserId));
|
|
66
65
|
}
|
|
67
|
-
function extractAuthInfo(obj, { allowUserId } = {}) {
|
|
66
|
+
function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {}) {
|
|
68
67
|
switch (true) {
|
|
69
68
|
case isEmail(obj):
|
|
70
69
|
return { auth: { email: obj.email }, authType: 'email', identifier: obj.email, publicKeyIdentifier: obj.email };
|
|
@@ -92,17 +91,9 @@ function extractAuthInfo(obj, { allowUserId } = {}) {
|
|
|
92
91
|
case isUserId(obj) && allowUserId:
|
|
93
92
|
return { auth: { userId: obj.userId }, authType: 'userId', identifier: obj.userId, publicKeyIdentifier: obj.userId };
|
|
94
93
|
default:
|
|
95
|
-
|
|
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) {
|
|
94
|
+
if (isRequired) {
|
|
95
|
+
throw new Error('invalid auth object');
|
|
96
|
+
}
|
|
104
97
|
return undefined;
|
|
105
|
-
}
|
|
106
|
-
throw e;
|
|
107
98
|
}
|
|
108
99
|
}
|
package/dist/esm/consts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export const SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid';
|
|
2
|
-
export const VERSION_HEADER_NAME = 'x-
|
|
2
|
+
export const VERSION_HEADER_NAME = 'x-para-version';
|
|
3
3
|
export const PARTNER_ID_HEADER_NAME = 'x-partner-id';
|
|
4
4
|
export const API_KEY_HEADER_NAME = 'X-External-API-Key';
|
package/dist/esm/utils.js
CHANGED
|
@@ -52,7 +52,7 @@ export function isUserId(params) {
|
|
|
52
52
|
!isValid(params.farcasterUsername) &&
|
|
53
53
|
!isValid(params.telegramUserId));
|
|
54
54
|
}
|
|
55
|
-
export function extractAuthInfo(obj, { allowUserId } = {}) {
|
|
55
|
+
export function extractAuthInfo(obj, { allowUserId = false, isRequired = false } = {}) {
|
|
56
56
|
switch (true) {
|
|
57
57
|
case isEmail(obj):
|
|
58
58
|
return { auth: { email: obj.email }, authType: 'email', identifier: obj.email, publicKeyIdentifier: obj.email };
|
|
@@ -80,17 +80,9 @@ export function extractAuthInfo(obj, { allowUserId } = {}) {
|
|
|
80
80
|
case isUserId(obj) && allowUserId:
|
|
81
81
|
return { auth: { userId: obj.userId }, authType: 'userId', identifier: obj.userId, publicKeyIdentifier: obj.userId };
|
|
82
82
|
default:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
export function extractAuth(obj, opts = {}) {
|
|
87
|
-
try {
|
|
88
|
-
return extractAuthInfo(obj, { allowUserId: opts.allowUserId || false }).auth;
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
if (opts.optional) {
|
|
83
|
+
if (isRequired) {
|
|
84
|
+
throw new Error('invalid auth object');
|
|
85
|
+
}
|
|
92
86
|
return undefined;
|
|
93
|
-
}
|
|
94
|
-
throw e;
|
|
95
87
|
}
|
|
96
88
|
}
|
package/dist/types/consts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const SESSION_COOKIE_HEADER_NAME = "x-capsule-sid";
|
|
2
|
-
export declare const VERSION_HEADER_NAME = "x-
|
|
2
|
+
export declare const VERSION_HEADER_NAME = "x-para-version";
|
|
3
3
|
export declare const PARTNER_ID_HEADER_NAME = "x-partner-id";
|
|
4
4
|
export declare const API_KEY_HEADER_NAME = "X-External-API-Key";
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -11,9 +11,12 @@ export declare function isPhone(params: AuthParams): params is Auth<'phone'>;
|
|
|
11
11
|
export declare function isFarcaster(params: AuthParams): params is Auth<'farcaster'>;
|
|
12
12
|
export declare function isTelegram(params: AuthParams): params is Auth<'telegram'>;
|
|
13
13
|
export declare function isUserId(params: AuthParams): params is Auth<'userId'>;
|
|
14
|
-
|
|
14
|
+
type ExtractAuthOpts = {
|
|
15
15
|
allowUserId?: boolean;
|
|
16
|
+
isRequired?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function extractAuthInfo(obj: AuthParams, opts: ExtractAuthOpts & {
|
|
19
|
+
isRequired: true;
|
|
16
20
|
}): ExtractAuth;
|
|
17
|
-
export declare function
|
|
18
|
-
|
|
19
|
-
}): Auth | undefined;
|
|
21
|
+
export declare function extractAuthInfo(obj: AuthParams, opts?: ExtractAuthOpts): ExtractAuth | undefined;
|
|
22
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/user-management-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"types": "./dist/types/index.d.ts"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "b52cb28fc10a5fda8c49747e98b512d680b5ded0"
|
|
36
36
|
}
|