diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 00000000..f9fed007 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,5 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`. + +Add a changeset with `npm run changeset` before opening a PR that should trigger a release. diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 00000000..eefd635b --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", + "baseBranch": "master", + "access": "public", + "privatePackages": { + "version": false + }, + "updateInternalDependencies": "patch", + "fixed": [], + "linked": [], + "ignore": [] +} diff --git a/.changeset/embed-590-stack-upgrade.md b/.changeset/embed-590-stack-upgrade.md new file mode 100644 index 00000000..d253100f --- /dev/null +++ b/.changeset/embed-590-stack-upgrade.md @@ -0,0 +1,5 @@ +--- +"@toruslabs/customauth": major +--- + +Stack upgrade to torus-scripts 9 / Vite+: Node >=24.22.0, npm >=12, Oxlint/Oxfmt, Changesets. Package `types` now point at `dist/lib.cjs/index.d.ts`. Dropped unused `@babel/runtime` peer. `@toruslabs/broadcast-channel` 13.3.0 → 14.0.0 (EMBED-586). `@toruslabs/fetch-node-details` 16.1.1 → 17.0.0. torus.js stays on 17.2.3 until EMBED-588, so eccrypto 8, constants 17, http-helpers 10, and metadata-helpers 9 install nested under the packages that need them. diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ec3487fc..05222f48 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -21,6 +21,7 @@ # Product code src/ @torusresearch/Web3Auth-Product test/ @torusresearch/Web3Auth-Product +examples/ @torusresearch/Web3Auth-Product # Most restrictive — last match wins .github/CODEOWNERS @torusresearch/Web3Auth-Admins diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3d508225..a0e6a046 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,7 @@ +## Motivation and Context + + + ## Jira Link diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..aa99ac5f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 + +updates: + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + cooldown: + default-days: 3 + open-pull-requests-limit: 10 + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + cooldown: + default-days: 3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 1894e3a2..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Build & Release - -on: [push] - -jobs: - build: - strategy: - matrix: - node: ["24.x"] - os: [ubuntu-latest] - - runs-on: ${{ matrix.os }} - - steps: - - name: Check out Git repository - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - - - name: Set up node - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 - with: - node-version: ${{ matrix.node }} - cache: "npm" - - - name: Install dependencies - run: npm install - - - name: Run Build - run: npm run build - - - name: Pack and build example - if: github.ref == 'refs/heads/master' - run: | - npm pack - cd examples/vue-app - npm run install:local - npm run build - - # Set the credentials from repository settings/secrets - - name: Configure AWS credentials - if: github.ref == 'refs/heads/master' - uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.AWS_REGION_US }} - - # Copy the files from build folder to the S3 bucket - # Upload to S3 - - name: sync s3 - if: github.ref == 'refs/heads/master' - uses: jakejarvis/s3-sync-action@7ed8b112447abb09f1da74f3466e4194fc7a6311 # master - env: - SOURCE_DIR: "./examples/vue-app/dist" - AWS_REGION: "us-east-1" - AWS_S3_BUCKET: "demo-customauth.web3auth.io" - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - - - name: Update AWS Cloudfront Config - uses: chaitanyapotti/cloudfront-update-distribution@c5d4a6b318664766f944d11c32544f492fb3027d # v4 - if: github.ref == 'refs/heads/master' - with: - cloudfront-distribution-id: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} - cloudfront-invalidation-required: true - cloudfront-invalidation-path: "/*" - cloudfront-wait-for-service-update: false diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml new file mode 100644 index 00000000..1ee46aca --- /dev/null +++ b/.github/workflows/release-pr.yml @@ -0,0 +1,39 @@ +name: Create release pull request + +on: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: release-pr + cancel-in-progress: false + +jobs: + release-pr: + if: github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: .nvmrc + - name: Install npm 12 + run: npm install --global npm@12.2.0 + - name: Install dependencies + run: npm ci + # The GitHub API commit mode signs the release commit, which `master` requires. + - name: Create or update the release pull request + uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2 + with: + version-script: npm run version-packages + commit-message: "chore: release packages" + pr-title: "chore: release packages" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/security-code-scanner.yml b/.github/workflows/security-code-scanner.yml new file mode 100644 index 00000000..660cf09d --- /dev/null +++ b/.github/workflows/security-code-scanner.yml @@ -0,0 +1,27 @@ +name: Security code scanner + +on: + pull_request: + push: + branches: [master] + schedule: + - cron: "17 4 * * 1" + workflow_dispatch: + +permissions: + contents: read + +jobs: + security-scan: + uses: MetaMask/action-security-code-scanner/.github/workflows/security-scan.yml@becb242930b3cc271c26da0280050db9c157e291 # v2.1.1 + permissions: + actions: read + contents: read + security-events: write + with: + scanner-ref: becb242930b3cc271c26da0280050db9c157e291 # v2.1.1 + paths-ignored: | + **/node_modules/** + **/dist/** + **/build/** + **/coverage/** diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 00000000..8e97cd7b --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,94 @@ +name: Validate pull request + +on: + pull_request: + push: + branches: [master] + +permissions: + contents: read + +jobs: + validate: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: ["24.22.0", "26"] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: ${{ matrix.node }} + - name: Install npm 12 + run: npm install --global npm@12.2.0 + - name: Install dependencies + run: npm ci + - name: Check dependency hardening + run: npm exec --no -- harden check --package-manager npm + - name: Check source + run: npm run check + - name: Build packages + run: npm run build + - name: Check TypeScript projects + run: npm run typecheck + - name: Run tests + run: npm test + - name: Check release notes + if: | + github.event_name == 'pull_request' && + !startsWith(github.head_ref, 'changeset-release/') && + !startsWith(github.head_ref, 'dependabot/') + env: + BASE_REF: ${{ github.base_ref }} + run: | + git fetch --no-tags origin "${BASE_REF}:refs/remotes/origin/${BASE_REF}" + npm exec -- changeset status --since="origin/${BASE_REF}" + - name: Preview package archive + run: npm pack --dry-run --json + + deploy-demo: + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + needs: validate + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: .nvmrc + - name: Install npm 12 + run: npm install --global npm@12.2.0 + - name: Install dependencies + run: npm ci + - name: Build package + run: npm run build + - name: Start Wiz sensor + uses: wiz-sec-public/wiz-sensor-github-action@2fd38e4d101f185b1deb0c313c0adb0a7efdfe62 # v0.9.6 + continue-on-error: true + with: + api-token: ${{ secrets.WIZ_SENSOR_TOKEN }} + - name: Pack and build example + run: | + npm pack + cd examples/vue-app + npm run install:local + npm run build + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0 + with: + role-to-assume: ${{ vars.AWS_ROLE_ARN }} + aws-region: ${{ secrets.AWS_REGION_US }} + - name: sync s3 + run: aws s3 sync ./examples/vue-app/dist s3://demo-customauth.web3auth.io --region us-east-1 --no-progress + - name: Update AWS Cloudfront Config + uses: chaitanyapotti/cloudfront-update-distribution@c5d4a6b318664766f944d11c32544f492fb3027d # v4 + with: + cloudfront-distribution-id: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} + cloudfront-invalidation-required: true + cloudfront-invalidation-path: "/*" + cloudfront-wait-for-service-update: false diff --git a/.gitignore b/.gitignore index 992c3ff2..ea0adcfd 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,4 @@ bundle.min.js types2/ .DS_Store -.npmrc \ No newline at end of file +.vitest/ diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..e5b77622 --- /dev/null +++ b/.npmrc @@ -0,0 +1,11 @@ +## Avoid installing packages published in last 3 days. +min-release-age=3 + +## Don't install packages from git urls. +allow-git=none + +## Disable installing dependencies from remote URLs. +allow-remote=none + +## Pin allowed scripts to exact versions of dependencies to prevent unexpected script execution. +allow-scripts-pin=true diff --git a/.nvmrc b/.nvmrc index 218de16f..6f4247a6 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ ->=24.x \ No newline at end of file +26 diff --git a/.prettierignore b/.prettierignore index de243c73..cb17fa97 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,23 +1,7 @@ -# See https://help.github.com/ignore-files/ for more about ignoring files. - -# dependencies -/node_modules - -# testing -/coverage - -#production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* -types/ -.github/CODEOWNERS \ No newline at end of file +dist +node_modules +coverage +examples +*.tgz +.changeset +package-lock.json diff --git a/.prettierrc.yaml b/.prettierrc.yaml deleted file mode 100644 index 3a122545..00000000 --- a/.prettierrc.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# .prettierrc or .prettierrc.yaml -printWidth: 150 -singleQuote: false -semi: true -trailingComma: es5 \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index 993f6a48..00000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,3 +0,0 @@ -import toruslabsTypescript from "@toruslabs/eslint-config-typescript"; - -export default [...toruslabsTypescript]; diff --git a/examples/vue-app/public/serviceworker/redirect.html b/examples/vue-app/public/serviceworker/redirect.html index 35637be1..009ad959 100644 --- a/examples/vue-app/public/serviceworker/redirect.html +++ b/examples/vue-app/public/serviceworker/redirect.html @@ -115,8 +115,8 @@

You can close this window now