@korajs/auth 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,148 +1,97 @@
1
- export { A as AuthClient, a as AuthClientConfig, b as AuthError, c as AuthState, d as AuthUser, C as ClientInvitation, e as ClientMembership, f as ClientOrganization, O as OrgClient, g as OrgClientConfig, h as OrgClientError } from './org-client-BVTLKcIk.cjs';
1
+ import { A as AuthClientConfig, a as AuthTokenStorage, b as AuthKeyValueStorage, c as AuthDeviceIdentityProvider, D as DeviceKeyStore, d as AuthClient, e as AuthState } from './create-org-session-RsDj9cl4.cjs';
2
+ export { f as AuthDeviceIdentity, g as AuthDeviceIdentityError, h as AuthError, i as AuthSession, j as AuthSessionSnapshot, k as AuthTokenStorageOptions, l as AuthUser, C as ClientInvitation, m as ClientMembership, n as ClientOrganization, o as DeviceKeyStoreError, I as InMemoryDeviceKeyStore, p as IndexedDBDeviceKeyStore, L as LinkedOAuthAccount, O as OAuthAuthorizationOptions, q as OAuthAuthorizationResult, r as OAuthCallbackParams, s as OrgClient, t as OrgClientConfig, u as OrgClientError, v as OrgSession, w as OrgSnapshot, P as PersistentDeviceIdentityOptions, x as checkOrgPermission, y as createAuthSession, z as createAuthTokenStorage, B as createDeviceKeyStore, E as createMemoryAuthTokenStorage, F as createOrgSession, G as createPersistentDeviceIdentity, H as createWebStorageAuthTokenStorage } from './create-org-session-RsDj9cl4.cjs';
3
+ import { SchemaDefinition, KoraError } from '@korajs/core';
4
+ import { AuthSyncBinding } from '@korajs/core/bindings';
5
+ export { AuthSyncBinding } from '@korajs/core/bindings';
2
6
  import { A as AuthTokens } from './operation-encryptor-DRmKNWpF.cjs';
3
7
  export { a as AuthConfig, b as AuthEvent, c as AuthEventType, d as AuthStatus, C as CryptoUnavailableError, D as DeviceIdentityError, O as OperationEncryptionError, e as OperationEncryptor, f as OperationEncryptorConfig, T as TokenPayload, g as TokenType, h as computePublicKeyThumbprint, i as exportPublicKeyJwk, j as fromBase64Url, k as generateDeviceKeyPair, l as isEncryptedField, s as signChallenge, t as toBase64Url, v as verifyChallenge } from './operation-encryptor-DRmKNWpF.cjs';
4
- import { KoraError } from '@korajs/core';
5
8
 
