@oxyhq/core 5.5.0 → 6.0.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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/HttpService.js +6 -3
- package/dist/cjs/OxyServices.base.js +7 -102
- package/dist/cjs/boot/coldBootV2.js +350 -0
- package/dist/cjs/boot/deviceBootReturn.js +152 -0
- package/dist/cjs/crypto/keyManager.js +95 -0
- package/dist/cjs/i18n/locales/en-US.json +13 -1
- package/dist/cjs/i18n/locales/es-ES.json +13 -1
- package/dist/cjs/i18n/locales/locales/en-US.json +13 -1
- package/dist/cjs/i18n/locales/locales/es-ES.json +13 -1
- package/dist/cjs/index.js +47 -44
- package/dist/cjs/mixins/OxyServices.accounts.js +6 -13
- package/dist/cjs/mixins/OxyServices.auth.js +66 -201
- package/dist/cjs/mixins/OxyServices.authorizedApps.js +38 -0
- package/dist/cjs/mixins/OxyServices.deviceBoot.js +119 -0
- package/dist/cjs/mixins/index.js +13 -17
- package/dist/cjs/session/SessionClient.js +40 -1
- package/dist/cjs/session/authStateStore.js +284 -0
- package/dist/cjs/session/refresh.js +264 -0
- package/dist/cjs/utils/accountUtils.js +1 -55
- package/dist/cjs/utils/authWebUrl.js +6 -15
- package/dist/cjs/utils/fapiAutoDetect.js +16 -64
- package/dist/cjs/utils/platform.js +19 -0
- package/dist/cjs/utils/ssoBounce.js +15 -362
- package/dist/cjs/utils/validationUtils.js +57 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/HttpService.js +6 -3
- package/dist/esm/OxyServices.base.js +7 -102
- package/dist/esm/boot/coldBootV2.js +344 -0
- package/dist/esm/boot/deviceBootReturn.js +146 -0
- package/dist/esm/crypto/keyManager.js +95 -0
- package/dist/esm/i18n/locales/en-US.json +13 -1
- package/dist/esm/i18n/locales/es-ES.json +13 -1
- package/dist/esm/i18n/locales/locales/en-US.json +13 -1
- package/dist/esm/i18n/locales/locales/es-ES.json +13 -1
- package/dist/esm/index.js +28 -18
- package/dist/esm/mixins/OxyServices.accounts.js +6 -13
- package/dist/esm/mixins/OxyServices.auth.js +66 -201
- package/dist/esm/mixins/OxyServices.authorizedApps.js +35 -0
- package/dist/esm/mixins/OxyServices.deviceBoot.js +116 -0
- package/dist/esm/mixins/index.js +13 -17
- package/dist/esm/session/SessionClient.js +40 -1
- package/dist/esm/session/authStateStore.js +278 -0
- package/dist/esm/session/refresh.js +257 -0
- package/dist/esm/utils/accountUtils.js +0 -53
- package/dist/esm/utils/authWebUrl.js +6 -14
- package/dist/esm/utils/fapiAutoDetect.js +16 -63
- package/dist/esm/utils/platform.js +18 -0
- package/dist/esm/utils/ssoBounce.js +14 -345
- package/dist/esm/utils/validationUtils.js +56 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/HttpService.d.ts +13 -0
- package/dist/types/OxyServices.base.d.ts +0 -52
- package/dist/types/OxyServices.d.ts +0 -25
- package/dist/types/boot/coldBootV2.d.ts +76 -0
- package/dist/types/boot/deviceBootReturn.d.ts +83 -0
- package/dist/types/crypto/keyManager.d.ts +21 -0
- package/dist/types/index.d.ts +15 -21
- package/dist/types/mixins/OxyServices.accounts.d.ts +0 -2
- package/dist/types/mixins/OxyServices.analytics.d.ts +0 -2
- package/dist/types/mixins/OxyServices.appData.d.ts +0 -2
- package/dist/types/mixins/OxyServices.assets.d.ts +0 -2
- package/dist/types/mixins/OxyServices.auth.d.ts +35 -77
- package/dist/types/mixins/{OxyServices.redirect.d.ts → OxyServices.authorizedApps.d.ts} +35 -33
- package/dist/types/mixins/OxyServices.civic.d.ts +0 -2
- package/dist/types/mixins/OxyServices.connectedApps.d.ts +0 -2
- package/dist/types/mixins/OxyServices.contacts.d.ts +0 -2
- package/dist/types/mixins/OxyServices.deviceBoot.d.ts +110 -0
- package/dist/types/mixins/OxyServices.devices.d.ts +0 -2
- package/dist/types/mixins/OxyServices.features.d.ts +0 -2
- package/dist/types/mixins/OxyServices.identity.d.ts +0 -2
- package/dist/types/mixins/OxyServices.language.d.ts +0 -2
- package/dist/types/mixins/OxyServices.links.d.ts +0 -2
- package/dist/types/mixins/OxyServices.location.d.ts +0 -2
- package/dist/types/mixins/OxyServices.nodes.d.ts +0 -2
- package/dist/types/mixins/OxyServices.payment.d.ts +0 -2
- package/dist/types/mixins/OxyServices.privacy.d.ts +0 -2
- package/dist/types/mixins/OxyServices.reputation.d.ts +0 -2
- package/dist/types/mixins/OxyServices.security.d.ts +0 -2
- package/dist/types/mixins/OxyServices.topics.d.ts +0 -2
- package/dist/types/mixins/OxyServices.user.d.ts +0 -2
- package/dist/types/mixins/OxyServices.utility.d.ts +0 -2
- package/dist/types/mixins/index.d.ts +6 -9
- package/dist/types/models/interfaces.d.ts +0 -67
- package/dist/types/session/SessionClient.d.ts +25 -0
- package/dist/types/session/authStateStore.d.ts +119 -0
- package/dist/types/session/refresh.d.ts +93 -0
- package/dist/types/utils/accountUtils.d.ts +0 -14
- package/dist/types/utils/authWebUrl.d.ts +6 -12
- package/dist/types/utils/fapiAutoDetect.d.ts +15 -38
- package/dist/types/utils/platform.d.ts +14 -0
- package/dist/types/utils/ssoBounce.d.ts +14 -280
- package/dist/types/utils/validationUtils.d.ts +15 -0
- package/package.json +2 -2
- package/src/HttpService.ts +19 -3
- package/src/OxyServices.base.ts +7 -112
- package/src/OxyServices.ts +0 -38
- package/src/boot/__tests__/coldBootV2.test.ts +317 -0
- package/src/boot/__tests__/deviceBootReturn.test.ts +158 -0
- package/src/boot/coldBootV2.ts +426 -0
- package/src/boot/deviceBootReturn.ts +195 -0
- package/src/crypto/__tests__/sharedDeviceToken.test.ts +24 -0
- package/src/crypto/keyManager.ts +101 -0
- package/src/i18n/locales/en-US.json +13 -1
- package/src/i18n/locales/es-ES.json +13 -1
- package/src/index.ts +74 -65
- package/src/mixins/OxyServices.accounts.ts +6 -13
- package/src/mixins/OxyServices.auth.ts +78 -253
- package/src/mixins/OxyServices.authorizedApps.ts +75 -0
- package/src/mixins/OxyServices.deviceBoot.ts +146 -0
- package/src/mixins/__tests__/OxyServices.deviceBoot.test.ts +107 -0
- package/src/mixins/__tests__/accounts.test.ts +17 -44
- package/src/mixins/__tests__/authorizedApps.test.ts +63 -0
- package/src/mixins/__tests__/passwordSignIn.test.ts +91 -0
- package/src/mixins/index.ts +16 -22
- package/src/models/interfaces.ts +0 -79
- package/src/session/SessionClient.ts +52 -1
- package/src/session/__tests__/SessionClient.additive.test.ts +92 -0
- package/src/session/__tests__/SessionClient.rest.test.ts +25 -0
- package/src/session/__tests__/SessionClient.state.test.ts +18 -5
- package/src/session/__tests__/authStateStore.test.ts +209 -0
- package/src/session/__tests__/refresh.test.ts +256 -0
- package/src/session/authStateStore.ts +335 -0
- package/src/session/refresh.ts +334 -0
- package/src/utils/__tests__/authWebUrl.test.ts +5 -29
- package/src/utils/__tests__/fapiAutoDetect.test.ts +5 -126
- package/src/utils/__tests__/validationUtils.test.ts +30 -0
- package/src/utils/accountUtils.ts +0 -62
- package/src/utils/authWebUrl.ts +6 -15
- package/src/utils/fapiAutoDetect.ts +16 -60
- package/src/utils/platform.ts +21 -0
- package/src/utils/ssoBounce.ts +14 -393
- package/src/utils/validationUtils.ts +62 -0
- package/dist/cjs/AuthManager.js +0 -1110
- package/dist/cjs/AuthManagerTypes.js +0 -13
- package/dist/cjs/CrossDomainAuth.js +0 -206
- package/dist/cjs/mixins/OxyServices.fedcm.js +0 -823
- package/dist/cjs/mixins/OxyServices.redirect.js +0 -95
- package/dist/cjs/mixins/OxyServices.silent.js +0 -204
- package/dist/cjs/mixins/OxyServices.sso.js +0 -208
- package/dist/cjs/utils/ssoEstablish.js +0 -110
- package/dist/cjs/utils/ssoReturn.js +0 -275
- package/dist/esm/AuthManager.js +0 -1105
- package/dist/esm/AuthManagerTypes.js +0 -12
- package/dist/esm/CrossDomainAuth.js +0 -201
- package/dist/esm/mixins/OxyServices.fedcm.js +0 -821
- package/dist/esm/mixins/OxyServices.redirect.js +0 -92
- package/dist/esm/mixins/OxyServices.silent.js +0 -202
- package/dist/esm/mixins/OxyServices.sso.js +0 -204
- package/dist/esm/utils/ssoEstablish.js +0 -107
- package/dist/esm/utils/ssoReturn.js +0 -271
- package/dist/types/AuthManager.d.ts +0 -380
- package/dist/types/AuthManagerTypes.d.ts +0 -81
- package/dist/types/CrossDomainAuth.d.ts +0 -164
- package/dist/types/mixins/OxyServices.fedcm.d.ts +0 -331
- package/dist/types/mixins/OxyServices.silent.d.ts +0 -132
- package/dist/types/mixins/OxyServices.sso.d.ts +0 -138
- package/dist/types/utils/ssoEstablish.d.ts +0 -85
- package/dist/types/utils/ssoReturn.d.ts +0 -156
- package/src/AuthManager.ts +0 -1269
- package/src/AuthManagerTypes.ts +0 -86
- package/src/CrossDomainAuth.ts +0 -243
- package/src/__tests__/authManager.cookiePath.test.ts +0 -390
- package/src/__tests__/authManager.security.test.ts +0 -377
- package/src/__tests__/crossDomainAuth.test.ts +0 -116
- package/src/__tests__/establishDeviceRefreshSlot.test.ts +0 -221
- package/src/mixins/OxyServices.fedcm.ts +0 -1026
- package/src/mixins/OxyServices.redirect.ts +0 -122
- package/src/mixins/OxyServices.silent.ts +0 -272
- package/src/mixins/OxyServices.sso.ts +0 -261
- package/src/mixins/__tests__/constructorAuthWebUrl.test.ts +0 -85
- package/src/mixins/__tests__/fedcm.test.ts +0 -667
- package/src/mixins/__tests__/sessionBaseUrl.test.ts +0 -61
- package/src/mixins/__tests__/silent.test.ts +0 -102
- package/src/mixins/__tests__/sso.test.ts +0 -228
- package/src/utils/__tests__/consumeSsoReturn.test.ts +0 -816
- package/src/utils/__tests__/ssoBounce.test.ts +0 -219
- package/src/utils/__tests__/ssoEstablish.test.ts +0 -204
- package/src/utils/__tests__/ssoReturn.test.ts +0 -276
- package/src/utils/ssoEstablish.ts +0 -174
- package/src/utils/ssoReturn.ts +0 -389
|
@@ -1,47 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* This helper computes `https://auth.<rp-apex>` from
|
|
16
|
-
* `window.location.hostname` so a consuming app doesn't have to pass
|
|
17
|
-
* `authWebUrl` explicitly. Returns `undefined` for environments where
|
|
18
|
-
* auto-detection would be wrong:
|
|
19
|
-
*
|
|
20
|
-
* - SSR / non-browser (no `window`).
|
|
21
|
-
* - `localhost`, `127.0.0.1`, IPv4/IPv6 literals.
|
|
22
|
-
* - Hostnames with fewer than two labels.
|
|
23
|
-
* - Hostnames where a registrable domain cannot be determined from the
|
|
24
|
-
* Public Suffix List, including private hosted suffixes such as
|
|
25
|
-
* `github.io`, `pages.dev`, and `netlify.app`.
|
|
26
|
-
*
|
|
27
|
-
* When the page is already loaded ON the IdP itself (`auth.<anything>`),
|
|
28
|
-
* the helper returns the current origin so the SDK keeps everything
|
|
29
|
-
* same-origin instead of hopping to a different IdP host.
|
|
30
|
-
*
|
|
31
|
-
* The IdP backend independently derives `iss`, `provider_urls`, and the
|
|
32
|
-
* `fedcm.json` icon URLs from the request host
|
|
33
|
-
* (`packages/auth/server/index.ts`), so an honest CNAME pair is all that
|
|
34
|
-
* is required for end-to-end FedCM correctness — no per-RP config.
|
|
2
|
+
* Registrable-apex (eTLD+1) host kernel.
|
|
3
|
+
*
|
|
4
|
+
* The client FAPI auto-detection helper (`autoDetectAuthWebUrl`) was removed in
|
|
5
|
+
* the device-first cutover — the SDK no longer derives a per-apex `auth.<rp>`
|
|
6
|
+
* IdP host. What survives is the pure registrable-domain kernel, still used by
|
|
7
|
+
* the api SSO surface, `fedcm.service`, `deviceAuth` (same-apex trust checks),
|
|
8
|
+
* and the IdP worker (all lista B / server-side). `@oxyhq/core/server`
|
|
9
|
+
* re-exports it for the api.
|
|
10
|
+
*
|
|
11
|
+
* LEGACY(old-sdk): `registrableApex` survives ONLY for the lista-B server/IdP
|
|
12
|
+
* SSO surface. Deletable once Homiio/Allo/Alia/Syra are bumped off the old SDK
|
|
13
|
+
* AND CloudWatch `/oxy/ecs` shows the `/sso*` + `/fedcm/*` routes quiet — the
|
|
14
|
+
* F-final sweep should remove this file then.
|
|
35
15
|
*/
|
|
36
16
|
import { getDomain } from 'tldts';
|
|
37
17
|
/**
|
|
38
18
|
* Compute the bare registrable apex (eTLD+1) of a hostname using the Public
|
|
39
19
|
* Suffix List, including private hosted suffixes.
|
|
40
20
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* and builds NO URL. It only answers "what is the registrable domain of this
|
|
44
|
-
* host, or is that undefinable?".
|
|
21
|
+
* Performs NO protocol handling and builds NO URL — it only answers "what is
|
|
22
|
+
* the registrable domain of this host, or is that undefinable?".
|
|
45
23
|
*
|
|
46
24
|
* Returns `null` (apex undefinable) for:
|
|
47
25
|
* - empty input;
|
|
@@ -65,31 +43,6 @@ export function registrableApex(hostname) {
|
|
|
65
43
|
return null;
|
|
66
44
|
// The Public Suffix List (private suffixes included) is the source of truth
|
|
67
45
|
// for what an attacker can register. A multi-part public suffix like `co.uk`
|
|
68
|
-
// or a hosted suffix like `github.io` returns no registrable domain
|
|
69
|
-
// deriving `auth.<apex>` against it is impossible — `getDomain` returns null.
|
|
46
|
+
// or a hosted suffix like `github.io` returns no registrable domain.
|
|
70
47
|
return getDomain(host, { allowPrivateDomains: true });
|
|
71
48
|
}
|
|
72
|
-
export function autoDetectAuthWebUrl(location = typeof window !== 'undefined' ? window.location : undefined) {
|
|
73
|
-
if (!location)
|
|
74
|
-
return undefined;
|
|
75
|
-
const { hostname, protocol } = location;
|
|
76
|
-
if (!hostname)
|
|
77
|
-
return undefined;
|
|
78
|
-
if (protocol !== 'https:' && protocol !== 'http:')
|
|
79
|
-
return undefined;
|
|
80
|
-
if (hostname === 'localhost' || hostname === '127.0.0.1')
|
|
81
|
-
return undefined;
|
|
82
|
-
if (/^\d+\.\d+\.\d+\.\d+$/.test(hostname))
|
|
83
|
-
return undefined;
|
|
84
|
-
if (hostname.startsWith('['))
|
|
85
|
-
return undefined;
|
|
86
|
-
// Already ON the IdP — keep everything same-origin instead of hopping to a
|
|
87
|
-
// sibling host.
|
|
88
|
-
if (hostname.startsWith('auth.')) {
|
|
89
|
-
return `${protocol}//${hostname}`;
|
|
90
|
-
}
|
|
91
|
-
const apex = registrableApex(hostname);
|
|
92
|
-
if (apex === null)
|
|
93
|
-
return undefined;
|
|
94
|
-
return `${protocol}//auth.${apex}`;
|
|
95
|
-
}
|
|
@@ -83,3 +83,21 @@ export function setPlatformOS(os) {
|
|
|
83
83
|
cachedPlatform = os;
|
|
84
84
|
globalThis.__REACT_NATIVE_PLATFORM__ = os;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* True only in a real web browser (a DOM is present), false on React Native
|
|
88
|
+
* and Node/SSR.
|
|
89
|
+
*
|
|
90
|
+
* Native defines a global `window` but no `document`, so the DOM probe — not a
|
|
91
|
+
* bare `window` check — is the reliable discriminator. This is the single
|
|
92
|
+
* source of truth consumed by `@oxyhq/services` and `@oxyhq/auth` (both dropped
|
|
93
|
+
* their local copies), so every consumer shares the exact same predicate.
|
|
94
|
+
*
|
|
95
|
+
* NOTE: this is a live runtime probe (not the cached `getPlatformOS()` verdict)
|
|
96
|
+
* because it must reflect the actual DOM availability at call time in the
|
|
97
|
+
* consumer's bundle.
|
|
98
|
+
*/
|
|
99
|
+
export function isWebBrowser() {
|
|
100
|
+
return (typeof window !== 'undefined' &&
|
|
101
|
+
typeof document !== 'undefined' &&
|
|
102
|
+
typeof document.documentElement !== 'undefined');
|
|
103
|
+
}
|
|
@@ -1,352 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* URL builder, and the small pure predicates shared by every consumer's
|
|
4
|
-
* cold-boot `sso-return` / `sso-bounce` steps and bfcache `pageshow`
|
|
5
|
-
* re-evaluation.
|
|
2
|
+
* SSO callback path constant.
|
|
6
3
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* The client SSO-bounce machinery (per-origin sessionStorage keys, the bounce
|
|
5
|
+
* URL builder, the `guardActive` / `allowSsoBounce` / `getSsoCallbackBootstrapScript`
|
|
6
|
+
* predicates, …) was removed in the device-first cutover — RP apps no longer
|
|
7
|
+
* bounce through `auth.oxy.so`. The one survivor is this path constant, still
|
|
8
|
+
* referenced by the api SSO controller and the IdP (both lista B, gated on the
|
|
9
|
+
* ecosystem bump). `@oxyhq/core/server` re-exports it for the api.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* `auth.oxy.so/sso?prompt=none&client_id=<origin>&return_to=<origin>{@link SSO_CALLBACK_PATH}&state=<s>`.
|
|
16
|
-
* Before navigating it records, in this origin's `sessionStorage`, the
|
|
17
|
-
* CSRF `state` ({@link ssoStateKey}), a guard timestamp ({@link ssoGuardKey},
|
|
18
|
-
* the loop breaker), and the real destination URL ({@link ssoDestKey}) to
|
|
19
|
-
* restore after the callback.
|
|
20
|
-
* 2. The central IdP worker reads its first-party `fedcm_session`, mints a
|
|
21
|
-
* session, stores it under an opaque single-use `code`, and 303-redirects
|
|
22
|
-
* back to `<origin>{@link SSO_CALLBACK_PATH}#oxy_sso=ok&code=<code>&state=<s>`
|
|
23
|
-
* (or `#oxy_sso=none` / `#oxy_sso=error`).
|
|
24
|
-
* 3. `sso-return` parses the fragment (`parseSsoReturnFragment`), validates
|
|
25
|
-
* `state`, exchanges the `code` via `oxyServices.exchangeSsoCode`, commits
|
|
26
|
-
* the session, then restores the original destination.
|
|
27
|
-
*
|
|
28
|
-
* Loop proof (logged-out): first load all steps skip → `sso-bounce` sets
|
|
29
|
-
* guard/state/dest + the outcome-independent attempted-flag
|
|
30
|
-
* ({@link ssoAttemptedKey}) and navigates; the IdP (no central session) returns
|
|
31
|
-
* `#oxy_sso=none`; the callback load's `sso-return` sees `none`, sets the
|
|
32
|
-
* NO_SESSION flag ({@link ssoNoSessionKey}), and `sso-bounce` is then disabled.
|
|
33
|
-
* Exactly ONE bounce, no loop. An interrupted bounce (user hit back
|
|
34
|
-
* mid-redirect) self-heals once the {@link SSO_GUARD_TTL_MS} guard TTL lapses.
|
|
35
|
-
* The attempted-flag is the definitive, outcome-INDEPENDENT loop breaker: it is
|
|
36
|
-
* set pre-bounce so even if the return-side NO_SESSION write never lands, the
|
|
37
|
-
* bounce can never re-fire this tab after the self-heal TTL lapses.
|
|
38
|
-
*
|
|
39
|
-
* All state lives in `sessionStorage` (per tab, cleared on tab close) and is
|
|
40
|
-
* keyed per-origin so two RPs hosted in the same browser never collide. The
|
|
41
|
-
* key strings and the 30s TTL are a wire/storage contract — they MUST match
|
|
42
|
-
* the values the IdP and every consumer expect and must not change lightly.
|
|
11
|
+
* LEGACY(old-sdk): `SSO_CALLBACK_PATH` survives ONLY for the lista-B api/IdP SSO
|
|
12
|
+
* surface. Deletable once Homiio/Allo/Alia/Syra are bumped off the old SDK AND
|
|
13
|
+
* CloudWatch `/oxy/ecs` shows the `/sso*` + `/fedcm/*` routes quiet — the
|
|
14
|
+
* F-final sweep should remove this file then.
|
|
43
15
|
*/
|
|
44
|
-
import { CENTRAL_AUTH_URL, resolveCentralAuthUrl } from './authWebUrl.js';
|
|
45
16
|
/**
|
|
46
|
-
* The RP callback path the central IdP redirects back to after a
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* {@link ssoDestKey}), so the user never lingers on this internal path.
|
|
17
|
+
* The RP callback path the central IdP redirects back to after a legacy SSO
|
|
18
|
+
* bounce. Kept as the single source of truth so the api/IdP never hardcode the
|
|
19
|
+
* literal.
|
|
50
20
|
*/
|
|
51
21
|
export const SSO_CALLBACK_PATH = '/__oxy/sso-callback';
|
|
52
|
-
/**
|
|
53
|
-
* Self-healing TTL (ms) for the bounce guard. An in-flight bounce sets a
|
|
54
|
-
* timestamp guard; if the bounce is interrupted before the callback lands
|
|
55
|
-
* (e.g. the user navigates back mid-redirect), the guard would otherwise pin
|
|
56
|
-
* the RP signed-out forever. After this window the guard is treated as stale
|
|
57
|
-
* and a fresh single bounce is permitted. 30s comfortably exceeds a real
|
|
58
|
-
* redirect round-trip while keeping a crash short-lived.
|
|
59
|
-
*/
|
|
60
|
-
export const SSO_GUARD_TTL_MS = 30000;
|
|
61
|
-
const STATE_KEY_PREFIX = 'oxy_sso_state:';
|
|
62
|
-
const GUARD_KEY_PREFIX = 'oxy_sso_guard:';
|
|
63
|
-
const DEST_KEY_PREFIX = 'oxy_sso_dest:';
|
|
64
|
-
const NO_SESSION_KEY_PREFIX = 'oxy_sso_no_session:';
|
|
65
|
-
const ATTEMPTED_KEY_PREFIX = 'oxy_sso_attempted:';
|
|
66
|
-
const CALLBACK_BOOTSTRAP_KEY_PREFIX = 'oxy_sso_callback_bootstrap:';
|
|
67
|
-
const PRIOR_SESSION_KEY_PREFIX = 'oxy_sso_prior_session:';
|
|
68
|
-
const SIGNED_OUT_KEY_PREFIX = 'oxy_signed_out:';
|
|
69
|
-
const OUTCOME_KEY_PREFIX = 'oxy_sso_outcome:';
|
|
70
|
-
/** Per-origin CSRF state key (matched on return to defeat fragment forgery). */
|
|
71
|
-
export function ssoStateKey(origin) {
|
|
72
|
-
return `${STATE_KEY_PREFIX}${origin}`;
|
|
73
|
-
}
|
|
74
|
-
/** Per-origin bounce guard key (a timestamp; loop breaker + self-heal TTL). */
|
|
75
|
-
export function ssoGuardKey(origin) {
|
|
76
|
-
return `${GUARD_KEY_PREFIX}${origin}`;
|
|
77
|
-
}
|
|
78
|
-
/** Per-origin destination key (the real URL to restore after the callback). */
|
|
79
|
-
export function ssoDestKey(origin) {
|
|
80
|
-
return `${DEST_KEY_PREFIX}${origin}`;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Per-origin "the central IdP has no session for me" key. Set after a
|
|
84
|
-
* `none`/`error` return (or a failed/forged exchange) so `sso-bounce` does not
|
|
85
|
-
* fire again this tab — the definitive loop breaker.
|
|
86
|
-
*/
|
|
87
|
-
export function ssoNoSessionKey(origin) {
|
|
88
|
-
return `${NO_SESSION_KEY_PREFIX}${origin}`;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Per-origin, OUTCOME-INDEPENDENT once-guard. Set in `sessionStorage` BEFORE
|
|
92
|
-
* the terminal SSO bounce navigates. Gates the bounce so the silent
|
|
93
|
-
* cross-domain probe fires AT MOST ONCE per tab session — independent of
|
|
94
|
-
* whether the return-side NO_SESSION flag ever lands. The definitive loop
|
|
95
|
-
* breaker; survives the 30s self-heal `ssoGuardKey` TTL. Cleared only on an
|
|
96
|
-
* explicit sign-out/clear so a later cold boot (after the user signs in
|
|
97
|
-
* centrally) can probe again.
|
|
98
|
-
*/
|
|
99
|
-
export function ssoAttemptedKey(origin) {
|
|
100
|
-
return `${ATTEMPTED_KEY_PREFIX}${origin}`;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Per-origin DURABLE "this device/origin has had a signed-in Oxy session
|
|
104
|
-
* before" hint.
|
|
105
|
-
*
|
|
106
|
-
* Unlike every other key in this module — which lives in per-tab
|
|
107
|
-
* `sessionStorage` — this hint is written to DURABLE storage (web
|
|
108
|
-
* `localStorage`; the services provider uses its own `storageKeyPrefix`-scoped
|
|
109
|
-
* key in `@oxyhq/services`). It is set whenever a session is established or
|
|
110
|
-
* restored and survives a session expiring; it is cleared ONLY on an explicit
|
|
111
|
-
* full sign-out. It exists purely to drive {@link allowSsoBounce}: a returning
|
|
112
|
-
* visitor (hint present) whose local session has lapsed still gets ONE terminal
|
|
113
|
-
* `/sso` establish bounce to recover a session that lives only at the central
|
|
114
|
-
* IdP, while a truly first-time anonymous visitor is never force-bounced.
|
|
115
|
-
*/
|
|
116
|
-
export function ssoPriorSessionKey(origin) {
|
|
117
|
-
return `${PRIOR_SESSION_KEY_PREFIX}${origin}`;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Per-origin DURABLE "the user DELIBERATELY signed out on this device/origin"
|
|
121
|
-
* flag.
|
|
122
|
-
*
|
|
123
|
-
* Like {@link ssoPriorSessionKey} this lives in DURABLE storage (web
|
|
124
|
-
* `localStorage`; services uses its own `storageKeyPrefix`-scoped key), NOT the
|
|
125
|
-
* per-tab `sessionStorage` the loop-breaker keys use — it must survive a reload.
|
|
126
|
-
*
|
|
127
|
-
* It exists purely to suppress AUTOMATIC silent restore after a deliberate
|
|
128
|
-
* sign-out: a still-live IdP session (the central `fedcm_session`) would
|
|
129
|
-
* otherwise let the per-apex `/auth/silent` iframe re-mint a session on the
|
|
130
|
-
* very next cold boot, so a user who pressed "Sign out" gets silently signed
|
|
131
|
-
* back in on reload. With this flag set, that silent cold-boot step is
|
|
132
|
-
* skipped while the Gmail-style returning-account fast-path is otherwise
|
|
133
|
-
* preserved.
|
|
134
|
-
*
|
|
135
|
-
* Lifecycle (mirrors the existing gate machinery — set on a definitive event,
|
|
136
|
-
* cleared on its inverse):
|
|
137
|
-
* - SET on EXPLICIT full sign-out (alongside clearing the prior-session hint
|
|
138
|
-
* and the SSO bounce state).
|
|
139
|
-
* - CLEARED on ANY deliberate sign-in (password, account switch, device
|
|
140
|
-
* claim) so a real sign-in fully re-enables silent restore — there is no
|
|
141
|
-
* "stuck signed out" state.
|
|
142
|
-
*
|
|
143
|
-
* NOTE: this gates only AUTOMATIC/silent restore. An INTERACTIVE sign-in always
|
|
144
|
-
* clears it first, so the user can always sign back in.
|
|
145
|
-
*/
|
|
146
|
-
export function ssoSignedOutKey(origin) {
|
|
147
|
-
return `${SIGNED_OUT_KEY_PREFIX}${origin}`;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Per-origin key holding the LAST consumed SSO-return outcome (`ok` | `none` |
|
|
151
|
-
* `error`, plus an optional machine-readable `reason` on the non-`ok` outcomes).
|
|
152
|
-
*
|
|
153
|
-
* Lives in per-tab `sessionStorage` like the other loop-breaker keys, and for
|
|
154
|
-
* the same reason: a `none`/`error` return HARD-navigates the RP off the
|
|
155
|
-
* internal callback path back to its real destination (a fresh document load),
|
|
156
|
-
* so the outcome an RP wants to render ("the central IdP had no session — show a
|
|
157
|
-
* branded sign-in screen instead of bouncing again") must survive that
|
|
158
|
-
* round-trip. The RP reads it on the destination load to decide whether an
|
|
159
|
-
* AUTOMATIC (guard-driven) sign-in should re-bounce or defer to a user gesture.
|
|
160
|
-
*
|
|
161
|
-
* Written as a small JSON blob (`{kind, reason?}`). Set whenever a return is
|
|
162
|
-
* consumed; cleared on a successful session commit and on an explicit
|
|
163
|
-
* user-gesture sign-in / full sign-out (so a deliberate retry is never
|
|
164
|
-
* suppressed by a prior automatic none/error).
|
|
165
|
-
*/
|
|
166
|
-
export function ssoOutcomeKey(origin) {
|
|
167
|
-
return `${OUTCOME_KEY_PREFIX}${origin}`;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Per-origin marker written by the pre-hydration callback bootstrap.
|
|
171
|
-
*
|
|
172
|
-
* Static Expo exports render unknown paths as `+not-found`; on
|
|
173
|
-
* `/__oxy/sso-callback` that can fail hydration before the React provider has a
|
|
174
|
-
* chance to run `consumeSsoReturn`. The bootstrap runs in the HTML head, moves
|
|
175
|
-
* the URL to a hydratable route while preserving the SSO fragment, and writes
|
|
176
|
-
* this marker so `consumeSsoReturn` still restores the original destination as
|
|
177
|
-
* if the page were physically on the callback path.
|
|
178
|
-
*/
|
|
179
|
-
export function ssoCallbackBootstrapKey(origin) {
|
|
180
|
-
return `${CALLBACK_BOOTSTRAP_KEY_PREFIX}${origin}`;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Inline script for Expo/static web apps.
|
|
184
|
-
*
|
|
185
|
-
* Must run before the app bundle hydrates. It is intentionally tiny and
|
|
186
|
-
* dependency-free: if the browser lands on the internal callback route with an
|
|
187
|
-
* Oxy SSO fragment, it marks the handoff and rewrites the path to `/` while
|
|
188
|
-
* preserving `#oxy_sso=...`. The normal SDK cold-boot `sso-return` step then
|
|
189
|
-
* consumes the fragment from a route that can hydrate. If the internal route is
|
|
190
|
-
* reached without a valid SSO fragment, it leaves the route via a hard root
|
|
191
|
-
* navigation because there is no session material to preserve.
|
|
192
|
-
*/
|
|
193
|
-
export function getSsoCallbackBootstrapScript() {
|
|
194
|
-
const callbackPath = JSON.stringify(SSO_CALLBACK_PATH);
|
|
195
|
-
const bootstrapPrefix = JSON.stringify(CALLBACK_BOOTSTRAP_KEY_PREFIX);
|
|
196
|
-
return `(function(){var p=${callbackPath};if(window.location.pathname!==p)return;var h=window.location.hash||"";if(!/(?:^#|&)oxy_sso=(?:ok|none|error)(?:&|$)/.test(h)){window.location.replace("/");return;}try{window.sessionStorage.setItem(${bootstrapPrefix}+window.location.origin,"1");}catch(e){window.__oxySsoCallbackBootstrapError=e instanceof Error?e.message:String(e);}try{window.history.replaceState(null,"","/"+h);}catch(e){window.__oxySsoCallbackBootstrapError=e instanceof Error?e.message:String(e);window.location.replace("/"+h);}})();`;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Perform the terminal top-level SSO bounce navigation.
|
|
200
|
-
*
|
|
201
|
-
* A thin wrapper over `window.location.assign(url)` so the single navigation
|
|
202
|
-
* seam lives in one place (and stays mockable in tests, where jsdom's
|
|
203
|
-
* `Location.assign` is a non-configurable native method). In production this is
|
|
204
|
-
* exactly `window.location.assign` — the document is torn down and replaced by
|
|
205
|
-
* the central IdP page. Off-browser (SSR / native) it is a no-op: native never
|
|
206
|
-
* bounces.
|
|
207
|
-
*/
|
|
208
|
-
export function ssoNavigate(url) {
|
|
209
|
-
if (typeof window === 'undefined' || typeof window.location === 'undefined') {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
window.location.assign(url);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Build the central IdP `/sso` bounce URL for an RP.
|
|
216
|
-
*
|
|
217
|
-
* Pure (no DOM access) so it is unit-testable and shared by every consumer's
|
|
218
|
-
* terminal `sso-bounce` step. The IdP reads `client_id` (the RP origin) and
|
|
219
|
-
* `return_to` to mint an origin-bound opaque code and 303-redirect back.
|
|
220
|
-
*
|
|
221
|
-
* The IdP base is resolved via {@link resolveCentralAuthUrl} so an explicit
|
|
222
|
-
* `authWebUrl` override (e.g. a staging IdP) drives the SSO bounce exactly the
|
|
223
|
-
* way it drives FedCM. When omitted, the central default {@link CENTRAL_AUTH_URL}
|
|
224
|
-
* is used.
|
|
225
|
-
*
|
|
226
|
-
* @param origin - The RP origin (`window.location.origin`).
|
|
227
|
-
* @param state - The CSRF state minted for this bounce.
|
|
228
|
-
* @param authWebUrl - Optional explicit IdP base URL override. Falls back to
|
|
229
|
-
* the central default when `undefined`/empty.
|
|
230
|
-
* @returns The absolute `<idp-origin>/sso?...` URL string.
|
|
231
|
-
*/
|
|
232
|
-
export function buildSsoBounceUrl(origin, state, authWebUrl) {
|
|
233
|
-
const url = new URL('/sso', resolveCentralAuthUrl(authWebUrl));
|
|
234
|
-
url.searchParams.set('prompt', 'none');
|
|
235
|
-
url.searchParams.set('client_id', origin);
|
|
236
|
-
url.searchParams.set('return_to', origin + SSO_CALLBACK_PATH);
|
|
237
|
-
url.searchParams.set('state', state);
|
|
238
|
-
return url.toString();
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Whether `origin` IS the central IdP origin. The RP must NEVER bounce while
|
|
242
|
-
* sitting on `auth.oxy.so` itself — doing so would loop the IdP against itself.
|
|
243
|
-
*
|
|
244
|
-
* Both sides are normalised via `new URL(...).origin` so a trailing-slash or
|
|
245
|
-
* path difference never defeats the guard. Returns `false` on any parse
|
|
246
|
-
* failure (an unparseable candidate is, by definition, not the central IdP).
|
|
247
|
-
*/
|
|
248
|
-
export function isCentralIdPOrigin(origin) {
|
|
249
|
-
let centralOrigin;
|
|
250
|
-
try {
|
|
251
|
-
centralOrigin = new URL(CENTRAL_AUTH_URL).origin;
|
|
252
|
-
}
|
|
253
|
-
catch {
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
let candidateOrigin;
|
|
257
|
-
try {
|
|
258
|
-
candidateOrigin = new URL(origin).origin;
|
|
259
|
-
}
|
|
260
|
-
catch {
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
return candidateOrigin === centralOrigin;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Read the bounce guard and decide whether it is still ACTIVE.
|
|
267
|
-
*
|
|
268
|
-
* Active means: a guard value is present AND it parses to a finite timestamp
|
|
269
|
-
* AND less than {@link SSO_GUARD_TTL_MS} has elapsed since it was set. An active
|
|
270
|
-
* guard disables `sso-bounce` (a bounce is already in flight this tab). A
|
|
271
|
-
* missing, malformed, or expired guard is NOT active, so a fresh bounce may
|
|
272
|
-
* proceed (this is the 30s self-heal for an interrupted bounce).
|
|
273
|
-
*
|
|
274
|
-
* Defensive: a `getItem` that throws (e.g. a locked/disabled storage) is
|
|
275
|
-
* treated as "not active" so the guard never wedges the flow.
|
|
276
|
-
*
|
|
277
|
-
* @param storage - The session storage to read (injected for testability).
|
|
278
|
-
* @param origin - The page origin whose guard to evaluate.
|
|
279
|
-
* @param now - Current epoch ms (injected for deterministic tests). Defaults to
|
|
280
|
-
* `Date.now()`.
|
|
281
|
-
*/
|
|
282
|
-
export function guardActive(storage, origin, now = Date.now()) {
|
|
283
|
-
let raw;
|
|
284
|
-
try {
|
|
285
|
-
raw = storage.getItem(ssoGuardKey(origin));
|
|
286
|
-
}
|
|
287
|
-
catch {
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
if (raw === null || raw.length === 0) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
const ts = Number(raw);
|
|
294
|
-
if (!Number.isFinite(ts)) {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
return now - ts < SSO_GUARD_TTL_MS;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Whether AUTOMATIC silent restore is SUPPRESSED for this origin because the
|
|
301
|
-
* user deliberately signed out (the durable {@link ssoSignedOutKey} flag).
|
|
302
|
-
*
|
|
303
|
-
* When `true`, the silent cold-boot step that can re-mint a session from a
|
|
304
|
-
* still-live IdP session WITHOUT user intent — the per-apex
|
|
305
|
-
* `/auth/silent` iframe — MUST be skipped, so a user who pressed "Sign out" is
|
|
306
|
-
* not silently signed back in on the next reload. Interactive sign-in clears the
|
|
307
|
-
* flag, so this never blocks a deliberate re-sign-in.
|
|
308
|
-
*
|
|
309
|
-
* Defensive: a `getItem` that throws (locked/disabled storage) is treated as NOT
|
|
310
|
-
* suppressed, so the gate fails toward the normal restore behaviour rather than
|
|
311
|
-
* wedging the user out.
|
|
312
|
-
*
|
|
313
|
-
* @param storage - The DURABLE storage to read (web `localStorage`; injected for
|
|
314
|
-
* testability).
|
|
315
|
-
* @param origin - The page origin whose signed-out flag to evaluate.
|
|
316
|
-
*/
|
|
317
|
-
export function silentRestoreSuppressed(storage, origin) {
|
|
318
|
-
try {
|
|
319
|
-
return storage.getItem(ssoSignedOutKey(origin)) === '1';
|
|
320
|
-
}
|
|
321
|
-
catch {
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Decide whether the terminal `/sso` establish-bounce is ALLOWED for this
|
|
327
|
-
* visitor (the smart `enabled` gate for the `sso-bounce` cold-boot step).
|
|
328
|
-
*
|
|
329
|
-
* The terminal bounce is the ONLY cold-boot step that can recover a session
|
|
330
|
-
* that lives SOLELY at the central IdP — the cross-apex Relying-Party case
|
|
331
|
-
* (e.g. `mention.earth`, a different apex from `oxy.so`) whose device-local
|
|
332
|
-
* session has expired and whose `Domain=oxy.so` refresh cookie never reaches
|
|
333
|
-
* `api.<apex>`. It is also what plants the first-party per-apex `fedcm_session`
|
|
334
|
-
* cookie that the EARLIER `silent-iframe` step later relies on. So it must fire
|
|
335
|
-
* for a RETURNING user, yet it must NOT force a truly first-time anonymous
|
|
336
|
-
* visitor off to the IdP.
|
|
337
|
-
*
|
|
338
|
-
* - ALLOW when there is a prior-signed-in hint OR a local session was
|
|
339
|
-
* recovered this boot (a returning user) — so a central-only cross-domain
|
|
340
|
-
* session recovers via ONE bounce, after which the per-apex cookie is
|
|
341
|
-
* planted and subsequent loads restore silently with no bounce.
|
|
342
|
-
* - else (no hint, no local session) SUPPRESS — a first-time anonymous
|
|
343
|
-
* visitor browses without a forced redirect.
|
|
344
|
-
*
|
|
345
|
-
* This is the smart DEFAULT and the ONLY behaviour: apps never configure it.
|
|
346
|
-
* It is also the GATE DECISION ONLY — callers still apply the per-tab loop
|
|
347
|
-
* guards (`ssoAttemptedKey`, `ssoNoSessionKey`, {@link guardActive}) so an
|
|
348
|
-
* allowed bounce still fires at most once per cold boot.
|
|
349
|
-
*/
|
|
350
|
-
export function allowSsoBounce(gate) {
|
|
351
|
-
return gate.hasPriorSession || gate.hasLocalSession;
|
|
352
|
-
}
|
|
@@ -32,6 +32,62 @@ export function isValidUsername(username) {
|
|
|
32
32
|
export function isValidPassword(password) {
|
|
33
33
|
return PASSWORD_REGEX.test(password);
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Display-name character policy.
|
|
37
|
+
*
|
|
38
|
+
* A clean display name is composed ONLY of:
|
|
39
|
+
* - letters of any script (`\p{L}`),
|
|
40
|
+
* - combining marks / accents (`\p{M}`, e.g. the acute accent in a decomposed
|
|
41
|
+
* "é"),
|
|
42
|
+
* - Unicode space separators (`\p{Zs}`: the ASCII space, NBSP, ideographic
|
|
43
|
+
* space, …) — but NOT control whitespace such as tab, newline, or carriage
|
|
44
|
+
* return, which would break layout or enable multi-line spoofing,
|
|
45
|
+
* - the straight apostrophe (`'`, e.g. "O'Brien").
|
|
46
|
+
*
|
|
47
|
+
* Everything else is rejected: emoji (🐧), symbols (⁂ ⏚), `:emoji:` shortcodes,
|
|
48
|
+
* digits, hyphens, dots, control whitespace (tab/newline/CR), and any other
|
|
49
|
+
* punctuation. The allowed set `\p{L}\p{M}\p{Zs}'` explicitly EXCLUDES `<`, `>`,
|
|
50
|
+
* `&`, and `"`, so a value that passes this predicate can never contain an
|
|
51
|
+
* HTML/XSS vector.
|
|
52
|
+
*
|
|
53
|
+
* This is the SINGLE definition of the policy, shared between the API 400-gate
|
|
54
|
+
* (`@oxyhq/api` `displayNameSanitize.ts`) and client-side inline validation
|
|
55
|
+
* (the RN profile editor) so the two can never drift. It is platform-agnostic
|
|
56
|
+
* (no react/react-native/expo).
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* Single test for the presence of a disallowed character (non-global). The
|
|
60
|
+
* whitespace class is `\p{Zs}` (space separators only), NOT `\s` — the latter
|
|
61
|
+
* would admit tab/newline/carriage return, which break layout and enable
|
|
62
|
+
* multi-line spoofing.
|
|
63
|
+
*/
|
|
64
|
+
const DISALLOWED_PROBE = /[^\p{L}\p{M}\p{Zs}']/u;
|
|
65
|
+
/**
|
|
66
|
+
* Single test for the presence of an orphaned combining mark (non-global) — a
|
|
67
|
+
* `\p{M}` not attached to a base letter (string start, whitespace, the
|
|
68
|
+
* apostrophe, or a position vacated by a stripped character). A mark preceded by
|
|
69
|
+
* `\p{L}` (a base letter, e.g. the decomposed accent in "Renée") or by another
|
|
70
|
+
* `\p{M}` (a multi-mark cluster) is NOT matched because the negative lookbehind
|
|
71
|
+
* fails at its position.
|
|
72
|
+
*/
|
|
73
|
+
const ORPHANED_MARK_PROBE = /(?<![\p{L}\p{M}])\p{M}/u;
|
|
74
|
+
/**
|
|
75
|
+
* Whether `raw` already satisfies the display-name policy, i.e. it contains no
|
|
76
|
+
* disallowed characters AND no orphaned combining marks. Used to REJECT native
|
|
77
|
+
* (signup / profile edit) names with a 400 rather than silently stripping them,
|
|
78
|
+
* and to validate inline in the client editor.
|
|
79
|
+
*
|
|
80
|
+
* The orphaned-mark probe runs on the NFC-normalized form so a legitimate
|
|
81
|
+
* decomposed accent (`e`+◌́) — which normalization recomposes into `é` — is NOT
|
|
82
|
+
* rejected, while a lone, base-less mark (e.g. `"༘"`) IS.
|
|
83
|
+
*
|
|
84
|
+
* The function only checks the character set; an empty or whitespace-only string
|
|
85
|
+
* is considered valid (`true`). Call sites that require a non-empty name enforce
|
|
86
|
+
* that separately.
|
|
87
|
+
*/
|
|
88
|
+
export function isValidDisplayName(raw) {
|
|
89
|
+
return (!DISALLOWED_PROBE.test(raw) && !ORPHANED_MARK_PROBE.test(raw.normalize('NFC')));
|
|
90
|
+
}
|
|
35
91
|
/**
|
|
36
92
|
* Validate required string
|
|
37
93
|
*/
|