Skip to content

Major SDK upgrade: Aptos TS SDK 6, Vite 8, TypeScript 6#4

Merged
WGB5445 merged 8 commits into
mainfrom
cursor/sdk-0ded
Mar 25, 2026
Merged

Major SDK upgrade: Aptos TS SDK 6, Vite 8, TypeScript 6#4
WGB5445 merged 8 commits into
mainfrom
cursor/sdk-0ded

Conversation

@WGB5445

@WGB5445 WGB5445 commented Mar 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Upgrade @aptos-labs/ts-sdk from 5.x to 6.3.1 (major).
  • Upgrade toolchain: Vite 8, TypeScript 6, @vitejs/plugin-react 6, SimpleWebAuthn 13.3, React 19.2.4.
  • ESLint 9 flat config: replace .eslintrc.cjs with eslint.config.js using typescript-eslint, @eslint/js, globals, eslint-plugin-react-hooks (flat/recommended), eslint-plugin-react-refresh.
  • pnpm: peerDependencyRules.allowedVersions so typescript-eslint accepts TypeScript 6 (peer range still <6.0.0 upstream).
  • tsconfig: moduleResolution: "bundler" for TS 6 (avoids deprecated node10).
  • Code: Hex.fromHexInput for SDK 6; CredentialInfo JSON-safe for localStorage + parseStoredCredentialInfo (with hex/base64/address validation and cross-checks); useCallback for balance fetch + effect deps; unknown error handling for lint.
  • CI: .github/workflows/ci.yml runs on pull requests and pushes to main: pnpm fmt:check, pnpm lint, pnpm build.
  • Formatting: Prettier with pnpm fmt / pnpm fmt:check.

Copilot review follow-up

  • localStorage / Uint8Array: removed rawData from persisted shape; added parseStoredCredentialInfo with validation.
  • Address derivation: calculateAptosAddressFromPublicKey returns null on failure; getCredentialInfo returns null if derivation fails.
  • Storage validation: parseStoredCredentialInfo checks uncompressed P-256 hex, base64 length, Aptos address shape, hex vs base64 byte equality, and recomputed address matches stored aptosAddress.
  • createPasskey: only updates credentialId / localStorage when credentialInfo is non-null; null guard for createCredential() and instanceof PublicKeyCredential.
  • fetchAptBalance: clears aptBalance when stored JSON is invalid or missing (no stale UI).
  • submitTransfer: credentialData.id must equal credentialId or throws a clear error.
  • useEffect interval: typed as ReturnType<typeof setInterval> | undefined with explicit cleanup check.

Verification

  • pnpm fmt:check, pnpm lint, and pnpm build pass locally.
Open in Web Open in Cursor 

…nfig

- Bump @aptos-labs/ts-sdk to 6.x; SimpleWebAuthn to 13.3; Vite 8; TS 6; React 19.2.4
- Add pnpm peerDependencyRules for typescript-eslint with TypeScript 6
- tsconfig: moduleResolution bundler for TS 6
- Migrate from .eslintrc.cjs to eslint.config.js (typescript-eslint, react-hooks)
- Fix App/webauthn types: CredentialInfo, Hex.fromHexInput, Secp256r1 key bytes
- Fix noble curves type-only import path (.js extension)

Co-authored-by: Logan Wang <WGB5445@users.noreply.github.com>
@WGB5445 WGB5445 marked this pull request as ready for review March 25, 2026 13:53
@WGB5445 WGB5445 requested a review from Copilot March 25, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the project’s Aptos/WebAuthn demo stack to newer major versions (Aptos TS SDK v6, Vite v8, TypeScript v6, React 19.x) and updates the code/configuration needed to compile and lint successfully under the new toolchain.

