@opexa/portal-components 0.0.927 → 0.0.928
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/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.js +11 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.js +11 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.js +126 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.js +10 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.js +12 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.d.ts +17 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.js +2 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.d.ts +1 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.js +41 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.d.ts +13 -0
- package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.js +91 -0
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/OnlineBankDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit__legacy/OnlineBankDeposit/useOnlineBankDeposit.d.ts +1 -1
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
- package/dist/components/DepositWithdrawal/Deposit__legacy/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
- package/dist/components/DigitainLauncher/Loading.js +1 -1
- package/dist/components/Disclaimer/DisclaimerV2.js +1 -1
- package/dist/components/Disclaimer/ResponsibleGaming.d.ts +10 -0
- package/dist/components/Disclaimer/ResponsibleGaming.js +13 -0
- package/dist/components/Disclaimer/TermsOfUse.d.ts +11 -0
- package/dist/components/Disclaimer/TermsOfUse.js +13 -0
- package/dist/components/FeatureFlag/FeatureFlag.d.ts +1 -0
- package/dist/components/FeatureFlag/FeatureFlag.js +29 -0
- package/dist/components/FeatureFlag/index.d.ts +1 -0
- package/dist/components/FeatureFlag/index.js +1 -0
- package/dist/components/ForgotPassword/Crazywin/ForgotPassword.module.css +42 -42
- package/dist/components/Jackpots/Jackpots.module.css +288 -288
- package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -184
- package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -184
- package/dist/components/KYC/AutoOpen.d.ts +1 -0
- package/dist/components/KYC/AutoOpen.js +40 -0
- package/dist/components/KYC/BasicInformation.js +1 -1
- package/dist/components/KYC/CaptureIdDocument.d.ts +1 -0
- package/dist/components/KYC/CaptureIdDocument.js +219 -0
- package/dist/components/KYC/CaptureSelfie.d.ts +1 -0
- package/dist/components/KYC/CaptureSelfie.js +285 -0
- package/dist/components/KYC/DisplayImage.d.ts +5 -0
- package/dist/components/KYC/DisplayImage.js +8 -0
- package/dist/components/KYC/FileUpload.d.ts +10 -0
- package/dist/components/KYC/FileUpload.js +72 -0
- package/dist/components/KYC/IdentityVerification.js +1 -1
- package/dist/components/KYC/KYC.lazy.js +1 -1
- package/dist/components/KYC/KYCDefault/KYCVerificationStatus.lazy.js +2 -2
- package/dist/components/KYC/KYCNonPagCor/KYCVerificationStatus.lazy.js +2 -2
- package/dist/components/KYC/KYCVerificationStatus.lazy.js +8 -5
- package/dist/components/KYC/NoCameraError.d.ts +7 -0
- package/dist/components/KYC/NoCameraError.js +6 -0
- package/dist/components/KYC/PersonOverlayDesktop.d.ts +7 -0
- package/dist/components/KYC/PersonOverlayDesktop.js +9 -0
- package/dist/components/KYC/PersonalInformation.js +1 -1
- package/dist/components/KYC/backup/Header.d.ts +1 -0
- package/dist/components/KYC/backup/Header.js +8 -0
- package/dist/components/KYC/backup/Indicator.d.ts +1 -0
- package/dist/components/KYC/backup/Indicator.js +9 -0
- package/dist/components/KYC/backup/KYC.d.ts +1 -0
- package/dist/components/KYC/backup/KYC.js +14 -0
- package/dist/components/KYC/backup/KYC.lazy.d.ts +1 -0
- package/dist/components/KYC/backup/KYC.lazy.js +26 -0
- package/dist/components/KYC/backup/KYCContext.d.ts +6 -0
- package/dist/components/KYC/backup/KYCContext.js +2 -0
- package/dist/components/KYC/backup/Step1.d.ts +1 -0
- package/dist/components/KYC/backup/Step1.js +13 -0
- package/dist/components/KYC/backup/Step2.d.ts +1 -0
- package/dist/components/KYC/backup/Step2.js +13 -0
- package/dist/components/KYC/backup/Step3.d.ts +1 -0
- package/dist/components/KYC/backup/Step3.js +13 -0
- package/dist/components/KYC/backup/Step4.d.ts +1 -0
- package/dist/components/KYC/backup/Step4.js +7 -0
- package/dist/components/KYC/backup/useKYC.d.ts +10 -0
- package/dist/components/KYC/backup/useKYC.js +8 -0
- package/dist/components/KYC/loadModels.d.ts +1 -0
- package/dist/components/KYC/loadModels.js +9 -0
- package/dist/components/KYC/utils.d.ts +9 -0
- package/dist/components/KYC/utils.js +79 -0
- package/dist/components/Messages/Message.d.ts +1 -0
- package/dist/components/Messages/Message.js +35 -0
- package/dist/components/Messages/MessageContext.d.ts +6 -0
- package/dist/components/Messages/MessageContext.js +2 -0
- package/dist/components/Messages/MessagePopup.d.ts +1 -0
- package/dist/components/Messages/MessagePopup.js +20 -0
- package/dist/components/Messages/MessageTrigger.d.ts +8 -0
- package/dist/components/Messages/MessageTrigger.js +19 -0
- package/dist/components/PortalProvider/CXDTokenObserver.js +11 -11
- package/dist/components/Quests/CountdownTimer.d.ts +15 -0
- package/dist/components/Quests/CountdownTimer.js +33 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +4 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +78 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +8 -0
- package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +9 -0
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +4 -0
- package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +4 -0
- package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +4 -0
- package/dist/components/Quests/WageringQuest/WageringQuest.js +20 -0
- package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +9 -0
- package/dist/components/Quests/WageringQuest/WageringQuestModal.js +9 -0
- package/dist/components/SignUp/SignUp.lazy.d.ts +12 -0
- package/dist/components/SignUp/SignUp.lazy.js +18 -0
- package/dist/components/SignUp/SignUpContext.d.ts +6 -0
- package/dist/components/SignUp/SignUpContext.js +2 -0
- package/dist/components/SignUp/SignUpDefault/SignUp.lazy.d.ts +17 -0
- package/dist/components/SignUp/SignUpDefault/SignUp.lazy.js +18 -0
- package/dist/components/SignUp/SignUpDefault/SignUpContext.d.ts +6 -0
- package/dist/components/SignUp/SignUpDefault/SignUpContext.js +2 -0
- package/dist/components/SignUp/SignUpDefault/SignUpForm.d.ts +1 -0
- package/dist/components/SignUp/SignUpDefault/SignUpForm.js +310 -0
- package/dist/components/SignUp/SignUpForm.d.ts +1 -0
- package/dist/components/SignUp/SignUpForm.js +284 -0
- package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.d.ts +1 -0
- package/dist/components/SignUp/SignUpKYC/CaptureIdDocument.js +198 -0
- package/dist/components/SignUp/SignUpKYC/CaptureSelfie.d.ts +1 -0
- package/dist/components/SignUp/SignUpKYC/CaptureSelfie.js +251 -0
- package/dist/components/SignUp/SignUpKYC/ImageUploader.d.ts +10 -0
- package/dist/components/SignUp/SignUpKYC/ImageUploader.js +42 -0
- package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.d.ts +7 -0
- package/dist/components/SignUp/SignUpKYC/PersonOverlayDesktop.js +9 -0
- package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.d.ts +1 -0
- package/dist/components/SignUp/SignUpKYC/SignUpFormKYC.js +464 -0
- package/dist/components/SignUp/SignUpKYC/useImageUploader.d.ts +11 -0
- package/dist/components/SignUp/SignUpKYC/useImageUploader.js +20 -0
- package/dist/components/SignUp/SignUpKYC/utils.d.ts +9 -0
- package/dist/components/SignUp/SignUpKYC/utils.js +79 -0
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.d.ts +1 -0
- package/dist/components/SignUp/SignUpPagcor/CaptureIdDocument.js +198 -0
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.d.ts +1 -0
- package/dist/components/SignUp/SignUpPagcor/CaptureSelfie.js +251 -0
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.d.ts +10 -0
- package/dist/components/SignUp/SignUpPagcor/ImageUploader.js +41 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.d.ts +1 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpFormPagcor.js +429 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.d.ts +13 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcor.lazy.js +26 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.d.ts +7 -0
- package/dist/components/SignUp/SignUpPagcor/SignUpPagcorContext.js +2 -0
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.d.ts +11 -0
- package/dist/components/SignUp/SignUpPagcor/useImageUploader.js +20 -0
- package/dist/components/Tournaments/TournamentsCarousel/TournamentsCarouselItem.module.css +184 -184
- package/dist/components/Tournaments/TournamentsList/TournamentItem.module.css +184 -184
- package/dist/components/shared/IdDocumentField.client.d.ts +25 -0
- package/dist/components/shared/IdDocumentField.client.js +204 -0
- package/dist/components/shared/IdDocumentField.d.ts +2 -0
- package/dist/components/shared/IdDocumentField.js +11 -0
- package/dist/components/shared/SelfieField.client.d.ts +20 -0
- package/dist/components/shared/SelfieField.client.js +327 -0
- package/dist/components/shared/SelfieField.d.ts +2 -0
- package/dist/components/shared/SelfieField.js +11 -0
- package/dist/constants/BranchCode.d.ts +4 -0
- package/dist/constants/BranchCode.js +42 -0
- package/dist/handlers/postTransformIdFrontImage.d.ts +3 -0
- package/dist/handlers/postTransformIdFrontImage.js +67 -0
- package/dist/handlers/postTransformSelfieImage.d.ts +3 -0
- package/dist/handlers/postTransformSelfieImage.js +71 -0
- package/dist/handlers.d.ts +43 -0
- package/dist/handlers.js +297 -0
- package/dist/icons/BellRingIcon.d.ts +2 -0
- package/dist/icons/BellRingIcon.js +4 -0
- package/dist/images/phone-icon.svg +10 -10
- package/dist/services/queries.js +3369 -3369
- package/dist/styles/theme.css +776 -776
- package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
- package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
- package/dist/ui/Checkbox/checkbox.recipe.js +1 -1
- package/dist/utils/dataUrlToBlob.d.ts +1 -0
- package/dist/utils/dataUrlToBlob.js +11 -0
- package/dist/utils/gamesAvailable3pmTo3am.d.ts +1 -0
- package/dist/utils/gamesAvailable3pmTo3am.js +1 -0
- package/dist/utils/getGameName.d.ts +1 -0
- package/dist/utils/getGameName.js +6 -0
- package/dist/utils/isBetween3amAnd3pm.d.ts +1 -0
- package/dist/utils/isBetween3amAnd3pm.js +5 -0
- package/dist/utils/resizeImageSize.d.ts +2 -0
- package/dist/utils/resizeImageSize.js +11 -0
- package/package.json +179 -179
- package/dist/components/Banner/Banner.client.d.ts +0 -12
- package/dist/components/Banner/Banner.client.js +0 -49
- package/dist/components/PortalProvider/AndroidOnlyComponents.d.ts +0 -1
- package/dist/components/PortalProvider/AndroidOnlyComponents.js +0 -12
package/dist/handlers.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { addDays, addMinutes, subMinutes } from 'date-fns';
|
|
2
|
+
import { NextResponse } from 'next/server';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { ACCESS_TOKEN_COOKIE_NAME, DOMAIN_COOKIE_NAME, DOMAIN_HEADER_KEY, RECAPTCHA_HEADER_KEY, REFRESH_TOKEN_COOKIE_NAME, } from './constants/index.js';
|
|
5
|
+
import { authenticate, createSession, destroySession, refreshSession, } from './services/auth.js';
|
|
6
|
+
const CreateSessionDefinition = z.union([
|
|
7
|
+
z.object({
|
|
8
|
+
type: z.literal('NAME_AND_PASSWORD'),
|
|
9
|
+
name: z.string(),
|
|
10
|
+
password: z.string(),
|
|
11
|
+
}),
|
|
12
|
+
z.object({
|
|
13
|
+
type: z.literal('MOBILE_NUMBER'),
|
|
14
|
+
mobileNumber: z.string(),
|
|
15
|
+
verificationCode: z.string(),
|
|
16
|
+
}),
|
|
17
|
+
z.object({
|
|
18
|
+
type: z.literal('MAYA'),
|
|
19
|
+
session: z.string(),
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
type: z.union([
|
|
23
|
+
z.literal('SOCIALS'),
|
|
24
|
+
z.literal('CABINET'),
|
|
25
|
+
z.literal('SINGLE_USE_TOKEN'),
|
|
26
|
+
]),
|
|
27
|
+
token: z.string(),
|
|
28
|
+
}),
|
|
29
|
+
]);
|
|
30
|
+
const AuthenticateDefinition = z.object({
|
|
31
|
+
type: z.literal('SECURITY_QUESTION'),
|
|
32
|
+
token: z.string(),
|
|
33
|
+
secretAnswer: z.string(),
|
|
34
|
+
});
|
|
35
|
+
export const GET = async (request, { params }) => {
|
|
36
|
+
const { auth } = await params;
|
|
37
|
+
const path = auth[0];
|
|
38
|
+
/*
|
|
39
|
+
*
|
|
40
|
+
* GET -> /api/health
|
|
41
|
+
* GET -> /api/healthcheck
|
|
42
|
+
* GET -> /api/health-check
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
if (/^health(-?check)?$/i.test(path)) {
|
|
46
|
+
return NextResponse.json({
|
|
47
|
+
ok: true,
|
|
48
|
+
}, {
|
|
49
|
+
headers: {
|
|
50
|
+
'Access-Control-Allow-Origin': '*',
|
|
51
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
52
|
+
Pragma: 'no-cache',
|
|
53
|
+
Expires: '0',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/*
|
|
58
|
+
*
|
|
59
|
+
* GET -> /api/sessions
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
if (path === 'sessions') {
|
|
63
|
+
const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
|
|
64
|
+
const refreshToken = request.cookies.get(REFRESH_TOKEN_COOKIE_NAME)?.value;
|
|
65
|
+
const domain = request.cookies.get(DOMAIN_COOKIE_NAME)?.value;
|
|
66
|
+
if (!refreshToken) {
|
|
67
|
+
const response = NextResponse.json({
|
|
68
|
+
ok: true,
|
|
69
|
+
data: {
|
|
70
|
+
domain,
|
|
71
|
+
status: 'unauthenticated',
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
response.cookies.delete(ACCESS_TOKEN_COOKIE_NAME);
|
|
75
|
+
response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
|
|
76
|
+
return response;
|
|
77
|
+
}
|
|
78
|
+
if (!accessToken) {
|
|
79
|
+
try {
|
|
80
|
+
const data = await refreshSession({
|
|
81
|
+
headers: {
|
|
82
|
+
Authorization: `Bearer ${refreshToken}`,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
const response = NextResponse.json({
|
|
86
|
+
ok: true,
|
|
87
|
+
data: {
|
|
88
|
+
status: 'authenticated',
|
|
89
|
+
domain,
|
|
90
|
+
token: data.accessToken,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
response.cookies.set(ACCESS_TOKEN_COOKIE_NAME, data.accessToken, {
|
|
94
|
+
expires: addMinutes(new Date(), 9),
|
|
95
|
+
httpOnly: true,
|
|
96
|
+
sameSite: 'strict',
|
|
97
|
+
});
|
|
98
|
+
return response;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
const response = NextResponse.json({
|
|
102
|
+
ok: true,
|
|
103
|
+
data: {
|
|
104
|
+
status: 'unauthenticated',
|
|
105
|
+
domain,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return NextResponse.json({
|
|
113
|
+
ok: true,
|
|
114
|
+
data: {
|
|
115
|
+
status: 'authenticated',
|
|
116
|
+
domain,
|
|
117
|
+
token: accessToken,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return NextResponse.json({
|
|
122
|
+
ok: false,
|
|
123
|
+
message: 'Not found',
|
|
124
|
+
}, { status: 404 });
|
|
125
|
+
};
|
|
126
|
+
export const DELETE = async (request, { params }) => {
|
|
127
|
+
const { auth } = await params;
|
|
128
|
+
const path = auth[0];
|
|
129
|
+
/*
|
|
130
|
+
*
|
|
131
|
+
* DELETE -> /api/sessions
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
if (path === 'sessions') {
|
|
135
|
+
const accessToken = request.cookies.get(ACCESS_TOKEN_COOKIE_NAME)?.value;
|
|
136
|
+
if (accessToken) {
|
|
137
|
+
await destroySession({
|
|
138
|
+
headers: {
|
|
139
|
+
Authorization: `Bearer ${accessToken}`,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const response = NextResponse.json({
|
|
144
|
+
ok: true,
|
|
145
|
+
});
|
|
146
|
+
response.cookies.delete(ACCESS_TOKEN_COOKIE_NAME);
|
|
147
|
+
response.cookies.delete(REFRESH_TOKEN_COOKIE_NAME);
|
|
148
|
+
return response;
|
|
149
|
+
}
|
|
150
|
+
return NextResponse.json({
|
|
151
|
+
ok: false,
|
|
152
|
+
message: 'Not found',
|
|
153
|
+
}, { status: 404 });
|
|
154
|
+
};
|
|
155
|
+
export const POST = async (request, { params }) => {
|
|
156
|
+
const { auth } = await params;
|
|
157
|
+
const path = auth[0];
|
|
158
|
+
/*
|
|
159
|
+
*
|
|
160
|
+
* POST -> /api/sessions
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
if (path === 'sessions') {
|
|
164
|
+
const body = await request.json();
|
|
165
|
+
const parsed = CreateSessionDefinition.safeParse(body);
|
|
166
|
+
if (!parsed.success) {
|
|
167
|
+
return NextResponse.json({
|
|
168
|
+
ok: false,
|
|
169
|
+
message: parsed.error.issues[0].message,
|
|
170
|
+
}, { status: 400 });
|
|
171
|
+
}
|
|
172
|
+
const recaptcha = request.headers.get(RECAPTCHA_HEADER_KEY);
|
|
173
|
+
const domain = request.headers.get(DOMAIN_HEADER_KEY);
|
|
174
|
+
try {
|
|
175
|
+
const res = await createSession(parsed.data, {
|
|
176
|
+
headers: {
|
|
177
|
+
...(recaptcha && {
|
|
178
|
+
[RECAPTCHA_HEADER_KEY]: recaptcha,
|
|
179
|
+
}),
|
|
180
|
+
...(domain && {
|
|
181
|
+
[DOMAIN_HEADER_KEY]: domain,
|
|
182
|
+
}),
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
if (res.authenticator) {
|
|
186
|
+
return NextResponse.json({
|
|
187
|
+
ok: true,
|
|
188
|
+
data: res.authenticator,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
const response = NextResponse.json({ ok: true, data: null }, { status: 201 });
|
|
192
|
+
response.cookies.set(ACCESS_TOKEN_COOKIE_NAME, res.accessToken, {
|
|
193
|
+
expires: addMinutes(new Date(), 9),
|
|
194
|
+
httpOnly: true,
|
|
195
|
+
sameSite: 'strict',
|
|
196
|
+
});
|
|
197
|
+
response.cookies.set(REFRESH_TOKEN_COOKIE_NAME, res.refreshToken, {
|
|
198
|
+
expires: subMinutes(addDays(new Date(), 30), 1),
|
|
199
|
+
httpOnly: true,
|
|
200
|
+
sameSite: 'strict',
|
|
201
|
+
});
|
|
202
|
+
return response;
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
return NextResponse.json({
|
|
206
|
+
ok: false,
|
|
207
|
+
message: 'Unauthorized',
|
|
208
|
+
__error: e,
|
|
209
|
+
}, { status: 401 });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/*
|
|
213
|
+
*
|
|
214
|
+
* POST -> /api/authenticate
|
|
215
|
+
*
|
|
216
|
+
*/
|
|
217
|
+
if (path === 'authenticate') {
|
|
218
|
+
const body = await request.json();
|
|
219
|
+
const parsed = AuthenticateDefinition.safeParse(body);
|
|
220
|
+
if (!parsed.success) {
|
|
221
|
+
return NextResponse.json({
|
|
222
|
+
ok: false,
|
|
223
|
+
message: parsed.error.issues[0].message,
|
|
224
|
+
}, { status: 400 });
|
|
225
|
+
}
|
|
226
|
+
const recaptcha = request.headers.get(RECAPTCHA_HEADER_KEY);
|
|
227
|
+
const domain = request.headers.get(DOMAIN_HEADER_KEY);
|
|
228
|
+
try {
|
|
229
|
+
const res = await authenticate(parsed.data, {
|
|
230
|
+
headers: {
|
|
231
|
+
...(recaptcha && {
|
|
232
|
+
[RECAPTCHA_HEADER_KEY]: recaptcha,
|
|
233
|
+
}),
|
|
234
|
+
...(domain && {
|
|
235
|
+
[DOMAIN_HEADER_KEY]: domain,
|
|
236
|
+
}),
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
const response = NextResponse.json({ ok: true }, { status: 201 });
|
|
240
|
+
response.cookies.set(ACCESS_TOKEN_COOKIE_NAME, res.accessToken, {
|
|
241
|
+
expires: addMinutes(new Date(), 9),
|
|
242
|
+
httpOnly: true,
|
|
243
|
+
});
|
|
244
|
+
response.cookies.set(REFRESH_TOKEN_COOKIE_NAME, res.refreshToken, {
|
|
245
|
+
expires: subMinutes(addDays(new Date(), 30), 1),
|
|
246
|
+
httpOnly: true,
|
|
247
|
+
});
|
|
248
|
+
return response;
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
return NextResponse.json({
|
|
252
|
+
ok: false,
|
|
253
|
+
message: 'Unauthorized',
|
|
254
|
+
__error: e,
|
|
255
|
+
}, { status: 401 });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return NextResponse.json({
|
|
259
|
+
ok: false,
|
|
260
|
+
message: 'Not found',
|
|
261
|
+
}, { status: 404 });
|
|
262
|
+
};
|
|
263
|
+
const UpdateSessionDefinition = z.object({
|
|
264
|
+
domain: z.string().optional().nullable(),
|
|
265
|
+
});
|
|
266
|
+
export const PATCH = async (request, { params }) => {
|
|
267
|
+
const { auth } = await params;
|
|
268
|
+
const path = auth[0];
|
|
269
|
+
/*
|
|
270
|
+
*
|
|
271
|
+
* PATCH -> /api/sessions
|
|
272
|
+
*
|
|
273
|
+
*/
|
|
274
|
+
if (path === 'sessions') {
|
|
275
|
+
const body = await request.json();
|
|
276
|
+
const parsed = UpdateSessionDefinition.safeParse(body);
|
|
277
|
+
if (!parsed.success) {
|
|
278
|
+
return NextResponse.json({
|
|
279
|
+
ok: false,
|
|
280
|
+
message: parsed.error.issues[0].message,
|
|
281
|
+
}, { status: 400 });
|
|
282
|
+
}
|
|
283
|
+
const response = NextResponse.json({ ok: true });
|
|
284
|
+
if (parsed.data.domain) {
|
|
285
|
+
response.cookies.set(DOMAIN_COOKIE_NAME, parsed.data.domain, {
|
|
286
|
+
expires: addDays(new Date(), 30),
|
|
287
|
+
httpOnly: true,
|
|
288
|
+
sameSite: 'strict',
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return response;
|
|
292
|
+
}
|
|
293
|
+
return NextResponse.json({
|
|
294
|
+
ok: false,
|
|
295
|
+
message: 'Not found',
|
|
296
|
+
}, { status: 404 });
|
|
297
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function BellRingIcon(props) {
|
|
3
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 25 24", fill: "none", stroke: "currentColor", ...props, children: _jsx("path", { d: "M15.5002 19C15.5002 20.6569 14.1571 22 12.5002 22C10.8434 22 9.50025 20.6569 9.50025 19M14.2968 6.23856C14.7322 5.78864 15.0002 5.17562 15.0002 4.5C15.0002 3.11929 13.881 2 12.5002 2C11.1195 2 10.0002 3.11929 10.0002 4.5C10.0002 5.17562 10.2683 5.78864 10.7037 6.23856M3.04707 8.32296C3.03272 6.87161 3.8152 5.51631 5.07928 4.80306M21.9534 8.32296C21.9678 6.87161 21.1853 5.51631 19.9212 4.80306M18.5002 11.2C18.5002 9.82087 17.8681 8.49823 16.7429 7.52304C15.6177 6.54786 14.0915 6 12.5002 6C10.9089 6 9.38283 6.54786 8.25761 7.52304C7.13239 8.49823 6.50025 9.82087 6.50025 11.2C6.50025 13.4818 5.93438 15.1506 5.22831 16.3447C4.42359 17.7056 4.02122 18.3861 4.03711 18.5486C4.05529 18.7346 4.08876 18.7933 4.23959 18.9036C4.37142 19 5.03376 19 6.35844 19H18.6421C19.9667 19 20.6291 19 20.7609 18.9036C20.9117 18.7933 20.9452 18.7346 20.9634 18.5486C20.9793 18.3861 20.5769 17.7056 19.7722 16.3447C19.0661 15.1506 18.5002 13.4818 18.5002 11.2Z", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
4
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<svg width="40" height="41" viewBox="0 0 40 41" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M19.9997 29.6667H20.0163M13.6663 37.1667H26.333C28.1998 37.1667 29.1333 37.1667 29.8463 36.8034C30.4735 36.4838 30.9835 35.9739 31.303 35.3467C31.6663 34.6336 31.6663 33.7002 31.6663 31.8334V9.16671C31.6663 7.29987 31.6663 6.36644 31.303 5.65341C30.9835 5.0262 30.4735 4.51626 29.8463 4.19669C29.1333 3.83337 28.1998 3.83337 26.333 3.83337H13.6663C11.7995 3.83337 10.8661 3.83337 10.153 4.19669C9.52583 4.51626 9.0159 5.0262 8.69632 5.65341C8.33301 6.36644 8.33301 7.29987 8.33301 9.16671V31.8334C8.33301 33.7002 8.33301 34.6336 8.69632 35.3467C9.0159 35.9739 9.52583 36.4838 10.153 36.8034C10.8661 37.1667 11.7995 37.1667 13.6663 37.1667ZM20.833 29.6667C20.833 30.1269 20.4599 30.5 19.9997 30.5C19.5394 30.5 19.1663 30.1269 19.1663 29.6667C19.1663 29.2065 19.5394 28.8334 19.9997 28.8334C20.4599 28.8334 20.833 29.2065 20.833 29.6667Z" stroke="url(#paint0_linear_7447_22974)" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
-
<defs>
|
|
4
|
-
<linearGradient id="paint0_linear_7447_22974" x1="6.15787" y1="37.1667" x2="42.6082" y2="16.0851" gradientUnits="userSpaceOnUse">
|
|
5
|
-
<stop stop-color="#C7802D"/>
|
|
6
|
-
<stop offset="0.438525" stop-color="#FFE585"/>
|
|
7
|
-
<stop offset="1" stop-color="#C7802D"/>
|
|
8
|
-
</linearGradient>
|
|
9
|
-
</defs>
|
|
10
|
-
</svg>
|
|
1
|
+
<svg width="40" height="41" viewBox="0 0 40 41" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M19.9997 29.6667H20.0163M13.6663 37.1667H26.333C28.1998 37.1667 29.1333 37.1667 29.8463 36.8034C30.4735 36.4838 30.9835 35.9739 31.303 35.3467C31.6663 34.6336 31.6663 33.7002 31.6663 31.8334V9.16671C31.6663 7.29987 31.6663 6.36644 31.303 5.65341C30.9835 5.0262 30.4735 4.51626 29.8463 4.19669C29.1333 3.83337 28.1998 3.83337 26.333 3.83337H13.6663C11.7995 3.83337 10.8661 3.83337 10.153 4.19669C9.52583 4.51626 9.0159 5.0262 8.69632 5.65341C8.33301 6.36644 8.33301 7.29987 8.33301 9.16671V31.8334C8.33301 33.7002 8.33301 34.6336 8.69632 35.3467C9.0159 35.9739 9.52583 36.4838 10.153 36.8034C10.8661 37.1667 11.7995 37.1667 13.6663 37.1667ZM20.833 29.6667C20.833 30.1269 20.4599 30.5 19.9997 30.5C19.5394 30.5 19.1663 30.1269 19.1663 29.6667C19.1663 29.2065 19.5394 28.8334 19.9997 28.8334C20.4599 28.8334 20.833 29.2065 20.833 29.6667Z" stroke="url(#paint0_linear_7447_22974)" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
<defs>
|
|
4
|
+
<linearGradient id="paint0_linear_7447_22974" x1="6.15787" y1="37.1667" x2="42.6082" y2="16.0851" gradientUnits="userSpaceOnUse">
|
|
5
|
+
<stop stop-color="#C7802D"/>
|
|
6
|
+
<stop offset="0.438525" stop-color="#FFE585"/>
|
|
7
|
+
<stop offset="1" stop-color="#C7802D"/>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
</defs>
|
|
10
|
+
</svg>
|