@owlmeans/oidc 0.1.18-rc.15 → 0.1.18-rc.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/oidc/SKILL.md +9 -8
- package/build/entrypoints.d.ts +9 -1
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +6 -5
- package/build/entrypoints.js.map +1 -1
- package/build/guard.d.ts +9 -2
- package/build/guard.d.ts.map +1 -1
- package/build/guard.js +18 -9
- package/build/guard.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +0 -1
- package/build/index.js.map +1 -1
- package/package.json +9 -10
- package/src/entrypoints.ts +9 -9
- package/src/guard.ts +24 -11
- package/src/index.ts +0 -1
- package/build/advertise.d.ts +0 -2
- package/build/advertise.d.ts.map +0 -1
- package/build/advertise.js +0 -28
- package/build/advertise.js.map +0 -1
- package/src/advertise.ts +0 -28
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Shared OIDC protocol abstractions — guard/gate aliases, models, and entrypoint
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
- `OIDC_GATE` — gate alias to
|
|
7
|
+
- `OIDC_GATE` — gate alias to put in a protocol's `gate` option
|
|
8
8
|
- `OIDC_GUARD`, `WRAPPED_OIDC`, `OIDC_FLOW`, `OIDC_AUTHEN_MODULE`, `OIDC_WRAPPED_TOKEN` — shared aliases
|
|
9
9
|
- `OidcGuard`, `WithSharedConfig`, `OidcProviderConfig` — shared types
|
|
10
10
|
- Entrypoint declarations for the OIDC dispatcher (`/authenticate/oidc/init`, `/authenticate/oidc/process`)
|
|
@@ -12,22 +12,23 @@ Shared OIDC protocol abstractions — guard/gate aliases, models, and entrypoint
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @owlmeans/oidc@^0.1.18-rc.
|
|
15
|
+
bun add @owlmeans/oidc@^0.1.18-rc.24
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
-
Compose `OIDC_GATE` into a
|
|
20
|
+
Compose `OIDC_GATE` into a protocol declaration:
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import {
|
|
23
|
+
import { contract, protocol, typed } from '@owlmeans/entrypoint'
|
|
24
24
|
import { route } from '@owlmeans/route'
|
|
25
25
|
import { DEFAULT_GUARD } from '@owlmeans/auth-common'
|
|
26
26
|
import { OIDC_GATE } from '@owlmeans/oidc'
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
protocol(
|
|
29
29
|
route(manager.back.account.base, '/account'),
|
|
30
|
-
|
|
30
|
+
contract(typed<Account>()),
|
|
31
|
+
{ guards: DEFAULT_GUARD, gate: { alias: OIDC_GATE, params: [`my-service-account-{entity}`] } },
|
|
31
32
|
)
|
|
32
33
|
```
|
|
33
34
|
|
|
@@ -92,7 +93,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
92
93
|
your project's skill store (`.agents/skills/`):
|
|
93
94
|
|
|
94
95
|
```sh
|
|
95
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
96
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.15
|
|
96
97
|
```
|
|
97
98
|
|
|
98
99
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/oidc",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-09-
|
|
4
|
+
"version": "0.1.18-rc.24",
|
|
5
|
+
"generatedAt": "2026-09-12T08:39:52.725Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: oidc
|
|
3
|
-
description: How to use @owlmeans/oidc — the OIDC names both sides share — the OIDC_GATE alias, the guard, the requested-scope contract, provider descriptors, the dispatcher entrypoints and the error query params. Auto-invoked when importing OIDC types or constants, wiring OIDC into a
|
|
3
|
+
description: How to use @owlmeans/oidc — the OIDC names both sides share — the OIDC_GATE alias, the guard, the requested-scope contract, provider descriptors, the dispatcher entrypoints and the error query params. Auto-invoked when importing OIDC types or constants, wiring OIDC into a protocol gate, or declaring an identity provider in configuration.
|
|
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/oidc
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/oidc": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/oidc": "^0.1.18-rc.24"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
The shared half of the OIDC stack: no transport, no library. It owns the names, the shapes and the
|
|
14
14
|
guard that the server relying party (`@owlmeans/server-oidc-rp`), the browser relying party
|
|
@@ -18,12 +18,12 @@ guard that the server relying party (`@owlmeans/server-oidc-rp`), the browser re
|
|
|
18
18
|
|
|
19
19
|
| Export | Description |
|
|
20
20
|
|--------|-------------|
|
|
21
|
-
| `OIDC_GATE` | Gate alias to pass
|
|
21
|
+
| `OIDC_GATE` | Gate alias to pass in a protocol's `gate` option |
|
|
22
22
|
| `OIDC_GUARD` | The guard's alias |
|
|
23
23
|
| `OIDC_GUARD_CACHE` | A resource-alias constant nothing reads — the guard has no cache lookup, so registering a resource under it changes no behaviour |
|
|
24
24
|
| `makeOidcGuard(opts?)` / `appendOidcGuard(context, opts?)` | The wrapped-token guard, and its registration. The target-specific packages wrap these |
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
25
|
+
| `withOidcGuard(protocolTree, coguards?)` | Returns a decorated immutable protocol tree, prepending `OIDC_GUARD` to selected guarded declarations (default `DEFAULT_GUARD`) |
|
|
26
|
+
| `oidcProtocols` | Shared dispatcher declarations: `DISPATCHER_OIDC_INIT` (`POST /authenticate/oidc/init`) and `DISPATCHER_OIDC` (`POST /authenticate/oidc/process`) |
|
|
27
27
|
| `DISPATCHER_OIDC_INIT`, `DISPATCHER_OIDC` | Their aliases |
|
|
28
28
|
| `OIDC_WRAPPED_TOKEN`, `WRAPPED_OIDC` | The authorization-header scheme for an OIDC-wrapped token, and the service alias that refreshes one |
|
|
29
29
|
| `OIDC_CLIENT_AUTH`, `GOOGLE_CLIENT_AUTH` | Authentication plugin types — the generic OIDC one and the Google one |
|
|
@@ -47,14 +47,15 @@ guard that the server relying party (`@owlmeans/server-oidc-rp`), the browser re
|
|
|
47
47
|
## Usage
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
|
-
import {
|
|
50
|
+
import { contract, protocol, typed } from '@owlmeans/entrypoint'
|
|
51
51
|
import { route } from '@owlmeans/route'
|
|
52
52
|
import { DEFAULT_GUARD } from '@owlmeans/auth-common'
|
|
53
53
|
import { OIDC_GATE } from '@owlmeans/oidc'
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
protocol(
|
|
56
56
|
route(accountAlias, '/account'),
|
|
57
|
-
|
|
57
|
+
contract(typed<Account>()),
|
|
58
|
+
{ guards: DEFAULT_GUARD, gate: { alias: OIDC_GATE, params: ['my-service-account--read'] } },
|
|
58
59
|
)
|
|
59
60
|
```
|
|
60
61
|
|
package/build/entrypoints.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/** Shared OIDC browser-to-server protocols, bound by the relying-party packages. */
|
|
2
|
+
export declare const oidcProtocols: {
|
|
3
|
+
init: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
4
|
+
body: import("./types.js").OIDCAuthInitParams;
|
|
5
|
+
}, any>;
|
|
6
|
+
authenticate: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
7
|
+
body: import("./types.js").OIDCClientAuthPayload;
|
|
8
|
+
}, any>;
|
|
9
|
+
};
|
|
2
10
|
//# sourceMappingURL=entrypoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAKA,oFAAoF;AACpF,eAAO,MAAM,aAAa;IACxB,IAAI;;;IAIJ,YAAY;;;CAIb,CAAA"}
|
package/build/entrypoints.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { contract, protocol, typed } from '@owlmeans/entrypoint';
|
|
2
2
|
import { route, RouteMethod, backend } from '@owlmeans/route';
|
|
3
3
|
import { DISPATCHER_OIDC, DISPATCHER_OIDC_INIT } from './consts.js';
|
|
4
4
|
import { OIDCAuthInitParamsSchema, OIDCClientAuthPayloadSchema } from './models.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/** Shared OIDC browser-to-server protocols, bound by the relying-party packages. */
|
|
6
|
+
export const oidcProtocols = {
|
|
7
|
+
init: protocol(route(DISPATCHER_OIDC_INIT, '/authenticate/oidc/init', backend(null, RouteMethod.POST)), contract.request({ body: typed(OIDCAuthInitParamsSchema) }, typed())),
|
|
8
|
+
authenticate: protocol(route(DISPATCHER_OIDC, '/authenticate/oidc/process', backend(null, RouteMethod.POST)), contract.request({ body: typed(OIDCClientAuthPayloadSchema) }, typed())),
|
|
9
|
+
};
|
|
9
10
|
//# sourceMappingURL=entrypoints.js.map
|
package/build/entrypoints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAEnF,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,QAAQ,CACZ,KAAK,CAAC,oBAAoB,EAAE,yBAAyB,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EACvF,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,wBAAwB,CAAC,EAAE,EAAE,KAAK,EAAO,CAAC,CAC1E;IACD,YAAY,EAAE,QAAQ,CACpB,KAAK,CAAC,eAAe,EAAE,4BAA4B,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EACrF,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,2BAA2B,CAAC,EAAE,EAAE,KAAK,EAAO,CAAC,CAC7E;CACF,CAAA"}
|
package/build/guard.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { Config, Context, OidcGuard, OidcGuardOptions } from './types.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { EntrypointTree } from '@owlmeans/entrypoint';
|
|
3
3
|
export declare const makeOidcGuard: (opts?: OidcGuardOptions) => OidcGuard;
|
|
4
4
|
export declare const appendOidcGuard: <C extends Config, T extends Context<C>>(context: T, opts?: OidcGuardOptions) => T;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Decorate an immutable protocol tree so the OIDC guard runs before each selected auth guard.
|
|
7
|
+
*
|
|
8
|
+
* The tree's shape and protocol types are preserved; only declarations that explicitly carry a
|
|
9
|
+
* selected guard are cloned. Parent inheritance then carries OIDC to their children exactly as
|
|
10
|
+
* the route model does for every other guard.
|
|
11
|
+
*/
|
|
12
|
+
export declare const withOidcGuard: <Tree extends EntrypointTree>(tree: Tree, coguards?: string | readonly string[]) => Tree;
|
|
6
13
|
//# sourceMappingURL=guard.d.ts.map
|
package/build/guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAsB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAsB,MAAM,YAAY,CAAA;AAGlG,OAAO,KAAK,EAAqC,cAAc,EAAgB,MAAM,sBAAsB,CAAA;AAQ3G,eAAO,MAAM,aAAa,UAAW,gBAAgB,KAAG,SA4FvD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,WAC3D,CAAC,SAAS,gBAAgB,MAKpC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GAAI,IAAI,SAAS,cAAc,QACjD,IAAI,aAAa,MAAM,GAAG,SAAS,MAAM,EAAE,KAChD,IAcF,CAAA"}
|
package/build/guard.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createService } from '@owlmeans/context';
|
|
2
2
|
import { OIDC_GUARD, OIDC_WRAPPED_TOKEN, WRAPPED_OIDC } from './consts.js';
|
|
3
|
+
import { decorateEntrypoint, isEntrypointProtocol } from '@owlmeans/entrypoint';
|
|
3
4
|
import { DEFAULT_GUARD, TOKEN_UPDATE } from '@owlmeans/auth-common';
|
|
4
5
|
import { AUTH_HEADER, AuthorizationError } from '@owlmeans/auth';
|
|
5
6
|
import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope';
|
|
6
7
|
import { trust } from '@owlmeans/auth-common/utils';
|
|
7
8
|
import { TRUSTED } from '@owlmeans/config';
|
|
8
9
|
import { extractAuthToken } from '@owlmeans/auth-common/utils';
|
|
9
|
-
import { entrypoints as oidcEntrypoints } from './entrypoints.js';
|
|
10
10
|
export const makeOidcGuard = (opts) => {
|
|
11
11
|
// const cache = (context: Context) => context.hasResource(opts?.cache ?? OIDC_GUARD_CACHE)
|
|
12
12
|
// ? context.resource<Resource<ResourceRecord>>(opts?.cache ?? OIDC_GUARD_CACHE)
|
|
@@ -86,15 +86,24 @@ export const appendOidcGuard = (context, opts) => {
|
|
|
86
86
|
context.registerService(makeOidcGuard(opts));
|
|
87
87
|
return context;
|
|
88
88
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Decorate an immutable protocol tree so the OIDC guard runs before each selected auth guard.
|
|
91
|
+
*
|
|
92
|
+
* The tree's shape and protocol types are preserved; only declarations that explicitly carry a
|
|
93
|
+
* selected guard are cloned. Parent inheritance then carries OIDC to their children exactly as
|
|
94
|
+
* the route model does for every other guard.
|
|
95
|
+
*/
|
|
96
|
+
export const withOidcGuard = (tree, coguards) => {
|
|
97
|
+
const selected = new Set(Array.isArray(coguards) ? coguards : [coguards ?? DEFAULT_GUARD]);
|
|
98
|
+
const decorate = (node) => Object.fromEntries(Object.entries(node).map(([key, value]) => {
|
|
99
|
+
if (!isEntrypointProtocol(value))
|
|
100
|
+
return [key, decorate(value)];
|
|
101
|
+
if (value.guards.includes(OIDC_GUARD) || !value.guards.some(guard => selected.has(guard))) {
|
|
102
|
+
return [key, value];
|
|
96
103
|
}
|
|
97
|
-
|
|
104
|
+
return [key, decorateEntrypoint(value, { guards: [OIDC_GUARD, ...value.guards] })];
|
|
105
|
+
}));
|
|
106
|
+
return decorate(tree);
|
|
98
107
|
};
|
|
99
108
|
const wrapper = (context) => context.hasService(WRAPPED_OIDC)
|
|
100
109
|
? context.service(WRAPPED_OIDC)
|
package/build/guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAE/E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,WAAW,EAAwB,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAE9D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC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CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACxC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;QAC/D,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YAC1F,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACrB,CAAC;QAED,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IACpF,CAAC,CAAC,CACH,CAAA;IAED,OAAO,QAAQ,CAAC,IAAI,CAAS,CAAA;AAC/B,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,CAAC,OAAgB,EAAsB,EAAE,CACvD,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC;IAC9B,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;IAC/B,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAC,KAAK,EAAC,EAAE,CAAC,KAAK,EAAwB,CAAA"}
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,mBAAmB,UAAU,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,mBAAmB,UAAU,CAAA"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/oidc",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.24",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,15 +21,14 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/
|
|
25
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/
|
|
27
|
-
"@owlmeans/
|
|
28
|
-
"@owlmeans/
|
|
29
|
-
"@owlmeans/
|
|
30
|
-
"@owlmeans/
|
|
31
|
-
"@owlmeans/
|
|
32
|
-
"@owlmeans/route": "^0.1.18-rc.11"
|
|
24
|
+
"@owlmeans/auth": "^0.1.18-rc.12",
|
|
25
|
+
"@owlmeans/auth-common": "^0.1.18-rc.16",
|
|
26
|
+
"@owlmeans/basic-envelope": "^0.1.18-rc.15",
|
|
27
|
+
"@owlmeans/config": "^0.1.18-rc.15",
|
|
28
|
+
"@owlmeans/context": "^0.1.18-rc.11",
|
|
29
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.14",
|
|
30
|
+
"@owlmeans/resource": "^0.1.18-rc.12",
|
|
31
|
+
"@owlmeans/route": "^0.1.18-rc.12"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"ajv": "*"
|
package/src/entrypoints.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { contract, protocol, typed } from '@owlmeans/entrypoint'
|
|
2
2
|
import { route, RouteMethod, backend } from '@owlmeans/route'
|
|
3
3
|
import { DISPATCHER_OIDC, DISPATCHER_OIDC_INIT } from './consts.js'
|
|
4
4
|
import { OIDCAuthInitParamsSchema, OIDCClientAuthPayloadSchema } from './models.js'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/** Shared OIDC browser-to-server protocols, bound by the relying-party packages. */
|
|
7
|
+
export const oidcProtocols = {
|
|
8
|
+
init: protocol(
|
|
8
9
|
route(DISPATCHER_OIDC_INIT, '/authenticate/oidc/init', backend(null, RouteMethod.POST)),
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
contract.request({ body: typed(OIDCAuthInitParamsSchema) }, typed<any>()),
|
|
11
11
|
),
|
|
12
|
-
|
|
12
|
+
authenticate: protocol(
|
|
13
13
|
route(DISPATCHER_OIDC, '/authenticate/oidc/process', backend(null, RouteMethod.POST)),
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
|
|
14
|
+
contract.request({ body: typed(OIDCClientAuthPayloadSchema) }, typed<any>()),
|
|
15
|
+
),
|
|
16
|
+
}
|
package/src/guard.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createService } from '@owlmeans/context'
|
|
2
2
|
import type { Config, Context, OidcGuard, OidcGuardOptions, WrappedOIDCService } from './types.js'
|
|
3
3
|
import { OIDC_GUARD, OIDC_WRAPPED_TOKEN, WRAPPED_OIDC } from './consts.js'
|
|
4
|
-
import
|
|
4
|
+
import { decorateEntrypoint, isEntrypointProtocol } from '@owlmeans/entrypoint'
|
|
5
|
+
import type { AbstractRequest, AbstractResponse, EntrypointTree, GuardService } from '@owlmeans/entrypoint'
|
|
5
6
|
import { DEFAULT_GUARD, TOKEN_UPDATE } from '@owlmeans/auth-common'
|
|
6
7
|
import { AUTH_HEADER, type Auth, AuthToken, AuthorizationError } from '@owlmeans/auth'
|
|
7
8
|
import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope'
|
|
8
9
|
import { trust } from '@owlmeans/auth-common/utils'
|
|
9
10
|
import { TRUSTED } from '@owlmeans/config'
|
|
10
11
|
import { extractAuthToken } from '@owlmeans/auth-common/utils'
|
|
11
|
-
import { entrypoints as oidcEntrypoints } from './entrypoints.js'
|
|
12
12
|
|
|
13
13
|
export const makeOidcGuard = (opts?: OidcGuardOptions): OidcGuard => {
|
|
14
14
|
// const cache = (context: Context) => context.hasResource(opts?.cache ?? OIDC_GUARD_CACHE)
|
|
@@ -112,16 +112,29 @@ export const appendOidcGuard = <C extends Config, T extends Context<C>>(
|
|
|
112
112
|
return context
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Decorate an immutable protocol tree so the OIDC guard runs before each selected auth guard.
|
|
117
|
+
*
|
|
118
|
+
* The tree's shape and protocol types are preserved; only declarations that explicitly carry a
|
|
119
|
+
* selected guard are cloned. Parent inheritance then carries OIDC to their children exactly as
|
|
120
|
+
* the route model does for every other guard.
|
|
121
|
+
*/
|
|
122
|
+
export const withOidcGuard = <Tree extends EntrypointTree>(
|
|
123
|
+
tree: Tree, coguards?: string | readonly string[],
|
|
124
|
+
): Tree => {
|
|
125
|
+
const selected = new Set(Array.isArray(coguards) ? coguards : [coguards ?? DEFAULT_GUARD])
|
|
126
|
+
const decorate = (node: EntrypointTree): EntrypointTree => Object.fromEntries(
|
|
127
|
+
Object.entries(node).map(([key, value]) => {
|
|
128
|
+
if (!isEntrypointProtocol(value)) return [key, decorate(value)]
|
|
129
|
+
if (value.guards.includes(OIDC_GUARD) || !value.guards.some(guard => selected.has(guard))) {
|
|
130
|
+
return [key, value]
|
|
131
|
+
}
|
|
118
132
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})
|
|
133
|
+
return [key, decorateEntrypoint(value, { guards: [OIDC_GUARD, ...value.guards] })]
|
|
134
|
+
}),
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
return decorate(tree) as Tree
|
|
125
138
|
}
|
|
126
139
|
|
|
127
140
|
const wrapper = (context: Context): WrappedOIDCService =>
|
package/src/index.ts
CHANGED
package/build/advertise.d.ts
DELETED
package/build/advertise.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advertise.d.ts","sourceRoot":"","sources":["../src/advertise.ts"],"names":[],"mappings":""}
|
package/build/advertise.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { apiConfigPlugin, every } from '@owlmeans/api-config';
|
|
2
|
-
apiConfigPlugin({
|
|
3
|
-
allow: {
|
|
4
|
-
oidc: {
|
|
5
|
-
clientCookie: true,
|
|
6
|
-
restrictedProviders: true,
|
|
7
|
-
providers: every({
|
|
8
|
-
entityId: true,
|
|
9
|
-
service: true,
|
|
10
|
-
discoveryUrl: true,
|
|
11
|
-
basePath: true,
|
|
12
|
-
clientId: true,
|
|
13
|
-
redirectUri: true,
|
|
14
|
-
extraScopes: true,
|
|
15
|
-
authEndpoint: true,
|
|
16
|
-
tokenEndpoint: true,
|
|
17
|
-
userinfoEndpoint: true,
|
|
18
|
-
idOverride: true,
|
|
19
|
-
def: true,
|
|
20
|
-
label: true,
|
|
21
|
-
icon: true,
|
|
22
|
-
order: true,
|
|
23
|
-
hidden: true,
|
|
24
|
-
}, value => value != null && typeof value === 'object' && value.internal !== true),
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=advertise.js.map
|
package/build/advertise.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"advertise.js","sourceRoot":"","sources":["../src/advertise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE7D,eAAe,CAAC;IACd,KAAK,EAAE;QACL,IAAI,EAAE;YACJ,YAAY,EAAE,IAAI;YAClB,mBAAmB,EAAE,IAAI;YACzB,SAAS,EAAE,KAAK,CAAC;gBACf,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;gBACd,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,IAAI;gBACjB,WAAW,EAAE,IAAI;gBACjB,YAAY,EAAE,IAAI;gBAClB,aAAa,EAAE,IAAI;gBACnB,gBAAgB,EAAE,IAAI;gBACtB,UAAU,EAAE,IAAI;gBAChB,GAAG,EAAE,IAAI;gBACT,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;aACb,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAK,KAAgC,CAAC,QAAQ,KAAK,IAAI,CAAC;SAC/G;KACF;CACF,CAAC,CAAA"}
|
package/src/advertise.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { apiConfigPlugin, every } from '@owlmeans/api-config'
|
|
2
|
-
|
|
3
|
-
apiConfigPlugin({
|
|
4
|
-
allow: {
|
|
5
|
-
oidc: {
|
|
6
|
-
clientCookie: true,
|
|
7
|
-
restrictedProviders: true,
|
|
8
|
-
providers: every({
|
|
9
|
-
entityId: true,
|
|
10
|
-
service: true,
|
|
11
|
-
discoveryUrl: true,
|
|
12
|
-
basePath: true,
|
|
13
|
-
clientId: true,
|
|
14
|
-
redirectUri: true,
|
|
15
|
-
extraScopes: true,
|
|
16
|
-
authEndpoint: true,
|
|
17
|
-
tokenEndpoint: true,
|
|
18
|
-
userinfoEndpoint: true,
|
|
19
|
-
idOverride: true,
|
|
20
|
-
def: true,
|
|
21
|
-
label: true,
|
|
22
|
-
icon: true,
|
|
23
|
-
order: true,
|
|
24
|
-
hidden: true,
|
|
25
|
-
}, value => value != null && typeof value === 'object' && (value as { internal?: boolean }).internal !== true),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
})
|