@owlmeans/auth-common 0.1.18-rc.45 → 0.1.18-rc.47

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 (53) hide show
  1. package/README.md +2 -2
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/auth-common/SKILL.md +27 -24
  4. package/build/entity/types.d.ts +52 -0
  5. package/build/entity/types.d.ts.map +1 -0
  6. package/build/entity/types.js +2 -0
  7. package/build/entity/types.js.map +1 -0
  8. package/build/entity.d.ts +5 -43
  9. package/build/entity.d.ts.map +1 -1
  10. package/build/entity.js +43 -76
  11. package/build/entity.js.map +1 -1
  12. package/build/entrypoints.d.ts +4 -4
  13. package/build/entrypoints.d.ts.map +1 -1
  14. package/build/entrypoints.js.map +1 -1
  15. package/build/guards/basic-ed25519/consts.local.d.ts +3 -0
  16. package/build/guards/basic-ed25519/consts.local.d.ts.map +1 -0
  17. package/build/guards/basic-ed25519/consts.local.js +4 -0
  18. package/build/guards/basic-ed25519/consts.local.js.map +1 -0
  19. package/build/guards/basic-ed25519/service.d.ts.map +1 -1
  20. package/build/guards/basic-ed25519/service.js +2 -3
  21. package/build/guards/basic-ed25519/service.js.map +1 -1
  22. package/build/index.d.ts +1 -0
  23. package/build/index.d.ts.map +1 -1
  24. package/build/index.js.map +1 -1
  25. package/build/middleware.d.ts +1 -1
  26. package/build/middleware.d.ts.map +1 -1
  27. package/build/middleware.js +2 -2
  28. package/build/middleware.js.map +1 -1
  29. package/build/schemas.d.ts +1 -13
  30. package/build/schemas.d.ts.map +1 -1
  31. package/build/schemas.js.map +1 -1
  32. package/build/types.d.ts +13 -0
  33. package/build/types.d.ts.map +1 -1
  34. package/build/types.local.d.ts +5 -0
  35. package/build/types.local.d.ts.map +1 -0
  36. package/build/types.local.js +2 -0
  37. package/build/types.local.js.map +1 -0
  38. package/build/utils/trusted.js +2 -2
  39. package/build/utils/trusted.js.map +1 -1
  40. package/package.json +12 -12
  41. package/src/entity/types.ts +52 -0
  42. package/src/entity.ts +49 -77
  43. package/src/entrypoints.ts +2 -7
  44. package/src/guards/basic-ed25519/consts.local.ts +4 -0
  45. package/src/guards/basic-ed25519/service.ts +2 -7
  46. package/src/index.ts +1 -0
  47. package/src/middleware.ts +4 -8
  48. package/src/schemas.ts +1 -14
  49. package/src/types.local.ts +5 -0
  50. package/src/types.ts +14 -0
  51. package/src/utils/trusted.ts +2 -2
  52. package/tests/basic-ed25519.spec.ts +2 -2
  53. package/tests/entity.spec.ts +9 -9
package/README.md CHANGED
@@ -12,7 +12,7 @@ Predefined authentication protocols, guards, and constants shared between server
12
12
  ## Installation
13
13
 
14
14
  ```bash
15
- bun add @owlmeans/auth-common@^0.1.18-rc.45
15
+ bun add @owlmeans/auth-common@^0.1.18-rc.47
16
16
  ```
17
17
 
18
18
  ## Usage
@@ -98,7 +98,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
98
98
  your project's skill store (`.agents/skills/`):
99
99
 
100
100
  ```sh
101
- npx @owlmeans/agent-skills@^0.1.18-rc.47
101
+ npx @owlmeans/agent-skills@^0.1.18-rc.49
102
102
  ```
103
103
 
104
104
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/auth-common",
4
- "version": "0.1.18-rc.45",
5
- "generatedAt": "2026-10-03T20:05:07.589Z",
4
+ "version": "0.1.18-rc.47",
5
+ "generatedAt": "2026-10-05T21:03:06.382Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: auth-common
3
- description: How to use @owlmeans/auth-common — the auth vocabulary both sides of the wire share, covering guard aliases (DEFAULT_GUARD, GUARD_ED25519), the shared auth protocol trees, the Ed25519 signature guard, the TRUSTED-record trust() helper, and the organization-entity resolver contract (ENTITY_RESOLVER, entityKeyOf, attachEntity). Auto-invoked when importing guard constants, shared auth protocols, or entity-resolution helpers.
3
+ description: How to use @owlmeans/auth-common — the auth vocabulary both sides of the wire share, covering guard aliases (DEFAULT_GUARD, GUARD_ED25519), the shared auth protocol trees, the Ed25519 signature guard, the TRUSTED-record trust() helper, and the organization-entity resolver contract (ENTITY_RESOLVER, makeEntityScope). Auto-invoked when importing guard constants, shared auth protocols, or entity-resolution helpers.
4
4
  user-invocable: false
5
5
  ---
6
6
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
@@ -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.45"` in `dependencies`
11
+ **Install:** `"@owlmeans/auth-common": "^0.1.18-rc.47"` in `dependencies`
12
12
 
13
13
  Everything a server and a browser must agree on to talk authentication: aliases, the shared
14
14
  protocol declarations, the signature guard, and the contract for resolving the organization
@@ -78,32 +78,35 @@ a deployment backed by an external IAM registers none, and every consumer must t
78
78
  entity as ordinary rather than exceptional.
79
79
 
80
80
  ```typescript
81
- import { attachEntity, entityKeyOf, requireEntityKey, requireEntity } from '@owlmeans/auth-common'
81
+ import { makeEntityScope } from '@owlmeans/auth-common'
82
+
83
+ const scope = makeEntityScope(request) // once at the top of a handler, never stored
82
84
  ```
83
85
 
84
86
  | Helper | What it answers |
85
87
  |--------|-----------------|
