@owlmeans/auth-common 0.1.18-rc.7 → 0.1.18-rc.9

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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/auth-common",
4
- "version": "0.1.18-rc.7",
5
- "generatedAt": "2026-08-24T21:14:00.112Z",
4
+ "version": "0.1.18-rc.8",
5
+ "generatedAt": "2026-08-27T16:32:18.484Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -8,7 +8,7 @@ user-invocable: false
8
8
  # @owlmeans/auth-common
9
9
 
10
10
  **Layer:** Core
11
- **Install:** `"@owlmeans/auth-common": "^0.1.18-rc.7"` in `dependencies`
11
+ **Install:** `"@owlmeans/auth-common": "^0.1.18-rc.8"` in `dependencies`
12
12
 
13
13
  ## Key Exports
14
14
 
package/build/consts.d.ts CHANGED
@@ -3,10 +3,29 @@ export declare const RELY_TOKEN_PREFIX = "rely-token:";
3
3
  export declare const RELY_CALL_TIMEOUT = 120;
4
4
  export declare const RELY_ACTION_TIMEOUT = 600;
5
5
  export declare const DISPATCHER_PATH = "/dispatcher";
6
+ /**
7
+ * Where the surrogate login window runs.
8
+ *
9
+ * Reserved exactly like {@link DISPATCHER_PATH}: an application must not declare a route of its
10
+ * own here, and a code generator must not produce one. It is user-visible — it is what the popup's
11
+ * address bar shows.
12
+ */
13
+ export declare const SURROGATE_PATH = "/surrogate";
6
14
  export declare const DEF_AUTH_SRV = "auth";
7
15
  export declare const DEFAULT_GUARD = "auth";
8
16
  export declare const TOKEN_UPDATE = "auth-token-refresh";
9
17
  export declare const WEB_API = "web-auth-api";
