Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/portal/src/app/typescript/v5/auth/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ import { privateKeyToAccount } from "thirdweb/wallets";

const privateKey = process.env.THIRDWEB_PRIVATE_KEY;
const thirdwebClient = createThirdwebClient({
secretKey: process.env.THIRDWEB_SECRET_KEY;
secretKey: process.env.THIRDWEB_SECRET_KEY,
});
Comment on lines +45 to 46

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "TypeScript strictness:"
rg -n '"strictNullChecks"|"strict"' --glob 'tsconfig*.json' .

echo "MDX and documentation type-checking:"
rg -n 'mdx|typecheck|tsc|twoslash|remark|rehype' \
  --glob 'package.json' \
  --glob 'tsconfig*.json' \
  --glob '*.{config,setup}.{js,ts,mjs,cjs}' .

echo "thirdweb API usage and local type references:"
rg -n 'privateKeyToAccount|CreateThirdwebClientOptions|PrivateKeyToAccountOptions' .

Repository: thirdweb-dev/js

Length of output: 35432


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "Relevant portal tsconfig:"
sed -n '1,120p' apps/portal/tsconfig.json

echo
echo "Relevant portal package scripts:"
sed -n '1,120p' apps/portal/package.json

echo
echo "Thirdweb client options:"
sed -n '45,125p' packages/thirdweb/src/client/client.ts

echo
echo "Thirdweb private key implementation:"
sed -n '1,105p' packages/thirdweb/src/wallets/private-key.ts

echo
echo "Target MDX snippet:"
sed -n '35,60p' apps/portal/src/app/typescript/v5/auth/page.mdx

echo
echo "Check env variable pattern in portal MDX auth pages:"
python3 - <<'PY'
from pathlib import Path
import re
for path in sorted(Path('apps/portal/src/app').glob('**/*.mdx')):
    text = path.read_text(errors='ignore')
    if re.search(r'process\.env\.(THIRDWEB_SECRET_KEY|THIRDWEB_PRIVATE_KEY|PRIVATE_KEY|PRIVATE_KEY_)', text):
        print(path)
Py

echo
echo "Type-check related config values:"
python3 - <<'PY'
import json
from pathlib import Path
for path in ['apps/portal/tsconfig.json', 'apps/portal/package.json']:
    data = json.loads(Path(path).read_text())
    print(path)
    for key in data if path.endswith('tsconfig.json') else ['scripts']:
        print(f'  {key}: {data[key]}')
PY

Repository: thirdweb-dev/js

Length of output: 11494


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "MDX files with THIRDWEB env vars:"
rg -n --glob '*.mdx' 'process\.env\.THIRDWEB_(SECRET_KEY|PRIVATE_KEY)|privateKeyToAccount\(\{[^}]*PRIVATE_KEY' apps/portal/src/app || true

echo
echo "Isolated TypeScript type-check probe for the snippet (with `@types/node` type definitions if available):"
python3 - <<'PY'
from pathlib import Path
import subprocess
import tempfile

index_path = Path('node_modules/@types/node/index.d.ts') if Path('node_modules/@types/node/index.d.ts').exists() else None
print(f'path/@types/node/index.d.ts: {index_path}')

# Use the repo's lockfile version declarations only if available locally; do not install dependencies.
tsc = subprocess.run(['command', '-v', 'tsc'], shell=True, text=True, capture_output=True)
print(f'tsc command: {tsc.stdout.strip()!r}')

PY

echo
echo "Search for env validation helpers:"
rg -n 'validateEnv|zod|process\.env\.[A-Z_]+|\?:"' apps packages --glob '*.{ts,tsx,js,jsx}' | head -120 || true

Repository: thirdweb-dev/js

Length of output: 13946


Cast environment variables before passing them to thirdweb APIs.

createThirdwebClient({ secretKey }) and privateKeyToAccount({ privateKey }) require string values. process.env.THIRDWEB_SECRET_KEY and process.env.THIRDWEB_PRIVATE_KEY are not checked here, so add as string or document that these variables must be set.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/portal/src/app/typescript/v5/auth/page.mdx` around lines 45 - 46, Update
the thirdweb initialization around createThirdwebClient and privateKeyToAccount
so process.env.THIRDWEB_SECRET_KEY and process.env.THIRDWEB_PRIVATE_KEY are
explicitly treated as strings before being passed to the APIs, using the
requested type assertion or an equivalent required-variable validation.

Source: MCP tools


const auth = createAuth({
domain: "localhost:3000",
client: thirdwebClient,
adminAccount: privateKeyToAccount({client, privateKey})
adminAccount: privateKeyToAccount({ client: thirdwebClient, privateKey }),
});

// 1. generate a login payload for a client on the server side
Expand Down
5 changes: 3 additions & 2 deletions apps/portal/src/app/typescript/v5/getting-started/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import { inAppWallet } from "thirdweb/wallets"
// create or access a wallet
const wallet = inAppWallet();
const account = await wallet.connect({
client: TEST_CLIENT,
client,
strategy: "backend", // we use backend strategy to generate a wallet from a secret key
walletSecret: "my-test-wallet-secret", // use this secret to access the same wallet across multiple scripts
});
Expand All @@ -102,7 +102,8 @@ import { getWalletBalance } from "thirdweb/wallets";

// Get the balance of the account
const balance = await getWalletBalance({
account,
client,
address: account.address,
chain: sepolia,
});
console.log("Balance:", balance.displayValue, balance.symbol);
Expand Down
Loading