Skip to content

Commit

Permalink
fix(app): use node included crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Feb 19, 2024
1 parent 470e9aa commit c58cf74
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 94 deletions.
Binary file modified bun.lockb
Binary file not shown.
181 changes: 90 additions & 91 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,93 +1,92 @@
{
"name": "supso",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "bunx --bun vite dev",
"build": "bunx vite build",
"preview": "bunx vite preview",
"start": "npm run db:migrate && node build/index.js",
"test": "bun run test:integration && bun run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:integration": "playwright test",
"test:unit": "vitest",
"db:generate": "npx drizzle-kit generate:sqlite",
"db:push": "bunx --bun drizzle-kit push:sqlite",
"db:migrate": "bun ./scripts/migrate.ts"
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-node": "^2.0.2",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "8.56.0",
"@types/pg": "^8.10.9",
"@types/swagger-jsdoc": "^6.0.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"autoprefixer": "^10.4.16",
"dotenv": "^16.3.1",
"drizzle-kit": "^0.20.13",
"esbuild": "^0.19.12",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"postcss": "^8.4.32",
"postcss-load-config": "^5.0.2",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"prettier-plugin-tailwindcss": "^0.5.9",
"sass": "^1.70.0",
"svelte": "^4.2.8",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.3.6",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3",
"vitest": "^1.0.0"
},
"type": "module",
"dependencies": {
"@carbon/charts-svelte": "^1.13.18",
"@cartamd/plugin-code": "^3.0.1",
"@cartamd/plugin-emoji": "^3.1.0",
"@cartamd/plugin-slash": "^3.1.0",
"@internationalized/date": "^3.5.1",
"@libsql/client": "^0.3.6",
"@lucia-auth/adapter-drizzle": "^1.0.1",
"bits-ui": "^0.13.0",
"carta-md": "^3.5.0",
"clsx": "^2.1.0",
"cmdk-sv": "^0.0.12",
"crypto": "^1.0.1",
"date-fns": "^3.0.6",
"dedent": "^1.5.1",
"drizzle-orm": "^0.29.2",
"drizzle-zod": "^0.5.1",
"feed": "^4.2.2",
"formsnap": "^0.4.2",
"isomorphic-dompurify": "^2.3.0",
"lemonsqueezy.ts": "^0.1.7",
"lucia": "^3.0.1",
"lucide-svelte": "^0.303.0",
"mode-watcher": "^0.1.2",
"rambda": "^8.6.0",
"shiki": "^1.0.0",
"sse.js": "^2.2.0",
"superjson": "^2.2.1",
"svelte-dnd-list": "^0.1.8",
"svelte-highlight": "^7.4.7",
"svelte-sonner": "^0.3.11",
"sveltekit-superforms": "^1.13.1",
"swagger-jsdoc": "^6.2.8",
"tailwind-merge": "^2.2.0",
"tailwind-variants": "^0.1.19",
"tsx": "^4.7.0",
"ua-parser-js": "2.0.0-beta.1",
"unique-names-generator": "^4.7.1",
"zod": "^3.22.4"
}
"name": "supso",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "bunx --bun vite dev",
"build": "bunx vite build",
"preview": "bunx vite preview",
"start": "npm run db:migrate && node build/index.js",
"test": "bun run test:integration && bun run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:integration": "playwright test",
"test:unit": "vitest",
"db:generate": "npx drizzle-kit generate:sqlite",
"db:push": "bunx --bun drizzle-kit push:sqlite",
"db:migrate": "bun ./scripts/migrate.ts"
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-node": "^2.0.2",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "8.56.0",
"@types/pg": "^8.10.9",
"@types/swagger-jsdoc": "^6.0.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"autoprefixer": "^10.4.16",
"dotenv": "^16.3.1",
"drizzle-kit": "^0.20.13",
"esbuild": "^0.19.12",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"postcss": "^8.4.32",
"postcss-load-config": "^5.0.2",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"prettier-plugin-tailwindcss": "^0.5.9",
"sass": "^1.70.0",
"svelte": "^4.2.8",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.3.6",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3",
"vitest": "^1.0.0"
},
"type": "module",
"dependencies": {
"@carbon/charts-svelte": "^1.13.18",
"@cartamd/plugin-code": "^3.0.1",
"@cartamd/plugin-emoji": "^3.1.0",
"@cartamd/plugin-slash": "^3.1.0",
"@internationalized/date": "^3.5.1",
"@libsql/client": "^0.3.6",
"@lucia-auth/adapter-drizzle": "^1.0.1",
"bits-ui": "^0.13.0",
"carta-md": "^3.5.0",
"clsx": "^2.1.0",
"cmdk-sv": "^0.0.12",
"date-fns": "^3.0.6",
"dedent": "^1.5.1",
"drizzle-orm": "^0.29.2",
"drizzle-zod": "^0.5.1",
"feed": "^4.2.2",
"formsnap": "^0.4.2",
"isomorphic-dompurify": "^2.3.0",
"lemonsqueezy.ts": "^0.1.7",
"lucia": "^3.0.1",
"lucide-svelte": "^0.303.0",
"mode-watcher": "^0.1.2",
"rambda": "^8.6.0",
"shiki": "^1.0.0",
"sse.js": "^2.2.0",
"superjson": "^2.2.1",
"svelte-dnd-list": "^0.1.8",
"svelte-highlight": "^7.4.7",
"svelte-sonner": "^0.3.11",
"sveltekit-superforms": "^1.13.1",
"swagger-jsdoc": "^6.2.8",
"tailwind-merge": "^2.2.0",
"tailwind-variants": "^0.1.19",
"tsx": "^4.7.0",
"ua-parser-js": "2.0.0-beta.1",
"unique-names-generator": "^4.7.1",
"zod": "^3.22.4"
}
}
7 changes: 4 additions & 3 deletions src/routes/api/subscription/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import crypto from 'crypto';
import crypto from 'node:crypto';
import type { RequestHandler } from './$types';
import { type LemonsqueezySubscription } from 'lemonsqueezy.ts';
import { db } from '$lib/db';
Expand All @@ -19,10 +19,11 @@ type SubscriptionBody = {
};

export const POST: RequestHandler = async ({ request }) => {
const hmac = crypto.createHmac('sha256', envPrivate.SECRET_LS_WEBHOOK_KEY);
const bodyRaw = await request.text();
const hmac = crypto.createHmac('sha256', envPrivate.SECRET_LS_WEBHOOK_KEY ?? '');
const digest = Buffer.from(hmac.update(bodyRaw).digest('hex'), 'utf8');
const signature = Buffer.from(request.headers.get('X-Signature') || '', 'utf8');
const signature = Buffer.from(request.headers.get('x-signature') as string, 'utf8');

if (!crypto.timingSafeEqual(digest, signature)) {
return Response.json({ error: true }, { status: 400 });
}
Expand Down

0 comments on commit c58cf74

Please sign in to comment.