@arbidocs/client 0.5.57 → 0.5.58
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 +84 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +84 -17
- 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[];
|
|
@@ -40426,6 +40459,8 @@ declare function disconnectSso(params: DisconnectSsoParams, deps: DisconnectSsoD
|
|
|
40426
40459
|
|
|
40427
40460
|
declare const API_PREFIX: "/v1";
|
|
40428
40461
|
interface ArbiClientOptions {
|
|
40462
|
+
/** Shared HTTP adapter, header timeout and metadata hooks; no workspace or retry policy. */
|
|
40463
|
+
transport?: HttpTransportOptions;
|
|
40429
40464
|
/**
|
|
40430
40465
|
* Base URL for the ARBI API (e.g. "https://api.mydeployment.com"; `''` for the page's own
|
|
40431
40466
|
* origin). A function is read on every request: a host whose configuration arrives after the
|
|
@@ -40476,6 +40511,8 @@ interface ArbiClientOptions {
|
|
|
40476
40511
|
userEmail?: string;
|
|
40477
40512
|
}
|
|
40478
40513
|
interface ArbiClient {
|
|
40514
|
+
/** Session-gated HTTP for raw streaming/multipart adapters. Optional for existing host adapters. */
|
|
40515
|
+
http?: HttpTransport;
|
|
40479
40516
|
/** Type-safe openapi-fetch client with middleware */
|
|
40480
40517
|
fetch: ReturnType<typeof createFetchClient<paths>>;
|
|
40481
40518
|
/** In-memory session state */
|
|
@@ -40746,4 +40783,4 @@ interface OpenAllDeps {
|
|
|
40746
40783
|
*/
|
|
40747
40784
|
declare function createAllWorkspacesOpener(deps: OpenAllDeps): () => Promise<void>;
|
|
40748
40785
|
|
|
40749
|
-
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 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, 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 };
|
|
40786
|
+
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, 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[];
|
|
@@ -40426,6 +40459,8 @@ declare function disconnectSso(params: DisconnectSsoParams, deps: DisconnectSsoD
|
|
|
40426
40459
|
|
|
40427
40460
|
declare const API_PREFIX: "/v1";
|
|
40428
40461
|
interface ArbiClientOptions {
|
|
40462
|
+
/** Shared HTTP adapter, header timeout and metadata hooks; no workspace or retry policy. */
|
|
40463
|
+
transport?: HttpTransportOptions;
|
|
40429
40464
|
/**
|
|
40430
40465
|
* Base URL for the ARBI API (e.g. "https://api.mydeployment.com"; `''` for the page's own
|
|
40431
40466
|
* origin). A function is read on every request: a host whose configuration arrives after the
|
|
@@ -40476,6 +40511,8 @@ interface ArbiClientOptions {
|
|
|
40476
40511
|
userEmail?: string;
|
|
40477
40512
|
}
|
|
40478
40513
|
interface ArbiClient {
|
|
40514
|
+
/** Session-gated HTTP for raw streaming/multipart adapters. Optional for existing host adapters. */
|
|
40515
|
+
http?: HttpTransport;
|
|
40479
40516
|
/** Type-safe openapi-fetch client with middleware */
|
|
40480
40517
|
fetch: ReturnType<typeof createFetchClient<paths>>;
|
|
40481
40518
|
/** In-memory session state */
|
|
@@ -40746,4 +40783,4 @@ interface OpenAllDeps {
|
|
|
40746
40783
|
*/
|
|
40747
40784
|
declare function createAllWorkspacesOpener(deps: OpenAllDeps): () => Promise<void>;
|
|
40748
40785
|
|
|
40749
|
-
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 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, 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 };
|
|
40786
|
+
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, 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,60 @@ import sodium from 'libsodium-wrappers-sumo';
|
|
|
3
3
|
|
|
4
4
|
// src/client.ts
|
|
5
5
|
|
|
6
|
+
// src/http-transport.ts
|
|
7
|
+
function createHttpTransport(options = {}) {
|
|
8
|
+
const { timeoutMs } = options;
|
|
9
|
+
if (timeoutMs !== void 0 && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) {
|
|
10
|
+
throw new RangeError("transport.timeoutMs must be a positive finite number.");
|
|
11
|
+
}
|
|
12
|
+
const wrap = (adapter2) => async (input, init) => {
|
|
13
|
+
const url = new URL(input instanceof Request ? input.url : String(input), "http://localhost");
|
|
14
|
+
url.username = "";
|
|
15
|
+
url.password = "";
|
|
16
|
+
url.search = "";
|
|
17
|
+
url.hash = "";
|
|
18
|
+
const info = {
|
|
19
|
+
method: (init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase(),
|
|
20
|
+
url: url.toString()
|
|
21
|
+
};
|
|
22
|
+
options.onRequest?.(info);
|
|
23
|
+
const started = performance.now();
|
|
24
|
+
let timer;
|
|
25
|
+
let requestInit = init;
|
|
26
|
+
if (timeoutMs !== void 0) {
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
const own = init?.signal ?? (input instanceof Request ? input.signal : void 0);
|
|
29
|
+
timer = setTimeout(
|
|
30
|
+
() => controller.abort(
|
|
31
|
+
new DOMException("Waiting for HTTP response timed out.", "TimeoutError")
|
|
32
|
+
),
|
|
33
|
+
timeoutMs
|
|
34
|
+
);
|
|
35
|
+
requestInit = {
|
|
36
|
+
...init,
|
|
37
|
+
signal: own ? AbortSignal.any([own, controller.signal]) : controller.signal
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
let response;
|
|
41
|
+
try {
|
|
42
|
+
response = await adapter2(input, requestInit);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
options.onError?.({ ...info, error, durationMs: performance.now() - started });
|
|
45
|
+
throw error;
|
|
46
|
+
} finally {
|
|
47
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
48
|
+
}
|
|
49
|
+
options.onResponse?.({
|
|
50
|
+
...info,
|
|
51
|
+
status: response.status,
|
|
52
|
+
durationMs: performance.now() - started
|
|
53
|
+
});
|
|
54
|
+
return response;
|
|
55
|
+
};
|
|
56
|
+
const adapter = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
|
|
57
|
+
return { fetch: wrap(adapter), customFetch: options.fetch !== void 0, withFetch: wrap };
|
|
58
|
+
}
|
|
59
|
+
|
|
6
60
|
// src/session.ts
|
|
7
61
|
function createInitialState(isSsoMode = false) {
|
|
8
62
|
return {
|
|
@@ -1154,11 +1208,11 @@ function createSessionGate() {
|
|
|
1154
1208
|
}
|
|
1155
1209
|
};
|
|
1156
1210
|
}
|
|
1157
|
-
function gatedFetch(gate,
|
|
1211
|
+
function gatedFetch(gate, fetch) {
|
|
1158
1212
|
return (input, init) => {
|
|
1159
1213
|
if (gate.closed) return Promise.reject(abortError());
|
|
1160
1214
|
const own = init?.signal ?? (input instanceof Request ? input.signal : void 0);
|
|
1161
|
-
return
|
|
1215
|
+
return fetch(input, { ...init, signal: eitherSignal(gate.signal, own) });
|
|
1162
1216
|
};
|
|
1163
1217
|
}
|
|
1164
1218
|
function createSessionGateMiddleware(gate) {
|
|
@@ -1372,7 +1426,7 @@ function createAutoReloginMiddleware(config) {
|
|
|
1372
1426
|
if (workspaceId) {
|
|
1373
1427
|
if (!await config.primeWorkspaceHandler(workspaceId)) return response;
|
|
1374
1428
|
const retry = cloneCache.get(request) ?? safeClone(request);
|
|
1375
|
-
if (retry) return fetch(retry);
|
|
1429
|
+
if (retry) return (config.fetch ?? globalThis.fetch)(retry);
|
|
1376
1430
|
config.onRetryCloneFailed?.();
|
|
1377
1431
|
return response;
|
|
1378
1432
|
}
|
|
@@ -1388,7 +1442,7 @@ function createAutoReloginMiddleware(config) {
|
|
|
1388
1442
|
const retry = cloneCache.get(request) ?? safeClone(request);
|
|
1389
1443
|
if (retry) {
|
|
1390
1444
|
if (token) retry.headers.set("Authorization", `Bearer ${token}`);
|
|
1391
|
-
return fetch(retry);
|
|
1445
|
+
return (config.fetch ?? globalThis.fetch)(retry);
|
|
1392
1446
|
}
|
|
1393
1447
|
config.onRetryCloneFailed?.();
|
|
1394
1448
|
return response;
|
|
@@ -1400,7 +1454,7 @@ function createAutoReloginMiddleware(config) {
|
|
|
1400
1454
|
if (newToken) {
|
|
1401
1455
|
const retryRequest = cloneCache.get(request) ?? request.clone();
|
|
1402
1456
|
retryRequest.headers.set("Authorization", `Bearer ${newToken}`);
|
|
1403
|
-
return fetch(retryRequest);
|
|
1457
|
+
return (config.fetch ?? globalThis.fetch)(retryRequest);
|
|
1404
1458
|
}
|
|
1405
1459
|
}
|
|
1406
1460
|
}
|
|
@@ -1413,12 +1467,12 @@ function createAutoReloginMiddleware(config) {
|
|
|
1413
1467
|
const cached = cloneCache.get(request);
|
|
1414
1468
|
if (cached) {
|
|
1415
1469
|
cached.headers.set("Authorization", `Bearer ${newToken}`);
|
|
1416
|
-
return fetch(cached);
|
|
1470
|
+
return (config.fetch ?? globalThis.fetch)(cached);
|
|
1417
1471
|
}
|
|
1418
1472
|
try {
|
|
1419
1473
|
const retryRequest = request.clone();
|
|
1420
1474
|
retryRequest.headers.set("Authorization", `Bearer ${newToken}`);
|
|
1421
|
-
return fetch(retryRequest);
|
|
1475
|
+
return (config.fetch ?? globalThis.fetch)(retryRequest);
|
|
1422
1476
|
} catch {
|
|
1423
1477
|
console.warn("[API] Could not retry request after re-login (body already consumed)");
|
|
1424
1478
|
config.onRetryCloneFailed?.();
|
|
@@ -1867,22 +1921,26 @@ var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
|
1867
1921
|
var MAX_RETRIES = 3;
|
|
1868
1922
|
var BASE_DELAY_MS = 200;
|
|
1869
1923
|
function isRetryableError(err) {
|
|
1870
|
-
if (!(err instanceof Error)) return false;
|
|
1924
|
+
if (!(err instanceof Error) || isAbortError(err)) return false;
|
|
1871
1925
|
const cause = err.cause;
|
|
1872
1926
|
if (cause?.code && RETRYABLE_CODES.has(cause.code)) return true;
|
|
1873
1927
|
const msg = err.message || "";
|
|
1874
1928
|
return RETRYABLE_CODES.has(msg) || msg.includes("ECONNREFUSED") || msg.includes("ECONNRESET");
|
|
1875
1929
|
}
|
|
1876
|
-
function createRetryFetch() {
|
|
1930
|
+
function createRetryFetch(fetch) {
|
|
1877
1931
|
return async (input, init) => {
|
|
1932
|
+
const method = (init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
|
|
1933
|
+
const maxRetries = method === "GET" || method === "HEAD" ? MAX_RETRIES : 0;
|
|
1934
|
+
const signal = init?.signal ?? (input instanceof Request ? input.signal : void 0);
|
|
1878
1935
|
let lastError;
|
|
1879
|
-
for (let attempt = 0; attempt <=
|
|
1936
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
1937
|
+
if (signal?.aborted) throw signal.reason ?? new DOMException("Request aborted.", "AbortError");
|
|
1880
1938
|
try {
|
|
1881
1939
|
const fetchInput = input instanceof Request ? input.clone() : input;
|
|
1882
|
-
return await
|
|
1940
|
+
return await fetch(fetchInput, init);
|
|
1883
1941
|
} catch (err) {
|
|
1884
1942
|
lastError = err;
|
|
1885
|
-
if (attempt <
|
|
1943
|
+
if (attempt < maxRetries && isRetryableError(err)) {
|
|
1886
1944
|
await new Promise((r) => setTimeout(r, BASE_DELAY_MS * 2 ** attempt));
|
|
1887
1945
|
continue;
|
|
1888
1946
|
}
|
|
@@ -1904,9 +1962,9 @@ function readBaseUrlPerRequest(fetchClient, base) {
|
|
|
1904
1962
|
}
|
|
1905
1963
|
var deploymentDomainOf = ({ deploymentDomain }) => typeof deploymentDomain === "function" ? deploymentDomain() : deploymentDomain;
|
|
1906
1964
|
function createArbiClient(options) {
|
|
1907
|
-
const { fetch
|
|
1965
|
+
const { fetch, http, session, persistence, workspaceKeys, workspaceOpens, auth } = createTransport(options);
|
|
1908
1966
|
const authDeps = {
|
|
1909
|
-
fetchClient:
|
|
1967
|
+
fetchClient: fetch,
|
|
1910
1968
|
session,
|
|
1911
1969
|
get deploymentDomain() {
|
|
1912
1970
|
return deploymentDomainOf(options);
|
|
@@ -1915,7 +1973,8 @@ function createArbiClient(options) {
|
|
|
1915
1973
|
signIn: options.signIn
|
|
1916
1974
|
};
|
|
1917
1975
|
return {
|
|
1918
|
-
fetch
|
|
1976
|
+
fetch,
|
|
1977
|
+
http,
|
|
1919
1978
|
workspaceKeys,
|
|
1920
1979
|
workspaceOpens,
|
|
1921
1980
|
session,
|
|
@@ -1965,9 +2024,15 @@ function createTransport(options) {
|
|
|
1965
2024
|
const persistence = options.persistence ?? { getSession, saveSession };
|
|
1966
2025
|
const baseUrlOption = options.baseUrl;
|
|
1967
2026
|
const base = typeof baseUrlOption === "function" ? baseUrlOption : () => baseUrlOption;
|
|
1968
|
-
const
|
|
2027
|
+
const transport = createHttpTransport(options.transport);
|
|
2028
|
+
const retryFetch = createRetryFetch(transport.fetch);
|
|
1969
2029
|
const gate = createSessionGate();
|
|
1970
2030
|
const sessionFetch = gatedFetch(gate, retryFetch);
|
|
2031
|
+
const http = {
|
|
2032
|
+
fetch: gatedFetch(gate, transport.fetch),
|
|
2033
|
+
customFetch: transport.customFetch,
|
|
2034
|
+
withFetch: (adapter) => gatedFetch(gate, transport.withFetch(adapter))
|
|
2035
|
+
};
|
|
1971
2036
|
const session = options.session ?? createSessionManager();
|
|
1972
2037
|
if (userEmail) session.setUser(userEmail);
|
|
1973
2038
|
const tokenProvider = createTokenProvider(session);
|
|
@@ -2164,6 +2229,7 @@ function createTransport(options) {
|
|
|
2164
2229
|
for (const m of middleware) fetchClient.use(m);
|
|
2165
2230
|
fetchClient.use(
|
|
2166
2231
|
createAutoReloginMiddleware({
|
|
2232
|
+
fetch: sessionFetch,
|
|
2167
2233
|
reloginHandler: relogin,
|
|
2168
2234
|
reloginExcludePatterns,
|
|
2169
2235
|
reopenWorkspaceHandler: reopenWorkspace,
|
|
@@ -2179,6 +2245,7 @@ function createTransport(options) {
|
|
|
2179
2245
|
);
|
|
2180
2246
|
return {
|
|
2181
2247
|
fetch: fetchClient,
|
|
2248
|
+
http,
|
|
2182
2249
|
session,
|
|
2183
2250
|
persistence,
|
|
2184
2251
|
workspaceKeys,
|
|
@@ -2299,6 +2366,6 @@ function isMessageType(msg, type) {
|
|
|
2299
2366
|
return msg.type === type;
|
|
2300
2367
|
}
|
|
2301
2368
|
|
|
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 };
|
|
2369
|
+
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, 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
2370
|
//# sourceMappingURL=index.js.map
|
|
2304
2371
|
//# sourceMappingURL=index.js.map
|