18
+ /** Service alias of the organization-entity resolver, when an implementation registers one. */
19
+ export declare const ENTITY_RESOLVER = "entity-resolver";
20
+ /**
21
+ * What an organization slug may look like: a DNS label, lowercase.
22
+ *
23
+ * The constraint is not cosmetic. The same slug is used to compose hostnames, Kubernetes object
24
+ * names and OIDC client ids, so anything that would need sanitising before it could address one of
25
+ * those is rejected at the point it is chosen instead — a slug that survives this pattern passes
26
+ * through every downstream name unchanged.
27
+ */
28
+ export declare const ENTITY_SLUG_PATTERN: RegExp;
10
29
  export declare const authApi: {
11
30
  profile: {
12
31
  base: string;
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,cAAc,CAAA;AAE1C,eAAO,MAAM,iBAAiB,gBAAgB,CAAA;AAE9C,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC,eAAO,MAAM,eAAe,gBAAgB,CAAA;AAE5C,eAAO,MAAM,YAAY,SAAS,CAAA;AAElC,eAAO,MAAM,aAAa,SAAe,CAAA;AAEzC,eAAO,MAAM,YAAY,uBAAuB,CAAA;AAEhD,eAAO,MAAM,OAAO,iBAAiB,CAAA;AAErC,eAAO,MAAM,OAAO;IAClB,OAAO;QACL,IAAI;QACJ,UAAU;;IAEZ,MAAM;QACJ,IAAI;QACJ,GAAG;QACH,OAAO;YACL,IAAI;YACJ,IAAI;YACJ,IAAI;;;IAGR,IAAI;QACF,IAAI;QACJ,QAAQ;;CAEX,CAAA"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,cAAc,CAAA;AAE1C,eAAO,MAAM,iBAAiB,gBAAgB,CAAA;AAE9C,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC,eAAO,MAAM,eAAe,gBAAgB,CAAA;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,eAAe,CAAA;AAE1C,eAAO,MAAM,YAAY,SAAS,CAAA;AAElC,eAAO,MAAM,aAAa,SAAe,CAAA;AAEzC,eAAO,MAAM,YAAY,uBAAuB,CAAA;AAEhD,eAAO,MAAM,OAAO,iBAAiB,CAAA;AAErC,+FAA+F;AAC/F,eAAO,MAAM,eAAe,oBAAoB,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QAA2C,CAAA;AAE3E,eAAO,MAAM,OAAO;IAClB,OAAO;QACL,IAAI;QACJ,UAAU;;IAEZ,MAAM;QACJ,IAAI;QACJ,GAAG;QACH,OAAO;YACL,IAAI;YACJ,IAAI;YACJ,IAAI;;;IAGR,IAAI;QACF,IAAI;QACJ,QAAQ;;CAEX,CAAA"}
package/build/consts.js CHANGED
@@ -3,10 +3,29 @@ export const RELY_TOKEN_PREFIX = 'rely-token:';
3
3
  export const RELY_CALL_TIMEOUT = 120;
4
4
  export const RELY_ACTION_TIMEOUT = 600;
5
5
  export const DISPATCHER_PATH = '/dispatcher';
6
+ /**
7
+ * Where the surrogate login window runs.
8
+ *
9
+ * Reserved exactly like {@link DISPATCHER_PATH}: an application must not declare a route of its
10
+ * own here, and a code generator must not produce one. It is user-visible — it is what the popup's
11
+ * address bar shows.
12
+ */
13
+ export const SURROGATE_PATH = '/surrogate';
6
14
  export const DEF_AUTH_SRV = 'auth';
7
15
  export const DEFAULT_GUARD = DEF_AUTH_SRV;
8
16
  export const TOKEN_UPDATE = 'auth-token-refresh';
9
17
  export const WEB_API = 'web-auth-api';
18
+ /** Service alias of the organization-entity resolver, when an implementation registers one. */
19
+ export const ENTITY_RESOLVER = 'entity-resolver';
20
+ /**
21
+ * What an organization slug may look like: a DNS label, lowercase.
22
+ *
23
+ * The constraint is not cosmetic. The same slug is used to compose hostnames, Kubernetes object
24
+ * names and OIDC client ids, so anything that would need sanitising before it could address one of
25
+ * those is rejected at the point it is chosen instead — a slug that survives this pattern passes
26
+ * through every downstream name unchanged.
27
+ */
28
+ export const ENTITY_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{1,61}[a-z0-9])?$/;
10
29
  export const authApi = {
11
30
  profile: {
12
31
  base: 'api:profile',
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAA;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAA;AAE9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAA;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAA;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAA;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAA;AAEhD,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAA;AAErC,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO,EAAE;QACP,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE,0BAA0B;KACvC;IACD,MAAM,EAAE;QACN,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,gBAAgB;QACrB,OAAO,EAAE;YACP,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,yBAAyB;YAC/B,IAAI,EAAE,yBAAyB;SAChC;KACF;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,mBAAmB;KAC9B;CACF,CAAA"}
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAA;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAA;AAE9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAA;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAA;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAA;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,CAAA;AAEhD,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAA;AAErC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA;AAEhD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,wCAAwC,CAAA;AAE3E,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO,EAAE;QACP,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE,0BAA0B;KACvC;IACD,MAAM,EAAE;QACN,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,gBAAgB;QACrB,OAAO,EAAE;YACP,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,yBAAyB;YAC/B,IAAI,EAAE,yBAAyB;SAChC;KACF;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,mBAAmB;KAC9B;CACF,CAAA"}
@@ -0,0 +1,43 @@
1
+ import type { AbstractRequest, ResolvedEntity } from '@owlmeans/entrypoint';
2
+ import type { BasicContext } from '@owlmeans/context';
3
+ /**
4
+ * The value a handler should store and query organization-scoped records by.
5
+ *
6
+ * Prefers the entity's stable id, which is the whole point of resolving one: records keyed by it
7
+ * survive a rename untouched. Falls back to the slug on the token for deployments that register no
8
+ * resolver — there the slug IS the only identifier the system has, and refusing to serve them
9
+ * would break every installation backed by an external IAM.
10
+ *
11
+ * Never use this to compose a user-facing name (a hostname, a display label). Those want the
12
+ * current slug, `req.entity?.slug`, precisely because it can change.
13
+ */
14
+ export declare const entityKeyOf: (req: AbstractRequest) => string | undefined;
15
+ /**
16
+ * `entityKeyOf` for handlers that cannot proceed without an organization.
17
+ *
18
+ * @throws {AuthorizationError} when the request carries no organization at all.
19
+ */
20
+ export declare const requireEntityKey: (req: AbstractRequest) => string;
21
+ /**
22
+ * The full resolved entity, for handlers that need the slug or the frozen key as well as the id.
23
+ *
24
+ * @throws {AuthorizationError} when no resolver is registered or the entity did not resolve.
25
+ */
26
+ export declare const requireEntity: (req: AbstractRequest) => ResolvedEntity;
27
+ /**
28
+ * Resolve the organization a just-authenticated request acts for, and attach it.
29
+ *
30
+ * Called wherever authentication is ESTABLISHED — the HTTP boundary, and any socket that
31
+ * authenticates on its own once the connection is already open. Both need it for the same reason:
32
+ * the token names the organization by a slug that can move, while everything downstream keys on
33
+ * the record. A path that authenticates without calling this leaves `request.entity` empty, and
34
+ * its handlers quietly fall back to comparing a slug against stored ids — which surfaces as "this
35
+ * project does not exist" rather than as a missing resolution, and costs an afternoon to find.
36
+ *
37
+ * A no-op when no resolver is registered: such a deployment has no organization store, and the
38
+ * slug is the only identifier it has.
39
+ *
40
+ * @throws {AuthenFailed} when the token names an organization that cannot be resolved.
41
+ */
42
+ export declare const attachEntity: (context: BasicContext<any>, request: AbstractRequest) => Promise<ResolvedEntity | undefined>;
43
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKrD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,QAAS,eAAe,KAAG,MAAM,GAAG,SAClB,CAAA;AAE1C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAS,eAAe,KAAG,MAOvD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAS,eAAe,KAAG,cAMpD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,YACd,YAAY,CAAC,GAAG,CAAC,WAAW,eAAe,KACnD,OAAO,CAAC,cAAc,GAAG,SAAS,CAiBpC,CAAA"}
@@ -0,0 +1,68 @@
1
+ import { AuthenFailed, AuthorizationError, entitySlugOf } from '@owlmeans/auth';
2
+ import { ENTITY_RESOLVER } from './consts.js';
3
+ /**
4
+ * The value a handler should store and query organization-scoped records by.
5
+ *
6
+ * Prefers the entity's stable id, which is the whole point of resolving one: records keyed by it
7
+ * survive a rename untouched. Falls back to the slug on the token for deployments that register no
8
+ * resolver — there the slug IS the only identifier the system has, and refusing to serve them
9
+ * would break every installation backed by an external IAM.
10
+ *
11
+ * Never use this to compose a user-facing name (a hostname, a display label). Those want the
12
+ * current slug, `req.entity?.slug`, precisely because it can change.
13
+ */
14
+ export const entityKeyOf = (req) => req.entity?.id ?? entitySlugOf(req.auth);
15
+ /**
16
+ * `entityKeyOf` for handlers that cannot proceed without an organization.
17
+ *
18
+ * @throws {AuthorizationError} when the request carries no organization at all.
19
+ */
20
+ export const requireEntityKey = (req) => {
21
+ const key = entityKeyOf(req);
22
+ if (key == null || key === '') {
23
+ throw new AuthorizationError();
24
+ }
25
+ return key;
26
+ };
27
+ /**
28
+ * The full resolved entity, for handlers that need the slug or the frozen key as well as the id.
29
+ *
30
+ * @throws {AuthorizationError} when no resolver is registered or the entity did not resolve.
31
+ */
32
+ export const requireEntity = (req) => {
33
+ if (req.entity == null) {
34
+ throw new AuthorizationError();
35
+ }
36
+ return req.entity;
37
+ };
38
+ /**
39
+ * Resolve the organization a just-authenticated request acts for, and attach it.
40
+ *
41
+ * Called wherever authentication is ESTABLISHED — the HTTP boundary, and any socket that
42
+ * authenticates on its own once the connection is already open. Both need it for the same reason:
43
+ * the token names the organization by a slug that can move, while everything downstream keys on
44
+ * the record. A path that authenticates without calling this leaves `request.entity` empty, and
45
+ * its handlers quietly fall back to comparing a slug against stored ids — which surfaces as "this
46
+ * project does not exist" rather than as a missing resolution, and costs an afternoon to find.
47
+ *
48
+ * A no-op when no resolver is registered: such a deployment has no organization store, and the
49
+ * slug is the only identifier it has.
50
+ *
51
+ * @throws {AuthenFailed} when the token names an organization that cannot be resolved.
52
+ */
53
+ export const attachEntity = async (context, request) => {
54
+ const slug = entitySlugOf(request.auth);
55
+ if (slug == null || !context.hasService(ENTITY_RESOLVER)) {
56
+ return undefined;
57
+ }
58
+ const entity = await context.service(ENTITY_RESOLVER).resolve(slug);
59
+ if (entity == null) {
60
+ throw new AuthenFailed('entity');
61
+ }
62
+ // Canonicalize: a request that arrived under a retired slug continues under the current one, so
63
+ // nothing echoing the value back can re-publish a name the organization has dropped.
64
+ request.auth.entitySlug = entity.slug;
65
+ request.entity = entity;
66
+ return entity;
67
+ };
68
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../src/entity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAoB,EAAsB,EAAE,CACtE,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAoB,EAAU,EAAE;IAC/D,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QAC9B,MAAM,IAAI,kBAAkB,EAAE,CAAA;IAChC,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAoB,EAAkB,EAAE;IACpE,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,kBAAkB,EAAE,CAAA;IAChC,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAA;AACnB,CAAC,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,OAA0B,EAAE,OAAwB,EACf,EAAE;IACvC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACvC,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACzD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAwB,eAAe,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1F,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAA;IAClC,CAAC;IAED,gGAAgG;IAChG,qFAAqF;IACrF,OAAO,CAAC,IAAK,CAAC,UAAU,GAAG,MAAM,CAAC,IAAI,CAAA;IACtC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;IAEvB,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
@@ -89,7 +89,7 @@ export const makeBasicEd25519Guard = (resource, opts) => {
89
89
  token: authorization,
90
90
  userId: trusted.user.id,
91
91
  profileId: trusted.user.id,
92
- entityId: trusted.user.entityId,
92
+ entitySlug: trusted.user.entitySlug,
93
93
  scopes: trusted.user.name != null ? [trusted.user.name] : [],
94
94
  type: AuthroizationType.Ed25519BasicSignature,
95
95
  source: context.cfg.service,
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,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CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":""}
package/build/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export type * from './types.js';
2
+ export * from './schemas.js';
2
3
  export * from './modules.js';
3
4
  export * from './consts.js';
5
+ export * from './entity.js';
4
6
  export * from './middleware.js';
5
7
  export * from './guards/index.js';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAE/B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAE/B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
package/build/index.js CHANGED
@@ -1,5 +1,7 @@
1
+ export * from './schemas.js';
1
2
  export * from './modules.js';
2
3
  export * from './consts.js';
4
+ export * from './entity.js';
3
5
  export * from './middleware.js';
4
6
  export * from './guards/index.js';
5
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO,mDAuBnB,CAAA;AAED,eAAO,MAAM,cAAc,mDAW1B,CAAA"}
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,mDAkCnB,CAAA;AAED,eAAO,MAAM,cAAc,mDAW1B,CAAA"}
package/build/modules.js CHANGED
@@ -1,8 +1,9 @@
1
- import { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, AllowanceRequestSchema, AuthCredentialsSchema, AuthTokenSchema, CAUTHEN, CAUTHEN_AUTHEN, CAUTHEN_AUTHEN_DEFAULT, CAUTHEN_AUTHEN_TYPED, DISPATCHER, DISPATCHER_AUTHEN, OptionalAuthTokenSchema, CAUTHEN_FLOW_ENTER } from '@owlmeans/auth';
1
+ import { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, AllowanceRequestSchema, AuthCredentialsSchema, AuthTokenSchema, CAUTHEN, CAUTHEN_AUTHEN, CAUTHEN_AUTHEN_DEFAULT, CAUTHEN_AUTHEN_TYPED, DISPATCHER, DISPATCHER_AUTHEN, DISPATCHER_SURROGATE, OptionalAuthTokenSchema, CAUTHEN_FLOW_ENTER } from '@owlmeans/auth';
2
2
  // import { AppType } from '@owlmeans/context'
3
3
  import { body, filter, entrypoint, query } from '@owlmeans/entrypoint';
4
4
  import { route, RouteMethod, frontend, backend, socket } from '@owlmeans/route';
5
- import { DISPATCHER_PATH, WEB_API, authApi } from './consts.js';
5
+ import { DISPATCHER_PATH, SURROGATE_PATH, WEB_API, authApi } from './consts.js';
6
+ import { SurrogateQuerySchema } from './schemas.js';
6
7
  export const modules = [
7
8
  entrypoint(route(AUTHEN, '/authentication', backend())),
8
9
  entrypoint(route(AUTHEN_INIT, '/init', backend(AUTHEN, RouteMethod.POST)), filter(body(AllowanceRequestSchema))),
@@ -21,6 +22,14 @@ export const modules = [
21
22
  // It's required here cause every web app needs dispatcher route to authorize
22
23
  // rediected users.
23
24
  filter(query(AuthTokenSchema), { sticky: true })),
25
+ // The login window an embedded application opens one level up.
26
+ //
27
+ // Top level and with no parent, so it renders outside every application layout — a popup must
28
+ // never show the application, with its navigation, inside itself. Sticky for the same reason the
29
+ // dispatcher is: it must attach to the client router regardless of service selection. It carries
30
+ // no `service`, unlike the dispatcher, because nothing server-side ever addresses it — the
31
+ // provider's callback goes to the dispatcher. And no guard: it is where a signed-out user lands.
32
+ entrypoint(route(DISPATCHER_SURROGATE, SURROGATE_PATH, frontend()), filter(query(SurrogateQuerySchema), { sticky: true })),
24
33
  // This is a helper route that representes a API endpoint of service provider that wants to authenticate
25
34
  // a user with OwlMeans server-auth library.
26
35
  entrypoint(route(DISPATCHER_AUTHEN, '/authenticate', backend(null, RouteMethod.POST)), filter(body(AuthTokenSchema))),
@@ -1 +1 @@
1
- {"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,qBAAqB,EAC9F,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,UAAU,EAClG,iBAAiB,EAAE,uBAAuB,EAAE,kBAAkB,EAC/D,MAAM,gBAAgB,CAAA;AACvB,8CAA8C;AAC9C,OAAO,E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eAAe,CAAC,CAAC,CAAC;CACtH,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAClF,UAAU,CAAC,KAAK,CACd,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,eAAe,EAC3C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAChD,CAAC;IACF,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5E,UAAU,CAAC,KAAK,CACd,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,EAClC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAC7C,CAAC;CACH,CAAA;AAED,mCAAmC;AACnC,oDAAoD;AACpD,iGAAiG;AACjG,gCAAgC"}
@@ -0,0 +1,16 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+ /**
3
+ * What the surrogate login window is told about why it was opened.
4
+ *
5
+ * Every field is optional: the window must render something sensible when opened by hand, or by an
6
+ * older build that knew none of these parameters. `next` carries the address to run once the
7
+ * window is one level up, so the flow parameters the opener's URL held are forwarded rather than
8
+ * silently dropped.
9
+ */
10
+ export interface SurrogateQuery {
11
+ intent?: string;
12
+ next?: string;
13
+ method?: string;
14
+ }
15
+ export declare const SurrogateQuerySchema: JSONSchemaType<SurrogateQuery>;
16
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAEzC;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,cAAc,CAQ/D,CAAA"}
@@ -0,0 +1,10 @@
1
+ export const SurrogateQuerySchema = {
2
+ type: 'object',
3
+ properties: {
4
+ intent: { type: 'string', maxLength: 32, nullable: true },
5
+ next: { type: 'string', maxLength: 2048, nullable: true },
6
+ method: { type: 'string', maxLength: 128, nullable: true },
7
+ },
8
+ additionalProperties: true,
9
+ };
10
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,MAAM,oBAAoB,GAAmC;IAClE,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;QACzD,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;QACzD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC3D;IACD,oBAAoB,EAAE,IAAI;CAC3B,CAAA"}
package/build/types.d.ts CHANGED
@@ -29,6 +29,57 @@ export interface ProfileToEntityIdRequest {
29
29
  profileId: string;
30
30
  }
31
31
  export interface ProfileToEntityIdResponse {
32
- entityId: string;
32
+ entitySlug: string;
33
+ }
34
+ /**
35
+ * An organization entity: one immutable id, one renameable slug, and the trail of slugs it used to
36
+ * answer to.
37
+ *
38
+ * `formerSlugs` is what makes a rename survivable rather than merely possible. Tokens minted before
39
+ * the rename keep arriving until they expire, and third-party systems keep quoting the old value
40
+ * indefinitely; resolving a former slug to the same entity is how both keep working without anyone
41
+ * reissuing anything.
42
+ */
43
+ export interface OrgEntityRef {
44
+ id: string;
45
+ slug: string;
46
+ formerSlugs?: string[];
47
+ /** Frozen identifier for systems whose names cannot be rewritten. See `ResolvedEntity.iamKey`. */
48
+ iamKey: string;
49
+ }
50
+ /**
51
+ * Resolves the renameable slug on a token to the stable entity it names.
52
+ *
53
+ * Registered only by implementations that actually store organizations. Basic auth deliberately
54
+ * does not define what an entity id is — a deployment backed by an external IAM has no such record
55
+ * and registers nothing, and every consumer must therefore treat an unresolved entity as ordinary
56
+ * rather than exceptional.
57
+ */
58
+ export interface EntityResolverService extends InitializedService {
59
+ /**
60
+ * Find an entity by any name it has ever answered to: its id, its current slug, a former slug,
61
+ * or its frozen `iamKey`. Ids win over slugs, so a slug that collides with some other entity's
62
+ * id can never shadow it.
63
+ */
64
+ resolve: (value: string) => Promise<OrgEntityRef | null>;
65
+ byId: (id: string) => Promise<OrgEntityRef | null>;
66
+ /** Mint an unused slug. Uniqueness is settled against the store, not by entropy. */
67
+ mintSlug: () => Promise<string>;
68
+ /**
69
+ * Point the entity at a new slug, retiring the old one into `formerSlugs`.
70
+ *
71
+ * This is the whole cost of a rename: nothing else in any store is touched, because nothing else
72
+ * keys on the slug.
73
+ */
74
+ rename: (id: string, slug: string) => Promise<OrgEntityRef>;
75
+ /**
76
+ * Read — or, on first ask, mint and persist — a name this entity is known by in a system that
77
+ * cannot be renamed later (a namespace, a bucket prefix, a realm).
78
+ *
79
+ * Minting through the entity record rather than deriving the name on demand is what lets the
80
+ * slug move afterwards: the derivation happens once, the result is what everything addresses,
81
+ * and a later rename leaves the live resource alone.
82
+ */
83
+ mintName: (id: string, key: string, mint: (entity: OrgEntityRef) => string) => Promise<string>;
33
84
  }
34
85
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d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AK,OAAO,CAAC,YAAY,CAAC,CAAA;IAC3D;;;;;;;OAOG;IACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC/F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/auth-common",
3
- "version": "0.1.18-rc.7",
3
+ "version": "0.1.18-rc.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -29,20 +29,20 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@owlmeans/auth": "^0.1.18-rc.6",
33
- "@owlmeans/auth-common": "^0.1.18-rc.7",
34
- "@owlmeans/basic-ids": "^0.1.18-rc.6",
35
- "@owlmeans/basic-keys": "^0.1.18-rc.7",
36
- "@owlmeans/client-entrypoint": "^0.1.18-rc.7",
32
+ "@owlmeans/auth": "^0.1.18-rc.7",
33
+ "@owlmeans/auth-common": "^0.1.18-rc.9",
34
+ "@owlmeans/basic-ids": "^0.1.18-rc.7",
35
+ "@owlmeans/basic-keys": "^0.1.18-rc.9",
36
+ "@owlmeans/client-entrypoint": "^0.1.18-rc.9",
37
37
  "@owlmeans/context": "^0.1.18-rc.6",
38
- "@owlmeans/entrypoint": "^0.1.18-rc.7",
38
+ "@owlmeans/entrypoint": "^0.1.18-rc.8",
39
39
  "@owlmeans/resource": "^0.1.18-rc.7",
40
40
  "@owlmeans/route": "^0.1.18-rc.6"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@owlmeans/dep-config": "workspace:*",
44
- "@owlmeans/test-auth": "^0.1.18-rc.7",
45
- "@types/bun": "^1.3.14",
44
+ "@owlmeans/test-auth": "^0.1.18-rc.9",
45
+ "@types/bun": "^1.4.0",
46
46
  "nodemon": "^3.1.14",
47
47
  "typescript": "^7.0.2"
48
48
  },
package/src/consts.ts CHANGED
@@ -8,6 +8,15 @@ export const RELY_ACTION_TIMEOUT = 600
8
8
 
9
9
  export const DISPATCHER_PATH = '/dispatcher'
10
10
 
11
+ /**
12
+ * Where the surrogate login window runs.
13
+ *
14
+ * Reserved exactly like {@link DISPATCHER_PATH}: an application must not declare a route of its
15
+ * own here, and a code generator must not produce one. It is user-visible — it is what the popup's
16
+ * address bar shows.
17
+ */
18
+ export const SURROGATE_PATH = '/surrogate'
19
+
11
20
  export const DEF_AUTH_SRV = 'auth'
12
21
 
13
22
  export const DEFAULT_GUARD = DEF_AUTH_SRV
@@ -16,6 +25,19 @@ export const TOKEN_UPDATE = 'auth-token-refresh'
16
25
 
17
26
  export const WEB_API = 'web-auth-api'
18
27
 
28
+ /** Service alias of the organization-entity resolver, when an implementation registers one. */
29
+ export const ENTITY_RESOLVER = 'entity-resolver'
30
+
31
+ /**
32
+ * What an organization slug may look like: a DNS label, lowercase.
33
+ *
34
+ * The constraint is not cosmetic. The same slug is used to compose hostnames, Kubernetes object
35
+ * names and OIDC client ids, so anything that would need sanitising before it could address one of
36
+ * those is rejected at the point it is chosen instead — a slug that survives this pattern passes
37
+ * through every downstream name unchanged.
38
+ */
39
+ export const ENTITY_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{1,61}[a-z0-9])?$/
40
+
19
41
  export const authApi = {
20
42
  profile: {
21
43
  base: 'api:profile',
package/src/entity.ts ADDED
@@ -0,0 +1,82 @@
1
+ import type { AbstractRequest, ResolvedEntity } from '@owlmeans/entrypoint'
2
+ import type { BasicContext } from '@owlmeans/context'
3
+ import { AuthenFailed, AuthorizationError, entitySlugOf } from '@owlmeans/auth'
4
+ import type { EntityResolverService } from './types.js'
5
+ import { ENTITY_RESOLVER } from './consts.js'
6
+
7
+ /**
8
+ * The value a handler should store and query organization-scoped records by.
9
+ *
10
+ * Prefers the entity's stable id, which is the whole point of resolving one: records keyed by it
11
+ * survive a rename untouched. Falls back to the slug on the token for deployments that register no
12
+ * resolver — there the slug IS the only identifier the system has, and refusing to serve them
13
+ * would break every installation backed by an external IAM.
14
+ *
15
+ * Never use this to compose a user-facing name (a hostname, a display label). Those want the
16
+ * current slug, `req.entity?.slug`, precisely because it can change.
17
+ */
18
+ export const entityKeyOf = (req: AbstractRequest): string | undefined =>
19
+ req.entity?.id ?? entitySlugOf(req.auth)
20
+
21
+ /**
22
+ * `entityKeyOf` for handlers that cannot proceed without an organization.
23
+ *
24
+ * @throws {AuthorizationError} when the request carries no organization at all.
25
+ */
26
+ export const requireEntityKey = (req: AbstractRequest): string => {
27
+ const key = entityKeyOf(req)
28
+ if (key == null || key === '') {
29
+ throw new AuthorizationError()
30
+ }
31
+
32
+ return key
33
+ }
34
+
35
+ /**
36
+ * The full resolved entity, for handlers that need the slug or the frozen key as well as the id.
37
+ *
38
+ * @throws {AuthorizationError} when no resolver is registered or the entity did not resolve.
39
+ */
40
+ export const requireEntity = (req: AbstractRequest): ResolvedEntity => {
41
+ if (req.entity == null) {
42
+ throw new AuthorizationError()
43
+ }
44
+
45
+ return req.entity
46
+ }
47
+
48
+ /**
49
+ * Resolve the organization a just-authenticated request acts for, and attach it.
50
+ *
51
+ * Called wherever authentication is ESTABLISHED — the HTTP boundary, and any socket that
52
+ * authenticates on its own once the connection is already open. Both need it for the same reason:
53
+ * the token names the organization by a slug that can move, while everything downstream keys on
54
+ * the record. A path that authenticates without calling this leaves `request.entity` empty, and
55
+ * its handlers quietly fall back to comparing a slug against stored ids — which surfaces as "this
56
+ * project does not exist" rather than as a missing resolution, and costs an afternoon to find.
57
+ *
58
+ * A no-op when no resolver is registered: such a deployment has no organization store, and the
59
+ * slug is the only identifier it has.
60
+ *
61
+ * @throws {AuthenFailed} when the token names an organization that cannot be resolved.
62
+ */
63
+ export const attachEntity = async (
64
+ context: BasicContext<any>, request: AbstractRequest
65
+ ): Promise<ResolvedEntity | undefined> => {
66
+ const slug = entitySlugOf(request.auth)
67
+ if (slug == null || !context.hasService(ENTITY_RESOLVER)) {
68
+ return undefined
69
+ }
70
+
71
+ const entity = await context.service<EntityResolverService>(ENTITY_RESOLVER).resolve(slug)
72
+ if (entity == null) {
73
+ throw new AuthenFailed('entity')
74
+ }
75
+
76
+ // Canonicalize: a request that arrived under a retired slug continues under the current one, so
77
+ // nothing echoing the value back can re-publish a name the organization has dropped.
78
+ request.auth!.entitySlug = entity.slug
79
+ request.entity = entity
80
+
81
+ return entity
82
+ }
@@ -120,7 +120,7 @@ export const makeBasicEd25519Guard = (resource: string, opts?: BasicEd25519Guard
120
120
  token: authorization,
121
121
  userId: trusted.user.id,
122
122
  profileId: trusted.user.id,
123
- entityId: trusted.user.entityId,
123
+ entitySlug: trusted.user.entitySlug,
124
124
  scopes: trusted.user.name != null ? [trusted.user.name] : [],
125
125
  type: AuthroizationType.Ed25519BasicSignature,
126
126
  source: context.cfg.service,
package/src/helper.ts ADDED
File without changes
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export type * from './types.js'
2
2
 
3
+ export * from './schemas.js'
3
4
  export * from './modules.js'
4
5
  export * from './consts.js'
6
+ export * from './entity.js'
5
7
  export * from './middleware.js'
6
8
  export * from './guards/index.js'
package/src/modules.ts CHANGED
@@ -2,12 +2,13 @@
2
2
  import {
3
3
  AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, AllowanceRequestSchema, AuthCredentialsSchema,
4
4
  AuthTokenSchema, CAUTHEN, CAUTHEN_AUTHEN, CAUTHEN_AUTHEN_DEFAULT, CAUTHEN_AUTHEN_TYPED, DISPATCHER,
5
- DISPATCHER_AUTHEN, OptionalAuthTokenSchema, CAUTHEN_FLOW_ENTER
5
+ DISPATCHER_AUTHEN, DISPATCHER_SURROGATE, OptionalAuthTokenSchema, CAUTHEN_FLOW_ENTER
6
6
  } from '@owlmeans/auth'
7
7
  // import { AppType } from '@owlmeans/context'
8
8
  import { body, filter, entrypoint, query } from '@owlmeans/entrypoint'
9
9
  import { route, RouteMethod, frontend, backend, socket } from '@owlmeans/route'
10
- import { DISPATCHER_PATH, WEB_API, authApi } from './consts.js'
10
+ import { DISPATCHER_PATH, SURROGATE_PATH, WEB_API, authApi } from './consts.js'
11
+ import { SurrogateQuerySchema } from './schemas.js'
11
12
 
12
13
  export const modules = [
13
14
  entrypoint(route(AUTHEN, '/authentication', backend())),
@@ -29,6 +30,17 @@ export const modules = [
29
30
  // rediected users.
30
31
  filter(query(AuthTokenSchema), { sticky: true })
31
32
  ),
33
+ // The login window an embedded application opens one level up.
34
+ //
35
+ // Top level and with no parent, so it renders outside every application layout — a popup must
36
+ // never show the application, with its navigation, inside itself. Sticky for the same reason the
37
+ // dispatcher is: it must attach to the client router regardless of service selection. It carries
38
+ // no `service`, unlike the dispatcher, because nothing server-side ever addresses it — the
39
+ // provider's callback goes to the dispatcher. And no guard: it is where a signed-out user lands.
40
+ entrypoint(
41
+ route(DISPATCHER_SURROGATE, SURROGATE_PATH, frontend()),
42
+ filter(query(SurrogateQuerySchema), { sticky: true })
43
+ ),
32
44
  // This is a helper route that representes a API endpoint of service provider that wants to authenticate
33
45
  // a user with OwlMeans server-auth library.
34
46
  entrypoint(route(DISPATCHER_AUTHEN, '/authenticate', backend(null, RouteMethod.POST)), filter(body(AuthTokenSchema))),
package/src/schemas.ts ADDED
@@ -0,0 +1,25 @@
1
+ import type { JSONSchemaType } from 'ajv'
2
+
3
+ /**
4
+ * What the surrogate login window is told about why it was opened.
5
+ *
6
+ * Every field is optional: the window must render something sensible when opened by hand, or by an
7
+ * older build that knew none of these parameters. `next` carries the address to run once the
8
+ * window is one level up, so the flow parameters the opener's URL held are forwarded rather than
9
+ * silently dropped.
10
+ */
11
+ export interface SurrogateQuery {
12
+ intent?: string
13
+ next?: string
14
+ method?: string
15
+ }
16
+
17
+ export const SurrogateQuerySchema: JSONSchemaType<SurrogateQuery> = {
18
+ type: 'object',
19
+ properties: {
20
+ intent: { type: 'string', maxLength: 32, nullable: true },
21
+ next: { type: 'string', maxLength: 2048, nullable: true },
22
+ method: { type: 'string', maxLength: 128, nullable: true },
23
+ },
24
+ additionalProperties: true,
25
+ }
package/src/types.ts CHANGED
@@ -42,5 +42,58 @@ export interface ProfileToEntityIdRequest {
42
42
  }
43
43
 
44
44
  export interface ProfileToEntityIdResponse {
45
- entityId: string
45
+ entitySlug: string
46
+ }
47
+
48
+ /**
49
+ * An organization entity: one immutable id, one renameable slug, and the trail of slugs it used to
50
+ * answer to.
51
+ *
52
+ * `formerSlugs` is what makes a rename survivable rather than merely possible. Tokens minted before
53
+ * the rename keep arriving until they expire, and third-party systems keep quoting the old value
54
+ * indefinitely; resolving a former slug to the same entity is how both keep working without anyone
55
+ * reissuing anything.
56
+ */
57
+ export interface OrgEntityRef {
58
+ id: string
59
+ slug: string
60
+ formerSlugs?: string[]
61
+ /** Frozen identifier for systems whose names cannot be rewritten. See `ResolvedEntity.iamKey`. */
62
+ iamKey: string
63
+ }
64
+
65
+ /**
66
+ * Resolves the renameable slug on a token to the stable entity it names.
67
+ *
68
+ * Registered only by implementations that actually store organizations. Basic auth deliberately
69
+ * does not define what an entity id is — a deployment backed by an external IAM has no such record
70
+ * and registers nothing, and every consumer must therefore treat an unresolved entity as ordinary
71
+ * rather than exceptional.
72
+ */
73
+ export interface EntityResolverService extends InitializedService {
74
+ /**
75
+ * Find an entity by any name it has ever answered to: its id, its current slug, a former slug,
76
+ * or its frozen `iamKey`. Ids win over slugs, so a slug that collides with some other entity's
77
+ * id can never shadow it.
78
+ */
79
+ resolve: (value: string) => Promise<OrgEntityRef | null>
80
+ byId: (id: string) => Promise<OrgEntityRef | null>
81
+ /** Mint an unused slug. Uniqueness is settled against the store, not by entropy. */
82
+ mintSlug: () => Promise<string>
83
+ /**
84
+ * Point the entity at a new slug, retiring the old one into `formerSlugs`.
85
+ *
86
+ * This is the whole cost of a rename: nothing else in any store is touched, because nothing else
87
+ * keys on the slug.
88
+ */
89
+ rename: (id: string, slug: string) => Promise<OrgEntityRef>
90
+ /**
91
+ * Read — or, on first ask, mint and persist — a name this entity is known by in a system that
92
+ * cannot be renamed later (a namespace, a bucket prefix, a realm).
93
+ *
94
+ * Minting through the entity record rather than deriving the name on demand is what lets the
95
+ * slug move afterwards: the derivation happens once, the result is what everything addresses,
96
+ * and a later rename leaves the live resource alone.
97
+ */
98
+ mintName: (id: string, key: string, mint: (entity: OrgEntityRef) => string) => Promise<string>
46
99
  }