86
- | `attachEntity(context, request)` | Resolve the slug on `request.auth` and set `request.entity`, canonicalizing a retired slug to the current one. Keeps an entity the guard already attached when its `slug` equals the token's exactly, and drops one that does not. Otherwise a no-op when no resolver is registered; throws `AuthenFailed('entity')` when the token names an organization that will not resolve |
87
- | `entityKeyOf(req)` | The value to store and query organization-scoped records by — `req.entity?.id`, falling back to the token's slug where no resolver exists |
88
- | `requireEntityKey(req)` | Same, throwing `AuthorizationError` when the request carries no organization |
89
- | `requireEntity(req)` | The full `ResolvedEntity` (`id`, `slug`, `iamKey`), throwing `AuthorizationError` when nothing resolved |
90
-
91
- `attachEntity` must be called wherever authentication is **established** — the HTTP boundary, and
92
- any socket that authenticates after its connection is already open. A path that authenticates
93
- without it leaves `request.entity` empty and its handlers silently compare a slug against stored
94
- ids.
95
-
96
- A guard may attach the entity itself when its authority names the organization — the OIDC guard
97
- does for a session of a tenanted client (`@owlmeans/oidc`), whose relying party has no registry to
98
- resolve from. `attachEntity` trusts that attachment only while its `slug` is the token's
99
- `entitySlugOf(request.auth)`; on any mismatch it removes it and resolves as if nothing had been
100
- attached, so a stale or foreign entity can never reach a handler. That attached entity is keyed by
101
- the organization's frozen IAM key (`{ id: entityKey, slug, iamKey: entityKey }`) — the registry's
102
- record id never leaves the provider — so on such a relying party `requireEntityKey(req)` answers the
103
- `entityKey`, which survives a rename exactly as a record id would.
104
-
105
- Never build a user-facing name (a hostname, a display label) from `entityKeyOf`. Those want the
106
- current slug, `req.entity?.slug`.
88
+ | `scope.attachEntity(context)` | Resolve the slug on `request.auth` and set `request.entity`, canonicalizing a retired slug to the current one. Keeps an entity the guard already attached when its `slug` equals the token's exactly, and drops one that does not. Otherwise a no-op when no resolver is registered; throws `AuthenFailed('entity')` when the token names an organization that will not resolve |
89
+ | `scope.entityKeyOf()` | The value to store and query organization-scoped records by — `req.entity?.id`, falling back to the token's slug where no resolver exists |
90
+ | `scope.requireEntityKey()` | Same, throwing `AuthorizationError` when the request carries no organization |
91
+ | `scope.requireEntity()` | The full `ResolvedEntity` (`id`, `slug`, `iamKey`), throwing `AuthorizationError` when nothing resolved |
92
+
93
+ `scope.attachEntity(context)` must be called wherever authentication is **established** — the HTTP
94
+ boundary, and any socket that authenticates after its connection is already open. A path that
95
+ authenticates without it leaves `request.entity` empty and its handlers silently compare a slug
96
+ against stored ids.
97
+
98
+ A guard may attach the entity itself when its authority names the organization — the OIDC guard does
99
+ for a session of a tenanted client (`@owlmeans/oidc`), whose relying party has no registry to
100
+ resolve from. `scope.attachEntity` trusts that attachment only while its `slug` is the token's
101
+ `authHelper.entitySlugOf(request.auth)`; on any mismatch it removes it and resolves as if nothing
102
+ had been attached, so a stale or foreign entity can never reach a handler. That attached entity is
103
+ keyed by the organization's frozen IAM key (`{ id: entityKey, slug, iamKey: entityKey }`) — the
104
+ registry's record id never leaves the provider — so on such a relying party
105
+ `scope.requireEntityKey()` answers the `entityKey`, which survives a rename exactly as a record id
106
+ would.
107
+
108
+ Never build a user-facing name (a hostname, a display label) from `scope.entityKeyOf()`. Those want
109
+ the current slug, `req.entity?.slug`.
107
110
 
108
111
  ## Usage
109
112
 
@@ -0,0 +1,52 @@
1
+ import type { BasicContext } from '@owlmeans/context';
2
+ import type { ResolvedEntity } from '@owlmeans/entrypoint';
3
+ /** The organization entity one request acts for — built once at the top of a handler, never stored. */
4
+ export interface EntityScope {
5
+ /**
6
+ * The value a handler should store and query organization-scoped records by.
7
+ *
8
+ * Prefers the entity's stable id, which is the whole point of resolving one: records keyed by it
9
+ * survive a rename untouched. Falls back to the slug on the token for deployments that register no
10
+ * resolver — there the slug IS the only identifier the system has, and refusing to serve them
11
+ * would break every installation backed by an external IAM.
12
+ *
13
+ * Never use this to compose a user-facing name (a hostname, a display label). Those want the
14
+ * current slug, `req.entity?.slug`, precisely because it can change.
15
+ */
16
+ entityKeyOf: () => string | undefined;
17
+ /**
18
+ * `entityKeyOf` for handlers that cannot proceed without an organization.
19
+ *
20
+ * @throws {AuthorizationError} when the request carries no organization at all.
21
+ */
22
+ requireEntityKey: () => string;
23
+ /**
24
+ * The full resolved entity, for handlers that need the slug or the frozen key as well as the id.
25
+ *
26
+ * @throws {AuthorizationError} when no resolver is registered or the entity did not resolve.
27
+ */
28
+ requireEntity: () => ResolvedEntity;
29
+ /**
30
+ * Resolve the organization a just-authenticated request acts for, and attach it.
31
+ *
32
+ * Called wherever authentication is ESTABLISHED — the HTTP boundary, and any socket that
33
+ * authenticates on its own once the connection is already open. Both need it for the same reason:
34
+ * the token names the organization by a slug that can move, while everything downstream keys on
35
+ * the record. A path that authenticates without calling this leaves `request.entity` empty, and
36
+ * its handlers quietly fall back to comparing a slug against stored ids — which surfaces as "this
37
+ * project does not exist" rather than as a missing resolution, and costs an afternoon to find.
38
+ *
39
+ * An entity the guard already attached is kept while its slug is exactly the token's: a guard
40
+ * whose authority names the organization itself (an OIDC session of a tenanted client) is the only
41
+ * source such a deployment has, because the registry that owns the organization is not its own.
42
+ * One whose slug differs is never trusted — it is dropped, and resolution proceeds as if it had
43
+ * not been there.
44
+ *
45
+ * Otherwise a no-op when no resolver is registered: such a deployment has no organization store,
46
+ * and the slug is the only identifier it has.
47
+ *
48
+ * @throws {AuthenFailed} when the token names an organization that cannot be resolved.
49
+ */
50
+ attachEntity: (context: BasicContext<any>) => Promise<ResolvedEntity | undefined>;
51
+ }
52
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/entity/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,uGAAuG;AACvG,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;OAUG;IACH,WAAW,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACrC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,MAAM,CAAA;IAC9B;;;;OAIG;IACH,aAAa,EAAE,MAAM,cAAc,CAAA;IACnC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAA;CAClF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/entity/types.ts"],"names":[],"mappings":""}
package/build/entity.d.ts CHANGED
@@ -1,49 +1,11 @@
1
1
  import type { AbstractRequest, ResolvedEntity } from '@owlmeans/entrypoint';
2
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
- */
3
+ import type { EntityScope } from './entity/types.js';
4
+ export declare const makeEntityScope: (req: AbstractRequest) => EntityScope;
5
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(req).entityKeyOf()` */
14
6
  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
- */
7
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(req).requireEntityKey()` */
20
8
  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
