@micha.bigler/ui-core-micha 4.12.0 → 4.14.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 +23 -0
- package/README.md +72 -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 +8 -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/chunkLoadRecovery.js +65 -0
- package/dist/utils/continuation.js +48 -0
- package/dist/utils/profileDraft.js +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const LAST_RELOAD_KEY = 'ucm:chunk-load-recovery:last-reload';
|
|
2
|
+
const DEFAULT_GUARD_WINDOW_MS = 60000;
|
|
3
|
+
let activeInstallation = null;
|
|
4
|
+
/**
|
|
5
|
+
* Returns whether an error indicates that a JavaScript or CSS module chunk could not be fetched.
|
|
6
|
+
* Errors thrown while evaluating a successfully fetched module do not count.
|
|
7
|
+
*/
|
|
8
|
+
export function isChunkLoadError(error) {
|
|
9
|
+
if (!error || (typeof error !== 'object' && typeof error !== 'function'))
|
|
10
|
+
return false;
|
|
11
|
+
if (error.name === 'ChunkLoadError')
|
|
12
|
+
return true;
|
|
13
|
+
if (typeof error.message !== 'string')
|
|
14
|
+
return false;
|
|
15
|
+
return /failed to fetch dynamically imported module|error loading dynamically imported module|importing a module script failed|unable to preload css/i.test(error.message);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Installs one-shot recovery for failed Vite or unhandled dynamic module loads.
|
|
19
|
+
* The session storage guard defaults to 60 seconds and survives a page reload; storage failures
|
|
20
|
+
* leave the error untouched. Options accept `guardWindowMs` and an injected `reload` function.
|
|
21
|
+
* Returns an uninstall function, or a no-op when called without `window`.
|
|
22
|
+
*/
|
|
23
|
+
export function installChunkLoadRecovery({ guardWindowMs = DEFAULT_GUARD_WINDOW_MS, reload = () => window.location.reload() } = {}) {
|
|
24
|
+
if (typeof window === 'undefined')
|
|
25
|
+
return () => { };
|
|
26
|
+
if (activeInstallation)
|
|
27
|
+
return activeInstallation.uninstall;
|
|
28
|
+
// A zero, negative or non-numeric window would disable the loop guard; use the default instead.
|
|
29
|
+
const windowMs = Number.isFinite(guardWindowMs) && guardWindowMs > 0 ? guardWindowMs : DEFAULT_GUARD_WINDOW_MS;
|
|
30
|
+
const tryRecover = (error, event) => {
|
|
31
|
+
if (!isChunkLoadError(error))
|
|
32
|
+
return;
|
|
33
|
+
let storage;
|
|
34
|
+
try {
|
|
35
|
+
storage = window.sessionStorage;
|
|
36
|
+
const previousValue = storage.getItem(LAST_RELOAD_KEY);
|
|
37
|
+
const previousReload = Number(previousValue);
|
|
38
|
+
const now = Date.now();
|
|
39
|
+
if (previousValue !== null && Number.isFinite(previousReload) && now - previousReload < windowMs)
|
|
40
|
+
return;
|
|
41
|
+
const storedTime = String(now);
|
|
42
|
+
storage.setItem(LAST_RELOAD_KEY, storedTime);
|
|
43
|
+
if (storage.getItem(LAST_RELOAD_KEY) !== storedTime)
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
catch (_a) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
50
|
+
reload();
|
|
51
|
+
};
|
|
52
|
+
const onVitePreloadError = (event) => tryRecover(event.payload, event);
|
|
53
|
+
const onUnhandledRejection = (event) => tryRecover(event.reason, event);
|
|
54
|
+
window.addEventListener('vite:preloadError', onVitePreloadError);
|
|
55
|
+
window.addEventListener('unhandledrejection', onUnhandledRejection);
|
|
56
|
+
const uninstall = () => {
|
|
57
|
+
if ((activeInstallation === null || activeInstallation === void 0 ? void 0 : activeInstallation.uninstall) !== uninstall)
|
|
58
|
+
return;
|
|
59
|
+
window.removeEventListener('vite:preloadError', onVitePreloadError);
|
|
60
|
+
window.removeEventListener('unhandledrejection', onUnhandledRejection);
|
|
61
|
+
activeInstallation = null;
|
|
62
|
+
};
|
|
63
|
+
activeInstallation = { uninstall };
|
|
64
|
+
return uninstall;
|
|
65
|
+
}
|
|
@@ -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
|
+
}
|