-
Notifications
You must be signed in to change notification settings - Fork 5
Feat/signature verification library #464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
198b7b5
chore: key sync on login
coodos d103751
chore: loosen CORS for evault-core
coodos 157a685
fix: default key ID
coodos dc95e1c
chore: EID_WALLET_TOKEN .env variable
coodos b1ebf31
chore: apply changes for .env
coodos 56aceac
feat: signature validator library
coodos e692130
chore: fix lockfile
coodos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| /** | ||
| * Script to generate a test JWT token for evault-core authentication | ||
| * | ||
| * Usage: | ||
| * REGISTRY_ENTROPY_KEY_JWK='{"kty":"EC",...}' node generate-test-token.js | ||
| * | ||
| * Or set the environment variable in a .env file | ||
| * | ||
| * You can also use tsx to run it: | ||
| * REGISTRY_ENTROPY_KEY_JWK='...' npx tsx generate-test-token.js | ||
| */ | ||
|
|
||
| const { importJWK, SignJWT } = require("jose"); | ||
| const dotenv = require("dotenv"); | ||
| const path = require("path"); | ||
|
|
||
| // Load .env file if it exists (try both root and current directory) | ||
| dotenv.config({ path: path.resolve(__dirname, "../../../.env") }); | ||
| dotenv.config({ path: path.resolve(__dirname, ".env") }); | ||
|
|
||
| async function generateTestToken() { | ||
| const jwkString = '{"kty":"EC","use":"sig","alg":"ES256","kid":"entropy-key-1","crv":"P-256","x":"POWUVJwOulAW0gheTVUHF4nXUenMCg0jxhGKI8M1LLU","y":"Cb4GC8Tt0gW7zMr-DhsDJisGVNgWttwjnyQl1HyU7hg","d":"FWqvWBzoiZcD0hh4JAMdJ7foxFRGqyV2Ei_eWvr1Si4"}'; | ||
|
|
||
| if (!jwkString) { | ||
| console.error("Error: REGISTRY_ENTROPY_KEY_JWK environment variable is required"); | ||
| console.error("\nUsage:"); | ||
| console.error(" REGISTRY_ENTROPY_KEY_JWK='<your-jwk-json>' node generate-test-token.js"); | ||
| console.error("\nOr set it in your .env file"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| try { | ||
| const jwk = JSON.parse(jwkString); | ||
| const privateKey = await importJWK(jwk, "ES256"); | ||
|
|
||
| // Generate token valid for 1 year | ||
| const token = await new SignJWT({ | ||
| // Add any custom claims you want | ||
| platform: "eid-wallet", | ||
| purpose: "public-key-sync", | ||
| }) | ||
| .setProtectedHeader({ | ||
| alg: "ES256", | ||
| kid: jwk.kid || "entropy-key-1", | ||
| }) | ||
| .setIssuedAt() | ||
| .setExpirationTime("1y") // Valid for 1 year | ||
| .sign(privateKey); | ||
|
|
||
| console.log("\n✅ Generated JWT Token (valid for 1 year):\n"); | ||
| console.log(token); | ||
| console.log("\n📋 Use this token in the Authorization header:"); | ||
| console.log(` Authorization: Bearer ${token}\n`); | ||
|
|
||
| return token; | ||
| } catch (error) { | ||
| console.error("Error generating token:", error.message); | ||
| if (error.message.includes("JSON")) { | ||
| console.error("\nMake sure REGISTRY_ENTROPY_KEY_JWK is valid JSON"); | ||
| } | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| generateTestToken(); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules/ | ||
| dist/ | ||
| *.log | ||
| .DS_Store | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
PUBLIC_EID_WALLET_TOKEN in
$env/static/publicwill be exposed to the browserDeclaring
PUBLIC_EID_WALLET_TOKENin the$env/static/publicmodule means its value is statically inlined into client bundles and is not secret. If this token is used for authenticating sensitive operations (e.g., calling eVault/public-key), exposing it to all client code (and, transitively, attackers running JS in the browser) significantly weakens your security model.Please:
$env/static/private/dynamic private) and adjust the flow so that only trusted server-side code uses it.Based on prior learnings about avoiding PUBLIC_* envs for critical configuration (e.g., PUBLIC_PLATFORM_URL), this is worth a careful threat-model review rather than treating it as just another public constant.
🏁 Script executed:
Length of output: 251
🏁 Script executed:
Length of output: 469
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 47537