@vantageos/cloud-identity 0.15.0 → 0.16.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/CHANGELOG.md CHANGED
@@ -12,6 +12,43 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
12
12
  `buildProtectedResourceMetadata`. A whitespace-only, non-URL or
13
13
  fragment-bearing audience throws the config error instead of being accepted.
14
14
 
15
+ ## [0.16.0]
16
+
17
+ **Additive: an organisation is its permanent ID (`./org-by-id`).** A consumer
18
+ used to keep its own copy of "which org is this credential", "are these two
19
+ rows one org", "which org is the operator" and "what is this slug's org ID".
20
+ Those decisions are now the package's, keyed on IDs, refusing by default. No
21
+ existing function changes behaviour for an existing input.
22
+
23
+ ### Added
24
+
25
+ - `resolveOrgFromClaim(claims, lookups, { door? })`: a verified
26
+ credential's `org_id` claim to the org's mapping row (roster, scopes, kind).
27
+ - `sameOrg`, `isFleetStamp`, `sameTenantStamp`: comparisons over `OrgRef`
28
+ (`{ id?, label? }`). Unstamped is never a match.
29
+ - `findOperatorOrg(lookups, { cap? })`: `one | none | many | overCap | unreadable`.
30
+ - `resolveOrgIdForLabelBackfillOnly(label, lookups)`: label to permanent ID,
31
+ or a typed `ORG_ID_ABSENT` absence. For the one-off backfill only; it must
32
+ never be called on a request path, and the name says so. (Developed as
33
+ `resolveOrgIdForLabel`; that name was never published.)
34
+ - `orgMappingRowSchema` and the types `OrgRef`, `OrgMappingRow`,
35
+ `OrgMappingLookups`, `ResolvedOrg`, `ResolveOrgFromClaimOptions`,
36
+ `ResolveOrgFromClaimResult`, `OrgIdAbsence`, `OrgIdAbsenceReason`,
37
+ `OrgIdResolution`, `OperatorOrgLookups`, `FindOperatorOrgOptions`,
38
+ `OperatorOrgResult`.
39
+ - New `IdentityRefusalReason` values: `org-mapping-lookup-failed`,
40
+ `org-mapping-not-found`, `org-mapping-record-invalid`.
41
+
42
+ ### No label resolution
43
+
44
+ An organisation is never resolved from its label on a request path, and no
45
+ option turns that on. A transitional `labelFallback` option was developed and
46
+ removed before publication: `sameOrg`, `isFleetStamp`, `sameTenantStamp` and
47
+ `resolveOrgFromClaim` compare and select by org ID only, a label-only input
48
+ refuses, and the `org-id-contradicts-label` reason and the `source` field of
49
+ `ResolvedOrg` went with it. The label adapter is read only by
50
+ `resolveOrgIdForLabelBackfillOnly`.
51
+
15
52
  ## [0.15.0]
16
53
 
17
54
  **Additive: resource-server primitives (`./resource-server`).** No existing
package/README.md CHANGED
@@ -895,6 +895,64 @@ if (!r.ok) return respond(r.status, "headers" in r ? r.headers : {});
895
895
  the consumer fetches and caches the key set; no scope check is made on the
896
896
  token (read `r.session.claims`).
897
897
 
