@micha.bigler/ui-core-micha 4.12.0 → 4.13.0
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/CHANGELOG.md +15 -0
- package/README.md +56 -0
- package/dist/auth/termsApi.js +12 -0
- package/dist/billing/api.js +29 -1
- package/dist/billing/wire.js +1 -0
- package/dist/components/LoginContent.js +293 -0
- package/dist/components/ProfileComponent.js +12 -30
- package/dist/components/ProfileStepContent.js +237 -0
- package/dist/components/SignUpContent.js +155 -0
- package/dist/components/SignupConfirmContent.js +62 -0
- package/dist/i18n/authTranslations.js +96 -0
- package/dist/i18n/onboardingTranslations.js +2 -0
- package/dist/index.js +7 -1
- package/dist/onboarding/SetupWizardShell.js +114 -0
- package/dist/pages/LoginPage.js +7 -250
- package/dist/pages/SignUpPage.js +13 -97
- package/dist/pages/SignupConfirmPage.js +13 -50
- package/dist/theme/kitSxRegistry.js +13 -0
- package/dist/utils/continuation.js +48 -0
- package/dist/utils/profileDraft.js +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Shared continuation validation for LoginPage, LoginContent and the embedded
|
|
2
|
+
// provider entries (UCM-AUTH-14). One implementation, so the page and the
|
|
3
|
+
// embedded variants can never disagree about which destinations are safe.
|
|
4
|
+
export const WEAK_LOGIN_SECURITY_TARGET = '/account?tab=security&from=weak_login';
|
|
5
|
+
export const RECOVERY_SECURITY_TARGET = '/account?tab=security&from=recovery';
|
|
6
|
+
function currentOrigin() {
|
|
7
|
+
return typeof window !== 'undefined' ? window.location.origin : '';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns the same-origin path (pathname + search + hash) for a continuation, or
|
|
11
|
+
* null when it is not safe.
|
|
12
|
+
*
|
|
13
|
+
* Requires a leading-slash absolute path on the raw input: that rejects relative
|
|
14
|
+
* inputs like `account/settings` and protocol-relative `//host` before they reach
|
|
15
|
+
* the URL parser, which would normalise both into a same-origin pathname. A
|
|
16
|
+
* backslash anywhere is rejected too (`/\evil.com` WHATWG-parses to
|
|
17
|
+
* `https://evil.com/` for special schemes). The parsed origin must still match,
|
|
18
|
+
* which catches stripped tab/newline tricks such as `/\t/evil.com`.
|
|
19
|
+
*/
|
|
20
|
+
export function sanitizeContinuation(value, origin = currentOrigin()) {
|
|
21
|
+
if (typeof value !== 'string'
|
|
22
|
+
|| !value.startsWith('/')
|
|
23
|
+
|| value.startsWith('//')
|
|
24
|
+
|| value.includes('\\')) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const parsed = new URL(value, origin);
|
|
29
|
+
return parsed.origin === origin ? parsed.pathname + parsed.search + parsed.hash : null;
|
|
30
|
+
}
|
|
31
|
+
catch (_a) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Where a person goes after signing in. Precedence: a forced target (recovery)
|
|
37
|
+
* > required additional security > the validated continuation > `/`.
|
|
38
|
+
*/
|
|
39
|
+
export function resolveContinuationTarget(value, user, forcedTarget) {
|
|
40
|
+
var _a;
|
|
41
|
+
var _b;
|
|
42
|
+
if (forcedTarget)
|
|
43
|
+
return forcedTarget;
|
|
44
|
+
if (((_a = user === null || user === void 0 ? void 0 : user.security_state) === null || _a === void 0 ? void 0 : _a.requires_additional_security) === true) {
|
|
45
|
+
return WEAK_LOGIN_SECURITY_TARGET;
|
|
46
|
+
}
|
|
47
|
+
return (_b = sanitizeContinuation(value)) !== null && _b !== void 0 ? _b : '/';
|
|
48
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Identity used to bind editable profile draft fields to one account. */
|
|
2
|
+
export const profileIdentity = (user) => { var _a, _b, _c; return user ? ((_c = (_b = (_a = user.id) !== null && _a !== void 0 ? _a : user.email) !== null && _b !== void 0 ? _b : user.username) !== null && _c !== void 0 ? _c : null) : null; };
|
|
3
|
+
/** Refresh untouched profile values while retaining edits for the same identity. */
|
|
4
|
+
export function refreshProfileDraft(user, previousIdentity, editedFields = new Set(), draft = {}) {
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
const identity = profileIdentity(user);
|
|
7
|
+
const samePerson = previousIdentity === identity;
|
|
8
|
+
const retained = samePerson ? editedFields : new Set();
|
|
9
|
+
if (!user)
|
|
10
|
+
return { identity, editedFields: retained, values: { username: '', email: '', firstName: '', lastName: '', acceptedPrivacy: false, acceptedCookies: false } };
|
|
11
|
+
return {
|
|
12
|
+
identity,
|
|
13
|
+
editedFields: retained,
|
|
14
|
+
values: {
|
|
15
|
+
username: (_a = user.username) !== null && _a !== void 0 ? _a : '', email: (_b = user.email) !== null && _b !== void 0 ? _b : '',
|
|
16
|
+
firstName: retained.has('firstName') ? draft.firstName : ((_c = user.first_name) !== null && _c !== void 0 ? _c : ''),
|
|
17
|
+
lastName: retained.has('lastName') ? draft.lastName : ((_d = user.last_name) !== null && _d !== void 0 ? _d : ''),
|
|
18
|
+
acceptedPrivacy: retained.has('acceptedPrivacy') ? draft.acceptedPrivacy : Boolean(user.accepted_privacy_statement),
|
|
19
|
+
acceptedCookies: retained.has('acceptedCookies') ? draft.acceptedCookies : Boolean(user.accepted_convenience_cookies),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|