@opexa/portal-components 0.1.65 → 0.1.66
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/client/hooks/useSessionQuery.js +11 -1
- package/dist/client/hooks/useSignInMutation.d.ts +1 -0
- package/dist/client/hooks/useSignInMutation.js +1 -1
- package/dist/client/services/signIn.js +4 -4
- package/dist/components/KYC/KYCReminder.lazy.js +1 -1
- package/dist/components/SignIn/SignIn.lazy.d.ts +2 -1
- package/dist/constants/StorageKey.d.ts +1 -0
- package/dist/constants/StorageKey.js +1 -0
- package/dist/handlers/deleteSession.d.ts +1 -1
- package/dist/handlers/deleteSession.js +6 -2
- package/dist/handlers/getSession.js +29 -4
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/postSession.js +20 -3
- package/dist/schemas/forgotPasswordSchema.d.ts +4 -4
- package/dist/services/auth.d.ts +4 -3
- package/dist/services/auth.js +9 -6
- package/dist/ui/AlertDialog/AlertDialog.d.ts +55 -55
- package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +5 -5
- package/dist/ui/Badge/Badge.d.ts +12 -12
- package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
- package/dist/ui/Badge/badge.recipe.d.ts +3 -3
- package/dist/ui/Carousel/Carousel.d.ts +99 -99
- package/dist/ui/Carousel/carousel.recipe.d.ts +11 -11
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
- package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
- package/dist/ui/Combobox/Combobox.d.ts +42 -42
- package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
- package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
- package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
- package/dist/ui/Dialog/Dialog.d.ts +33 -33
- package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
- package/dist/ui/Drawer/Drawer.d.ts +33 -33
- package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
- package/dist/ui/Field/Field.d.ts +21 -21
- package/dist/ui/Field/field.recipe.d.ts +3 -3
- package/dist/ui/Menu/Menu.d.ts +144 -144
- package/dist/ui/Menu/menu.recipe.d.ts +8 -8
- package/dist/ui/Popover/Popover.d.ts +55 -55
- package/dist/ui/Popover/popover.recipe.d.ts +5 -5
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
- package/dist/ui/Select/Select.d.ts +45 -45
- package/dist/ui/Select/select.recipe.d.ts +3 -3
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.anatomy.d.ts +1 -1
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/package.json +2 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { FINGERPRINT_HEADER_KEY } from '../../constants/index.js';
|
|
2
3
|
import { getSessionQueryKey } from '../../utils/queryKeys.js';
|
|
3
4
|
import { getSession } from '../services/getSession.js';
|
|
5
|
+
import { getFingerprint } from './useSignInMutation.js';
|
|
4
6
|
export const useSessionQuery = (config) => {
|
|
5
7
|
return useQuery({
|
|
6
8
|
gcTime: 1000 * 2,
|
|
@@ -8,7 +10,15 @@ export const useSessionQuery = (config) => {
|
|
|
8
10
|
...config,
|
|
9
11
|
queryKey: getSessionQueryKey(),
|
|
10
12
|
queryFn: async ({ signal }) => {
|
|
11
|
-
|
|
13
|
+
const fingerprint = await getFingerprint();
|
|
14
|
+
return await getSession({
|
|
15
|
+
signal,
|
|
16
|
+
headers: {
|
|
17
|
+
...(fingerprint && {
|
|
18
|
+
[FINGERPRINT_HEADER_KEY]: fingerprint,
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
});
|
|
12
22
|
},
|
|
13
23
|
});
|
|
14
24
|
};
|
|
@@ -8,3 +8,4 @@ export interface UseSignInMutationOptions extends MutationConfig<Authenticator |
|
|
|
8
8
|
version?: ApiVersion;
|
|
9
9
|
}
|
|
10
10
|
export declare const useSignInMutation: (options?: UseSignInMutationOptions) => UseMutationResult<Authenticator | null, Error, SignInInput>;
|
|
11
|
+
export declare function getFingerprint(): Promise<string | null>;
|
|
@@ -88,7 +88,7 @@ async function pollSignIn(signInOnce) {
|
|
|
88
88
|
return result.authenticator;
|
|
89
89
|
}
|
|
90
90
|
let thumbmark_instance;
|
|
91
|
-
async function getFingerprint() {
|
|
91
|
+
export async function getFingerprint() {
|
|
92
92
|
if (typeof window === 'undefined')
|
|
93
93
|
return null;
|
|
94
94
|
if (!thumbmark_instance) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Capacitor } from '@capacitor/core';
|
|
2
|
-
import { API_VERSION_HEADER_KEY, AUTH_API_BASE_URL_HEADER_KEY,
|
|
2
|
+
import { API_VERSION_HEADER_KEY, AUTH_API_BASE_URL_HEADER_KEY, SESSION_VERSION_HEADER_KEY, } from '../../constants/index.js';
|
|
3
3
|
import { httpRequest, } from '../../services/httpRequest.js';
|
|
4
4
|
const platform = Capacitor.getPlatform();
|
|
5
5
|
export async function signIn(input, options, versionSession = 'default', version = 1, authApiBaseUrl, isInplayMobileEnabled = false) {
|
|
@@ -9,9 +9,9 @@ export async function signIn(input, options, versionSession = 'default', version
|
|
|
9
9
|
: versionSession;
|
|
10
10
|
headers.set(SESSION_VERSION_HEADER_KEY, effectiveVersionSession);
|
|
11
11
|
headers.set(API_VERSION_HEADER_KEY, String(version));
|
|
12
|
-
if (version === 4 && platform === 'web') {
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
// if (version === 4 && platform === 'web') {
|
|
13
|
+
// headers.set(PLATFORM_WEB_HEADER_KEY, 'true');
|
|
14
|
+
// }
|
|
15
15
|
if (authApiBaseUrl) {
|
|
16
16
|
headers.set(AUTH_API_BASE_URL_HEADER_KEY, authApiBaseUrl);
|
|
17
17
|
}
|
|
@@ -11,7 +11,6 @@ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
|
|
|
11
11
|
import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
|
|
12
12
|
import { useSignOutMutation } from '../../client/hooks/useSignOutMutation.js';
|
|
13
13
|
import { getSession } from '../../client/services/getSession.js';
|
|
14
|
-
import { clearLocalStorageOnLogout } from '../../utils/clear-local-storage-on-logout.js';
|
|
15
14
|
import { FileCheck02Icon } from '../../icons/FileCheck02Icon.js';
|
|
16
15
|
import { XIcon } from '../../icons/XIcon.js';
|
|
17
16
|
import pagcorLogo from '../../images/pagcor.png';
|
|
@@ -20,6 +19,7 @@ import { unregisterFCMDevice } from '../../services/trigger.js';
|
|
|
20
19
|
import { Button } from '../../ui/Button/index.js';
|
|
21
20
|
import { Dialog } from '../../ui/Dialog/index.js';
|
|
22
21
|
import { Portal } from '../../ui/Portal/index.js';
|
|
22
|
+
import { clearLocalStorageOnLogout } from '../../utils/clear-local-storage-on-logout.js';
|
|
23
23
|
import { getQueryClient } from '../../utils/getQueryClient.js';
|
|
24
24
|
import { getSessionQueryKey } from '../../utils/queryKeys.js';
|
|
25
25
|
export function KYCReminder({ enablePendingKycReminder = false, ...props }) {
|
|
@@ -29,7 +29,8 @@ export interface SignInProps extends UseSignInProps {
|
|
|
29
29
|
/**
|
|
30
30
|
* Selects which auth session endpoint the sign-in flow targets.
|
|
31
31
|
* - `default` (default): `${AUTH_ENDPOINT}/sessions`
|
|
32
|
-
* - `Inplay`: `${AUTH_ENDPOINT}/v3/inplay/sessions`
|
|
32
|
+
* - `Inplay`: `${AUTH_ENDPOINT}/v3/inplay/sessions`, or `/v4/inplay/sessions`
|
|
33
|
+
* when `version` is `4`
|
|
33
34
|
*/
|
|
34
35
|
versionSession?: VersionSession;
|
|
35
36
|
/**
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
-
import { ACCESS_TOKEN_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
|
|
2
|
+
import { ACCESS_TOKEN_COOKIE_NAME, AUTH_CONFIG_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
|
|
3
3
|
import { destroySession } from '../services/auth.js';
|
|
4
4
|
export async function deleteSession(request) {
|
|
5
5
|
const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
|
|
6
|
+
const authConfig = JSON.parse(request.cookies.get(AUTH_CONFIG_COOKIE_NAME)?.value ?? '{}');
|
|
7
|
+
const authApiBaseUrl = authConfig.apiBaseUrl;
|
|
8
|
+
console.log('[DESTROY SESSION]');
|
|
9
|
+
console.log({ authApiBaseUrl });
|
|
6
10
|
if (accessToken) {
|
|
7
11
|
await destroySession({
|
|
8
12
|
headers: {
|
|
9
13
|
Authorization: `Bearer ${accessToken}`,
|
|
10
14
|
},
|
|
11
|
-
});
|
|
15
|
+
}, authApiBaseUrl);
|
|
12
16
|
}
|
|
13
17
|
const response = NextResponse.json({
|
|
14
18
|
ok: true,
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import { addMinutes } from 'date-fns';
|
|
1
|
+
import { addDays, addMinutes, subMinutes } from 'date-fns';
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
|
-
import { ACCESS_TOKEN_COOKIE_NAME, BTAG_COOKIE_NAME, DOMAIN_COOKIE_NAME, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
|
|
3
|
+
import { ACCESS_TOKEN_COOKIE_NAME, AUTH_CONFIG_COOKIE_NAME, BTAG_COOKIE_NAME, DOMAIN_COOKIE_NAME, FINGERPRINT_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, } from '../constants/index.js';
|
|
4
4
|
import { refreshSession } from '../services/auth.js';
|
|
5
5
|
export async function getSession(request) {
|
|
6
6
|
const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
|
|
7
|
+
const authConfig = JSON.parse(request.cookies.get(AUTH_CONFIG_COOKIE_NAME)?.value ?? '{}');
|
|
8
|
+
const authVersion = authConfig.version;
|
|
9
|
+
const authApiBaseUrl = authConfig.apiBaseUrl;
|
|
10
|
+
const fingerprint = request.headers.get(FINGERPRINT_HEADER_KEY);
|
|
11
|
+
console.log('[GET SESSION]');
|
|
12
|
+
console.log({
|
|
13
|
+
authVersion,
|
|
14
|
+
authApiBaseUrl,
|
|
15
|
+
fingerprint,
|
|
16
|
+
});
|
|
7
17
|
let isAccessTokenValid = true;
|
|
8
|
-
if (accessToken) {
|
|
18
|
+
if (accessToken && authVersion !== 4) {
|
|
9
19
|
try {
|
|
10
20
|
const payload = accessToken.split('.')[1];
|
|
11
21
|
const decoded = JSON.parse(Buffer.from(payload, 'base64').toString('utf8'));
|
|
@@ -17,6 +27,9 @@ export async function getSession(request) {
|
|
|
17
27
|
isAccessTokenValid = false;
|
|
18
28
|
}
|
|
19
29
|
}
|
|
30
|
+
if (authVersion === 4 && !accessToken) {
|
|
31
|
+
isAccessTokenValid = false;
|
|
32
|
+
}
|
|
20
33
|
const refreshToken = request.cookies.get(REFRESH_TOKEN_COOKIE_NAME)?.value;
|
|
21
34
|
const domain = request.cookies.get(DOMAIN_COOKIE_NAME)?.value;
|
|
22
35
|
const btag = request.cookies.get(BTAG_COOKIE_NAME)?.value;
|
|
@@ -31,6 +44,7 @@ export async function getSession(request) {
|
|
|
31
44
|
});
|
|
32
45
|
response.cookies.delete(ACCESS_TOKEN_COOKIE_NAME);
|
|
33
46
|
response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
|
|
47
|
+
response.cookies.delete(AUTH_CONFIG_COOKIE_NAME);
|
|
34
48
|
return response;
|
|
35
49
|
}
|
|
36
50
|
if (!accessToken || !isAccessTokenValid) {
|
|
@@ -45,8 +59,11 @@ export async function getSession(request) {
|
|
|
45
59
|
...(ipAddress && {
|
|
46
60
|
'X-Forwarded-For': ipAddress,
|
|
47
61
|
}),
|
|
62
|
+
...(fingerprint && {
|
|
63
|
+
[FINGERPRINT_HEADER_KEY]: fingerprint,
|
|
64
|
+
}),
|
|
48
65
|
},
|
|
49
|
-
});
|
|
66
|
+
}, authVersion, authApiBaseUrl);
|
|
50
67
|
const response = NextResponse.json({
|
|
51
68
|
ok: true,
|
|
52
69
|
data: {
|
|
@@ -60,6 +77,13 @@ export async function getSession(request) {
|
|
|
60
77
|
httpOnly: true,
|
|
61
78
|
sameSite: 'strict',
|
|
62
79
|
});
|
|
80
|
+
if (authVersion === 4) {
|
|
81
|
+
response.cookies.set(REFRESH_TOKEN_COOKIE_NAME, data.refreshToken, {
|
|
82
|
+
expires: subMinutes(addDays(new Date(), 15), 2),
|
|
83
|
+
httpOnly: true,
|
|
84
|
+
sameSite: 'strict',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
63
87
|
return response;
|
|
64
88
|
}
|
|
65
89
|
catch {
|
|
@@ -72,6 +96,7 @@ export async function getSession(request) {
|
|
|
72
96
|
},
|
|
73
97
|
});
|
|
74
98
|
response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
|
|
99
|
+
response.cookies.delete(AUTH_CONFIG_COOKIE_NAME);
|
|
75
100
|
return response;
|
|
76
101
|
}
|
|
77
102
|
}
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -18,14 +18,14 @@ export declare const GET: (req: NextRequest, { params }: Context) => Promise<Nex
|
|
|
18
18
|
__error?: unknown;
|
|
19
19
|
} | {
|
|
20
20
|
ok: true;
|
|
21
|
-
data:
|
|
21
|
+
data: import("../types").Session;
|
|
22
22
|
}> | NextResponse<{
|
|
23
23
|
ok: false;
|
|
24
24
|
message: string;
|
|
25
25
|
__error?: unknown;
|
|
26
26
|
} | {
|
|
27
27
|
ok: true;
|
|
28
|
-
data:
|
|
28
|
+
data: Record<string, unknown>;
|
|
29
29
|
}>>;
|
|
30
30
|
export declare const DELETE: (req: NextRequest, { params }: Context) => Promise<NextResponse<{
|
|
31
31
|
ok: true;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { addDays, addMinutes, subMinutes } from 'date-fns';
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { ACCESS_TOKEN_COOKIE_NAME, API_VERSION_HEADER_KEY, AUTH_API_BASE_URL_HEADER_KEY, DOMAIN_HEADER_KEY, FINGERPRINT_HEADER_KEY, GOOGLE_FRAUD_DEFENSE_HEADER_KEY, PLATFORM_WEB_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, SESSION_VERSION_HEADER_KEY, } from '../constants/index.js';
|
|
4
|
+
import { ACCESS_TOKEN_COOKIE_NAME, API_VERSION_HEADER_KEY, AUTH_API_BASE_URL_HEADER_KEY, AUTH_CONFIG_COOKIE_NAME, DOMAIN_HEADER_KEY, FINGERPRINT_HEADER_KEY, GOOGLE_FRAUD_DEFENSE_HEADER_KEY, PLATFORM_WEB_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, SESSION_VERSION_HEADER_KEY, } from '../constants/index.js';
|
|
5
5
|
import { createSession, } from '../services/auth.js';
|
|
6
6
|
const CreateSessionDefinition = z.union([
|
|
7
7
|
z.object({
|
|
@@ -47,6 +47,14 @@ export async function postSession(request) {
|
|
|
47
47
|
const authApiBaseUrl = request.headers.get(AUTH_API_BASE_URL_HEADER_KEY);
|
|
48
48
|
const version = request.headers.get(API_VERSION_HEADER_KEY) === '4' ? 4 : 1;
|
|
49
49
|
const isWeb = request.headers.get(PLATFORM_WEB_HEADER_KEY) === 'true';
|
|
50
|
+
console.log('[CREATE SESSION]');
|
|
51
|
+
console.log({
|
|
52
|
+
versionSession,
|
|
53
|
+
version,
|
|
54
|
+
authApiBaseUrl,
|
|
55
|
+
fingerprint,
|
|
56
|
+
isWeb,
|
|
57
|
+
});
|
|
50
58
|
try {
|
|
51
59
|
const googleFraudDefense = request.headers.get(GOOGLE_FRAUD_DEFENSE_HEADER_KEY);
|
|
52
60
|
const recaptchaToken = googleFraudDefense ?? recaptcha;
|
|
@@ -79,12 +87,21 @@ export async function postSession(request) {
|
|
|
79
87
|
}
|
|
80
88
|
const response = NextResponse.json({ ok: true, data: null }, { status: 201 });
|
|
81
89
|
response.cookies.set(ACCESS_TOKEN_COOKIE_NAME, res.accessToken, {
|
|
82
|
-
expires: addMinutes(new Date(), 9),
|
|
90
|
+
expires: addMinutes(new Date(), version === 4 ? 4 : 9),
|
|
83
91
|
httpOnly: true,
|
|
84
92
|
sameSite: 'strict',
|
|
85
93
|
});
|
|
94
|
+
const _15d = subMinutes(addDays(new Date(), version === 4 ? 15 : 1), 2);
|
|
86
95
|
response.cookies.set(REFRESH_TOKEN_COOKIE_NAME, res.refreshToken, {
|
|
87
|
-
expires:
|
|
96
|
+
expires: _15d,
|
|
97
|
+
httpOnly: true,
|
|
98
|
+
sameSite: 'strict',
|
|
99
|
+
});
|
|
100
|
+
response.cookies.set(AUTH_CONFIG_COOKIE_NAME, JSON.stringify({
|
|
101
|
+
version,
|
|
102
|
+
authApiBaseUrl,
|
|
103
|
+
}), {
|
|
104
|
+
expires: _15d,
|
|
88
105
|
httpOnly: true,
|
|
89
106
|
sameSite: 'strict',
|
|
90
107
|
});
|
|
@@ -8,24 +8,24 @@ export declare const createForgotPasswordSchema: (mobileNumberParser: MobileNumb
|
|
|
8
8
|
mobileNumber: z.ZodEffects<z.ZodString, string, string>;
|
|
9
9
|
verificationCode: z.ZodEffects<z.ZodString, string, string>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
verificationCode: string;
|
|
12
11
|
password: string;
|
|
13
12
|
mobileNumber: string;
|
|
13
|
+
verificationCode: string;
|
|
14
14
|
confirmPassword: string;
|
|
15
15
|
}, {
|
|
16
|
-
verificationCode: string;
|
|
17
16
|
password: string;
|
|
18
17
|
mobileNumber: string;
|
|
18
|
+
verificationCode: string;
|
|
19
19
|
confirmPassword: string;
|
|
20
20
|
}>, {
|
|
21
|
-
verificationCode: string;
|
|
22
21
|
password: string;
|
|
23
22
|
mobileNumber: string;
|
|
23
|
+
verificationCode: string;
|
|
24
24
|
confirmPassword: string;
|
|
25
25
|
}, {
|
|
26
|
-
verificationCode: string;
|
|
27
26
|
password: string;
|
|
28
27
|
mobileNumber: string;
|
|
28
|
+
verificationCode: string;
|
|
29
29
|
confirmPassword: string;
|
|
30
30
|
}>;
|
|
31
31
|
export type ForgotPasswordSchema = z.infer<ReturnType<typeof createForgotPasswordSchema>>;
|
package/dist/services/auth.d.ts
CHANGED
|
@@ -25,7 +25,8 @@ export type CreateSessionInput = CreateSessionInput__UsernameAndPassword | Creat
|
|
|
25
25
|
/**
|
|
26
26
|
* Controls which auth endpoint is used to create a session.
|
|
27
27
|
* - `default` -> `${AUTH_ENDPOINT}/sessions` (or `/v3`/`/v4/sessions`, see `ApiVersion`)
|
|
28
|
-
* - `Inplay` -> `${AUTH_ENDPOINT}/v3/inplay/sessions
|
|
28
|
+
* - `Inplay` -> `${AUTH_ENDPOINT}/v3/inplay/sessions`, or `/v4/inplay/sessions`
|
|
29
|
+
* when `version` is `4` (any other version falls back to `v3`)
|
|
29
30
|
*/
|
|
30
31
|
export type VersionSession = 'default' | 'Inplay';
|
|
31
32
|
/**
|
|
@@ -80,8 +81,8 @@ export type AuthenticateInput = AuthenticateInput__SecurityQuestion;
|
|
|
80
81
|
export declare function authenticate(input: AuthenticateInput, options?: HttpRequestOptions): Promise<AuthenticateMutation>;
|
|
81
82
|
export interface RefreshSessionMutation extends Omit<CreateSessionTwoFactorAuthDisabledMutation, 'authenticator'> {
|
|
82
83
|
}
|
|
83
|
-
export declare function refreshSession(options?: HttpRequestOptions): Promise<RefreshSessionMutation>;
|
|
84
|
-
export declare function destroySession(options?: HttpRequestOptions): Promise<void>;
|
|
84
|
+
export declare function refreshSession(options?: HttpRequestOptions, version?: ApiVersion, authApiBaseUrl?: string | null): Promise<RefreshSessionMutation>;
|
|
85
|
+
export declare function destroySession(options?: HttpRequestOptions, authApiBaseUrl?: string | null): Promise<void>;
|
|
85
86
|
export declare function getSessionHealth(options?: HttpRequestOptions): Promise<boolean>;
|
|
86
87
|
export interface SendVerificationCodeInput {
|
|
87
88
|
strict?: boolean;
|
package/dist/services/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ import { httpRequest } from './httpRequest.js';
|
|
|
3
3
|
import { sha256 } from './sha256.js';
|
|
4
4
|
function getSessionEndpoint(versionSession, version) {
|
|
5
5
|
if (versionSession === 'Inplay')
|
|
6
|
-
return
|
|
6
|
+
return `/v${version === 4 ? 4 : 3}/inplay/sessions`;
|
|
7
7
|
return version !== 1 ? `/v${version}/sessions` : '/sessions';
|
|
8
8
|
}
|
|
9
9
|
export async function createSession(input, options, versionSession = 'default', version = 1, authApiBaseUrl) {
|
|
@@ -50,7 +50,6 @@ export async function createSession(input, options, versionSession = 'default',
|
|
|
50
50
|
const queryParam = version === 4 && isWeb ? '?type=web' : '';
|
|
51
51
|
const path = getSessionEndpoint(effectiveVersionSession, version);
|
|
52
52
|
const baseUrl = authApiBaseUrl || AUTH_ENDPOINT;
|
|
53
|
-
console.log({ x: baseUrl });
|
|
54
53
|
try {
|
|
55
54
|
// v1 against the default endpoint returns the payload flat; every
|
|
56
55
|
// other combination (Inplay, or version 3/4) wraps it in `{ data: { ... } }`.
|
|
@@ -143,9 +142,12 @@ export async function authenticate(input, options) {
|
|
|
143
142
|
}
|
|
144
143
|
throw new Error("Invalid input 'type'");
|
|
145
144
|
}
|
|
146
|
-
export async function refreshSession(options) {
|
|
145
|
+
export async function refreshSession(options, version = 1, authApiBaseUrl) {
|
|
146
|
+
const url = authApiBaseUrl || AUTH_ENDPOINT;
|
|
147
147
|
try {
|
|
148
|
-
return await httpRequest.json(
|
|
148
|
+
return await httpRequest.json(version !== 1
|
|
149
|
+
? `${url}/v${version}/session/refresh`
|
|
150
|
+
: `${url}/session:refresh`, {
|
|
149
151
|
...options,
|
|
150
152
|
method: 'POST',
|
|
151
153
|
});
|
|
@@ -163,9 +165,10 @@ export async function refreshSession(options) {
|
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
|
-
export async function destroySession(options) {
|
|
168
|
+
export async function destroySession(options, authApiBaseUrl) {
|
|
169
|
+
const url = authApiBaseUrl || AUTH_ENDPOINT;
|
|
167
170
|
try {
|
|
168
|
-
await httpRequest(`${
|
|
171
|
+
await httpRequest(`${url}/session`, {
|
|
169
172
|
...options,
|
|
170
173
|
method: 'DELETE',
|
|
171
174
|
});
|