6
- /**
7
- * Thrown when a device key store operation fails.
8
- * Provides context about the operation and the underlying cause.
9
- */
10
- declare class DeviceKeyStoreError extends KoraError {
11
- constructor(message: string, context?: Record<string, unknown>);
12
- }
13
- /**
14
- * Persistent storage interface for ECDSA P-256 device key pairs.
15
- *
16
- * Device key pairs are used for proof-of-possession authentication:
17
- * the private key never leaves the device, and the public key is
18
- * registered with the server. This store persists key pairs across
19
- * page reloads and app restarts.
20
- *
21
- * In the browser, CryptoKey objects are structured-cloneable, so they
22
- * can be stored directly in IndexedDB without serialization. In Node.js
23
- * or test environments, an in-memory implementation is used instead.
24
- */
25
- interface DeviceKeyStore {
9
+ interface CreateKoraAuthOptions extends Omit<AuthClientConfig, 'storage' | 'deviceIdentity'> {
26
10
  /**
27
- * Persist a key pair for the given device.
28
- *
29
- * Overwrites any previously stored key pair for the same device ID.
30
- *
31
- * @param deviceId - The unique device identifier (typically a UUID v7)
32
- * @param keyPair - The ECDSA P-256 CryptoKeyPair to store
33
- * @throws {DeviceKeyStoreError} If the storage operation fails
11
+ * Complete token storage adapter. Use this for fully custom runtimes.
12
+ * If omitted, `credentialStore` is adapted automatically.
34
13
  */
35
- saveKeyPair(deviceId: string, keyPair: CryptoKeyPair): Promise<void>;
14
+ storage?: AuthTokenStorage;
36
15
  /**
37
- * Load a previously stored key pair for the given device.
38
- *
39
- * @param deviceId - The unique device identifier
40
- * @returns The stored CryptoKeyPair, or null if no key pair exists for the device
41
- * @throws {DeviceKeyStoreError} If the storage operation fails
16
+ * Runtime credential store used for tokens and stable device ID.
17
+ * Examples: Tauri secure storage, Expo SecureStore, iOS Keychain, Android Keystore.
42
18
  */
43
- loadKeyPair(deviceId: string): Promise<CryptoKeyPair | null>;
19
+ credentialStore?: AuthKeyValueStorage;
44
20
  /**
45
- * Delete a stored key pair for the given device.
46
- *
47
- * No-op if no key pair exists for the device ID.
48
- *
49
- * @param deviceId - The unique device identifier
50
- * @throws {DeviceKeyStoreError} If the storage operation fails
21
+ * Explicit device identity provider. Set to `false` to disable automatic
22
+ * device binding during sign-up/sign-in.
51
23
  */
52
- deleteKeyPair(deviceId: string): Promise<void>;
24
+ deviceIdentity?: AuthDeviceIdentityProvider | false;
53
25
  /**
54
- * Check whether a key pair exists for the given device.
55
- *
56
- * @param deviceId - The unique device identifier
57
- * @returns True if a key pair is stored for the device, false otherwise
58
- * @throws {DeviceKeyStoreError} If the storage operation fails
26
+ * Device key store for runtimes without IndexedDB, such as React Native.
59
27
  */
60
- hasKeyPair(deviceId: string): Promise<boolean>;
28
+ deviceKeyStore?: DeviceKeyStore;
61
29
  }
62
30
  /**
63
- * Browser-based device key store backed by IndexedDB.
64
- *
65
- * CryptoKey objects are structured-cloneable, so they can be stored
66
- * directly in IndexedDB without needing to export/import them as JWK.
67
- * This preserves the non-extractable flag on private keys, ensuring
68
- * they cannot be read even from storage.
31
+ * Create a production-shaped Kora auth client with minimal setup.
69
32
  *
70
- * The database uses a single object store (`keypairs`) with the device ID
71
- * as the key and the full CryptoKeyPair as the value.
72
- *
73
- * @example
74
- * ```typescript
75
- * const store = new IndexedDBDeviceKeyStore()
76
- * const keyPair = await generateDeviceKeyPair()
77
- * await store.saveKeyPair('device-123', keyPair)
33
+ * Defaults:
34
+ * - browser/Tauri WebView: localStorage for tokens, IndexedDB for device keys
35
+ * - desktop/mobile: pass `credentialStore` and optionally `deviceKeyStore`
36
+ * - automatic device identity is enabled when a persistent device ID store exists
37
+ */
38
+ declare function createKoraAuth(options: CreateKoraAuthOptions): AuthClient;
39
+
40
+ /**
41
+ * Minimal auth client surface required for sync integration.
42
+ * Matches {@link AuthClient} without importing implementation details.
43
+ */
44
+ interface AuthSyncClient {
45
+ getAccessToken(): Promise<string | null>;
46
+ onAuthChange?(callback: (state: AuthState) => void): () => void;
47
+ }
48
+ /**
49
+ * Sync binding returned by {@link createKoraAuthSync}.
50
+ * Passed to `createApp({ sync: { authClient } })` in korajs.
78
51
  *
79
- * const loaded = await store.loadKeyPair('device-123')
80
- * // loaded.privateKey is still non-extractable
81
- * ```
52
+ * @deprecated Use {@link AuthSyncBinding} from `@korajs/core/bindings` or `@korajs/auth`.
53
+ */
54
+ type KoraAuthSyncBinding = AuthSyncBinding;
55
+ /**
56
+ * Configuration for {@link createKoraAuthSync}.
82
57
  */
83
- declare class IndexedDBDeviceKeyStore implements DeviceKeyStore {
84
- private dbPromise;
58
+ interface CreateKoraAuthSyncOptions {
59
+ /** Kora auth client from `createKoraAuth()`. */
60
+ authClient: AuthSyncClient;
85
61
  /**
86
- * Opens (or creates) the IndexedDB database.
87
- *
88
- * The database connection is lazily initialized on first use and
89
- * reused for subsequent operations. If the database does not exist,
90
- * it is created with the `keypairs` object store.
62
+ * Application schema. When provided, scope maps are built automatically
63
+ * from JWT claims and schema scope declarations.
64
+ */
65
+ schema?: SchemaDefinition;
66
+ /**
67
+ * Custom claim → flat scope value mapping.
68
+ * Defaults to {@link extractScopeValuesFromClaims}.
91
69
  */
92
- private openDatabase;
93
- /** @inheritdoc */
94
- saveKeyPair(deviceId: string, keyPair: CryptoKeyPair): Promise<void>;
95
- /** @inheritdoc */
96
- loadKeyPair(deviceId: string): Promise<CryptoKeyPair | null>;
97
- /** @inheritdoc */
98
- deleteKeyPair(deviceId: string): Promise<void>;
99
- /** @inheritdoc */
100
- hasKeyPair(deviceId: string): Promise<boolean>;
70
+ scopeFromClaims?: (claims: Record<string, unknown>) => Record<string, unknown>;
101
71
  }
102
72
  /**
103
- * In-memory device key store for Node.js and testing environments.
73
+ * Creates a sync auth binding for `createApp({ sync: { authClient: binding } })`.
104
74
  *
105
- * Key pairs are stored in a plain Map and do not survive process restarts.
106
- * This is suitable for server-side rendering, Node.js scripts, and unit tests
107
- * where IndexedDB is not available.
75
+ * Wires token refresh, automatic scope maps from JWT claims, and device-bound
76
+ * sync node ids (`dev` claim) separate from the user id (`sub`).
108
77
  *
109
78
  * @example
110
79
  * ```typescript
111
- * const store = new InMemoryDeviceKeyStore()
112
- * const keyPair = await generateDeviceKeyPair()
113
- * await store.saveKeyPair('device-123', keyPair)
114
- *
115
- * const loaded = await store.loadKeyPair('device-123')
116
- * ```
117
- */
118
- declare class InMemoryDeviceKeyStore implements DeviceKeyStore {
119
- private readonly store;
120
- /** @inheritdoc */
121
- saveKeyPair(deviceId: string, keyPair: CryptoKeyPair): Promise<void>;
122
- /** @inheritdoc */
123
- loadKeyPair(deviceId: string): Promise<CryptoKeyPair | null>;
124
- /** @inheritdoc */
125
- deleteKeyPair(deviceId: string): Promise<void>;
126
- /** @inheritdoc */
127
- hasKeyPair(deviceId: string): Promise<boolean>;
128
- }
129
- /**
130
- * Creates a DeviceKeyStore appropriate for the current environment.
131
- *
132
- * In browsers where IndexedDB is available, returns an {@link IndexedDBDeviceKeyStore}
133
- * that persists CryptoKeyPair objects as structured clones. In Node.js, SSR,
134
- * or environments without IndexedDB, returns an {@link InMemoryDeviceKeyStore}.
80
+ * import { createKoraAuth, createKoraAuthSync } from '@korajs/auth'
81
+ * import { createApp } from 'korajs'
135
82
  *
136
- * @returns A DeviceKeyStore instance for the current environment
83
+ * const authClient = createKoraAuth({ serverUrl: 'https://api.example.com' })
137
84
  *
138
- * @example
139
- * ```typescript
140
- * const store = createDeviceKeyStore()
141
- * const keyPair = await generateDeviceKeyPair()
142
- * await store.saveKeyPair(deviceId, keyPair)
85
+ * const app = createApp({
86
+ * schema,
87
+ * sync: {
88
+ * url: 'wss://api.example.com/kora-sync',
89
+ * authClient: createKoraAuthSync({ authClient, schema }),
90
+ * },
91
+ * })
143
92
  * ```
144
93
  */
145
- declare function createDeviceKeyStore(): DeviceKeyStore;
94
+ declare function createKoraAuthSync(options: CreateKoraAuthSyncOptions): AuthSyncBinding;
146
95
 
147
96
  /**
148
97
  * Client-side token storage for Kora auth tokens.
@@ -780,4 +729,4 @@ declare class AutoLockManager {
780
729
  private _clearTimer;
781
730
  }
782
731
 
783
- export { AuthTokens, type AutoLockConfig, AutoLockManager, type DeviceKeyStore, DeviceKeyStoreError, EncryptedTokenStore, type EncryptedTokenStoreConfig, EncryptedTokenStoreError, EncryptionError, InMemoryDeviceKeyStore, IndexedDBDeviceKeyStore, KeyDerivationError, type PasskeyAuthenticationResponse, PasskeyError, type PasskeyRegistrationResponse, PasskeyUnsupportedError, TokenStore, authenticateWithPasskey, createDeviceKeyStore, createPasskeyCredential, decryptData, deriveEncryptionKey, encryptData, exportKey, generateEncryptionKey, generateSalt, importKey, isPasskeySupported, isPlatformAuthenticatorAvailable };
732
+ export { AuthClient, AuthClientConfig, AuthDeviceIdentityProvider, AuthKeyValueStorage, AuthState, type AuthSyncClient, AuthTokenStorage, AuthTokens, type AutoLockConfig, AutoLockManager, type CreateKoraAuthOptions, type CreateKoraAuthSyncOptions, DeviceKeyStore, EncryptedTokenStore, type EncryptedTokenStoreConfig, EncryptedTokenStoreError, EncryptionError, KeyDerivationError, type KoraAuthSyncBinding, type PasskeyAuthenticationResponse, PasskeyError, type PasskeyRegistrationResponse, PasskeyUnsupportedError, TokenStore, authenticateWithPasskey, createKoraAuth, createKoraAuthSync, createPasskeyCredential, decryptData, deriveEncryptionKey, encryptData, exportKey, generateEncryptionKey, generateSalt, importKey, isPasskeySupported, isPlatformAuthenticatorAvailable };
package/dist/index.d.ts CHANGED
@@ -1,148 +1,97 @@
1
- export { A as AuthClient, a as AuthClientConfig, b as AuthError, c as AuthState, d as AuthUser, C as ClientInvitation, e as ClientMembership, f as ClientOrganization, O as OrgClient, g as OrgClientConfig, h as OrgClientError } from './org-client-BVTLKcIk.js';
1
+ import { A as AuthClientConfig, a as AuthTokenStorage, b as AuthKeyValueStorage, c as AuthDeviceIdentityProvider, D as DeviceKeyStore, d as AuthClient, e as AuthState } from './create-org-session-RsDj9cl4.js';
2
+ export { f as AuthDeviceIdentity, g as AuthDeviceIdentityError, h as AuthError, i as AuthSession, j as AuthSessionSnapshot, k as AuthTokenStorageOptions, l as AuthUser, C as ClientInvitation, m as ClientMembership, n as ClientOrganization, o as DeviceKeyStoreError, I as InMemoryDeviceKeyStore, p as IndexedDBDeviceKeyStore, L as LinkedOAuthAccount, O as OAuthAuthorizationOptions, q as OAuthAuthorizationResult, r as OAuthCallbackParams, s as OrgClient, t as OrgClientConfig, u as OrgClientError, v as OrgSession, w as OrgSnapshot, P as PersistentDeviceIdentityOptions, x as checkOrgPermission, y as createAuthSession, z as createAuthTokenStorage, B as createDeviceKeyStore, E as createMemoryAuthTokenStorage, F as createOrgSession, G as createPersistentDeviceIdentity, H as createWebStorageAuthTokenStorage } from './create-org-session-RsDj9cl4.js';
3
+ import { SchemaDefinition, KoraError } from '@korajs/core';
4
+ import { AuthSyncBinding } from '@korajs/core/bindings';
5
+ export { AuthSyncBinding } from '@korajs/core/bindings';
2
6
  import { A as AuthTokens } from './operation-encryptor-DRmKNWpF.js';
3
7
  export { a as AuthConfig, b as AuthEvent, c as AuthEventType, d as AuthStatus, C as CryptoUnavailableError, D as DeviceIdentityError, O as OperationEncryptionError, e as OperationEncryptor, f as OperationEncryptorConfig, T as TokenPayload, g as TokenType, h as computePublicKeyThumbprint, i as exportPublicKeyJwk, j as fromBase64Url, k as generateDeviceKeyPair, l as isEncryptedField, s as signChallenge, t as toBase64Url, v as verifyChallenge } from './operation-encryptor-DRmKNWpF.js';
4
- import { KoraError } from '@korajs/core';
5
8
 
6
- /**
7
- * Thrown when a device key store operation fails.
8
- * Provides context about the operation and the underlying cause.
9
- */
10
- declare class DeviceKeyStoreError extends KoraError {
11
- constructor(message: string, context?: Record<string, unknown>);
12
- }
13
- /**
14
- * Persistent storage interface for ECDSA P-256 device key pairs.
15
- *
16
- * Device key pairs are used for proof-of-possession authentication:
17
- * the private key never leaves the device, and the public key is
18
- * registered with the server. This store persists key pairs across
19
- * page reloads and app restarts.
20
- *
21
- * In the browser, CryptoKey objects are structured-cloneable, so they
22
- * can be stored directly in IndexedDB without serialization. In Node.js
23
- * or test environments, an in-memory implementation is used instead.
24
- */
25
- interface DeviceKeyStore {
9
+ interface CreateKoraAuthOptions extends Omit<AuthClientConfig, 'storage' | 'deviceIdentity'> {
26
10
  /**
27
- * Persist a key pair for the given device.
28
- *
29
- * Overwrites any previously stored key pair for the same device ID.
30
- *
31
- * @param deviceId - The unique device identifier (typically a UUID v7)
32
- * @param keyPair - The ECDSA P-256 CryptoKeyPair to store
33
- * @throws {DeviceKeyStoreError} If the storage operation fails
11
+ * Complete token storage adapter. Use this for fully custom runtimes.
12
+ * If omitted, `credentialStore` is adapted automatically.
34
13
  */
35
- saveKeyPair(deviceId: string, keyPair: CryptoKeyPair): Promise<void>;
14
+ storage?: AuthTokenStorage;
36
15
  /**
37
- * Load a previously stored key pair for the given device.
38
- *
39
- * @param deviceId - The unique device identifier
40
- * @returns The stored CryptoKeyPair, or null if no key pair exists for the device
41
- * @throws {DeviceKeyStoreError} If the storage operation fails
16
+ * Runtime credential store used for tokens and stable device ID.
17
+ * Examples: Tauri secure storage, Expo SecureStore, iOS Keychain, Android Keystore.
42
18
  */
43
- loadKeyPair(deviceId: string): Promise<CryptoKeyPair | null>;
19
+ credentialStore?: AuthKeyValueStorage;
44
20
  /**
45
- * Delete a stored key pair for the given device.
46
- *
47
- * No-op if no key pair exists for the device ID.
48
- *
49
- * @param deviceId - The unique device identifier
50
- * @throws {DeviceKeyStoreError} If the storage operation fails
21
+ * Explicit device identity provider. Set to `false` to disable automatic
22
+ * device binding during sign-up/sign-in.
51
23
  */
52
- deleteKeyPair(deviceId: string): Promise<void>;
24
+ deviceIdentity?: AuthDeviceIdentityProvider | false;
53
25
  /**
54
- * Check whether a key pair exists for the given device.
55
- *
56
- * @param deviceId - The unique device identifier
57
- * @returns True if a key pair is stored for the device, false otherwise
58
- * @throws {DeviceKeyStoreError} If the storage operation fails
26
+ * Device key store for runtimes without IndexedDB, such as React Native.
59
27
  */
60
- hasKeyPair(deviceId: string): Promise<boolean>;
28
+ deviceKeyStore?: DeviceKeyStore;
61
29
  }
62
30
  /**
63
- * Browser-based device key store backed by IndexedDB.
64
- *
65
- * CryptoKey objects are structured-cloneable, so they can be stored
66
- * directly in IndexedDB without needing to export/import them as JWK.
67
- * This preserves the non-extractable flag on private keys, ensuring
68
- * they cannot be read even from storage.
31
+ * Create a production-shaped Kora auth client with minimal setup.
69
32
  *
70
- * The database uses a single object store (`keypairs`) with the device ID
71
- * as the key and the full CryptoKeyPair as the value.
72
- *
73
- * @example
74
- * ```typescript
75
- * const store = new IndexedDBDeviceKeyStore()
76
- * const keyPair = await generateDeviceKeyPair()
77
- * await store.saveKeyPair('device-123', keyPair)
33
+ * Defaults:
34
+ * - browser/Tauri WebView: localStorage for tokens, IndexedDB for device keys
35
+ * - desktop/mobile: pass `credentialStore` and optionally `deviceKeyStore`
36
+ * - automatic device identity is enabled when a persistent device ID store exists
37
+ */
38
+ declare function createKoraAuth(options: CreateKoraAuthOptions): AuthClient;
39
+
40
+ /**
41
+ * Minimal auth client surface required for sync integration.
42
+ * Matches {@link AuthClient} without importing implementation details.
43
+ */
44
+ interface AuthSyncClient {
45
+ getAccessToken(): Promise<string | null>;
46
+ onAuthChange?(callback: (state: AuthState) => void): () => void;
47
+ }
48
+ /**
49
+ * Sync binding returned by {@link createKoraAuthSync}.
50
+ * Passed to `createApp({ sync: { authClient } })` in korajs.
78
51
  *
79
- * const loaded = await store.loadKeyPair('device-123')
80
- * // loaded.privateKey is still non-extractable
81
- * ```
52
+ * @deprecated Use {@link AuthSyncBinding} from `@korajs/core/bindings` or `@korajs/auth`.
53
+ */
54
+ type KoraAuthSyncBinding = AuthSyncBinding;
55
+ /**
56
+ * Configuration for {@link createKoraAuthSync}.
82
57
  */
83
- declare class IndexedDBDeviceKeyStore implements DeviceKeyStore {
84
- private dbPromise;
58
+ interface CreateKoraAuthSyncOptions {
59
+ /** Kora auth client from `createKoraAuth()`. */
60
+ authClient: AuthSyncClient;
85
61
  /**
86
- * Opens (or creates) the IndexedDB database.
87
- *
88
- * The database connection is lazily initialized on first use and
89
- * reused for subsequent operations. If the database does not exist,
90
- * it is created with the `keypairs` object store.
62
+ * Application schema. When provided, scope maps are built automatically
63
+ * from JWT claims and schema scope declarations.
64
+ */
65
+ schema?: SchemaDefinition;
66
+ /**
67
+ * Custom claim → flat scope value mapping.
68
+ * Defaults to {@link extractScopeValuesFromClaims}.
91
69
  */
92
- private openDatabase;
93
- /** @inheritdoc */
94
- saveKeyPair(deviceId: string, keyPair: CryptoKeyPair): Promise<void>;
95
- /** @inheritdoc */
96
- loadKeyPair(deviceId: string): Promise<CryptoKeyPair | null>;
97
- /** @inheritdoc */
98
- deleteKeyPair(deviceId: string): Promise<void>;
99
- /** @inheritdoc */
100
- hasKeyPair(deviceId: string): Promise<boolean>;
70
+ scopeFromClaims?: (claims: Record<string, unknown>) => Record<string, unknown>;
101
71
  }
102
72
  /**
103
- * In-memory device key store for Node.js and testing environments.
73
+ * Creates a sync auth binding for `createApp({ sync: { authClient: binding } })`.
104
74
  *
105
- * Key pairs are stored in a plain Map and do not survive process restarts.
106
- * This is suitable for server-side rendering, Node.js scripts, and unit tests
107
- * where IndexedDB is not available.
75
+ * Wires token refresh, automatic scope maps from JWT claims, and device-bound
76
+ * sync node ids (`dev` claim) separate from the user id (`sub`).
108
77
  *
109
78
  * @example
110
79
  * ```typescript
111
- * const store = new InMemoryDeviceKeyStore()
112
- * const keyPair = await generateDeviceKeyPair()
113
- * await store.saveKeyPair('device-123', keyPair)
114
- *
115
- * const loaded = await store.loadKeyPair('device-123')
116
- * ```
117
- */
118
- declare class InMemoryDeviceKeyStore implements DeviceKeyStore {
119
- private readonly store;
120
- /** @inheritdoc */
121
- saveKeyPair(deviceId: string, keyPair: CryptoKeyPair): Promise<void>;
122
- /** @inheritdoc */
123
- loadKeyPair(deviceId: string): Promise<CryptoKeyPair | null>;
124
- /** @inheritdoc */
125
- deleteKeyPair(deviceId: string): Promise<void>;
126
- /** @inheritdoc */
127
- hasKeyPair(deviceId: string): Promise<boolean>;
128
- }
129
- /**
130
- * Creates a DeviceKeyStore appropriate for the current environment.
131
- *
132
- * In browsers where IndexedDB is available, returns an {@link IndexedDBDeviceKeyStore}
133
- * that persists CryptoKeyPair objects as structured clones. In Node.js, SSR,
134
- * or environments without IndexedDB, returns an {@link InMemoryDeviceKeyStore}.
80
+ * import { createKoraAuth, createKoraAuthSync } from '@korajs/auth'
81
+ * import { createApp } from 'korajs'
135
82
  *
136
- * @returns A DeviceKeyStore instance for the current environment
83
+ * const authClient = createKoraAuth({ serverUrl: 'https://api.example.com' })
137
84
  *
138
- * @example
139
- * ```typescript
140
- * const store = createDeviceKeyStore()
141
- * const keyPair = await generateDeviceKeyPair()
142
- * await store.saveKeyPair(deviceId, keyPair)
85
+ * const app = createApp({
86
+ * schema,
87
+ * sync: {
88
+ * url: 'wss://api.example.com/kora-sync',
89
+ * authClient: createKoraAuthSync({ authClient, schema }),
90
+ * },
91
+ * })
143
92
  * ```
144
93
  */
145
- declare function createDeviceKeyStore(): DeviceKeyStore;
94
+ declare function createKoraAuthSync(options: CreateKoraAuthSyncOptions): AuthSyncBinding;
146
95
 
147
96
  /**
148
97
  * Client-side token storage for Kora auth tokens.
@@ -780,4 +729,4 @@ declare class AutoLockManager {
780
729
  private _clearTimer;
781
730
  }
782
731
 
783
- export { AuthTokens, type AutoLockConfig, AutoLockManager, type DeviceKeyStore, DeviceKeyStoreError, EncryptedTokenStore, type EncryptedTokenStoreConfig, EncryptedTokenStoreError, EncryptionError, InMemoryDeviceKeyStore, IndexedDBDeviceKeyStore, KeyDerivationError, type PasskeyAuthenticationResponse, PasskeyError, type PasskeyRegistrationResponse, PasskeyUnsupportedError, TokenStore, authenticateWithPasskey, createDeviceKeyStore, createPasskeyCredential, decryptData, deriveEncryptionKey, encryptData, exportKey, generateEncryptionKey, generateSalt, importKey, isPasskeySupported, isPlatformAuthenticatorAvailable };
732
+ export { AuthClient, AuthClientConfig, AuthDeviceIdentityProvider, AuthKeyValueStorage, AuthState, type AuthSyncClient, AuthTokenStorage, AuthTokens, type AutoLockConfig, AutoLockManager, type CreateKoraAuthOptions, type CreateKoraAuthSyncOptions, DeviceKeyStore, EncryptedTokenStore, type EncryptedTokenStoreConfig, EncryptedTokenStoreError, EncryptionError, KeyDerivationError, type KoraAuthSyncBinding, type PasskeyAuthenticationResponse, PasskeyError, type PasskeyRegistrationResponse, PasskeyUnsupportedError, TokenStore, authenticateWithPasskey, createKoraAuth, createKoraAuthSync, createPasskeyCredential, decryptData, deriveEncryptionKey, encryptData, exportKey, generateEncryptionKey, generateSalt, importKey, isPasskeySupported, isPlatformAuthenticatorAvailable };