@owlmeans/auth-common 0.1.18-rc.14 → 0.1.18-rc.16
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 +11 -6
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/auth-common/SKILL.md +6 -5
- package/build/entrypoints.d.ts +40 -2
- package/build/entrypoints.d.ts.map +1 -1
- package/build/entrypoints.js +27 -28
- package/build/entrypoints.js.map +1 -1
- package/package.json +11 -11
- package/src/entrypoints.ts +39 -31
package/README.md
CHANGED
|
@@ -31,9 +31,14 @@ Protect a route with the ED25519 signature guard (re-exported via `@owlmeans/ser
|
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
33
|
import { GUARD_ED25519 } from '@owlmeans/auth-common'
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
import { contract, protocol, typed } from '@owlmeans/entrypoint'
|
|
35
|
+
import { route } from '@owlmeans/route'
|
|
36
|
+
|
|
37
|
+
const adminProtocol = protocol(
|
|
38
|
+
route('admin', '/api/admin'),
|
|
39
|
+
contract(typed<AdminResponse>()),
|
|
40
|
+
{ guards: GUARD_ED25519 },
|
|
41
|
+
)
|
|
37
42
|
```
|
|
38
43
|
|
|
39
44
|
## API
|
|
@@ -66,9 +71,9 @@ BED255_CASHE_RESOURCE // resource alias for nonce cache
|
|
|
66
71
|
## Product-Viable Integration Notes
|
|
67
72
|
|
|
68
73
|
- `DEFAULT_GUARD` protects manager routes after bearer authentication is installed by `@owlmeans/server-auth`.
|
|
69
|
-
- Product authorization composes a custom gate
|
|
74
|
+
- Product authorization composes a custom gate in the protocol options rather than using `OIDC_GATE` for Google login flows.
|
|
70
75
|
- `GUARD_ED25519` remains the service-to-service guard for internal/publisher/payment/auth-service calls.
|
|
71
|
-
- The browser-side
|
|
76
|
+
- The browser-side binding from `@owlmeans/client-auth` uses the same protocol references as the shared declarations.
|
|
72
77
|
|
|
73
78
|
## Related Packages
|
|
74
79
|
|
|
@@ -84,7 +89,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
84
89
|
your project's skill store (`.agents/skills/`):
|
|
85
90
|
|
|
86
91
|
```sh
|
|
87
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
92
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.15
|
|
88
93
|
```
|
|
89
94
|
|
|
90
95
|
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/auth-common",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-09-
|
|
4
|
+
"version": "0.1.18-rc.16",
|
|
5
|
+
"generatedAt": "2026-09-12T08:39:52.720Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/auth-common
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/auth-common": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/auth-common": "^0.1.18-rc.16"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
Everything a server and a browser must agree on to talk authentication: aliases, the shared
|
|
14
14
|
entrypoint declarations, the signature guard, and the contract for resolving the organization
|
|
@@ -35,7 +35,7 @@ entity a token names.
|
|
|
35
35
|
|
|
36
36
|
| Export | Description |
|
|
37
37
|
|--------|-------------|
|
|
38
|
-
| `
|
|
38
|
+
| `authEntrypoints` | The shared auth protocol tree — `AUTHEN*`, `CAUTHEN*`, `DISPATCHER`, `DISPATCHER_SURROGATE`, `DISPATCHER_AUTHEN`. Server and client packages bind the entries they serve |
|
|
39
39
|
| `managerEntrypoints` | The auth-manager web API entrypoints (profile → entity slug, auth delegation) |
|
|
40
40
|
| `makeBasicEd25519Guard(resource, opts?)` | The `GUARD_ED25519` guard service: signs outgoing requests as a client, verifies time/nonce/signature as a server |
|
|
41
41
|
| `authMiddleware` | Loading-stage context middleware that attaches the guard's token to every guarded backend entrypoint's `invoke`/`call` |
|
|
@@ -102,14 +102,15 @@ Declare an entrypoint with a guard so both sides agree on the alias, and compose
|
|
|
102
102
|
gate inside the same options object:
|
|
103
103
|
|
|
104
104
|
```typescript
|
|
105
|
-
import {
|
|
105
|
+
import { contract, protocol, typed } from '@owlmeans/entrypoint'
|
|
106
106
|
import { route, backend } from '@owlmeans/route'
|
|
107
107
|
import { DEFAULT_GUARD } from '@owlmeans/auth-common'
|
|
108
108
|
|
|
109
109
|
// PRODUCT_GATE is the consuming app's own gate alias, registered as a GateService on its context.
|
|
110
|
-
|
|
110
|
+
protocol(
|
|
111
111
|
route('api:account', '/account', backend()),
|
|
112
|
-
|
|
112
|
+
contract(typed<Account>()),
|
|
113
|
+
{ guards: DEFAULT_GUARD, gate: { alias: PRODUCT_GATE, params: ['my-service-account-{entity}'] } },
|
|
113
114
|
)
|
|
114
115
|
```
|
|
115
116
|
|
package/build/entrypoints.d.ts
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { AllowanceRequest, AllowanceResponse, AuthCredentials, AuthToken } from '@owlmeans/auth';
|
|
2
|
+
import type { SurrogateQuery } from './schemas.js';
|
|
3
|
+
/** Shared authentication protocols, bound independently by server and browser packages. */
|
|
4
|
+
export declare const authProtocols: {
|
|
5
|
+
authen: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
6
|
+
init: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
7
|
+
body: AllowanceRequest;
|
|
8
|
+
}, AllowanceResponse>;
|
|
9
|
+
authenticate: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
10
|
+
body: AuthCredentials;
|
|
11
|
+
}, AuthToken>;
|
|
12
|
+
rely: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
13
|
+
query: Partial<AuthToken>;
|
|
14
|
+
}, undefined>;
|
|
15
|
+
client: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
16
|
+
login: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
17
|
+
loginDefault: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
18
|
+
loginTyped: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
19
|
+
flowEnter: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
20
|
+
dispatcher: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
21
|
+
query: AuthToken;
|
|
22
|
+
}, undefined>;
|
|
23
|
+
surrogate: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
24
|
+
query: SurrogateQuery;
|
|
25
|
+
}, undefined>;
|
|
26
|
+
dispatcherAuthenticate: import("@owlmeans/entrypoint").EntrypointProtocol<{
|
|
27
|
+
body: AuthToken;
|
|
28
|
+
}, AuthToken>;
|
|
29
|
+
};
|
|
30
|
+
/** Shared manager authentication protocols. */
|
|
31
|
+
export declare const managerProtocols: {
|
|
32
|
+
profile: {
|
|
33
|
+
base: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
34
|
+
toEntityId: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
35
|
+
};
|
|
36
|
+
auth: {
|
|
37
|
+
base: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
38
|
+
delegate: import("@owlmeans/entrypoint").EntrypointProtocol<import("@owlmeans/entrypoint").OpenRequest, import("@owlmeans/entrypoint").OpenValue>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
3
41
|
//# sourceMappingURL=entrypoints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.d.ts","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"
|
|
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"}
|
package/build/entrypoints.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, AllowanceRequestSchema, AuthCredentialsSchema, AuthTokenSchema, CAUTHEN, CAUTHEN_AUTHEN, CAUTHEN_AUTHEN_DEFAULT, CAUTHEN_AUTHEN_TYPED, DISPATCHER, DISPATCHER_AUTHEN, DISPATCHER_SURROGATE, OptionalAuthTokenSchema, CAUTHEN_FLOW_ENTER } from '@owlmeans/auth';
|
|
2
2
|
// import { AppType } from '@owlmeans/context'
|
|
3
|
-
import {
|
|
3
|
+
import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint';
|
|
4
4
|
import { route, RouteMethod, frontend, backend, socket } from '@owlmeans/route';
|
|
5
5
|
import { DISPATCHER_PATH, SURROGATE_PATH, WEB_API, authApi } from './consts.js';
|
|
6
6
|
import { SurrogateQuerySchema } from './schemas.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Also it can be default starting point to be redirected to an external identity provider.
|
|
20
|
-
entrypoint(route(DISPATCHER, DISPATCHER_PATH, frontend({ service: DISPATCHER })),
|
|
21
|
-
// This entrypoint is sticky - it means it's always attach to client router.
|
|
22
|
-
// It's required here cause every web app needs dispatcher route to authorize
|
|
23
|
-
// rediected users.
|
|
24
|
-
filter(query(AuthTokenSchema), { sticky: true })),
|
|
7
|
+
/** Shared authentication protocols, bound independently by server and browser packages. */
|
|
8
|
+
export const authProtocols = {
|
|
9
|
+
authen: openProtocol(route(AUTHEN, '/authentication', backend())),
|
|
10
|
+
init: protocol(route(AUTHEN_INIT, '/init', backend(AUTHEN, RouteMethod.POST)), contract.request({ body: typed(AllowanceRequestSchema) }, typed())),
|
|
11
|
+
authenticate: protocol(route(AUTHEN_AUTHEN, '/authenticate', backend(AUTHEN, RouteMethod.POST)), contract.request({ body: typed(AuthCredentialsSchema) }, typed())),
|
|
12
|
+
rely: protocol(route(AUTHEN_RELY, '/rely', socket(AUTHEN)), contract.request({ query: typed(OptionalAuthTokenSchema) }, typed())),
|
|
13
|
+
client: openProtocol(route(CAUTHEN, '/authentication', frontend())),
|
|
14
|
+
login: openProtocol(route(CAUTHEN_AUTHEN, '/login', frontend(CAUTHEN))),
|
|
15
|
+
loginDefault: openProtocol(route(CAUTHEN_AUTHEN_DEFAULT, '/', frontend(CAUTHEN_AUTHEN, true))),
|
|
16
|
+
loginTyped: openProtocol(route(CAUTHEN_AUTHEN_TYPED, '/:type', frontend(CAUTHEN_AUTHEN))),
|
|
17
|
+
flowEnter: openProtocol(route(CAUTHEN_FLOW_ENTER, '/', frontend())),
|
|
18
|
+
dispatcher: protocol(route(DISPATCHER, DISPATCHER_PATH, frontend({ service: DISPATCHER })), contract.request({ query: typed(AuthTokenSchema) }, typed()), { sticky: true }),
|
|
25
19
|
// The login window an embedded application opens one level up.
|
|
26
20
|
//
|
|
27
21
|
// Top level and with no parent, so it renders outside every application layout — a popup must
|
|
@@ -29,17 +23,22 @@ export const entrypoints = [
|
|
|
29
23
|
// dispatcher is: it must attach to the client router regardless of service selection. It carries
|
|
30
24
|
// no `service`, unlike the dispatcher, because nothing server-side ever addresses it — the
|
|
31
25
|
// provider's callback goes to the dispatcher. And no guard: it is where a signed-out user lands.
|
|
32
|
-
|
|
26
|
+
surrogate: protocol(route(DISPATCHER_SURROGATE, SURROGATE_PATH, frontend()), contract.request({ query: typed(SurrogateQuerySchema) }, typed()), { sticky: true }),
|
|
33
27
|
// This is a helper route that representes a API endpoint of service provider that wants to authenticate
|
|
34
28
|
// a user with OwlMeans server-auth library.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
dispatcherAuthenticate: protocol(route(DISPATCHER_AUTHEN, '/authenticate', backend(null, RouteMethod.POST)), contract.request({ body: typed(AuthTokenSchema) }, typed())),
|
|
30
|
+
};
|
|
31
|
+
/** Shared manager authentication protocols. */
|
|
32
|
+
export const managerProtocols = {
|
|
33
|
+
profile: {
|
|
34
|
+
base: openProtocol(route(authApi.profile.base, '/profile', backend({ service: WEB_API }))),
|
|
35
|
+
toEntityId: openProtocol(route(authApi.profile.toEntityId, '/to-entity-id', backend(authApi.profile.base, RouteMethod.POST))),
|
|
36
|
+
},
|
|
37
|
+
auth: {
|
|
38
|
+
base: openProtocol(route(authApi.auth.base, '/auth', backend({ service: WEB_API }))),
|
|
39
|
+
delegate: openProtocol(route(authApi.auth.delegate, '/delegate', backend(authApi.auth.base, RouteMethod.POST))),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
43
42
|
// const skipEntrypoints = [DISPATCHER]
|
|
44
43
|
// export const authBackendEntrypoints = entrypoints.filter(
|
|
45
44
|
// module => !skipEntrypoints.includes(module.alias) && module.route.route.type === AppType.Backend
|
package/build/entrypoints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,qBAAqB,EAC9F,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,UAAU,EAClG,iBAAiB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,kBAAkB,EACrF,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"entrypoints.js","sourceRoot":"","sources":["../src/entrypoints.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,qBAAqB,EAC9F,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,UAAU,EAClG,iBAAiB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,kBAAkB,EACrF,MAAM,gBAAgB,CAAA;AAEvB,8CAA8C;AAC9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAE,KAAK,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/C,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE;QACP,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/auth-common",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.16",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
33
|
-
"@owlmeans/auth-common": "^0.1.18-rc.
|
|
34
|
-
"@owlmeans/basic-ids": "^0.1.18-rc.
|
|
35
|
-
"@owlmeans/basic-keys": "^0.1.18-rc.
|
|
36
|
-
"@owlmeans/client-entrypoint": "^0.1.18-rc.
|
|
37
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
38
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
39
|
-
"@owlmeans/resource": "^0.1.18-rc.
|
|
40
|
-
"@owlmeans/route": "^0.1.18-rc.
|
|
32
|
+
"@owlmeans/auth": "^0.1.18-rc.12",
|
|
33
|
+
"@owlmeans/auth-common": "^0.1.18-rc.16",
|
|
34
|
+
"@owlmeans/basic-ids": "^0.1.18-rc.12",
|
|
35
|
+
"@owlmeans/basic-keys": "^0.1.18-rc.15",
|
|
36
|
+
"@owlmeans/client-entrypoint": "^0.1.18-rc.16",
|
|
37
|
+
"@owlmeans/context": "^0.1.18-rc.11",
|
|
38
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.14",
|
|
39
|
+
"@owlmeans/resource": "^0.1.18-rc.12",
|
|
40
|
+
"@owlmeans/route": "^0.1.18-rc.12"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@owlmeans/dep-config": "workspace:*",
|
|
44
|
-
"@owlmeans/test-auth": "^0.1.18-rc.
|
|
44
|
+
"@owlmeans/test-auth": "^0.1.18-rc.16",
|
|
45
45
|
"@types/bun": "^1.4.0",
|
|
46
46
|
"nodemon": "^3.1.14",
|
|
47
47
|
"typescript": "^7.0.2"
|
package/src/entrypoints.ts
CHANGED
|
@@ -4,31 +4,32 @@ import {
|
|
|
4
4
|
AuthTokenSchema, CAUTHEN, CAUTHEN_AUTHEN, CAUTHEN_AUTHEN_DEFAULT, CAUTHEN_AUTHEN_TYPED, DISPATCHER,
|
|
5
5
|
DISPATCHER_AUTHEN, DISPATCHER_SURROGATE, OptionalAuthTokenSchema, CAUTHEN_FLOW_ENTER
|
|
6
6
|
} from '@owlmeans/auth'
|
|
7
|
+
import type { AllowanceRequest, AllowanceResponse, AuthCredentials, AuthToken } from '@owlmeans/auth'
|
|
7
8
|
// import { AppType } from '@owlmeans/context'
|
|
8
|
-
import {
|
|
9
|
+
import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint'
|
|
9
10
|
import { route, RouteMethod, frontend, backend, socket } from '@owlmeans/route'
|
|
10
11
|
import { DISPATCHER_PATH, SURROGATE_PATH, WEB_API, authApi } from './consts.js'
|
|
11
12
|
import { SurrogateQuerySchema } from './schemas.js'
|
|
13
|
+
import type { SurrogateQuery } from './schemas.js'
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
/** Shared authentication protocols, bound independently by server and browser packages. */
|
|
16
|
+
export const authProtocols = {
|
|
17
|
+
authen: openProtocol(route(AUTHEN, '/authentication', backend())),
|
|
18
|
+
init: protocol(route(AUTHEN_INIT, '/init', backend(AUTHEN, RouteMethod.POST)),
|
|
19
|
+
contract.request({ body: typed<AllowanceRequest>(AllowanceRequestSchema) }, typed<AllowanceResponse>())),
|
|
20
|
+
authenticate: protocol(route(AUTHEN_AUTHEN, '/authenticate', backend(AUTHEN, RouteMethod.POST)),
|
|
21
|
+
contract.request({ body: typed<AuthCredentials>(AuthCredentialsSchema) }, typed<AuthToken>())),
|
|
22
|
+
rely: protocol(route(AUTHEN_RELY, '/rely', socket(AUTHEN)),
|
|
23
|
+
contract.request({ query: typed<Partial<AuthToken>>(OptionalAuthTokenSchema) }, typed())),
|
|
24
|
+
client: openProtocol(route(CAUTHEN, '/authentication', frontend())),
|
|
25
|
+
login: openProtocol(route(CAUTHEN_AUTHEN, '/login', frontend(CAUTHEN))),
|
|
26
|
+
loginDefault: openProtocol(route(CAUTHEN_AUTHEN_DEFAULT, '/', frontend(CAUTHEN_AUTHEN, true))),
|
|
27
|
+
loginTyped: openProtocol(route(CAUTHEN_AUTHEN_TYPED, '/:type', frontend(CAUTHEN_AUTHEN))),
|
|
28
|
+
flowEnter: openProtocol(route(CAUTHEN_FLOW_ENTER, '/', frontend())),
|
|
29
|
+
dispatcher: protocol(
|
|
27
30
|
route(DISPATCHER, DISPATCHER_PATH, frontend({ service: DISPATCHER })),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// rediected users.
|
|
31
|
-
filter(query(AuthTokenSchema), { sticky: true })
|
|
31
|
+
contract.request({ query: typed<AuthToken>(AuthTokenSchema) }, typed()),
|
|
32
|
+
{ sticky: true },
|
|
32
33
|
),
|
|
33
34
|
// The login window an embedded application opens one level up.
|
|
34
35
|
//
|
|
@@ -37,27 +38,34 @@ export const entrypoints = [
|
|
|
37
38
|
// dispatcher is: it must attach to the client router regardless of service selection. It carries
|
|
38
39
|
// no `service`, unlike the dispatcher, because nothing server-side ever addresses it — the
|
|
39
40
|
// provider's callback goes to the dispatcher. And no guard: it is where a signed-out user lands.
|
|
40
|
-
|
|
41
|
+
surrogate: protocol(
|
|
41
42
|
route(DISPATCHER_SURROGATE, SURROGATE_PATH, frontend()),
|
|
42
|
-
|
|
43
|
+
contract.request({ query: typed<SurrogateQuery>(SurrogateQuerySchema) }, typed()),
|
|
44
|
+
{ sticky: true },
|
|
43
45
|
),
|
|
44
46
|
// This is a helper route that representes a API endpoint of service provider that wants to authenticate
|
|
45
47
|
// a user with OwlMeans server-auth library.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
dispatcherAuthenticate: protocol(route(DISPATCHER_AUTHEN, '/authenticate', backend(null, RouteMethod.POST)),
|
|
49
|
+
contract.request({ body: typed<AuthToken>(AuthTokenSchema) }, typed<AuthToken>())),
|
|
50
|
+
}
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
/** Shared manager authentication protocols. */
|
|
53
|
+
export const managerProtocols = {
|
|
54
|
+
profile: {
|
|
55
|
+
base: openProtocol(route(authApi.profile.base, '/profile', backend({ service: WEB_API }))),
|
|
56
|
+
toEntityId: openProtocol(route(
|
|
52
57
|
authApi.profile.toEntityId, '/to-entity-id',
|
|
53
58
|
backend(authApi.profile.base, RouteMethod.POST)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
)),
|
|
60
|
+
},
|
|
61
|
+
auth: {
|
|
62
|
+
base: openProtocol(route(authApi.auth.base, '/auth', backend({ service: WEB_API }))),
|
|
63
|
+
delegate: openProtocol(route(
|
|
57
64
|
authApi.auth.delegate, '/delegate',
|
|
58
65
|
backend(authApi.auth.base, RouteMethod.POST)
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
)),
|
|
67
|
+
},
|
|
68
|
+
}
|
|
61
69
|
|
|
62
70
|
// const skipEntrypoints = [DISPATCHER]
|
|
63
71
|
// export const authBackendEntrypoints = entrypoints.filter(
|