Skip to content
Merged
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 .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
})
```
Expand All @@ -82,7 +82,7 @@ const oms = new OMSClient({

```typescript
new OMSClient(params: {
publicApiKey: string
publishableKey: string
projectId: string
environment?: OmsEnvironment
storage?: StorageManager
Expand All @@ -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`. |
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
})
```
Expand All @@ -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),
})
```
Expand Down Expand Up @@ -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
```

Expand All @@ -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
```

Expand All @@ -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',
})

Expand Down Expand Up @@ -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',
})
```
Expand Down Expand Up @@ -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',
Expand All @@ -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(),
})
Expand Down
2 changes: 1 addition & 1 deletion examples/node-contract-deploy-example/.env.example
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion examples/node-contract-deploy-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
6 changes: 3 additions & 3 deletions examples/node-contract-deploy-example/deployErc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(),
});
Expand Down
2 changes: 1 addition & 1 deletion examples/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions examples/node/signInFlow.ts
Original file line number Diff line number Diff line change
@@ -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: ");
Expand All @@ -17,7 +17,7 @@ async function main() {
console.log("[setup] creating OmsWallet…");

const client = new OMSClient({
publicApiKey,
publishableKey,
projectId,
storage: new MemoryStorageManager(),
});
Expand Down
2 changes: 1 addition & 1 deletion examples/react/.env.example
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions examples/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ 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
```

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
Expand Down
2 changes: 1 addition & 1 deletion examples/react/src/config.ts
Original file line number Diff line number Diff line change
@@ -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)
Comment thread
andygruening marked this conversation as resolved.
export const PROJECT_ID = requiredEnv('VITE_OMS_PROJECT_ID', import.meta.env.VITE_OMS_PROJECT_ID)

function requiredEnv(name: string, value: string | undefined): string {
Expand Down
4 changes: 2 additions & 2 deletions examples/react/src/omsClient.ts
Original file line number Diff line number Diff line change
@@ -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,
})
2 changes: 1 addition & 1 deletion examples/react/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_OMS_PUBLIC_API_KEY?: string
readonly VITE_OMS_PUBLISHABLE_KEY?: string
readonly VITE_OMS_PROJECT_ID?: string
}

Expand Down
2 changes: 1 addition & 1 deletion examples/trails-actions/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_OMS_PUBLIC_API_KEY=
VITE_OMS_PUBLISHABLE_KEY=
VITE_OMS_PROJECT_ID=
2 changes: 1 addition & 1 deletion examples/trails-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
2 changes: 1 addition & 1 deletion examples/trails-actions/src/config.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions examples/trails-actions/src/omsClient.ts
Original file line number Diff line number Diff line change
@@ -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,
})
2 changes: 1 addition & 1 deletion examples/trails-actions/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_OMS_PUBLIC_API_KEY?: string
readonly VITE_OMS_PUBLISHABLE_KEY?: string
readonly VITE_OMS_PROJECT_ID?: string
}

Expand Down
8 changes: 4 additions & 4 deletions src/clients/indexerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -284,7 +284,7 @@ export class IndexerClient {

private defaultHeaders(): Record<string, string> {
return {
"X-Access-Key": this.publicApiKey,
"X-Access-Key": this.publishableKey,
Accept: "application/json",
};
}
Expand Down
12 changes: 6 additions & 6 deletions src/clients/walletClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class WalletClient<Env extends OmsEnvironment = OmsEnvironment> {
private walletId: string

constructor(params: {
publicApiKey: string,
publishableKey: string,
projectId: string,
environment: Env,
storage?: StorageManager
Expand Down Expand Up @@ -366,14 +366,14 @@ export class WalletClient<Env extends OmsEnvironment = OmsEnvironment> {
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,
})
}
Expand Down Expand Up @@ -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<Response> => {
const existingHeaders = (init?.headers ?? {}) as Record<string, string>
const headers: Record<string, string> = {
...existingHeaders,
'X-Access-Key': publicApiKey,
'X-Access-Key': publishableKey,
}

return globalThis.fetch(input, {...init, headers})
Expand Down
6 changes: 3 additions & 3 deletions src/omsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +28,7 @@ class OMSClientImpl<Env extends OmsEnvironment = OmsEnvironment> {
const storage = params.storage ?? createDefaultStorage()

this.wallet = new WalletClient({
publicApiKey: params.publicApiKey,
publishableKey: params.publishableKey,
projectId: params.projectId,
environment,
storage,
Expand All @@ -37,7 +37,7 @@ class OMSClientImpl<Env extends OmsEnvironment = OmsEnvironment> {
});

this.indexer = new IndexerClient({
publicApiKey: params.publicApiKey,
publishableKey: params.publishableKey,
environment
});
}
Expand Down
Loading
Loading