898
+ ## An organisation is its permanent ID (0.16.0)
899
+
900
+ A label (the slug an org can be renamed to) is display text. These functions
901
+ decide "which organisation" from the permanent org ID, with the store supplied
902
+ as adapters, and refuse by default. All are in `./org-by-id` and the root.
903
+
904
+ **`resolveOrgFromClaim(claims, lookups, opts)`** takes the claim record of a
905
+ VERIFIED credential (never a request field) and returns
906
+ `{ ok: true, org: { id, label, allowedOrchestrators, scopes, orgKind } }`
907
+ or a typed `RBAC_DENIED` refusal. The `org_id` claim (also read from
908
+ `organizationId` and `orgId`, only when shaped like a Clerk org ID) selects the
909
+ mapping row through `lookups.orgById`; a stale label in the token is ignored,
910
+ so a rename never changes who the caller is. Refused: no claim, an ID no
911
+ mapping holds, an inactive org, a row that does not repeat the ID asked for, a
912
+ malformed row, a missing or throwing adapter.
913
+
914
+ ```ts
915
+ const r = await resolveOrgFromClaim(identity, {
916
+ orgById: (id) => db.mappingByClerkOrgId(id),
917
+ }, { door: "tasks:list" });
918
+ if (!r.ok) throw new IdentityRefusalError(r.refusal);
919
+ ```
920
+
921
+ **`sameOrg(a, b, opts)`**, **`isFleetStamp(stamp, operator, opts)`** and
922
+ **`sameTenantStamp(a, b, operator, opts)`** compare `OrgRef` values
923
+ (`{ id?, label? }`). Two IDs are equal or they are not; unstamped is never
924
+ a match; `isFleetStamp` is true for an unstamped stamp or the operator's, and
925
+ `sameTenantStamp` is true for the same org or when both are the fleet's.
926
+
927
+ **`findOperatorOrg(lookups, opts)`** finds the operator organisation from
928
+ `lookups.activeOrganisations(limit)`: `one`, `none`, `many`, `overCap`
929
+ (`cap` defaults to 1000, the read is `cap + 1`) or `unreadable`. Only `one` is
930
+ an operator; pass `undefined` as `operator` otherwise and only unstamped rows
931
+ are the fleet's.
932
+
933
+ **`resolveOrgIdForLabelBackfillOnly(label, lookups)`** derives the permanent
934
+ ID of the org a label names, for a ONE-OFF BACKFILL that stamps rows written
935
+ before IDs existed. It must never be called on a request path: a request
936
+ decides its organisation from the verified `org_id` claim
937
+ (`resolveOrgFromClaim`), and a miss there is a refusal, never a retry by label.
938
+ It returns `{ present: true, orgId }` or a typed `ORG_ID_ABSENT` absence
939
+ (`no-label`, `lookup-failed`, `not-mapped`, `record-invalid`, `id-not-filled`).
940
+ It never invents an ID.
941
+
942
+ **`orgMappingRowSchema`** is the Zod shape of a mapping row an adapter returns
943
+ (`id`, `label`, `active`, `allowedOrchestrators`, `scopes`, `orgKind`).
944
+
945
+ Types: `OrgRef`, `OrgMappingRow`, `OrgMappingLookups`,
946
+ `ResolvedOrg`, `ResolveOrgFromClaimOptions`, `ResolveOrgFromClaimResult`,
947
+ `OrgIdAbsence`, `OrgIdAbsenceReason`, `OrgIdResolution`, `OperatorOrgLookups`,
948
+ `FindOperatorOrgOptions`, `OperatorOrgResult`.
949
+
950
+ **No label resolution.** No function above compares or selects by label, and
951
+ no option turns that on: a reference or credential without an org ID names no
952
+ organisation and is refused. A store that has not filled every ID is filled
953
+ once, with `resolveOrgIdForLabelBackfillOnly`, before the consumer relies on
954
+ these functions.
955
+
898
956
  ## What this package does not do
899
957
 
900
958
  Worth reading before you rely on it.
@@ -13,7 +13,7 @@
13
13
  * closed vocabulary for the person path.
14
14
  */
15
15
  export type IdentityRefusalCode = "RBAC_DENIED" | "CREDENTIAL_REFUSED";
