diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 4d3a9fb..e592d84 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -46,14 +46,14 @@ jobs: run: pnpm build:example env: GITHUB_PAGES: 'true' - VITE_OMS_PUBLIC_API_KEY: ${{ secrets.OMS_PUBLIC_API_KEY }} + VITE_OMS_PUBLISHABLE_KEY: ${{ secrets.OMS_PUBLIC_API_KEY }} VITE_OMS_PROJECT_ID: ${{ secrets.OMS_PROJECT_ID }} - name: Build Trails Actions example run: pnpm build:trails-actions-example env: GITHUB_PAGES: 'true' - VITE_OMS_PUBLIC_API_KEY: ${{ secrets.OMS_PUBLIC_API_KEY }} + VITE_OMS_PUBLISHABLE_KEY: ${{ secrets.OMS_PUBLIC_API_KEY }} VITE_OMS_PROJECT_ID: ${{ secrets.OMS_PROJECT_ID }} - name: Stage Pages artifact diff --git a/AGENTS.md b/AGENTS.md index da1c279..808c600 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -78,9 +78,9 @@ This repository is a pnpm workspace for the OMS TypeScript SDK. The root package ## Security and Configuration - Do not commit real secrets. `.env.local` and `.env.*.local` files are ignored for local overrides. -- The React example uses `examples/react/.env.example` for `VITE_OMS_PUBLIC_API_KEY` and `VITE_OMS_PROJECT_ID`; keep local overrides in `examples/react/.env.local`. +- The React example uses `examples/react/.env.example` for `VITE_OMS_PUBLISHABLE_KEY` and `VITE_OMS_PROJECT_ID`; keep local overrides in `examples/react/.env.local`. - Treat credential signing, nonce handling, OIDC redirect state cleanup, session persistence, transaction execution/status polling, and access revocation as high-risk paths. Prefer focused regression tests for changes in these areas. -- GitHub Pages may provide `OMS_PUBLIC_API_KEY` and `OMS_PROJECT_ID` secrets for the deployed React example. Do not require those secrets for ordinary local unit tests unless the test explicitly needs an external boundary. +- GitHub Pages currently reads the existing `OMS_PUBLIC_API_KEY` secret and exposes it as `VITE_OMS_PUBLISHABLE_KEY` for deployed examples. Do not require those secrets for ordinary local unit tests unless the test explicitly needs an external boundary. ## Agent Workflow Rules diff --git a/API.md b/API.md index 7a1578e..3ff4797 100644 --- a/API.md +++ b/API.md @@ -73,7 +73,7 @@ The top-level entry point for the SDK. import { OMSClient } from '@0xsequence/typescript-sdk' const oms = new OMSClient({ - publicApiKey: 'your-public-api-key', + publishableKey: 'your-publishable-key', projectId: 'your-project-id', }) ``` @@ -82,7 +82,7 @@ const oms = new OMSClient({ ```typescript new OMSClient(params: { - publicApiKey: string + publishableKey: string projectId: string environment?: OmsEnvironment storage?: StorageManager @@ -95,7 +95,7 @@ new OMSClient(params: { | Name | Type | Required | Description | |---|---|---|---| -| `publicApiKey` | `string` | Yes | Your OMS public API key. | +| `publishableKey` | `string` | Yes | Your OMS publishable key. | | `projectId` | `string` | Yes | Your OMS project ID. Used as the WaaS signing scope for wallet requests and OIDC redirect state. | | `environment` | `OmsEnvironment` | No | API endpoint configuration. Defaults to the SDK's configured OMS endpoints. | | `storage` | `StorageManager` | No | Storage backend for wallet metadata. Defaults to `LocalStorageManager` when browser `localStorage` is available, otherwise `MemoryStorageManager`. | diff --git a/README.md b/README.md index e2b9598..9f78f44 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Then initialize the client with your OMS project credentials: import { OMSClient } from '@0xsequence/typescript-sdk' const oms = new OMSClient({ - publicApiKey: 'your-public-api-key', + publishableKey: 'your-publishable-key', projectId: 'your-project-id', }) ``` @@ -39,7 +39,7 @@ function requiredEnv(name: string, value: string | undefined): string { } const oms = new OMSClient({ - publicApiKey: requiredEnv('VITE_OMS_PUBLIC_API_KEY', import.meta.env.VITE_OMS_PUBLIC_API_KEY), + publishableKey: requiredEnv('VITE_OMS_PUBLISHABLE_KEY', import.meta.env.VITE_OMS_PUBLISHABLE_KEY), projectId: requiredEnv('VITE_OMS_PROJECT_ID', import.meta.env.VITE_OMS_PROJECT_ID), }) ``` @@ -67,7 +67,7 @@ To run it locally from the repository root: ```bash cp examples/react/.env.example examples/react/.env.local -# Fill VITE_OMS_PUBLIC_API_KEY and VITE_OMS_PROJECT_ID in examples/react/.env.local +# Fill VITE_OMS_PUBLISHABLE_KEY and VITE_OMS_PROJECT_ID in examples/react/.env.local pnpm dev:example ``` @@ -81,7 +81,7 @@ To run it locally from the repository root: ```bash cp examples/trails-actions/.env.example examples/trails-actions/.env.local -# Fill VITE_OMS_PUBLIC_API_KEY and VITE_OMS_PROJECT_ID in examples/trails-actions/.env.local +# Fill VITE_OMS_PUBLISHABLE_KEY and VITE_OMS_PROJECT_ID in examples/trails-actions/.env.local pnpm dev:trails-actions-example ``` @@ -92,7 +92,7 @@ import { Networks, OMSClient, WalletType } from '@0xsequence/typescript-sdk' import { parseUnits } from 'viem' const oms = new OMSClient({ - publicApiKey: 'your-public-api-key', + publishableKey: 'your-publishable-key', projectId: 'your-project-id', }) @@ -168,7 +168,7 @@ Google redirect auth is configured on the default environment. The redirect auth ```typescript const oms = new OMSClient({ - publicApiKey: 'your-public-api-key', + publishableKey: 'your-publishable-key', projectId: 'your-project-id', }) ``` @@ -367,7 +367,7 @@ const tx = await oms.wallet.sendTransaction({ ```typescript const oms = new OMSClient({ - publicApiKey: 'your-public-api-key', + publishableKey: 'your-publishable-key', projectId: 'your-project-id', environment: { walletApiUrl: 'https://staging-wallet.example.com', @@ -386,7 +386,7 @@ The default storage backend is browser `localStorage` when available, otherwise import { MemoryStorageManager, OMSClient } from '@0xsequence/typescript-sdk' const oms = new OMSClient({ - publicApiKey: 'your-public-api-key', + publishableKey: 'your-publishable-key', projectId: 'your-project-id', storage: new MemoryStorageManager(), }) diff --git a/examples/node-contract-deploy-example/.env.example b/examples/node-contract-deploy-example/.env.example index 531431c..08c0ba0 100644 --- a/examples/node-contract-deploy-example/.env.example +++ b/examples/node-contract-deploy-example/.env.example @@ -1,3 +1,3 @@ -OMS_PUBLIC_API_KEY=your-public-api-key +OMS_PUBLISHABLE_KEY=your-publishable-key OMS_PROJECT_ID=your-oms-project-id # DEPLOY_SALT=0x0000000000000000000000000000000000000000000000000000000000000001 diff --git a/examples/node-contract-deploy-example/README.md b/examples/node-contract-deploy-example/README.md index d2c8ad9..fd5a793 100644 --- a/examples/node-contract-deploy-example/README.md +++ b/examples/node-contract-deploy-example/README.md @@ -32,7 +32,7 @@ From the repository root: pnpm install pnpm build cp examples/node-contract-deploy-example/.env.example examples/node-contract-deploy-example/.env.local -# Fill OMS_PUBLIC_API_KEY and OMS_PROJECT_ID in .env.local +# Fill OMS_PUBLISHABLE_KEY and OMS_PROJECT_ID in .env.local pnpm dev:node-contract-deploy-example ``` diff --git a/examples/node-contract-deploy-example/deployErc20.ts b/examples/node-contract-deploy-example/deployErc20.ts index 340da46..d71f84b 100644 --- a/examples/node-contract-deploy-example/deployErc20.ts +++ b/examples/node-contract-deploy-example/deployErc20.ts @@ -13,7 +13,7 @@ const exampleDir = dirname(fileURLToPath(import.meta.url)); loadDotenv({path: join(exampleDir, ".env.local"), quiet: true}); loadDotenv({path: join(exampleDir, ".env"), quiet: true}); -const publicApiKey = requiredEnv("OMS_PUBLIC_API_KEY", process.env.OMS_PUBLIC_API_KEY); +const publishableKey = requiredEnv("OMS_PUBLISHABLE_KEY", process.env.OMS_PUBLISHABLE_KEY); const projectId = requiredEnv("OMS_PROJECT_ID", process.env.OMS_PROJECT_ID); const defaultDeployerAddress = "0xce0042B868300000d44A59004Da54A005ffdcf9f" as const satisfies Address; const deployerAddress = optionalAddress("DEPLOYER_ADDRESS", process.env.DEPLOYER_ADDRESS) ?? defaultDeployerAddress; @@ -39,12 +39,12 @@ async function main() { console.log(" OMS wallet ERC-20 deploy example"); console.log("------------------------------------------------------------"); console.log("network :", `${Networks.amoy.displayName} (${Networks.amoy.id})`); - console.log("public API key :", mask(publicApiKey)); + console.log("publishable key :", mask(publishableKey)); console.log("deployer address :", deployerAddress); console.log(); const client = new OMSClient({ - publicApiKey, + publishableKey, projectId, storage: new MemoryStorageManager(), }); diff --git a/examples/node/README.md b/examples/node/README.md index 0e6f534..0c6474a 100644 --- a/examples/node/README.md +++ b/examples/node/README.md @@ -11,7 +11,7 @@ Run it from the repository root: ```bash pnpm install pnpm build -OMS_PUBLIC_API_KEY=your-public-api-key OMS_PROJECT_ID=your-project-id pnpm dev:node-example +OMS_PUBLISHABLE_KEY=your-publishable-key OMS_PROJECT_ID=your-project-id pnpm dev:node-example ``` The example prompts for an email address, sends an OTP code, then prompts for the code. diff --git a/examples/node/signInFlow.ts b/examples/node/signInFlow.ts index bfc5714..14bfd81 100644 --- a/examples/node/signInFlow.ts +++ b/examples/node/signInFlow.ts @@ -1,14 +1,14 @@ import readline from "node:readline/promises"; import {MemoryStorageManager, Networks, OMSClient} from "@0xsequence/typescript-sdk"; -const publicApiKey = requiredEnv("OMS_PUBLIC_API_KEY", process.env.OMS_PUBLIC_API_KEY); +const publishableKey = requiredEnv("OMS_PUBLISHABLE_KEY", process.env.OMS_PUBLISHABLE_KEY); const projectId = requiredEnv("OMS_PROJECT_ID", process.env.OMS_PROJECT_ID); async function main() { console.log("------------------------------------------------------------"); console.log(" OmsWallet sign-in flow"); console.log("------------------------------------------------------------"); - console.log("public API key :", mask(publicApiKey)); + console.log("publishable key :", mask(publishableKey)); console.log(); const email = await prompt("Enter your email: "); @@ -17,7 +17,7 @@ async function main() { console.log("[setup] creating OmsWallet…"); const client = new OMSClient({ - publicApiKey, + publishableKey, projectId, storage: new MemoryStorageManager(), }); diff --git a/examples/react/.env.example b/examples/react/.env.example index 0ad1393..6316db9 100644 --- a/examples/react/.env.example +++ b/examples/react/.env.example @@ -1,2 +1,2 @@ -VITE_OMS_PUBLIC_API_KEY=your-public-api-key +VITE_OMS_PUBLISHABLE_KEY=your-publishable-key VITE_OMS_PROJECT_ID=your-oms-project-id diff --git a/examples/react/README.md b/examples/react/README.md index f36f262..aea350f 100644 --- a/examples/react/README.md +++ b/examples/react/README.md @@ -12,7 +12,7 @@ Run it from the repository root: pnpm install pnpm build cp examples/react/.env.example examples/react/.env.local -# Fill VITE_OMS_PUBLIC_API_KEY and VITE_OMS_PROJECT_ID +# Fill VITE_OMS_PUBLISHABLE_KEY and VITE_OMS_PROJECT_ID pnpm dev:example ``` @@ -20,11 +20,11 @@ The dev server runs at `http://localhost:5173`. The deployed example is available at `https://0xsequence.github.io/typescript-sdk/react-example`. -The example requires a public API key and project ID. Configure them locally before running the dev server: +The example requires a publishable key and project ID. Configure them locally before running the dev server: ```bash cp examples/react/.env.example examples/react/.env.local -# Fill VITE_OMS_PUBLIC_API_KEY and VITE_OMS_PROJECT_ID +# Fill VITE_OMS_PUBLISHABLE_KEY and VITE_OMS_PROJECT_ID ``` The Amoy-only "ERC20 example" panel includes a WalletKit Dollar example using diff --git a/examples/react/src/config.ts b/examples/react/src/config.ts index ea003e9..eb4d77c 100644 --- a/examples/react/src/config.ts +++ b/examples/react/src/config.ts @@ -1,4 +1,4 @@ -export const PUBLIC_API_KEY = requiredEnv('VITE_OMS_PUBLIC_API_KEY', import.meta.env.VITE_OMS_PUBLIC_API_KEY) +export const PUBLISHABLE_KEY = requiredEnv('VITE_OMS_PUBLISHABLE_KEY', import.meta.env.VITE_OMS_PUBLISHABLE_KEY) export const PROJECT_ID = requiredEnv('VITE_OMS_PROJECT_ID', import.meta.env.VITE_OMS_PROJECT_ID) function requiredEnv(name: string, value: string | undefined): string { diff --git a/examples/react/src/omsClient.ts b/examples/react/src/omsClient.ts index 26b9fe0..d85a6f3 100644 --- a/examples/react/src/omsClient.ts +++ b/examples/react/src/omsClient.ts @@ -1,7 +1,7 @@ import { OMSClient } from '@0xsequence/typescript-sdk' -import { PROJECT_ID, PUBLIC_API_KEY } from './config' +import { PROJECT_ID, PUBLISHABLE_KEY } from './config' export const oms = new OMSClient({ - publicApiKey: PUBLIC_API_KEY, + publishableKey: PUBLISHABLE_KEY, projectId: PROJECT_ID, }) diff --git a/examples/react/src/vite-env.d.ts b/examples/react/src/vite-env.d.ts index aa51999..37fee95 100644 --- a/examples/react/src/vite-env.d.ts +++ b/examples/react/src/vite-env.d.ts @@ -1,7 +1,7 @@ /// interface ImportMetaEnv { - readonly VITE_OMS_PUBLIC_API_KEY?: string + readonly VITE_OMS_PUBLISHABLE_KEY?: string readonly VITE_OMS_PROJECT_ID?: string } diff --git a/examples/trails-actions/.env.example b/examples/trails-actions/.env.example index f99841c..83de793 100644 --- a/examples/trails-actions/.env.example +++ b/examples/trails-actions/.env.example @@ -1,2 +1,2 @@ -VITE_OMS_PUBLIC_API_KEY= +VITE_OMS_PUBLISHABLE_KEY= VITE_OMS_PROJECT_ID= diff --git a/examples/trails-actions/README.md b/examples/trails-actions/README.md index 948e6d6..d096842 100644 --- a/examples/trails-actions/README.md +++ b/examples/trails-actions/README.md @@ -12,7 +12,7 @@ Run it from the repository root: pnpm install pnpm build cp examples/trails-actions/.env.example examples/trails-actions/.env.local -# Fill VITE_OMS_PUBLIC_API_KEY and VITE_OMS_PROJECT_ID +# Fill VITE_OMS_PUBLISHABLE_KEY and VITE_OMS_PROJECT_ID pnpm dev:trails-actions-example ``` diff --git a/examples/trails-actions/src/config.ts b/examples/trails-actions/src/config.ts index 6a045fe..09ca60c 100644 --- a/examples/trails-actions/src/config.ts +++ b/examples/trails-actions/src/config.ts @@ -1,4 +1,4 @@ -export const PUBLIC_API_KEY = requiredEnv('VITE_OMS_PUBLIC_API_KEY', import.meta.env.VITE_OMS_PUBLIC_API_KEY) +export const PUBLISHABLE_KEY = requiredEnv('VITE_OMS_PUBLISHABLE_KEY', import.meta.env.VITE_OMS_PUBLISHABLE_KEY) export const PROJECT_ID = requiredEnv('VITE_OMS_PROJECT_ID', import.meta.env.VITE_OMS_PROJECT_ID) function requiredEnv(name: string, value: string | undefined): string { diff --git a/examples/trails-actions/src/omsClient.ts b/examples/trails-actions/src/omsClient.ts index 26b9fe0..d85a6f3 100644 --- a/examples/trails-actions/src/omsClient.ts +++ b/examples/trails-actions/src/omsClient.ts @@ -1,7 +1,7 @@ import { OMSClient } from '@0xsequence/typescript-sdk' -import { PROJECT_ID, PUBLIC_API_KEY } from './config' +import { PROJECT_ID, PUBLISHABLE_KEY } from './config' export const oms = new OMSClient({ - publicApiKey: PUBLIC_API_KEY, + publishableKey: PUBLISHABLE_KEY, projectId: PROJECT_ID, }) diff --git a/examples/trails-actions/src/vite-env.d.ts b/examples/trails-actions/src/vite-env.d.ts index aa51999..37fee95 100644 --- a/examples/trails-actions/src/vite-env.d.ts +++ b/examples/trails-actions/src/vite-env.d.ts @@ -1,7 +1,7 @@ /// interface ImportMetaEnv { - readonly VITE_OMS_PUBLIC_API_KEY?: string + readonly VITE_OMS_PUBLISHABLE_KEY?: string readonly VITE_OMS_PROJECT_ID?: string } diff --git a/src/clients/indexerClient.ts b/src/clients/indexerClient.ts index 85cb0a9..39eadf3 100644 --- a/src/clients/indexerClient.ts +++ b/src/clients/indexerClient.ts @@ -155,15 +155,15 @@ export interface OmsEnvironment { } export class IndexerClient { - private readonly publicApiKey: string; + private readonly publishableKey: string; private readonly environment: OmsEnvironment; private readonly client: HttpClient; constructor(params: { - publicApiKey: string, + publishableKey: string, environment: OmsEnvironment }) { - this.publicApiKey = params.publicApiKey; + this.publishableKey = params.publishableKey; this.environment = params.environment; this.client = new HttpClient(); } @@ -284,7 +284,7 @@ export class IndexerClient { private defaultHeaders(): Record { return { - "X-Access-Key": this.publicApiKey, + "X-Access-Key": this.publishableKey, Accept: "application/json", }; } diff --git a/src/clients/walletClient.ts b/src/clients/walletClient.ts index d2b0f37..ab1d6da 100644 --- a/src/clients/walletClient.ts +++ b/src/clients/walletClient.ts @@ -336,7 +336,7 @@ export class WalletClient { private walletId: string constructor(params: { - publicApiKey: string, + publishableKey: string, projectId: string, environment: Env, storage?: StorageManager @@ -366,14 +366,14 @@ export class WalletClient { this.sessionEmail = undefined } - const signedFetch = createSignedFetch(params.publicApiKey, this.credentialSigner, this.projectId) + const signedFetch = createSignedFetch(params.publishableKey, this.credentialSigner, this.projectId) this.client = new Walletclient(params.environment.walletApiUrl, signedFetch) this.publicClient = new WalletPublicclient( params.environment.walletApiUrl, - createAccessKeyFetch(params.publicApiKey), + createAccessKeyFetch(params.publishableKey), ) this.indexerClient = new IndexerClient({ - publicApiKey: params.publicApiKey, + publishableKey: params.publishableKey, environment: params.environment, }) } @@ -1604,12 +1604,12 @@ function defaultRedirectAuthStorage(): StorageManager | undefined { : undefined } -function createAccessKeyFetch(publicApiKey: string): Fetch { +function createAccessKeyFetch(publishableKey: string): Fetch { return async (input: RequestInfo, init?: RequestInit): Promise => { const existingHeaders = (init?.headers ?? {}) as Record const headers: Record = { ...existingHeaders, - 'X-Access-Key': publicApiKey, + 'X-Access-Key': publishableKey, } return globalThis.fetch(input, {...init, headers}) diff --git a/src/omsClient.ts b/src/omsClient.ts index 8e59f12..1b4ae42 100644 --- a/src/omsClient.ts +++ b/src/omsClient.ts @@ -6,7 +6,7 @@ import type {CredentialSigner} from "./credentialSigner.js"; import {supportedNetworks} from "./networks.js"; interface OMSClientBaseParams { - publicApiKey: string; + publishableKey: string; projectId: string; storage?: StorageManager; redirectAuthStorage?: StorageManager; @@ -28,7 +28,7 @@ class OMSClientImpl { const storage = params.storage ?? createDefaultStorage() this.wallet = new WalletClient({ - publicApiKey: params.publicApiKey, + publishableKey: params.publishableKey, projectId: params.projectId, environment, storage, @@ -37,7 +37,7 @@ class OMSClientImpl { }); this.indexer = new IndexerClient({ - publicApiKey: params.publicApiKey, + publishableKey: params.publishableKey, environment }); } diff --git a/src/signedFetch.ts b/src/signedFetch.ts index b901741..3ad4df0 100644 --- a/src/signedFetch.ts +++ b/src/signedFetch.ts @@ -16,7 +16,7 @@ async function buildWalletSignatureHeader( } export function createSignedFetch( - publicApiKey: string, + publishableKey: string, signer: CredentialSigner, projectId: string, ): Fetch { @@ -32,7 +32,7 @@ export function createSignedFetch( const existingHeaders = (init?.headers ?? {}) as Record const headers: Record = { ...existingHeaders, - 'X-Access-Key': publicApiKey, + 'X-Access-Key': publishableKey, 'OMS-Wallet-Signature': signatureHeader, } diff --git a/tests/credentialSigner.test.ts b/tests/credentialSigner.test.ts index 6c1def5..de097f7 100644 --- a/tests/credentialSigner.test.ts +++ b/tests/credentialSigner.test.ts @@ -33,7 +33,7 @@ describe("wallet request signing", () => { const fetchMock = vi.fn(async () => new Response("{}", {status: 200})); vi.stubGlobal("fetch", fetchMock); - const signedFetch = createSignedFetch("public-api-key", signer, "project-id"); + const signedFetch = createSignedFetch("publishable-key", signer, "project-id"); await signedFetch("https://wallet.example/rpc/Wallet/CommitVerifier", { method: "POST", body, @@ -48,7 +48,7 @@ describe("wallet request signing", () => { const headers = fetchMock.mock.calls[0][1]?.headers as Record; expect(headers).toMatchObject({ - "X-Access-Key": "public-api-key", + "X-Access-Key": "publishable-key", "OMS-Wallet-Signature": `alg="ecdsa-p256-sha256", scope="project-id", cred="0x04${"11".repeat(64)}", nonce=42, sig="0x${"22".repeat(64)}"`, }); }); diff --git a/tests/indexerClient.test.ts b/tests/indexerClient.test.ts index 24d31c5..ebde7e2 100644 --- a/tests/indexerClient.test.ts +++ b/tests/indexerClient.test.ts @@ -31,7 +31,7 @@ describe("IndexerClient", () => { vi.stubGlobal("fetch", fetchMock); const indexer = new IndexerClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", environment: testEnvironment(), }); @@ -68,7 +68,7 @@ describe("IndexerClient", () => { vi.stubGlobal("fetch", fetchMock); const indexer = new IndexerClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", environment: testEnvironment(), }); @@ -89,7 +89,7 @@ describe("IndexerClient", () => { vi.stubGlobal("fetch", vi.fn(async () => new Response("Bad Gateway", {status: 502}))); const indexer = new IndexerClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", environment: testEnvironment(), }); diff --git a/tests/networks.test.ts b/tests/networks.test.ts index 6a9c6c2..a7ffbc5 100644 --- a/tests/networks.test.ts +++ b/tests/networks.test.ts @@ -50,7 +50,7 @@ describe("Networks", () => { it("is available from OMSClient", () => { const oms = new OMSClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", }); diff --git a/tests/oidcRedirectAuth.test.ts b/tests/oidcRedirectAuth.test.ts index 39c66e1..4cf6061 100644 --- a/tests/oidcRedirectAuth.test.ts +++ b/tests/oidcRedirectAuth.test.ts @@ -651,7 +651,7 @@ function createWalletClient { const environment = params.environment ?? testEnvironment() as Env; return new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: params.projectId ?? "project-id", environment, storage: new MemoryStorageManager(), diff --git a/tests/walletAccess.test.ts b/tests/walletAccess.test.ts index 33004ba..e775dac 100644 --- a/tests/walletAccess.test.ts +++ b/tests/walletAccess.test.ts @@ -93,7 +93,7 @@ describe("WalletClient access management", () => { function createWalletWithSession(): WalletClient { const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), diff --git a/tests/walletErrors.test.ts b/tests/walletErrors.test.ts index f645d4a..2b85563 100644 --- a/tests/walletErrors.test.ts +++ b/tests/walletErrors.test.ts @@ -32,7 +32,7 @@ afterEach(() => { describe("WalletClient errors", () => { it("wraps local validation failures separately from request failures", async () => { const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -53,7 +53,7 @@ describe("WalletClient errors", () => { vi.stubGlobal("fetch", vi.fn(async () => new Response("Bad Gateway", {status: 502}))); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -85,7 +85,7 @@ describe("WalletClient errors", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), diff --git a/tests/walletSession.test.ts b/tests/walletSession.test.ts index a49b3f7..69cde79 100644 --- a/tests/walletSession.test.ts +++ b/tests/walletSession.test.ts @@ -50,7 +50,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("localStorage", undefined); const client = new OMSClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), credentialSigner: new MockSigner(), @@ -68,7 +68,7 @@ describe("WalletClient session storage", () => { storage.set(Constants.sessionEmailStorageKey, "user@example.com"); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, @@ -93,7 +93,7 @@ describe("WalletClient session storage", () => { const redirectAuthStorage = new MemoryStorageManager(); redirectAuthStorage.set(Constants.redirectAuthStorageKey, JSON.stringify({verifier: "old-verifier"})); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, @@ -153,7 +153,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, @@ -182,7 +182,7 @@ describe("WalletClient session storage", () => { storage.set(Constants.sessionEmailStorageKey, "user@example.com"); const client = new OMSClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, @@ -238,7 +238,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, @@ -291,7 +291,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -358,7 +358,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -419,7 +419,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -474,7 +474,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -533,7 +533,7 @@ describe("WalletClient session storage", () => { const storage = new MemoryStorageManager(); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, @@ -601,7 +601,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -643,7 +643,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -698,7 +698,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -750,7 +750,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -795,7 +795,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -846,7 +846,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -897,7 +897,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -948,7 +948,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -979,7 +979,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -1020,7 +1020,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, @@ -1072,7 +1072,7 @@ describe("WalletClient session storage", () => { const storage = new MemoryStorageManager(); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, @@ -1117,7 +1117,7 @@ describe("WalletClient session storage", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), diff --git a/tests/walletSigning.test.ts b/tests/walletSigning.test.ts index 822da27..431c44b 100644 --- a/tests/walletSigning.test.ts +++ b/tests/walletSigning.test.ts @@ -37,7 +37,7 @@ describe("WalletClient signing", () => { const body = JSON.parse(init?.body as string); const headers = init?.headers as Record; - expect(headers["X-Access-Key"]).toBe("public-api-key"); + expect(headers["X-Access-Key"]).toBe("publishable-key"); expect(headers["OMS-Wallet-Signature"]).toContain('alg="ecdsa-p256-sha256"'); expect(headers.Authorization).toBeUndefined(); @@ -95,7 +95,7 @@ describe("WalletClient signing", () => { const url = input.toString(); const body = JSON.parse(init?.body as string); - expect((init?.headers as Record)["X-Access-Key"]).toBe("public-api-key"); + expect((init?.headers as Record)["X-Access-Key"]).toBe("publishable-key"); const headers = init?.headers as Record; expect(headers["OMS-Wallet-Signature"]).toContain('alg="ecdsa-p256-sha256"'); expect(headers.Authorization).toBeUndefined(); @@ -136,7 +136,7 @@ describe("WalletClient signing", () => { const body = JSON.parse(init?.body as string); const headers = init?.headers as Record; - expect(headers["X-Access-Key"]).toBe("public-api-key"); + expect(headers["X-Access-Key"]).toBe("publishable-key"); expect(headers["OMS-Wallet-Signature"]).toBeUndefined(); expect(headers.Authorization).toBeUndefined(); @@ -183,7 +183,7 @@ describe("WalletClient signing", () => { function createWalletWithSession(walletAddress: string): WalletClient { const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), diff --git a/tests/walletTransactions.test.ts b/tests/walletTransactions.test.ts index 6b4e985..3be80ca 100644 --- a/tests/walletTransactions.test.ts +++ b/tests/walletTransactions.test.ts @@ -218,7 +218,7 @@ describe("WalletClient transactions", () => { vi.stubGlobal("fetch", fetchMock); const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage: new MemoryStorageManager(), @@ -277,7 +277,7 @@ describe("WalletClient transactions", () => { function createWalletWithSession(storage: MemoryStorageManager, walletAddress: string): WalletClient { const wallet = new WalletClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: testEnvironment(), storage, diff --git a/type-tests/oidcProviderTypes.ts b/type-tests/oidcProviderTypes.ts index 6951636..0c2a209 100644 --- a/type-tests/oidcProviderTypes.ts +++ b/type-tests/oidcProviderTypes.ts @@ -66,17 +66,19 @@ if (false) { } const defaultClient = new OMSClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", }); -// @ts-expect-error publicApiKey is required. +// @ts-expect-error publishableKey is required. new OMSClient({projectId: "project-id"}); // @ts-expect-error projectId is required. -new OMSClient({publicApiKey: "public-api-key"}); +new OMSClient({publishableKey: "publishable-key"}); // @ts-expect-error old projectAccessKey initializer name is not supported. -new OMSClient({projectAccessKey: "public-api-key", projectId: "project-id"}); +new OMSClient({projectAccessKey: "publishable-key", projectId: "project-id"}); +// @ts-expect-error old publicApiKey initializer name is not supported. +new OMSClient({publicApiKey: "publishable-key", projectId: "project-id"}); // @ts-expect-error old authorizationScope initializer name is not supported. -new OMSClient({publicApiKey: "public-api-key", authorizationScope: "project-id"}); +new OMSClient({publishableKey: "publishable-key", authorizationScope: "project-id"}); const session: OMSClientSessionState = defaultClient.wallet.session; const idTokenParams: GetIdTokenParams = {ttlSeconds: 300, customClaims: {role: "admin"}}; const idToken: Promise = defaultClient.wallet.getIdToken(idTokenParams); @@ -164,7 +166,7 @@ const customEnvironmentWithoutProviders = defineOmsEnvironment({ indexerUrlTemplate: "https://indexer.example/{value}", }); const customClient = new OMSClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: customEnvironmentWithoutProviders, }); @@ -178,7 +180,7 @@ void customClient.wallet.startOidcRedirectAuth({ }); function createClient(params: { - publicApiKey: string; + publishableKey: string; projectId: string; environment?: OmsEnvironment; }) { @@ -186,11 +188,11 @@ function createClient(params: { } void createClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", }); void createClient({ - publicApiKey: "public-api-key", + publishableKey: "publishable-key", projectId: "project-id", environment: customEnvironmentWithoutProviders, });