Repository navigation
Conversation
- CODEOWNERS: give examples/ to the product team - PR template: add Motivation and Context section - Dependabot: npm and github-actions, weekly, 3-day cooldown Co-authored-by: Cursor <cursoragent@cursor.com>
- Node >=24.22.0, npm >=12, .nvmrc 26, @types/node ^26 - Replace torus-scripts 8, ESLint and Prettier with vp pack/lint/fmt, @toruslabs/oxlint-config-typescript and formatPreset() - @toruslabs/config 5 (library profile, DOM libs added) - Add .npmrc policy (min-release-age, allow-scripts-pin) and @lavamoat/harden - Changesets config (baseBranch master, public access) - Fix strictNullChecks errors surfaced by config 5 - Remove legacy torus.config.js, eslint/prettier/vitest configs - Pin vite and vitest overrides to vite-plus 1.5.0 Co-authored-by: Cursor <cursoragent@cursor.com>
…590) - validate: Node 24.22.0 and 26, npm 12, npm ci, harden check, check, build, typecheck, tests, changeset status (PRs), pack dry-run - release-pr: manual Changesets release PR on master, does not publish - security-code-scanner: MetaMask reusable scanner pinned to v2.1.1 - vue-app demo deploy moved to validate on master, using STS role from vars.AWS_ROLE_ARN plus Wiz sensor; static AWS keys removed Co-authored-by: Cursor <cursoragent@cursor.com>
- bowser ^2.14.1 -> ^2.15.0 - @sentry/core ^10.45.0 -> ^10.78.0 (dev and optional peer) - typescript ^7 -> ^7.0.2 - npm audit fix for in-range advisories; remaining advisories are transitive or need a major (deepmerge, minimatch via eslint-plugin-tsdoc) Co-authored-by: Cursor <cursoragent@cursor.com>
- @babel/runtime peer removed: no build step or source import needs it - Changeset for @toruslabs/customauth (major): Node/npm engines, Vite+ build, types path move, babel peer removal Co-authored-by: Cursor <cursoragent@cursor.com>
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
- Replaced the S3 sync action with a direct AWS CLI command for improved reliability and simplicity. - Removed unnecessary permissions for id-token in the workflow configuration. Co-authored-by: Cursor <cursoragent@cursor.com>
…ndencies - Updated @toruslabs/broadcast-channel from 13.3.0 to 14.0.0 in package.json and related files. - Adjusted dependencies for @toruslabs/eccrypto, @toruslabs/constants, and @toruslabs/metadata-helpers to align with the new broadcast-channel version. - Added prepack script to package.json for build automation. - Updated service worker scripts to reference the new broadcast-channel version. Co-authored-by: Cursor <cursoragent@cursor.com>
…endencies - Updated @toruslabs/fetch-node-details from 16.1.1 to 17.0.0 in package.json and package-lock.json. - Adjusted dependencies for @toruslabs/constants and @toruslabs/http-helpers to align with the new fetch-node-details version. - Updated Node and npm engine requirements to >=24.22.0 and >=12 respectively. Co-authored-by: Cursor <cursoragent@cursor.com>
- Updated @toruslabs/constants to 17.0.0, @toruslabs/eccrypto to 8.0.0, @toruslabs/http-helpers to 10.0.0, @toruslabs/metadata-helpers to 9.0.0, and @toruslabs/session-manager to 6.0.0 in package.json and package-lock.json. - Upgraded @toruslabs/torus.js to 18.0.0 to align with the new dependency versions. - Removed unused node_modules entries for better clarity and maintenance. Co-authored-by: Cursor <cursoragent@cursor.com>
- Updated @toruslabs/constants to 17.0.0, @toruslabs/fnd-base to 17.0.0, and @toruslabs/torus.js to 18.0.0 in package.json and package-lock.json across multiple examples. - Upgraded @toruslabs/customauth to version 22.3.3. - Updated service worker scripts to reference the new @toruslabs/broadcast-channel version 14.0.0. - Adjusted Node and npm engine requirements to >=24.22.0 and >=12 respectively. Co-authored-by: Cursor <cursoragent@cursor.com>
- Changed the peer dependency version of @sentry/core from ^10.78.0 to ^10.x in package.json and package-lock.json across multiple examples for better compatibility.
- Updated userId retrieval in JwtHandler and MockLoginHandler to remove the nullish coalescing operator, ensuring consistent behavior with the isUserIdCaseSensitive parameter.
| public nonce: string = randomId(); | ||
|
|
||
| public finalURL: URL; | ||
| public finalURL!: URL; |
There was a problem hiding this comment.
Every subclass sets it in its constructor via setFinalUrl(). Calling it from the base constructor would run before subclass field initializers (Telegram's RESPONSE_TYPE/SCOPE/PROMPT would be undefined)
| encodeBase64Url( | ||
| JSON.stringify({ | ||
| ...(this.params.customState || {}), | ||
| ...this.params.customState, |
There was a problem hiding this comment.
customState can be undefined right?
There was a problem hiding this comment.
Yes. Object spread of undefined is a no-op ({...undefined} → {}), so behavior is unchanged. Oxlint's unicorn/no-useless-fallback-in-spread flags the || {}.
| }); | ||
| } | ||
| return null; | ||
| return null as unknown as LoginWindowResponse; |
There was a problem hiding this comment.
Can we avoid as unknown as?
There was a problem hiding this comment.
Previously we keeped the type cast for null to not break client type check but this is a major upgrade so i updated the type to return nullable response.
| const { idToken, extraParams } = parameters; | ||
|
|
||
| const { sessionId } = JSON.parse(decodeBase64Url(extraParams)) || {}; | ||
| const { sessionId } = JSON.parse(decodeBase64Url(extraParams || "")) || {}; |
There was a problem hiding this comment.
decodeBase64Url('') returns empty string, ''.
JSON.parse('') will throw an error.
Shall we just throw new Error("sessionId not found") if extraParams is empty?
| async getUserInfo(params: LoginWindowResponse): Promise<TorusConnectionResponse> { | ||
| const { idToken } = params; | ||
| const userInfo = objectToAuthDataMap(idToken); | ||
| const userInfo = objectToAuthDataMap(idToken || ""); |
There was a problem hiding this comment.
Same here as above, https://github.com/torusresearch/CustomAuth/pull/474/changes#r4563764706
objectToAuthDataMap does JSON.parse under the hood.
| ...rest, | ||
| idToken: encodeBase64Url(JSON.stringify(result)) || "", | ||
| state: decodeBase64Url(stateParam) as unknown as { [key: string]: string }, | ||
| state: decodeBase64Url(stateParam || "") as unknown as { [key: string]: string }, |
There was a problem hiding this comment.
Same as above.
Let's throw an informative error rather than uncaught exceptions. 😅
- Added a check to throw an error if extraParams is empty or missing in the getUserInfo method. - Updated unit tests to cover scenarios where extraParams is undefined or an empty string, ensuring robust error handling.
- Added a check in the getUserInfo method to throw an error if idToken is not provided, enhancing robustness. - Introduced unit tests to validate the new error handling and ensure correct behavior when idToken is missing or invalid.
…meter - Added a check to throw an error if the state parameter is missing in the handleLoginWindow method, improving robustness. - Updated unit tests to validate the new error handling for scenarios where the state parameter is not present in the Telegram response.
- Modified the handleLoginWindow method in AbstractLoginHandler and its implementations to return Promise<LoginWindowResponse | null> instead of just LoginWindowResponse. - Added error handling in CustomAuth to throw an error if the login window returns no response, enhancing robustness. - Updated related implementations in MockLoginHandler and TelegramHandler to align with the new return type.
- Changed the return type of triggerLogin in CustomAuth and related implementations to Promise<TorusLoginResponse | null> to reflect the new behavior in redirect mode. - Updated examples in Angular and Vue applications to handle the new null return type, ensuring proper null-checking before accessing user information.
Build hash and query param objects with Object.fromEntries so keys from the URL (e.g. __proto__) become own properties instead of dynamic writes. Resolves CodeQL js/remote-property-injection in src/utils/helpers.ts.
Motivation and Context
Modernize CustomAuth to the 2026 Q4 stack policy: Node 24/26, npm 12, LavaMoat harden, TypeScript + Oxlint/Oxfmt via
@toruslabs/torus-scripts@9, Changesets release PR, and MetaMask security scanner. Shared acceptance criteria live in EMBED-573.Jira Link
Description
examples/), PR template Motivation section, Dependabot (npm + github-actions, 3-day cooldown)torus-scripts@8/ ESLint / Prettier → Vite+ (vp),@toruslabs/config@5, Oxlint/Oxfmt,@lavamoat/hardenmoderatenode >=24.22.0,npm >=12,.nvmrc26,@types/node^26.6.6main/module/unpkg/jsdelivrunchanged;typesdist/lib.cjs/types/index.d.ts→dist/lib.cjs/index.d.ts@babel/runtimepeer@toruslabs/config@5):triggerLoginreturnsPromise<TorusLoginResponse | null>andILoginHandler.handleLoginWindowreturnsPromise<LoginWindowResponse | null>. Both already resolved tonullin redirect mode; only the types change. Callers must null-check before readinguserInfo.@sentry/coreoptional peer stays^10.x. DevDependency is^10.78.0. Stack-upgrade step 7 says to raise peer ranges with the devDependency; this is an exception. The library only type-importsstartSpan(Span,StartSpanOptions), which@sentry/corehas exported since 10.0.0. Sentry packages pin@sentry/coreto their exact version, so a^10.78.0peer makesnpm install --strict-peer-depsfail for an app on@sentry/browser@10.50.0that also depends on@sentry/core@10.50.0.validate(Node 24.22.0 + 26),release-pr(Changesets, no publish),security-code-scanner; vue-app S3/CloudFront deploy on master uses STSvars.AWS_ROLE_ARN+ Wiz sensorserviceworker/and every example) loadbroadcast-channel@14.0.0from jsDelivr with SRIsha384-xh8PrJAG…constants/fnd-base17 in all four,torus.js18 in nextjs, vite-react, and vue. Only source change: vue and angular type thetriggerLoginresult asTorusLoginResponse | null.Majors taken
@toruslabs/torus-scripts8 → 9.0.1,@toruslabs/config4 → 5, Oxlint presets replace ESLint configs, TypeScript 5 → 7,@types/node25 → 26, vite-plus / Changesets / harden addedtorus.js17 → 18,broadcast-channel13 → 14,fetch-node-details16 → 17,session-manager5 → 6,eccrypto7 → 8,constants16 → 17,http-helpers9 → 10,metadata-helpers8 → 9. One copy of each in the tree. Nosrc/changes were needed.torus.js17 orconstants16 directly should move to the matching majors.Scan / audit
npm audit: 6 left (1 low / 5 moderate). The low one is the deepmerge prototype advisory, with no in-range fix without an API change. The 5 moderate are one minimatch chain viaeslint-plugin-tsdoc, pulled in by the oxlint preset (dev only).vitest(require-mock-type-parameters)warnings only (0 errors)Verification
dist/lib.{cjs,esm}/index.{js,d.ts},serviceworker/require+ ESMimportof packed buildconstants/fnd-base17 andtorus.js18. All popup pages pinbroadcast-channel@14.0.0with SRI. (vue and angular not rebuilt after the| nulltype change.)NodeDetailManageruses the server's data rather than the local fallback, andtorus.js@18getPublicAddresssucceeds against those nodes.Settings the token could not change
release-pr)vars.AWS_ROLE_ARNandsecrets.WIZ_SENSOR_TOKENfor deployrelease-packagesstays manual after release PR mergesHow has this been tested?
See Verification checklist above.
Screenshots (if appropriate)
N/A
Types of changes
Checklist
Note
High Risk
Major release with toolchain, CI, and dependency majors plus breaking public types; consumers must upgrade Node/npm, handle null login results, and align Torus package majors.
Overview
This PR is a 2026 Q4 stack upgrade for
@toruslabs/customauth, shipped as a major release via Changesets. It moves the repo onto torus-scripts 9 / Vite+ with Oxlint/Oxfmt (replacing ESLint/Prettier), Node ≥24.22.0 and npm ≥12, and TypeScript 7.Release & CI: Adds Changesets (config + major bump notes), replaces the old build/release workflow with validate (matrix Node 24.22.0/26, harden, check, build, typecheck, tests, changeset status on PRs), release-pr (Changesets action), security-code-scanner, and Dependabot. Master deploy still builds/packs the vue demo and syncs S3/CloudFront, now using OIDC (
vars.AWS_ROLE_ARN) and an optional Wiz sensor instead of long-lived AWS keys.Package surface: Published types move from
dist/lib.cjs/types/index.d.tstodist/lib.cjs/index.d.ts. The unused@babel/runtimepeer is removed. Major runtime bumps:torus.js18,broadcast-channel14,fetch-node-details17,session-manager6,eccrypto8,constants17,http-helpers10,metadata-helpers9.Breaking for consumers:
triggerLoginandILoginHandler.handleLoginWindoware typed as returningPromise<… | null>(redirect mode already returned null). Example apps and serviceworker pages were updated accordingly; popup HTML/CDN pinsbroadcast-channel@14.0.0with new SRI hashes.Reviewed by Cursor Bugbot for commit 8bacb12. Bugbot is set up for automated code reviews on this repo. Configure here.