@arbidocs/sdk 0.4.94 → 0.4.96
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/{browser-DcxlFaYK.d.cts → browser-CJqWb9M6.d.cts} +25 -1
- package/dist/{browser-DcxlFaYK.d.ts → browser-CJqWb9M6.d.ts} +25 -1
- package/dist/browser.cjs +46 -23
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +46 -23
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +46 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -23
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -3984,6 +3984,12 @@ declare namespace agents {
|
|
|
3984
3984
|
*/
|
|
3985
3985
|
|
|
3986
3986
|
type UpdateProfileRequest = components['schemas']['UpdateProfileRequest'];
|
|
3987
|
+
type CurrentUserResponse = components['schemas']['CurrentUserResponse'];
|
|
3988
|
+
/**
|
|
3989
|
+
* The signed-in user as the server sees them now, including what they may do on this deployment
|
|
3990
|
+
* (`can_create_projects`). Unlike the login profile it is re-read, so it follows role changes.
|
|
3991
|
+
*/
|
|
3992
|
+
declare function getCurrentUser(arbi: ArbiClient): Promise<CurrentUserResponse>;
|
|
3987
3993
|
/**
|
|
3988
3994
|
* Update the signed-in user's profile. Fields are optional — pass only what
|
|
3989
3995
|
* changes (e.g. `given_name`, `family_name`, `picture`).
|
|
@@ -3996,10 +4002,12 @@ declare function updateProfile(arbi: ArbiClient, body: UpdateProfileRequest): Pr
|
|
|
3996
4002
|
is_identity_verified: boolean;
|
|
3997
4003
|
}>;
|
|
3998
4004
|
|
|
4005
|
+
type profile_CurrentUserResponse = CurrentUserResponse;
|
|
3999
4006
|
type profile_UpdateProfileRequest = UpdateProfileRequest;
|
|
4007
|
+
declare const profile_getCurrentUser: typeof getCurrentUser;
|
|
4000
4008
|
declare const profile_updateProfile: typeof updateProfile;
|
|
4001
4009
|
declare namespace profile {
|
|
4002
|
-
export { type profile_UpdateProfileRequest as UpdateProfileRequest, profile_updateProfile as updateProfile };
|
|
4010
|
+
export { type profile_CurrentUserResponse as CurrentUserResponse, type profile_UpdateProfileRequest as UpdateProfileRequest, profile_getCurrentUser as getCurrentUser, profile_updateProfile as updateProfile };
|
|
4003
4011
|
}
|
|
4004
4012
|
|
|
4005
4013
|
/**
|
|
@@ -5870,6 +5878,22 @@ declare class Arbi {
|
|
|
5870
5878
|
usageToday: () => Promise<{
|
|
5871
5879
|
credits_used: number;
|
|
5872
5880
|
}>;
|
|
5881
|
+
/**
|
|
5882
|
+
* The signed-in user from the server, with `can_create_projects`: false on deployments where
|
|
5883
|
+
* only firm members may create projects and workspaces and this user is not one (yet).
|
|
5884
|
+
*/
|
|
5885
|
+
me: () => Promise<{
|
|
5886
|
+
external_id: string;
|
|
5887
|
+
parent_ext_id?: string | null;
|
|
5888
|
+
email: string;
|
|
5889
|
+
given_name: string;
|
|
5890
|
+
family_name?: string | null;
|
|
5891
|
+
picture?: string | null;
|
|
5892
|
+
encryption_public_key: string;
|
|
5893
|
+
is_sso: boolean;
|
|
5894
|
+
is_identity_verified: boolean;
|
|
5895
|
+
can_create_projects: boolean;
|
|
5896
|
+
}>;
|
|
5873
5897
|
};
|
|
5874
5898
|
readonly profile: {
|
|
5875
5899
|
/** Update the display profile; pass only what changes (`''` clears family name or picture). */
|
|
@@ -3984,6 +3984,12 @@ declare namespace agents {
|
|
|
3984
3984
|
*/
|
|
3985
3985
|
|
|
3986
3986
|
type UpdateProfileRequest = components['schemas']['UpdateProfileRequest'];
|
|
3987
|
+
type CurrentUserResponse = components['schemas']['CurrentUserResponse'];
|
|
3988
|
+
/**
|
|
3989
|
+
* The signed-in user as the server sees them now, including what they may do on this deployment
|
|
3990
|
+
* (`can_create_projects`). Unlike the login profile it is re-read, so it follows role changes.
|
|
3991
|
+
*/
|
|
3992
|
+
declare function getCurrentUser(arbi: ArbiClient): Promise<CurrentUserResponse>;
|
|
3987
3993
|
/**
|
|
3988
3994
|
* Update the signed-in user's profile. Fields are optional — pass only what
|
|
3989
3995
|
* changes (e.g. `given_name`, `family_name`, `picture`).
|
|
@@ -3996,10 +4002,12 @@ declare function updateProfile(arbi: ArbiClient, body: UpdateProfileRequest): Pr
|
|
|
3996
4002
|
is_identity_verified: boolean;
|
|
3997
4003
|
}>;
|
|
3998
4004
|
|
|
4005
|
+
type profile_CurrentUserResponse = CurrentUserResponse;
|
|
3999
4006
|
type profile_UpdateProfileRequest = UpdateProfileRequest;
|
|
4007
|
+
declare const profile_getCurrentUser: typeof getCurrentUser;
|
|
4000
4008
|
declare const profile_updateProfile: typeof updateProfile;
|
|
4001
4009
|
declare namespace profile {
|
|
4002
|
-
export { type profile_UpdateProfileRequest as UpdateProfileRequest, profile_updateProfile as updateProfile };
|
|
4010
|
+
export { type profile_CurrentUserResponse as CurrentUserResponse, type profile_UpdateProfileRequest as UpdateProfileRequest, profile_getCurrentUser as getCurrentUser, profile_updateProfile as updateProfile };
|
|
4003
4011
|
}
|
|
4004
4012
|
|
|
4005
4013
|
/**
|
|
@@ -5870,6 +5878,22 @@ declare class Arbi {
|
|
|
5870
5878
|
usageToday: () => Promise<{
|
|
5871
5879
|
credits_used: number;
|
|
5872
5880
|
}>;
|
|
5881
|
+
/**
|
|
5882
|
+
* The signed-in user from the server, with `can_create_projects`: false on deployments where
|
|
5883
|
+
* only firm members may create projects and workspaces and this user is not one (yet).
|
|
5884
|
+
*/
|
|
5885
|
+
me: () => Promise<{
|
|
5886
|
+
external_id: string;
|
|
5887
|
+
parent_ext_id?: string | null;
|
|
5888
|
+
email: string;
|
|
5889
|
+
given_name: string;
|
|
5890
|
+
family_name?: string | null;
|
|
5891
|
+
picture?: string | null;
|
|
5892
|
+
encryption_public_key: string;
|
|
5893
|
+
is_sso: boolean;
|
|
5894
|
+
is_identity_verified: boolean;
|
|
5895
|
+
can_create_projects: boolean;
|
|
5896
|
+
}>;
|
|
5873
5897
|
};
|
|
5874
5898
|
readonly profile: {
|
|
5875
5899
|
/** Update the display profile; pass only what changes (`''` clears family name or picture). */
|
package/dist/browser.cjs
CHANGED
|
@@ -3695,6 +3695,12 @@ async function getRawWorkspaceKey(arbi, workspaceId, signingPrivateKeyBase64) {
|
|
|
3695
3695
|
});
|
|
3696
3696
|
return client.sealedBoxDecrypt(ws.wrapped_key, encryptionKeyPair.secretKey);
|
|
3697
3697
|
}
|
|
3698
|
+
var StaleSessionError = class extends ArbiError {
|
|
3699
|
+
constructor(message) {
|
|
3700
|
+
super(message);
|
|
3701
|
+
this.name = "StaleSessionError";
|
|
3702
|
+
}
|
|
3703
|
+
};
|
|
3698
3704
|
async function openWorkspaceEntry(arbi, ws, serverSessionKey, signingPrivateKeyBase64) {
|
|
3699
3705
|
if (ws.wrapped_key) {
|
|
3700
3706
|
const sealedKey = await selectWorkspace(
|
|
@@ -3704,12 +3710,13 @@ async function openWorkspaceEntry(arbi, ws, serverSessionKey, signingPrivateKeyB
|
|
|
3704
3710
|
serverSessionKey,
|
|
3705
3711
|
signingPrivateKeyBase64
|
|
3706
3712
|
);
|
|
3707
|
-
const { error: error2 } = await arbi.fetch.POST("/v1/workspace/{workspace_ext_id}/open", {
|
|
3713
|
+
const { error: error2, response } = await arbi.fetch.POST("/v1/workspace/{workspace_ext_id}/open", {
|
|
3708
3714
|
params: { path: { workspace_ext_id: ws.external_id } },
|
|
3709
3715
|
body: { workspace_key: sealedKey }
|
|
3710
3716
|
});
|
|
3711
3717
|
if (error2) {
|
|
3712
|
-
|
|
3718
|
+
const message = `Workspace open failed for ${ws.external_id}: ${JSON.stringify(error2)}`;
|
|
3719
|
+
throw response.status === 401 ? new StaleSessionError(message) : new ArbiError(message);
|
|
3713
3720
|
}
|
|
3714
3721
|
return sealedKey;
|
|
3715
3722
|
}
|
|
@@ -3768,6 +3775,28 @@ async function resolveAuth(store) {
|
|
|
3768
3775
|
const { arbi, loginResult } = await createAuthenticatedClient(config, creds, store);
|
|
3769
3776
|
return { arbi, loginResult, config };
|
|
3770
3777
|
}
|
|
3778
|
+
async function openOnCachedSession(store, config, creds, workspaceId) {
|
|
3779
|
+
const { arbi, loginResult } = await buildAuthFromCache(config, creds, store);
|
|
3780
|
+
arbi.session.setSelectedWorkspace(workspaceId);
|
|
3781
|
+
await selectWorkspaceById(
|
|
3782
|
+
arbi,
|
|
3783
|
+
workspaceId,
|
|
3784
|
+
loginResult.serverSessionKey,
|
|
3785
|
+
creds.signingPrivateKeyBase64
|
|
3786
|
+
);
|
|
3787
|
+
const nextOpened = Array.from(/* @__PURE__ */ new Set([...creds.openedWorkspaces ?? [], workspaceId]));
|
|
3788
|
+
store.saveCredentials({
|
|
3789
|
+
...store.requireCredentials(),
|
|
3790
|
+
openedWorkspaces: nextOpened
|
|
3791
|
+
});
|
|
3792
|
+
return {
|
|
3793
|
+
arbi,
|
|
3794
|
+
loginResult,
|
|
3795
|
+
config,
|
|
3796
|
+
workspaceId,
|
|
3797
|
+
accessToken: creds.accessToken
|
|
3798
|
+
};
|
|
3799
|
+
}
|
|
3771
3800
|
async function resolveWorkspace(store, workspaceOpt) {
|
|
3772
3801
|
const config = store.requireConfig();
|
|
3773
3802
|
const creds = store.requireCredentials();
|
|
@@ -3776,26 +3805,11 @@ async function resolveWorkspace(store, workspaceOpt) {
|
|
|
3776
3805
|
throw new ArbiError("No workspace selected. Run: arbi workspace select <id>");
|
|
3777
3806
|
}
|
|
3778
3807
|
if (isSessionAlive(creds)) {
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
loginResult2.serverSessionKey,
|
|
3785
|
-
creds.signingPrivateKeyBase64
|
|
3786
|
-
);
|
|
3787
|
-
const nextOpened = Array.from(/* @__PURE__ */ new Set([...creds.openedWorkspaces ?? [], workspaceId]));
|
|
3788
|
-
store.saveCredentials({
|
|
3789
|
-
...store.requireCredentials(),
|
|
3790
|
-
openedWorkspaces: nextOpened
|
|
3791
|
-
});
|
|
3792
|
-
return {
|
|
3793
|
-
arbi: arbi2,
|
|
3794
|
-
loginResult: loginResult2,
|
|
3795
|
-
config,
|
|
3796
|
-
workspaceId,
|
|
3797
|
-
accessToken: creds.accessToken
|
|
3798
|
-
};
|
|
3808
|
+
try {
|
|
3809
|
+
return await openOnCachedSession(store, config, creds, workspaceId);
|
|
3810
|
+
} catch (err) {
|
|
3811
|
+
if (!(err instanceof StaleSessionError)) throw err;
|
|
3812
|
+
}
|
|
3799
3813
|
}
|
|
3800
3814
|
const { arbi, loginResult } = await createAuthenticatedClient(config, creds, store);
|
|
3801
3815
|
await selectWorkspaceById(
|
|
@@ -6025,8 +6039,12 @@ function currentSessionId(accessToken) {
|
|
|
6025
6039
|
// src/operations/profile.ts
|
|
6026
6040
|
var profile_exports = {};
|
|
6027
6041
|
__export(profile_exports, {
|
|
6042
|
+
getCurrentUser: () => getCurrentUser,
|
|
6028
6043
|
updateProfile: () => updateProfile
|
|
6029
6044
|
});
|
|
6045
|
+
async function getCurrentUser(arbi) {
|
|
6046
|
+
return requireData(await arbi.fetch.GET("/v1/user/me"), "Failed to fetch the current user");
|
|
6047
|
+
}
|
|
6030
6048
|
async function updateProfile(arbi, body) {
|
|
6031
6049
|
return requireData(
|
|
6032
6050
|
await arbi.fetch.PATCH("/v1/user/profile", { body }),
|
|
@@ -7607,7 +7625,12 @@ var Arbi = class {
|
|
|
7607
7625
|
return () => this.profileListeners.delete(listener);
|
|
7608
7626
|
},
|
|
7609
7627
|
/** Today's deployment-wide credit spend for the current user. */
|
|
7610
|
-
usageToday: () => getUserUsageToday(this.requireClient())
|
|
7628
|
+
usageToday: () => getUserUsageToday(this.requireClient()),
|
|
7629
|
+
/**
|
|
7630
|
+
* The signed-in user from the server, with `can_create_projects`: false on deployments where
|
|
7631
|
+
* only firm members may create projects and workspaces and this user is not one (yet).
|
|
7632
|
+
*/
|
|
7633
|
+
me: () => getCurrentUser(this.requireClient())
|
|
7611
7634
|
};
|
|
7612
7635
|
// ── Profile ───────────────────────────────────────────────────────────
|
|
7613
7636
|
profile = {
|