@owlmeans/client-auth 0.1.18-rc.5 → 0.1.18-rc.50
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 +282 -37
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/client-auth/SKILL.md +144 -21
- package/build/components/dispatcher/component.d.ts.map +1 -1
- package/build/components/dispatcher/component.js +23 -5
- package/build/components/dispatcher/component.js.map +1 -1
- package/build/entrypoints.d.ts +5 -0
- package/build/entrypoints.d.ts.map +1 -0
- package/build/entrypoints.js +7 -0
- package/build/entrypoints.js.map +1 -0
- package/build/helper.d.ts +2 -1
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +24 -3
- package/build/helper.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/login/adopt.d.ts +24 -0
- package/build/login/adopt.d.ts.map +1 -0
- package/build/login/adopt.js +28 -0
- package/build/login/adopt.js.map +1 -0
- package/build/login/consts.d.ts +49 -0
- package/build/login/consts.d.ts.map +1 -0
- package/build/login/consts.js +49 -0
- package/build/login/consts.js.map +1 -0
- package/build/login/credit.d.ts +24 -0
- package/build/login/credit.d.ts.map +1 -0
- package/build/login/credit.js +58 -0
- package/build/login/credit.js.map +1 -0
- package/build/login/env.d.ts +32 -0
- package/build/login/env.d.ts.map +1 -0
- package/build/login/env.js +84 -0
- package/build/login/env.js.map +1 -0
- package/build/login/flow.d.ts +20 -0
- package/build/login/flow.d.ts.map +1 -0
- package/build/login/flow.js +39 -0
- package/build/login/flow.js.map +1 -0
- package/build/login/hook.d.ts +37 -0
- package/build/login/hook.d.ts.map +1 -0
- package/build/login/hook.js +72 -0
- package/build/login/hook.js.map +1 -0
- package/build/login/i18n/be.json +41 -0
- package/build/login/i18n/de.json +41 -0
- package/build/login/i18n/en.json +41 -0
- package/build/login/i18n/es.json +41 -0
- package/build/login/i18n/fr.json +41 -0
- package/build/login/i18n/pl.json +41 -0
- package/build/login/i18n/ru.json +41 -0
- package/build/login/i18n/uk.json +41 -0
- package/build/login/i18n.d.ts +2 -0
- package/build/login/i18n.d.ts.map +1 -0
- package/build/login/i18n.js +27 -0
- package/build/login/i18n.js.map +1 -0
- package/build/login/index.d.ts +17 -0
- package/build/login/index.d.ts.map +1 -0
- package/build/login/index.js +17 -0
- package/build/login/index.js.map +1 -0
- package/build/login/land.d.ts +46 -0
- package/build/login/land.d.ts.map +1 -0
- package/build/login/land.js +166 -0
- package/build/login/land.js.map +1 -0
- package/build/login/methods.d.ts +25 -0
- package/build/login/methods.d.ts.map +1 -0
- package/build/login/methods.js +97 -0
- package/build/login/methods.js.map +1 -0
- package/build/login/resume.d.ts +30 -0
- package/build/login/resume.d.ts.map +1 -0
- package/build/login/resume.js +57 -0
- package/build/login/resume.js.map +1 -0
- package/build/login/screen.d.ts +17 -0
- package/build/login/screen.d.ts.map +1 -0
- package/build/login/screen.js +81 -0
- package/build/login/screen.js.map +1 -0
- package/build/login/service.d.ts +31 -0
- package/build/login/service.d.ts.map +1 -0
- package/build/login/service.js +168 -0
- package/build/login/service.js.map +1 -0
- package/build/login/surrogate.d.ts +20 -0
- package/build/login/surrogate.d.ts.map +1 -0
- package/build/login/surrogate.js +33 -0
- package/build/login/surrogate.js.map +1 -0
- package/build/login/terms-config.d.ts +59 -0
- package/build/login/terms-config.d.ts.map +1 -0
- package/build/login/terms-config.js +2 -0
- package/build/login/terms-config.js.map +1 -0
- package/build/login/terms.d.ts +102 -0
- package/build/login/terms.d.ts.map +1 -0
- package/build/login/terms.js +253 -0
- package/build/login/terms.js.map +1 -0
- package/build/login/types.d.ts +349 -0
- package/build/login/types.d.ts.map +1 -0
- package/build/login/types.js +31 -0
- package/build/login/types.js.map +1 -0
- package/build/manager/components/authentication/control.js +3 -3
- package/build/manager/components/authentication/control.js.map +1 -1
- package/build/manager/components/authentication/types.d.ts +2 -2
- package/build/manager/components/authentication/types.d.ts.map +1 -1
- package/build/manager/components/tunnel-consumer.js +2 -2
- package/build/manager/components/tunnel-consumer.js.map +1 -1
- package/build/manager/entrypoints.d.ts +3 -0
- package/build/manager/entrypoints.d.ts.map +1 -0
- package/build/manager/entrypoints.js +17 -0
- package/build/manager/entrypoints.js.map +1 -0
- package/build/manager/plugins/basic-ed25519.d.ts.map +1 -1
- package/build/manager/plugins/basic-ed25519.js +5 -0
- package/build/manager/plugins/basic-ed25519.js.map +1 -1
- package/build/manager/plugins/exports.d.ts +2 -0
- package/build/manager/plugins/exports.d.ts.map +1 -1
- package/build/manager/plugins/exports.js +2 -0
- package/build/manager/plugins/exports.js.map +1 -1
- package/build/manager/plugins/index.d.ts +1 -5
- package/build/manager/plugins/index.d.ts.map +1 -1
- package/build/manager/plugins/index.js +9 -1
- package/build/manager/plugins/index.js.map +1 -1
- package/build/manager/plugins/methods.d.ts +6 -0
- package/build/manager/plugins/methods.d.ts.map +1 -0
- package/build/manager/plugins/methods.js +65 -0
- package/build/manager/plugins/methods.js.map +1 -0
- package/build/manager/plugins/re-captcha.d.ts.map +1 -1
- package/build/manager/plugins/re-captcha.js +5 -0
- package/build/manager/plugins/re-captcha.js.map +1 -1
- package/build/manager/plugins/registry.d.ts +20 -0
- package/build/manager/plugins/registry.d.ts.map +1 -0
- package/build/manager/plugins/registry.js +19 -0
- package/build/manager/plugins/registry.js.map +1 -0
- package/build/manager/plugins/tunnel-consumer.d.ts.map +1 -1
- package/build/manager/plugins/tunnel-consumer.js +8 -1
- package/build/manager/plugins/tunnel-consumer.js.map +1 -1
- package/build/manager/plugins/types.d.ts +53 -0
- package/build/manager/plugins/types.d.ts.map +1 -1
- package/build/service.js +1 -1
- package/build/service.js.map +1 -1
- package/package.json +36 -27
- package/src/components/dispatcher/component.tsx +31 -5
- package/src/entrypoints.ts +10 -0
- package/src/helper.ts +26 -3
- package/src/index.ts +1 -1
- package/src/login/adopt.ts +31 -0
- package/src/login/consts.ts +64 -0
- package/src/login/credit.ts +75 -0
- package/src/login/env.ts +86 -0
- package/src/login/flow.ts +44 -0
- package/src/login/hook.ts +80 -0
- package/src/login/i18n/be.json +41 -0
- package/src/login/i18n/de.json +41 -0
- package/src/login/i18n/en.json +41 -0
- package/src/login/i18n/es.json +41 -0
- package/src/login/i18n/fr.json +41 -0
- package/src/login/i18n/pl.json +41 -0
- package/src/login/i18n/ru.json +41 -0
- package/src/login/i18n/uk.json +41 -0
- package/src/login/i18n.ts +28 -0
- package/src/login/index.ts +17 -0
- package/src/login/land.ts +196 -0
- package/src/login/methods.ts +113 -0
- package/src/login/resume.ts +58 -0
- package/src/login/screen.tsx +160 -0
- package/src/login/service.ts +219 -0
- package/src/login/surrogate.ts +45 -0
- package/src/login/terms-config.ts +49 -0
- package/src/login/terms.ts +354 -0
- package/src/login/types.ts +377 -0
- package/src/manager/README.md +37 -80
- package/src/manager/components/authentication/control.ts +3 -3
- package/src/manager/components/authentication/types.ts +2 -2
- package/src/manager/components/tunnel-consumer.tsx +2 -2
- package/src/manager/entrypoints.ts +18 -0
- package/src/manager/plugins/basic-ed25519.tsx +7 -0
- package/src/manager/plugins/exports.ts +2 -0
- package/src/manager/plugins/index.ts +10 -4
- package/src/manager/plugins/methods.ts +74 -0
- package/src/manager/plugins/re-captcha.tsx +7 -0
- package/src/manager/plugins/registry.ts +26 -0
- package/src/manager/plugins/tunnel-consumer.tsx +10 -1
- package/src/manager/plugins/types.ts +54 -0
- package/src/service.ts +1 -1
- package/tests/context.ts +1 -2
- package/tests/i18n.spec.ts +68 -0
- package/tests/land.spec.ts +294 -0
- package/tests/login.spec.ts +332 -0
- package/tests/terms-deferred.spec.ts +65 -0
- package/tests/terms.spec.ts +256 -0
- package/build/.gitkeep +0 -0
- package/build/manager/modules.d.ts +0 -2
- package/build/manager/modules.d.ts.map +0 -1
- package/build/manager/modules.js +0 -16
- package/build/manager/modules.js.map +0 -1
- package/build/modules.d.ts +0 -4
- package/build/modules.d.ts.map +0 -1
- package/build/modules.js +0 -9
- package/build/modules.js.map +0 -1
- package/src/manager/modules.ts +0 -18
- package/src/modules.ts +0 -13
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { createLazyService } from '@owlmeans/context';
|
|
2
|
+
import { DEFAULT_ALIAS } from './consts.js';
|
|
3
|
+
import { defaultLoginEnv } from './env.js';
|
|
4
|
+
import { adoptToken, revokeToken } from './adopt.js';
|
|
5
|
+
import { resolveLoginMethods } from './methods.js';
|
|
6
|
+
import { LoginOutcome } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Login service = plugin host. It holds a registry of login plugins and, on every facade call,
|
|
9
|
+
* resolves the active plugin by cascade (priority desc, first whose `match(env)` is truthy) and
|
|
10
|
+
* delegates to it.
|
|
11
|
+
*
|
|
12
|
+
* The facade methods stay ordinary writable properties (never getters) so that non-plugin
|
|
13
|
+
* implementations — e.g. a native login service — can keep overriding them directly.
|
|
14
|
+
*
|
|
15
|
+
* It is a LAZY service on purpose. The host carries no async setup, and plugin packages must be
|
|
16
|
+
* able to reach it from an app's `makeContext` — i.e. while the context is still in the Loading
|
|
17
|
+
* stage. `context.service()` throws for an uninitialized non-lazy service, which would make
|
|
18
|
+
* `ensureLoginService` fail exactly where apps are told to call it.
|
|
19
|
+
*
|
|
20
|
+
* `begin` and `logout` are deliberately NOT `async`. An async facade method defers the plugin's
|
|
21
|
+
* body past a microtask boundary, and a `window.open` that lands after the user gesture has
|
|
22
|
+
* finished being handled is eaten by the popup blocker. The same rule binds every plugin's own
|
|
23
|
+
* `begin` and `logout`, and it is why a precondition must be synchronous too.
|
|
24
|
+
*/
|
|
25
|
+
export const makeLoginService = (alias = DEFAULT_ALIAS) => {
|
|
26
|
+
const plugins = [];
|
|
27
|
+
const preconditions = [];
|
|
28
|
+
const methodSources = [];
|
|
29
|
+
const steps = [];
|
|
30
|
+
const hooks = [];
|
|
31
|
+
let screen = null;
|
|
32
|
+
let notifier = null;
|
|
33
|
+
const ctx = () => service.ctx;
|
|
34
|
+
const service = createLazyService(alias, {
|
|
35
|
+
registerPlugin: (plugin) => {
|
|
36
|
+
const existing = plugins.findIndex(candidate => candidate.alias === plugin.alias);
|
|
37
|
+
if (existing >= 0) {
|
|
38
|
+
plugins.splice(existing, 1);
|
|
39
|
+
}
|
|
40
|
+
plugins.push(plugin);
|
|
41
|
+
plugins.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
42
|
+
},
|
|
43
|
+
registerPrecondition: (precondition) => {
|
|
44
|
+
const existing = preconditions.findIndex(candidate => candidate.alias === precondition.alias);
|
|
45
|
+
if (existing >= 0) {
|
|
46
|
+
preconditions.splice(existing, 1);
|
|
47
|
+
}
|
|
48
|
+
preconditions.push(precondition);
|
|
49
|
+
preconditions.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
50
|
+
},
|
|
51
|
+
registerMethodSource: (source) => {
|
|
52
|
+
const existing = methodSources.findIndex(candidate => candidate.alias === source.alias);
|
|
53
|
+
if (existing >= 0) {
|
|
54
|
+
methodSources.splice(existing, 1);
|
|
55
|
+
}
|
|
56
|
+
methodSources.push(source);
|
|
57
|
+
},
|
|
58
|
+
methods: methodCtx => resolveLoginMethods(methodCtx, methodCtx.context.cfg.security?.auth?.login, methodSources),
|
|
59
|
+
registerScreen: value => { screen = value; },
|
|
60
|
+
screen: () => screen,
|
|
61
|
+
registerNotifier: value => { notifier = value; },
|
|
62
|
+
registerStep: (step) => {
|
|
63
|
+
const existing = steps.findIndex(candidate => candidate.alias === step.alias);
|
|
64
|
+
if (existing >= 0) {
|
|
65
|
+
steps.splice(existing, 1);
|
|
66
|
+
}
|
|
67
|
+
steps.push(step);
|
|
68
|
+
steps.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
69
|
+
},
|
|
70
|
+
steps: () => [...steps],
|
|
71
|
+
onLanded: (hook) => {
|
|
72
|
+
const existing = hooks.findIndex(candidate => candidate.alias === hook.alias);
|
|
73
|
+
if (existing >= 0) {
|
|
74
|
+
hooks.splice(existing, 1);
|
|
75
|
+
}
|
|
76
|
+
hooks.push(hook);
|
|
77
|
+
hooks.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
78
|
+
},
|
|
79
|
+
landingHooks: () => [...hooks],
|
|
80
|
+
plugin: env => {
|
|
81
|
+
const environment = env ?? defaultLoginEnv();
|
|
82
|
+
const plugin = plugins.find(candidate => candidate.match?.(environment, service.ctx) ?? true);
|
|
83
|
+
if (plugin == null) {
|
|
84
|
+
throw new Error('login: no plugin matches the current environment');
|
|
85
|
+
}
|
|
86
|
+
return plugin;
|
|
87
|
+
},
|
|
88
|
+
env: () => defaultLoginEnv(),
|
|
89
|
+
enter: () => {
|
|
90
|
+
const env = defaultLoginEnv();
|
|
91
|
+
service.plugin(env).enter?.(ctx(), env);
|
|
92
|
+
},
|
|
93
|
+
begin: request => {
|
|
94
|
+
const env = defaultLoginEnv();
|
|
95
|
+
// Synchronously, before anything can open a window: a precondition that refuses leaves the
|
|
96
|
+
// user exactly where `Gesture` describes — unable to proceed until they act again.
|
|
97
|
+
for (const precondition of preconditions) {
|
|
98
|
+
if (!precondition.check(ctx(), request, env)) {
|
|
99
|
+
return Promise.resolve(LoginOutcome.Gesture);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Notified here, in the facade, rather than by each caller: `useLogin` fires the flow and
|
|
103
|
+
// forgets the result, and this is the one place every caller — the header hook and the
|
|
104
|
+
// sign-in screen's method buttons alike — passes through on the way to a settled outcome.
|
|
105
|
+
return service.plugin(env).begin(ctx(), request, env).then(outcome => {
|
|
106
|
+
notifier?.(outcome, env);
|
|
107
|
+
return outcome;
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
authorize: async (url) => {
|
|
111
|
+
const env = defaultLoginEnv();
|
|
112
|
+
return await service.plugin(env).authorize(ctx(), url, env);
|
|
113
|
+
},
|
|
114
|
+
complete: async (token) => {
|
|
115
|
+
const env = defaultLoginEnv();
|
|
116
|
+
return await service.plugin(env).complete(ctx(), token, env);
|
|
117
|
+
},
|
|
118
|
+
resume: async (token) => {
|
|
119
|
+
const env = defaultLoginEnv();
|
|
120
|
+
// Absent means "keep it and carry on" — which is what an ordinary tab has always done, and
|
|
121
|
+
// is why the redirect plugin implements nothing here.
|
|
122
|
+
return await service.plugin(env).resume?.(ctx(), token, env) ?? LoginOutcome.Passed;
|
|
123
|
+
},
|
|
124
|
+
logout: request => {
|
|
125
|
+
const env = defaultLoginEnv();
|
|
126
|
+
const plugin = service.plugin(env);
|
|
127
|
+
if (plugin.logout == null) {
|
|
128
|
+
// A plugin with no logout mechanic still has to end the session it started.
|
|
129
|
+
return revokeToken(ctx()).then(async () => {
|
|
130
|
+
await request.navigate?.();
|
|
131
|
+
return LoginOutcome.Passed;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return plugin.logout(ctx(), request, env).then(outcome => {
|
|
135
|
+
notifier?.(outcome, env);
|
|
136
|
+
return outcome;
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
logoutComplete: async () => {
|
|
140
|
+
const env = defaultLoginEnv();
|
|
141
|
+
return await service.plugin(env).logoutComplete?.(ctx(), env) ?? LoginOutcome.Passed;
|
|
142
|
+
},
|
|
143
|
+
adopt: async (token) => { await adoptToken(ctx(), token); },
|
|
144
|
+
revoke: async () => { await revokeToken(ctx()); },
|
|
145
|
+
});
|
|
146
|
+
return service;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Idempotently obtain the login service on a context, registering an empty host if none exists
|
|
150
|
+
* yet. Plugin packages call this before `registerPlugin`.
|
|
151
|
+
*/
|
|
152
|
+
export const ensureLoginService = (ctx) => {
|
|
153
|
+
if (ctx.hasService(DEFAULT_ALIAS)) {
|
|
154
|
+
return ctx.service(DEFAULT_ALIAS);
|
|
155
|
+
}
|
|
156
|
+
const service = makeLoginService();
|
|
157
|
+
ctx.registerService(service);
|
|
158
|
+
return service;
|
|
159
|
+
};
|
|
160
|
+
/** Register the host and expose it as `context.login()`. */
|
|
161
|
+
export const appendLogin = (ctx) => {
|
|
162
|
+
ensureLoginService(ctx);
|
|
163
|
+
const contextual = ctx;
|
|
164
|
+
contextual.login = () => ctx.service(DEFAULT_ALIAS);
|
|
165
|
+
return contextual;
|
|
166
|
+
};
|
|
167
|
+
export { LoginOutcome };
|
|
168
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/login/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAMzC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,GAAW,aAAa,EAAgB,EAAE;IAC9E,MAAM,OAAO,GAAkB,EAAE,CAAA;IACjC,MAAM,aAAa,GAAwB,EAAE,CAAA;IAC7C,MAAM,aAAa,GAAwB,EAAE,CAAA;IAC7C,MAAM,KAAK,GAAgB,EAAE,CAAA;IAC7B,MAAM,KAAK,GAAuB,EAAE,CAAA;IACpC,IAAI,MAAM,GAAgC,IAAI,CAAA;IAC9C,IAAI,QAAQ,GAAyB,IAAI,CAAA;IAEzC,MAAM,GAAG,GAAG,GAAiB,EAAE,CAAC,OAAO,CAAC,GAAmB,CAAA;IAE3D,MAAM,OAAO,GAAiB,iBAAiB,CAAe,KAAK,EAAE;QACnE,cAAc,EAAE,CAAC,MAAmB,EAAE,EAAE;YACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,S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,CAAe,aAAa,CAAC,CAAA;IACjD,CAAC;IACD,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAA;IAClC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAE5B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,4DAA4D;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAM,EACkB,EAAE;IAC1B,kBAAkB,CAAC,GAAG,CAAC,CAAA;IACvB,MAAM,UAAU,GAAG,GAA6B,CAAA;IAChD,UAAU,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAe,aAAa,CAAC,CAAA;IAEjE,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LoginIntent } from './types.js';
|
|
2
|
+
import type { LoginContext } from './types.js';
|
|
3
|
+
export interface SurrogateTarget {
|
|
4
|
+
intent: LoginIntent;
|
|
5
|
+
/** The address the surrogate should actually run, once it is one window up. */
|
|
6
|
+
next?: string;
|
|
7
|
+
/** The method the user already chose in the opener. */
|
|
8
|
+
method?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Where a surrogate window opens.
|
|
12
|
+
*
|
|
13
|
+
* Returns `null` when the application's entrypoint list predates the surrogate route — an app
|
|
14
|
+
* built against an older `@owlmeans/auth-common` has no such entrypoint, and the caller then falls
|
|
15
|
+
* back to opening the dispatcher directly, which is exactly what it used to do. That fallback is
|
|
16
|
+
* the whole compatibility story for already-deployed applications, so it must never be removed in
|
|
17
|
+
* favour of throwing.
|
|
18
|
+
*/
|
|
19
|
+
export declare const surrogatePath: (ctx: LoginContext, target: SurrogateTarget) => string | null;
|
|
20
|
+
//# sourceMappingURL=surrogate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surrogate.d.ts","sourceRoot":"","sources":["../../src/login/surrogate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,WAAW,CAAA;IACnB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,QAAS,YAAY,UAAU,eAAe,KAAG,MAAM,GAAG,IAqBnF,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DISPATCHER_SURROGATE } from '@owlmeans/auth';
|
|
2
|
+
import { LOGIN_INTENT_QUERY, LOGIN_METHOD_QUERY, LOGIN_NEXT_QUERY } from './consts.js';
|
|
3
|
+
/**
|
|
4
|
+
* Where a surrogate window opens.
|
|
5
|
+
*
|
|
6
|
+
* Returns `null` when the application's entrypoint list predates the surrogate route — an app
|
|
7
|
+
* built against an older `@owlmeans/auth-common` has no such entrypoint, and the caller then falls
|
|
8
|
+
* back to opening the dispatcher directly, which is exactly what it used to do. That fallback is
|
|
9
|
+
* the whole compatibility story for already-deployed applications, so it must never be removed in
|
|
10
|
+
* favour of throwing.
|
|
11
|
+
*/
|
|
12
|
+
export const surrogatePath = (ctx, target) => {
|
|
13
|
+
if (!ctx.hasEntrypoint(DISPATCHER_SURROGATE)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
let path;
|
|
17
|
+
try {
|
|
18
|
+
path = ctx.entrypoint(DISPATCHER_SURROGATE).path();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const query = new URLSearchParams();
|
|
24
|
+
query.set(LOGIN_INTENT_QUERY, target.intent);
|
|
25
|
+
if (target.next != null && target.next !== '') {
|
|
26
|
+
query.set(LOGIN_NEXT_QUERY, target.next);
|
|
27
|
+
}
|
|
28
|
+
if (target.method != null && target.method !== '') {
|
|
29
|
+
query.set(LOGIN_METHOD_QUERY, target.method);
|
|
30
|
+
}
|
|
31
|
+
return `${path}?${query.toString()}`;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=surrogate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surrogate.js","sourceRoot":"","sources":["../../src/login/surrogate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAErD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAYtF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAiB,EAAE,MAAuB,EAAiB,EAAE;IACzF,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,IAAY,CAAA;IAChB,IAAI,CAAC;QACH,IAAI,GAAG,GAAG,CAAC,UAAU,CAAmB,oBAAoB,CAAC,CAAC,IAAI,EAAE,CAAA;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAA;IACnC,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAC5C,IAAI,MAAM,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;QAC9C,KAAK,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1C,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAClD,KAAK,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO,GAAG,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAA;AACtC,CAAC,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extra `LoginTermsConfig` fields, added by TypeScript module augmentation rather than by editing
|
|
3
|
+
* `@owlmeans/config` itself.
|
|
4
|
+
*
|
|
5
|
+
* `@owlmeans/config` has roughly 85 dependents, and every one of them sits in the same release
|
|
6
|
+
* closure — a config bump ripples through every package that pins a range against it, whether or
|
|
7
|
+
* not it touches sign-in. The fields below are needed by exactly one consumer family (the sign-in
|
|
8
|
+
* screen and its terms confirmation, all downstream of `@owlmeans/client-auth`), so they are
|
|
9
|
+
* declared here instead, merged onto the base interface by TypeScript's own declaration merging.
|
|
10
|
+
*
|
|
11
|
+
* This file must be part of whatever a consumer's own compilation actually loads, or the merge
|
|
12
|
+
* never happens — an ambient augmentation applies only once the compiler has read the file that
|
|
13
|
+
* declares it. `@owlmeans/client-auth/login`'s barrel (`./index.ts`) re-exports this module for
|
|
14
|
+
* exactly that reason, so ANY import from `@owlmeans/client-auth/login` — which every application
|
|
15
|
+
* wiring sign-in already has — pulls this augmentation into that program. An app that constructs a
|
|
16
|
+
* `LoginTermsConfig` literal in a file that imports NOTHING from `@owlmeans/client-auth/login`
|
|
17
|
+
* still benefits as long as some other file in the same `tsc` program does; if none does (an
|
|
18
|
+
* isolated leaf package that only ever imports `@owlmeans/config`), add
|
|
19
|
+
* `import type {} from '@owlmeans/client-auth/login'` to the file building the literal — an
|
|
20
|
+
* import with an empty type list, kept only to pull this file into that program's graph.
|
|
21
|
+
*
|
|
22
|
+
* `export {}` below is required, not decorative: without at least one top-level import/export this
|
|
23
|
+
* file is a SCRIPT to TypeScript, not a MODULE, and `declare module '@owlmeans/config'` inside a
|
|
24
|
+
* script augments the global scope instead of merging onto the named module's exports.
|
|
25
|
+
*/
|
|
26
|
+
declare module '@owlmeans/config' {
|
|
27
|
+
interface LoginTermsConfig {
|
|
28
|
+
/** `documents[].key` (or a custom document's own key) → the ISO date it was last revised. */
|
|
29
|
+
revisions?: Record<string, string>;
|
|
30
|
+
/** Off by default. A bare string is `{ href }`. */
|
|
31
|
+
billing?: string | {
|
|
32
|
+
href: string;
|
|
33
|
+
revisedAt?: string;
|
|
34
|
+
} | false;
|
|
35
|
+
/** Off by default. `name` is interpolated into the `login.terms.product` translation. */
|
|
36
|
+
product?: {
|
|
37
|
+
name: string;
|
|
38
|
+
href: string;
|
|
39
|
+
revisedAt?: string;
|
|
40
|
+
} | false;
|
|
41
|
+
/**
|
|
42
|
+
* Custom documents beyond terms/billing/product, in the order they are agreed to.
|
|
43
|
+
*
|
|
44
|
+
* `label` may be a locale map (`{ en: '...', fr: '...' }`) — resolved at RENDER time, by
|
|
45
|
+
* whichever renderer has the current locale, never here: this file stays locale-free.
|
|
46
|
+
*/
|
|
47
|
+
documents?: Array<{
|
|
48
|
+
key: string;
|
|
49
|
+
href: string;
|
|
50
|
+
label?: string | Record<string, string>;
|
|
51
|
+
i18nKey?: string;
|
|
52
|
+
revisedAt?: string;
|
|
53
|
+
}>;
|
|
54
|
+
/** Show the latest revision date beneath the confirmation. Default false. */
|
|
55
|
+
showRevision?: boolean;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=terms-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms-config.d.ts","sourceRoot":"","sources":["../../src/login/terms-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,gBAAgB;QACxB,6FAA6F;QAC7F,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAClC,mDAAmD;QACnD,OAAO,CAAC,EAAE,MAAM,GAAG;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,KAAK,CAAA;QAC/D,yFAAyF;QACzF,OAAO,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,KAAK,CAAA;QACpE;;;;;WAKG;QACH,SAAS,CAAC,EAAE,KAAK,CAAC;YAChB,GAAG,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAC;YACrF,SAAS,CAAC,EAAE,MAAM,CAAC;SACpB,CAAC,CAAA;QACF,6EAA6E;QAC7E,YAAY,CAAC,EAAE,OAAO,CAAA;KACvB;CACF;AAED,OAAO,EAAG,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms-config.js","sourceRoot":"","sources":["../../src/login/terms-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { LoginTermsConfig } from '@owlmeans/config';
|
|
2
|
+
import type { LoginContext } from './types.js';
|
|
3
|
+
import './terms-config.js';
|
|
4
|
+
/** One document (or notice) a sign-in screen links to. */
|
|
5
|
+
export interface ResolvedTermsDocument {
|
|
6
|
+
key: string;
|
|
7
|
+
href: string;
|
|
8
|
+
/** A caller's own label, already resolved to one string — only ever set for a custom document. */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** A locale map for the label, when the config supplied one — resolved by the renderer, not here. */
|
|
11
|
+
labelMap?: Record<string, string>;
|
|
12
|
+
/** Translation key under `login.terms.*`, when this document has one. */
|
|
13
|
+
i18nKey?: string;
|
|
14
|
+
revisedAt?: string;
|
|
15
|
+
/** Extra interpolation values for `i18nKey`'s translation (e.g. `{ product: 'Acme' }`). */
|
|
16
|
+
params?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export interface ResolvedTerms {
|
|
19
|
+
required: boolean;
|
|
20
|
+
terms: string;
|
|
21
|
+
privacy: string;
|
|
22
|
+
cookies?: string;
|
|
23
|
+
version: string;
|
|
24
|
+
/** What the checkbox agrees to — terms, then billing/product when configured, then custom. */
|
|
25
|
+
documents: ResolvedTermsDocument[];
|
|
26
|
+
/** What is merely DISCLOSED, never consented to — privacy, plus cookies per the rule below. */
|
|
27
|
+
notices: ResolvedTermsDocument[];
|
|
28
|
+
/** The latest `revisedAt` among {@link documents}. Only set when `showRevision` is true. */
|
|
29
|
+
revisedAt?: string;
|
|
30
|
+
showRevision: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare const resolveTerms: (cfg?: LoginTermsConfig | false) => ResolvedTerms | null;
|
|
33
|
+
/**
|
|
34
|
+
* Whether this browser has already agreed to exactly these documents.
|
|
35
|
+
*
|
|
36
|
+
* `localStorage` and not a cookie: the record is a UI convenience, it never travels to a server,
|
|
37
|
+
* and it must be readable by the surrogate login window — which is same-origin, so it sees the
|
|
38
|
+
* opener's acceptance and does not ask twice. A preview iframe on a different origin gets its own
|
|
39
|
+
* partition and therefore its own acceptance, which is correct rather than unfortunate.
|
|
40
|
+
*/
|
|
41
|
+
export declare const termsAccepted: (resolved: ResolvedTerms | null) => boolean;
|
|
42
|
+
export declare const acceptTerms: (resolved: ResolvedTerms | null, accepted: boolean) => void;
|
|
43
|
+
/**
|
|
44
|
+
* A document's own label: a caller's literal `label`, else its `labelMap` for the current locale,
|
|
45
|
+
* else its `i18nKey` translated — each with `params` (e.g. `{ product: 'Acme' }`) interpolated
|
|
46
|
+
* afterwards, since the `translate` contract every renderer shares is a plain
|
|
47
|
+
* `(key, defaultValue) => string` with no interpolation option of its own.
|
|
48
|
+
*
|
|
49
|
+
* The one label resolver every renderer of a terms sentence uses — `FallbackLoginScreen` here, and
|
|
50
|
+
* `@owlmeans/web-panel`'s `LoginTerms` — so the English fallbacks and the resolution order live in
|
|
51
|
+
* exactly one place instead of two hand-kept copies.
|
|
52
|
+
*/
|
|
53
|
+
export declare const termsLabelResolver: (translate: (key: string, defaultValue: string) => string, locale: string | undefined) => (doc: ResolvedTermsDocument) => string;
|
|
54
|
+
/** One document as `@owlmeans/marketing-consent`'s `TermsDocumentRef` shape — structurally, with
|
|
55
|
+
* no dependency on that package (client-auth is a layer below it). */
|
|
56
|
+
export interface TermsAcceptanceRef {
|
|
57
|
+
key: string;
|
|
58
|
+
href: string;
|
|
59
|
+
revisedAt?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* What a sign-in-time terms acceptance sends the server — structurally
|
|
63
|
+
* `@owlmeans/marketing-consent`'s `TermsAcceptance`, so `client.recordTerms(termsAcceptanceOf(...))`
|
|
64
|
+
* type-checks with no dependency in this direction. Shared by `termsRecorder` (the sign-in screen's
|
|
65
|
+
* own local acceptance, copied at landing) and a Terms-mode consent screen recording the box it
|
|
66
|
+
* just showed.
|
|
67
|
+
*/
|
|
68
|
+
export declare const termsAcceptanceOf: (resolved: Pick<ResolvedTerms, 'documents' | 'notices' | 'version'>, locale?: string) => {
|
|
69
|
+
documents: TermsAcceptanceRef[];
|
|
70
|
+
notices: TermsAcceptanceRef[];
|
|
71
|
+
version: string;
|
|
72
|
+
locale?: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Whether the Terms confirmation has been moved off the sign-in screen onto a registered step.
|
|
76
|
+
*
|
|
77
|
+
* True only when a step both DECLARES `confirmsTerms` and is BOUND (`ctx.hasEntrypoint`) — an app
|
|
78
|
+
* that registers the step (e.g. `appendMarketingConsent({ terms: 'step' })`) but never binds its
|
|
79
|
+
* screen (an older target, a partial import) keeps the sign-in checkbox, fail-closed: a person must
|
|
80
|
+
* never find the confirmation missing from both places at once.
|
|
81
|
+
*
|
|
82
|
+
* Reads the service directly (`ctx.hasService`), never `ensureLoginService` — that registers an
|
|
83
|
+
* empty host as a side effect, which a render-time check must not do.
|
|
84
|
+
*/
|
|
85
|
+
export declare const termsDeferred: (ctx: LoginContext) => boolean;
|
|
86
|
+
/** One fragment of an interpolated terms sentence — plain text, or a link to a document. */
|
|
87
|
+
export interface TermsSentencePart {
|
|
88
|
+
text: string;
|
|
89
|
+
href?: string;
|
|
90
|
+
documentKey?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Interpolate a translated sentence template around its document list(s).
|
|
94
|
+
*
|
|
95
|
+
* Supports `{{documents}}` (→ `resolved.documents`) and `{{notices}}` (→ `resolved.notices`), and
|
|
96
|
+
* — for backward compatibility with an older template string — the legacy `{{terms}}`, `{{privacy}}`
|
|
97
|
+
* and `{{cookies}}` placeholders, each resolved to its one matching document. Framework-agnostic on
|
|
98
|
+
* purpose: it returns plain data, never JSX, so both `@owlmeans/web-panel` and the plain fallback
|
|
99
|
+
* screen can turn the parts into their own markup.
|
|
100
|
+
*/
|
|
101
|
+
export declare const termsSentence: (template: string, resolved: Pick<ResolvedTerms, 'documents' | 'notices'>, locale: string | undefined, resolveLabel: (doc: ResolvedTermsDocument) => string) => TermsSentencePart[];
|
|
102
|
+
//# sourceMappingURL=terms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms.d.ts","sourceRoot":"","sources":["../../src/login/terms.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAA;AAC5D,OAAO,mBAAmB,CAAA;AAE1B,0DAA0D;AAC1D,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,kGAAkG;IAClG,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qGAAqG;IACrG,QAAQ,CAAC,EAAE,MAAM,CAAC,MA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