@owlmeans/web-oauth 0.1.18-rc.20 → 0.1.18-rc.21
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 +1 -1
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/web-oauth/SKILL.md +3 -3
- package/build/components/device-screen.js +2 -2
- package/build/components/device-screen.js.map +1 -1
- package/build/hooks/use-oauth-consent.d.ts.map +1 -1
- package/build/hooks/use-oauth-consent.js +2 -2
- package/build/hooks/use-oauth-consent.js.map +1 -1
- package/build/i18n.js +9 -9
- package/build/i18n.js.map +1 -1
- package/package.json +19 -19
- package/src/components/device-screen.tsx +2 -2
- package/src/hooks/use-oauth-consent.ts +2 -2
- package/src/i18n.ts +10 -9
- package/tests/consent.spec.ts +10 -10
- package/tests/device.spec.ts +2 -2
- package/tests/done.spec.ts +2 -2
- package/tests/harness/mount.tsx +4 -0
- package/tests/helpers.ts +17 -2
- package/tests/languages.spec.ts +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
6
6
|
your project's skill store (`.agents/skills/`):
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
9
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.49
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
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/web-oauth",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.21",
|
|
5
|
+
"generatedAt": "2026-10-05T21:03:06.408Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/web-oauth
|
|
9
9
|
|
|
10
10
|
**Layer:** Web (React, shadcn + Tailwind v4)
|
|
11
|
-
**Install:** `"@owlmeans/web-oauth": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/web-oauth": "^0.1.18-rc.21"` in `dependencies`
|
|
12
12
|
**Contracts:** `@owlmeans/oauth` — aliases, `makeOAuthProtocols`, `oauthFlow`, `ConsentView`
|
|
13
13
|
**Server half:** `@owlmeans/server-oauth` (its `consentUrl`/`deviceUrl` must point at these screens)
|
|
14
14
|
|
|
@@ -80,9 +80,9 @@ of this package's runtime, and `tests/package-boundary.spec.ts` fails on any `fr
|
|
|
80
80
|
|
|
81
81
|
The consent screen never assumes a session. When `auth.authenticated()` is empty it builds
|
|
82
82
|
`makeFlowModel(oauthFlow)` (never the live flow slot), sets `ref`, transits the explicit `sign-in`
|
|
83
|
-
step, calls `suspendFlow(
|
|
83
|
+
step, calls `flowLandingOf(context).suspendFlow(model, { expiresAt: now + OAUTH_SUSPEND_TTL_MS })` and sends the
|
|
84
84
|
browser to `DISPATCHER`. The chooser / Google / supervisor sign-in then lands through
|
|
85
|
-
`resumeSuspendedFlow` (the landing rule in `/login-plugins`, `/client-flow`) — back on the consent
|
|
85
|
+
`flowLandingOf(context).resumeSuspendedFlow` (the landing rule in `/login-plugins`, `/client-flow`) — back on the consent
|
|
86
86
|
screen with the **same `ref`**, now authenticated. What is stored is the destination entrypoint alias
|
|
87
87
|
plus the payload query, delete-on-read and expiry-checked, in `FLOW_STATE` (IndexedDB, so it survives
|
|
88
88
|
Google's full-page round trip). A plugin that still navigates to `HOME` instead of the landing breaks
|
|
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
3
3
|
import { useContext, useNavigate } from '@owlmeans/client';
|
|
4
4
|
import { useI18nLib } from '@owlmeans/client-i18n';
|
|
5
5
|
import { makeFlowModel } from '@owlmeans/flow';
|
|
6
|
-
import {
|
|
6
|
+
import { oauthFlow, oauthFormatHelper, OAuthFlowStep, OAUTH_PAYLOAD_REF } from '@owlmeans/oauth';
|
|
7
7
|
import { OAUTH_I18N } from '../consts.js';
|
|
8
8
|
import { Button } from '../@/components/ui/button.js';
|
|
9
9
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../@/components/ui/card.js';
|
|
@@ -25,7 +25,7 @@ export const OAuthDeviceScreen = () => {
|
|
|
25
25
|
const proceed = useCallback(async (typed) => {
|
|
26
26
|
const model = await makeFlowModel(oauthFlow);
|
|
27
27
|
model.enter(OAuthFlowStep.Verify);
|
|
28
|
-
model.updatePayload({ [OAUTH_PAYLOAD_REF]: normalizeUserCode(typed) });
|
|
28
|
+
model.updatePayload({ [OAUTH_PAYLOAD_REF]: oauthFormatHelper.normalizeUserCode(typed) });
|
|
29
29
|
model.transit('next', true);
|
|
30
30
|
const destination = model.step();
|
|
31
31
|
await nav.navigate(context.entrypoint(destination.module), { query: model.payload() });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-screen.js","sourceRoot":"","sources":["../../src/components/device-screen.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"device-screen.js","sourceRoot":"","sources":["../../src/components/device-screen.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE1D,OAAO,EAAE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AAM,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE,aACpF,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,aAC9D,KAAC,KAAK,IAAC,OAAO,EAAC,mBAAmB,YAAE,CAAC,CAAC,YAAY,CAAC,GAAS,EAC5D,KAAC,KAAK,IACJ,EAAE,EAAC,mBAAmB,iBAAa,oBAAoB,EAAC,YAAY,EAAC,KAAK,EAC1E,WAAW,EAAC,WAAW,EAAC,KAAK,EAAE,IAAI,EACnC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAC9C,IACE,EACN,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,iBAAa,qBAAqB,EAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,YACjF,CAAC,CAAC,UAAU,CAAC,GACP,IACJ,GACK,IACT,GACH,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-oauth-consent.d.ts","sourceRoot":"","sources":["../../src/hooks/use-oauth-consent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-oauth-consent.d.ts","sourceRoot":"","sources":["../../src/hooks/use-oauth-consent.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyG,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAGpK,OAAO,KAAK,EAAkC,eAAe,EAAE,MAAM,YAAY,CAAA;AASjF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,QAAS,MAAM,GAAG,IAAI,YAAY,sBAAsB,KAAG,eAkHtF,CAAA"}
|
|
@@ -2,11 +2,11 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { useContext, useNavigate } from '@owlmeans/client';
|
|
3
3
|
import { DEFAULT_ALIAS as AUTH_SERVICE } from '@owlmeans/client-auth';
|
|
4
4
|
import { DISPATCHER } from '@owlmeans/auth';
|
|
5
|
-
import { suspendFlow } from '@owlmeans/client-flow';
|
|
6
5
|
import { makeFlowModel } from '@owlmeans/flow';
|
|
7
6
|
import { ResilientError } from '@owlmeans/error';
|
|
8
7
|
import { makeOAuthProtocols, oauthFlow, OAuthFlowStep, OAUTH_PAYLOAD_KIND, OAUTH_PAYLOAD_REF } from '@owlmeans/oauth';
|
|
9
8
|
import { OAUTH_SUSPEND_TTL_MS } from '../consts.js';
|
|
9
|
+
import { flowLandingOf } from '@owlmeans/client-flow';
|
|
10
10
|
const errorKindOf = (message) => message.includes('request-expired') ? 'expired'
|
|
11
11
|
: message.includes('request-not-found') ? 'not-found'
|
|
12
12
|
: message.includes('forbidden') ? 'forbidden'
|
|
@@ -44,7 +44,7 @@ export const useOAuthConsent = (ref, aliases) => {
|
|
|
44
44
|
const model = await makeFlowModel(oauthFlow);
|
|
45
45
|
model.updatePayload({ [OAUTH_PAYLOAD_REF]: target });
|
|
46
46
|
model.transit(OAuthFlowStep.SignIn, true);
|
|
47
|
-
await suspendFlow(
|
|
47
|
+
await flowLandingOf(context).suspendFlow(model, { expiresAt: Date.now() + OAUTH_SUSPEND_TTL_MS });
|
|
48
48
|
const dispatcher = await context.entrypoint(DISPATCHER).url();
|
|
49
49
|
window.location.href = dispatcher;
|
|
50
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-oauth-consent.js","sourceRoot":"","sources":["../../src/hooks/use-oauth-consent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,aAA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AAA;YAChB,MAAM,GAAG,CAAC,QAAQ,CAChB,OAAO,CAAC,UAAU,CAA2B,WAAW,CAAC,MAAO,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAC9F,CAAA;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,CAAC,CAAC,CAAA;QACT,CAAC;IACH,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IAEf,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC3C,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE;YAAE,OAAM;QACrC,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,OAAO,CAAc,YAAY,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YAClE,MAAM,cAAc,CAAC,GAAG,CAAC,CAAA;QAC3B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,CAAC,CAAC,CAAA;QACT,CAAC;IACH,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IAET,OAAO;QACL,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS;QAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC;QAChC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1B,aAAa;KACd,CAAA;AACH,CAAC,CAAA"}
|
package/build/i18n.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { addI18nLib } from '@owlmeans/i18n';
|
|
2
1
|
import { OAUTH_I18N } from './consts.js';
|
|
3
2
|
import en from './i18n/en.json' with { type: 'json' };
|
|
4
3
|
import pl from './i18n/pl.json' with { type: 'json' };
|
|
@@ -8,12 +7,13 @@ import uk from './i18n/uk.json' with { type: 'json' };
|
|
|
8
7
|
import es from './i18n/es.json' with { type: 'json' };
|
|
9
8
|
import de from './i18n/de.json' with { type: 'json' };
|
|
10
9
|
import fr from './i18n/fr.json' with { type: 'json' };
|
|
11
|
-
|
|
12
|
-
addI18nLib('
|
|
13
|
-
addI18nLib('
|
|
14
|
-
addI18nLib('
|
|
15
|
-
addI18nLib('
|
|
16
|
-
addI18nLib('
|
|
17
|
-
addI18nLib('
|
|
18
|
-
addI18nLib('
|
|
10
|
+
import { i18nHelper } from '@owlmeans/i18n';
|
|
11
|
+
i18nHelper.addI18nLib('en', OAUTH_I18N, en);
|
|
12
|
+
i18nHelper.addI18nLib('pl', OAUTH_I18N, pl);
|
|
13
|
+
i18nHelper.addI18nLib('ru', OAUTH_I18N, ru);
|
|
14
|
+
i18nHelper.addI18nLib('be', OAUTH_I18N, be);
|
|
15
|
+
i18nHelper.addI18nLib('uk', OAUTH_I18N, uk);
|
|
16
|
+
i18nHelper.addI18nLib('es', OAUTH_I18N, es);
|
|
17
|
+
i18nHelper.addI18nLib('de', OAUTH_I18N, de);
|
|
18
|
+
i18nHelper.addI18nLib('fr', OAUTH_I18N, fr);
|
|
19
19
|
//# sourceMappingURL=i18n.js.map
|
package/build/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACrD,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AAC3C,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AAC3C,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AAC3C,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AAC3C,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AAC3C,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AAC3C,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA;AAC3C,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/web-oauth",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The browser half of @owlmeans/oauth — the consent, device-code and done screens an OAuth 2.1 sign-in ends on, driven by the shared consent flow, plus the entrypoints and app-config helper that put them on a web app with no wiring beyond configuration.",
|
|
6
6
|
"type": "module",
|
|
@@ -23,20 +23,20 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@owlmeans/auth-common": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/client": "^0.1.18-rc.
|
|
28
|
-
"@owlmeans/client-auth": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/client-context": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/client-entrypoint": "^0.1.18-rc.
|
|
31
|
-
"@owlmeans/client-flow": "^0.1.18-rc.
|
|
32
|
-
"@owlmeans/client-i18n": "^0.1.18-rc.
|
|
33
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
34
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
35
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
36
|
-
"@owlmeans/flow": "^0.1.18-rc.
|
|
37
|
-
"@owlmeans/i18n": "^0.1.18-rc.
|
|
38
|
-
"@owlmeans/oauth": "^0.1.18-rc.
|
|
39
|
-
"@owlmeans/route": "^0.1.18-rc.
|
|
26
|
+
"@owlmeans/auth-common": "^0.1.18-rc.47",
|
|
27
|
+
"@owlmeans/client": "^0.1.18-rc.51",
|
|
28
|
+
"@owlmeans/client-auth": "^0.1.18-rc.58",
|
|
29
|
+
"@owlmeans/client-context": "^0.1.18-rc.48",
|
|
30
|
+
"@owlmeans/client-entrypoint": "^0.1.18-rc.47",
|
|
31
|
+
"@owlmeans/client-flow": "^0.1.18-rc.54",
|
|
32
|
+
"@owlmeans/client-i18n": "^0.1.18-rc.50",
|
|
33
|
+
"@owlmeans/context": "^0.1.18-rc.34",
|
|
34
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.41",
|
|
35
|
+
"@owlmeans/error": "^0.1.18-rc.38",
|
|
36
|
+
"@owlmeans/flow": "^0.1.18-rc.45",
|
|
37
|
+
"@owlmeans/i18n": "^0.1.18-rc.39",
|
|
38
|
+
"@owlmeans/oauth": "^0.1.18-rc.16",
|
|
39
|
+
"@owlmeans/route": "^0.1.18-rc.35"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@radix-ui/react-label": "*",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@owlmeans/dep-config": "workspace:*",
|
|
53
|
-
"@owlmeans/test-auth": "^0.1.18-rc.
|
|
54
|
-
"@owlmeans/test-ui": "^0.1.18-rc.
|
|
55
|
-
"@owlmeans/web-client": "^0.1.18-rc.
|
|
56
|
-
"@owlmeans/web-flow": "^0.1.18-rc.
|
|
53
|
+
"@owlmeans/test-auth": "^0.1.18-rc.46",
|
|
54
|
+
"@owlmeans/test-ui": "^0.1.18-rc.49",
|
|
55
|
+
"@owlmeans/web-client": "^0.1.18-rc.61",
|
|
56
|
+
"@owlmeans/web-flow": "^0.1.18-rc.53",
|
|
57
57
|
"@radix-ui/react-label": "^2.1.15",
|
|
58
58
|
"@radix-ui/react-slot": "^1.3.3",
|
|
59
59
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -5,7 +5,7 @@ import type { RoutedComponent } from '@owlmeans/client'
|
|
|
5
5
|
import { useI18nLib } from '@owlmeans/client-i18n'
|
|
6
6
|
import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
|
|
7
7
|
import { makeFlowModel } from '@owlmeans/flow'
|
|
8
|
-
import {
|
|
8
|
+
import { oauthFlow, oauthFormatHelper, OAuthFlowStep, OAUTH_PAYLOAD_REF } from '@owlmeans/oauth'
|
|
9
9
|
import { OAUTH_I18N } from '../consts.js'
|
|
10
10
|
import { Button } from '../@/components/ui/button.js'
|
|
11
11
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../@/components/ui/card.js'
|
|
@@ -29,7 +29,7 @@ export const OAuthDeviceScreen: RoutedComponent = () => {
|
|
|
29
29
|
const proceed = useCallback(async (typed: string) => {
|
|
30
30
|
const model = await makeFlowModel(oauthFlow)
|
|
31
31
|
model.enter(OAuthFlowStep.Verify)
|
|
32
|
-
model.updatePayload({ [OAUTH_PAYLOAD_REF]: normalizeUserCode(typed) })
|
|
32
|
+
model.updatePayload({ [OAUTH_PAYLOAD_REF]: oauthFormatHelper.normalizeUserCode(typed) })
|
|
33
33
|
model.transit('next', true)
|
|
34
34
|
const destination = model.step()
|
|
35
35
|
await nav.navigate(
|
|
@@ -3,13 +3,13 @@ import { useContext, useNavigate } from '@owlmeans/client'
|
|
|
3
3
|
import { DEFAULT_ALIAS as AUTH_SERVICE } from '@owlmeans/client-auth'
|
|
4
4
|
import type { AuthService } from '@owlmeans/auth-common'
|
|
5
5
|
import { DISPATCHER } from '@owlmeans/auth'
|
|
6
|
-
import { suspendFlow } from '@owlmeans/client-flow'
|
|
7
6
|
import { makeFlowModel } from '@owlmeans/flow'
|
|
8
7
|
import { ResilientError } from '@owlmeans/error'
|
|
9
8
|
import { makeOAuthProtocols, oauthFlow, OAuthFlowStep, OAUTH_PAYLOAD_KIND, OAUTH_PAYLOAD_REF, type ConsentView, type OAuthEntrypointOptions } from '@owlmeans/oauth'
|
|
10
9
|
import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
|
|
11
10
|
import { OAUTH_SUSPEND_TTL_MS } from '../consts.js'
|
|
12
11
|
import type { ConsentErrorKind, ConsentStage, UseOAuthConsent } from './types.js'
|
|
12
|
+
import { flowLandingOf } from '@owlmeans/client-flow'
|
|
13
13
|
|
|
14
14
|
const errorKindOf = (message: string): ConsentErrorKind =>
|
|
15
15
|
message.includes('request-expired') ? 'expired'
|
|
@@ -53,7 +53,7 @@ export const useOAuthConsent = (ref: string | null, aliases?: OAuthEntrypointOpt
|
|
|
53
53
|
const model = await makeFlowModel(oauthFlow)
|
|
54
54
|
model.updatePayload({ [OAUTH_PAYLOAD_REF]: target })
|
|
55
55
|
model.transit(OAuthFlowStep.SignIn, true)
|
|
56
|
-
await suspendFlow(
|
|
56
|
+
await flowLandingOf(context).suspendFlow(model, { expiresAt: Date.now() + OAUTH_SUSPEND_TTL_MS })
|
|
57
57
|
|
|
58
58
|
const dispatcher = await context.entrypoint<ClientEntrypoint<string>>(DISPATCHER).url()
|
|
59
59
|
window.location.href = dispatcher
|
package/src/i18n.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { OAUTH_I18N } from './consts.js'
|
|
3
3
|
|
|
4
4
|
import en from './i18n/en.json' with { type: 'json' }
|
|
@@ -9,12 +9,13 @@ import uk from './i18n/uk.json' with { type: 'json' }
|
|
|
9
9
|
import es from './i18n/es.json' with { type: 'json' }
|
|
10
10
|
import de from './i18n/de.json' with { type: 'json' }
|
|
11
11
|
import fr from './i18n/fr.json' with { type: 'json' }
|
|
12
|
+
import { i18nHelper } from '@owlmeans/i18n'
|
|
12
13
|
|
|
13
|
-
addI18nLib('en', OAUTH_I18N, en)
|
|
14
|
-
addI18nLib('pl', OAUTH_I18N, pl)
|
|
15
|
-
addI18nLib('ru', OAUTH_I18N, ru)
|
|
16
|
-
addI18nLib('be', OAUTH_I18N, be)
|
|
17
|
-
addI18nLib('uk', OAUTH_I18N, uk)
|
|
18
|
-
addI18nLib('es', OAUTH_I18N, es)
|
|
19
|
-
addI18nLib('de', OAUTH_I18N, de)
|
|
20
|
-
addI18nLib('fr', OAUTH_I18N, fr)
|
|
14
|
+
i18nHelper.addI18nLib('en', OAUTH_I18N, en)
|
|
15
|
+
i18nHelper.addI18nLib('pl', OAUTH_I18N, pl)
|
|
16
|
+
i18nHelper.addI18nLib('ru', OAUTH_I18N, ru)
|
|
17
|
+
i18nHelper.addI18nLib('be', OAUTH_I18N, be)
|
|
18
|
+
i18nHelper.addI18nLib('uk', OAUTH_I18N, uk)
|
|
19
|
+
i18nHelper.addI18nLib('es', OAUTH_I18N, es)
|
|
20
|
+
i18nHelper.addI18nLib('de', OAUTH_I18N, de)
|
|
21
|
+
i18nHelper.addI18nLib('fr', OAUTH_I18N, fr)
|
package/tests/consent.spec.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { afterAll, describe, expect, test } from 'bun:test'
|
|
2
|
-
import { closeBrowser } from '@owlmeans/test-ui'
|
|
3
2
|
import { OAUTH_CONSENT_PATH, oauth } from '@owlmeans/oauth'
|
|
4
3
|
import { OAUTH_SUSPEND_TTL_MS } from '../src/consts.js'
|
|
5
4
|
import en from '../src/i18n/en.json' with { type: 'json' }
|
|
6
|
-
import { bearer, codeView, deviceView, open, refusal, TIMEOUT } from './helpers.js'
|
|
5
|
+
import { bearer, codeView, deviceView, open, refusal, TIMEOUT, untilPath } from './helpers.js'
|
|
7
6
|
import { HARNESS_URL } from './context.js'
|
|
7
|
+
import { browserHelper } from '@owlmeans/test-ui'
|
|
8
8
|
|
|
9
|
-
afterAll(async () => { await closeBrowser() })
|
|
9
|
+
afterAll(async () => { await browserHelper.closeBrowser() })
|
|
10
10
|
|
|
11
11
|
const CONSENT = `${OAUTH_CONSENT_PATH}?ref=ABCD-EFGH`
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ describe('consent screen — signed out', () => {
|
|
|
15
15
|
const before = Date.now()
|
|
16
16
|
const { page, calls, close } = await open(CONSENT)
|
|
17
17
|
try {
|
|
18
|
-
await page
|
|
18
|
+
await untilPath(page, '/dispatcher', 45_000)
|
|
19
19
|
|
|
20
20
|
// Nobody is signed in, so there is nothing to load and nothing to approve.
|
|
21
21
|
expect(calls).toEqual([])
|
|
@@ -44,7 +44,7 @@ describe('consent screen — the round trip through sign-in', () => {
|
|
|
44
44
|
authenticate: true, stubs: { load: { json: deviceView() }, approve: { json: {} } },
|
|
45
45
|
})
|
|
46
46
|
try {
|
|
47
|
-
await page
|
|
47
|
+
await untilPath(page, '/dispatcher', 45_000)
|
|
48
48
|
expect(await page.evaluate(async () => await (window as any).__oauth.suspended())).not.toBeNull()
|
|
49
49
|
|
|
50
50
|
// Any sign-in method ends the same way: the dispatcher is handed a token.
|
|
@@ -79,7 +79,7 @@ describe('consent screen — signed in', () => {
|
|
|
79
79
|
expect(calls).toEqual(['GET ABCD-EFGH'])
|
|
80
80
|
|
|
81
81
|
await page.getByTestId('oauth-consent-approve').click()
|
|
82
|
-
await page
|
|
82
|
+
await untilPath(page, '/oauth/done', 30_000)
|
|
83
83
|
|
|
84
84
|
expect(calls).toEqual(['GET ABCD-EFGH', 'POST ABCD-EFGH/approve'])
|
|
85
85
|
expect(new URL(page.url()).searchParams.get('kind')).toBe('device')
|
|
@@ -127,7 +127,7 @@ describe('consent screen — signed in', () => {
|
|
|
127
127
|
try {
|
|
128
128
|
await page.getByTestId('oauth-consent-approve').waitFor({ state: 'visible', timeout: 45_000 })
|
|
129
129
|
await page.getByTestId('oauth-consent-approve').click()
|
|
130
|
-
await page
|
|
130
|
+
await untilPath(page, '/client-callback', 30_000)
|
|
131
131
|
|
|
132
132
|
expect(page.url()).toBe(target)
|
|
133
133
|
expect(calls).toEqual(['GET req-1', 'POST req-1/approve'])
|
|
@@ -144,7 +144,7 @@ describe('consent screen — signed in', () => {
|
|
|
144
144
|
try {
|
|
145
145
|
await code.page.getByTestId('oauth-consent-deny').waitFor({ state: 'visible', timeout: 45_000 })
|
|
146
146
|
await code.page.getByTestId('oauth-consent-deny').click()
|
|
147
|
-
await code.page
|
|
147
|
+
await untilPath(code.page, '/client-callback', 30_000)
|
|
148
148
|
|
|
149
149
|
expect(code.page.url()).toBe(back)
|
|
150
150
|
expect(code.calls).toEqual(['GET req-1', 'POST req-1/deny'])
|
|
@@ -158,7 +158,7 @@ describe('consent screen — signed in', () => {
|
|
|
158
158
|
try {
|
|
159
159
|
await device.page.getByTestId('oauth-consent-deny').waitFor({ state: 'visible', timeout: 45_000 })
|
|
160
160
|
await device.page.getByTestId('oauth-consent-deny').click()
|
|
161
|
-
await device.page
|
|
161
|
+
await untilPath(device.page, '/oauth/done', 30_000)
|
|
162
162
|
|
|
163
163
|
expect(device.calls).toEqual(['GET ABCD-EFGH', 'POST ABCD-EFGH/deny'])
|
|
164
164
|
expect(await device.page.getByTestId('oauth-done-card').count()).toBe(1)
|
|
@@ -176,7 +176,7 @@ describe('consent screen — signed in', () => {
|
|
|
176
176
|
expect(await page.evaluate(async () => await (window as any).__oauth.token())).not.toBeNull()
|
|
177
177
|
|
|
178
178
|
await page.getByTestId('oauth-consent-switch').click()
|
|
179
|
-
await page
|
|
179
|
+
await untilPath(page, '/dispatcher', 45_000)
|
|
180
180
|
|
|
181
181
|
expect(await page.evaluate(async () => await (window as any).__oauth.token())).toBeNull()
|
|
182
182
|
const record = await page.evaluate(async () => await (window as any).__oauth.suspended()) as
|
package/tests/device.spec.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { afterAll, describe, expect, test } from 'bun:test'
|
|
2
|
-
import { closeBrowser } from '@owlmeans/test-ui'
|
|
3
2
|
import { OAUTH_CONSENT_PATH, OAUTH_DEVICE_PATH } from '@owlmeans/oauth'
|
|
4
3
|
import { deviceView, open, TIMEOUT } from './helpers.js'
|
|
4
|
+
import { browserHelper } from '@owlmeans/test-ui'
|
|
5
5
|
|
|
6
|
-
afterAll(async () => { await closeBrowser() })
|
|
6
|
+
afterAll(async () => { await browserHelper.closeBrowser() })
|
|
7
7
|
|
|
8
8
|
describe('device screen — a link that already carries the code', () => {
|
|
9
9
|
test('goes straight to the consent screen for that code, normalised', async () => {
|
package/tests/done.spec.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { afterAll, describe, expect, test } from 'bun:test'
|
|
2
|
-
import { closeBrowser } from '@owlmeans/test-ui'
|
|
3
2
|
import { OAUTH_DONE_PATH } from '@owlmeans/oauth'
|
|
4
3
|
import en from '../src/i18n/en.json' with { type: 'json' }
|
|
5
4
|
import { open, TIMEOUT } from './helpers.js'
|
|
5
|
+
import { browserHelper } from '@owlmeans/test-ui'
|
|
6
6
|
|
|
7
|
-
afterAll(async () => { await closeBrowser() })
|
|
7
|
+
afterAll(async () => { await browserHelper.closeBrowser() })
|
|
8
8
|
|
|
9
9
|
describe('done screen', () => {
|
|
10
10
|
test('a device sign-in tells the person to close the window — the application picks it up', async () => {
|
package/tests/harness/mount.tsx
CHANGED
|
@@ -45,6 +45,10 @@ service({
|
|
|
45
45
|
}, base)
|
|
46
46
|
base.security = { unsecure: true }
|
|
47
47
|
;(base as { i18n?: unknown }).i18n = { defaultLng: lng, fallbackLng: lng }
|
|
48
|
+
// The app starts in a persisted choice first and the BROWSER's language second — headless Chromium
|
|
49
|
+
// says `en-US`, which beats `fallbackLng`. Stored the way `setLanguage` stores a person's choice
|
|
50
|
+
// (`owlmeans-lng`), so `?lng` wins on every load, whatever an earlier page of this context chose.
|
|
51
|
+
try { localStorage.setItem('owlmeans-lng', lng) } catch (_) { /* storage blocked: stays on the browser's */ }
|
|
48
52
|
|
|
49
53
|
// `ready` stays false: the Router compiles the entrypoint tree into routes ONLY while the context
|
|
50
54
|
// is un-initialized.
|
package/tests/helpers.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import type { Page } from '@owlmeans/test-ui'
|
|
3
3
|
import { makeBearer, USER } from '@owlmeans/test-auth'
|
|
4
4
|
import type { ConsentView } from '@owlmeans/oauth'
|
|
5
5
|
import { HARNESS_URL } from './context.js'
|
|
6
|
+
import { browserHelper } from '@owlmeans/test-ui'
|
|
6
7
|
|
|
7
8
|
/** Generous: a cold harness compiles the whole app on its first request. */
|
|
8
9
|
export const TIMEOUT = 60_000
|
|
@@ -56,7 +57,7 @@ export interface Opened {
|
|
|
56
57
|
export const open = async (
|
|
57
58
|
path: string, opts: { stubs?: Stubs, signedIn?: boolean, lng?: string, authenticate?: boolean } = {}
|
|
58
59
|
): Promise<Opened> => {
|
|
59
|
-
const browser = await launchBrowser({ headless: true })
|
|
60
|
+
const browser = await browserHelper.launchBrowser({ headless: true })
|
|
60
61
|
const context = await browser.newContext()
|
|
61
62
|
const page = await context.newPage()
|
|
62
63
|
page.setDefaultTimeout(30_000)
|
|
@@ -95,3 +96,17 @@ export const open = async (
|
|
|
95
96
|
|
|
96
97
|
return { page, calls, close: async () => { await context.close() } }
|
|
97
98
|
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Wait until the page sits on `pathname`, reading `page.url()` rather than awaiting a navigation.
|
|
102
|
+
* Signing out reloads before the router pushes the dispatcher, and under load `waitForURL` sees the
|
|
103
|
+
* superseded navigation abort (`net::ERR_ABORTED; maybe frame was detached?`) instead of the one that lands.
|
|
104
|
+
*/
|
|
105
|
+
export const untilPath = async (page: Page, pathname: string, timeout = 45_000): Promise<void> => {
|
|
106
|
+
const deadline = Date.now() + timeout
|
|
107
|
+
while (new URL(page.url()).pathname !== pathname) {
|
|
108
|
+
if (Date.now() > deadline) throw new Error(`still on ${page.url()} after ${timeout} ms, expected ${pathname}`)
|
|
109
|
+
await new Promise(resolve => setTimeout(resolve, 100))
|
|
110
|
+
}
|
|
111
|
+
await page.waitForLoadState('load').catch(() => undefined)
|
|
112
|
+
}
|
package/tests/languages.spec.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { afterAll, describe, expect, test } from 'bun:test'
|
|
2
|
-
import { closeBrowser } from '@owlmeans/test-ui'
|
|
3
2
|
import { OAUTH_CONSENT_PATH } from '@owlmeans/oauth'
|
|
4
3
|
import en from '../src/i18n/en.json' with { type: 'json' }
|
|
5
4
|
import pl from '../src/i18n/pl.json' with { type: 'json' }
|
|
@@ -9,8 +8,9 @@ import uk from '../src/i18n/uk.json' with { type: 'json' }
|
|
|
9
8
|
import es from '../src/i18n/es.json' with { type: 'json' }
|
|
10
9
|
import de from '../src/i18n/de.json' with { type: 'json' }
|
|
11
10
|
import { deviceView, open, TIMEOUT } from './helpers.js'
|
|
11
|
+
import { browserHelper } from '@owlmeans/test-ui'
|
|
12
12
|
|
|
13
|
-
afterAll(async () => { await closeBrowser() })
|
|
13
|
+
afterAll(async () => { await browserHelper.closeBrowser() })
|
|
14
14
|
|
|
15
15
|
const LANGUAGES = { en, pl, ru, be, uk, es, de }
|
|
16
16
|
|