@arbidocs/client 0.5.57 → 0.5.59
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.cjs +122 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -6
- package/dist/index.d.ts +48 -6
- package/dist/index.js +121 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import createFetchClient, { Middleware } from 'openapi-fetch';
|
|
2
2
|
|
|
3
|
+
/** HTTP plumbing only: no token, workspace selection, response-body parsing or retries. */
|
|
4
|
+
interface HttpRequestInfo {
|
|
5
|
+
readonly method: string;
|
|
6
|
+
/** URL without credentials, query or fragment; hooks never receive bodies or headers. */
|
|
7
|
+
readonly url: string;
|
|
8
|
+
}
|
|
9
|
+
interface HttpResponseInfo extends HttpRequestInfo {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
readonly durationMs: number;
|
|
12
|
+
}
|
|
13
|
+
interface HttpErrorInfo extends HttpRequestInfo {
|
|
14
|
+
readonly error: unknown;
|
|
15
|
+
readonly durationMs: number;
|
|
16
|
+
}
|
|
17
|
+
interface HttpTransportOptions {
|
|
18
|
+
/** Fetch-compatible implementation; defaults to globalThis.fetch at request time. */
|
|
19
|
+
fetch?: typeof globalThis.fetch;
|
|
20
|
+
/** Time until the adapter returns a Response (native fetch: headers). Disabled by default. */
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
onRequest?: (request: HttpRequestInfo) => void;
|
|
23
|
+
onResponse?: (response: HttpResponseInfo) => void;
|
|
24
|
+
onError?: (failure: HttpErrorInfo) => void;
|
|
25
|
+
}
|
|
26
|
+
interface HttpTransport {
|
|
27
|
+
readonly fetch: typeof globalThis.fetch;
|
|
28
|
+
readonly customFetch: boolean;
|
|
29
|
+
/** Use the same timeout/hooks with a specialized adapter, such as upload-progress XHR. */
|
|
30
|
+
withFetch(adapter: typeof globalThis.fetch): typeof globalThis.fetch;
|
|
31
|
+
}
|
|
32
|
+
declare function createHttpTransport(options?: HttpTransportOptions): HttpTransport;
|
|
33
|
+
|
|
3
34
|
/**
|
|
4
35
|
* This file was auto-generated by openapi-typescript.
|
|
5
36
|
* Do not make direct changes to the file.
|
|
@@ -39279,6 +39310,8 @@ interface BearerAuthMiddlewareConfig {
|
|
|
39279
39310
|
/** The new access token, or `null`. Ending a session the server refused is the handler's job. */
|
|
39280
39311
|
type ReloginHandler = () => Promise<string | null>;
|
|
39281
39312
|
interface AutoReloginMiddlewareConfig {
|
|
39313
|
+
/** Send recovered requests through the same configured/session-gated transport. */
|
|
39314
|
+
fetch?: typeof globalThis.fetch;
|
|
39282
39315
|
reloginHandler: ReloginHandler;
|
|
39283
39316
|
/** URL substrings that should never trigger re-login (e.g. the login endpoint itself) */
|
|
39284
39317
|
reloginExcludePatterns?: string[];
|
|
@@ -39324,12 +39357,14 @@ interface SessionKeys {
|
|
|
39324
39357
|
}
|
|
39325
39358
|
/**
|
|
39326
39359
|
* Where the signed-in identity is kept between page loads (the signing key and the server session
|
|
39327
|
-
* key). Browsers default to the bundled encrypted IndexedDB store;
|
|
39328
|
-
*
|
|
39360
|
+
* key). Browsers default to the bundled encrypted IndexedDB store; without IndexedDB the default
|
|
39361
|
+
* is per-client memory. Hosts may supply their own persistence. A silent re-login reads the key from here and saves the new server session key back.
|
|
39329
39362
|
*/
|
|
39330
39363
|
interface SessionPersistence {
|
|
39331
39364
|
getSession(): Promise<SessionKeys | null>;
|
|
39332
39365
|
saveSession(data: SessionKeys): Promise<void>;
|
|
39366
|
+
/** Clear local key material when signing out everywhere. Optional for existing adapters. */
|
|
39367
|
+
clearSession?(): Promise<void>;
|
|
39333
39368
|
}
|
|
39334
39369
|
interface AuthStateProvider {
|
|
39335
39370
|
getUserEmail(): string | null;
|
|
@@ -40426,6 +40461,8 @@ declare function disconnectSso(params: DisconnectSsoParams, deps: DisconnectSsoD
|
|
|
40426
40461
|
|
|
40427
40462
|
declare const API_PREFIX: "/v1";
|
|
40428
40463
|
interface ArbiClientOptions {
|
|
40464
|
+
/** Shared HTTP adapter, header timeout and metadata hooks; no workspace or retry policy. */
|
|
40465
|
+
transport?: HttpTransportOptions;
|
|
40429
40466
|
/**
|
|
40430
40467
|
* Base URL for the ARBI API (e.g. "https://api.mydeployment.com"; `''` for the page's own
|
|
40431
40468
|
* origin). A function is read on every request: a host whose configuration arrives after the
|
|
@@ -40446,8 +40483,8 @@ interface ArbiClientOptions {
|
|
|
40446
40483
|
session?: SessionManager;
|
|
40447
40484
|
/**
|
|
40448
40485
|
* Where the signing key and server session key are kept between page loads. Browsers default to
|
|
40449
|
-
* the bundled encrypted IndexedDB store;
|
|
40450
|
-
*
|
|
40486
|
+
* the bundled encrypted IndexedDB store; without IndexedDB the default is per-client memory.
|
|
40487
|
+
* Supply an adapter explicitly to persist Node sessions beyond this instance.
|
|
40451
40488
|
*/
|
|
40452
40489
|
persistence?: SessionPersistence;
|
|
40453
40490
|
/**
|
|
@@ -40476,6 +40513,8 @@ interface ArbiClientOptions {
|
|
|
40476
40513
|
userEmail?: string;
|
|
40477
40514
|
}
|
|
40478
40515
|
interface ArbiClient {
|
|
40516
|
+
/** Session-gated HTTP for raw streaming/multipart adapters. Optional for existing host adapters. */
|
|
40517
|
+
http?: HttpTransport;
|
|
40479
40518
|
/** Type-safe openapi-fetch client with middleware */
|
|
40480
40519
|
fetch: ReturnType<typeof createFetchClient<paths>>;
|
|
40481
40520
|
/** In-memory session state */
|
|
@@ -40572,7 +40611,7 @@ interface ArbiClient {
|
|
|
40572
40611
|
encryptMessageWithSharedSecret: typeof encryptMessageWithSharedSecret;
|
|
40573
40612
|
decryptMessageWithSharedSecret: typeof decryptMessageWithSharedSecret;
|
|
40574
40613
|
};
|
|
40575
|
-
/**
|
|
40614
|
+
/** The same session-key persistence used by login and session recovery. */
|
|
40576
40615
|
storage: {
|
|
40577
40616
|
getSession: typeof getSession;
|
|
40578
40617
|
saveSession: typeof saveSession;
|
|
@@ -40746,4 +40785,7 @@ interface OpenAllDeps {
|
|
|
40746
40785
|
*/
|
|
40747
40786
|
declare function createAllWorkspacesOpener(deps: OpenAllDeps): () => Promise<void>;
|
|
40748
40787
|
|
|
40749
|
-
|
|
40788
|
+
/** Per-client memory only: no browser globals, files or process-wide shared identity. */
|
|
40789
|
+
declare function createMemorySessionPersistence(): SessionPersistence;
|
|
40790
|
+
|
|
40791
|
+
export { type $defs, ACCESS_TOKEN_STORAGE_KEY, API_PREFIX, type ArbiClient, type ArbiClientOptions, type AuthStateProvider, type AutoReloginMiddlewareConfig, type BearerAuthMiddlewareConfig, CALL_KEY_BYTES, CHAT_KEY_BYTES, type CallPeer, type ChangePasswordParams, type ChangePasswordRequest, type ChangePasswordResult, type CryptoProvider, type DisconnectSsoParams, ENCRYPTED_RECOVERY_KEY_SIZE, type HttpErrorInfo, type HttpRequestInfo, type HttpResponseInfo, type HttpTransport, type HttpTransportOptions, type KeyLoginCredentials, type KeyPair, type ListedWorkspaceKey, type LoginCredentials, type LoginParams, type LoginProfile, type LoginProvider, type LoginRequest, type LoginResponse, type LoginResult, type LoginWithKeyParams, type OfflineSealer, type OfflineSealerOptions, type OnReloginSuccess, type OpenAllDeps, type ParsedRecoveryUrl, type PasswordChangeCredentials, RECOVERY_KEY_ERRORS, type RecoveryKeyParams, type RecoveryKeyValidationResult, type RegisterParams, type RegisterRequest, type RegisterResult, type RegistrationCredentials, type ReloginDeps, type ReloginFailure, type ReloginHandler, type ReopenDeps, SECURE_MAIL_KEY_BYTES, type SealedSecureMail, type SecureMailCiphertexts, type SecureMailClaim, type SessionClaims, type SessionData, type SessionKeys, type SessionManager, type SessionManagerOptions, type SessionPersistence, type SessionSignIn, type SessionState, type SessionStateStorage, type SessionUser, type SignInHooks, type SsoTokenSource, type StoredSessionState, type TokenProvider, UNENCRYPTED_RECOVERY_KEY_SIZE, type UserKeypairs, type WebSocketClientMessage, type WebSocketServerMessage, type WorkspaceKeyRefreshProvider, type WorkspaceKeys, type WorkspaceOpenProvider, type WorkspaceOpens, type WsAgentDmStatusMessage, type WsAuthMessage, type WsAuthResultMessage, type WsBatchCompleteMessage, type WsChatMessageMessage, type WsChatReadMessage, type WsChatUpdatedMessage, type WsConnectionClosedMessage, type WsConversationMessagePostedMessage, type WsErrorMessage, type WsNotificationResponse, type WsPresenceUpdateMessage, type WsResponseCompleteMessage, type WsTaskUpdateMessage, authRequestError, base64Decode, base64Encode, base64ToBytes, base64UrlToBytes, browserSessionStateStorage, buildCallFragment, buildCallLink, buildWebSocketUrl, bytesToBase64, bytesToBase64Url, canPersistSession, changePassword, clearAllData, clearSession, type components, computeSharedSecret, createAllWorkspacesOpener, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createHttpTransport, createMemorySessionPersistence, createOfflineSealer, createRecoveryFile, createRecoveryUrl, createReloginHandler, createSessionManager, createWorkspaceKeys, createWorkspaceOpens, createWorkspaceReopener, decodeCallKey, decodeSecureMailKey, decryptCallTitle, decryptFile, decryptMessage, decryptMessageWithSharedSecret, decryptRecoveryKey, decryptWithChatKey, deriveDirectChatKey, deriveEncryptionKeypairFromSigning, derivePublicKey, disconnectSso, encodeCallKey, encryptCallTitle, encryptFile, encryptMessage, encryptMessageWithSharedSecret, encryptRecoveryKey, encryptWithChatKey, encryptionKeypairFromSigningKey, generateCallKey, generateChatKey, generateIdentityKeypair, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRegistrationCredentials, generateUserKeypairs, getRecoveryKeyFilename, getSession, getUserEncryptionKeypair, hasSession, identityFromLoginResponse, initSodium, initializeDatabase, isAbortError, isEncryptedRecoveryKey, isMessageType, openCallKeyOf, openSealedCallKey, openSealedChatKey, openSecureMail, type operations, parseCallFragment, parseRecoveryUrl, parseServerMessage, passwordChangeErrorMessage, type paths, prewarmKeyPairs, readSessionClaims, requestSsoDisconnectCode, saveSession, sealCallKey, sealCallKeyForPeers, sealChatKey, sealKeyForSession, sealSecureMail, sealedBoxDecrypt, sealedBoxEncrypt, secureMailClaim, signMessage, unlockIdentityWithPassword, unwrapIdentityKey, unwrapWorkspaceKey, updateWrappedIdentityKey, validateRecoveryKeyFile, type webhooks, workspaceKeyRequiredOf, wrapIdentityKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import createFetchClient, { Middleware } from 'openapi-fetch';
|
|
2
2
|
|
|
3
|
+
/** HTTP plumbing only: no token, workspace selection, response-body parsing or retries. */
|
|
4
|
+
interface HttpRequestInfo {
|
|
5
|
+
readonly method: string;
|
|
6
|
+
/** URL without credentials, query or fragment; hooks never receive bodies or headers. */
|
|
7
|
+
readonly url: string;
|
|
8
|
+
}
|
|
9
|
+
interface HttpResponseInfo extends HttpRequestInfo {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
readonly durationMs: number;
|
|
12
|
+
}
|
|
13
|
+
interface HttpErrorInfo extends HttpRequestInfo {
|
|
14
|
+
readonly error: unknown;
|
|
15
|
+
readonly durationMs: number;
|
|
16
|
+
}
|
|
17
|
+
interface HttpTransportOptions {
|
|
18
|
+
/** Fetch-compatible implementation; defaults to globalThis.fetch at request time. */
|
|
19
|
+
fetch?: typeof globalThis.fetch;
|
|
20
|
+
/** Time until the adapter returns a Response (native fetch: headers). Disabled by default. */
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
onRequest?: (request: HttpRequestInfo) => void;
|
|
23
|
+
onResponse?: (response: HttpResponseInfo) => void;
|
|
24
|
+
onError?: (failure: HttpErrorInfo) => void;
|
|
25
|
+
}
|
|
26
|
+
interface HttpTransport {
|
|
27
|
+
readonly fetch: typeof globalThis.fetch;
|
|
28
|
+
readonly customFetch: boolean;
|
|
29
|
+
/** Use the same timeout/hooks with a specialized adapter, such as upload-progress XHR. */
|
|
30
|
+
withFetch(adapter: typeof globalThis.fetch): typeof globalThis.fetch;
|
|
31
|
+
}
|
|
32
|
+
declare function createHttpTransport(options?: HttpTransportOptions): HttpTransport;
|
|
33
|
+
|
|
3
34
|
/**
|
|
4
35
|
* This file was auto-generated by openapi-typescript.
|
|
5
36
|
* Do not make direct changes to the file.
|
|
@@ -39279,6 +39310,8 @@ interface BearerAuthMiddlewareConfig {
|
|
|
39279
39310
|
/** The new access token, or `null`. Ending a session the server refused is the handler's job. */
|
|
39280
39311
|
type ReloginHandler = () => Promise<string | null>;
|
|
39281
39312
|
interface AutoReloginMiddlewareConfig {
|
|
39313
|
+
/** Send recovered requests through the same configured/session-gated transport. */
|
|
39314
|
+
fetch?: typeof globalThis.fetch;
|
|
39282
39315
|
reloginHandler: ReloginHandler;
|
|
39283
39316
|
/** URL substrings that should never trigger re-login (e.g. the login endpoint itself) */
|
|
39284
39317
|
reloginExcludePatterns?: string[];
|
|
@@ -39324,12 +39357,14 @@ interface SessionKeys {
|
|
|
39324
39357
|
}
|
|
39325
39358
|
/**
|
|
39326
39359
|
* Where the signed-in identity is kept between page loads (the signing key and the server session
|
|
39327
|
-
* key). Browsers default to the bundled encrypted IndexedDB store;
|
|
39328
|
-
*
|
|
39360
|
+
* key). Browsers default to the bundled encrypted IndexedDB store; without IndexedDB the default
|
|
39361
|
+
* is per-client memory. Hosts may supply their own persistence. A silent re-login reads the key from here and saves the new server session key back.
|
|
39329
39362
|
*/
|
|
39330
39363
|
interface SessionPersistence {
|
|
39331
39364
|
getSession(): Promise<SessionKeys | null>;
|
|
39332
39365
|
saveSession(data: SessionKeys): Promise<void>;
|
|
39366
|
+
/** Clear local key material when signing out everywhere. Optional for existing adapters. */
|
|
39367
|
+
clearSession?(): Promise<void>;
|
|
39333
39368
|
}
|
|
39334
39369
|
interface AuthStateProvider {
|
|
39335
39370
|
getUserEmail(): string | null;
|
|
@@ -40426,6 +40461,8 @@ declare function disconnectSso(params: DisconnectSsoParams, deps: DisconnectSsoD
|
|
|
40426
40461
|
|
|
40427
40462
|
declare const API_PREFIX: "/v1";
|
|
40428
40463
|
interface ArbiClientOptions {
|
|
40464
|
+
/** Shared HTTP adapter, header timeout and metadata hooks; no workspace or retry policy. */
|
|
40465
|
+
transport?: HttpTransportOptions;
|
|
40429
40466
|
/**
|
|
40430
40467
|
* Base URL for the ARBI API (e.g. "https://api.mydeployment.com"; `''` for the page's own
|
|
40431
40468
|
* origin). A function is read on every request: a host whose configuration arrives after the
|
|
@@ -40446,8 +40483,8 @@ interface ArbiClientOptions {
|
|
|
40446
40483
|
session?: SessionManager;
|
|
40447
40484
|
/**
|
|
40448
40485
|
* Where the signing key and server session key are kept between page loads. Browsers default to
|
|
40449
|
-
* the bundled encrypted IndexedDB store;
|
|
40450
|
-
*
|
|
40486
|
+
* the bundled encrypted IndexedDB store; without IndexedDB the default is per-client memory.
|
|
40487
|
+
* Supply an adapter explicitly to persist Node sessions beyond this instance.
|
|
40451
40488
|
*/
|
|
40452
40489
|
persistence?: SessionPersistence;
|
|
40453
40490
|
/**
|
|
@@ -40476,6 +40513,8 @@ interface ArbiClientOptions {
|
|
|
40476
40513
|
userEmail?: string;
|
|
40477
40514
|
}
|
|
40478
40515
|
interface ArbiClient {
|
|
40516
|
+
/** Session-gated HTTP for raw streaming/multipart adapters. Optional for existing host adapters. */
|
|
40517
|
+
http?: HttpTransport;
|
|
40479
40518
|
/** Type-safe openapi-fetch client with middleware */
|
|
40480
40519
|
fetch: ReturnType<typeof createFetchClient<paths>>;
|
|
40481
40520
|
/** In-memory session state */
|
|
@@ -40572,7 +40611,7 @@ interface ArbiClient {
|
|
|
40572
40611
|
encryptMessageWithSharedSecret: typeof encryptMessageWithSharedSecret;
|
|
40573
40612
|
decryptMessageWithSharedSecret: typeof decryptMessageWithSharedSecret;
|
|
40574
40613
|
};
|
|
40575
|
-
/**
|
|
40614
|
+
/** The same session-key persistence used by login and session recovery. */
|
|
40576
40615
|
storage: {
|
|
40577
40616
|
getSession: typeof getSession;
|
|
40578
40617
|
saveSession: typeof saveSession;
|
|
@@ -40746,4 +40785,7 @@ interface OpenAllDeps {
|
|
|
40746
40785
|
*/
|
|
40747
40786
|
declare function createAllWorkspacesOpener(deps: OpenAllDeps): () => Promise<void>;
|
|
40748
40787
|
|
|
40749
|
-
|
|
40788
|
+
/** Per-client memory only: no browser globals, files or process-wide shared identity. */
|
|
40789
|
+
declare function createMemorySessionPersistence(): SessionPersistence;
|
|
40790
|
+
|
|
40791
|
+
export { type $defs, ACCESS_TOKEN_STORAGE_KEY, API_PREFIX, type ArbiClient, type ArbiClientOptions, type AuthStateProvider, type AutoReloginMiddlewareConfig, type BearerAuthMiddlewareConfig, CALL_KEY_BYTES, CHAT_KEY_BYTES, type CallPeer, type ChangePasswordParams, type ChangePasswordRequest, type ChangePasswordResult, type CryptoProvider, type DisconnectSsoParams, ENCRYPTED_RECOVERY_KEY_SIZE, type HttpErrorInfo, type HttpRequestInfo, type HttpResponseInfo, type HttpTransport, type HttpTransportOptions, type KeyLoginCredentials, type KeyPair, type ListedWorkspaceKey, type LoginCredentials, type LoginParams, type LoginProfile, type LoginProvider, type LoginRequest, type LoginResponse, type LoginResult, type LoginWithKeyParams, type OfflineSealer, type OfflineSealerOptions, type OnReloginSuccess, type OpenAllDeps, type ParsedRecoveryUrl, type PasswordChangeCredentials, RECOVERY_KEY_ERRORS, type RecoveryKeyParams, type RecoveryKeyValidationResult, type RegisterParams, type RegisterRequest, type RegisterResult, type RegistrationCredentials, type ReloginDeps, type ReloginFailure, type ReloginHandler, type ReopenDeps, SECURE_MAIL_KEY_BYTES, type SealedSecureMail, type SecureMailCiphertexts, type SecureMailClaim, type SessionClaims, type SessionData, type SessionKeys, type SessionManager, type SessionManagerOptions, type SessionPersistence, type SessionSignIn, type SessionState, type SessionStateStorage, type SessionUser, type SignInHooks, type SsoTokenSource, type StoredSessionState, type TokenProvider, UNENCRYPTED_RECOVERY_KEY_SIZE, type UserKeypairs, type WebSocketClientMessage, type WebSocketServerMessage, type WorkspaceKeyRefreshProvider, type WorkspaceKeys, type WorkspaceOpenProvider, type WorkspaceOpens, type WsAgentDmStatusMessage, type WsAuthMessage, type WsAuthResultMessage, type WsBatchCompleteMessage, type WsChatMessageMessage, type WsChatReadMessage, type WsChatUpdatedMessage, type WsConnectionClosedMessage, type WsConversationMessagePostedMessage, type WsErrorMessage, type WsNotificationResponse, type WsPresenceUpdateMessage, type WsResponseCompleteMessage, type WsTaskUpdateMessage, authRequestError, base64Decode, base64Encode, base64ToBytes, base64UrlToBytes, browserSessionStateStorage, buildCallFragment, buildCallLink, buildWebSocketUrl, bytesToBase64, bytesToBase64Url, canPersistSession, changePassword, clearAllData, clearSession, type components, computeSharedSecret, createAllWorkspacesOpener, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createHttpTransport, createMemorySessionPersistence, createOfflineSealer, createRecoveryFile, createRecoveryUrl, createReloginHandler, createSessionManager, createWorkspaceKeys, createWorkspaceOpens, createWorkspaceReopener, decodeCallKey, decodeSecureMailKey, decryptCallTitle, decryptFile, decryptMessage, decryptMessageWithSharedSecret, decryptRecoveryKey, decryptWithChatKey, deriveDirectChatKey, deriveEncryptionKeypairFromSigning, derivePublicKey, disconnectSso, encodeCallKey, encryptCallTitle, encryptFile, encryptMessage, encryptMessageWithSharedSecret, encryptRecoveryKey, encryptWithChatKey, encryptionKeypairFromSigningKey, generateCallKey, generateChatKey, generateIdentityKeypair, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRegistrationCredentials, generateUserKeypairs, getRecoveryKeyFilename, getSession, getUserEncryptionKeypair, hasSession, identityFromLoginResponse, initSodium, initializeDatabase, isAbortError, isEncryptedRecoveryKey, isMessageType, openCallKeyOf, openSealedCallKey, openSealedChatKey, openSecureMail, type operations, parseCallFragment, parseRecoveryUrl, parseServerMessage, passwordChangeErrorMessage, type paths, prewarmKeyPairs, readSessionClaims, requestSsoDisconnectCode, saveSession, sealCallKey, sealCallKeyForPeers, sealChatKey, sealKeyForSession, sealSecureMail, sealedBoxDecrypt, sealedBoxEncrypt, secureMailClaim, signMessage, unlockIdentityWithPassword, unwrapIdentityKey, unwrapWorkspaceKey, updateWrappedIdentityKey, validateRecoveryKeyFile, type webhooks, workspaceKeyRequiredOf, wrapIdentityKey };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,90 @@ import sodium from 'libsodium-wrappers-sumo';
|
|
|
3
3
|
|
|
4
4
|
// src/client.ts
|
|
5
5
|
|
|
6
|
+
// src/memory-persistence.ts
|
|
7
|
+
function copy(keys) {
|
|
8
|
+
return {
|
|
9
|
+
...keys,
|
|
10
|
+
signingPrivateKey: keys.signingPrivateKey.slice(),
|
|
11
|
+
...keys.serverSessionKey ? { serverSessionKey: keys.serverSessionKey.slice() } : {}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function createMemorySessionPersistence() {
|
|
15
|
+
let saved = null;
|
|
16
|
+
const clear = () => {
|
|
17
|
+
saved?.signingPrivateKey.fill(0);
|
|
18
|
+
saved?.serverSessionKey?.fill(0);
|
|
19
|
+
saved = null;
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
async getSession() {
|
|
23
|
+
return saved ? copy(saved) : null;
|
|
24
|
+
},
|
|
25
|
+
async saveSession(keys) {
|
|
26
|
+
const next = copy(keys);
|
|
27
|
+
clear();
|
|
28
|
+
saved = next;
|
|
29
|
+
},
|
|
30
|
+
async clearSession() {
|
|
31
|
+
clear();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/http-transport.ts
|
|
37
|
+
function createHttpTransport(options = {}) {
|
|
38
|
+
const { timeoutMs } = options;
|
|
39
|
+
if (timeoutMs !== void 0 && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) {
|
|
40
|
+
throw new RangeError("transport.timeoutMs must be a positive finite number.");
|
|
41
|
+
}
|
|
42
|
+
const wrap = (adapter2) => async (input, init) => {
|
|
43
|
+
const url = new URL(input instanceof Request ? input.url : String(input), "http://localhost");
|
|
44
|
+
url.username = "";
|
|
45
|
+
url.password = "";
|
|
46
|
+
url.search = "";
|
|
47
|
+
url.hash = "";
|
|
48
|
+
const info = {
|
|
49
|
+
method: (init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase(),
|
|
50
|
+
url: url.toString()
|
|
51
|
+
};
|
|
52
|
+
options.onRequest?.(info);
|
|
53
|
+
const started = performance.now();
|
|
54
|
+
let timer;
|
|
55
|
+
let requestInit = init;
|
|
56
|
+
if (timeoutMs !== void 0) {
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
const own = init?.signal ?? (input instanceof Request ? input.signal : void 0);
|
|
59
|
+
timer = setTimeout(
|
|
60
|
+
() => controller.abort(
|
|
61
|
+
new DOMException("Waiting for HTTP response timed out.", "TimeoutError")
|
|
62
|
+
),
|
|
63
|
+
timeoutMs
|
|
64
|
+
);
|
|
65
|
+
requestInit = {
|
|
66
|
+
...init,
|
|
67
|
+
signal: own ? AbortSignal.any([own, controller.signal]) : controller.signal
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
let response;
|
|
71
|
+
try {
|
|
72
|
+
response = await adapter2(input, requestInit);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
options.onError?.({ ...info, error, durationMs: performance.now() - started });
|
|
75
|
+
throw error;
|
|
76
|
+
} finally {
|
|
77
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
78
|
+
}
|
|
79
|
+
options.onResponse?.({
|
|
80
|
+
...info,
|
|
81
|
+
status: response.status,
|
|
82
|
+
durationMs: performance.now() - started
|
|
83
|
+
});
|
|
84
|
+
return response;
|
|
85
|
+
};
|
|
86
|
+
const adapter = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
87
|
+
return { fetch: wrap(adapter), customFetch: options.fetch !== void 0, withFetch: wrap };
|
|
88
|
+
}
|
|
89
|
+
|
|
6
90
|
// src/session.ts
|
|
7
91
|
function createInitialState(isSsoMode = false) {
|
|
8
92
|
return {
|
|
@@ -1154,11 +1238,11 @@ function createSessionGate() {
|
|
|
1154
1238
|
}
|
|
1155
1239
|
};
|
|
1156
1240
|
}
|
|
1157
|
-
function gatedFetch(gate,
|
|
1241
|
+
function gatedFetch(gate, fetch) {
|
|
1158
1242
|
return (input, init) => {
|
|
1159
1243
|
if (gate.closed) return Promise.reject(abortError());
|
|
1160
1244
|
const own = init?.signal ?? (input instanceof Request ? input.signal : void 0);
|
|
1161
|
-
return
|
|
1245
|
+
return fetch(input, { ...init, signal: eitherSignal(gate.signal, own) });
|
|
1162
1246
|
};
|
|
1163
1247
|
}
|
|
1164
1248
|
function createSessionGateMiddleware(gate) {
|
|
@@ -1372,7 +1456,7 @@ function createAutoReloginMiddleware(config) {
|
|
|
1372
1456
|
if (workspaceId) {
|
|
1373
1457
|
if (!await config.primeWorkspaceHandler(workspaceId)) return response;
|
|
1374
1458
|
const retry = cloneCache.get(request) ?? safeClone(request);
|
|
1375
|
-
if (retry) return fetch(retry);
|
|
1459
|
+
if (retry) return (config.fetch ?? globalThis.fetch)(retry);
|
|
1376
1460
|
config.onRetryCloneFailed?.();
|
|
1377
1461
|
return response;
|
|
1378
1462
|
}
|
|
@@ -1388,7 +1472,7 @@ function createAutoReloginMiddleware(config) {
|
|
|
1388
1472
|
const retry = cloneCache.get(request) ?? safeClone(request);
|
|
1389
1473
|
if (retry) {
|
|
1390
1474
|
if (token) retry.headers.set("Authorization", `Bearer ${token}`);
|
|
1391
|
-
return fetch(retry);
|
|
1475
|
+
return (config.fetch ?? globalThis.fetch)(retry);
|
|
1392
1476
|
}
|
|
1393
1477
|
config.onRetryCloneFailed?.();
|
|
1394
1478
|
return response;
|
|
@@ -1400,7 +1484,7 @@ function createAutoReloginMiddleware(config) {
|
|
|
1400
1484
|
if (newToken) {
|
|
1401
1485
|
const retryRequest = cloneCache.get(request) ?? request.clone();
|
|
1402
1486
|
retryRequest.headers.set("Authorization", `Bearer ${newToken}`);
|
|
1403
|
-
return fetch(retryRequest);
|
|
1487
|
+
return (config.fetch ?? globalThis.fetch)(retryRequest);
|
|
1404
1488
|
}
|
|
1405
1489
|
}
|
|
1406
1490
|
}
|
|
@@ -1413,12 +1497,12 @@ function createAutoReloginMiddleware(config) {
|
|
|
1413
1497
|
const cached = cloneCache.get(request);
|
|
1414
1498
|
if (cached) {
|
|
1415
1499
|
cached.headers.set("Authorization", `Bearer ${newToken}`);
|
|
1416
|
-
return fetch(cached);
|
|
1500
|
+
return (config.fetch ?? globalThis.fetch)(cached);
|
|
1417
1501
|
}
|
|
1418
1502
|
try {
|
|
1419
1503
|
const retryRequest = request.clone();
|
|
1420
1504
|
retryRequest.headers.set("Authorization", `Bearer ${newToken}`);
|
|
1421
|
-
return fetch(retryRequest);
|
|
1505
|
+
return (config.fetch ?? globalThis.fetch)(retryRequest);
|
|
1422
1506
|
} catch {
|
|
1423
1507
|
console.warn("[API] Could not retry request after re-login (body already consumed)");
|
|
1424
1508
|
config.onRetryCloneFailed?.();
|
|
@@ -1867,22 +1951,26 @@ var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
|
1867
1951
|
var MAX_RETRIES = 3;
|
|
1868
1952
|
var BASE_DELAY_MS = 200;
|
|
1869
1953
|
function isRetryableError(err) {
|
|
1870
|
-
if (!(err instanceof Error)) return false;
|
|
1954
|
+
if (!(err instanceof Error) || isAbortError(err)) return false;
|
|
1871
1955
|
const cause = err.cause;
|
|
1872
1956
|
if (cause?.code && RETRYABLE_CODES.has(cause.code)) return true;
|
|
1873
1957
|
const msg = err.message || "";
|
|
1874
1958
|
return RETRYABLE_CODES.has(msg) || msg.includes("ECONNREFUSED") || msg.includes("ECONNRESET");
|
|
1875
1959
|
}
|
|
1876
|
-
function createRetryFetch() {
|
|
1960
|
+
function createRetryFetch(fetch) {
|
|
1877
1961
|
return async (input, init) => {
|
|
1962
|
+
const method = (init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
|
|
1963
|
+
const maxRetries = method === "GET" || method === "HEAD" ? MAX_RETRIES : 0;
|
|
1964
|
+
const signal = init?.signal ?? (input instanceof Request ? input.signal : void 0);
|
|
1878
1965
|
let lastError;
|
|
1879
|
-
for (let attempt = 0; attempt <=
|
|
1966
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
1967
|
+
if (signal?.aborted) throw signal.reason ?? new DOMException("Request aborted.", "AbortError");
|
|
1880
1968
|
try {
|
|
1881
1969
|
const fetchInput = input instanceof Request ? input.clone() : input;
|
|
1882
|
-
return await
|
|
1970
|
+
return await fetch(fetchInput, init);
|
|
1883
1971
|
} catch (err) {
|
|
1884
1972
|
lastError = err;
|
|
1885
|
-
if (attempt <
|
|
1973
|
+
if (attempt < maxRetries && isRetryableError(err)) {
|
|
1886
1974
|
await new Promise((r) => setTimeout(r, BASE_DELAY_MS * 2 ** attempt));
|
|
1887
1975
|
continue;
|
|
1888
1976
|
}
|
|
@@ -1904,9 +1992,9 @@ function readBaseUrlPerRequest(fetchClient, base) {
|
|
|
1904
1992
|
}
|
|
1905
1993
|
var deploymentDomainOf = ({ deploymentDomain }) => typeof deploymentDomain === "function" ? deploymentDomain() : deploymentDomain;
|
|
1906
1994
|
function createArbiClient(options) {
|
|
1907
|
-
const { fetch
|
|
1995
|
+
const { fetch, http, session, persistence, workspaceKeys, workspaceOpens, auth } = createTransport(options);
|
|
1908
1996
|
const authDeps = {
|
|
1909
|
-
fetchClient:
|
|
1997
|
+
fetchClient: fetch,
|
|
1910
1998
|
session,
|
|
1911
1999
|
get deploymentDomain() {
|
|
1912
2000
|
return deploymentDomainOf(options);
|
|
@@ -1915,7 +2003,8 @@ function createArbiClient(options) {
|
|
|
1915
2003
|
signIn: options.signIn
|
|
1916
2004
|
};
|
|
1917
2005
|
return {
|
|
1918
|
-
fetch
|
|
2006
|
+
fetch,
|
|
2007
|
+
http,
|
|
1919
2008
|
workspaceKeys,
|
|
1920
2009
|
workspaceOpens,
|
|
1921
2010
|
session,
|
|
@@ -1947,8 +2036,8 @@ function createArbiClient(options) {
|
|
|
1947
2036
|
decryptMessageWithSharedSecret
|
|
1948
2037
|
},
|
|
1949
2038
|
storage: {
|
|
1950
|
-
getSession,
|
|
1951
|
-
saveSession
|
|
2039
|
+
getSession: () => persistence.getSession(),
|
|
2040
|
+
saveSession: (data) => persistence.saveSession(data)
|
|
1952
2041
|
}
|
|
1953
2042
|
};
|
|
1954
2043
|
}
|
|
@@ -1962,12 +2051,18 @@ function createTransport(options) {
|
|
|
1962
2051
|
onRetryCloneFailed,
|
|
1963
2052
|
userEmail
|
|
1964
2053
|
} = options;
|
|
1965
|
-
const persistence = options.persistence ?? { getSession, saveSession };
|
|
2054
|
+
const persistence = options.persistence ?? (typeof indexedDB === "undefined" ? createMemorySessionPersistence() : { getSession, saveSession, clearSession: clearAllData });
|
|
1966
2055
|
const baseUrlOption = options.baseUrl;
|
|
1967
2056
|
const base = typeof baseUrlOption === "function" ? baseUrlOption : () => baseUrlOption;
|
|
1968
|
-
const
|
|
2057
|
+
const transport = createHttpTransport(options.transport);
|
|
2058
|
+
const retryFetch = createRetryFetch(transport.fetch);
|
|
1969
2059
|
const gate = createSessionGate();
|
|
1970
2060
|
const sessionFetch = gatedFetch(gate, retryFetch);
|
|
2061
|
+
const http = {
|
|
2062
|
+
fetch: gatedFetch(gate, transport.fetch),
|
|
2063
|
+
customFetch: transport.customFetch,
|
|
2064
|
+
withFetch: (adapter) => gatedFetch(gate, transport.withFetch(adapter))
|
|
2065
|
+
};
|
|
1971
2066
|
const session = options.session ?? createSessionManager();
|
|
1972
2067
|
if (userEmail) session.setUser(userEmail);
|
|
1973
2068
|
const tokenProvider = createTokenProvider(session);
|
|
@@ -2164,6 +2259,7 @@ function createTransport(options) {
|
|
|
2164
2259
|
for (const m of middleware) fetchClient.use(m);
|
|
2165
2260
|
fetchClient.use(
|
|
2166
2261
|
createAutoReloginMiddleware({
|
|
2262
|
+
fetch: sessionFetch,
|
|
2167
2263
|
reloginHandler: relogin,
|
|
2168
2264
|
reloginExcludePatterns,
|
|
2169
2265
|
reopenWorkspaceHandler: reopenWorkspace,
|
|
@@ -2179,6 +2275,7 @@ function createTransport(options) {
|
|
|
2179
2275
|
);
|
|
2180
2276
|
return {
|
|
2181
2277
|
fetch: fetchClient,
|
|
2278
|
+
http,
|
|
2182
2279
|
session,
|
|
2183
2280
|
persistence,
|
|
2184
2281
|
workspaceKeys,
|
|
@@ -2216,7 +2313,10 @@ function createTransport(options) {
|
|
|
2216
2313
|
}).catch((error) => console.warn("[API] Server logout failed:", error));
|
|
2217
2314
|
}
|
|
2218
2315
|
session.clear();
|
|
2219
|
-
if (everywhere)
|
|
2316
|
+
if (everywhere) {
|
|
2317
|
+
if (persistence.clearSession) await persistence.clearSession();
|
|
2318
|
+
else if (typeof indexedDB !== "undefined") await clearAllData();
|
|
2319
|
+
}
|
|
2220
2320
|
} finally {
|
|
2221
2321
|
gate.reopen();
|
|
2222
2322
|
}
|
|
@@ -2299,6 +2399,6 @@ function isMessageType(msg, type) {
|
|
|
2299
2399
|
return msg.type === type;
|
|
2300
2400
|
}
|
|
2301
2401
|
|
|
2302
|
-
export { ACCESS_TOKEN_STORAGE_KEY, API_PREFIX, CALL_KEY_BYTES, CHAT_KEY_BYTES, ENCRYPTED_RECOVERY_KEY_SIZE, RECOVERY_KEY_ERRORS, SECURE_MAIL_KEY_BYTES, UNENCRYPTED_RECOVERY_KEY_SIZE, authRequestError, base64Decode, base64Encode, base64ToBytes, base64UrlToBytes, browserSessionStateStorage, buildCallFragment, buildCallLink, buildWebSocketUrl, bytesToBase64, bytesToBase64Url, canPersistSession, changePassword, clearAllData, clearSession, computeSharedSecret, createAllWorkspacesOpener, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createOfflineSealer, createRecoveryFile, createRecoveryUrl, createReloginHandler, createSessionManager, createWorkspaceKeys, createWorkspaceOpens, createWorkspaceReopener, decodeCallKey, decodeSecureMailKey, decryptCallTitle, decryptFile, decryptMessage, decryptMessageWithSharedSecret, decryptRecoveryKey, decryptWithChatKey, deriveDirectChatKey, deriveEncryptionKeypairFromSigning, derivePublicKey, disconnectSso, encodeCallKey, encryptCallTitle, encryptFile, encryptMessage, encryptMessageWithSharedSecret, encryptRecoveryKey, encryptWithChatKey, encryptionKeypairFromSigningKey, generateCallKey, generateChatKey, generateIdentityKeypair, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRegistrationCredentials, generateUserKeypairs, getRecoveryKeyFilename, getSession, getUserEncryptionKeypair, hasSession, identityFromLoginResponse, initSodium, initializeDatabase, isAbortError, isEncryptedRecoveryKey, isMessageType, openCallKeyOf, openSealedCallKey, openSealedChatKey, openSecureMail, parseCallFragment, parseRecoveryUrl, parseServerMessage, passwordChangeErrorMessage, prewarmKeyPairs, readSessionClaims, requestSsoDisconnectCode, saveSession, sealCallKey, sealCallKeyForPeers, sealChatKey, sealKeyForSession, sealSecureMail, sealedBoxDecrypt, sealedBoxEncrypt, secureMailClaim, signMessage, unlockIdentityWithPassword, unwrapIdentityKey, unwrapWorkspaceKey, updateWrappedIdentityKey, validateRecoveryKeyFile, workspaceKeyRequiredOf, wrapIdentityKey };
|
|
2402
|
+
export { ACCESS_TOKEN_STORAGE_KEY, API_PREFIX, CALL_KEY_BYTES, CHAT_KEY_BYTES, ENCRYPTED_RECOVERY_KEY_SIZE, RECOVERY_KEY_ERRORS, SECURE_MAIL_KEY_BYTES, UNENCRYPTED_RECOVERY_KEY_SIZE, authRequestError, base64Decode, base64Encode, base64ToBytes, base64UrlToBytes, browserSessionStateStorage, buildCallFragment, buildCallLink, buildWebSocketUrl, bytesToBase64, bytesToBase64Url, canPersistSession, changePassword, clearAllData, clearSession, computeSharedSecret, createAllWorkspacesOpener, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createHttpTransport, createMemorySessionPersistence, createOfflineSealer, createRecoveryFile, createRecoveryUrl, createReloginHandler, createSessionManager, createWorkspaceKeys, createWorkspaceOpens, createWorkspaceReopener, decodeCallKey, decodeSecureMailKey, decryptCallTitle, decryptFile, decryptMessage, decryptMessageWithSharedSecret, decryptRecoveryKey, decryptWithChatKey, deriveDirectChatKey, deriveEncryptionKeypairFromSigning, derivePublicKey, disconnectSso, encodeCallKey, encryptCallTitle, encryptFile, encryptMessage, encryptMessageWithSharedSecret, encryptRecoveryKey, encryptWithChatKey, encryptionKeypairFromSigningKey, generateCallKey, generateChatKey, generateIdentityKeypair, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRegistrationCredentials, generateUserKeypairs, getRecoveryKeyFilename, getSession, getUserEncryptionKeypair, hasSession, identityFromLoginResponse, initSodium, initializeDatabase, isAbortError, isEncryptedRecoveryKey, isMessageType, openCallKeyOf, openSealedCallKey, openSealedChatKey, openSecureMail, parseCallFragment, parseRecoveryUrl, parseServerMessage, passwordChangeErrorMessage, prewarmKeyPairs, readSessionClaims, requestSsoDisconnectCode, saveSession, sealCallKey, sealCallKeyForPeers, sealChatKey, sealKeyForSession, sealSecureMail, sealedBoxDecrypt, sealedBoxEncrypt, secureMailClaim, signMessage, unlockIdentityWithPassword, unwrapIdentityKey, unwrapWorkspaceKey, updateWrappedIdentityKey, validateRecoveryKeyFile, workspaceKeyRequiredOf, wrapIdentityKey };
|
|
2303
2403
|
//# sourceMappingURL=index.js.map
|
|
2304
2404
|
//# sourceMappingURL=index.js.map
|