@arbidocs/sdk 0.3.88 → 0.3.90

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.
@@ -1823,6 +1823,46 @@ declare class Arbi {
1823
1823
  agent_ext_id?: string | null | undefined;
1824
1824
  is_temporary: boolean;
1825
1825
  }[]>;
1826
+ /**
1827
+ * Ask another user to grant you workspace access. Builds the E2E-encrypted
1828
+ * request `content` (carrying this session's public key for a temporary
1829
+ * grant) and posts it. `workspaceExtId` is optional — pass it only when you
1830
+ * already know the target workspace id (obtained out-of-band).
1831
+ */
1832
+ requestAccess: (params: {
1833
+ recipientExtId: string;
1834
+ recipientEncryptionPublicKey: string;
1835
+ note?: string;
1836
+ workspaceExtId?: string;
1837
+ }) => Promise<{
1838
+ type: components["schemas"]["NotificationType"];
1839
+ external_id: string;
1840
+ sender: {
1841
+ external_id: string;
1842
+ parent_ext_id?: string | null | undefined;
1843
+ email: string;
1844
+ given_name: string;
1845
+ family_name?: string | null | undefined;
1846
+ picture?: string | null | undefined;
1847
+ encryption_public_key: string;
1848
+ is_sso: boolean;
1849
+ };
1850
+ recipient: {
1851
+ external_id: string;
1852
+ parent_ext_id?: string | null | undefined;
1853
+ email: string;
1854
+ given_name: string;
1855
+ family_name?: string | null | undefined;
1856
+ picture?: string | null | undefined;
1857
+ encryption_public_key: string;
1858
+ is_sso: boolean;
1859
+ };
1860
+ workspace_ext_id?: string | null | undefined;
1861
+ content?: string | null | undefined;
1862
+ read: boolean;
1863
+ created_at: string;
1864
+ updated_at: string;
1865
+ }>;
1826
1866
  copyDocuments: (targetWorkspaceId: string, docIds: string[], targetWorkspaceKey: string) => Promise<{
1827
1867
  detail: string;
1828
1868
  documents_copied: number;
@@ -2677,6 +2717,7 @@ declare class Arbi {
2677
2717
  email_notifications?: {
2678
2718
  messages: boolean;
2679
2719
  workspace_added: boolean;
2720
+ workspace_access_request: boolean;
2680
2721
  contact_accepted: boolean;
2681
2722
  referral_reward: boolean;
2682
2723
  product_updates: boolean;
@@ -3924,6 +3965,54 @@ declare function sendEncryptedDM(arbi: ArbiClient, messages: Array<{
3924
3965
  created_at: string;
3925
3966
  updated_at: string;
3926
3967
  }[]>;
3968
+ /**
3969
+ * Ask another user to grant you workspace access.
3970
+ *
3971
+ * Creates a `workspace_access_request` notification. The `content` is an
3972
+ * opaque base64 blob, E2E-encrypted with the requester↔recipient shared key
3973
+ * (same scheme as a DM), carrying the requester's live session public key
3974
+ * (`sessionPubkeyB64`) so the recipient can mint a temporary, session-scoped
3975
+ * grant, plus an optional note.
3976
+ *
3977
+ * `workspaceExtId` is optional and only meaningful for API/SDK/CLI callers who
3978
+ * already know a workspace id (obtained out-of-band); omit it and the recipient
3979
+ * picks the workspace.
3980
+ */
3981
+ declare function requestWorkspaceAccess(arbi: ArbiClient, params: {
3982
+ recipientExtId: string;
3983
+ recipientEncryptionPublicKey: string;
3984
+ sessionPubkeyB64: string;
3985
+ note?: string;
3986
+ workspaceExtId?: string;
3987
+ }, crypto: DmCryptoContext): Promise<{
3988
+ type: components["schemas"]["NotificationType"];
3989
+ external_id: string;
3990
+ sender: {
3991
+ external_id: string;
3992
+ parent_ext_id?: string | null | undefined;
3993
+ email: string;
3994
+ given_name: string;
3995
+ family_name?: string | null | undefined;
3996
+ picture?: string | null | undefined;
3997
+ encryption_public_key: string;
3998
+ is_sso: boolean;
3999
+ };
4000
+ recipient: {
4001
+ external_id: string;
4002
+ parent_ext_id?: string | null | undefined;
4003
+ email: string;
4004
+ given_name: string;
4005
+ family_name?: string | null | undefined;
4006
+ picture?: string | null | undefined;
4007
+ encryption_public_key: string;
4008
+ is_sso: boolean;
4009
+ };
4010
+ workspace_ext_id?: string | null | undefined;
4011
+ content?: string | null | undefined;
4012
+ read: boolean;
4013
+ created_at: string;
4014
+ updated_at: string;
4015
+ }>;
3927
4016
  /**
3928
4017
  * Send a plaintext DM (no encryption).
3929
4018
  * @deprecated Use sendEncryptedDM instead.
@@ -4000,10 +4089,11 @@ declare const dm_encryptDmContent: typeof encryptDmContent;
4000
4089
  declare const dm_listDMs: typeof listDMs;
4001
4090
  declare const dm_listDecryptedDMs: typeof listDecryptedDMs;
4002
4091
  declare const dm_markRead: typeof markRead;
4092
+ declare const dm_requestWorkspaceAccess: typeof requestWorkspaceAccess;
4003
4093
  declare const dm_sendDM: typeof sendDM;
4004
4094
  declare const dm_sendEncryptedDM: typeof sendEncryptedDM;
4005
4095
  declare namespace dm {
4006
- export { type dm_DmCryptoContext as DmCryptoContext, dm_createDmCryptoContext as createDmCryptoContext, dm_decryptDmBatch as decryptDmBatch, dm_decryptDmContent as decryptDmContent, dm_deleteDMs as deleteDMs, dm_encryptDmContent as encryptDmContent, dm_listDMs as listDMs, dm_listDecryptedDMs as listDecryptedDMs, dm_markRead as markRead, dm_sendDM as sendDM, dm_sendEncryptedDM as sendEncryptedDM };
4096
+ export { type dm_DmCryptoContext as DmCryptoContext, dm_createDmCryptoContext as createDmCryptoContext, dm_decryptDmBatch as decryptDmBatch, dm_decryptDmContent as decryptDmContent, dm_deleteDMs as deleteDMs, dm_encryptDmContent as encryptDmContent, dm_listDMs as listDMs, dm_listDecryptedDMs as listDecryptedDMs, dm_markRead as markRead, dm_requestWorkspaceAccess as requestWorkspaceAccess, dm_sendDM as sendDM, dm_sendEncryptedDM as sendEncryptedDM };
4007
4097
  }
4008
4098
 
4009
4099
  /**
@@ -4047,6 +4137,7 @@ declare function getSettings(arbi: ArbiClient): Promise<{
4047
4137
  email_notifications?: {
4048
4138
  messages: boolean;
4049
4139
  workspace_added: boolean;
4140
+ workspace_access_request: boolean;
4050
4141
  contact_accepted: boolean;
4051
4142
  referral_reward: boolean;
4052
4143
  product_updates: boolean;
@@ -1823,6 +1823,46 @@ declare class Arbi {
1823
1823
  agent_ext_id?: string | null | undefined;
1824
1824
  is_temporary: boolean;
1825
1825
  }[]>;
1826
+ /**
1827
+ * Ask another user to grant you workspace access. Builds the E2E-encrypted
1828
+ * request `content` (carrying this session's public key for a temporary
1829
+ * grant) and posts it. `workspaceExtId` is optional — pass it only when you
1830
+ * already know the target workspace id (obtained out-of-band).
1831
+ */
1832
+ requestAccess: (params: {
1833
+ recipientExtId: string;
1834
+ recipientEncryptionPublicKey: string;
1835
+ note?: string;
1836
+ workspaceExtId?: string;
1837
+ }) => Promise<{
1838
+ type: components["schemas"]["NotificationType"];
1839
+ external_id: string;
1840
+ sender: {
1841
+ external_id: string;
1842
+ parent_ext_id?: string | null | undefined;
1843
+ email: string;
1844
+ given_name: string;
1845
+ family_name?: string | null | undefined;
1846
+ picture?: string | null | undefined;
1847
+ encryption_public_key: string;
1848
+ is_sso: boolean;
1849
+ };
1850
+ recipient: {
1851
+ external_id: string;
1852
+ parent_ext_id?: string | null | undefined;
1853
+ email: string;
1854
+ given_name: string;
1855
+ family_name?: string | null | undefined;
1856
+ picture?: string | null | undefined;
1857
+ encryption_public_key: string;
1858
+ is_sso: boolean;
1859
+ };
1860
+ workspace_ext_id?: string | null | undefined;
1861
+ content?: string | null | undefined;
1862
+ read: boolean;
1863
+ created_at: string;
1864
+ updated_at: string;
1865
+ }>;
1826
1866
  copyDocuments: (targetWorkspaceId: string, docIds: string[], targetWorkspaceKey: string) => Promise<{
1827
1867
  detail: string;
1828
1868
  documents_copied: number;
@@ -2677,6 +2717,7 @@ declare class Arbi {
2677
2717
  email_notifications?: {
2678
2718
  messages: boolean;
2679
2719
  workspace_added: boolean;
2720
+ workspace_access_request: boolean;
2680
2721
  contact_accepted: boolean;
2681
2722
  referral_reward: boolean;
2682
2723
  product_updates: boolean;
@@ -3924,6 +3965,54 @@ declare function sendEncryptedDM(arbi: ArbiClient, messages: Array<{
3924
3965
  created_at: string;
3925
3966
  updated_at: string;
3926
3967
  }[]>;
3968
+ /**
3969
+ * Ask another user to grant you workspace access.
3970
+ *
3971
+ * Creates a `workspace_access_request` notification. The `content` is an
3972
+ * opaque base64 blob, E2E-encrypted with the requester↔recipient shared key
3973
+ * (same scheme as a DM), carrying the requester's live session public key
3974
+ * (`sessionPubkeyB64`) so the recipient can mint a temporary, session-scoped
3975
+ * grant, plus an optional note.
3976
+ *
3977
+ * `workspaceExtId` is optional and only meaningful for API/SDK/CLI callers who
3978
+ * already know a workspace id (obtained out-of-band); omit it and the recipient
3979
+ * picks the workspace.
3980
+ */
3981
+ declare function requestWorkspaceAccess(arbi: ArbiClient, params: {
3982
+ recipientExtId: string;
3983
+ recipientEncryptionPublicKey: string;
3984
+ sessionPubkeyB64: string;
3985
+ note?: string;
3986
+ workspaceExtId?: string;
3987
+ }, crypto: DmCryptoContext): Promise<{
3988
+ type: components["schemas"]["NotificationType"];
3989
+ external_id: string;
3990
+ sender: {
3991
+ external_id: string;
3992
+ parent_ext_id?: string | null | undefined;
3993
+ email: string;
3994
+ given_name: string;
3995
+ family_name?: string | null | undefined;
3996
+ picture?: string | null | undefined;
3997
+ encryption_public_key: string;
3998
+ is_sso: boolean;
3999
+ };
4000
+ recipient: {
4001
+ external_id: string;
4002
+ parent_ext_id?: string | null | undefined;
4003
+ email: string;
4004
+ given_name: string;
4005
+ family_name?: string | null | undefined;
4006
+ picture?: string | null | undefined;
4007
+ encryption_public_key: string;
4008
+ is_sso: boolean;
4009
+ };
4010
+ workspace_ext_id?: string | null | undefined;
4011
+ content?: string | null | undefined;
4012
+ read: boolean;
4013
+ created_at: string;
4014
+ updated_at: string;
4015
+ }>;
3927
4016
  /**
3928
4017
  * Send a plaintext DM (no encryption).
3929
4018
  * @deprecated Use sendEncryptedDM instead.
@@ -4000,10 +4089,11 @@ declare const dm_encryptDmContent: typeof encryptDmContent;
4000
4089
  declare const dm_listDMs: typeof listDMs;
4001
4090
  declare const dm_listDecryptedDMs: typeof listDecryptedDMs;
4002
4091
  declare const dm_markRead: typeof markRead;
4092
+ declare const dm_requestWorkspaceAccess: typeof requestWorkspaceAccess;
4003
4093
  declare const dm_sendDM: typeof sendDM;
4004
4094
  declare const dm_sendEncryptedDM: typeof sendEncryptedDM;
4005
4095
  declare namespace dm {
4006
- export { type dm_DmCryptoContext as DmCryptoContext, dm_createDmCryptoContext as createDmCryptoContext, dm_decryptDmBatch as decryptDmBatch, dm_decryptDmContent as decryptDmContent, dm_deleteDMs as deleteDMs, dm_encryptDmContent as encryptDmContent, dm_listDMs as listDMs, dm_listDecryptedDMs as listDecryptedDMs, dm_markRead as markRead, dm_sendDM as sendDM, dm_sendEncryptedDM as sendEncryptedDM };
4096
+ export { type dm_DmCryptoContext as DmCryptoContext, dm_createDmCryptoContext as createDmCryptoContext, dm_decryptDmBatch as decryptDmBatch, dm_decryptDmContent as decryptDmContent, dm_deleteDMs as deleteDMs, dm_encryptDmContent as encryptDmContent, dm_listDMs as listDMs, dm_listDecryptedDMs as listDecryptedDMs, dm_markRead as markRead, dm_requestWorkspaceAccess as requestWorkspaceAccess, dm_sendDM as sendDM, dm_sendEncryptedDM as sendEncryptedDM };
4007
4097
  }
4008
4098
 
4009
4099
  /**
@@ -4047,6 +4137,7 @@ declare function getSettings(arbi: ArbiClient): Promise<{
4047
4137
  email_notifications?: {
4048
4138
  messages: boolean;
4049
4139
  workspace_added: boolean;
4140
+ workspace_access_request: boolean;
4050
4141
  contact_accepted: boolean;
4051
4142
  referral_reward: boolean;
4052
4143
  product_updates: boolean;
package/dist/browser.cjs CHANGED
@@ -5035,6 +5035,7 @@ __export(dm_exports, {
5035
5035
  listDMs: () => listDMs,
5036
5036
  listDecryptedDMs: () => listDecryptedDMs,
5037
5037
  markRead: () => markRead,
5038
+ requestWorkspaceAccess: () => requestWorkspaceAccess,
5038
5039
  sendDM: () => sendDM,
5039
5040
  sendEncryptedDM: () => sendEncryptedDM
5040
5041
  });
@@ -5103,6 +5104,28 @@ async function sendEncryptedDM(arbi, messages, crypto) {
5103
5104
  "Failed to send message"
5104
5105
  );
5105
5106
  }
5107
+ async function requestWorkspaceAccess(arbi, params, crypto) {
5108
+ const payload = JSON.stringify({
5109
+ session_pubkey_b64: params.sessionPubkeyB64,
5110
+ note: params.note?.trim() || void 0
5111
+ });
5112
+ const content = await encryptDmContent(
5113
+ arbi,
5114
+ payload,
5115
+ params.recipientEncryptionPublicKey,
5116
+ crypto.encryptionKeypair.secretKey
5117
+ );
5118
+ return requireData(
5119
+ await arbi.fetch.POST("/v1/notifications/access-request", {
5120
+ body: {
5121
+ recipient_ext_id: params.recipientExtId,
5122
+ content,
5123
+ ...params.workspaceExtId ? { workspace_ext_id: params.workspaceExtId } : {}
5124
+ }
5125
+ }),
5126
+ "Failed to request workspace access"
5127
+ );
5128
+ }
5106
5129
  async function sendDM(arbi, messages) {
5107
5130
  return requireData(
5108
5131
  await arbi.fetch.POST("/v1/notifications/", {
@@ -5452,6 +5475,21 @@ var Arbi = class {
5452
5475
  addUsers: (emails, role) => addWorkspaceUsers(this.requireClient(), emails, role),
5453
5476
  removeUsers: (userIds) => removeWorkspaceUsers(this.requireClient(), userIds),
5454
5477
  setUserRole: (userIds, role) => setUserRole(this.requireClient(), userIds, role),
5478
+ /**
5479
+ * Ask another user to grant you workspace access. Builds the E2E-encrypted
5480
+ * request `content` (carrying this session's public key for a temporary
5481
+ * grant) and posts it. `workspaceExtId` is optional — pass it only when you
5482
+ * already know the target workspace id (obtained out-of-band).
5483
+ */
5484
+ requestAccess: (params) => {
5485
+ const client = this.requireClient();
5486
+ const lr2 = this.requireLogin();
5487
+ const userExtId = lr2.userExtId ?? client.session.getState().userExtId;
5488
+ if (!userExtId) throw new ArbiError("No user id in session \u2014 cannot request access");
5489
+ const crypto = createDmCryptoContext(client, lr2.signingPrivateKey, userExtId);
5490
+ const sessionPubkeyB64 = client.crypto.bytesToBase64(lr2.serverSessionKey);
5491
+ return requestWorkspaceAccess(client, { ...params, sessionPubkeyB64 }, crypto);
5492
+ },
5455
5493
  copyDocuments: (targetWorkspaceId, docIds, targetWorkspaceKey) => copyDocuments(
5456
5494
  this.requireClient(),
5457
5495
  targetWorkspaceId,