@stigmer/sdk 3.14.1 → 3.15.0
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/__tests__/ensure-identity-account.test.d.ts +2 -0
- package/__tests__/ensure-identity-account.test.d.ts.map +1 -0
- package/__tests__/ensure-identity-account.test.js +108 -0
- package/__tests__/ensure-identity-account.test.js.map +1 -0
- package/__tests__/resource-availability.test.js +4 -2
- package/__tests__/resource-availability.test.js.map +1 -1
- package/ensure-identity-account.d.ts +72 -0
- package/ensure-identity-account.d.ts.map +1 -0
- package/ensure-identity-account.js +29 -0
- package/ensure-identity-account.js.map +1 -0
- package/gen/resource-availability.js +1 -1
- package/gen/resource-availability.js.map +1 -1
- package/index.d.ts +5 -4
- package/index.d.ts.map +1 -1
- package/index.js +8 -4
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/ensure-identity-account.test.ts +146 -0
- package/src/__tests__/resource-availability.test.ts +4 -2
- package/src/ensure-identity-account.ts +87 -0
- package/src/gen/resource-availability.ts +1 -1
- package/src/index.ts +22 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-identity-account.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/ensure-identity-account.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pins `ensureMyIdentityAccount` (`ensure-identity-account.ts`; 20260911.11
|
|
3
|
+
* A3): the ONE first-sign-in flow every surface runs — the console's
|
|
4
|
+
* `useIdentityAccountGate` delegates to it, the CLI's `auth whoami` and
|
|
5
|
+
* `auth login` call it — so a platform builder embedding Stigmer gets the
|
|
6
|
+
* same flow as a first-class import.
|
|
7
|
+
*
|
|
8
|
+
* 1. whoAmI answers → the account, `created: false`; nothing else is
|
|
9
|
+
* called;
|
|
10
|
+
* 2. whoAmI is NOT_FOUND → `onProvisioning` fires once (the hook's
|
|
11
|
+
* "provisioning" state), provisionMyAccount runs, the created account
|
|
12
|
+
* comes back with `created: true`;
|
|
13
|
+
* 3. any other whoAmI error propagates untouched (UNAUTHENTICATED,
|
|
14
|
+
* UNAVAILABLE, a network fault) — the caller's error UX owns it;
|
|
15
|
+
* 4. a provisionMyAccount failure propagates untouched (UNAVAILABLE when
|
|
16
|
+
* the issuer's userinfo is down is the documented arm).
|
|
17
|
+
*
|
|
18
|
+
* The doubles reject with `StigmerError`, the vocabulary the real
|
|
19
|
+
* `IdentityAccountClient` speaks (every RPC failure passes through
|
|
20
|
+
* `wrapError`), so `isNotFound` — the SDK's one classifier — is what the
|
|
21
|
+
* helper is proven against (refinement 11, slice 4).
|
|
22
|
+
*/
|
|
23
|
+
import { Code } from "@connectrpc/connect";
|
|
24
|
+
import { create } from "@bufbuild/protobuf";
|
|
25
|
+
import { IdentityAccountSchema, } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
|
|
26
|
+
import { describe, expect, it } from "vitest";
|
|
27
|
+
import { ensureMyIdentityAccount, } from "../ensure-identity-account";
|
|
28
|
+
import { StigmerError } from "../gen/errors";
|
|
29
|
+
function clientWith(behaviour) {
|
|
30
|
+
const calls = { whoAmI: 0, provisionMyAccount: 0 };
|
|
31
|
+
const client = {
|
|
32
|
+
identityAccount: {
|
|
33
|
+
whoAmI: () => {
|
|
34
|
+
calls.whoAmI += 1;
|
|
35
|
+
return behaviour.whoAmI();
|
|
36
|
+
},
|
|
37
|
+
provisionMyAccount: () => {
|
|
38
|
+
calls.provisionMyAccount += 1;
|
|
39
|
+
return (behaviour.provisionMyAccount ??
|
|
40
|
+
(() => Promise.reject(new Error("must not be called"))))();
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
return { client, calls };
|
|
45
|
+
}
|
|
46
|
+
const EXISTING = create(IdentityAccountSchema, {
|
|
47
|
+
metadata: { id: "ida_existing" },
|
|
48
|
+
spec: { idpId: "auth0|existing" },
|
|
49
|
+
});
|
|
50
|
+
const CREATED = create(IdentityAccountSchema, {
|
|
51
|
+
metadata: { id: "ida_created" },
|
|
52
|
+
spec: { idpId: "auth0|created" },
|
|
53
|
+
});
|
|
54
|
+
const NOT_FOUND = () => new StigmerError("not-found", "Identity account not found for the authenticated user", Code.NotFound);
|
|
55
|
+
describe("ensureMyIdentityAccount", () => {
|
|
56
|
+
it("answers the existing account without provisioning", async () => {
|
|
57
|
+
const { client, calls } = clientWith({
|
|
58
|
+
whoAmI: () => Promise.resolve(EXISTING),
|
|
59
|
+
});
|
|
60
|
+
const result = await ensureMyIdentityAccount(client);
|
|
61
|
+
expect(result).toEqual({ account: EXISTING, created: false });
|
|
62
|
+
expect(calls).toEqual({ whoAmI: 1, provisionMyAccount: 0 });
|
|
63
|
+
});
|
|
64
|
+
it("provisions on NOT_FOUND, telling the caller once that it is provisioning", async () => {
|
|
65
|
+
const { client, calls } = clientWith({
|
|
66
|
+
whoAmI: () => Promise.reject(NOT_FOUND()),
|
|
67
|
+
provisionMyAccount: () => Promise.resolve(CREATED),
|
|
68
|
+
});
|
|
69
|
+
let provisioning = 0;
|
|
70
|
+
const result = await ensureMyIdentityAccount(client, {
|
|
71
|
+
onProvisioning: () => (provisioning += 1),
|
|
72
|
+
});
|
|
73
|
+
expect(result).toEqual({ account: CREATED, created: true });
|
|
74
|
+
expect(provisioning).toBe(1);
|
|
75
|
+
expect(calls).toEqual({ whoAmI: 1, provisionMyAccount: 1 });
|
|
76
|
+
});
|
|
77
|
+
it("does not fire onProvisioning when the account already exists", async () => {
|
|
78
|
+
const { client } = clientWith({ whoAmI: () => Promise.resolve(EXISTING) });
|
|
79
|
+
let provisioning = 0;
|
|
80
|
+
await ensureMyIdentityAccount(client, {
|
|
81
|
+
onProvisioning: () => (provisioning += 1),
|
|
82
|
+
});
|
|
83
|
+
expect(provisioning).toBe(0);
|
|
84
|
+
});
|
|
85
|
+
it("propagates any other whoAmI error untouched — only NOT_FOUND means 'provision me'", async () => {
|
|
86
|
+
const unauthenticated = new StigmerError("unauthenticated", "authentication token missing", Code.Unauthenticated);
|
|
87
|
+
const { client, calls } = clientWith({
|
|
88
|
+
whoAmI: () => Promise.reject(unauthenticated),
|
|
89
|
+
});
|
|
90
|
+
await expect(ensureMyIdentityAccount(client)).rejects.toBe(unauthenticated);
|
|
91
|
+
expect(calls.provisionMyAccount).toBe(0);
|
|
92
|
+
// A value that is not a StigmerError at all (a lane double that does
|
|
93
|
+
// not wrap, a transport fault) is also "any other error": propagated
|
|
94
|
+
// as the same object, never classified as "provision me".
|
|
95
|
+
const network = new TypeError("Load failed");
|
|
96
|
+
const offline = clientWith({ whoAmI: () => Promise.reject(network) });
|
|
97
|
+
await expect(ensureMyIdentityAccount(offline.client)).rejects.toBe(network);
|
|
98
|
+
});
|
|
99
|
+
it("propagates a provisioning failure untouched (the issuer's userinfo down is UNAVAILABLE)", async () => {
|
|
100
|
+
const unavailable = new StigmerError("unavailable", "Failed to fetch user profile from identity provider: userinfo answered 503", Code.Unavailable);
|
|
101
|
+
const { client } = clientWith({
|
|
102
|
+
whoAmI: () => Promise.reject(NOT_FOUND()),
|
|
103
|
+
provisionMyAccount: () => Promise.reject(unavailable),
|
|
104
|
+
});
|
|
105
|
+
await expect(ensureMyIdentityAccount(client)).rejects.toBe(unavailable);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=ensure-identity-account.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-identity-account.test.js","sourceRoot":"","sources":["../../src/__tests__/ensure-identity-account.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,qBAAqB,GAEtB,MAAM,0DAA0D,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,Q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MAAM,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yFAAyF,EAAE,KAAK,IAAI,EAAE;QACvG,MAAM,WAAW,GAAG,IAAI,YAAY,CAClC,aAAa,EACb,4EAA4E,EAC5E,IAAI,CAAC,WAAW,CACjB,CAAC;QACF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;YAC5B,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YACzC,kBAAkB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC;SACtD,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -58,8 +58,10 @@ describe("isResourceAvailable — a tier is a minimum edition", () => {
|
|
|
58
58
|
// platform: the operator seat a self-hosting Enterprise company owns.
|
|
59
59
|
expect(isResourceAvailable(ApiResourceKind.platform, "local")).toBe(false);
|
|
60
60
|
expect(isResourceAvailable(ApiResourceKind.platform, "enterprise")).toBe(true);
|
|
61
|
-
// identity_account:
|
|
62
|
-
|
|
61
|
+
// identity_account: open_source since the open-source server serves the
|
|
62
|
+
// domain (20260911.11 slice 5); the tier moved in the same change as
|
|
63
|
+
// the serving code, never ahead of it.
|
|
64
|
+
expect(isResourceAvailable(ApiResourceKind.identity_account, "local")).toBe(true);
|
|
63
65
|
// agent_share and channel_app: served by OSS; they never moved.
|
|
64
66
|
expect(isResourceAvailable(ApiResourceKind.agent_share, "local")).toBe(true);
|
|
65
67
|
expect(isResourceAvailable(ApiResourceKind.channel_app, "local")).toBe(true);
|
|
@@ -1 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,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first-sign-in flow, once: make sure the authenticated caller has an
|
|
3
|
+
* identity account, creating it if this is the first time they arrive.
|
|
4
|
+
*
|
|
5
|
+
* Every edition serves `IdentityAccount` from one controller (20260911.11),
|
|
6
|
+
* and every surface that greets a signed-in person runs the same two-step
|
|
7
|
+
* flow — the console's `useIdentityAccountGate` (`@stigmer/react`), the
|
|
8
|
+
* CLI's `auth login` and `auth whoami`, and any platform builder's own
|
|
9
|
+
* gate. This module is that flow's one home, so the surfaces cannot drift
|
|
10
|
+
* on the question "what does a missing account mean?".
|
|
11
|
+
*
|
|
12
|
+
* Three facts it is built on:
|
|
13
|
+
*
|
|
14
|
+
* - `whoAmI` answers NOT_FOUND for an authenticated caller who has no
|
|
15
|
+
* account yet (the server's byte-pinned copy: "Identity account not found
|
|
16
|
+
* for the authenticated user"). That code, and ONLY that code, means
|
|
17
|
+
* "provision me". UNAUTHENTICATED, UNAVAILABLE, a transport fault — each
|
|
18
|
+
* is the caller's to handle and is rethrown as the same object.
|
|
19
|
+
* - `provisionMyAccount` is the one creator of a direct account and is
|
|
20
|
+
* idempotent by the caller's subject: two racing first sign-ins resolve
|
|
21
|
+
* to one row. Its failures are also rethrown untouched (the issuer's
|
|
22
|
+
* userinfo being down is UNAVAILABLE, the documented arm).
|
|
23
|
+
* - Whether THIS call created the account is part of the answer. A first
|
|
24
|
+
* sign-in should be visible ("your account was created"), not silent.
|
|
25
|
+
*
|
|
26
|
+
* The client parameter is structural, the `McpServerConnectLane` precedent:
|
|
27
|
+
* the full `Stigmer` client satisfies it, and a test can hand in two
|
|
28
|
+
* functions.
|
|
29
|
+
*/
|
|
30
|
+
import type { IdentityAccount } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
|
|
31
|
+
/**
|
|
32
|
+
* The slice of the identity-account client this flow needs. Errors are the
|
|
33
|
+
* SDK client's `StigmerError`s; `isNotFound` is the one classifier read.
|
|
34
|
+
*/
|
|
35
|
+
export interface IdentityAccountLane {
|
|
36
|
+
whoAmI(): Promise<IdentityAccount>;
|
|
37
|
+
provisionMyAccount(): Promise<IdentityAccount>;
|
|
38
|
+
}
|
|
39
|
+
/** Options for {@link ensureMyIdentityAccount}. */
|
|
40
|
+
export interface EnsureMyIdentityAccountOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Called once, before `provisionMyAccount` is issued, when `whoAmI` found
|
|
43
|
+
* no account — the moment a surface shows "Setting up your account…".
|
|
44
|
+
* Not called when the account already exists.
|
|
45
|
+
*/
|
|
46
|
+
readonly onProvisioning?: () => void;
|
|
47
|
+
}
|
|
48
|
+
/** What {@link ensureMyIdentityAccount} learned. */
|
|
49
|
+
export interface EnsuredIdentityAccount {
|
|
50
|
+
/** The caller's account, existing or just created. */
|
|
51
|
+
readonly account: IdentityAccount;
|
|
52
|
+
/** `true` when this call created the account (a first sign-in). */
|
|
53
|
+
readonly created: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the caller's identity account, provisioning it on a first sign-in.
|
|
57
|
+
*
|
|
58
|
+
* `whoAmI` first; on NOT_FOUND — and only NOT_FOUND — `onProvisioning` fires
|
|
59
|
+
* and `provisionMyAccount` runs. Every other error, from either RPC, is
|
|
60
|
+
* rethrown as the same object so the caller's error UX owns it.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const { account, created } = await ensureMyIdentityAccount(stigmer, {
|
|
65
|
+
* onProvisioning: () => console.log("Setting up your account…"),
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function ensureMyIdentityAccount(client: {
|
|
70
|
+
readonly identityAccount: IdentityAccountLane;
|
|
71
|
+
}, options?: EnsureMyIdentityAccountOptions): Promise<EnsuredIdentityAccount>;
|
|
72
|
+
//# sourceMappingURL=ensure-identity-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-identity-account.d.ts","sourceRoot":"","sources":["../src/ensure-identity-account.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAGhG;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IACnC,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CAChD;AAED,mDAAmD;AACnD,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CACtC;AAED,oDAAoD;AACpD,MAAM,WAAW,sBAAsB;IACrC,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE;IAAE,QAAQ,CAAC,eAAe,EAAE,mBAAmB,CAAA;CAAE,EACzD,OAAO,CAAC,EAAE,8BAA8B,GACvC,OAAO,CAAC,sBAAsB,CAAC,CAUjC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { isNotFound } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the caller's identity account, provisioning it on a first sign-in.
|
|
4
|
+
*
|
|
5
|
+
* `whoAmI` first; on NOT_FOUND — and only NOT_FOUND — `onProvisioning` fires
|
|
6
|
+
* and `provisionMyAccount` runs. Every other error, from either RPC, is
|
|
7
|
+
* rethrown as the same object so the caller's error UX owns it.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const { account, created } = await ensureMyIdentityAccount(stigmer, {
|
|
12
|
+
* onProvisioning: () => console.log("Setting up your account…"),
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export async function ensureMyIdentityAccount(client, options) {
|
|
17
|
+
try {
|
|
18
|
+
const account = await client.identityAccount.whoAmI();
|
|
19
|
+
return { account, created: false };
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (!isNotFound(err))
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
options?.onProvisioning?.();
|
|
26
|
+
const account = await client.identityAccount.provisionMyAccount();
|
|
27
|
+
return { account, created: true };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ensure-identity-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-identity-account.js","sourceRoot":"","sources":["../src/ensure-identity-account.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6BzC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,MAAyD,EACzD,OAAwC;IAExC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACrC,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,MAAM,GAAG,CAAC;IAClC,CAAC;IACD,OAAO,EAAE,cAAc,EAAE,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,kBAAkB,EAAE,CAAC;IAClE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -12,7 +12,7 @@ import { ApiResourceKind, ResourceTier } from "@stigmer/protos/ai/stigmer/common
|
|
|
12
12
|
export const KIND_TIERS = new Map([
|
|
13
13
|
[ApiResourceKind.api_resource_version, ResourceTier.cloud_only],
|
|
14
14
|
[ApiResourceKind.iam_policy, ResourceTier.enterprise],
|
|
15
|
-
[ApiResourceKind.identity_account, ResourceTier.
|
|
15
|
+
[ApiResourceKind.identity_account, ResourceTier.open_source],
|
|
16
16
|
[ApiResourceKind.api_key, ResourceTier.open_source],
|
|
17
17
|
[ApiResourceKind.invitation, ResourceTier.enterprise],
|
|
18
18
|
[ApiResourceKind.identity_provider, ResourceTier.enterprise],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-availability.js","sourceRoot":"","sources":["../../src/gen/resource-availability.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qFAAqF,CAAC;AAEpI;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAA+C,IAAI,GAAG,CAAC;IAC5E,CAAC,eAAe,CAAC,oBAAoB,EAAE,YAAY,CAAC,UAAU,CAAC;IAC/D,CAAC,eAAe,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;IACrD,CAAC,eAAe,CAAC,gBAAgB,EAAE,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"resource-availability.js","sourceRoot":"","sources":["../../src/gen/resource-availability.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,qFAAqF,CAAC;AAEpI;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAA+C,IAAI,GAAG,CAAC;IAC5E,CAAC,eAAe,CAAC,oBAAoB,EAAE,YAAY,CAAC,UAAU,CAAC;IAC/D,CAAC,eAAe,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;IACrD,CAAC,eAAe,CAAC,gBAAgB,EAAE,YAAY,CAAC,WAAW,CAAC;IAC5D,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,WAAW,CA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,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,CAAC,WAAW,CAAC;IACpD,CAAC,eAAe,CAAC,QAAQ,EAAE,YAAY,CAAC,WAAW,CAAC;IACpD,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC;IAClD,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC;CACpD,CAAC,CAAC"}
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { createGuestAuth, GuestAuth, type GuestAuthConfig, type GuestIdStorage,
|
|
|
5
5
|
export { MAX_ALLOWED_ORIGINS, LINK_TOKEN_PARAM, validateOrigin, chatPath, buildChatUrl, appendLinkToken, buildEmbedLoaderUrl, buildEmbedSnippet, } from "./sharing.js";
|
|
6
6
|
export { StigmerError, type ErrorCode, isNotFound, isUnauthenticated, isPermissionDenied, isRetryable, isUnimplemented, type ErrorCategory, isConnectError, classifyError, isRetryableError, isTransientStreamError, getUserMessage, type ErrorReason, getErrorReason, type RpcErrorMetadata, annotateRpcError, getRpcMetadata, } from "./errors.js";
|
|
7
7
|
export { type DeploymentMode, deploymentModeOf, isResourceAvailable, } from "./resource-availability.js";
|
|
8
|
+
export { ensureMyIdentityAccount, type EnsuredIdentityAccount, type EnsureMyIdentityAccountOptions, type IdentityAccountLane, } from "./ensure-identity-account.js";
|
|
8
9
|
export { getGrantableRoles, hasGrantableRoles, isRoleGrantable, } from "./authorization-config.js";
|
|
9
10
|
export { iamRoleToString, iamRoleFromString, iamRoleDisplayName, iamRoleDescription, } from "./iam-role.js";
|
|
10
11
|
export { IamRole } from "@stigmer/protos/ai/stigmer/iam/v1/enum_pb";
|
|
@@ -15,7 +16,7 @@ export { CursorAccountsClient, type UpsertCursorAccountParams, type DeleteCursor
|
|
|
15
16
|
export { ProviderStandingClient } from "./provider-standing.js";
|
|
16
17
|
export { SearchClient, type SearchParams, type SearchResponse, ApiResourceKind, } from "./search.js";
|
|
17
18
|
export { GitHubClient, type GetOAuthAuthorizeUrlParams, type OAuthAuthorizeUrlResponse, type ExchangeOAuthCodeParams, type OAuthTokenResponse, } from "./github.js";
|
|
18
|
-
export { PlatformClient, type ServerInfo
|
|
19
|
+
export { PlatformClient, type ServerInfo } from "./platform.js";
|
|
19
20
|
export { ManifestClient, parseManifest, serializeManifest, manifestDocumentForResource, manifestKinds, manifestHandlerForYamlKind, manifestHandlerForTypeName, metadataOf, REDACTED_SECRET_MARKER, containsRedactedSecrets, type AppliedManifest, type ManifestDocument, type ManifestKindHandler, type ParseManifestOptions, } from "./manifest/index.js";
|
|
20
21
|
export { type DeleteResourceInput, type ResourceRef, type Page, type ListParams, type ListResult, type EnvSpecInput, type EnvVarInput, } from "./gen/types.js";
|
|
21
22
|
export { AgentClient, buildAgentProto, toAgentUpdateInput, type AgentInput, type McpServerUsageInput, type ToolApprovalOverrideInput, type SubAgentInput, type McpAccessInput, type EnvVarDeclarationInput, } from "./gen/agent.js";
|
|
@@ -23,13 +24,13 @@ export { AgentChannelClient, toAgentChannelUpdateInput, type AgentChannelInput,
|
|
|
23
24
|
export { AgentExecutionClient, toAgentExecutionUpdateInput, type AgentExecutionInput, type ExecutionConfigInput, type ContextManagementConfigInput, type AttachmentInput, } from "./gen/agentexecution.js";
|
|
24
25
|
export { AgentInstanceClient, toAgentInstanceUpdateInput, type AgentInstanceInput, } from "./gen/agentinstance.js";
|
|
25
26
|
export { AgentShareClient, toAgentShareUpdateInput, type AgentShareInput, type AgentShareMessagesInput, } from "./gen/agentshare.js";
|
|
26
|
-
export { ApiKeyClient, toApiKeyUpdateInput, type ApiKeyInput } from "./gen/apikey.js";
|
|
27
|
+
export { ApiKeyClient, toApiKeyUpdateInput, type ApiKeyInput, } from "./gen/apikey.js";
|
|
27
28
|
export { ChannelAppClient, toChannelAppUpdateInput, type ChannelAppInput, type SlackChannelAppConfigInput, } from "./gen/channelapp.js";
|
|
28
29
|
export { EnvironmentClient, toEnvironmentUpdateInput, type EnvironmentInput, } from "./gen/environment.js";
|
|
29
30
|
export { ExecutionContextClient, type ExecutionContextInput, } from "./gen/executioncontext.js";
|
|
30
31
|
export { IamPolicyClient, type IamPolicyInput, type ApiResourceRefInput, } from "./gen/iampolicy.js";
|
|
31
32
|
export { IdentityAccountClient, toIdentityAccountUpdateInput, type IdentityAccountInput, } from "./gen/identityaccount.js";
|
|
32
|
-
export { InvitationClient, type InvitationInput
|
|
33
|
+
export { InvitationClient, type InvitationInput } from "./gen/invitation.js";
|
|
33
34
|
export { IdentityProviderClient, toIdentityProviderUpdateInput, type IdentityProviderInput, } from "./gen/identityprovider.js";
|
|
34
35
|
export { OAuthAppClient, toOAuthAppUpdateInput, type OAuthAppInput, } from "./gen/oauthapp.js";
|
|
35
36
|
export { McpServerClient, buildMcpServerProto, toMcpServerUpdateInput, type McpServerInput, type StdioServerConfigInput, type HttpServerConfigInput, type ToolApprovalPolicyInput, } from "./gen/mcpserver.js";
|
|
@@ -37,7 +38,7 @@ export { MemoryClient, buildMemoryProto, toMemoryUpdateInput, type MemoryInput,
|
|
|
37
38
|
export { connectAndWait, ConnectStillRunningError, CONNECT_POLL_INTERVAL_MS, CONNECT_SETTLE_BOUND_MS, type ConnectAndWaitOptions, type McpServerConnectLane, } from "./mcpserver-connect.js";
|
|
38
39
|
export { OrganizationClient, toOrganizationUpdateInput, type OrganizationInput, } from "./gen/organization.js";
|
|
39
40
|
export { PlatformClientClient, toPlatformClientUpdateInput, type PlatformClientInput, } from "./gen/platformclient.js";
|
|
40
|
-
export { ProjectClient, toProjectUpdateInput, type ProjectInput } from "./gen/project.js";
|
|
41
|
+
export { ProjectClient, toProjectUpdateInput, type ProjectInput, } from "./gen/project.js";
|
|
41
42
|
export { ScheduleClient, buildScheduleProto, toScheduleUpdateInput, type ScheduleInput, type AgentInvocationInput, type RunConfigInput, } from "./gen/schedule.js";
|
|
42
43
|
export { SessionClient, toSessionUpdateInput, type SessionInput, type WorkspaceEntryInput, type WorkspaceSourceInput, type GitRepoSourceInput, type LocalPathSourceInput, } from "./gen/session.js";
|
|
43
44
|
export { PENDING_SUBJECT, SESSION_CONTEXT_METADATA_KEY, mergeSessionContext, resolvedSubject, } from "./session.js";
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,EACL,eAAe,EACf,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,YAAY,EACZ,KAAK,SAAS,EACd,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,KAAK,WAAW,EAChB,cAAc,EACd,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,cAAc,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,mBAAmB,GACpB,MAAM,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, buildC
|
|
|
11
11
|
export { StigmerError, isNotFound, isUnauthenticated, isPermissionDenied, isRetryable, isUnimplemented, isConnectError, classifyError, isRetryableError, isTransientStreamError, getUserMessage, getErrorReason, annotateRpcError, getRpcMetadata, } from "./errors.js";
|
|
12
12
|
// Edition vocabulary and resource availability
|
|
13
13
|
export { deploymentModeOf, isResourceAvailable, } from "./resource-availability.js";
|
|
14
|
+
// The first-sign-in flow: resolve the caller's identity account, provisioning
|
|
15
|
+
// it on a first sign-in. One home for every surface (console gate, CLI,
|
|
16
|
+
// platform builders' own gates).
|
|
17
|
+
export { ensureMyIdentityAccount, } from "./ensure-identity-account.js";
|
|
14
18
|
// Authorization config and IAM role utilities
|
|
15
19
|
export { getGrantableRoles, hasGrantableRoles, isRoleGrantable, } from "./authorization-config.js";
|
|
16
20
|
export { iamRoleToString, iamRoleFromString, iamRoleDisplayName, iamRoleDescription, } from "./iam-role.js";
|
|
@@ -28,7 +32,7 @@ export { SearchClient, ApiResourceKind, } from "./search.js";
|
|
|
28
32
|
// GitHub OAuth client
|
|
29
33
|
export { GitHubClient, } from "./github.js";
|
|
30
34
|
// Platform client (server info / edition detection)
|
|
31
|
-
export { PlatformClient
|
|
35
|
+
export { PlatformClient } from "./platform.js";
|
|
32
36
|
// Manifest engine (kind-agnostic YAML ⇄ proto ⇄ apply)
|
|
33
37
|
export { ManifestClient, parseManifest, serializeManifest, manifestDocumentForResource, manifestKinds, manifestHandlerForYamlKind, manifestHandlerForTypeName, metadataOf, REDACTED_SECRET_MARKER, containsRedactedSecrets, } from "./manifest/index.js";
|
|
34
38
|
// Re-export all resource client classes and input types. The
|
|
@@ -40,13 +44,13 @@ export { AgentChannelClient, toAgentChannelUpdateInput, } from "./gen/agentchann
|
|
|
40
44
|
export { AgentExecutionClient, toAgentExecutionUpdateInput, } from "./gen/agentexecution.js";
|
|
41
45
|
export { AgentInstanceClient, toAgentInstanceUpdateInput, } from "./gen/agentinstance.js";
|
|
42
46
|
export { AgentShareClient, toAgentShareUpdateInput, } from "./gen/agentshare.js";
|
|
43
|
-
export { ApiKeyClient, toApiKeyUpdateInput } from "./gen/apikey.js";
|
|
47
|
+
export { ApiKeyClient, toApiKeyUpdateInput, } from "./gen/apikey.js";
|
|
44
48
|
export { ChannelAppClient, toChannelAppUpdateInput, } from "./gen/channelapp.js";
|
|
45
49
|
export { EnvironmentClient, toEnvironmentUpdateInput, } from "./gen/environment.js";
|
|
46
50
|
export { ExecutionContextClient, } from "./gen/executioncontext.js";
|
|
47
51
|
export { IamPolicyClient, } from "./gen/iampolicy.js";
|
|
48
52
|
export { IdentityAccountClient, toIdentityAccountUpdateInput, } from "./gen/identityaccount.js";
|
|
49
|
-
export { InvitationClient
|
|
53
|
+
export { InvitationClient } from "./gen/invitation.js";
|
|
50
54
|
export { IdentityProviderClient, toIdentityProviderUpdateInput, } from "./gen/identityprovider.js";
|
|
51
55
|
export { OAuthAppClient, toOAuthAppUpdateInput, } from "./gen/oauthapp.js";
|
|
52
56
|
export { McpServerClient, buildMcpServerProto, toMcpServerUpdateInput, } from "./gen/mcpserver.js";
|
|
@@ -54,7 +58,7 @@ export { MemoryClient, buildMemoryProto, toMemoryUpdateInput, } from "./gen/memo
|
|
|
54
58
|
export { connectAndWait, ConnectStillRunningError, CONNECT_POLL_INTERVAL_MS, CONNECT_SETTLE_BOUND_MS, } from "./mcpserver-connect.js";
|
|
55
59
|
export { OrganizationClient, toOrganizationUpdateInput, } from "./gen/organization.js";
|
|
56
60
|
export { PlatformClientClient, toPlatformClientUpdateInput, } from "./gen/platformclient.js";
|
|
57
|
-
export { ProjectClient, toProjectUpdateInput } from "./gen/project.js";
|
|
61
|
+
export { ProjectClient, toProjectUpdateInput, } from "./gen/project.js";
|
|
58
62
|
export { ScheduleClient, buildScheduleProto, toScheduleUpdateInput, } from "./gen/schedule.js";
|
|
59
63
|
export { SessionClient, toSessionUpdateInput, } from "./gen/session.js";
|
|
60
64
|
// Session utilities (hand-written)
|
package/index.js.map
CHANGED
|
@@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mB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,GAIpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,GAQjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,qBAAqB,GAMtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,EACvB,8BAA8B,GAE/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,GAE9B,MAAM,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stigmer/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "Stigmer TypeScript SDK — typed API client for all Stigmer platform resources",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@bufbuild/protobuf": "^2.0.0",
|
|
47
47
|
"@connectrpc/connect-node": "^2.0.0",
|
|
48
|
-
"@stigmer/protos": "3.
|
|
48
|
+
"@stigmer/protos": "3.15.0"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pins `ensureMyIdentityAccount` (`ensure-identity-account.ts`; 20260911.11
|
|
3
|
+
* A3): the ONE first-sign-in flow every surface runs — the console's
|
|
4
|
+
* `useIdentityAccountGate` delegates to it, the CLI's `auth whoami` and
|
|
5
|
+
* `auth login` call it — so a platform builder embedding Stigmer gets the
|
|
6
|
+
* same flow as a first-class import.
|
|
7
|
+
*
|
|
8
|
+
* 1. whoAmI answers → the account, `created: false`; nothing else is
|
|
9
|
+
* called;
|
|
10
|
+
* 2. whoAmI is NOT_FOUND → `onProvisioning` fires once (the hook's
|
|
11
|
+
* "provisioning" state), provisionMyAccount runs, the created account
|
|
12
|
+
* comes back with `created: true`;
|
|
13
|
+
* 3. any other whoAmI error propagates untouched (UNAUTHENTICATED,
|
|
14
|
+
* UNAVAILABLE, a network fault) — the caller's error UX owns it;
|
|
15
|
+
* 4. a provisionMyAccount failure propagates untouched (UNAVAILABLE when
|
|
16
|
+
* the issuer's userinfo is down is the documented arm).
|
|
17
|
+
*
|
|
18
|
+
* The doubles reject with `StigmerError`, the vocabulary the real
|
|
19
|
+
* `IdentityAccountClient` speaks (every RPC failure passes through
|
|
20
|
+
* `wrapError`), so `isNotFound` — the SDK's one classifier — is what the
|
|
21
|
+
* helper is proven against (refinement 11, slice 4).
|
|
22
|
+
*/
|
|
23
|
+
import { Code } from "@connectrpc/connect";
|
|
24
|
+
import { create } from "@bufbuild/protobuf";
|
|
25
|
+
import {
|
|
26
|
+
IdentityAccountSchema,
|
|
27
|
+
type IdentityAccount,
|
|
28
|
+
} from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
|
|
29
|
+
import { describe, expect, it } from "vitest";
|
|
30
|
+
|
|
31
|
+
import {
|
|
32
|
+
ensureMyIdentityAccount,
|
|
33
|
+
type IdentityAccountLane,
|
|
34
|
+
} from "../ensure-identity-account";
|
|
35
|
+
import { StigmerError } from "../gen/errors";
|
|
36
|
+
|
|
37
|
+
interface Calls {
|
|
38
|
+
whoAmI: number;
|
|
39
|
+
provisionMyAccount: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function clientWith(behaviour: {
|
|
43
|
+
whoAmI: () => Promise<IdentityAccount>;
|
|
44
|
+
provisionMyAccount?: () => Promise<IdentityAccount>;
|
|
45
|
+
}): { client: { identityAccount: IdentityAccountLane }; calls: Calls } {
|
|
46
|
+
const calls: Calls = { whoAmI: 0, provisionMyAccount: 0 };
|
|
47
|
+
const client = {
|
|
48
|
+
identityAccount: {
|
|
49
|
+
whoAmI: () => {
|
|
50
|
+
calls.whoAmI += 1;
|
|
51
|
+
return behaviour.whoAmI();
|
|
52
|
+
},
|
|
53
|
+
provisionMyAccount: () => {
|
|
54
|
+
calls.provisionMyAccount += 1;
|
|
55
|
+
return (
|
|
56
|
+
behaviour.provisionMyAccount ??
|
|
57
|
+
(() => Promise.reject(new Error("must not be called")))
|
|
58
|
+
)();
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
return { client, calls };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const EXISTING = create(IdentityAccountSchema, {
|
|
66
|
+
metadata: { id: "ida_existing" },
|
|
67
|
+
spec: { idpId: "auth0|existing" },
|
|
68
|
+
});
|
|
69
|
+
const CREATED = create(IdentityAccountSchema, {
|
|
70
|
+
metadata: { id: "ida_created" },
|
|
71
|
+
spec: { idpId: "auth0|created" },
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const NOT_FOUND = () =>
|
|
75
|
+
new StigmerError(
|
|
76
|
+
"not-found",
|
|
77
|
+
"Identity account not found for the authenticated user",
|
|
78
|
+
Code.NotFound,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
describe("ensureMyIdentityAccount", () => {
|
|
82
|
+
it("answers the existing account without provisioning", async () => {
|
|
83
|
+
const { client, calls } = clientWith({
|
|
84
|
+
whoAmI: () => Promise.resolve(EXISTING),
|
|
85
|
+
});
|
|
86
|
+
const result = await ensureMyIdentityAccount(client);
|
|
87
|
+
expect(result).toEqual({ account: EXISTING, created: false });
|
|
88
|
+
expect(calls).toEqual({ whoAmI: 1, provisionMyAccount: 0 });
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("provisions on NOT_FOUND, telling the caller once that it is provisioning", async () => {
|
|
92
|
+
const { client, calls } = clientWith({
|
|
93
|
+
whoAmI: () => Promise.reject(NOT_FOUND()),
|
|
94
|
+
provisionMyAccount: () => Promise.resolve(CREATED),
|
|
95
|
+
});
|
|
96
|
+
let provisioning = 0;
|
|
97
|
+
const result = await ensureMyIdentityAccount(client, {
|
|
98
|
+
onProvisioning: () => (provisioning += 1),
|
|
99
|
+
});
|
|
100
|
+
expect(result).toEqual({ account: CREATED, created: true });
|
|
101
|
+
expect(provisioning).toBe(1);
|
|
102
|
+
expect(calls).toEqual({ whoAmI: 1, provisionMyAccount: 1 });
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("does not fire onProvisioning when the account already exists", async () => {
|
|
106
|
+
const { client } = clientWith({ whoAmI: () => Promise.resolve(EXISTING) });
|
|
107
|
+
let provisioning = 0;
|
|
108
|
+
await ensureMyIdentityAccount(client, {
|
|
109
|
+
onProvisioning: () => (provisioning += 1),
|
|
110
|
+
});
|
|
111
|
+
expect(provisioning).toBe(0);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("propagates any other whoAmI error untouched — only NOT_FOUND means 'provision me'", async () => {
|
|
115
|
+
const unauthenticated = new StigmerError(
|
|
116
|
+
"unauthenticated",
|
|
117
|
+
"authentication token missing",
|
|
118
|
+
Code.Unauthenticated,
|
|
119
|
+
);
|
|
120
|
+
const { client, calls } = clientWith({
|
|
121
|
+
whoAmI: () => Promise.reject(unauthenticated),
|
|
122
|
+
});
|
|
123
|
+
await expect(ensureMyIdentityAccount(client)).rejects.toBe(unauthenticated);
|
|
124
|
+
expect(calls.provisionMyAccount).toBe(0);
|
|
125
|
+
|
|
126
|
+
// A value that is not a StigmerError at all (a lane double that does
|
|
127
|
+
// not wrap, a transport fault) is also "any other error": propagated
|
|
128
|
+
// as the same object, never classified as "provision me".
|
|
129
|
+
const network = new TypeError("Load failed");
|
|
130
|
+
const offline = clientWith({ whoAmI: () => Promise.reject(network) });
|
|
131
|
+
await expect(ensureMyIdentityAccount(offline.client)).rejects.toBe(network);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("propagates a provisioning failure untouched (the issuer's userinfo down is UNAVAILABLE)", async () => {
|
|
135
|
+
const unavailable = new StigmerError(
|
|
136
|
+
"unavailable",
|
|
137
|
+
"Failed to fetch user profile from identity provider: userinfo answered 503",
|
|
138
|
+
Code.Unavailable,
|
|
139
|
+
);
|
|
140
|
+
const { client } = clientWith({
|
|
141
|
+
whoAmI: () => Promise.reject(NOT_FOUND()),
|
|
142
|
+
provisionMyAccount: () => Promise.reject(unavailable),
|
|
143
|
+
});
|
|
144
|
+
await expect(ensureMyIdentityAccount(client)).rejects.toBe(unavailable);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
@@ -85,9 +85,11 @@ describe("isResourceAvailable — a tier is a minimum edition", () => {
|
|
|
85
85
|
expect(isResourceAvailable(ApiResourceKind.platform, "enterprise")).toBe(
|
|
86
86
|
true,
|
|
87
87
|
);
|
|
88
|
-
// identity_account:
|
|
88
|
+
// identity_account: open_source since the open-source server serves the
|
|
89
|
+
// domain (20260911.11 slice 5); the tier moved in the same change as
|
|
90
|
+
// the serving code, never ahead of it.
|
|
89
91
|
expect(isResourceAvailable(ApiResourceKind.identity_account, "local")).toBe(
|
|
90
|
-
|
|
92
|
+
true,
|
|
91
93
|
);
|
|
92
94
|
// agent_share and channel_app: served by OSS; they never moved.
|
|
93
95
|
expect(isResourceAvailable(ApiResourceKind.agent_share, "local")).toBe(
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first-sign-in flow, once: make sure the authenticated caller has an
|
|
3
|
+
* identity account, creating it if this is the first time they arrive.
|
|
4
|
+
*
|
|
5
|
+
* Every edition serves `IdentityAccount` from one controller (20260911.11),
|
|
6
|
+
* and every surface that greets a signed-in person runs the same two-step
|
|
7
|
+
* flow — the console's `useIdentityAccountGate` (`@stigmer/react`), the
|
|
8
|
+
* CLI's `auth login` and `auth whoami`, and any platform builder's own
|
|
9
|
+
* gate. This module is that flow's one home, so the surfaces cannot drift
|
|
10
|
+
* on the question "what does a missing account mean?".
|
|
11
|
+
*
|
|
12
|
+
* Three facts it is built on:
|
|
13
|
+
*
|
|
14
|
+
* - `whoAmI` answers NOT_FOUND for an authenticated caller who has no
|
|
15
|
+
* account yet (the server's byte-pinned copy: "Identity account not found
|
|
16
|
+
* for the authenticated user"). That code, and ONLY that code, means
|
|
17
|
+
* "provision me". UNAUTHENTICATED, UNAVAILABLE, a transport fault — each
|
|
18
|
+
* is the caller's to handle and is rethrown as the same object.
|
|
19
|
+
* - `provisionMyAccount` is the one creator of a direct account and is
|
|
20
|
+
* idempotent by the caller's subject: two racing first sign-ins resolve
|
|
21
|
+
* to one row. Its failures are also rethrown untouched (the issuer's
|
|
22
|
+
* userinfo being down is UNAVAILABLE, the documented arm).
|
|
23
|
+
* - Whether THIS call created the account is part of the answer. A first
|
|
24
|
+
* sign-in should be visible ("your account was created"), not silent.
|
|
25
|
+
*
|
|
26
|
+
* The client parameter is structural, the `McpServerConnectLane` precedent:
|
|
27
|
+
* the full `Stigmer` client satisfies it, and a test can hand in two
|
|
28
|
+
* functions.
|
|
29
|
+
*/
|
|
30
|
+
import type { IdentityAccount } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
|
|
31
|
+
import { isNotFound } from "./errors.js";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The slice of the identity-account client this flow needs. Errors are the
|
|
35
|
+
* SDK client's `StigmerError`s; `isNotFound` is the one classifier read.
|
|
36
|
+
*/
|
|
37
|
+
export interface IdentityAccountLane {
|
|
38
|
+
whoAmI(): Promise<IdentityAccount>;
|
|
39
|
+
provisionMyAccount(): Promise<IdentityAccount>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Options for {@link ensureMyIdentityAccount}. */
|
|
43
|
+
export interface EnsureMyIdentityAccountOptions {
|
|
44
|
+
/**
|
|
45
|
+
* Called once, before `provisionMyAccount` is issued, when `whoAmI` found
|
|
46
|
+
* no account — the moment a surface shows "Setting up your account…".
|
|
47
|
+
* Not called when the account already exists.
|
|
48
|
+
*/
|
|
49
|
+
readonly onProvisioning?: () => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** What {@link ensureMyIdentityAccount} learned. */
|
|
53
|
+
export interface EnsuredIdentityAccount {
|
|
54
|
+
/** The caller's account, existing or just created. */
|
|
55
|
+
readonly account: IdentityAccount;
|
|
56
|
+
/** `true` when this call created the account (a first sign-in). */
|
|
57
|
+
readonly created: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the caller's identity account, provisioning it on a first sign-in.
|
|
62
|
+
*
|
|
63
|
+
* `whoAmI` first; on NOT_FOUND — and only NOT_FOUND — `onProvisioning` fires
|
|
64
|
+
* and `provisionMyAccount` runs. Every other error, from either RPC, is
|
|
65
|
+
* rethrown as the same object so the caller's error UX owns it.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const { account, created } = await ensureMyIdentityAccount(stigmer, {
|
|
70
|
+
* onProvisioning: () => console.log("Setting up your account…"),
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export async function ensureMyIdentityAccount(
|
|
75
|
+
client: { readonly identityAccount: IdentityAccountLane },
|
|
76
|
+
options?: EnsureMyIdentityAccountOptions,
|
|
77
|
+
): Promise<EnsuredIdentityAccount> {
|
|
78
|
+
try {
|
|
79
|
+
const account = await client.identityAccount.whoAmI();
|
|
80
|
+
return { account, created: false };
|
|
81
|
+
} catch (err: unknown) {
|
|
82
|
+
if (!isNotFound(err)) throw err;
|
|
83
|
+
}
|
|
84
|
+
options?.onProvisioning?.();
|
|
85
|
+
const account = await client.identityAccount.provisionMyAccount();
|
|
86
|
+
return { account, created: true };
|
|
87
|
+
}
|
|
@@ -14,7 +14,7 @@ import { ApiResourceKind, ResourceTier } from "@stigmer/protos/ai/stigmer/common
|
|
|
14
14
|
export const KIND_TIERS: ReadonlyMap<ApiResourceKind, ResourceTier> = new Map([
|
|
15
15
|
[ApiResourceKind.api_resource_version, ResourceTier.cloud_only],
|
|
16
16
|
[ApiResourceKind.iam_policy, ResourceTier.enterprise],
|
|
17
|
-
[ApiResourceKind.identity_account, ResourceTier.
|
|
17
|
+
[ApiResourceKind.identity_account, ResourceTier.open_source],
|
|
18
18
|
[ApiResourceKind.api_key, ResourceTier.open_source],
|
|
19
19
|
[ApiResourceKind.invitation, ResourceTier.enterprise],
|
|
20
20
|
[ApiResourceKind.identity_provider, ResourceTier.enterprise],
|
package/src/index.ts
CHANGED
|
@@ -62,6 +62,16 @@ export {
|
|
|
62
62
|
isResourceAvailable,
|
|
63
63
|
} from "./resource-availability.js";
|
|
64
64
|
|
|
65
|
+
// The first-sign-in flow: resolve the caller's identity account, provisioning
|
|
66
|
+
// it on a first sign-in. One home for every surface (console gate, CLI,
|
|
67
|
+
// platform builders' own gates).
|
|
68
|
+
export {
|
|
69
|
+
ensureMyIdentityAccount,
|
|
70
|
+
type EnsuredIdentityAccount,
|
|
71
|
+
type EnsureMyIdentityAccountOptions,
|
|
72
|
+
type IdentityAccountLane,
|
|
73
|
+
} from "./ensure-identity-account.js";
|
|
74
|
+
|
|
65
75
|
// Authorization config and IAM role utilities
|
|
66
76
|
export {
|
|
67
77
|
getGrantableRoles,
|
|
@@ -127,10 +137,7 @@ export {
|
|
|
127
137
|
} from "./github.js";
|
|
128
138
|
|
|
129
139
|
// Platform client (server info / edition detection)
|
|
130
|
-
export {
|
|
131
|
-
PlatformClient,
|
|
132
|
-
type ServerInfo,
|
|
133
|
-
} from "./platform.js";
|
|
140
|
+
export { PlatformClient, type ServerInfo } from "./platform.js";
|
|
134
141
|
|
|
135
142
|
// Manifest engine (kind-agnostic YAML ⇄ proto ⇄ apply)
|
|
136
143
|
export {
|
|
@@ -201,7 +208,11 @@ export {
|
|
|
201
208
|
type AgentShareInput,
|
|
202
209
|
type AgentShareMessagesInput,
|
|
203
210
|
} from "./gen/agentshare.js";
|
|
204
|
-
export {
|
|
211
|
+
export {
|
|
212
|
+
ApiKeyClient,
|
|
213
|
+
toApiKeyUpdateInput,
|
|
214
|
+
type ApiKeyInput,
|
|
215
|
+
} from "./gen/apikey.js";
|
|
205
216
|
export {
|
|
206
217
|
ChannelAppClient,
|
|
207
218
|
toChannelAppUpdateInput,
|
|
@@ -227,10 +238,7 @@ export {
|
|
|
227
238
|
toIdentityAccountUpdateInput,
|
|
228
239
|
type IdentityAccountInput,
|
|
229
240
|
} from "./gen/identityaccount.js";
|
|
230
|
-
export {
|
|
231
|
-
InvitationClient,
|
|
232
|
-
type InvitationInput,
|
|
233
|
-
} from "./gen/invitation.js";
|
|
241
|
+
export { InvitationClient, type InvitationInput } from "./gen/invitation.js";
|
|
234
242
|
export {
|
|
235
243
|
IdentityProviderClient,
|
|
236
244
|
toIdentityProviderUpdateInput,
|
|
@@ -275,7 +283,11 @@ export {
|
|
|
275
283
|
toPlatformClientUpdateInput,
|
|
276
284
|
type PlatformClientInput,
|
|
277
285
|
} from "./gen/platformclient.js";
|
|
278
|
-
export {
|
|
286
|
+
export {
|
|
287
|
+
ProjectClient,
|
|
288
|
+
toProjectUpdateInput,
|
|
289
|
+
type ProjectInput,
|
|
290
|
+
} from "./gen/project.js";
|
|
279
291
|
export {
|
|
280
292
|
ScheduleClient,
|
|
281
293
|
buildScheduleProto,
|