- * An entity the guard already attached is kept while its slug is exactly the token's: a guard
38
- * whose authority names the organization itself (an OIDC session of a tenanted client) is the only
39
- * source such a deployment has, because the registry that owns the organization is not its own.
40
- * One whose slug differs is never trusted — it is dropped, and resolution proceeds as if it had
41
- * not been there.
42
- *
43
- * Otherwise a no-op when no resolver is registered: such a deployment has no organization store,
44
- * and the slug is the only identifier it has.
45
- *
46
- * @throws {AuthenFailed} when the token names an organization that cannot be resolved.
47
- */
9
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(request).attachEntity(context)` */
48
10
  export declare const attachEntity: (context: BasicContext<any>, request: AbstractRequest) => Promise<ResolvedEntity | undefined>;
49
11
  //# sourceMappingURL=entity.d.ts.map
@@ -1 +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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,YACd,YAAY,CAAC,GAAG,CAAC,WAAW,eAAe,KACnD,OAAO,CAAC,cAAc,GAAG,SAAS,CAwBpC,CAAA"}
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;AAIrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,eAAO,MAAM,eAAe,QAAS,eAAe,KAAG,WAgDtD,CAAA;AAED,qFAAqF;AACrF,eAAO,MAAM,WAAW,QAAS,eAAe,KAAG,MAAM,GAAG,SAA+C,CAAA;AAE3G,0FAA0F;AAC1F,eAAO,MAAM,gBAAgB,QAAS,eAAe,KAAG,MAAiD,CAAA;AAEzG,iGAAiG;AACjG,eAAO,MAAM,YAAY,YACd,YAAY,CAAC,GAAG,CAAC,WAAW,eAAe,KACnD,OAAO,CAAC,cAAc,GAAG,SAAS,CAAyD,CAAA"}
package/build/entity.js CHANGED
@@ -1,80 +1,47 @@
1
- import { AuthenFailed, AuthorizationError, entitySlugOf } from '@owlmeans/auth';
1
+ import { AuthenFailed, AuthorizationError, authHelper } from '@owlmeans/auth';
2
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
- * An entity the guard already attached is kept while its slug is exactly the token's: a guard
49
- * whose authority names the organization itself (an OIDC session of a tenanted client) is the only
50
- * source such a deployment has, because the registry that owns the organization is not its own.
51
- * One whose slug differs is never trusted — it is dropped, and resolution proceeds as if it had
52
- * not been there.
53
- *
54
- * Otherwise a no-op when no resolver is registered: such a deployment has no organization store,
55
- * and the slug is the only identifier it has.
56
- *
57
- * @throws {AuthenFailed} when the token names an organization that cannot be resolved.
58
- */
59
- export const attachEntity = async (context, request) => {
60
- const slug = entitySlugOf(request.auth);
61
- if (request.entity != null) {
62
- if (slug != null && request.entity.slug === slug) {
63
- return request.entity;
3
+ export const makeEntityScope = (req) => {
4
+ const entityKeyOf = () => req.entity?.id ?? authHelper.entitySlugOf(req.auth);
5
+ const requireEntityKey = () => {
6
+ const key = entityKeyOf();
7
+ if (key == null || key === '') {
8
+ throw new AuthorizationError();
9
+ }
10
+ return key;
11
+ };
12
+ const requireEntity = () => {
13
+ if (req.entity == null) {
14
+ throw new AuthorizationError();
15
+ }
16
+ return req.entity;
17
+ };
18
+ const attachEntity = async (context) => {
19
+ const slug = authHelper.entitySlugOf(req.auth);
20
+ if (req.entity != null) {
21
+ if (slug != null && req.entity.slug === slug) {
22
+ return req.entity;
23
+ }
24
+ req.entity = undefined;
25
+ }
26
+ if (slug == null || !context.hasService(ENTITY_RESOLVER)) {
27
+ return undefined;
28
+ }
29
+ const entity = await context.service(ENTITY_RESOLVER).resolve(slug);
30
+ if (entity == null) {
31
+ throw new AuthenFailed('entity');
64
32
  }
65
- request.entity = undefined;
66
- }
67
- if (slug == null || !context.hasService(ENTITY_RESOLVER)) {
68
- return undefined;
69
- }
70
- const entity = await context.service(ENTITY_RESOLVER).resolve(slug);
71
- if (entity == null) {
72
- throw new AuthenFailed('entity');
73
- }
74
- // Canonicalize: a request that arrived under a retired slug continues under the current one, so
75
- // nothing echoing the value back can re-publish a name the organization has dropped.
76
- request.auth.entitySlug = entity.slug;
77
- request.entity = entity;
78
- return entity;
33
+ // Canonicalize: a request that arrived under a retired slug continues under the current one, so
34
+ // nothing echoing the value back can re-publish a name the organization has dropped.
35
+ req.auth.entitySlug = entity.slug;
36
+ req.entity = entity;
37
+ return entity;
38
+ };
39
+ return { entityKeyOf, requireEntityKey, requireEntity, attachEntity };
79
40
  };
41
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(req).entityKeyOf()` */
42
+ export const entityKeyOf = (req) => makeEntityScope(req).entityKeyOf();
43
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(req).requireEntityKey()` */
44
+ export const requireEntityKey = (req) => makeEntityScope(req).requireEntityKey();
45
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(request).attachEntity(context)` */
46
+ export const attachEntity = async (context, request) => await makeEntityScope(request).attachEntity(context);
80
47
  //# sourceMappingURL=entity.js.map
@@ -1 +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,IAA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ACD,GAAG,CAAC,MAAM,GAAG,SAAS,CAAA;QACxB,CAAC;QAED,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;YACzD,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAwB,eAAe,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC1F,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAA;QAClC,CAAC;QAED,gGAAgG;QAChG,qFAAqF;QACrF,GAAG,CAAC,IAAK,CAAC,UAAU,GAAG,MAAM,CAAC,IAAI,CAAA;QAClC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;QAEnB,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAED,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,CAAA;AACvE,CAAC,CAAA;AAED,qFAAqF;AACrF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAoB,EAAsB,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;AAE3G,0FAA0F;AAC1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAoB,EAAU,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,CAAA;AAEzG,iGAAiG;AACjG,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,OAA0B,EAAE,OAAwB,EACf,EAAE,CAAC,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
- import type { AllowanceRequest, AllowanceResponse, AuthCredentials, AuthToken } from '@owlmeans/auth';
2
- import type { SurrogateQuery } from './schemas.js';
1
+ import { type AllowanceRequest, type AllowanceResponse, type AuthCredentials, type AuthToken } from '@owlmeans/auth';
2
+ import type { SurrogateQuery } from './types.js';
3
3
  /** Shared authentication protocols, bound independently by server and browser packages. */
4
4
  export declare const authProtocols: {
5
5
  authen: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
@@ -19,10 +19,10 @@ export declare const authProtocols: {
19
19
  flowEnter: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
20
20
  dispatcher: import("@owlmeans/entrypoint").EntrypointProtocol<{
21
21
  query: AuthToken;
22
- }, undefined>;
22
+ }, unknown>;
23
23
  surrogate: import("@owlmeans/entrypoint").EntrypointProtocol<{
24
24
  query: SurrogateQuery;
25
- }, undefined>;
25
+ }, unknown>;
26
26
  dispatcherAuthenticate: import("@owlmeans/entrypoint").EntrypointProtocol<{
27
27
  body: AuthToken;
28
28
  }, AuthToken>;