16
- export type IdentityRefusalReason = "unknown-role" | "unknown-minimum-role" | "invalid-role-order" | "role-below-minimum" | "role-claim-absent" | "role-claim-unmapped" | "invalid-role-mapping" | "membership-invalid-input" | "membership-lookup-failed" | "membership-not-found" | "membership-record-invalid" | "membership-inactive" | "other-organisation" | "no-verified-organisation" | "role-not-admin" | "namespace-invalid" | "no-write-prefixes" | "namespace-write-denied" | "secret-not-configured" | "secret-mismatch" | "credential-invalid" | "principal-lookup-failed" | "principal-not-found" | "principal-record-invalid" | "principal-inactive" | "organisation-not-active" | "reserved-fleet-scope" | "acting-agent-other-organisation" | "target-unstamped" | "target-other-organisation" | "target-owner-mismatch" | "principal-not-a-person" | "list-absent" | "list-empty" | "principal-not-an-agent" | "principal-not-listed" | "bearer-missing" | "bearer-malformed" | "token-invalid" | "jwks-unavailable";
16
+ export type IdentityRefusalReason = "unknown-role" | "unknown-minimum-role" | "invalid-role-order" | "role-below-minimum" | "role-claim-absent" | "role-claim-unmapped" | "invalid-role-mapping" | "membership-invalid-input" | "membership-lookup-failed" | "membership-not-found" | "membership-record-invalid" | "membership-inactive" | "other-organisation" | "no-verified-organisation" | "role-not-admin" | "namespace-invalid" | "no-write-prefixes" | "namespace-write-denied" | "secret-not-configured" | "secret-mismatch" | "credential-invalid" | "principal-lookup-failed" | "principal-not-found" | "principal-record-invalid" | "principal-inactive" | "organisation-not-active" | "reserved-fleet-scope" | "acting-agent-other-organisation" | "target-unstamped" | "target-other-organisation" | "target-owner-mismatch" | "principal-not-a-person" | "list-absent" | "list-empty" | "principal-not-an-agent" | "principal-not-listed" | "bearer-missing" | "bearer-malformed" | "token-invalid" | "jwks-unavailable" | "org-mapping-lookup-failed" | "org-mapping-not-found" | "org-mapping-record-invalid";
17
17
  export type IdentityRefusal = {
18
18
  code: IdentityRefusalCode;
19
19
  reason: IdentityRefusalReason;
@@ -1 +1 @@
1
- {"version":3,"file":"identity-refusal.d.ts","sourceRoot":"","sources":["../src/identity-refusal.ts"],"names":[],"mappings":"A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,GACb,eAAe,CAEjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"identity-refusal.js","sourceRoot":"","sources":["../src/identity-refusal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgEH,0EAA0E;AAC1E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,OAAO,CAAkB;IAClC,YAAY,OAAwB;QAClC,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QACjF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,gEAAgE;AAChE,MAAM,UAAU,OAAO,CACrB,IAAyB,EACzB,MAA6B,EAC7B,IAAY,EACZ,MAAc;IAEd,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC"}
1
+ {"version":3,"file":"identity-refusal.js","sourceRoot":"","sources":["../src/identity-refusal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoEH,0EAA0E;AAC1E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,OAAO,CAAkB;IAClC,YAAY,OAAwB;QAClC,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;QACjF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,gEAAgE;AAChE,MAAM,UAAU,OAAO,CACrB,IAAyB,EACzB,MAA6B,EAC7B,IAAY,EACZ,MAAc;IAEd,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -41,4 +41,6 @@ export { actingCredentialSchema, principalRowSchema, organisationRowSchema, reso
41
41
  export type { ActingCredential, PrincipalRow, OrganisationRow, PrincipalLookups, OrgKind, OrgKindLookups, ActingPrincipalKind, ActingPrincipal, ResolveActingPrincipalResult, TargetIds, AssertTargetOptions, AssertTargetResult, FilterTargetsResult, AssertOrgAdminOptions, AssertOrgAdminResult, PrincipalIdList, AssertPrincipalListedOptions, AssertPrincipalListedResult, RecipientIds, RecipientLookups, AssertRecipientAddressableOptions, AssertRecipientAddressableResult, CallerCredential, AssertCallerStandingOptions, CallerStanding, } from "./principal-by-id.js";
42
42
  export { buildProtectedResourceMetadata, unauthorizedChallenge, deriveClerkDiscoveryUrls, verifyMcpAccessToken, } from "./resource-server.js";
43
43
  export type { ProtectedResourceMetadataConfig, ProtectedResourceMetadata, UnauthorizedChallengeConfig, UnauthorizedChallenge, ClerkDiscoveryUrls, McpResourceServerConfig, VerifyMcpAccessTokenResult, } from "./resource-server.js";
44
+ export { sameOrg, isFleetStamp, sameTenantStamp, resolveOrgFromClaim, resolveOrgIdForLabelBackfillOnly, findOperatorOrg, orgMappingRowSchema, } from "./org-by-id.js";
45
+ export type { OrgRef, OrgMappingRow, OrgMappingLookups, ResolvedOrg, ResolveOrgFromClaimOptions, ResolveOrgFromClaimResult, OrgIdAbsence, OrgIdAbsenceReason, OrgIdResolution, OperatorOrgLookups, FindOperatorOrgOptions, OperatorOrgResult, } from "./org-by-id.js";
44
46
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,K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,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,+BAA+B,EAC/B,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EACL,OAAO,EACP,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,gCAAgC,EAChC,eAAe,EACf,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,0BAA0B,EAC1B,yBAAyB,EACzB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -44,4 +44,10 @@ export { actingCredentialSchema, principalRowSchema, organisationRowSchema, reso
44
44
  // verification bound to this resource. Replaces the standalone resource-server
45
45
  // package; one identity layer.
46
46
  export { buildProtectedResourceMetadata, unauthorizedChallenge, deriveClerkDiscoveryUrls, verifyMcpAccessToken, } from "./resource-server.js";
47
+ // 0.16.0 — An organisation is its permanent ID: the credential's org_id claim to
48
+ // the org's mapping row, the ID comparisons and the operator org. Labels
49
+ // (slugs) never select or prove an org; no option turns that on. The
50
+ // label-to-ID derivation is exported only as
51
+ // `resolveOrgIdForLabelBackfillOnly`, for a one-off backfill.
52
+ export { sameOrg, isFleetStamp, sameTenantStamp, resolveOrgFromClaim, resolveOrgIdForLabelBackfillOnly, findOperatorOrg, orgMappingRowSchema, } from "./org-by-id.js";
47
53
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,SAAS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AA0B,CAAC;AAEjF,8EAA8E;AAC9E,oEAAoE;AACpE,8EAA8E;AAC9E,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AA6B9B,6EAA6E;AAC7E,yEAAyE;AACzE,+EAA+E;AAC/E,+BAA+B;AAC/B,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAW9B,iFAAiF;AACjF,yEAAyE;AACzE,qEAAqE;AACrE,6CAA6C;AAC7C,8DAA8D;AAC9D,OAAO,EACL,OAAO,EACP,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,gCAAgC,EAChC,eAAe,EACf,mBAAmB,GACpB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * @vantageos/cloud-identity — an organisation is its permanent ID.
3
+ *
4
+ * Everything here decides "which organisation" from the permanent org ID a
5
+ * verified credential or a stored row carries. A label (the slug an org can be
6
+ * renamed to) is display text: it never selects an org and never proves two
7
+ * references are one org.
8
+ *
9
+ * Refusal, always. There is no option that compares or resolves by label: a
10
+ * reference or credential without an org ID names no organisation, and a
11
+ * mapping is reached only by an ID.
12
+ *
13
+ * The store is the consumer's: every read is an adapter it supplies, called
14
+ * with the key as presented, byte for byte. A missing, throwing or malformed
15
+ * adapter refuses. An adapter's error text is never surfaced.
16
+ */
17
+ import { z } from "zod";
18
+ import { type IdentityRefusal } from "./identity-refusal.js";
19
+ import type { OrgKind } from "./principal-by-id.js";
20
+ /**
21
+ * An organisation as a row or a caller names it: the permanent ID and the
22
+ * label. Either may be absent. Both absent is "unstamped", which names no
23
+ * organisation.
24
+ */
25
+ export type OrgRef = {
26
+ /** The permanent org ID. */
27
+ id?: string | null;
28
+ /** The renamable label (slug). Display text; never compared. */
29
+ label?: string | null;
30
+ };
31
+ /**
32
+ * Do two references name the same organisation? Only by ID, when both carry
33
+ * one. A label never matches, and absence is not a match: two unstamped
34
+ * references are NOT the same organisation here.
35
+ */
36
+ export declare function sameOrg(a: OrgRef | null | undefined, b: OrgRef | null | undefined): boolean;
37
+ /**
38
+ * Is a stamp the fleet's: unstamped, or the operator organisation's? The
39
+ * operator is read from stored data by the caller (see `findOperatorOrg`);
40
+ * pass `undefined` when there is not exactly one, and only an unstamped stamp
41
+ * is the fleet's. An empty-string stamp is neither unstamped nor the operator.
42
+ */
43
+ export declare function isFleetStamp(stamp: OrgRef | null | undefined, operator: OrgRef | null | undefined): boolean;
44
+ /**
45
+ * Do two stamps name the same tenant: the same organisation, or both the
46
+ * fleet's? Two IDs that differ are two tenants even under one label.
47
+ */
48
+ export declare function sameTenantStamp(a: OrgRef | null | undefined, b: OrgRef | null | undefined, operator: OrgRef | null | undefined): boolean;
49
+ /**
50
+ * The consumer's organisation mapping row, as an adapter returns it. `id` is
51
+ * the permanent org ID and may be absent while the store is being filled;
52
+ * `label` is the slug. Extra fields are allowed and ignored.
53
+ */
54
+ export declare const orgMappingRowSchema: z.ZodObject<{
55
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
+ label: z.ZodString;
57
+ active: z.ZodBoolean;
58
+ allowedOrchestrators: z.ZodArray<z.ZodString>;
59
+ scopes: z.ZodArray<z.ZodString>;
60
+ orgKind: z.ZodOptional<z.ZodNullable<z.ZodString>>;
61
+ }, z.core.$strip>;
62
+ export type OrgMappingRow = z.input<typeof orgMappingRowSchema>;
63
+ type Lookup<A extends unknown[], R> = (...args: A) => Promise<R | null | undefined> | R | null | undefined;
64
+ /** Indexed reads of the mapping store. Only the lookups of the path taken are called. */
65
+ export type OrgMappingLookups = {
66
+ /** The mapping row whose permanent ID is exactly the one asked for. */
67
+ orgById?: Lookup<[orgId: string], OrgMappingRow>;
68
+ /** The mapping row whose label is exactly the one asked for. Read only by `resolveOrgIdForLabelBackfillOnly`. */
69
+ orgByLabel?: Lookup<[label: string], OrgMappingRow>;
70
+ };
71
+ /** The org a credential resolves to, with the roster and scopes of its mapping row. */
72
+ export type ResolvedOrg = {
73
+ /** The permanent org ID: the one the credential carried and the mapping holds. */
74
+ id: string;
75
+ /** The org's CURRENT label. Display text. */
76
+ label: string;
77
+ allowedOrchestrators: string[];
78
+ scopes: string[];
79
+ orgKind: OrgKind | null;
80
+ };
81
+ export type ResolveOrgFromClaimOptions = {
82
+ /** The consumer's name for the door; carried on every refusal. */
83
+ door?: string;
84
+ };
85
+ export type ResolveOrgFromClaimResult = {
86
+ ok: true;
87
+ org: ResolvedOrg;
88
+ } | {
89
+ ok: false;
90
+ refusal: IdentityRefusal;
91
+ };
92
+ /**
93
+ * Resolves a VERIFIED credential's claims to the stored mapping row of its
94
+ * organisation, or refuses. The claim's org ID selects the row; nothing the
95
+ * request supplies does.
96
+ *
97
+ * A credential carrying no usable org ID is refused
98
+ * (`no-verified-organisation`) and an ID no mapping holds is refused
99
+ * (`org-mapping-not-found`). A label claim (a slug) is never read: it neither
100
+ * selects a mapping nor rescues a missing ID.
101
+ *
102
+ * `claims` is the verified identity's own claim record, never a request field.
103
+ */
104
+ export declare function resolveOrgFromClaim(claims: Record<string, unknown> | null | undefined, lookups: OrgMappingLookups | null | undefined, options?: ResolveOrgFromClaimOptions): Promise<ResolveOrgFromClaimResult>;
105
+ export type OrgIdAbsenceReason = "no-label" | "lookup-failed" | "not-mapped" | "record-invalid" | "id-not-filled";
106
+ /** The typed absence of an ID. A non-empty object: never mistaken for an ID or for nothing. */
107
+ export type OrgIdAbsence = {
108
+ code: "ORG_ID_ABSENT";
109
+ reason: OrgIdAbsenceReason;
110
+ };
111
+ export type OrgIdResolution = {
112
+ present: true;
113
+ orgId: string;
114
+ } | {
115
+ present: false;
116
+ absence: OrgIdAbsence;
117
+ };
118
+ /**
119
+ * BACKFILL ONLY. Derives the permanent org ID of the organisation a label
120
+ * names, from the consumer's stored mapping, so a one-off migration can stamp
121
+ * rows written before IDs existed.
122
+ *
123
+ * MUST NEVER be called on a request path. A request decides its organisation
124
+ * from the verified credential's `org_id` claim (`resolveOrgFromClaim`); a miss
125
+ * there is a refusal, never a retry by label. A label is renamable display
126
+ * text: resolving an org from it on a request is the name-to-ID defect this
127
+ * module exists to close, and the export name carries that restriction so a
128
+ * reviewer sees it at every call site.
129
+ *
130
+ * A derivation and not an authorization: it answers for an inactive mapping
131
+ * too. It never invents an ID: a mapping with none filled is `id-not-filled`.
132
+ */
133
+ export declare function resolveOrgIdForLabelBackfillOnly(label: string | null | undefined, lookups: OrgMappingLookups | null | undefined): Promise<OrgIdResolution>;
134
+ export type OperatorOrgLookups = {
135
+ /**
136
+ * The ACTIVE organisation mapping rows, at most `limit` of them. Called with
137
+ * `cap + 1` so a filled read is recognisable as over the cap.
138
+ */
139
+ activeOrganisations?: (limit: number) => unknown;
140
+ };
141
+ export type FindOperatorOrgOptions = {
142
+ /** Read bound. Default 1000. A read over the cap is never decided from. */
143
+ cap?: number;
144
+ };
145
+ export type OperatorOrgResult = {
146
+ kind: "one";
147
+ org: {
148
+ id: string | undefined;
149
+ label: string;
150
+ };
151
+ } | {
152
+ kind: "none";
153
+ } | {
154
+ kind: "many";
155
+ count: number;
156
+ } | {
157
+ kind: "overCap";
158
+ } | {
159
+ kind: "unreadable";
160
+ };
161
+ /**
162
+ * Finds the operator organisation (the fleet) from stored mapping rows: the
163
+ * single ACTIVE row whose kind is exactly `"operator"`. None, several, an
164
+ * over-cap read, an unreadable store and a malformed row are each a typed
165
+ * non-answer, so the caller can only treat the fleet as "no single operator"
166
+ * (fail closed) and never widen from a guess.
167
+ */
168
+ export declare function findOperatorOrg(lookups: OperatorOrgLookups | null | undefined, options?: FindOperatorOrgOptions): Promise<OperatorOrgResult>;
169
+ export {};
170
+ //# sourceMappingURL=org-by-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-by-id.d.ts","sourceRoot":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loud-identity — an organisation is its permanent ID.
3
+ *
4
+ * Everything here decides "which organisation" from the permanent org ID a
5
+ * verified credential or a stored row carries. A label (the slug an org can be
6
+ * renamed to) is display text: it never selects an org and never proves two
7
+ * references are one org.
8
+ *
9
+ * Refusal, always. There is no option that compares or resolves by label: a
10
+ * reference or credential without an org ID names no organisation, and a
11
+ * mapping is reached only by an ID.
12
+ *
13
+ * The store is the consumer's: every read is an adapter it supplies, called
14
+ * with the key as presented, byte for byte. A missing, throwing or malformed
15
+ * adapter refuses. An adapter's error text is never surfaced.
16
+ */
17
+ import { z } from "zod";
18
+ import { refusal } from "./identity-refusal.js";
19
+ import { resolveTenantIdOrAbsent } from "./org-guard.js";
20
+ function nonEmpty(value) {
21
+ return typeof value === "string" && value.length > 0;
22
+ }
23
+ function isUnstamped(ref) {
24
+ return (ref === null ||
25
+ ref === undefined ||
26
+ ((ref.id === null || ref.id === undefined) &&
27
+ (ref.label === null || ref.label === undefined)));
28
+ }
29
+ // ---------------------------------------------------------------------------
30
+ // sameOrg / isFleetStamp / sameTenantStamp
31
+ // ---------------------------------------------------------------------------
32
+ /**
33
+ * Do two references name the same organisation? Only by ID, when both carry
34
+ * one. A label never matches, and absence is not a match: two unstamped
35
+ * references are NOT the same organisation here.
36
+ */
37
+ export function sameOrg(a, b) {
38
+ if (!a || !b)
39
+ return false;
40
+ return nonEmpty(a.id) && nonEmpty(b.id) && a.id === b.id;
41
+ }
42
+ /**
43
+ * Is a stamp the fleet's: unstamped, or the operator organisation's? The
44
+ * operator is read from stored data by the caller (see `findOperatorOrg`);
45
+ * pass `undefined` when there is not exactly one, and only an unstamped stamp
46
+ * is the fleet's. An empty-string stamp is neither unstamped nor the operator.
47
+ */
48
+ export function isFleetStamp(stamp, operator) {
49
+ if (isUnstamped(stamp))
50
+ return true;
51
+ return operator !== null && operator !== undefined && sameOrg(stamp, operator);
52
+ }
53
+ /**
54
+ * Do two stamps name the same tenant: the same organisation, or both the
55
+ * fleet's? Two IDs that differ are two tenants even under one label.
56
+ */
57
+ export function sameTenantStamp(a, b, operator) {
58
+ if (isFleetStamp(a, operator) && isFleetStamp(b, operator))
59
+ return true;
60
+ return sameOrg(a, b);
61
+ }
62
+ // ---------------------------------------------------------------------------
63
+ // The stored mapping row
64
+ // ---------------------------------------------------------------------------
65
+ /**
66
+ * The consumer's organisation mapping row, as an adapter returns it. `id` is
67
+ * the permanent org ID and may be absent while the store is being filled;
68
+ * `label` is the slug. Extra fields are allowed and ignored.
69
+ */
70
+ export const orgMappingRowSchema = z.object({
71
+ id: z.string().min(1).nullish(),
72
+ label: z.string().min(1),
73
+ active: z.boolean(),
74
+ allowedOrchestrators: z.array(z.string()),
75
+ scopes: z.array(z.string()),
76
+ orgKind: z.string().nullish(),
77
+ });
78
+ function kindOf(raw) {
79
+ return raw === "operator" || raw === "client" ? raw : null;
80
+ }
81
+ /** Calls an adapter; a missing or throwing one is `called: false`. */
82
+ async function call(lookup, ...args) {
83
+ if (typeof lookup !== "function")
84
+ return { called: false };
85
+ try {
86
+ const raw = await lookup(...args);
87
+ return { called: true, row: raw ?? null };
88
+ }
89
+ catch {
90
+ return { called: false };
91
+ }
92
+ }
93
+ const CLERK_ORG_ID_SHAPE = /^org_[A-Za-z0-9]+$/;
94
+ const ID_CLAIMS = ["org_id", "organizationId", "orgId"];
95
+ /** The first claim that is shaped like a Clerk org ID and resolves as a tenant. */
96
+ function claimedOrgId(claims) {
97
+ for (const name of ID_CLAIMS) {
98
+ const value = claims[name];
99
+ if (typeof value !== "string" || !CLERK_ORG_ID_SHAPE.test(value))
100
+ continue;
101
+ const resolved = resolveTenantIdOrAbsent({ kind: "session", identity: { orgId: value } });
102
+ if (resolved.present)
103
+ return resolved.tenantId;
104
+ }
105
+ return undefined;
106
+ }
107
+ /**
108
+ * Resolves a VERIFIED credential's claims to the stored mapping row of its
109
+ * organisation, or refuses. The claim's org ID selects the row; nothing the
110
+ * request supplies does.
111
+ *
112
+ * A credential carrying no usable org ID is refused
113
+ * (`no-verified-organisation`) and an ID no mapping holds is refused
114
+ * (`org-mapping-not-found`). A label claim (a slug) is never read: it neither
115
+ * selects a mapping nor rescues a missing ID.
116
+ *
117
+ * `claims` is the verified identity's own claim record, never a request field.
118
+ */
119
+ export async function resolveOrgFromClaim(claims, lookups, options) {
120
+ const door = options?.door ?? "resolveOrgFromClaim";
121
+ const deny = (reason, detail) => ({
122
+ ok: false,
123
+ refusal: refusal("RBAC_DENIED", reason, door, detail),
124
+ });
125
+ const record = claims && typeof claims === "object" ? claims : {};
126
+ const orgId = claimedOrgId(record);
127
+ if (orgId === undefined) {
128
+ return deny("no-verified-organisation", "The credential carries no verified organisation.");
129
+ }
130
+ const served = (row, id) => {
131
+ if (row.active !== true) {
132
+ return deny("organisation-not-active", "The organisation is not mapped or not active.");
133
+ }
134
+ return {
135
+ ok: true,
136
+ org: {
137
+ id,
138
+ label: row.label,
139
+ allowedOrchestrators: row.allowedOrchestrators,
140
+ scopes: row.scopes,
141
+ orgKind: kindOf(row.orgKind),
142
+ },
143
+ };
144
+ };
145
+ const invalid = deny("org-mapping-record-invalid", "The organisation mapping record is not well formed.");
146
+ const unreadable = deny("org-mapping-lookup-failed", "The organisation mapping could not be read, so none is resolved.");
147
+ const found = await call(lookups?.orgById, orgId);
148
+ if (!found.called)
149
+ return unreadable;
150
+ if (found.row === null) {
151
+ return deny("org-mapping-not-found", "No organisation mapping holds the credential's organisation ID.");
152
+ }
153
+ const parsed = orgMappingRowSchema.safeParse(found.row);
154
+ if (!parsed.success || parsed.data.id !== orgId)
155
+ return invalid;
156
+ return served(parsed.data, orgId);
157
+ }
158
+ /**
159
+ * BACKFILL ONLY. Derives the permanent org ID of the organisation a label
160
+ * names, from the consumer's stored mapping, so a one-off migration can stamp
161
+ * rows written before IDs existed.
162
+ *
163
+ * MUST NEVER be called on a request path. A request decides its organisation
164
+ * from the verified credential's `org_id` claim (`resolveOrgFromClaim`); a miss
165
+ * there is a refusal, never a retry by label. A label is renamable display
166
+ * text: resolving an org from it on a request is the name-to-ID defect this
167
+ * module exists to close, and the export name carries that restriction so a
168
+ * reviewer sees it at every call site.
169
+ *
170
+ * A derivation and not an authorization: it answers for an inactive mapping
171
+ * too. It never invents an ID: a mapping with none filled is `id-not-filled`.
172
+ */
173
+ export async function resolveOrgIdForLabelBackfillOnly(label, lookups) {
174
+ const absent = (reason) => ({
175
+ present: false,
176
+ absence: { code: "ORG_ID_ABSENT", reason },
177
+ });
178
+ if (!nonEmpty(label))
179
+ return absent("no-label");
180
+ const found = await call(lookups?.orgByLabel, label);
181
+ if (!found.called)
182
+ return absent("lookup-failed");
183
+ if (found.row === null)
184
+ return absent("not-mapped");
185
+ const parsed = orgMappingRowSchema.safeParse(found.row);
186
+ if (!parsed.success || parsed.data.label !== label)
187
+ return absent("record-invalid");
188
+ if (parsed.data.id === undefined || parsed.data.id === null)
189
+ return absent("id-not-filled");
190
+ return { present: true, orgId: parsed.data.id };
191
+ }
192
+ const DEFAULT_OPERATOR_READ_CAP = 1000;
193
+ /**
194
+ * Finds the operator organisation (the fleet) from stored mapping rows: the
195
+ * single ACTIVE row whose kind is exactly `"operator"`. None, several, an
196
+ * over-cap read, an unreadable store and a malformed row are each a typed
197
+ * non-answer, so the caller can only treat the fleet as "no single operator"
198
+ * (fail closed) and never widen from a guess.
199
+ */
200
+ export async function findOperatorOrg(lookups, options) {
201
+ const cap = options?.cap ?? DEFAULT_OPERATOR_READ_CAP;
202
+ const read = lookups?.activeOrganisations;
203
+ if (typeof read !== "function")
204
+ return { kind: "unreadable" };
205
+ let raw;
206
+ try {
207
+ raw = await read(cap + 1);
208
+ }
209
+ catch {
210
+ return { kind: "unreadable" };
211
+ }
212
+ if (!Array.isArray(raw))
213
+ return { kind: "unreadable" };
214
+ if (raw.length > cap)
215
+ return { kind: "overCap" };
216
+ const operators = [];
217
+ for (const item of raw) {
218
+ const parsed = orgMappingRowSchema.safeParse(item);
219
+ if (!parsed.success)
220
+ return { kind: "unreadable" };
221
+ if (parsed.data.active === true && parsed.data.orgKind === "operator") {
222
+ operators.push(parsed.data);
223
+ }
224
+ }
225
+ if (operators.length === 0)
226
+ return { kind: "none" };
227
+ if (operators.length > 1)
228
+ return { kind: "many", count: operators.length };
229
+ const [only] = operators;
230
+ return { kind: "one", org: { id: only.id ?? undefined, label: only.label } };
231
+ }
232
+ //# sourceMappingURL=org-by-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"org-by-id.js","sourceRoot":"","sources":["../src/org-by-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAwB,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAmBzD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,WAAW,CAAC,GAA8B;IACjD,OAAO,CACL,GAAG,KAAK,IAAI;QACZ,GAAG,KAAK,SAAS;QACjB,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,CAAC;YACxC,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CACnD,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,2CAA2C;AAC3C,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,UAAU,OAAO,CACrB,CAA4B,EAC5B,CAA4B;IAE5B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,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UAAU,EAAE,CAAC;YACtE,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACpD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;IAC3E,MAAM,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;AAC/E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vantageos/cloud-identity",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Framework-agnostic identity + scope-filter primitives for VantagePeers Cloud (multi-tenant MCP).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -85,6 +85,10 @@
85
85
  "./resource-server": {
86
86
  "types": "./dist/resource-server.d.ts",
87
87
  "import": "./dist/resource-server.js"
88
+ },
89
+ "./org-by-id": {
90
+ "types": "./dist/org-by-id.d.ts",
91
+ "import": "./dist/org-by-id.js"
88
92
  }
89
93
  },
90
94
  "files": [