Refactor billing imports, reorganize package scripts and improve action structure

Deleted unnecessary schema files and reorganized their imports into more logical order. Modified the package script structure to align more accurately with standard conventions. Also refactored the team-billing.service file to improve action structure, making it easier to understand and edit. Furthermore, upgraded various dependencies, reflecting their new versions in the lockfile.
This commit is contained in:
giancarlo
2024-04-07 12:47:29 +08:00
parent 0a9c1f35c6
commit 0002ac6255
22 changed files with 244 additions and 82 deletions

View File

@@ -14,7 +14,8 @@
"./password-reset": "./src/password-reset.ts",
"./shared": "./src/shared.ts",
"./mfa": "./src/mfa.ts",
"./captcha": "./src/components/captcha/index.ts"
"./captcha/client": "./src/captcha/client/index.ts",
"./captcha/server": "./src/captcha/server/index.ts"
},
"devDependencies": {
"@hookform/resolvers": "^3.3.4",

View File

@@ -0,0 +1 @@
export * from './verify-captcha';

View File

@@ -0,0 +1,30 @@
import 'server-only';
const verifyEndpoint =
'https://challenges.cloudflare.com/turnstile/v0/siteverify';
const secret = process.env.CAPTCHA_SECRET_TOKEN;
/**
* Verify the CAPTCHA token with the CAPTCHA service
* @param token
*/
export async function verifyCaptchaToken(token: string) {
if (!secret) {
throw new Error('CAPTCHA_SECRET_TOKEN is not set');
}
const res = await fetch(verifyEndpoint, {
method: 'POST',
body: `secret=${encodeURIComponent(secret)}&response=${encodeURIComponent(token)}`,
headers: {
'content-type': 'application/x-www-form-urlencoded',
},
});
const data = await res.json();
if (!data.success) {
throw new Error('Invalid CAPTCHA token');
}
}

View File

@@ -8,7 +8,7 @@ import { If } from '@kit/ui/if';
import { Separator } from '@kit/ui/separator';
import { Trans } from '@kit/ui/trans';
import { useCaptchaToken } from './captcha';
import { useCaptchaToken } from '../captcha/client';
import { MagicLinkAuthContainer } from './magic-link-auth-container';
import { OauthProviders } from './oauth-providers';
import { EmailPasswordSignUpContainer } from './password-sign-up-container';