| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -39,15 +39,17 @@ const SECRET = getSecret(); | |
| /** | ||
| * Create a simple token for a WebID | ||
| * @param {string} webId - The WebID to create token for | ||
| * @param {number} expiresIn - Expiration time in seconds (default 1 hour) | ||
| * @param {number} [expiresIn] - Expiration time in seconds (default: no expiry) | ||
| * @returns {string} Token string | ||
| */ | ||
| export function createToken(webId, expiresIn = 3600) { | ||
| export function createToken(webId, expiresIn) { | ||
| const payload = { | ||
| webId, | ||
| iat: Math.floor(Date.now() / 1000), | ||
| exp: Math.floor(Date.now() / 1000) + expiresIn | ||
| }; | ||
| if (expiresIn !== undefined && expiresIn > 0) { | ||
| payload.exp = Math.floor(Date.now() / 1000) + expiresIn; | ||
| } | ||
|
Comment thread
Comment on lines
+45
to
+52
|
||
|
|
||
| const data = Buffer.from(JSON.stringify(payload)).toString('base64url'); | ||
| const signature = crypto | ||
| Expand All | @@ -65,7 +67,7 @@ export function createToken(webId, expiresIn = 3600) { | |
| * JWT tokens (3-part) require async verification via verifyTokenAsync(). | ||
| * | ||
| * @param {string} token - The token to verify | ||
| * @returns {{webId: string, iat: number, exp: number} | null} Decoded payload or null | ||
| * @returns {{webId: string, iat: number, exp?: number} | null} Decoded payload or null | ||
| */ | ||
| export function verifyToken(token) { | ||
| if (!token || typeof token !== 'string') { | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWith createToken() now able to omit exp, the token module’s docs/types should reflect that exp is optional (e.g., the file header comment describing the payload shape and the verifyToken() JSDoc return type currently imply exp is always present). Updating those docs will help avoid confusion for future callers.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.