@arbidocs/client 0.3.33 → 0.3.35
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 +24 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +285 -6
- package/dist/index.d.ts +285 -6
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -897,6 +897,73 @@ interface paths {
|
|
|
897
897
|
patch?: never;
|
|
898
898
|
trace?: never;
|
|
899
899
|
};
|
|
900
|
+
'/v1/document/upload-init': {
|
|
901
|
+
parameters: {
|
|
902
|
+
query?: never;
|
|
903
|
+
header?: never;
|
|
904
|
+
path?: never;
|
|
905
|
+
cookie?: never;
|
|
906
|
+
};
|
|
907
|
+
get?: never;
|
|
908
|
+
put?: never;
|
|
909
|
+
/**
|
|
910
|
+
* Upload Init
|
|
911
|
+
* @description Phase 1 of the direct-to-MinIO upload flow.
|
|
912
|
+
*
|
|
913
|
+
* The client declares each file it intends to upload (name, raw size,
|
|
914
|
+
* workspace-scoped HMAC content hash). For every file that passes
|
|
915
|
+
* validation + quota + dedup, the server reserves a ``Docs`` row in
|
|
916
|
+
* ``uploading`` state and returns a short-lived presigned PUT URL pointing
|
|
917
|
+
* at the public ``/arbi-files/`` nginx route. The client then encrypts
|
|
918
|
+
* the bytes locally with SecretBox(workspace_key) and PUTs the ciphertext
|
|
919
|
+
* straight to MinIO — arbi-app never sees the raw or encrypted payload.
|
|
920
|
+
*
|
|
921
|
+
* Call ``POST /v1/document/upload-commit`` once the PUTs succeed to flip
|
|
922
|
+
* the rows to ``queued`` and enqueue the parser pipeline.
|
|
923
|
+
*
|
|
924
|
+
* See ``init_direct_uploads`` for the full side-effect ordering.
|
|
925
|
+
*
|
|
926
|
+
* Requires active subscription if Stripe is configured.
|
|
927
|
+
*/
|
|
928
|
+
post: operations['upload_init'];
|
|
929
|
+
delete?: never;
|
|
930
|
+
options?: never;
|
|
931
|
+
head?: never;
|
|
932
|
+
patch?: never;
|
|
933
|
+
trace?: never;
|
|
934
|
+
};
|
|
935
|
+
'/v1/document/upload-commit': {
|
|
936
|
+
parameters: {
|
|
937
|
+
query?: never;
|
|
938
|
+
header?: never;
|
|
939
|
+
path?: never;
|
|
940
|
+
cookie?: never;
|
|
941
|
+
};
|
|
942
|
+
get?: never;
|
|
943
|
+
put?: never;
|
|
944
|
+
/**
|
|
945
|
+
* Upload Commit
|
|
946
|
+
* @description Phase 3 of the direct-to-MinIO upload flow.
|
|
947
|
+
*
|
|
948
|
+
* The client calls this after it has PUT encrypted bytes for each
|
|
949
|
+
* ``doc_ext_id`` handed out by ``/upload-init``. The server HEADs each
|
|
950
|
+
* object in MinIO, flips the row from ``uploading`` → ``queued``, and
|
|
951
|
+
* runs the usual parser-enqueue pipeline (or the media / text
|
|
952
|
+
* fast-path for those file types). Any ``doc_ext_id`` whose object is
|
|
953
|
+
* missing is dropped and reported in the response's ``skipped`` list —
|
|
954
|
+
* the row is deleted rather than left half-committed.
|
|
955
|
+
*
|
|
956
|
+
* The response shape matches ``POST /v1/document/upload`` so the
|
|
957
|
+
* frontend's existing post-upload UI (batch completion tracking etc.)
|
|
958
|
+
* can consume it unchanged.
|
|
959
|
+
*/
|
|
960
|
+
post: operations['upload_commit'];
|
|
961
|
+
delete?: never;
|
|
962
|
+
options?: never;
|
|
963
|
+
head?: never;
|
|
964
|
+
patch?: never;
|
|
965
|
+
trace?: never;
|
|
966
|
+
};
|
|
900
967
|
'/v1/document/{document_ext_id}/download': {
|
|
901
968
|
parameters: {
|
|
902
969
|
query?: never;
|
|
@@ -3174,6 +3241,35 @@ interface components {
|
|
|
3174
3241
|
[key: string]: components['schemas']['ModelGroupUsage'];
|
|
3175
3242
|
};
|
|
3176
3243
|
};
|
|
3244
|
+
/**
|
|
3245
|
+
* DeclaredUploadFile
|
|
3246
|
+
* @description One file declared by the client for the direct-to-MinIO upload flow.
|
|
3247
|
+
*
|
|
3248
|
+
* The client hashes the RAW (pre-encryption) bytes with HMAC-SHA256 keyed by
|
|
3249
|
+
* the workspace key and truncates to 16 hex chars — same formula the server
|
|
3250
|
+
* uses today in ``create_content_hash``. ``file_size`` is the RAW byte count
|
|
3251
|
+
* (not ciphertext); quota accounting and UI display stay in raw units so the
|
|
3252
|
+
* ciphertext size (raw + 40 for SecretBox nonce + tag) is an implementation
|
|
3253
|
+
* detail of what goes over the wire.
|
|
3254
|
+
*/
|
|
3255
|
+
DeclaredUploadFile: {
|
|
3256
|
+
/** File Name */
|
|
3257
|
+
file_name: string;
|
|
3258
|
+
/**
|
|
3259
|
+
* File Size
|
|
3260
|
+
* @description Raw byte count (pre-encryption)
|
|
3261
|
+
*/
|
|
3262
|
+
file_size: number;
|
|
3263
|
+
/**
|
|
3264
|
+
* Encrypted File Size
|
|
3265
|
+
* @description Ciphertext byte count the client will PUT to MinIO (raw + SecretBox envelope: 24-byte nonce + 16-byte MAC = 40 bytes).
|
|
3266
|
+
*/
|
|
3267
|
+
encrypted_file_size: number;
|
|
3268
|
+
/** Content Hash */
|
|
3269
|
+
content_hash: string;
|
|
3270
|
+
/** Content Type */
|
|
3271
|
+
content_type?: string | null;
|
|
3272
|
+
};
|
|
3177
3273
|
/**
|
|
3178
3274
|
* DeleteAgentsRequest
|
|
3179
3275
|
* @description Request to delete agents by external ID.
|
|
@@ -3814,6 +3910,37 @@ interface components {
|
|
|
3814
3910
|
/** Detail */
|
|
3815
3911
|
detail?: components['schemas']['ValidationError'][];
|
|
3816
3912
|
};
|
|
3913
|
+
/**
|
|
3914
|
+
* InitedUploadItem
|
|
3915
|
+
* @description One file slot returned by ``POST /v1/document/upload-init``.
|
|
3916
|
+
*
|
|
3917
|
+
* When ``status == "uploading"`` the client should PUT the SecretBox-encrypted
|
|
3918
|
+
* bytes (``nonce(24) ‖ ciphertext+tag``) to ``upload_url`` using a plain HTTPS
|
|
3919
|
+
* PUT, then call ``/v1/document/upload-commit`` with the ``doc_ext_id``.
|
|
3920
|
+
* Any other status means the server rejected this file and no PUT/commit
|
|
3921
|
+
* should be attempted for it — the client should surface the reason to the
|
|
3922
|
+
* user and move on.
|
|
3923
|
+
*/
|
|
3924
|
+
InitedUploadItem: {
|
|
3925
|
+
/** File Name */
|
|
3926
|
+
file_name: string;
|
|
3927
|
+
/** Doc Ext Id */
|
|
3928
|
+
doc_ext_id?: string | null;
|
|
3929
|
+
/** Storage Uri */
|
|
3930
|
+
storage_uri?: string | null;
|
|
3931
|
+
/** Upload Url */
|
|
3932
|
+
upload_url?: string | null;
|
|
3933
|
+
/** Expires In */
|
|
3934
|
+
expires_in?: number | null;
|
|
3935
|
+
/**
|
|
3936
|
+
* Status
|
|
3937
|
+
* @default uploading
|
|
3938
|
+
* @enum {string}
|
|
3939
|
+
*/
|
|
3940
|
+
status: 'uploading' | 'duplicate' | 'quota_exceeded' | 'unsupported' | 'empty';
|
|
3941
|
+
/** Reason */
|
|
3942
|
+
reason?: string | null;
|
|
3943
|
+
};
|
|
3817
3944
|
/**
|
|
3818
3945
|
* KeywordEmbedderConfig
|
|
3819
3946
|
* @description Configuration for keyword embedder with BM25 scoring.
|
|
@@ -4539,6 +4666,10 @@ interface components {
|
|
|
4539
4666
|
* @default markdown
|
|
4540
4667
|
*/
|
|
4541
4668
|
output_mode: string;
|
|
4669
|
+
/** Timing */
|
|
4670
|
+
timing?: {
|
|
4671
|
+
[key: string]: unknown;
|
|
4672
|
+
} | null;
|
|
4542
4673
|
};
|
|
4543
4674
|
/**
|
|
4544
4675
|
* ParsedStage
|
|
@@ -6436,7 +6567,7 @@ interface components {
|
|
|
6436
6567
|
* Status
|
|
6437
6568
|
* @enum {string}
|
|
6438
6569
|
*/
|
|
6439
|
-
status: 'queued' | 'parsing' | 'encrypting' | 'indexing' | 'analysing' | 'completed' | 'failed' | 'skipped' | 'empty';
|
|
6570
|
+
status: 'uploading' | 'queued' | 'parsing' | 'encrypting' | 'indexing' | 'analysing' | 'completed' | 'failed' | 'skipped' | 'empty';
|
|
6440
6571
|
/** Progress */
|
|
6441
6572
|
progress: number;
|
|
6442
6573
|
};
|
|
@@ -6713,6 +6844,20 @@ interface components {
|
|
|
6713
6844
|
user_ext_ids: string[];
|
|
6714
6845
|
role: components['schemas']['WorkspaceRole'];
|
|
6715
6846
|
};
|
|
6847
|
+
/**
|
|
6848
|
+
* UploadCommitRequest
|
|
6849
|
+
* @description Request body for ``POST /v1/document/upload-commit``.
|
|
6850
|
+
*
|
|
6851
|
+
* ``doc_ext_ids`` should be the subset of init items the client actually
|
|
6852
|
+
* uploaded successfully. Any IDs not listed here are left in ``uploading``
|
|
6853
|
+
* state on the server and eventually garbage-collected.
|
|
6854
|
+
*/
|
|
6855
|
+
UploadCommitRequest: {
|
|
6856
|
+
/** Doc Ext Ids */
|
|
6857
|
+
doc_ext_ids: string[];
|
|
6858
|
+
/** Tag Ext Id */
|
|
6859
|
+
tag_ext_id?: string | null;
|
|
6860
|
+
};
|
|
6716
6861
|
/**
|
|
6717
6862
|
* UploadDocumentsResponse
|
|
6718
6863
|
* @description Response for document upload operations.
|
|
@@ -6734,6 +6879,42 @@ interface components {
|
|
|
6734
6879
|
*/
|
|
6735
6880
|
skipped?: components['schemas']['SkippedFile'][];
|
|
6736
6881
|
};
|
|
6882
|
+
/**
|
|
6883
|
+
* UploadInitRequest
|
|
6884
|
+
* @description Request body for ``POST /v1/document/upload-init``.
|
|
6885
|
+
*/
|
|
6886
|
+
UploadInitRequest: {
|
|
6887
|
+
/** Files */
|
|
6888
|
+
files: components['schemas']['DeclaredUploadFile'][];
|
|
6889
|
+
/**
|
|
6890
|
+
* Shared
|
|
6891
|
+
* @default true
|
|
6892
|
+
*/
|
|
6893
|
+
shared: boolean;
|
|
6894
|
+
/** Config Ext Id */
|
|
6895
|
+
config_ext_id?: string | null;
|
|
6896
|
+
/** Parent Ext Id */
|
|
6897
|
+
parent_ext_id?: string | null;
|
|
6898
|
+
/** Wp Type */
|
|
6899
|
+
wp_type?: string | null;
|
|
6900
|
+
/** Tag Ext Id */
|
|
6901
|
+
tag_ext_id?: string | null;
|
|
6902
|
+
/** Folder */
|
|
6903
|
+
folder?: string | null;
|
|
6904
|
+
/**
|
|
6905
|
+
* Presign Expires In
|
|
6906
|
+
* @default 3600
|
|
6907
|
+
*/
|
|
6908
|
+
presign_expires_in: number;
|
|
6909
|
+
};
|
|
6910
|
+
/**
|
|
6911
|
+
* UploadInitResponse
|
|
6912
|
+
* @description Response body for ``POST /v1/document/upload-init``.
|
|
6913
|
+
*/
|
|
6914
|
+
UploadInitResponse: {
|
|
6915
|
+
/** Items */
|
|
6916
|
+
items?: components['schemas']['InitedUploadItem'][];
|
|
6917
|
+
};
|
|
6737
6918
|
/**
|
|
6738
6919
|
* UserInputBody
|
|
6739
6920
|
* @description Request body for POST /assistant/respond.
|
|
@@ -7181,11 +7362,11 @@ interface components {
|
|
|
7181
7362
|
WorkspaceOpenResponse: {
|
|
7182
7363
|
workspace: components['schemas']['WorkspaceResponse'];
|
|
7183
7364
|
/** Conversations */
|
|
7184
|
-
conversations
|
|
7365
|
+
conversations?: components['schemas']['ConversationResponse'][] | null;
|
|
7185
7366
|
/** Documents */
|
|
7186
|
-
documents
|
|
7367
|
+
documents?: unknown[] | null;
|
|
7187
7368
|
/** Tags */
|
|
7188
|
-
tags
|
|
7369
|
+
tags?: unknown[] | null;
|
|
7189
7370
|
};
|
|
7190
7371
|
/** WorkspaceResponse */
|
|
7191
7372
|
WorkspaceResponse: {
|
|
@@ -8197,7 +8378,14 @@ interface operations {
|
|
|
8197
8378
|
};
|
|
8198
8379
|
open_workspace: {
|
|
8199
8380
|
parameters: {
|
|
8200
|
-
query?:
|
|
8381
|
+
query?: {
|
|
8382
|
+
/** @description Include full document list in response */
|
|
8383
|
+
include_documents?: boolean;
|
|
8384
|
+
/** @description Include conversations in response */
|
|
8385
|
+
include_conversations?: boolean;
|
|
8386
|
+
/** @description Include tags in response */
|
|
8387
|
+
include_tags?: boolean;
|
|
8388
|
+
};
|
|
8201
8389
|
header?: never;
|
|
8202
8390
|
path: {
|
|
8203
8391
|
workspace_ext_id: string;
|
|
@@ -8789,6 +8977,72 @@ interface operations {
|
|
|
8789
8977
|
};
|
|
8790
8978
|
};
|
|
8791
8979
|
};
|
|
8980
|
+
upload_init: {
|
|
8981
|
+
parameters: {
|
|
8982
|
+
query?: never;
|
|
8983
|
+
header?: never;
|
|
8984
|
+
path?: never;
|
|
8985
|
+
cookie?: never;
|
|
8986
|
+
};
|
|
8987
|
+
requestBody: {
|
|
8988
|
+
content: {
|
|
8989
|
+
'application/json': components['schemas']['UploadInitRequest'];
|
|
8990
|
+
};
|
|
8991
|
+
};
|
|
8992
|
+
responses: {
|
|
8993
|
+
/** @description Successful Response */
|
|
8994
|
+
200: {
|
|
8995
|
+
headers: {
|
|
8996
|
+
[name: string]: unknown;
|
|
8997
|
+
};
|
|
8998
|
+
content: {
|
|
8999
|
+
'application/json': components['schemas']['UploadInitResponse'];
|
|
9000
|
+
};
|
|
9001
|
+
};
|
|
9002
|
+
/** @description Validation Error */
|
|
9003
|
+
422: {
|
|
9004
|
+
headers: {
|
|
9005
|
+
[name: string]: unknown;
|
|
9006
|
+
};
|
|
9007
|
+
content: {
|
|
9008
|
+
'application/json': components['schemas']['HTTPValidationError'];
|
|
9009
|
+
};
|
|
9010
|
+
};
|
|
9011
|
+
};
|
|
9012
|
+
};
|
|
9013
|
+
upload_commit: {
|
|
9014
|
+
parameters: {
|
|
9015
|
+
query?: never;
|
|
9016
|
+
header?: never;
|
|
9017
|
+
path?: never;
|
|
9018
|
+
cookie?: never;
|
|
9019
|
+
};
|
|
9020
|
+
requestBody: {
|
|
9021
|
+
content: {
|
|
9022
|
+
'application/json': components['schemas']['UploadCommitRequest'];
|
|
9023
|
+
};
|
|
9024
|
+
};
|
|
9025
|
+
responses: {
|
|
9026
|
+
/** @description Successful Response */
|
|
9027
|
+
200: {
|
|
9028
|
+
headers: {
|
|
9029
|
+
[name: string]: unknown;
|
|
9030
|
+
};
|
|
9031
|
+
content: {
|
|
9032
|
+
'application/json': components['schemas']['UploadDocumentsResponse'];
|
|
9033
|
+
};
|
|
9034
|
+
};
|
|
9035
|
+
/** @description Validation Error */
|
|
9036
|
+
422: {
|
|
9037
|
+
headers: {
|
|
9038
|
+
[name: string]: unknown;
|
|
9039
|
+
};
|
|
9040
|
+
content: {
|
|
9041
|
+
'application/json': components['schemas']['HTTPValidationError'];
|
|
9042
|
+
};
|
|
9043
|
+
};
|
|
9044
|
+
};
|
|
9045
|
+
};
|
|
8792
9046
|
download_document: {
|
|
8793
9047
|
parameters: {
|
|
8794
9048
|
query?: never;
|
|
@@ -10269,6 +10523,31 @@ declare function deriveEncryptionKeypairFromSigning(signingKeyPair: KeyPair): Ke
|
|
|
10269
10523
|
* Used for agent accounts that don't derive keys from a password.
|
|
10270
10524
|
*/
|
|
10271
10525
|
declare function generateRandomSigningKeypair(): KeyPair;
|
|
10526
|
+
/**
|
|
10527
|
+
* SecretBox-encrypt file bytes with the workspace key.
|
|
10528
|
+
*
|
|
10529
|
+
* Returns the wire format the server stores in MinIO:
|
|
10530
|
+
* `nonce(24) ‖ ciphertext ‖ tag(16)` — byte-for-byte identical to what
|
|
10531
|
+
* PyNaCl's `SecretBox(workspace_key).encrypt(raw)` produces and what the
|
|
10532
|
+
* server's `decrypt_file` expects. PUT the returned bytes directly to the
|
|
10533
|
+
* presigned upload URL returned by `/v1/document/upload-init`.
|
|
10534
|
+
*/
|
|
10535
|
+
declare function encryptFile(raw: Uint8Array, workspaceKey: Uint8Array): Uint8Array;
|
|
10536
|
+
/**
|
|
10537
|
+
* SecretBox-decrypt a file body downloaded from MinIO.
|
|
10538
|
+
* Input is the same `nonce ‖ ciphertext ‖ tag` wire format that `encryptFile`
|
|
10539
|
+
* produces.
|
|
10540
|
+
*/
|
|
10541
|
+
declare function decryptFile(ciphertext: Uint8Array, workspaceKey: Uint8Array): Uint8Array;
|
|
10542
|
+
/**
|
|
10543
|
+
* Workspace-scoped content hash for client-side dedup.
|
|
10544
|
+
*
|
|
10545
|
+
* HMAC-SHA256(workspace_key, raw_bytes) truncated to 16 hex chars — byte
|
|
10546
|
+
* compatible with the server's `create_content_hash` helper. The client
|
|
10547
|
+
* sends this to `/v1/document/upload-init` so the server can dedup without
|
|
10548
|
+
* ever seeing plaintext.
|
|
10549
|
+
*/
|
|
10550
|
+
declare function createContentHash(content: Uint8Array, workspaceKey: Uint8Array): string;
|
|
10272
10551
|
/**
|
|
10273
10552
|
* Precompute shared secret for ECDH encryption.
|
|
10274
10553
|
*
|
|
@@ -10769,4 +11048,4 @@ declare function isMessageType<T extends WebSocketServerMessage>(msg: WebSocketS
|
|
|
10769
11048
|
*/
|
|
10770
11049
|
declare function createReloginHandler(deps: ReloginDeps): () => Promise<string | null>;
|
|
10771
11050
|
|
|
10772
|
-
export { type $defs, API_PREFIX, type ArbiClient, type ArbiClientOptions, type AuthStateProvider, type AutoReloginMiddlewareConfig, type BearerAuthMiddlewareConfig, type ChangePasswordParams, type ChangePasswordRequest, type ChangePasswordResult, type CryptoProvider, type KeyPair, type LoginCredentials, type LoginParams, type LoginProvider, type LoginRequest, type LoginResult, type LoginWithKeyParams, type OnReloginSuccess, type PasswordChangeCredentials, type RegisterParams, type RegisterRequest, type RegisterResult, type RegistrationCredentials, type ReloginDeps, type ReloginHandler, type SessionData, type SessionKeys, type SessionManager, type SessionState, type SessionStorageProvider, type SsoTokenProvider, type TokenProvider, type UserKeypairs, type WebSocketClientMessage, type WebSocketServerMessage, type WorkspaceKeyRefreshProvider, type WorkspaceOpenProvider, type WsAuthMessage, type WsAuthResultMessage, type WsBatchCompleteMessage, type WsConnectionClosedMessage, type WsErrorMessage, type WsNotificationResponse, type WsPresenceUpdateMessage, type WsResponseCompleteMessage, type WsTaskUpdateMessage, base64Decode, base64Encode, base64ToBytes, buildWebSocketUrl, bytesToBase64, clearAllData, clearSession, type components, computeSharedSecret, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createReloginHandler, createSessionManager, decryptMessage, decryptMessageWithSharedSecret, deriveEncryptionKeypairFromSigning, derivePublicKey, encryptMessage, encryptMessageWithSharedSecret, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRecoveryPasswordChangeCredentials, generateRegistrationCredentials, generateUserKeypairs, getSession, hasSession, initSodium, initializeDatabase, isMessageType, type operations, parseServerMessage, type paths, saveSession, sealKeyForSession, sealedBoxDecrypt, sealedBoxEncrypt, signMessage, updateSigningPrivateKey, type webhooks };
|
|
11051
|
+
export { type $defs, API_PREFIX, type ArbiClient, type ArbiClientOptions, type AuthStateProvider, type AutoReloginMiddlewareConfig, type BearerAuthMiddlewareConfig, type ChangePasswordParams, type ChangePasswordRequest, type ChangePasswordResult, type CryptoProvider, type KeyPair, type LoginCredentials, type LoginParams, type LoginProvider, type LoginRequest, type LoginResult, type LoginWithKeyParams, type OnReloginSuccess, type PasswordChangeCredentials, type RegisterParams, type RegisterRequest, type RegisterResult, type RegistrationCredentials, type ReloginDeps, type ReloginHandler, type SessionData, type SessionKeys, type SessionManager, type SessionState, type SessionStorageProvider, type SsoTokenProvider, type TokenProvider, type UserKeypairs, type WebSocketClientMessage, type WebSocketServerMessage, type WorkspaceKeyRefreshProvider, type WorkspaceOpenProvider, type WsAuthMessage, type WsAuthResultMessage, type WsBatchCompleteMessage, type WsConnectionClosedMessage, type WsErrorMessage, type WsNotificationResponse, type WsPresenceUpdateMessage, type WsResponseCompleteMessage, type WsTaskUpdateMessage, base64Decode, base64Encode, base64ToBytes, buildWebSocketUrl, bytesToBase64, clearAllData, clearSession, type components, computeSharedSecret, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createReloginHandler, createSessionManager, decryptFile, decryptMessage, decryptMessageWithSharedSecret, deriveEncryptionKeypairFromSigning, derivePublicKey, encryptFile, encryptMessage, encryptMessageWithSharedSecret, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRecoveryPasswordChangeCredentials, generateRegistrationCredentials, generateUserKeypairs, getSession, hasSession, initSodium, initializeDatabase, isMessageType, type operations, parseServerMessage, type paths, saveSession, sealKeyForSession, sealedBoxDecrypt, sealedBoxEncrypt, signMessage, updateSigningPrivateKey, type webhooks };
|
package/dist/index.js
CHANGED
|
@@ -180,6 +180,27 @@ function generateRandomSigningKeypair() {
|
|
|
180
180
|
const kp = sodium.crypto_sign_keypair();
|
|
181
181
|
return { publicKey: kp.publicKey, secretKey: kp.privateKey };
|
|
182
182
|
}
|
|
183
|
+
function encryptFile(raw, workspaceKey) {
|
|
184
|
+
const nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES);
|
|
185
|
+
const cipher = sodium.crypto_secretbox_easy(raw, nonce, workspaceKey);
|
|
186
|
+
const combined = new Uint8Array(nonce.length + cipher.length);
|
|
187
|
+
combined.set(nonce, 0);
|
|
188
|
+
combined.set(cipher, nonce.length);
|
|
189
|
+
return combined;
|
|
190
|
+
}
|
|
191
|
+
function decryptFile(ciphertext, workspaceKey) {
|
|
192
|
+
const nonce = ciphertext.slice(0, sodium.crypto_secretbox_NONCEBYTES);
|
|
193
|
+
const cipher = ciphertext.slice(sodium.crypto_secretbox_NONCEBYTES);
|
|
194
|
+
return sodium.crypto_secretbox_open_easy(cipher, nonce, workspaceKey);
|
|
195
|
+
}
|
|
196
|
+
function createContentHash(content, workspaceKey) {
|
|
197
|
+
const mac = sodium.crypto_auth_hmacsha256(content, workspaceKey);
|
|
198
|
+
let hex = "";
|
|
199
|
+
for (let i = 0; i < mac.length; i++) {
|
|
200
|
+
hex += mac[i].toString(16).padStart(2, "0");
|
|
201
|
+
}
|
|
202
|
+
return hex.slice(0, 16);
|
|
203
|
+
}
|
|
183
204
|
async function computeSharedSecret(theirPublicKeyBase64, myPrivateKey) {
|
|
184
205
|
await initSodium();
|
|
185
206
|
const theirPublicKey = base64ToBytes(theirPublicKeyBase64);
|
|
@@ -1090,6 +1111,6 @@ function isMessageType(msg, type) {
|
|
|
1090
1111
|
return msg.type === type;
|
|
1091
1112
|
}
|
|
1092
1113
|
|
|
1093
|
-
export { API_PREFIX, base64Decode, base64Encode, base64ToBytes, buildWebSocketUrl, bytesToBase64, clearAllData, clearSession, computeSharedSecret, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createReloginHandler, createSessionManager, decryptMessage, decryptMessageWithSharedSecret, deriveEncryptionKeypairFromSigning, derivePublicKey, encryptMessage, encryptMessageWithSharedSecret, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRecoveryPasswordChangeCredentials, generateRegistrationCredentials, generateUserKeypairs, getSession, hasSession, initSodium, initializeDatabase, isMessageType, parseServerMessage, saveSession, sealKeyForSession, sealedBoxDecrypt, sealedBoxEncrypt, signMessage, updateSigningPrivateKey };
|
|
1114
|
+
export { API_PREFIX, base64Decode, base64Encode, base64ToBytes, buildWebSocketUrl, bytesToBase64, clearAllData, clearSession, computeSharedSecret, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createReloginHandler, createSessionManager, decryptFile, decryptMessage, decryptMessageWithSharedSecret, deriveEncryptionKeypairFromSigning, derivePublicKey, encryptFile, encryptMessage, encryptMessageWithSharedSecret, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRecoveryPasswordChangeCredentials, generateRegistrationCredentials, generateUserKeypairs, getSession, hasSession, initSodium, initializeDatabase, isMessageType, parseServerMessage, saveSession, sealKeyForSession, sealedBoxDecrypt, sealedBoxEncrypt, signMessage, updateSigningPrivateKey };
|
|
1094
1115
|
//# sourceMappingURL=index.js.map
|
|
1095
1116
|
//# sourceMappingURL=index.js.map
|