@icp-sdk/auth 5.0.0 → 6.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"auth-client.js","sources":["../../../src/client/auth-client.ts"],"sourcesContent":["import {\n AnonymousIdentity,\n type DerEncodedPublicKey,\n type Identity,\n type Signature,\n type SignIdentity,\n} from '@icp-sdk/core/agent';\nimport {\n Delegation,\n DelegationChain,\n DelegationIdentity,\n ECDSAKeyIdentity,\n Ed25519KeyIdentity,\n isDelegationValid,\n PartialDelegationIdentity,\n type PartialIdentity,\n} from '@icp-sdk/core/identity';\nimport type { Principal } from '@icp-sdk/core/principal';\nimport { IdleManager, type IdleManagerOptions } from './idle-manager.ts';\nimport {\n type AuthClientStorage,\n IdbStorage,\n KEY_STORAGE_DELEGATION,\n KEY_STORAGE_KEY,\n KEY_VECTOR,\n LocalStorage,\n type StoredKey,\n} from './storage.ts';\n\nconst NANOSECONDS_PER_SECOND = BigInt(1_000_000_000);\nconst SECONDS_PER_HOUR = BigInt(3_600);\nconst NANOSECONDS_PER_HOUR = NANOSECONDS_PER_SECOND * SECONDS_PER_HOUR;\n\nconst IDENTITY_PROVIDER_DEFAULT = 'https://identity.internetcomputer.org';\nconst IDENTITY_PROVIDER_ENDPOINT = '#authorize';\n\nconst DEFAULT_MAX_TIME_TO_LIVE = BigInt(8) * NANOSECONDS_PER_HOUR;\n\nconst ECDSA_KEY_LABEL = 'ECDSA';\nconst ED25519_KEY_LABEL = 'Ed25519';\ntype BaseKeyType = typeof ECDSA_KEY_LABEL | typeof ED25519_KEY_LABEL;\n\nconst INTERRUPT_CHECK_INTERVAL = 500;\n\nexport const ERROR_USER_INTERRUPT = 'UserInterrupt';\n\n/**\n * List of options for creating an {@link AuthClient}.\n */\nexport interface AuthClientCreateOptions {\n /**\n * An {@link SignIdentity} or {@link PartialIdentity} to authenticate via delegation.\n */\n identity?: SignIdentity | PartialIdentity;\n /**\n * Optional storage with get, set, and remove. Uses {@link IdbStorage} by default.\n * @see {@link AuthClientStorage}\n */\n storage?: AuthClientStorage;\n\n /**\n * Type to use for the base key.\n *\n * If you are using a custom storage provider that does not support CryptoKey storage,\n * you should use `Ed25519` as the key type, as it can serialize to a string.\n * @default 'ECDSA'\n */\n keyType?: BaseKeyType;\n\n /**\n * Options to handle idle timeouts\n * @default after 10 minutes, invalidates the identity\n */\n idleOptions?: IdleOptions;\n\n /**\n * Options to handle login, passed to the login method\n */\n loginOptions?: AuthClientLoginOptions;\n}\n\nexport interface IdleOptions extends IdleManagerOptions {\n /**\n * Disables idle functionality for {@link IdleManager}\n * @default false\n */\n disableIdle?: boolean;\n\n /**\n * Disables default idle behavior - call logout & reload window\n * @default false\n */\n disableDefaultIdleCallback?: boolean;\n}\n\nexport type OnSuccessFunc =\n | (() => void | Promise<void>)\n | ((message: InternetIdentityAuthResponseSuccess) => void | Promise<void>);\n\nexport type OnErrorFunc = (error?: string) => void | Promise<void>;\n\nexport interface AuthClientLoginOptions {\n /**\n * Identity provider\n * @default \"https://identity.internetcomputer.org\"\n */\n identityProvider?: string | URL;\n /**\n * Expiration of the authentication in nanoseconds\n * @default BigInt(8) hours * BigInt(3_600_000_000_000) nanoseconds\n */\n maxTimeToLive?: bigint;\n /**\n * If present, indicates whether or not the Identity Provider should allow the user to authenticate and/or register using a temporary key/PIN identity. Authenticating dapps may want to prevent users from using Temporary keys/PIN identities because Temporary keys/PIN identities are less secure than Passkeys (webauthn credentials) and because Temporary keys/PIN identities generally only live in a browser database (which may get cleared by the browser/OS).\n */\n allowPinAuthentication?: boolean;\n /**\n * Origin for Identity Provider to use while generating the delegated identity. For II, the derivation origin must authorize this origin by setting a record at `<derivation-origin>/.well-known/ii-alternative-origins`.\n * @see https://github.com/dfinity/internet-identity/blob/main/docs/internet-identity-spec.adoc\n */\n derivationOrigin?: string | URL;\n /**\n * Auth Window feature config string\n * @example \"toolbar=0,location=0,menubar=0,width=500,height=500,left=100,top=100\"\n */\n windowOpenerFeatures?: string;\n /**\n * Callback once login has completed\n */\n onSuccess?: OnSuccessFunc;\n /**\n * Callback in case authentication fails\n */\n onError?: OnErrorFunc;\n /**\n * Extra values to be passed in the login request during the authorize-ready phase\n */\n customValues?: Record<string, unknown>;\n}\n\ninterface InternetIdentityAuthRequest {\n kind: 'authorize-client';\n sessionPublicKey: Uint8Array;\n maxTimeToLive?: bigint;\n allowPinAuthentication?: boolean;\n derivationOrigin?: string;\n}\n\nexport interface InternetIdentityAuthResponseSuccess {\n kind: 'authorize-client-success';\n delegations: {\n delegation: {\n pubkey: Uint8Array;\n expiration: bigint;\n targets?: Principal[];\n };\n signature: Uint8Array;\n }[];\n userPublicKey: Uint8Array;\n authnMethod: 'passkey' | 'pin' | 'recovery';\n}\n\ninterface AuthReadyMessage {\n kind: 'authorize-ready';\n}\n\ninterface AuthResponseSuccess {\n kind: 'authorize-client-success';\n delegations: {\n delegation: {\n pubkey: Uint8Array;\n expiration: bigint;\n targets?: Principal[];\n };\n signature: Uint8Array;\n }[];\n userPublicKey: Uint8Array;\n authnMethod: 'passkey' | 'pin' | 'recovery';\n}\n\ninterface AuthResponseFailure {\n kind: 'authorize-client-failure';\n text: string;\n}\n\ntype IdentityServiceResponseMessage = AuthReadyMessage | AuthResponse;\ntype AuthResponse = AuthResponseSuccess | AuthResponseFailure;\n\n/**\n * Tool to manage authentication and identity\n * @see {@link AuthClient}\n */\nexport class AuthClient {\n /**\n * Create an AuthClient to manage authentication and identity\n * @param {AuthClientCreateOptions} options - Options for creating an {@link AuthClient}\n * @see {@link AuthClientCreateOptions}\n * @param options.identity Optional Identity to use as the base\n * @see {@link SignIdentity}\n * @param options.storage Storage mechanism for delegation credentials\n * @see {@link AuthClientStorage}\n * @param options.keyType Type of key to use for the base key\n * @param {IdleOptions} options.idleOptions Configures an {@link IdleManager}\n * @see {@link IdleOptions}\n * Default behavior is to clear stored identity and reload the page when a user goes idle, unless you set the disableDefaultIdleCallback flag or pass in a custom idle callback.\n * @example\n * const authClient = await AuthClient.create({\n * idleOptions: {\n * disableIdle: true\n * }\n * })\n */\n public static async create(options: AuthClientCreateOptions = {}): Promise<AuthClient> {\n const storage = options.storage ?? new IdbStorage();\n const keyType = options.keyType ?? ECDSA_KEY_LABEL;\n\n let key: null | SignIdentity | PartialIdentity = null;\n if (options.identity) {\n key = options.identity;\n } else {\n let maybeIdentityStorage = await storage.get(KEY_STORAGE_KEY);\n if (!maybeIdentityStorage) {\n // Attempt to migrate from localstorage\n try {\n const fallbackLocalStorage = new LocalStorage();\n const localChain = await fallbackLocalStorage.get(KEY_STORAGE_DELEGATION);\n const localKey = await fallbackLocalStorage.get(KEY_STORAGE_KEY);\n // not relevant for Ed25519\n if (localChain && localKey && keyType === ECDSA_KEY_LABEL) {\n console.log('Discovered an identity stored in localstorage. Migrating to IndexedDB');\n await storage.set(KEY_STORAGE_DELEGATION, localChain);\n await storage.set(KEY_STORAGE_KEY, localKey);\n\n maybeIdentityStorage = localChain;\n // clean up\n await fallbackLocalStorage.remove(KEY_STORAGE_DELEGATION);\n await fallbackLocalStorage.remove(KEY_STORAGE_KEY);\n }\n } catch (error) {\n console.error(`error while attempting to recover localstorage: ${error}`);\n }\n }\n if (maybeIdentityStorage) {\n try {\n if (typeof maybeIdentityStorage === 'object') {\n if (keyType === ED25519_KEY_LABEL && typeof maybeIdentityStorage === 'string') {\n key = Ed25519KeyIdentity.fromJSON(maybeIdentityStorage);\n } else {\n key = await ECDSAKeyIdentity.fromKeyPair(maybeIdentityStorage);\n }\n } else if (typeof maybeIdentityStorage === 'string') {\n // This is a legacy identity, which is a serialized Ed25519KeyIdentity.\n key = Ed25519KeyIdentity.fromJSON(maybeIdentityStorage);\n }\n } catch {\n // Ignore this, this means that the localStorage value isn't a valid Ed25519KeyIdentity or ECDSAKeyIdentity\n // serialization.\n }\n }\n }\n\n let identity: SignIdentity | PartialIdentity = new AnonymousIdentity() as PartialIdentity;\n let chain: null | DelegationChain = null;\n if (key) {\n try {\n const chainStorage = await storage.get(KEY_STORAGE_DELEGATION);\n if (typeof chainStorage === 'object' && chainStorage !== null) {\n throw new Error(\n 'Delegation chain is incorrectly stored. A delegation chain should be stored as a string.',\n );\n }\n\n if (options.identity) {\n identity = options.identity;\n } else if (chainStorage) {\n chain = DelegationChain.fromJSON(chainStorage);\n\n // Verify that the delegation isn't expired.\n if (!isDelegationValid(chain)) {\n await _deleteStorage(storage);\n key = null;\n } else {\n // If the key is a public key, then we create a PartialDelegationIdentity.\n if ('toDer' in key) {\n identity = PartialDelegationIdentity.fromDelegation(key, chain);\n // otherwise, we create a DelegationIdentity.\n } else {\n identity = DelegationIdentity.fromDelegation(key, chain);\n }\n }\n }\n } catch (e) {\n console.error(e);\n // If there was a problem loading the chain, delete the key.\n await _deleteStorage(storage);\n key = null;\n }\n }\n let idleManager: IdleManager | undefined;\n if (options.idleOptions?.disableIdle) {\n idleManager = undefined;\n }\n // if there is a delegation chain or provided identity, setup idleManager\n else if (chain || options.identity) {\n idleManager = IdleManager.create(options.idleOptions);\n }\n\n if (!key) {\n // Create a new key (whether or not one was in storage).\n if (keyType === ED25519_KEY_LABEL) {\n key = Ed25519KeyIdentity.generate();\n } else {\n if (options.storage && keyType === ECDSA_KEY_LABEL) {\n console.warn(\n `You are using a custom storage provider that may not support CryptoKey storage. If you are using a custom storage provider that does not support CryptoKey storage, you should use '${ED25519_KEY_LABEL}' as the key type, as it can serialize to a string`,\n );\n }\n key = await ECDSAKeyIdentity.generate();\n }\n await persistKey(storage, key);\n }\n\n return new AuthClient(identity, key, chain, storage, idleManager, options);\n }\n\n protected constructor(\n private _identity: Identity | PartialIdentity,\n private _key: SignIdentity | PartialIdentity,\n private _chain: DelegationChain | null,\n private _storage: AuthClientStorage,\n public idleManager: IdleManager | undefined,\n private _createOptions: AuthClientCreateOptions | undefined,\n // A handle on the IdP window.\n private _idpWindow?: Window,\n // The event handler for processing events from the IdP.\n private _eventHandler?: (event: MessageEvent) => void,\n ) {\n this._registerDefaultIdleCallback();\n }\n\n private _registerDefaultIdleCallback() {\n const idleOptions = this._createOptions?.idleOptions;\n /**\n * Default behavior is to clear stored identity and reload the page.\n * By either setting the disableDefaultIdleCallback flag or passing in a custom idle callback, we will ignore this config\n */\n if (!idleOptions?.onIdle && !idleOptions?.disableDefaultIdleCallback) {\n this.idleManager?.registerCallback(() => {\n this.logout();\n location.reload();\n });\n }\n }\n\n private async _handleSuccess(\n message: InternetIdentityAuthResponseSuccess,\n onSuccess?: OnSuccessFunc,\n ) {\n const delegations = message.delegations.map((signedDelegation) => {\n return {\n delegation: new Delegation(\n signedDelegation.delegation.pubkey,\n signedDelegation.delegation.expiration,\n signedDelegation.delegation.targets,\n ),\n signature: signedDelegation.signature as Signature,\n };\n });\n\n const delegationChain = DelegationChain.fromDelegations(\n delegations,\n message.userPublicKey as DerEncodedPublicKey,\n );\n\n const key = this._key;\n if (!key) {\n return;\n }\n\n this._chain = delegationChain;\n\n if ('toDer' in key) {\n this._identity = PartialDelegationIdentity.fromDelegation(key, this._chain);\n } else {\n this._identity = DelegationIdentity.fromDelegation(key, this._chain);\n }\n\n this._idpWindow?.close();\n const idleOptions = this._createOptions?.idleOptions;\n // create the idle manager on a successful login if we haven't disabled it\n // and it doesn't already exist.\n if (!this.idleManager && !idleOptions?.disableIdle) {\n this.idleManager = IdleManager.create(idleOptions);\n this._registerDefaultIdleCallback();\n }\n\n this._removeEventListener();\n delete this._idpWindow;\n\n if (this._chain) {\n await this._storage.set(KEY_STORAGE_DELEGATION, JSON.stringify(this._chain.toJSON()));\n }\n\n // Ensure the stored key in persistent storage matches the in-memory key that\n // was used to obtain the delegation. This avoids key/delegation mismatches\n // across multiple tabs overwriting each other's cached keys.\n await persistKey(this._storage, this._key);\n\n // onSuccess should be the last thing to do to avoid consumers\n // interfering by navigating or refreshing the page\n onSuccess?.(message);\n }\n\n public getIdentity(): Identity {\n return this._identity;\n }\n\n public async isAuthenticated(): Promise<boolean> {\n return (\n !this.getIdentity().getPrincipal().isAnonymous() &&\n this._chain !== null &&\n isDelegationValid(this._chain)\n );\n }\n\n /**\n * AuthClient Login - Opens up a new window to authenticate with Internet Identity\n * @param {AuthClientLoginOptions} options - Options for logging in, merged with the options set during creation if any. Note: we only perform a shallow merge for the `customValues` property.\n * @param options.identityProvider Identity provider\n * @param options.maxTimeToLive Expiration of the authentication in nanoseconds\n * @param options.allowPinAuthentication If present, indicates whether or not the Identity Provider should allow the user to authenticate and/or register using a temporary key/PIN identity. Authenticating dapps may want to prevent users from using Temporary keys/PIN identities because Temporary keys/PIN identities are less secure than Passkeys (webauthn credentials) and because Temporary keys/PIN identities generally only live in a browser database (which may get cleared by the browser/OS).\n * @param options.derivationOrigin Origin for Identity Provider to use while generating the delegated identity\n * @param options.windowOpenerFeatures Configures the opened authentication window\n * @param options.onSuccess Callback once login has completed\n * @param options.onError Callback in case authentication fails\n * @param options.customValues Extra values to be passed in the login request during the authorize-ready phase. Note: we only perform a shallow merge for the `customValues` property.\n * @example\n * const authClient = await AuthClient.create();\n * authClient.login({\n * identityProvider: 'http://<canisterID>.127.0.0.1:8000',\n * maxTimeToLive: BigInt (7) * BigInt(24) * BigInt(3_600_000_000_000), // 1 week\n * windowOpenerFeatures: \"toolbar=0,location=0,menubar=0,width=500,height=500,left=100,top=100\",\n * onSuccess: () => {\n * console.log('Login Successful!');\n * },\n * onError: (error) => {\n * console.error('Login Failed: ', error);\n * }\n * });\n */\n public async login(options?: AuthClientLoginOptions): Promise<void> {\n // Merge the passed options with the options set during creation\n const loginOptions = mergeLoginOptions(this._createOptions?.loginOptions, options);\n\n // Set default maxTimeToLive to 8 hours\n const maxTimeToLive = loginOptions?.maxTimeToLive ?? DEFAULT_MAX_TIME_TO_LIVE;\n\n // Create the URL of the IDP. (e.g. https://XXXX/#authorize)\n const identityProviderUrl = new URL(\n loginOptions?.identityProvider?.toString() || IDENTITY_PROVIDER_DEFAULT,\n );\n // Set the correct hash if it isn't already set.\n identityProviderUrl.hash = IDENTITY_PROVIDER_ENDPOINT;\n\n // If `login` has been called previously, then close/remove any previous windows\n // and event listeners.\n this._idpWindow?.close();\n this._removeEventListener();\n\n // Add an event listener to handle responses.\n this._eventHandler = this._getEventHandler(identityProviderUrl, {\n maxTimeToLive,\n ...loginOptions,\n });\n window.addEventListener('message', this._eventHandler);\n\n // Open a new window with the IDP provider.\n this._idpWindow =\n window.open(\n identityProviderUrl.toString(),\n 'idpWindow',\n loginOptions?.windowOpenerFeatures,\n ) ?? undefined;\n\n // Check if the _idpWindow is closed by user.\n const checkInterruption = (): void => {\n // The _idpWindow is opened and not yet closed by the client\n if (this._idpWindow) {\n if (this._idpWindow.closed) {\n this._handleFailure(ERROR_USER_INTERRUPT, loginOptions?.onError);\n } else {\n setTimeout(checkInterruption, INTERRUPT_CHECK_INTERVAL);\n }\n }\n };\n checkInterruption();\n }\n\n private _getEventHandler(identityProviderUrl: URL, options?: AuthClientLoginOptions) {\n return async (event: MessageEvent) => {\n if (event.origin !== identityProviderUrl.origin) {\n // Ignore any event that is not from the identity provider\n return;\n }\n\n const message = event.data as IdentityServiceResponseMessage;\n\n switch (message.kind) {\n case 'authorize-ready': {\n // IDP is ready. Send a message to request authorization.\n const request: InternetIdentityAuthRequest = {\n kind: 'authorize-client',\n sessionPublicKey: new Uint8Array(this._key?.getPublicKey().toDer()),\n maxTimeToLive: options?.maxTimeToLive,\n allowPinAuthentication: options?.allowPinAuthentication,\n derivationOrigin: options?.derivationOrigin?.toString(),\n // Pass any custom values to the IDP.\n ...options?.customValues,\n };\n this._idpWindow?.postMessage(request, identityProviderUrl.origin);\n break;\n }\n case 'authorize-client-success':\n // Create the delegation chain and store it.\n try {\n await this._handleSuccess(message, options?.onSuccess);\n } catch (err) {\n this._handleFailure((err as Error).message, options?.onError);\n }\n break;\n case 'authorize-client-failure':\n this._handleFailure(message.text, options?.onError);\n break;\n default:\n break;\n }\n };\n }\n\n private _handleFailure(errorMessage?: string, onError?: (error?: string) => void): void {\n this._idpWindow?.close();\n onError?.(errorMessage);\n this._removeEventListener();\n delete this._idpWindow;\n }\n\n private _removeEventListener() {\n if (this._eventHandler) {\n window.removeEventListener('message', this._eventHandler);\n }\n this._eventHandler = undefined;\n }\n\n public async logout(options: { returnTo?: string } = {}): Promise<void> {\n await _deleteStorage(this._storage);\n\n // Reset this auth client to a non-authenticated state.\n this._identity = new AnonymousIdentity();\n this._chain = null;\n\n if (options.returnTo) {\n try {\n window.history.pushState({}, '', options.returnTo);\n } catch {\n window.location.href = options.returnTo;\n }\n }\n }\n}\n\nasync function _deleteStorage(storage: AuthClientStorage) {\n await storage.remove(KEY_STORAGE_KEY);\n await storage.remove(KEY_STORAGE_DELEGATION);\n await storage.remove(KEY_VECTOR);\n}\n\nfunction mergeLoginOptions(\n loginOptions: AuthClientLoginOptions | undefined,\n otherLoginOptions: AuthClientLoginOptions | undefined,\n): AuthClientLoginOptions | undefined {\n if (!loginOptions && !otherLoginOptions) {\n return undefined;\n }\n\n const customValues =\n loginOptions?.customValues || otherLoginOptions?.customValues\n ? {\n ...loginOptions?.customValues,\n ...otherLoginOptions?.customValues,\n }\n : undefined;\n\n return {\n ...loginOptions,\n ...otherLoginOptions,\n customValues,\n };\n}\n\nfunction toStoredKey(key: SignIdentity | PartialIdentity): StoredKey {\n if (key instanceof ECDSAKeyIdentity) {\n return key.getKeyPair();\n }\n if (key instanceof Ed25519KeyIdentity) {\n return JSON.stringify(key.toJSON());\n }\n throw new Error('Unsupported key type');\n}\n\nasync function persistKey(\n storage: AuthClientStorage,\n key: SignIdentity | PartialIdentity,\n): Promise<void> {\n const serialized = toStoredKey(key);\n await storage.set(KEY_STORAGE_KEY, serialized);\n}\n"],"names":[],"mappings":";;;;AA6BA,MAAM,yBAAyB,OAAO,GAAa;AACnD,MAAM,mBAAmB,OAAO,IAAK;AACrC,MAAM,uBAAuB,yBAAyB;AAEtD,MAAM,4BAA4B;AAClC,MAAM,6BAA6B;AAEnC,MAAM,2BAA2B,OAAO,CAAC,IAAI;AAE7C,MAAM,kBAAkB;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NAME = "ic-keyval";
1
+ import { openDB } from 'idb';
2
+ import { DB_VERSION, KEY_STORAGE_DELEGATION, KEY_STORAGE_KEY } from './storage.js';
3
+ const AUTH_DB_NAME = 'auth-client-db';
4
+ const OBJECT_STORE_NAME = 'ic-keyval';
5
5
  const _openDbStore = async (dbName = AUTH_DB_NAME, storeName = OBJECT_STORE_NAME, version) => {
6
- if (globalThis.localStorage?.getItem(KEY_STORAGE_DELEGATION)) {
7
- globalThis.localStorage.removeItem(KEY_STORAGE_DELEGATION);
8
- globalThis.localStorage.removeItem(KEY_STORAGE_KEY);
9
- }
10
- return await openDB(dbName, version, {
11
- upgrade: (database) => {
12
- if (database.objectStoreNames.contains(storeName)) {
13
- database.clear(storeName);
14
- }
15
- database.createObjectStore(storeName);
6
+ // Clear legacy stored delegations
7
+ if (globalThis.localStorage?.getItem(KEY_STORAGE_DELEGATION)) {
8
+ globalThis.localStorage.removeItem(KEY_STORAGE_DELEGATION);
9
+ globalThis.localStorage.removeItem(KEY_STORAGE_KEY);
16
10
  }
17
- });
11
+ return await openDB(dbName, version, {
12
+ upgrade: (database) => {
13
+ if (database.objectStoreNames.contains(storeName)) {
14
+ database.clear(storeName);
15
+ }
16
+ database.createObjectStore(storeName);
17
+ },
18
+ });
18
19
  };
19
20
  async function _getValue(db, storeName, key) {
20
- return await db.get(storeName, key);
21
+ return await db.get(storeName, key);
21
22
  }
22
23
  async function _setValue(db, storeName, key, value) {
23
- return await db.put(storeName, value, key);
24
+ return await db.put(storeName, value, key);
24
25
  }
25
26
  async function _removeValue(db, storeName, key) {
26
- return await db.delete(storeName, key);
27
+ return await db.delete(storeName, key);
27
28
  }
28
- class IdbKeyVal {
29
- // Do not use - instead prefer create
30
- constructor(_db, _storeName) {
31
- this._db = _db;
32
- this._storeName = _storeName;
33
- }
34
- /**
35
- * @param {DBCreateOptions} options - DBCreateOptions
36
- * @param {DBCreateOptions['dbName']} options.dbName name for the indexeddb database
37
- * @default
38
- * @param {DBCreateOptions['storeName']} options.storeName name for the indexeddb Data Store
39
- * @default
40
- * @param {DBCreateOptions['version']} options.version version of the database. Increment to safely upgrade
41
- */
42
- static async create(options) {
43
- const {
44
- dbName = AUTH_DB_NAME,
45
- storeName = OBJECT_STORE_NAME,
46
- version = DB_VERSION
47
- } = options ?? {};
48
- const db = await _openDbStore(dbName, storeName, version);
49
- return new IdbKeyVal(db, storeName);
50
- }
51
- /**
52
- * Basic setter
53
- * @param {IDBValidKey} key string | number | Date | BufferSource | IDBValidKey[]
54
- * @param value value to set
55
- * @returns void
56
- */
57
- async set(key, value) {
58
- return await _setValue(this._db, this._storeName, key, value);
59
- }
60
- /**
61
- * Basic getter
62
- * Pass in a type T for type safety if you know the type the value will have if it is found
63
- * @param {IDBValidKey} key string | number | Date | BufferSource | IDBValidKey[]
64
- * @returns `Promise<T | null>`
65
- * @example
66
- * await get<string>('exampleKey') -> 'exampleValue'
67
- */
68
- async get(key) {
69
- return await _getValue(this._db, this._storeName, key) ?? null;
70
- }
71
- /**
72
- * Remove a key
73
- * @param key {@link IDBValidKey}
74
- * @returns void
75
- */
76
- async remove(key) {
77
- return await _removeValue(this._db, this._storeName, key);
78
- }
29
+ /**
30
+ * Simple Key Value store
31
+ * Defaults to `'auth-client-db'` with an object store of `'ic-keyval'`
32
+ */
33
+ export class IdbKeyVal {
34
+ _db;
35
+ _storeName;
36
+ /**
37
+ * @param {DBCreateOptions} options - DBCreateOptions
38
+ * @param {DBCreateOptions['dbName']} options.dbName name for the indexeddb database
39
+ * @default
40
+ * @param {DBCreateOptions['storeName']} options.storeName name for the indexeddb Data Store
41
+ * @default
42
+ * @param {DBCreateOptions['version']} options.version version of the database. Increment to safely upgrade
43
+ */
44
+ static async create(options) {
45
+ const { dbName = AUTH_DB_NAME, storeName = OBJECT_STORE_NAME, version = DB_VERSION, } = options ?? {};
46
+ const db = await _openDbStore(dbName, storeName, version);
47
+ return new IdbKeyVal(db, storeName);
48
+ }
49
+ // Do not use - instead prefer create
50
+ constructor(_db, _storeName) {
51
+ this._db = _db;
52
+ this._storeName = _storeName;
53
+ }
54
+ /**
55
+ * Basic setter
56
+ * @param {IDBValidKey} key string | number | Date | BufferSource | IDBValidKey[]
57
+ * @param value value to set
58
+ * @returns void
59
+ */
60
+ async set(key, value) {
61
+ return await _setValue(this._db, this._storeName, key, value);
62
+ }
63
+ /**
64
+ * Basic getter
65
+ * Pass in a type T for type safety if you know the type the value will have if it is found
66
+ * @param {IDBValidKey} key string | number | Date | BufferSource | IDBValidKey[]
67
+ * @returns `Promise<T | null>`
68
+ * @example
69
+ * await get<string>('exampleKey') -> 'exampleValue'
70
+ */
71
+ async get(key) {
72
+ return (await _getValue(this._db, this._storeName, key)) ?? null;
73
+ }
74
+ /**
75
+ * Remove a key
76
+ * @param key {@link IDBValidKey}
77
+ * @returns void
78
+ */
79
+ async remove(key) {
80
+ return await _removeValue(this._db, this._storeName, key);
81
+ }
79
82
  }
80
- export {
81
- IdbKeyVal
82
- };
83
- //# sourceMappingURL=db.js.map
83
+ //# sourceMappingURL=db.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"db.js","sources":["../../../src/client/db.ts"],"sourcesContent":["import { type IDBPDatabase, openDB } from 'idb';\nimport { DB_VERSION, KEY_STORAGE_DELEGATION, KEY_STORAGE_KEY } from './storage.ts';\n\ntype Database = IDBPDatabase<unknown>;\ntype IDBValidKey = string | number | Date | BufferSource | IDBValidKey[];\nconst AUTH_DB_NAME = 'auth-client-db';\nconst OBJECT_STORE_NAME = 'ic-keyval';\n\nconst _openDbStore = async (\n dbName = AUTH_DB_NAME,\n storeName = OBJECT_STORE_NAME,\n version: number,\n) => {\n // Clear legacy stored delegations\n if (globalThis.localStorage?.getItem(KEY_STORAGE_DELEGATION)) {\n globalThis.localStorage.removeItem(KEY_STORAGE_DELEGATION);\n globalThis.localStorage.removeItem(KEY_STORAGE_KEY);\n }\n return await openDB(dbName, version, {\n upgrade: (database) => {\n if (database.objectStoreNames.contains(storeName)) {\n database.clear(storeName);\n }\n database.createObjectStore(storeName);\n },\n });\n};\n\nasync function _getValue<T>(\n db: Database,\n storeName: string,\n key: IDBValidKey,\n): Promise<T | undefined> {\n return await db.get(storeName, key);\n}\n\nasync function _setValue<T>(\n db: Database,\n storeName: string,\n key: IDBValidKey,\n value: T,\n): Promise<IDBValidKey> {\n return await db.put(storeName, value, key);\n}\n\nasync function _removeValue(db: Database, storeName: string, key: IDBValidKey): Promise<void> {\n return await db.delete(storeName, key);\n}\n\nexport type DBCreateOptions = {\n dbName?: string;\n storeName?: string;\n version?: number;\n};\n\n/**\n * Simple Key Value store\n * Defaults to `'auth-client-db'` with an object store of `'ic-keyval'`\n */\nexport class IdbKeyVal {\n /**\n * @param {DBCreateOptions} options - DBCreateOptions\n * @param {DBCreateOptions['dbName']} options.dbName name for the indexeddb database\n * @default\n * @param {DBCreateOptions['storeName']} options.storeName name for the indexeddb Data Store\n * @default\n * @param {DBCreateOptions['version']} options.version version of the database. Increment to safely upgrade\n */\n public static async create(options?: DBCreateOptions): Promise<IdbKeyVal> {\n const {\n dbName = AUTH_DB_NAME,\n storeName = OBJECT_STORE_NAME,\n version = DB_VERSION,\n } = options ?? {};\n const db = await _openDbStore(dbName, storeName, version);\n return new IdbKeyVal(db, storeName);\n }\n\n // Do not use - instead prefer create\n private constructor(\n private _db: Database,\n private _storeName: string,\n ) {}\n\n /**\n * Basic setter\n * @param {IDBValidKey} key string | number | Date | BufferSource | IDBValidKey[]\n * @param value value to set\n * @returns void\n */\n public async set<T>(key: IDBValidKey, value: T) {\n return await _setValue<T>(this._db, this._storeName, key, value);\n }\n /**\n * Basic getter\n * Pass in a type T for type safety if you know the type the value will have if it is found\n * @param {IDBValidKey} key string | number | Date | BufferSource | IDBValidKey[]\n * @returns `Promise<T | null>`\n * @example\n * await get<string>('exampleKey') -> 'exampleValue'\n */\n public async get<T>(key: IDBValidKey): Promise<T | null> {\n return (await _getValue<T>(this._db, this._storeName, key)) ?? null;\n }\n\n /**\n * Remove a key\n * @param key {@link IDBValidKey}\n * @returns void\n */\n public async remove(key: IDBValidKey) {\n return await _removeValue(this._db, this._storeName, key);\n }\n}\n"],"names":[],"mappings":";;AAKA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAE1B,MAAM,eAAe,OACnB,SAAS,cACT,YAAY,mBACZ,YACG;AAEH,MAAI,WAAW,cAAc,QAAQ,sBAAsB,GAAG;AAC5D,eAAW,aAAa,WAAW,sBAAsB;AACzD,eAAW,aAAa,WAAW,eAAe;AAAA,EACpD;AACA,SAAO,MAAM,OAAO,QAAQ,SAAS;AAAA,IACnC,SAAS,CAAC,aAAa;AACrB,UAAI,SAAS,iBAAiB,SAAS,SAAS,GAAG;AACjD,iBAAS,MAAM,SAAS;AAAA,MAC1B;AACA,eAAS,kBAAkB,SAAS;AAAA,IACtC;AAAA,EAAA,CACD;AACH;AAEA,eAAe,UACb,IACA,WACA,KACwB;AACxB,SAAO,MAAM,GAAG,IAAI,WAAW,GAAG;AACpC;AAEA,eAAe,UACb,IACA,WACA,KACA,OACsB;AACtB,SAAO,MAAM,GAAG,IAAI,WAAW,OAAO,GAAG;AAC3C;AAEA,eAAe,aAAa,IAAc,WAAmB,KAAiC;AAC5F,SAAO,MAAM,GAAG,OAAO,WAAW,GAAG;AACvC;AAYO,MAAM,UAAU;AAAA;AAAA,EAoBb,YACE,KACA,YACR;AAFQ,SAAA,MAAA;AACA,SAAA,aAAA;AAAA,EACP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAdH,aAAoB,OAAO,SAA+C;AACxE,UAAM;AAAA,MACJ,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,UAAU;AAAA,IAAA,IACR,WAAW,CAAA;AACf,UAAM,KAAK,MAAM,aAAa,QAAQ,WAAW,OAAO;AACxD,WAAO,IAAI,UAAU,IAAI,SAAS;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAa,IAAO,KAAkB,OAAU;AAC9C,WAAO,M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IACI,KAAK,CAAC,GAAG,CAAI,GAAgB;QAClC,OAAO,CAAC,MAAM,SAAS,CAAI,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;IACtE,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM,CAAC,GAAgB;QAClC,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAC5D,CAAC;CACF"}
@@ -23,14 +23,17 @@ export type IdleManagerOptions = {
23
23
  /**
24
24
  * Detects if the user has been idle for a duration of `idleTimeout` ms, and calls `onIdle` and registered callbacks.
25
25
  * By default, the IdleManager will log a user out after 10 minutes of inactivity.
26
- * To override these defaults, you can pass an `onIdle` callback, or configure a custom `idleTimeout` in milliseconds
26
+ * To override these defaults, you can pass an `onIdle` callback, or configure a custom `idleTimeout` in milliseconds.
27
+ *
28
+ * IdleManager is a singleton: multiple calls to `create()` return the same instance,
29
+ * registering any new `onIdle` callback. Call `exit()` to tear down the singleton.
27
30
  */
28
31
  export declare class IdleManager {
29
- callbacks: IdleCB[];
30
- idleTimeout: IdleManagerOptions['idleTimeout'];
31
- timeoutID?: number;
32
+ #private;
32
33
  /**
33
- * Creates an {@link IdleManager}
34
+ * Creates or returns the singleton {@link IdleManager}.
35
+ * If the instance already exists, any provided `onIdle` callback is registered
36
+ * on the existing instance.
34
37
  * @param {IdleManagerOptions} options Optional configuration
35
38
  * @see {@link IdleManagerOptions}
36
39
  * @param options.onIdle Callback once user has been idle. Use to prompt for fresh login, and use `Actor.agentOf(your_actor).invalidateIdentity()` to protect the user
@@ -61,21 +64,20 @@ export declare class IdleManager {
61
64
  scrollDebounce?: number;
62
65
  }): IdleManager;
63
66
  /**
64
- * @protected
65
67
  * @param options {@link IdleManagerOptions}
66
68
  */
67
- protected constructor(options?: IdleManagerOptions);
69
+ private constructor();
68
70
  /**
69
71
  * @param {IdleCB} callback function to be called when user goes idle
70
72
  */
71
73
  registerCallback(callback: IdleCB): void;
72
74
  /**
73
- * Cleans up the idle manager and its listeners
75
+ * Tears down listeners, fires all callbacks, and clears the singleton.
74
76
  */
75
77
  exit(): void;
76
78
  /**
77
79
  * Resets the timeouts during cleanup
78
80
  */
79
- _resetTimer(): void;
81
+ private _resetTimer;
80
82
  }
81
83
  export {};
@@ -1,81 +1,100 @@
1
- const events = ["mousedown", "mousemove", "keydown", "touchstart", "wheel"];
2
- class IdleManager {
3
- callbacks = [];
4
- idleTimeout = 10 * 60 * 1e3;
5
- timeoutID = void 0;
6
- /**
7
- * Creates an {@link IdleManager}
8
- * @param {IdleManagerOptions} options Optional configuration
9
- * @see {@link IdleManagerOptions}
10
- * @param options.onIdle Callback once user has been idle. Use to prompt for fresh login, and use `Actor.agentOf(your_actor).invalidateIdentity()` to protect the user
11
- * @param options.idleTimeout timeout in ms
12
- * @param options.captureScroll capture scroll events
13
- * @param options.scrollDebounce scroll debounce time in ms
14
- */
15
- static create(options = {}) {
16
- return new IdleManager(options);
17
- }
18
- /**
19
- * @protected
20
- * @param options {@link IdleManagerOptions}
21
- */
22
- constructor(options = {}) {
23
- const { onIdle, idleTimeout = 10 * 60 * 1e3 } = options || {};
24
- this.callbacks = onIdle ? [onIdle] : [];
25
- this.idleTimeout = idleTimeout;
26
- const _resetTimer = this._resetTimer.bind(this);
27
- window.addEventListener("load", _resetTimer, true);
28
- events.forEach((name) => {
29
- document.addEventListener(name, _resetTimer, true);
30
- });
31
- const debounce = (func, wait) => {
32
- let timeout;
33
- return (...args) => {
34
- const context = this;
35
- const later = () => {
36
- timeout = void 0;
37
- func.apply(context, args);
1
+ const events = ['mousedown', 'mousemove', 'keydown', 'touchstart', 'wheel'];
2
+ /**
3
+ * Detects if the user has been idle for a duration of `idleTimeout` ms, and calls `onIdle` and registered callbacks.
4
+ * By default, the IdleManager will log a user out after 10 minutes of inactivity.
5
+ * To override these defaults, you can pass an `onIdle` callback, or configure a custom `idleTimeout` in milliseconds.
6
+ *
7
+ * IdleManager is a singleton: multiple calls to `create()` return the same instance,
8
+ * registering any new `onIdle` callback. Call `exit()` to tear down the singleton.
9
+ */
10
+ export class IdleManager {
11
+ static #instance;
12
+ #callbacks = [];
13
+ #idleTimeout;
14
+ #timeoutID = undefined;
15
+ #resetTimer;
16
+ /**
17
+ * Creates or returns the singleton {@link IdleManager}.
18
+ * If the instance already exists, any provided `onIdle` callback is registered
19
+ * on the existing instance.
20
+ * @param {IdleManagerOptions} options Optional configuration
21
+ * @see {@link IdleManagerOptions}
22
+ * @param options.onIdle Callback once user has been idle. Use to prompt for fresh login, and use `Actor.agentOf(your_actor).invalidateIdentity()` to protect the user
23
+ * @param options.idleTimeout timeout in ms
24
+ * @param options.captureScroll capture scroll events
25
+ * @param options.scrollDebounce scroll debounce time in ms
26
+ */
27
+ static create(options = {}) {
28
+ if (IdleManager.#instance) {
29
+ if (options.onIdle) {
30
+ IdleManager.#instance.registerCallback(options.onIdle);
31
+ }
32
+ return IdleManager.#instance;
33
+ }
34
+ const instance = new IdleManager(options);
35
+ IdleManager.#instance = instance;
36
+ return instance;
37
+ }
38
+ /**
39
+ * @param options {@link IdleManagerOptions}
40
+ */
41
+ constructor(options = {}) {
42
+ const { onIdle, idleTimeout = 10 * 60 * 1000 } = options || {};
43
+ this.#callbacks = onIdle ? [onIdle] : [];
44
+ this.#idleTimeout = idleTimeout;
45
+ // Store the bound function once so the same reference is used
46
+ // for both addEventListener and removeEventListener.
47
+ this.#resetTimer = this._resetTimer.bind(this);
48
+ window.addEventListener('load', this.#resetTimer, true);
49
+ events.forEach((name) => {
50
+ document.addEventListener(name, this.#resetTimer, true);
51
+ });
52
+ const debounce = (func, wait) => {
53
+ let timeout;
54
+ return (...args) => {
55
+ const context = this;
56
+ const later = () => {
57
+ timeout = undefined;
58
+ func.apply(context, args);
59
+ };
60
+ clearTimeout(timeout);
61
+ timeout = window.setTimeout(later, wait);
62
+ };
38
63
  };
39
- clearTimeout(timeout);
40
- timeout = window.setTimeout(later, wait);
41
- };
42
- };
43
- if (options?.captureScroll) {
44
- const scroll = debounce(_resetTimer, options?.scrollDebounce ?? 100);
45
- window.addEventListener("scroll", scroll, true);
64
+ if (options?.captureScroll) {
65
+ // debounce scroll events
66
+ const scroll = debounce(this.#resetTimer, options?.scrollDebounce ?? 100);
67
+ window.addEventListener('scroll', scroll, true);
68
+ }
69
+ this.#resetTimer();
70
+ }
71
+ /**
72
+ * @param {IdleCB} callback function to be called when user goes idle
73
+ */
74
+ registerCallback(callback) {
75
+ this.#callbacks.push(callback);
76
+ }
77
+ /**
78
+ * Tears down listeners, fires all callbacks, and clears the singleton.
79
+ */
80
+ exit() {
81
+ clearTimeout(this.#timeoutID);
82
+ window.removeEventListener('load', this.#resetTimer, true);
83
+ events.forEach((name) => {
84
+ document.removeEventListener(name, this.#resetTimer, true);
85
+ });
86
+ this.#callbacks.forEach((cb) => {
87
+ cb();
88
+ });
89
+ IdleManager.#instance = undefined;
90
+ }
91
+ /**
92
+ * Resets the timeouts during cleanup
93
+ */
94
+ _resetTimer() {
95
+ const exit = this.exit.bind(this);
96
+ window.clearTimeout(this.#timeoutID);
97
+ this.#timeoutID = window.setTimeout(exit, this.#idleTimeout);
46
98
  }
47
- _resetTimer();
48
- }
49
- /**
50
- * @param {IdleCB} callback function to be called when user goes idle
51
- */
52
- registerCallback(callback) {
53
- this.callbacks.push(callback);
54
- }
55
- /**
56
- * Cleans up the idle manager and its listeners
57
- */
58
- exit() {
59
- clearTimeout(this.timeoutID);
60
- window.removeEventListener("load", this._resetTimer, true);
61
- const _resetTimer = this._resetTimer.bind(this);
62
- events.forEach((name) => {
63
- document.removeEventListener(name, _resetTimer, true);
64
- });
65
- this.callbacks.forEach((cb) => {
66
- cb();
67
- });
68
- }
69
- /**
70
- * Resets the timeouts during cleanup
71
- */
72
- _resetTimer() {
73
- const exit = this.exit.bind(this);
74
- window.clearTimeout(this.timeoutID);
75
- this.timeoutID = window.setTimeout(exit, this.idleTimeout);
76
- }
77
99
  }
78
- export {
79
- IdleManager
80
- };
81
- //# sourceMappingURL=idle-manager.js.map
100
+ //# sourceMappingURL=idle-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"idle-manager.js","sources":["../../../src/client/idle-manager.ts"],"sourcesContent":["type IdleCB = () => unknown;\n\nexport type IdleManagerOptions = {\n /**\n * Callback after the user has gone idle\n */\n onIdle?: IdleCB;\n /**\n * timeout in ms\n * @default 30 minutes [600_000]\n */\n idleTimeout?: number;\n /**\n * capture scroll events\n * @default false\n */\n captureScroll?: boolean;\n /**\n * scroll debounce time in ms\n * @default 100\n */\n scrollDebounce?: number;\n};\n\nconst events = ['mousedown', 'mousemove', 'keydown', 'touchstart', 'wheel'];\n\n/**\n * Detects if the user has been idle for a duration of `idleTimeout` ms, and calls `onIdle` and registered callbacks.\n * By default, the IdleManager will log a user out after 10 minutes of inactivity.\n * To override these defaults, you can pass an `onIdle` callback, or configure a custom `idleTimeout` in milliseconds\n */\nexport class IdleManager {\n callbacks: IdleCB[] = [];\n idleTimeout: IdleManagerOptions['idleTimeout'] = 10 * 60 * 1000;\n timeoutID?: number = undefined;\n\n /**\n * Creates an {@link IdleManager}\n * @param {IdleManagerOptions} options Optional configuration\n * @see {@link IdleManagerOptions}\n * @param options.onIdle Callback once user has been idle. Use to prompt for fresh login, and use `Actor.agentOf(your_actor).invalidateIdentity()` to protect the user\n * @param options.idleTimeout timeout in ms\n * @param options.captureScroll capture scroll events\n * @param options.scrollDebounce scroll debounce time in ms\n */\n public static create(\n options: {\n /**\n * Callback after the user has gone idle\n * @see {@link IdleCB}\n */\n onIdle?: () => unknown;\n /**\n * timeout in ms\n * @default 10 minutes [600_000]\n */\n idleTimeout?: number;\n /**\n * capture scroll events\n * @default false\n */\n captureScroll?: boolean;\n /**\n * scroll debounce time in ms\n * @default 100\n */\n scrollDebounce?: number;\n } = {},\n ): IdleManager {\n return new IdleManager(options);\n }\n\n /**\n * @protected\n * @param options {@link IdleManagerOptions}\n */\n protected constructor(options: IdleManagerOptions = {}) {\n const { onIdle, idleTimeout = 10 * 60 * 1000 } = options || {};\n\n this.callbacks = onIdle ? [onIdle] : [];\n this.idleTimeout = idleTimeout;\n\n const _resetTimer = this._resetTimer.bind(this);\n\n window.addEventListener('load', _resetTimer, true);\n\n events.forEach((name) => {\n document.addEventListener(name, _resetTimer, true);\n });\n\n const debounce = (func: (...args: unknown[]) => void, wait: number) => {\n let timeout: number | undefined;\n return (...args: unknown[]) => {\n const context = this;\n const later = () => {\n timeout = undefined;\n func.apply(context, args);\n };\n clearTimeout(timeout);\n timeout = window.setTimeout(later, wait);\n };\n };\n\n if (options?.captureScroll) {\n // debounce scroll events\n const scroll = debounce(_resetTimer, options?.scrollDebounce ?? 100);\n window.addEventListener('scroll', scroll, true);\n }\n\n _resetTimer();\n }\n\n /**\n * @param {IdleCB} callback function to be called when user goes idle\n */\n public registerCallback(callback: IdleCB): void {\n this.callbacks.push(callback);\n }\n\n /**\n * Cleans up the idle manager and its listeners\n */\n public exit(): void {\n clearTimeout(this.timeoutID);\n window.removeEventListener('load', this._resetTimer, true);\n\n const _resetTimer = this._resetTimer.bind(this);\n events.forEach((name) => {\n document.removeEventListener(name, _resetTimer, true);\n });\n this.callbacks.forEach((cb) => {\n cb();\n });\n }\n\n /**\n * Resets the timeouts during cleanup\n */\n _resetTimer(): void {\n const exit = this.exit.bind(this);\n window.clearTimeout(this.timeoutID);\n this.timeoutID = window.setTimeout(exit, this.idleTimeout);\n }\n}\n"],"names":[],"mappings":"AAwBA,MAAM,SAAS,CAAC,aAAa,aAAa,WAAW,cAAc,OAAO;AAOnE,MAAM,YAAY;AAAA,EACvB,YAAsB,CAAA;AAAA,EACtB,cAAiD,KAAK,KAAK;AAAA,EAC3D,YAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWrB,OAAc,OACZ,UAqBI,IACS;AACb,WAAO,IAAI,YAAY,OAAO;AAAA,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QACT,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9B,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAE3D,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACtB,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YAC7B,EAAE,EAAE,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;IACpC,CAAC;IAED;;OAEG;IACK,WAAW;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;CACF"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module api/client
3
3
  */
4
- export * from './auth-client.ts';
5
- export { type DBCreateOptions, IdbKeyVal } from './db.ts';
6
- export * from './idle-manager.ts';
7
- export { type AuthClientStorage, IdbStorage, KEY_STORAGE_DELEGATION, KEY_STORAGE_KEY, LocalStorage, } from './storage.ts';
4
+ export * from './auth-client.js';
5
+ export { type DBCreateOptions, IdbKeyVal } from './db.js';
6
+ export * from './idle-manager.js';
7
+ export { type AuthClientStorage, IdbStorage, KEY_STORAGE_DELEGATION, KEY_STORAGE_KEY, LocalStorage, } from './storage.js';
@@ -1,15 +1,8 @@
1
- import { AuthClient, ERROR_USER_INTERRUPT } from "./auth-client.js";
2
- import { IdbKeyVal } from "./db.js";
3
- import { IdleManager } from "./idle-manager.js";
4
- import { IdbStorage, KEY_STORAGE_DELEGATION, KEY_STORAGE_KEY, LocalStorage } from "./storage.js";
5
- export {
6
- AuthClient,
7
- ERROR_USER_INTERRUPT,
8
- IdbKeyVal,
9
- IdbStorage,
10
- IdleManager,
11
- KEY_STORAGE_DELEGATION,
12
- KEY_STORAGE_KEY,
13
- LocalStorage
14
- };
15
- //# sourceMappingURL=index.js.map
1
+ /**
2
+ * @module api/client
3
+ */
4
+ export * from './auth-client.js';
5
+ export { IdbKeyVal } from './db.js';
6
+ export * from './idle-manager.js';
7
+ export { IdbStorage, KEY_STORAGE_DELEGATION, KEY_STORAGE_KEY, LocalStorage, } from './storage.js';
8
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAwB,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAEL,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAC"}
@@ -1,4 +1,4 @@
1
- import { DBCreateOptions, IdbKeyVal } from './db.ts';
1
+ import { type DBCreateOptions, IdbKeyVal } from './db.js';
2
2
  export declare const KEY_STORAGE_KEY = "identity";
3
3
  export declare const KEY_STORAGE_DELEGATION = "delegation";
4
4
  export declare const KEY_VECTOR = "iv";