Skip to content

Commit

Permalink
fix: lint & code fix & delete crypto from runtime edge
Browse files Browse the repository at this point in the history
  • Loading branch information
qamarq committed Dec 7, 2024
1 parent 1950db3 commit d696106
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
env:
USOS_CONSUMER_KEY: hello
USOS_CONSUMER_SECRET: jello
NEXT_PUBLIC_API_URL: http://localhost:3333
if: always()

- name: Find deadcode
Expand Down
2 changes: 1 addition & 1 deletion frontend/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const config = {
"lint-staged.config.mjs",
],
// sharp is used in nextjs image optimization
ignoreDependencies: ["sharp", "@radix-ui/*", "eslint-config-next"],
ignoreDependencies: ["sharp", "@radix-ui/*"],
} satisfies KnipConfig;

export default config;
15 changes: 15 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
"crypto-js": "^4.2.0",
"date-fns": "^4.1.0",
"fetch-cookie": "^3.0.1",
"framer-motion": "^11.3.28",
Expand All @@ -56,6 +57,7 @@
"@alergeek-ventures/eslint-config": "^9.0.17",
"@next/eslint-plugin-next": "^14.2.7",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/crypto-js": "^4.2.2",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
Empty file removed frontend/src/lib/auth/example.ts
Empty file.
9 changes: 7 additions & 2 deletions frontend/src/lib/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import crypto from "crypto";
import CryptoJS, { HmacSHA1 } from "crypto-js";
import { cookies as cookiesPromise } from "next/headers";
import OAuth from "oauth-1.0a";

import { env } from "@/env.mjs";

function createHmacSha1Base64(base_string: string, key: string) {
const hmac: CryptoJS.lib.WordArray = HmacSHA1(base_string, key);
return CryptoJS.enc.Base64.stringify(hmac);
}

export const oauth = new OAuth({
consumer: { key: env.USOS_CONSUMER_KEY, secret: env.USOS_CONSUMER_SECRET },
signature_method: "HMAC-SHA1",
hash_function(base_string, key) {
return crypto.createHmac("sha1", key).update(base_string).digest("base64");
return createHmacSha1Base64(base_string, key);
},
});

Expand Down

0 comments on commit d696106

Please sign in to comment.