Changes:

  • Upgrade major dependencies (Aptos TS SDK, Vite, TypeScript, React, SimpleWebAuthn) and refresh the lockfile.
  • Migrate ESLint to v9 flat config (eslint.config.js) and adjust the lint script accordingly.
  • Update app/helper code for SDK v6 APIs and stricter linting (typed credential info, useCallback balance fetch, unknown error handling).

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tsconfig.json Switches TS module resolution to bundler for TS 6 compatibility.
src/helper/webauthn.ts Updates imports/types and refines credential info typing (CredentialInfo).
src/App.tsx Adapts to new helper exports/types; improves effect deps and error handling; updates Hex conversion.
package.json Bumps core deps/devDeps and adds pnpm peerDependencyRules for TS 6.
pnpm-lock.yaml Lockfile updated to reflect dependency upgrades (Vite 8, SDK 6, etc.).
eslint.config.js Adds ESLint 9 flat configuration with TypeScript + React hooks/refresh plugins.
.eslintrc.cjs Removes legacy ESLint config in favor of flat config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/helper/webauthn.ts
Comment thread src/App.tsx Outdated
cursoragent and others added 2 commits March 25, 2026 14:04
- Drop rawData Uint8Array from persisted shape; use publicKey.hex when logging
- Add parseStoredCredentialInfo with runtime validation for reads
- Use parser in App and submitTransfer instead of unsafe JSON.parse casts

Co-authored-by: Logan Wang <WGB5445@users.noreply.github.com>
- Add .github/workflows/ci.yml for pull_request and push to main
- Add prettier, fmt (write) and fmt:check; .prettierignore for dist/node_modules
- Format repo with Prettier (incl. vite-gh-pages workflow YAML)

Co-authored-by: Logan Wang <WGB5445@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/helper/webauthn.ts
Comment thread src/helper/webauthn.ts
Comment thread src/App.tsx
Comment thread src/App.tsx Outdated
…ey UX)

- calculateAptosAddressFromPublicKey returns null on failure; getCredentialInfo fails fast
- parseStoredCredentialInfo validates hex length/prefix, base64 length, Aptos address shape
- createPasskey only updates credentialId/localStorage when credentialInfo succeeds
- useEffect interval typed as ReturnType<typeof setInterval> | undefined

Co-authored-by: Logan Wang <WGB5445@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/App.tsx
Comment thread src/App.tsx Outdated
Comment thread src/helper/webauthn.ts
Comment thread src/helper/webauthn.ts
…e consistency

- Guard createCredential null / non-PublicKeyCredential before getCredentialInfo
- fetchAptBalance: clear balance when stored JSON invalid or missing
- parseStoredCredentialInfo: require hex and base64 decode to same 65 bytes; match aptosAddress to recomputed derivation
- submitTransfer: require credentialData.id matches credentialId parameter

Co-authored-by: Logan Wang <WGB5445@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/helper/webauthn.ts Outdated
Addresses Copilot review: avoid duplicating WebAuthn sender authenticator construction for log vs submit.

Co-authored-by: Logan Wang <WGB5445@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/helper/webauthn.ts
Comment thread src/App.tsx Outdated
Comment thread src/App.tsx
…ad data

- parseStoredCredentialInfo: require id decodes from base64 to non-empty bytes
- handleFaucetRequest/openTestnetFaucet: showError when JSON invalid or missing

Co-authored-by: Logan Wang <WGB5445@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/helper/webauthn.ts
Comment on lines +486 to +507
function isValidBase64PublicKey(b64: string, expectedRawLen: number): boolean {
if (!/^[A-Za-z0-9+/]+=*$/.test(b64)) return false;
try {
const buf = Buffer.from(b64, "base64");
return buf.length === expectedRawLen;
} catch {
return false;
}
}

function isValidAptosAccountAddress(addr: string): boolean {
return /^0x[0-9a-fA-F]{64}$/.test(addr);
}

/** Credential rawId encoded as standard base64 (matches Buffer.toString("base64") in getCredentialInfo). */
function isValidCredentialIdBase64(id: string): boolean {
if (!/^[A-Za-z0-9+/]+=*$/.test(id) || id.length % 4 !== 0) return false;
try {
const buf = Buffer.from(id, "base64");
return buf.length > 0;
} catch {
return false;

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isValidBase64PublicKey / isValidCredentialIdBase64 use the regex ^[A-Za-z0-9+/]+=*$, which allows = padding in the middle of the string and doesn’t enforce canonical padding (0–2 = at the end). Since this function is used to validate persisted credential data, it would be better to enforce length % 4 === 0 and restrict padding to the end only (or use a small base64 validation helper) to avoid accepting malformed/corrupted values.

Copilot uses AI. Check for mistakes.
Comment thread src/helper/webauthn.ts
Comment thread src/helper/webauthn.ts
Comment thread src/helper/webauthn.ts
@WGB5445 WGB5445 merged commit f94e7e8 into main Mar 25, 2026
1 check passed
@WGB5445 WGB5445 deleted the cursor/sdk-0ded branch March 25, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants