@stigmer/server 3.14.1 → 3.15.1

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.
Files changed (129) hide show
  1. package/dist/boot/compose.d.ts +8 -1
  2. package/dist/boot/compose.d.ts.map +1 -1
  3. package/dist/boot/compose.js +121 -14
  4. package/dist/boot/compose.js.map +1 -1
  5. package/dist/boot/config.d.ts +14 -0
  6. package/dist/boot/config.d.ts.map +1 -1
  7. package/dist/boot/config.js +1 -0
  8. package/dist/boot/config.js.map +1 -1
  9. package/dist/domain/apikey/verifier.d.ts +8 -1
  10. package/dist/domain/apikey/verifier.d.ts.map +1 -1
  11. package/dist/domain/apikey/verifier.js +14 -2
  12. package/dist/domain/apikey/verifier.js.map +1 -1
  13. package/dist/domain/identityaccount/constants.d.ts +66 -0
  14. package/dist/domain/identityaccount/constants.d.ts.map +1 -0
  15. package/dist/domain/identityaccount/constants.js +153 -0
  16. package/dist/domain/identityaccount/constants.js.map +1 -0
  17. package/dist/domain/identityaccount/controller.d.ts +34 -0
  18. package/dist/domain/identityaccount/controller.d.ts.map +1 -0
  19. package/dist/domain/identityaccount/controller.js +342 -0
  20. package/dist/domain/identityaccount/controller.js.map +1 -0
  21. package/dist/domain/identityaccount/operator.d.ts +14 -0
  22. package/dist/domain/identityaccount/operator.d.ts.map +1 -0
  23. package/dist/domain/identityaccount/operator.js +67 -0
  24. package/dist/domain/identityaccount/operator.js.map +1 -0
  25. package/dist/domain/identityaccount/provisioning.d.ts +52 -0
  26. package/dist/domain/identityaccount/provisioning.d.ts.map +1 -0
  27. package/dist/domain/identityaccount/provisioning.js +114 -0
  28. package/dist/domain/identityaccount/provisioning.js.map +1 -0
  29. package/dist/domain/identityaccount/resolve.d.ts +36 -0
  30. package/dist/domain/identityaccount/resolve.d.ts.map +1 -0
  31. package/dist/domain/identityaccount/resolve.js +12 -0
  32. package/dist/domain/identityaccount/resolve.js.map +1 -0
  33. package/dist/domain/identityaccount/resource-store.d.ts +4 -0
  34. package/dist/domain/identityaccount/resource-store.d.ts.map +1 -0
  35. package/dist/domain/identityaccount/resource-store.js +131 -0
  36. package/dist/domain/identityaccount/resource-store.js.map +1 -0
  37. package/dist/domain/identityaccount/steps.d.ts +79 -0
  38. package/dist/domain/identityaccount/steps.d.ts.map +1 -0
  39. package/dist/domain/identityaccount/steps.js +291 -0
  40. package/dist/domain/identityaccount/steps.js.map +1 -0
  41. package/dist/domain/identityaccount/store-contract.d.ts +22 -0
  42. package/dist/domain/identityaccount/store-contract.d.ts.map +1 -0
  43. package/dist/domain/identityaccount/store-contract.js +307 -0
  44. package/dist/domain/identityaccount/store-contract.js.map +1 -0
  45. package/dist/domain/identityaccount/store.d.ts +66 -0
  46. package/dist/domain/identityaccount/store.d.ts.map +1 -0
  47. package/dist/domain/identityaccount/store.js +13 -0
  48. package/dist/domain/identityaccount/store.js.map +1 -0
  49. package/dist/extensions/drivers.d.ts +26 -0
  50. package/dist/extensions/drivers.d.ts.map +1 -1
  51. package/dist/extensions/gate-slots.d.ts +16 -1
  52. package/dist/extensions/gate-slots.d.ts.map +1 -1
  53. package/dist/extensions/gate-slots.js +1 -0
  54. package/dist/extensions/gate-slots.js.map +1 -1
  55. package/dist/extensions/identity-federation.d.ts +36 -0
  56. package/dist/extensions/identity-federation.d.ts.map +1 -0
  57. package/dist/extensions/identity-federation.js +2 -0
  58. package/dist/extensions/identity-federation.js.map +1 -0
  59. package/dist/extensions/registry.d.ts +18 -1
  60. package/dist/extensions/registry.d.ts.map +1 -1
  61. package/dist/extensions/registry.js +20 -0
  62. package/dist/extensions/registry.js.map +1 -1
  63. package/dist/identity/oidc-discovery.d.ts +36 -0
  64. package/dist/identity/oidc-discovery.d.ts.map +1 -0
  65. package/dist/identity/oidc-discovery.js +60 -0
  66. package/dist/identity/oidc-discovery.js.map +1 -0
  67. package/dist/identity/oidc-userinfo.d.ts +30 -0
  68. package/dist/identity/oidc-userinfo.d.ts.map +1 -0
  69. package/dist/identity/oidc-userinfo.js +28 -0
  70. package/dist/identity/oidc-userinfo.js.map +1 -0
  71. package/dist/identity/oidc-verifier.d.ts +6 -0
  72. package/dist/identity/oidc-verifier.d.ts.map +1 -1
  73. package/dist/identity/oidc-verifier.js +35 -34
  74. package/dist/identity/oidc-verifier.js.map +1 -1
  75. package/dist/index.d.ts +7 -0
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +3 -0
  78. package/dist/index.js.map +1 -1
  79. package/dist/pipeline/interceptors/auth.d.ts +10 -0
  80. package/dist/pipeline/interceptors/auth.d.ts.map +1 -1
  81. package/dist/pipeline/interceptors/auth.js +9 -1
  82. package/dist/pipeline/interceptors/auth.js.map +1 -1
  83. package/dist/transport/console/handler.d.ts +22 -5
  84. package/dist/transport/console/handler.d.ts.map +1 -1
  85. package/dist/transport/console/handler.js +53 -24
  86. package/dist/transport/console/handler.js.map +1 -1
  87. package/package.json +4 -4
  88. package/src/boot/__tests__/auth-enabled-composition.test.ts +274 -4
  89. package/src/boot/__tests__/config.test.ts +41 -3
  90. package/src/boot/compose.ts +148 -15
  91. package/src/boot/config.ts +15 -0
  92. package/src/domain/apikey/__tests__/verifier.test.ts +146 -22
  93. package/src/domain/apikey/verifier.ts +24 -2
  94. package/src/domain/identityaccount/__tests__/constants.test.ts +155 -0
  95. package/src/domain/identityaccount/__tests__/identityaccount.test.ts +484 -0
  96. package/src/domain/identityaccount/__tests__/operator.test.ts +180 -0
  97. package/src/domain/identityaccount/__tests__/provisioning.test.ts +281 -0
  98. package/src/domain/identityaccount/__tests__/resolve.test.ts +114 -0
  99. package/src/domain/identityaccount/__tests__/resource-store.test.ts +216 -0
  100. package/src/domain/identityaccount/__tests__/support.ts +58 -0
  101. package/src/domain/identityaccount/constants.ts +178 -0
  102. package/src/domain/identityaccount/controller.ts +667 -0
  103. package/src/domain/identityaccount/operator.ts +94 -0
  104. package/src/domain/identityaccount/provisioning.ts +182 -0
  105. package/src/domain/identityaccount/resolve.ts +52 -0
  106. package/src/domain/identityaccount/resource-store.ts +157 -0
  107. package/src/domain/identityaccount/steps.ts +377 -0
  108. package/src/domain/identityaccount/store-contract.ts +471 -0
  109. package/src/domain/identityaccount/store.ts +70 -0
  110. package/src/extensions/__tests__/identity-account-composed.test.ts +803 -0
  111. package/src/extensions/__tests__/identity-account-points.test.ts +129 -0
  112. package/src/extensions/__tests__/registry.test.ts +4 -0
  113. package/src/extensions/__tests__/tier-truthfulness.test.ts +299 -0
  114. package/src/extensions/drivers.ts +26 -0
  115. package/src/extensions/gate-slots.ts +16 -0
  116. package/src/extensions/identity-federation.ts +58 -0
  117. package/src/extensions/registry.ts +44 -1
  118. package/src/identity/__tests__/oidc-discovery.test.ts +122 -0
  119. package/src/identity/__tests__/oidc-userinfo.test.ts +103 -0
  120. package/src/identity/__tests__/oidc-verifier.test.ts +173 -3
  121. package/src/identity/oidc-discovery.ts +84 -0
  122. package/src/identity/oidc-userinfo.ts +64 -0
  123. package/src/identity/oidc-verifier.ts +42 -45
  124. package/src/index.ts +19 -0
  125. package/src/pipeline/interceptors/auth.ts +13 -1
  126. package/src/pipeline/steps/__tests__/authorize-annotation-completeness.test.ts +184 -0
  127. package/src/transport/console/__tests__/handler.test.ts +93 -23
  128. package/src/transport/console/__tests__/resolver.test.ts +6 -0
  129. package/src/transport/console/handler.ts +84 -30
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Identity-account domain constants (20260911.11, T01_1_review.md A1, A2,
3
+ * A7): the derived account id, the one function that turns a caller into
4
+ * an issuer subject, and the byte-pinned wire copy.
5
+ *
6
+ * The derived id (A1). A direct account's id is a pure function of its
7
+ * subject: `ida_` + the top 130 bits of sha256(idp_id) as 26 lowercase
8
+ * Crockford-base32 characters. The shape is indistinguishable from a
9
+ * minted `{prefix}_{ulid}`, so nothing downstream learns a second id
10
+ * grammar, and the PRIMARY KEY becomes the one home of "one account per
11
+ * subject": the generic store has no secondary uniqueness and its save is
12
+ * an upsert (`store/sqlite/store.ts`), so a lookup-then-insert on a scan
13
+ * could never close the first-login race. Two replicas deriving the same
14
+ * id converge by primary key with no migration and no second copy of any
15
+ * field. The hash is one-way, so an issuer subject never leaks into the
16
+ * `created_by.id` stamps that ride on every resource. The golden vectors in
17
+ * __tests__/constants.test.ts are wire-adjacent contract: a change here
18
+ * re-addresses every direct account open source ever created.
19
+ *
20
+ * `idpIdOf` (A2) is the ONE place a CallerIdentity becomes a subject. An
21
+ * issuer-vouched token is read for its `sub` (already verified at
22
+ * position 1, so this is a read of trusted state, never a verification);
23
+ * a caller with no issuer and no token is the trusted-local operator,
24
+ * whose subject is `local|<identityId>`. It deliberately knows nothing
25
+ * about API keys: every verifier resolves its stamp to the account when
26
+ * one exists (A6), so a credential's shape is the verifier's business.
27
+ *
28
+ * The copy moved from the cloud's iam/account/handlers.ts as-is: the CLI,
29
+ * console and SDK show these sentences verbatim, so they are contract.
30
+ */
31
+ import { createHash } from "node:crypto";
32
+ /** The kind's id prefix (kind_meta `identity_account.id_prefix`). */
33
+ export const ACCOUNT_ID_PREFIX = "ida";
34
+ /** Crockford base32, lowercased — the alphabet every minted ULID id uses. */
35
+ const CROCKFORD_ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz";
36
+ const DERIVED_ID_CHARS = 26;
37
+ const DERIVED_ID_BITS = BigInt(DERIVED_ID_CHARS * 5);
38
+ const SHA256_BITS = 256n;
39
+ /**
40
+ * The derived account id of a direct account with subject `idpId`. Pure,
41
+ * total over non-empty input; an empty subject has no principal and so
42
+ * no address — refused, never hashed.
43
+ */
44
+ export function accountIdFor(idpId) {
45
+ if (idpId === "") {
46
+ throw new Error("idp_id must not be empty");
47
+ }
48
+ const digest = createHash("sha256").update(idpId, "utf8").digest();
49
+ let bits = 0n;
50
+ for (const byte of digest) {
51
+ bits = (bits << 8n) | BigInt(byte);
52
+ }
53
+ let top = bits >> (SHA256_BITS - DERIVED_ID_BITS);
54
+ let encoded = "";
55
+ for (let i = 0; i < DERIVED_ID_CHARS; i++) {
56
+ encoded = CROCKFORD_ALPHABET[Number(top & 31n)] + encoded;
57
+ top >>= 5n;
58
+ }
59
+ return `${ACCOUNT_ID_PREFIX}_${encoded}`;
60
+ }
61
+ /**
62
+ * The subject namespace of the trusted-local posture. An OIDC subject is
63
+ * `<connection>|<id>` by Auth0 convention; `local|` claims the same shape
64
+ * for the one principal no issuer vouches for, so the derived ids of a
65
+ * local operator and an OIDC user can never collide by construction.
66
+ */
67
+ export const LOCAL_IDP_ID_PREFIX = "local|";
68
+ /** `local|<identityId>` — the trusted-local operator's subject. */
69
+ export function localIdpIdFor(identityId) {
70
+ return `${LOCAL_IDP_ID_PREFIX}${identityId}`;
71
+ }
72
+ /**
73
+ * The issuer subject a caller stands for:
74
+ * - a caller with no issuer and no token is the trusted-local operator
75
+ * (`local|<identityId>`; identityId is the operator's email or
76
+ * "system" — pipeline/interceptors/auth.ts trustedLocalIdentity);
77
+ * - a token-bearing caller is its JWT `sub`, read from the raw token
78
+ * the verifier already proved; `""` when the token carries no
79
+ * readable subject (an opaque credential under an issuer), which
80
+ * the provisionMyAccount handler maps to the UNAUTHENTICATED arm.
81
+ */
82
+ export function idpIdOf(caller) {
83
+ if (caller.issuer === "" && caller.rawToken === "") {
84
+ return localIdpIdFor(caller.identityId);
85
+ }
86
+ return jwtSubjectOf(caller.rawToken);
87
+ }
88
+ /**
89
+ * The cloud's jwtSubjectOf verbatim: the payload segment decoded, `sub`
90
+ * when it is a string. Not a verification — the chain's position 1 did
91
+ * that; this only reads a claim from trusted state.
92
+ */
93
+ function jwtSubjectOf(rawToken) {
94
+ const segments = rawToken.split(".");
95
+ if (segments.length !== 3) {
96
+ return "";
97
+ }
98
+ try {
99
+ const payload = JSON.parse(Buffer.from(segments[1] ?? "", "base64url").toString("utf8"));
100
+ return typeof payload.sub === "string" ? payload.sub : "";
101
+ }
102
+ catch {
103
+ return "";
104
+ }
105
+ }
106
+ /**
107
+ * Auth0's client-credentials subject shape (`<client_id>@clients`) — the
108
+ * cloud's IsMachineAccountVerifier rule, the one input to
109
+ * `is_machine_account`.
110
+ */
111
+ export const MACHINE_ACCOUNT_SUFFIX = "@clients";
112
+ export function isMachineSubject(idpId) {
113
+ return idpId.endsWith(MACHINE_ACCOUNT_SUFFIX);
114
+ }
115
+ // ---------------------------------------------------------------------------
116
+ // Byte-pinned copy (the cloud handlers' sentences, moved as-is).
117
+ // ---------------------------------------------------------------------------
118
+ /** whoAmI for a caller with no account (NOT_FOUND). */
119
+ export const ACCOUNT_NOT_FOUND_FOR_CALLER_MESSAGE = "Identity account not found for the authenticated user";
120
+ /** provisionMyAccount for a caller whose credential names no subject (UNAUTHENTICATED). */
121
+ export const NO_IDP_ID_MESSAGE = "Cannot provision account: no IDP ID in authentication context";
122
+ /** provisionMyAccount when the issuer's userinfo cannot be read (UNAVAILABLE); the cause follows. */
123
+ export const USERINFO_UNAVAILABLE_PREFIX = "Failed to fetch user profile from identity provider: ";
124
+ /** get / getByEmail / getByIdpId / getActorInfo / update / delete on a missing account (NOT_FOUND). */
125
+ export function accountNotFoundMessage(handle) {
126
+ return `Identity account not found: ${handle}`;
127
+ }
128
+ /**
129
+ * The cloud#393 gate's refusal (PERMISSION_DENIED): the create RPC admits
130
+ * the platform's own pipelines only — machine-class callers and
131
+ * server-composed (in-process) requests (T01_1_review.md A7).
132
+ */
133
+ export const CREATE_IS_INTERNAL_MESSAGE = "this RPC is internal to the platform";
134
+ /**
135
+ * The reason a composition with no IdentityFederation unit refuses the four
136
+ * federation RPCs (UNIMPLEMENTED). The sentence a person can act on; the
137
+ * method-naming prefix is the organization directory's absent-method shape
138
+ * so clients matching on "is not implemented" keep working.
139
+ */
140
+ export const FEDERATION_UNIMPLEMENTED_REASON = "federated identity accounts are served by the Enterprise and Cloud editions";
141
+ export function federationUnimplementedMessage(method) {
142
+ return `${method} is not implemented: ${FEDERATION_UNIMPLEMENTED_REASON}`;
143
+ }
144
+ /**
145
+ * update with a changed spec.idp_id (FAILED_PRECONDITION; the schedule
146
+ * domain's immutability shape, T01_1_review.md A1). The subject IS the
147
+ * identity; a client that sends a different one has a bug it should hear
148
+ * about, never a silent preserve.
149
+ */
150
+ export function idpIdImmutableMessage(existingIdpId) {
151
+ return `spec.idp_id is immutable (account subject is '${existingIdpId}') — create a new account for a different subject`;
152
+ }
153
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/domain/identityaccount/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,qEAAqE;AACrE,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEvC,6EAA6E;AAC7E,MAAM,kBAAkB,GAAG,kCAAkC,CAAC;AAC9D,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,eAAe,GAAG,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;AACrD,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IACnE,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,eAAe,CAAC,CAAC;IAClD,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CA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IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAEjD,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC;AAChD,CAAC;AAED,8EAA8E;AAC9E,iEAAiE;AACjE,8EAA8E;AAE9E,uDAAuD;AACvD,MAAM,CAAC,MAAM,oCAAoC,GAC/C,uDAAuD,CAAC;AAE1D,2FAA2F;AAC3F,MAAM,CAAC,MAAM,iBAAiB,GAC5B,+DAA+D,CAAC;AAElE,qGAAqG;AACrG,MAAM,CAAC,MAAM,2BAA2B,GACtC,uDAAuD,CAAC;AAE1D,uGAAuG;AACvG,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,OAAO,+BAA+B,MAAM,EAAE,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC,sCAAsC,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAC1C,6EAA6E,CAAC;AAEhF,MAAM,UAAU,8BAA8B,CAAC,MAAc;IAC3D,OAAO,GAAG,MAAM,wBAAwB,+BAA+B,EAAE,CAAC;AAC5E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAqB;IACzD,OAAO,iDAAiD,aAAa,mDAAmD,CAAC;AAC3H,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { ConnectRouter } from "@connectrpc/connect";
2
+ import type { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
3
+ import type { Logger } from "../../boot/logger.js";
4
+ import type { Authorizer } from "../../extensions/authorizer.js";
5
+ import type { ResolvedGateSteps } from "../../extensions/gate-slots.js";
6
+ import type { IdentityFederation } from "../../extensions/identity-federation.js";
7
+ import type { ResourceAuthorizationLifecycle } from "../../extensions/resource-authorization.js";
8
+ import type { CreateAccount, DirectAccountProvisioner } from "./provisioning.js";
9
+ import type { IdentityAccountStore } from "./store.js";
10
+ /** What the create path needs — the subset every caller of it composes. */
11
+ export interface CreateAccountPathDeps {
12
+ readonly accounts: IdentityAccountStore;
13
+ readonly logger: Logger;
14
+ /** The composed authorization seam — the Authorize step at position 1 of every chain calls it (DD-007 §3). */
15
+ readonly authorizer: Authorizer;
16
+ /** The composed tuple-lifecycle driver — undefined = the shared steps no-op. */
17
+ readonly authorizationLifecycle: ResourceAuthorizationLifecycle | undefined;
18
+ }
19
+ export interface IdentityAccountControllerDeps extends CreateAccountPathDeps {
20
+ readonly provisioner: DirectAccountProvisioner;
21
+ /** The composed federation capability — undefined = the four RPCs refuse UNIMPLEMENTED. */
22
+ readonly federation: IdentityFederation | undefined;
23
+ /** The composed slot registrations — this domain's provision slot (Q-IA-9, A10). */
24
+ readonly gateSteps: ResolvedGateSteps;
25
+ }
26
+ /** Registers both identityaccount services on the router (routes stage). */
27
+ export declare function registerIdentityAccountServices(router: ConnectRouter, deps: IdentityAccountControllerDeps): void;
28
+ /**
29
+ * The create path as its in-process callers see it (provisioning.ts
30
+ * `CreateAccount`): the input becomes the resource envelope the chain
31
+ * expects, tagged with the kind this controller serves.
32
+ */
33
+ export declare function newCreateAccountPath(deps: CreateAccountPathDeps, kind: ApiResourceKind): CreateAccount;
34
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/domain/identityaccount/controller.ts"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,qBAAqB,CAAC;AAKzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAc3H,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AA8BjG,OAAO,KAAK,EACV,aAAa,EAEb,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAiB3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,2EAA2E;AAC3E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,8GAA8G;IAC9G,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,gFAAgF;IAChF,QAAQ,CAAC,sBAAsB,EAAE,8BAA8B,GAAG,SAAS,CAAC;CAC7E;AAED,MAAM,WAAW,6BAA8B,SAAQ,qBAAqB;IAC1E,QAAQ,CAAC,WAAW,EAAE,wBAAwB,CAAC;IAC/C,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACpD,oFAAoF;IACpF,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;CACvC;AAED,4EAA4E;AAC5E,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,6BAA6B,GAClC,IAAI,CAkDN;AA0DD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,qBAAqB,EAC3B,IAAI,EAAE,eAAe,GACpB,aAAa,CAaf"}
@@ -0,0 +1,342 @@
1
+ /**
2
+ * IdentityAccount controller (20260911.11) — the identity-account domain
3
+ * served ONCE by @stigmer/server in every edition (the editions program's
4
+ * tier truth: `identity_account` is open-source tier). The behavioural
5
+ * reference is the cloud's iam/account/handlers.ts, whose twelve direct
6
+ * handlers retire against this module; the byte-pinned copy moved with it
7
+ * (constants.ts). The cloud keeps only what differs per edition — its row
8
+ * store as `drivers.identityAccountStore`, the federated arms as
9
+ * `drivers.identityFederation`, the personal organization as a gate on
10
+ * `identity-account-provision:post-persist`.
11
+ *
12
+ * Persistence is the IdentityAccountStore PORT, never the generic Store
13
+ * (steps.ts explains); the storage-free shared steps are reused as they
14
+ * are, so every chain reads onto the inventory unchanged.
15
+ *
16
+ * The ONE create path (`newCreateAccountPath`): the create RPC, the
17
+ * provisioner and the trusted-local operator ensure all run the same
18
+ * chain — DeriveAccountId, CheckDuplicate by subject, BuildNewState,
19
+ * AssignBackendFields, Persist through the port, CreateAuthorizationTuples
20
+ * (the lifecycle driver's SELF arm gives the account its self-owner grant
21
+ * in the cloud) — so no account exists that skipped a step. The create
22
+ * RPC is the cloud#393 gate in front of that path (T01_1_review.md A7):
23
+ * machine / internal / in-process callers only, in every edition. The
24
+ * gate is the RPC's admission rule and deliberately NOT a step in the
25
+ * path, because the provisioner runs the path as the idp-shaped wire user
26
+ * (the account is created by the subject it is for) and the operator
27
+ * ensure runs it as the trusted-local user.
28
+ *
29
+ * Direct handlers (no pipeline): whoAmI (the cloud's two primary-key
30
+ * reads through idpIdOf; NOT_FOUND for the unprovisioned), getByEmail and
31
+ * getByIdpId (lookup FIRST, then authorizeDirect on the FOUND id — the
32
+ * cloud's order; the annotation's `field_path = "value"` would otherwise
33
+ * hand the Authorizer an email as a resource id), getActorInfo, and
34
+ * provisionMyAccount (the provisioner, then the composed post-persist
35
+ * gates; UNAUTHENTICATED with the cloud's copy for a credential naming no
36
+ * subject; UNAVAILABLE with the cloud's copy when userinfo fails).
37
+ *
38
+ * The four federation RPCs refuse UNIMPLEMENTED with the edition reason
39
+ * when no unit composes the capability (never INTERNAL; the organization
40
+ * directory's absent-method shape); present, the controller owns the
41
+ * shared precondition (authorize on the org, ref-with-slug, org match,
42
+ * IdP exists) and dispatches to the arm with the resolved ref.
43
+ *
44
+ * Proven by __tests__/identityaccount.test.ts (the composed trusted-local
45
+ * server), boot/__tests__/auth-enabled-composition.test.ts (the OIDC
46
+ * posture end to end) and identityaccount.conformance.test.ts.
47
+ */
48
+ import { Code, ConnectError } from "@connectrpc/connect";
49
+ import { create } from "@bufbuild/protobuf";
50
+ import { ApiResourceAuditActorSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/status_pb";
51
+ import { IdentityAccountSchema } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
52
+ import { IdentityAccountCommandController } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/command_pb";
53
+ import { IdentityAccountQueryController } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/query_pb";
54
+ import { stepsForSlot } from "../../extensions/gate-slots.js";
55
+ import { internalError, invalidArgumentError } from "../../pipeline/errors.js";
56
+ import { apiResourceKindKey } from "../../pipeline/interceptors/apiresource.js";
57
+ import { callerIdentityOf } from "../../pipeline/interceptors/auth.js";
58
+ import { newPipeline } from "../../pipeline/pipeline.js";
59
+ import { RequestContext } from "../../pipeline/request-context.js";
60
+ import { newCleanupIamPoliciesStep, newCreateAuthorizationTuplesStep, } from "../../pipeline/steps/authorization-tuples.js";
61
+ import { authorizeDirect, newAuthorizeStep, } from "../../pipeline/steps/authorize.js";
62
+ import { newBuildUpdateStateStep } from "../../pipeline/steps/build-update-state.js";
63
+ import { newBuildNewStateStep } from "../../pipeline/steps/defaults.js";
64
+ import { newExtractResourceIdStep } from "../../pipeline/steps/delete.js";
65
+ import { newGuardReservedLabelsStep } from "../../pipeline/steps/guard-reserved-labels.js";
66
+ import { EXISTING_RESOURCE_KEY } from "../../pipeline/steps/load-existing.js";
67
+ import { TARGET_RESOURCE_KEY } from "../../pipeline/steps/load-target.js";
68
+ import { newResolveSlugStep } from "../../pipeline/steps/slug.js";
69
+ import { newValidateProtoStep } from "../../pipeline/steps/validation.js";
70
+ import { ACCOUNT_NOT_FOUND_FOR_CALLER_MESSAGE, CREATE_IS_INTERNAL_MESSAGE, NO_IDP_ID_MESSAGE, USERINFO_UNAVAILABLE_PREFIX, federationUnimplementedMessage, idpIdOf, } from "./constants.js";
71
+ import { UserInfoFetchError } from "./provisioning.js";
72
+ import { accountNotFoundError, newAssignBackendFieldsStep, newCheckDuplicateStep, newDefaultAccountNameStep, newDeleteAccountStep, newDeriveAccountIdStep, newGuardImmutableSubjectStep, newLoadExistingAccountForDeleteStep, newLoadExistingAccountStep, newLoadTargetAccountStep, newPersistNewAccountStep, newPersistUpdatedAccountStep, newPreserveBackendFieldsStep, } from "./steps.js";
73
+ /** Registers both identityaccount services on the router (routes stage). */
74
+ export function registerIdentityAccountServices(router, deps) {
75
+ router.service(IdentityAccountCommandController, {
76
+ create: (account, ctx) => createRpc(deps, account, ctx),
77
+ update: (account, ctx) => update(deps, account, ctx),
78
+ delete: (id, ctx) => deleteAccount(deps, id, ctx),
79
+ createFederatedAccount: (input, ctx) => federated(deps, ctx, IdentityAccountCommandController.method.createFederatedAccount, input, (federation, ref, caller) => federation.createFederatedAccount(input, ref, caller)),
80
+ updateFederatedAccount: (input, ctx) => federated(deps, ctx, IdentityAccountCommandController.method.updateFederatedAccount, input, (federation, ref, caller) => federation.updateFederatedAccount(input, ref, caller)),
81
+ deprovisionFederatedAccount: (input, ctx) => federated(deps, ctx, IdentityAccountCommandController.method.deprovisionFederatedAccount, input, (federation, ref, caller) => federation.deprovisionFederatedAccount(input, ref, caller)),
82
+ provisionMyAccount: (empty, ctx) => provisionMyAccount(deps, empty, ctx),
83
+ });
84
+ router.service(IdentityAccountQueryController, {
85
+ get: (id, ctx) => get(deps, id, ctx),
86
+ whoAmI: (empty, ctx) => whoAmI(deps, empty, ctx),
87
+ getByEmail: (email, ctx) => getByEmail(deps, email, ctx),
88
+ getByIdpId: (idpId, ctx) => getByIdpId(deps, idpId, ctx),
89
+ getByExternalSub: (lookup, ctx) => federated(deps, ctx, IdentityAccountQueryController.method.getByExternalSub, lookup, (federation, ref, caller) => federation.getByExternalSub(lookup, ref, caller)),
90
+ getActorInfo: (id, ctx) => getActorInfo(deps, id, ctx),
91
+ });
92
+ }
93
+ function kindOf(ctx) {
94
+ return ctx.values.get(apiResourceKindKey);
95
+ }
96
+ // ---------------------------------------------------------------------------
97
+ // The one create path
98
+ // ---------------------------------------------------------------------------
99
+ /**
100
+ * Runs the create chain AS `caller` and answers the persisted account.
101
+ * `kind` is the service's kind tag for wire calls; the path callers with
102
+ * no HandlerContext (the provisioner, the operator ensure) pass the kind
103
+ * the controller serves.
104
+ */
105
+ async function runCreateChain(deps, account, caller, kind) {
106
+ const reqCtx = new RequestContext(IdentityAccountSchema, account, caller, kind);
107
+ await newPipeline("identityaccount-create", deps.logger)
108
+ .addStep(newAuthorizeStep(IdentityAccountCommandController.method.create, deps.authorizer))
109
+ .addStep(newValidateProtoStep())
110
+ .addStep(newDefaultAccountNameStep())
111
+ .addStep(newResolveSlugStep())
112
+ .addStep(newDeriveAccountIdStep())
113
+ .addStep(newCheckDuplicateStep(deps.accounts))
114
+ .addStep(newBuildNewStateStep())
115
+ .addStep(newGuardReservedLabelsStep(deps.authorizer))
116
+ .addStep(newAssignBackendFieldsStep())
117
+ .addStep(newPersistNewAccountStep(deps.accounts))
118
+ .addStep(newCreateAuthorizationTuplesStep(deps.authorizationLifecycle, deps.logger))
119
+ .build()
120
+ .execute(reqCtx);
121
+ return reqCtx.newState;
122
+ }
123
+ /**
124
+ * The create path as its in-process callers see it (provisioning.ts
125
+ * `CreateAccount`): the input becomes the resource envelope the chain
126
+ * expects, tagged with the kind this controller serves.
127
+ */
128
+ export function newCreateAccountPath(deps, kind) {
129
+ return (input, caller) => runCreateChain(deps, create(IdentityAccountSchema, {
130
+ apiVersion: "iam.stigmer.ai/v1",
131
+ kind: "IdentityAccount",
132
+ metadata: { name: input.name },
133
+ spec: input.spec,
134
+ }), caller, kind);
135
+ }
136
+ /**
137
+ * The create RPC: the cloud#393 gate, then the path AS the caller. FGA
138
+ * cannot gate this RPC (the account being created IS the principal — the
139
+ * bootstrap problem), so the gate is caller class: the platform's own
140
+ * pipelines only.
141
+ */
142
+ function createRpc(deps, account, ctx) {
143
+ const caller = callerIdentityOf(ctx);
144
+ guardInternalRpc(caller);
145
+ return runCreateChain(deps, account, caller, kindOf(ctx));
146
+ }
147
+ function guardInternalRpc(caller) {
148
+ if (caller.callerClass === "machine" ||
149
+ caller.callerClass === "internal" ||
150
+ caller.origin === "in-process") {
151
+ return;
152
+ }
153
+ throw new ConnectError(CREATE_IS_INTERNAL_MESSAGE, Code.PermissionDenied);
154
+ }
155
+ // ---------------------------------------------------------------------------
156
+ // Update / Delete
157
+ // ---------------------------------------------------------------------------
158
+ /**
159
+ * Update: full-envelope replace with the cloud's writable surface (A9) —
160
+ * BuildUpdateState preserves id/slug/org/visibility, GuardImmutableSubject
161
+ * refuses a changed subject, AssignBackendFields preserves the rest of
162
+ * what the backend owns from the existing row.
163
+ */
164
+ async function update(deps, account, ctx) {
165
+ const reqCtx = new RequestContext(IdentityAccountSchema, account, callerIdentityOf(ctx), kindOf(ctx));
166
+ await newPipeline("identityaccount-update", deps.logger)
167
+ .addStep(newAuthorizeStep(IdentityAccountCommandController.method.update, deps.authorizer))
168
+ .addStep(newValidateProtoStep())
169
+ .addStep(newLoadExistingAccountStep(deps.accounts))
170
+ .addStep(newGuardImmutableSubjectStep())
171
+ .addStep(newBuildUpdateStateStep())
172
+ .addStep(newPreserveBackendFieldsStep())
173
+ .addStep(newPersistUpdatedAccountStep(deps.accounts))
174
+ .build()
175
+ .execute(reqCtx);
176
+ return reqCtx.newState;
177
+ }
178
+ /** Delete — answers the pre-delete account (the canonical delete chain over the port). */
179
+ async function deleteAccount(deps, id, ctx) {
180
+ const reqCtx = new RequestContext(IdentityAccountCommandController.method.delete.input, id, callerIdentityOf(ctx), kindOf(ctx));
181
+ await newPipeline("identityaccount-delete", deps.logger)
182
+ .addStep(newAuthorizeStep(IdentityAccountCommandController.method.delete, deps.authorizer))
183
+ .addStep(newValidateProtoStep())
184
+ .addStep(newExtractResourceIdStep())
185
+ .addStep(newLoadExistingAccountForDeleteStep(deps.accounts))
186
+ .addStep(newDeleteAccountStep(deps.accounts))
187
+ .addStep(newCleanupIamPoliciesStep(deps.authorizationLifecycle, deps.logger))
188
+ .build()
189
+ .execute(reqCtx);
190
+ const deleted = reqCtx.get(EXISTING_RESOURCE_KEY);
191
+ if (deleted === undefined) {
192
+ throw internalError(new Error("delete pipeline completed without a loaded resource"), "deleted identity account not found in context");
193
+ }
194
+ return deleted;
195
+ }
196
+ // ---------------------------------------------------------------------------
197
+ // Reads
198
+ // ---------------------------------------------------------------------------
199
+ /** Get — LoadTarget by id through the port; the domain's NOT_FOUND copy. */
200
+ async function get(deps, id, ctx) {
201
+ return loadTarget(deps, IdentityAccountQueryController.method.get, id, ctx);
202
+ }
203
+ /** getActorInfo — the contract-shaped actor: id, avatar, "First Last", email. */
204
+ async function getActorInfo(deps, id, ctx) {
205
+ const account = await loadTarget(deps, IdentityAccountQueryController.method.getActorInfo, id, ctx);
206
+ const firstName = account.spec?.firstName ?? "";
207
+ const lastName = account.spec?.lastName ?? "";
208
+ return create(ApiResourceAuditActorSchema, {
209
+ id: account.metadata?.id ?? "",
210
+ avatar: account.spec?.pictureUrl ?? "",
211
+ displayName: `${firstName} ${lastName}`.trim(),
212
+ email: account.spec?.email ?? "",
213
+ });
214
+ }
215
+ async function loadTarget(deps, method, id, ctx) {
216
+ const reqCtx = new RequestContext(method.input, id, callerIdentityOf(ctx), kindOf(ctx));
217
+ await newPipeline(`identityaccount-${method.localName}`, deps.logger)
218
+ .addStep(newAuthorizeStep(method, deps.authorizer))
219
+ .addStep(newValidateProtoStep())
220
+ .addStep(newLoadTargetAccountStep(deps.accounts))
221
+ .build()
222
+ .execute(reqCtx);
223
+ return reqCtx.get(TARGET_RESOURCE_KEY);
224
+ }
225
+ /**
226
+ * whoAmI — the cloud's lookup verbatim: by the resolved identity, then by
227
+ * the derived id of the caller's subject for a caller whose identity is
228
+ * still idp-shaped (an unprovisioned OIDC subject), then NOT_FOUND with
229
+ * the cloud's copy. Two primary-key reads at most; no scan.
230
+ */
231
+ async function whoAmI(deps, _empty, ctx) {
232
+ const caller = callerIdentityOf(ctx);
233
+ let account = await read(() => deps.accounts.findById(caller.identityId), "failed to load identity account");
234
+ if (account === undefined) {
235
+ account = await read(() => deps.accounts.findDirectByIdpId(idpIdOf(caller)), "failed to load identity account");
236
+ }
237
+ if (account === undefined) {
238
+ throw new ConnectError(ACCOUNT_NOT_FOUND_FOR_CALLER_MESSAGE, Code.NotFound);
239
+ }
240
+ return account;
241
+ }
242
+ /** getByEmail — direct accounts only; lookup first, authorize on the FOUND id. */
243
+ async function getByEmail(deps, email, ctx) {
244
+ return lookupThenAuthorize(deps, IdentityAccountQueryController.method.getByEmail, email, ctx, () => deps.accounts.findDirectByEmail(email.value), email.value);
245
+ }
246
+ /** getByIdpId — any provisioning mode; lookup first, authorize on the FOUND id. */
247
+ async function getByIdpId(deps, idpId, ctx) {
248
+ return lookupThenAuthorize(deps, IdentityAccountQueryController.method.getByIdpId, idpId, ctx, () => deps.accounts.findByIdpId(idpId.value), idpId.value);
249
+ }
250
+ async function lookupThenAuthorize(deps, method, input, ctx, lookup, handle) {
251
+ const account = await read(lookup, "failed to look up identity account");
252
+ if (account === undefined) {
253
+ throw accountNotFoundError(handle);
254
+ }
255
+ await authorizeDirect(method, deps.authorizer, callerIdentityOf(ctx), input, {
256
+ resourceId: account.metadata?.id ?? "",
257
+ });
258
+ return account;
259
+ }
260
+ // ---------------------------------------------------------------------------
261
+ // Provisioning
262
+ // ---------------------------------------------------------------------------
263
+ /**
264
+ * provisionMyAccount — the subject from the caller's credential, the
265
+ * provisioner's flow, then the composed post-persist gates (the cloud's
266
+ * personal organization) with the caller RE-STAMPED as the account: the
267
+ * position-1 identity was idp-shaped because no row existed when the
268
+ * verifier ran, and a gate that attributes ownership must name the
269
+ * account, never a principal no later request carries. The gates run on
270
+ * EVERY call, the idempotent early return included — the cloud's step
271
+ * backfills accounts that predate personal organizations there, which is
272
+ * why Q-IA-9 chose a slot over onResourceCreated. Non-transactional in
273
+ * the `org-create:post-persist` sense: a gate failure fails the request,
274
+ * the row survives, the next call heals it.
275
+ */
276
+ async function provisionMyAccount(deps, _empty, ctx) {
277
+ const caller = callerIdentityOf(ctx);
278
+ const idpId = idpIdOf(caller);
279
+ if (idpId === "") {
280
+ throw new ConnectError(NO_IDP_ID_MESSAGE, Code.Unauthenticated);
281
+ }
282
+ let account;
283
+ try {
284
+ account = await deps.provisioner.provisionDirectAccount(idpId, caller);
285
+ }
286
+ catch (error) {
287
+ if (error instanceof UserInfoFetchError) {
288
+ throw new ConnectError(`${USERINFO_UNAVAILABLE_PREFIX}${error.message}`, Code.Unavailable);
289
+ }
290
+ throw error;
291
+ }
292
+ // The ratified provision slot (Q-IA-9; the gate-slots.ts header carries
293
+ // its semantics). Empty in OSS — no pipeline is built for zero steps.
294
+ const gates = stepsForSlot(deps.gateSteps, "identity-account-provision:post-persist");
295
+ if (gates.length > 0) {
296
+ const asAccount = {
297
+ ...caller,
298
+ identityId: account.metadata?.id ?? "",
299
+ };
300
+ const reqCtx = new RequestContext(IdentityAccountSchema, account, asAccount, kindOf(ctx));
301
+ const pipeline = newPipeline("identityaccount-provision-post-persist", deps.logger);
302
+ for (const step of gates) {
303
+ pipeline.addStep(step);
304
+ }
305
+ await pipeline.build().execute(reqCtx);
306
+ }
307
+ return account;
308
+ }
309
+ async function federated(deps, ctx, method, input, arm) {
310
+ const federation = deps.federation;
311
+ if (federation === undefined) {
312
+ throw new ConnectError(federationUnimplementedMessage(`${method.parent.typeName}.${method.localName}`), Code.Unimplemented);
313
+ }
314
+ const caller = callerIdentityOf(ctx);
315
+ const org = input.org;
316
+ const ref = input.identityProviderRef;
317
+ if (ref === undefined || ref.slug === "") {
318
+ throw invalidArgumentError("identity_provider_ref with a valid slug is required");
319
+ }
320
+ if (ref.org !== "" && ref.org !== org) {
321
+ throw invalidArgumentError(`identity_provider_ref.org '${ref.org}' does not match input org '${org}'`);
322
+ }
323
+ // The annotation's target is the org (`field_path = "org"`); resolved
324
+ // from the input exactly as the pipeline step would.
325
+ await authorizeDirect(method, deps.authorizer, caller, input);
326
+ const refOrg = ref.org !== "" ? ref.org : org;
327
+ if (!(await federation.providerExists(refOrg, ref.slug))) {
328
+ throw new ConnectError(`IdentityProvider '${refOrg}/${ref.slug}' not found`, Code.NotFound);
329
+ }
330
+ ref.org = refOrg;
331
+ return arm(federation, ref, caller);
332
+ }
333
+ /** A direct handler's store read: a fault is INTERNAL with a static message, never "not found". */
334
+ async function read(operation, message) {
335
+ try {
336
+ return await operation();
337
+ }
338
+ catch (error) {
339
+ throw internalError(error, message);
340
+ }
341
+ }
342
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/domain/identityaccount/controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAK5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,0DAA0D,CAAC;AAGvG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0DAA0D,CAAC;AACjG,OAAO,EAAE,gCAAgC,EAAE,MAAM,8DAA8D,CAAC;AAMhH,OAAO,EAAE,8BAA8B,EAAE,MAAM,4DAA4D,CAAC;AAI5G,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAK9D,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;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1,14 @@
1
+ import type { IdentityAccount } from "@stigmer/protos/ai/stigmer/iam/identityaccount/v1/api_pb";
2
+ import type { CreateAccount } from "./provisioning.js";
3
+ import type { IdentityAccountStore } from "./store.js";
4
+ /** The operator as boot/config.ts loads it; empty email = the "system" placeholder. */
5
+ export interface OperatorIdentity {
6
+ readonly email: string;
7
+ readonly displayName: string;
8
+ }
9
+ export interface OperatorAccountDeps {
10
+ readonly accounts: IdentityAccountStore;
11
+ readonly createAccount: CreateAccount;
12
+ }
13
+ export declare function ensureOperatorAccount(deps: OperatorAccountDeps, operator: OperatorIdentity): Promise<IdentityAccount>;
14
+ //# sourceMappingURL=operator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../../src/domain/identityaccount/operator.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAKhG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,uFAAuF;AACvF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC;AAKD,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,eAAe,CAAC,CAiC1B"}