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
47 changes: 39 additions & 8 deletions apps/docs/docs/pages/account/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ Type: `AccountConfig`
| `chainId` | `number` | Yes | Chain ID for the account |
| `apiKey` | `string` | Yes | API key for JAW services |
| `paymasterUrl` | `string` | No | Custom paymaster URL for gas sponsorship |
| `paymasterContext` | `Record<string, unknown>` | No | Custom paymaster context for gas sponsorship |
| `storage` | `SyncStorage` | No | Custom storage implementation (defaults to localStorage on web, in-memory fallback in React Native) |
| `nativeGetFn` | `NativePasskeyGetFn` | No | Native passkey get function for React Native (e.g. `Passkey.get`). See [React Native Usage](#react-native-usage). |
| `nativeCreateFn` | `NativePasskeyCreateFn` | No | Native passkey create function for React Native (e.g. `Passkey.create`). See [React Native Usage](#react-native-usage). |
| `rpId` | `string` | No | Relying party identifier (defaults to `window.location.hostname`). **Required in React Native.** |
| `rpName` | `string` | No | Relying party name (defaults to `'JAW'`) |

### options

Expand All @@ -34,8 +40,6 @@ Type: `CreateAccountOptions`
| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `username` | `string` | Yes | Username/display name for the passkey |
| `rpId` | `string` | No | Relying party identifier (defaults to `window.location.hostname`) |
| `rpName` | `string` | No | Relying party name (defaults to `'JAW'`) |


## Returns
Expand Down Expand Up @@ -79,12 +83,8 @@ console.log('Username:', account.getMetadata()?.username);

```typescript
const account = await Account.create(
{ chainId: 1, apiKey: 'your-api-key' },
{
username: 'alice',
rpId: 'myapp.com',
rpName: 'My Awesome App',
}
{ chainId: 1, apiKey: 'your-api-key', rpId: 'myapp.com', rpName: 'My Awesome App' },
{ username: 'alice' }
);
```

Expand Down Expand Up @@ -119,6 +119,37 @@ class MyUIHandler implements UIHandler {
```


## React Native Usage

In React Native, `window` and `navigator.credentials` are unavailable. Pass `Passkey.get` and `Passkey.create` from [`react-native-passkey`](https://github.com/f-23/react-native-passkey) directly in `config` — JAW handles all format conversion, challenge generation, and public key extraction internally.

:::warning[Storage in React Native]
Without a custom `storage`, JAW falls back to an in-memory store that does **not** persist across app restarts. Pass a `SyncStorage` implementation backed by MMKV or similar for durable persistence.
:::

```typescript
import { Account } from '@jaw.id/core';
import { Passkey } from 'react-native-passkey';
import type { SyncStorage } from '@jaw.id/core';

// Your SyncStorage backed by MMKV or similar
const storage: SyncStorage = { /* ... */ };

// Configure once — all RN options live in config
const config = {
chainId: 8453,
apiKey: 'your-api-key',
storage,
nativeGetFn: Passkey.get,
nativeCreateFn: Passkey.create,
rpId: 'myapp.com',
rpName: 'My App',
};

const account = await Account.create(config, { username: 'alice' });
```


## Related

- [Account.get()](/account/get) - Login with existing account
Expand Down
29 changes: 29 additions & 0 deletions apps/docs/docs/pages/account/get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Type: `AccountConfig`
| `chainId` | `number` | Yes | Chain ID for the account |
| `apiKey` | `string` | Yes | API key for JAW services |
| `paymasterUrl` | `string` | No | Custom paymaster URL for gas sponsorship |
| `paymasterContext` | `Record<string, unknown>` | No | Custom paymaster context for gas sponsorship |
| `storage` | `SyncStorage` | No | Custom storage implementation (defaults to localStorage on web, in-memory fallback in React Native) |
| `nativeGetFn` | `NativePasskeyGetFn` | No | Native passkey get function for React Native (e.g. `Passkey.get`). |
| `rpId` | `string` | No | Relying party identifier. **Required in React Native.** |

### credentialId

Expand Down Expand Up @@ -96,6 +100,31 @@ if (accounts.length > 0) {
```


## React Native Usage

Pass `Passkey.get` from [`react-native-passkey`](https://github.com/f-23/react-native-passkey) as `nativeGetFn` and an explicit `rpId` in `config`. JAW handles all base64url ↔ ArrayBuffer conversion internally.

```typescript
import { Account } from '@jaw.id/core';
import { Passkey } from 'react-native-passkey';

const config = {
chainId: 8453,
apiKey: 'your-api-key',
storage,
nativeGetFn: Passkey.get,
rpId: 'myapp.com',
};

// Restore existing session (no passkey prompt)
const account = await Account.get(config);

// Login with specific credential (triggers native passkey prompt)
const stored = Account.getStoredAccounts('your-api-key', storage);
const account = await Account.get(config, stored[0].credentialId);
```


## Related

- [Account.create()](/account/create) - Create a new account
Expand Down
26 changes: 25 additions & 1 deletion apps/docs/docs/pages/account/import.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Import a passkey from cloud backup.
## Signature

```typescript
static async import(config: AccountConfig): Promise<Account>
static async import(
config: AccountConfig
): Promise<Account>
```


Expand All @@ -23,6 +25,10 @@ Type: `AccountConfig`
| `chainId` | `number` | Yes | Chain ID for the account |
| `apiKey` | `string` | Yes | API key for JAW services |
| `paymasterUrl` | `string` | No | Custom paymaster URL for gas sponsorship |
| `paymasterContext` | `Record<string, unknown>` | No | Custom paymaster context for gas sponsorship |
| `storage` | `SyncStorage` | No | Custom storage implementation (defaults to localStorage on web, in-memory fallback in React Native) |
| `nativeGetFn` | `NativePasskeyGetFn` | No | Native passkey get function for React Native (e.g. `Passkey.get`). |
| `rpId` | `string` | No | Relying party identifier. **Required in React Native.** |


## Returns
Expand Down Expand Up @@ -105,6 +111,24 @@ Passkeys can be synced via:
The import flow allows users to access their JAW account on any device where their passkeys are synced.


## React Native Usage

Pass `Passkey.get` from [`react-native-passkey`](https://github.com/f-23/react-native-passkey) as `nativeGetFn` and an explicit `rpId` in `config`. JAW handles all base64url ↔ ArrayBuffer conversion internally.

```typescript
import { Account } from '@jaw.id/core';
import { Passkey } from 'react-native-passkey';

const account = await Account.import({
chainId: 8453,
apiKey: 'your-api-key',
storage,
nativeGetFn: Passkey.get,
rpId: 'myapp.com',
});
```


## Related

- [Account.create()](/account/create) - Create a new account
Expand Down
22 changes: 17 additions & 5 deletions apps/docs/docs/pages/account/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The `Account` class is ideal for:

- **AI Agents** - Issue programmable smart wallets for AI agents
- **Headless Integration** - No UI required, direct programmatic access
- **React Native** - Native mobile passkey support via `nativeGetFn` and `nativeCreateFn`
- **Server-side Applications** - Using `fromLocalAccount()` with embedded wallets (Privy, Dynamic, Turnkey)
- **Custom UI Handlers** - When implementing your own `UIHandler` for app-specific mode
- **Direct Integration** - When you need fine-grained control over account operations
Expand Down Expand Up @@ -46,6 +47,9 @@ The `Account` class is exported from `@jaw.id/core`:

```typescript
import { Account } from '@jaw.id/core';

// React Native: also import adapter types
import type { NativePasskeyGetFn, NativePasskeyCreateFn, SyncStorage } from '@jaw.id/core';
```


Expand Down Expand Up @@ -118,7 +122,7 @@ Utility methods:

### AccountConfig

Configuration for creating or loading an account:
Configuration for creating or loading an account. React Native options (`nativeGetFn`, `nativeCreateFn`, `rpId`) are configured once here and shared across all static methods.

```typescript
interface AccountConfig {
Expand All @@ -130,6 +134,16 @@ interface AccountConfig {
paymasterUrl?: string;
/** Custom paymaster context for gas sponsorship */
paymasterContext?: Record<string, unknown>;
/** Custom storage implementation (defaults to localStorage on web, in-memory fallback in React Native) */
storage?: SyncStorage;
/** Native passkey get function for React Native (e.g. Passkey.get) */
nativeGetFn?: NativePasskeyGetFn;
/** Native passkey create function for React Native (e.g. Passkey.create) */
nativeCreateFn?: NativePasskeyCreateFn;
/** Relying party identifier (defaults to window.location.hostname). Required in React Native. */
rpId?: string;
/** Relying party name (defaults to 'JAW') */
rpName?: string;
}
```

Expand All @@ -141,10 +155,6 @@ Options for creating a new account:
interface CreateAccountOptions {
/** Username/display name for the passkey */
username: string;
/** Relying party identifier (defaults to window.location.hostname) */
rpId?: string;
/** Relying party name (defaults to 'JAW') */
rpName?: string;
}
```

Expand All @@ -171,6 +181,8 @@ Account metadata returned by `getMetadata()`:
interface AccountMetadata {
/** Username/display name */
username: string;
/** Credential ID of the passkey */
credentialId: string;
/** ISO date string when created */
creationDate: string;
/** Whether imported from cloud */
Expand Down
28 changes: 28 additions & 0 deletions apps/docs/docs/pages/account/restore.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Type: `AccountConfig`
| `apiKey` | `string` | Yes | API key for JAW services |
| `paymasterUrl` | `string` | No | Custom paymaster URL for gas sponsorship |
| `paymasterContext` | `Record<string, unknown>` | No | Custom paymaster context |
| `storage` | `SyncStorage` | No | Custom storage implementation (defaults to localStorage on web, in-memory fallback in React Native) |
| `nativeGetFn` | `NativePasskeyGetFn` | No | Native passkey get function for React Native (e.g. `Passkey.get`). |
| `rpId` | `string` | No | Relying party identifier. **Required in React Native.** |

### credentialId

Expand Down Expand Up @@ -100,6 +103,31 @@ async function handleSignRequest(credentialId: string, publicKey: `0x${string}`)
```


## React Native Usage

Pass `Passkey.get` from [`react-native-passkey`](https://github.com/f-23/react-native-passkey) as `nativeGetFn` and an explicit `rpId` in `config` so signing operations use the native passkey prompt. JAW handles all base64url ↔ ArrayBuffer conversion internally.

```typescript
import { Account } from '@jaw.id/core';
import { Passkey } from 'react-native-passkey';

const account = await Account.restore(
{
chainId: 8453,
apiKey: 'your-api-key',
storage,
nativeGetFn: Passkey.get,
rpId: 'myapp.com',
},
credentialId,
publicKey,
);

// Signing triggers the native passkey prompt via nativeGetFn
const signature = await account.signMessage('Hello');
```


## Related

- [Account.get()](/account/get) - Get account with optional WebAuthn prompt
Expand Down
1 change: 0 additions & 1 deletion apps/keys-jaw-id/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
4 changes: 2 additions & 2 deletions apps/keys-jaw-id/src/lib/passkey-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ export class PasskeyService {
{
chainId: this.getDefaultChainId(),
apiKey: this.apiKey,
rpId: this.rpId,
rpName: this.rpName,
},
{
username,
rpId: this.rpId,
rpName: this.rpName,
}
);

Expand Down
Loading
Loading