@@ -1 +1 @@
1
- {"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAMrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,2FAA2F;AAC3F,eAAO,MAAM,aAAa;IACxB,MAAM;IACN,IAAI;;;IAEJ,YAAY;;;IAEZ,IAAI;;;IAEJ,MAAM;IACN,KAAK;IACL,YAAY;IACZ,UAAU;IACV,SAAS;IACT,UAAU;;;IAYV,SAAS;;;IAOT,sBAAsB;;;CAEvB,CAAA;AAED,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB;IAC3B,OAAO;QACL,IAAI;QACJ,UAAU;;IAKZ,IAAI;QACF,IAAI;QACJ,QAAQ;;CAKX,CAAA"}
1
+ {"version":3,"file":"entrypoints.d.ts","sour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,EAAE,CAAC,CAAC,CAAC;QAC1F,UAAU,EAAE,YAAY,CAAC,KAAK,CAC9B,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,eAAe,EAC3C,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAC9C,CAAC;KACH;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QACpF,QAAQ,EAAE,YAAY,CAAC,KAAK,CAC5B,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,EAClC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAC3C,CAAC;KACH;CACF,CAAA;AAED,uCAAuC;AACvC,4DAA4D;AAC5D,qGAAqG;AACrG,gCAAgC"}
@@ -0,0 +1,3 @@
1
+ export declare const timeKey: string;
2
+ export declare const nonceKey: string;
3
+ //# sourceMappingURL=consts.local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.local.d.ts","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/consts.local.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,QAAyC,CAAA;AAC7D,eAAO,MAAM,QAAQ,QAA0C,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { BED255_NONCE_HEADER, BED255_TIME_HEADER } from './consts.js';
2
+ export const timeKey = BED255_TIME_HEADER.toLocaleLowerCase();
3
+ export const nonceKey = BED255_NONCE_HEADER.toLocaleLowerCase();
4
+ //# sourceMappingURL=consts.local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.local.js","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/consts.local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErE,MAAM,CAAC,MAAM,OAAO,GAAG,kBAAkB,CAAC,iBAAiB,EAAE,CAAA;AAC7D,MAAM,CAAC,MAAM,QAAQ,GAAG,mBAAmB,CAAC,iBAAiB,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/service.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAa7E,eAAO,MAAM,qBAAqB,aAAc,MAAM,SAAS,wBAAwB,KAAG,iBA+IzF,CAAA"}
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/service.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAU7E,eAAO,MAAM,qBAAqB,aAAc,MAAM,SAAS,wBAAwB,KAAG,iBA+IzF,CAAA"}
@@ -1,13 +1,12 @@
1
1
  import { createService } from '@owlmeans/context';
2
2
  import { assertContext } from '@owlmeans/context';
3
- import { BED255_NONCE_HEADER, BED255_TIME_HEADER, BED255_CASHE_RESOURCE, GUARD_ED25519, BED255_SIG_TTL } from './consts.js';
3
+ import { BED255_CASHE_RESOURCE, GUARD_ED25519, BED255_SIG_TTL } from './consts.js';
4
+ import { nonceKey, timeKey } from './consts.local.js';
4
5
  import { trust } from '../../utils/trusted.js';
5
6
  import { AuthenPayloadError, AuthroizationType, AuthRole } from '@owlmeans/auth';
6
7
  import { createIdOfLength } from '@owlmeans/basic-ids';
7
8
  import { extractAuthToken } from '@owlmeans/auth-common/utils';
8
9
  import { makeMemorySignedRequestReplayStore, makeResourceSignedRequestReplayStore } from './replay.js';
9
- const timeKey = BED255_TIME_HEADER.toLocaleLowerCase();
10
- const nonceKey = BED255_NONCE_HEADER.toLocaleLowerCase();
11
10
  export const makeBasicEd25519Guard = (resource, opts) => {
12
11
  const memoryReplay = makeMemorySignedRequestReplayStore();
13
12
  const replay = (context) => {
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EACL,mBAAmB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,aAAa,EAC7E,cAAc,EACf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAG9C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EACL,kCAAkC,EAAE,oCAAoC,EACzE,MAAM,aAAa,CAAA;AAGpB,MAAM,OAAO,GAAG,kBAAkB,CAAC,iBAAiB,EAAE,CAAA;AACtD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,iBAAiB,EAAE,CAAA;AAExD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,IAA+B,EAAqB,EAAE;IAC5G,MAAM,YAAY,GAAG,kCAAkC,EAAE,CAAA;IAEzD,MAAM,MAAM,GAAG,CAAC,OAAgB,EAA4B,EAAE;QAC5D,IAAI,IAAI,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,qBAAqB,CAAA;QAClD,IAAI,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,oCAAoC,CACzC,OAAO,CAAC,Q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B,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU;gBACnC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;gBAC5D,IAAI,EAAE,iBAAiB,CAAC,qBAAqB;gBAC7C,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;gBAC3B;;mBAEG;gBACH,IAAI,EAAE,QAAQ,CAAC,OAAO;gBACtB,MAAM,EAAE,KAAK;gBACb,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC,CAAA;YAEF,OAAO,IAAS,CAAA;QAClB,CAAC;KACF,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE;QACrB,KAAK,CAAC,WAAW,GAAG,IAAI,CAAA;IAC1B,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
package/build/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type * from './types.js';
2
+ export type * from './entity/types.js';
2
3
  export * from './schemas.js';
3
4
  export * from './entrypoints.js';
4
5
  export * from './consts.js';
@@ -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,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,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;AAC/B,mBAAmB,mBAAmB,CAAA;AAEtC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,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":"AAGA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
@@ -1,3 +1,3 @@
1
- import type { Middleware } from '@owlmeans/context';
1
+ import { type Middleware } from '@owlmeans/context';
2
2
  export declare const authMiddleware: Middleware;
3
3
  //# sourceMappingURL=middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAOnD,eAAO,MAAM,cAAc,EAAE,UAuC5B,CAAA"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAA4C,MAAM,mBAAmB,CAAA;AAM7F,eAAO,MAAM,cAAc,EAAE,UAuC5B,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { MiddlewareType, MiddlewareStage, AppType } from '@owlmeans/context';
2
- import { provideRequest } from '@owlmeans/client-entrypoint';
3
2
  import { AUTH_HEADER } from '@owlmeans/auth';
3
+ import { clientRequestHelper } from '@owlmeans/client-entrypoint';
4
4
  export const authMiddleware = {
5
5
  type: MiddlewareType.Context,
6
6
  stage: MiddlewareStage.Loading,
@@ -22,7 +22,7 @@ export const authMiddleware = {
22
22
  // middleware wrapped this entrypoint.
23
23
  const [token] = (await Promise.all(module.getGuards().map(guard => context.service(guard).authenticated(req)))).filter(token => token != null).reverse();
24
24
  if (token != null) {
25
- const _req = req ?? provideRequest(module.alias, module.path());
25
+ const _req = req ?? clientRequestHelper.provideRequest(module.alias, module.path());
26
26
  const headers = (_req.headers ?? {});
27
27
  if (headers[AUTH_HEADER] == null) {
28
28
  headers[AUTH_HEADER] = token;
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAG5C,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,IAAI,EAAE,cAAc,CAAC,OAAO;IAC5B,KAAK,EAAE,eAAe,CAAC,OAAO;IAC9B,KAAK,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;QACrB,OAAO,CAAC,WAAW,EAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC7C,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;gBACzE,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAClC,IAAI,MAAM,CAAC,+BAA+B,KAAK,IAAI,EAAE,CAAC;wBACpD,OAAM;oBACR,CAAC;oBACD,MAAM,CAAC,+BAA+B,GAAG,IAAI,CAAA;oBAC7C,uFAAuF;oBACvF,iEAAiE;oBACjE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;o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,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;4BAC7G,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAuC,CAAA;4BAC1E,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE,CAAC;gCACjC,OAAO,CAAC,WAAW,CAAC,GAAG,KAAK,CAAA;gCAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;gCACtB,GAAG,GAAG,IAAkB,CAAA;4BAC1B,CAAC;wBACH,CAAC;wBAED,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;oBACpB,CAAC,CAAyB,CAAA;gBAE5B,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -1,16 +1,4 @@
1
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
- }
2
+ import type { SurrogateQuery } from './types.js';
15
3
  export declare const SurrogateQuerySchema: JSONSchemaType<SurrogateQuery>;
16
4
  //# sourceMappingURL=schemas.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,cAAc,CAQ/D,CAAA"}
@@ -1 +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"}
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAGA,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
@@ -82,4 +82,17 @@ export interface EntityResolverService extends InitializedService {
82
82
  */
83
83
  mintName: (id: string, key: string, mint: (entity: OrgEntityRef) => string) => Promise<string>;
84
84
  }
85
+ /**
86
+ * What the surrogate login window is told about why it was opened.
87
+ *
88
+ * Every field is optional: the window must render something sensible when opened by hand, or by an
89
+ * older build that knew none of these parameters. `next` carries the address to run once the
90
+ * window is one level up, so the flow parameters the opener's URL held are forwarded rather than
91
+ * silently dropped.
92
+ */
93
+ export interface SurrogateQuery {
94
+ intent?: string;
95
+ next?: string;
96
+ method?: string;
97
+ }
85
98
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAElE,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,KAAK,EAAE,SAAS,CAAA;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACjD,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpD,IAAI,EAAE,MAA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AM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,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;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
@@ -0,0 +1,5 @@
1
+ import type { ClientEntrypoint } from '@owlmeans/client-entrypoint';
2
+ export interface Perked extends ClientEntrypoint<unknown> {
3
+ _auth_common_middleware_applied?: boolean;
4
+ }
5
+ //# sourceMappingURL=types.local.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE,MAAM,WAAW,MAAO,SAAQ,gBAAgB,CAAC,OAAO,CAAC;IACvD,+BAA+B,CAAC,EAAE,OAAO,CAAA;CAC1C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.local.js","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { fromPubKey, makeKeyPairModel } from '@owlmeans/basic-keys';
1
+ import { keyHelper, makeKeyPairModel } from '@owlmeans/basic-keys';
2
2
  export const trust = async (context, resource, userName, field = 'name') => {
3
3
  const where = { [field]: userName };
4
4
  const trustedUser = await context.resource(resource).load(where);
@@ -6,7 +6,7 @@ export const trust = async (context, resource, userName, field = 'name') => {
6
6
  throw new SyntaxError(`Auth service trusted entity is not provided: ${userName}`);
7
7
  }
8
8
  // @TODO credential can really be undefined - we need to process it properly
9
- const keyPair = trustedUser.secret != null ? makeKeyPairModel(trustedUser.secret) : fromPubKey(trustedUser.credential);
9
+ const keyPair = trustedUser.secret != null ? makeKeyPairModel(trustedUser.secret) : keyHelper.fromPubKey(trustedUser.credential);
10
10
  return { user: trustedUser, key: keyPair };
11
11
  };
12
12
  //# sourceMappingURL=trusted.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"trusted.js","sourceRoot":"","sources":["../../src/utils/trusted.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEnE,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAA0C,OAAU,EAAE,QAAgB,EAAE,QAAgB,EAAE,KAAK,GAAW,MAAM,EAAE,EAAE;IAC5I,MAAM,KAAK,GAA4B,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;IAC5D,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,QAAQ,CAA0B,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzF,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,WAAW,CAAC,gDAAgD,QAAQ,EAAE,CAAC,CAAA;IACnF,CAAC;IAED,4EAA4E;IAC5E,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,UAAW,CAAC,CAAA;IAEvH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,CAAA;AAC5C,CAAC,CAAA"}
1
+ {"version":3,"file":"trusted.js","sourceRoot":"","sources":["../../src/utils/trusted.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAElE,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAA0C,OAAU,EAAE,QAAgB,EAAE,QAAgB,EAAE,KAAK,GAAW,MAAM,EAAE,EAAE;IAC5I,MAAM,KAAK,GAA4B,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;IAC5D,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,QAAQ,CAA0B,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzF,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,WAAW,CAAC,gDAAgD,QAAQ,EAAE,CAAC,CAAA;IACnF,CAAC;IAED,4EAA4E;IAC5E,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,UAAW,CAAC,CAAA;IAEjI,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,CAAA;AAC5C,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/auth-common",
3
- "version": "0.1.18-rc.45",
3
+ "version": "0.1.18-rc.47",
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.38",
33
- "@owlmeans/auth-common": "^0.1.18-rc.45",
34
- "@owlmeans/basic-ids": "^0.1.18-rc.35",
35
- "@owlmeans/basic-keys": "^0.1.18-rc.46",
36
- "@owlmeans/client-entrypoint": "^0.1.18-rc.45",
37
- "@owlmeans/context": "^0.1.18-rc.32",
38
- "@owlmeans/entrypoint": "^0.1.18-rc.39",
39
- "@owlmeans/resource": "^0.1.18-rc.38",
40
- "@owlmeans/route": "^0.1.18-rc.33"
32
+ "@owlmeans/auth": "^0.1.18-rc.40",
33
+ "@owlmeans/auth-common": "^0.1.18-rc.47",
34
+ "@owlmeans/basic-ids": "^0.1.18-rc.37",
35
+ "@owlmeans/basic-keys": "^0.1.18-rc.48",
36
+ "@owlmeans/client-entrypoint": "^0.1.18-rc.47",
37
+ "@owlmeans/context": "^0.1.18-rc.34",
38
+ "@owlmeans/entrypoint": "^0.1.18-rc.41",
39
+ "@owlmeans/resource": "^0.1.18-rc.40",
40
+ "@owlmeans/route": "^0.1.18-rc.35"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@owlmeans/dep-config": "workspace:*",
44
- "@owlmeans/test-auth": "^0.1.18-rc.44",
45
- "@types/bun": "^1.4.0",
44
+ "@owlmeans/test-auth": "^0.1.18-rc.46",
45
+ "@types/bun": "^1.4.2",
46
46
  "nodemon": "^3.1.14",
47
47
  "typescript": "^7.0.2"
48
48
  },
@@ -0,0 +1,52 @@
1
+ import type { BasicContext } from '@owlmeans/context'
2
+ import type { ResolvedEntity } from '@owlmeans/entrypoint'
3
+
4
+ /** The organization entity one request acts for — built once at the top of a handler, never stored. */
5
+ export interface EntityScope {
6
+ /**
7
+ * The value a handler should store and query organization-scoped records by.
8
+ *
9
+ * Prefers the entity's stable id, which is the whole point of resolving one: records keyed by it
10
+ * survive a rename untouched. Falls back to the slug on the token for deployments that register no
11
+ * resolver — there the slug IS the only identifier the system has, and refusing to serve them
12
+ * would break every installation backed by an external IAM.
13
+ *
14
+ * Never use this to compose a user-facing name (a hostname, a display label). Those want the
15
+ * current slug, `req.entity?.slug`, precisely because it can change.
16
+ */
17
+ entityKeyOf: () => string | undefined
18
+ /**
19
+ * `entityKeyOf` for handlers that cannot proceed without an organization.
20
+ *
21
+ * @throws {AuthorizationError} when the request carries no organization at all.
22
+ */
23
+ requireEntityKey: () => string
24
+ /**
25
+ * The full resolved entity, for handlers that need the slug or the frozen key as well as the id.
26
+ *
27
+ * @throws {AuthorizationError} when no resolver is registered or the entity did not resolve.
28
+ */
29
+ requireEntity: () => ResolvedEntity
30
+ /**
31
+ * Resolve the organization a just-authenticated request acts for, and attach it.
32
+ *
33
+ * Called wherever authentication is ESTABLISHED — the HTTP boundary, and any socket that
34
+ * authenticates on its own once the connection is already open. Both need it for the same reason:
35
+ * the token names the organization by a slug that can move, while everything downstream keys on
36
+ * the record. A path that authenticates without calling this leaves `request.entity` empty, and
37
+ * its handlers quietly fall back to comparing a slug against stored ids — which surfaces as "this
38
+ * project does not exist" rather than as a missing resolution, and costs an afternoon to find.
39
+ *
40
+ * An entity the guard already attached is kept while its slug is exactly the token's: a guard
41
+ * whose authority names the organization itself (an OIDC session of a tenanted client) is the only
42
+ * source such a deployment has, because the registry that owns the organization is not its own.
43
+ * One whose slug differs is never trusted — it is dropped, and resolution proceeds as if it had
44
+ * not been there.
45
+ *
46
+ * Otherwise a no-op when no resolver is registered: such a deployment has no organization store,
47
+ * and the slug is the only identifier it has.
48
+ *
49
+ * @throws {AuthenFailed} when the token names an organization that cannot be resolved.
50
+ */
51
+ attachEntity: (context: BasicContext<any>) => Promise<ResolvedEntity | undefined>
52
+ }
package/src/entity.ts CHANGED
@@ -1,95 +1,67 @@
1
1
  import type { AbstractRequest, ResolvedEntity } from '@owlmeans/entrypoint'
2
2
  import type { BasicContext } from '@owlmeans/context'
3
- import { AuthenFailed, AuthorizationError, entitySlugOf } from '@owlmeans/auth'
3
+ import { AuthenFailed, AuthorizationError, authHelper } from '@owlmeans/auth'
4
4
  import type { EntityResolverService } from './types.js'
5
5
  import { ENTITY_RESOLVER } from './consts.js'
6
+ import type { EntityScope } from './entity/types.js'
6
7
 
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)
8
+ export const makeEntityScope = (req: AbstractRequest): EntityScope => {
9
+ const entityKeyOf = (): string | undefined =>
10
+ req.entity?.id ?? authHelper.entitySlugOf(req.auth)
20
11
 
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()
12
+ const requireEntityKey = (): string => {
13
+ const key = entityKeyOf()
14
+ if (key == null || key === '') {
15
+ throw new AuthorizationError()
16
+ }
17
+
18
+ return key
30
19
  }
31
20
 
32
- return key
33
- }
21
+ const requireEntity = (): ResolvedEntity => {
22
+ if (req.entity == null) {
23
+ throw new AuthorizationError()
24
+ }
34
25
 
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()
26
+ return req.entity
43
27
  }
44
28
 
45
- return req.entity
46
- }
29
+ const attachEntity = async (context: BasicContext<any>): Promise<ResolvedEntity | undefined> => {
30
+ const slug = authHelper.entitySlugOf(req.auth)
31
+ if (req.entity != null) {
32
+ if (slug != null && req.entity.slug === slug) {
33
+ return req.entity
34
+ }
35
+ req.entity = undefined
36
+ }
47
37
 
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
- * An entity the guard already attached is kept while its slug is exactly the token's: a guard
59
- * whose authority names the organization itself (an OIDC session of a tenanted client) is the only
60
- * source such a deployment has, because the registry that owns the organization is not its own.
61
- * One whose slug differs is never trusted — it is dropped, and resolution proceeds as if it had
62
- * not been there.
63
- *
64
- * Otherwise a no-op when no resolver is registered: such a deployment has no organization store,
65
- * and the slug is the only identifier it has.
66
- *
67
- * @throws {AuthenFailed} when the token names an organization that cannot be resolved.
68
- */
69
- export const attachEntity = async (
70
- context: BasicContext<any>, request: AbstractRequest
71
- ): Promise<ResolvedEntity | undefined> => {
72
- const slug = entitySlugOf(request.auth)
73
- if (request.entity != null) {
74
- if (slug != null && request.entity.slug === slug) {
75
- return request.entity
38
+ if (slug == null || !context.hasService(ENTITY_RESOLVER)) {
39
+ return undefined
76
40
  }
77
- request.entity = undefined
78
- }
79
41
 
80
- if (slug == null || !context.hasService(ENTITY_RESOLVER)) {
81
- return undefined
82
- }
42
+ const entity = await context.service<EntityResolverService>(ENTITY_RESOLVER).resolve(slug)
43
+ if (entity == null) {
44
+ throw new AuthenFailed('entity')
45
+ }
83
46
 
84
- const entity = await context.service<EntityResolverService>(ENTITY_RESOLVER).resolve(slug)
85
- if (entity == null) {
86
- throw new AuthenFailed('entity')
87
- }
47
+ // Canonicalize: a request that arrived under a retired slug continues under the current one, so
48
+ // nothing echoing the value back can re-publish a name the organization has dropped.
49
+ req.auth!.entitySlug = entity.slug
50
+ req.entity = entity
88
51
 
89
- // Canonicalize: a request that arrived under a retired slug continues under the current one, so
90
- // nothing echoing the value back can re-publish a name the organization has dropped.
91
- request.auth!.entitySlug = entity.slug
92
- request.entity = entity
52
+ return entity
53
+ }
93
54
 
94
- return entity
55
+ return { entityKeyOf, requireEntityKey, requireEntity, attachEntity }
95
56
  }
57
+
58
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(req).entityKeyOf()` */
59
+ export const entityKeyOf = (req: AbstractRequest): string | undefined => makeEntityScope(req).entityKeyOf()
60
+
61
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(req).requireEntityKey()` */
62
+ export const requireEntityKey = (req: AbstractRequest): string => makeEntityScope(req).requireEntityKey()
63
+
64
+ /** @deprecated compat:factory-refactor — use `makeEntityScope(request).attachEntity(context)` */
65
+ export const attachEntity = async (
66
+ context: BasicContext<any>, request: AbstractRequest
67
+ ): Promise<ResolvedEntity | undefined> => await makeEntityScope(request).attachEntity(context)
@@ -1,16 +1,11 @@
1
1
 
2
- import {
3
- AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, AllowanceRequestSchema, AuthCredentialsSchema,
4
- AuthTokenSchema, CAUTHEN, CAUTHEN_AUTHEN, CAUTHEN_AUTHEN_DEFAULT, CAUTHEN_AUTHEN_TYPED, DISPATCHER,
5
- DISPATCHER_AUTHEN, DISPATCHER_SURROGATE, OptionalAuthTokenSchema, CAUTHEN_FLOW_ENTER
6
- } from '@owlmeans/auth'
7
- import type { AllowanceRequest, AllowanceResponse, AuthCredentials, AuthToken } from '@owlmeans/auth'
2
+ 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, type AllowanceRequest, type AllowanceResponse, type AuthCredentials, type AuthToken } from '@owlmeans/auth'
8
3
  // import { AppType } from '@owlmeans/context'
9
4
  import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint'
10
5
  import { route, RouteMethod, frontend, backend, socket } from '@owlmeans/route'
11
6
  import { DISPATCHER_PATH, SURROGATE_PATH, WEB_API, authApi } from './consts.js'
12
7
  import { SurrogateQuerySchema } from './schemas.js'
13
- import type { SurrogateQuery } from './schemas.js'
8
+ import type { SurrogateQuery } from './types.js'
14
9
 
15
10
  /** Shared authentication protocols, bound independently by server and browser packages. */
16
11
  export const authProtocols = {
@@ -0,0 +1,4 @@
1
+ import { BED255_NONCE_HEADER, BED255_TIME_HEADER } from './consts.js'
2
+
3
+ export const timeKey = BED255_TIME_HEADER.toLocaleLowerCase()
4
+ export const nonceKey = BED255_NONCE_HEADER.toLocaleLowerCase()
@@ -1,10 +1,8 @@
1
1
  import { createService } from '@owlmeans/context'
2
2
  import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint'
3
3
  import { assertContext } from '@owlmeans/context'
4
- import {
5
- BED255_NONCE_HEADER, BED255_TIME_HEADER, BED255_CASHE_RESOURCE, GUARD_ED25519,
6
- BED255_SIG_TTL
7
- } from './consts.js'
4
+ import { BED255_CASHE_RESOURCE, GUARD_ED25519, BED255_SIG_TTL } from './consts.js'
5
+ import { nonceKey, timeKey } from './consts.local.js'
8
6
  import { trust } from '../../utils/trusted.js'
9
7
  import type { Config, Context } from '../../utils/types.js'
10
8
  import type { BasicEd25519Guard, BasicEd25519GuardOptions } from './types.js'
@@ -17,9 +15,6 @@ import {
17
15
  } from './replay.js'
18
16
  import type { SignedRequestReplayResource, SignedRequestReplayStore } from './types.js'
19
17
 
20
- const timeKey = BED255_TIME_HEADER.toLocaleLowerCase()
21
- const nonceKey = BED255_NONCE_HEADER.toLocaleLowerCase()
22
-
23
18
  export const makeBasicEd25519Guard = (resource: string, opts?: BasicEd25519GuardOptions): BasicEd25519Guard => {
24
19
  const memoryReplay = makeMemorySignedRequestReplayStore()
25
20
 
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type * from './types.js'
2
+ export type * from './entity/types.js'
2
3
 
3
4
  export * from './schemas.js'
4
5
  export * from './entrypoints.js'
package/src/middleware.ts CHANGED
@@ -1,9 +1,8 @@
1
- import type { Middleware } from '@owlmeans/context'
2
- import { MiddlewareType, MiddlewareStage, AppType } from '@owlmeans/context'
3
- import { provideRequest } from '@owlmeans/client-entrypoint'
4
- import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
1
+ import { type Middleware, MiddlewareType, MiddlewareStage, AppType } from '@owlmeans/context'
5
2
  import { AUTH_HEADER } from '@owlmeans/auth'
6
3
  import type { AbstractRequest, GuardService } from '@owlmeans/entrypoint'
4
+ import type { Perked } from './types.local.js'
5
+ import { clientRequestHelper } from '@owlmeans/client-entrypoint'
7
6
 
8
7
  export const authMiddleware: Middleware = {
9
8
  type: MiddlewareType.Context,
@@ -28,7 +27,7 @@ export const authMiddleware: Middleware = {
28
27
  guard => context.service<GuardService>(guard).authenticated(req)
29
28
  ))).filter(token => token != null).reverse()
30
29
  if (token != null) {
31
- const _req: Partial<AbstractRequest> = req ?? provideRequest(module.alias, module.path())
30
+ const _req: Partial<AbstractRequest> = req ?? clientRequestHelper.provideRequest(module.alias, module.path())
32
31
  const headers = (_req.headers ?? {}) as Record<string, string | undefined>
33
32
  if (headers[AUTH_HEADER] == null) {
34
33
  headers[AUTH_HEADER] = token
@@ -46,6 +45,3 @@ export const authMiddleware: Middleware = {
46
45
  }
47
46
  }
48
47
 
49
- interface Perked extends ClientEntrypoint<unknown> {
50
- _auth_common_middleware_applied?: boolean
51
- }
package/src/schemas.ts CHANGED
@@ -1,18 +1,5 @@
1
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
- }
2
+ import type { SurrogateQuery } from './types.js'
16
3
 
17
4
  export const SurrogateQuerySchema: JSONSchemaType<SurrogateQuery> = {
18
5
  type: 'object',
@@ -0,0 +1,5 @@
1
+ import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
2
+
3
+ export interface Perked extends ClientEntrypoint<unknown> {
4
+ _auth_common_middleware_applied?: boolean
5
+ }
package/src/types.ts CHANGED
@@ -97,3 +97,17 @@ export interface EntityResolverService extends InitializedService {
97
97
  */
98
98
  mintName: (id: string, key: string, mint: (entity: OrgEntityRef) => string) => Promise<string>
99
99
  }
100
+
101
+ /**
102
+ * What the surrogate login window is told about why it was opened.
103
+ *
104
+ * Every field is optional: the window must render something sensible when opened by hand, or by an
105
+ * older build that knew none of these parameters. `next` carries the address to run once the
106
+ * window is one level up, so the flow parameters the opener's URL held are forwarded rather than
107
+ * silently dropped.
108
+ */
109
+ export interface SurrogateQuery {
110
+ intent?: string
111
+ next?: string
112
+ method?: string
113
+ }
@@ -2,7 +2,7 @@
2
2
  import type { Context, Config } from './types.js'
3
3
  import type { TrustedRecord } from '../types.js'
4
4
  import type { Criteria, Resource } from '@owlmeans/resource'
5
- import { fromPubKey, makeKeyPairModel } from '@owlmeans/basic-keys'
5
+ import { keyHelper, makeKeyPairModel } from '@owlmeans/basic-keys'
6
6
 
7
7
  export const trust = async <C extends Config, T extends Context<C>>(context: T, resource: string, userName: string, field: string = 'name') => {
8
8
  const where: Criteria<TrustedRecord> = { [field]: userName }
@@ -12,7 +12,7 @@ export const trust = async <C extends Config, T extends Context<C>>(context: T,
12
12
  }
13
13
 
14
14
  // @TODO credential can really be undefined - we need to process it properly
15
- const keyPair = trustedUser.secret != null ? makeKeyPairModel(trustedUser.secret) : fromPubKey(trustedUser.credential!)
15
+ const keyPair = trustedUser.secret != null ? makeKeyPairModel(trustedUser.secret) : keyHelper.fromPubKey(trustedUser.credential!)
16
16
 
17
17
  return { user: trustedUser, key: keyPair }
18
18
  }
@@ -4,7 +4,7 @@ import {
4
4
  BED255_NONCE_HEADER, BED255_SIG_TTL, BED255_TIME_HEADER, makeBasicEd25519Guard,
5
5
  makeResourceSignedRequestReplayStore
6
6
  } from '@owlmeans/auth-common'
7
- import type { SignedRequestReplayResource } from '@owlmeans/auth-common'
7
+ import type { BasicEd25519Guard, SignedRequestReplayResource } from '@owlmeans/auth-common'
8
8
  import type { AbstractRequest, AbstractResponse } from '@owlmeans/entrypoint'
9
9
  import type { Auth } from '@owlmeans/auth'
10
10
  import { RecordExists } from '@owlmeans/resource'
@@ -35,7 +35,7 @@ const request = async (timestamp: string, nonce: string) => {
35
35
  }
36
36
 
37
37
  const handle = async (
38
- guard: ReturnType<typeof makeBasicEd25519Guard>, req: AbstractRequest
38
+ guard: BasicEd25519Guard, req: AbstractRequest
39
39
  ): Promise<Auth | undefined> => {
40
40
  let value: Auth | undefined
41
41
  const response: AbstractResponse<Auth> = {
@@ -4,7 +4,7 @@ import type { BasicConfig, BasicContext } from '@owlmeans/context'
4
4
  import { AuthenFailed, AuthRole } from '@owlmeans/auth'
5
5
  import type { Auth } from '@owlmeans/auth'
6
6
  import type { AbstractRequest, ResolvedEntity } from '@owlmeans/entrypoint'
7
- import { attachEntity } from '../src/entity.js'
7
+ import { makeEntityScope } from '../src/entity.js'
8
8
  import { ENTITY_RESOLVER } from '../src/consts.js'
9
9
  import type { EntityResolverService, OrgEntityRef } from '../src/types.js'
10
10
 
@@ -47,7 +47,7 @@ describe('attachEntity — an entity the guard attached', () => {
47
47
  const { ctx } = await contextWith()
48
48
  const request = requestFor('tenant', attached)
49
49
 
50
- expect(await attachEntity(ctx, request)).toEqual(attached)
50
+ expect(await makeEntityScope(request).attachEntity(ctx)).toEqual(attached)
51
51
  expect(request.entity).toEqual(attached)
52
52
  })
53
53
 
@@ -55,7 +55,7 @@ describe('attachEntity — an entity the guard attached', () => {
55
55
  const { ctx, calls } = await contextWith([ACME])
56
56
  const request = requestFor('tenant', attached)
57
57
 
58
- expect(await attachEntity(ctx, request)).toEqual(attached)
58
+ expect(await makeEntityScope(request).attachEntity(ctx)).toEqual(attached)
59
59
  expect(calls).toEqual([])
60
60
  })
61
61
 
@@ -63,7 +63,7 @@ describe('attachEntity — an entity the guard attached', () => {
63
63
  const { ctx, calls } = await contextWith([ACME])
64
64
  const request = requestFor('acme', attached)
65
65
 
66
- expect(await attachEntity(ctx, request)).toEqual(ACME)
66
+ expect(await makeEntityScope(request).attachEntity(ctx)).toEqual(ACME)
67
67
  expect(request.entity).toEqual(ACME)
68
68
  expect(calls).toEqual(['acme'])
69
69
  })
@@ -72,7 +72,7 @@ describe('attachEntity — an entity the guard attached', () => {
72
72
  const { ctx } = await contextWith()
73
73
  const request = requestFor('acme', attached)
74
74
 
75
- expect(await attachEntity(ctx, request)).toBeUndefined()
75
+ expect(await makeEntityScope(request).attachEntity(ctx)).toBeUndefined()
76
76
  expect(request.entity).toBeUndefined()
77
77
  })
78
78
 
@@ -80,7 +80,7 @@ describe('attachEntity — an entity the guard attached', () => {
80
80
  const { ctx } = await contextWith()
81
81
  const request = requestFor(undefined, attached)
82
82
 
83
- expect(await attachEntity(ctx, request)).toBeUndefined()
83
+ expect(await makeEntityScope(request).attachEntity(ctx)).toBeUndefined()
84
84
  expect(request.entity).toBeUndefined()
85
85
  })
86
86
  })
@@ -90,7 +90,7 @@ describe('attachEntity — the resolver path', () => {
90
90
  const { ctx } = await contextWith([ACME])
91
91
  const request = requestFor('acme-old')
92
92
 
93
- expect(await attachEntity(ctx, request)).toEqual(ACME)
93
+ expect(await makeEntityScope(request).attachEntity(ctx)).toEqual(ACME)
94
94
  expect(request.entity).toEqual(ACME)
95
95
  expect(request.auth?.entitySlug).toBe('acme')
96
96
  })
@@ -98,14 +98,14 @@ describe('attachEntity — the resolver path', () => {
98
98
  test('refuses a token naming an organization the registry does not know', async () => {
99
99
  const { ctx } = await contextWith([ACME])
100
100
 
101
- await expect(attachEntity(ctx, requestFor('nobody'))).rejects.toBeInstanceOf(AuthenFailed)
101
+ await expect(makeEntityScope(requestFor('nobody')).attachEntity(ctx)).rejects.toBeInstanceOf(AuthenFailed)
102
102
  })
103
103
 
104
104
  test('is a no-op with no resolver and nothing attached', async () => {
105
105
  const { ctx } = await contextWith()
106
106
  const request = requestFor('acme')
107
107
 
108
- expect(await attachEntity(ctx, request)).toBeUndefined()
108
+ expect(await makeEntityScope(request).attachEntity(ctx)).toBeUndefined()
109
109
  expect(request.entity).toBeUndefined()
110
110
  expect(request.auth?.entitySlug).toBe('acme')
111
111
  })