@vectoriox/iox-ui 5.100.0 → 5.101.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/commerce-core/index.d.ts +2 -0
- package/composite-core/index.d.ts +24 -8
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +3 -0
- package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +75 -18
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-identity-core.mjs +203 -23
- package/fesm2022/vectoriox-iox-ui-identity-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +5 -2
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/identity-core/index.d.ts +130 -16
- package/index.d.ts +0 -11
- package/package.json +1 -1
- package/src/commerce-core/site-checkout.ts +3 -0
- package/src/composite-core/account-runtime.ts +41 -8
- package/src/composite-core/account.ts +39 -11
- package/src/identity-core/provider-marks.ts +60 -0
- package/src/identity-core/public-api.ts +2 -0
- package/src/identity-core/sign-in.ts +43 -6
- package/src/identity-core/site-auth-transport.ts +10 -2
- package/src/identity-core/site-auth.ts +26 -0
- package/src/identity-core/site-methods.ts +78 -0
- package/src/identity-core/words.ts +60 -17
- package/styles/iox-design.css +6 -6
package/identity-core/index.d.ts
CHANGED
|
@@ -12,10 +12,11 @@ declare enum SignInPurpose {
|
|
|
12
12
|
/** portal.iox.studio. */
|
|
13
13
|
Portal = "portal"
|
|
14
14
|
}
|
|
15
|
-
/** A provider the broker runs.
|
|
15
|
+
/** A provider the broker runs (board 18). The enum's order is the order every sign-in shows them in. Each id is the path
|
|
16
|
+
* segment of the ONE address registered with that provider: `https://auth.iox.studio/<id>/callback`. */
|
|
16
17
|
declare enum SignInProvider {
|
|
17
18
|
Google = "google",
|
|
18
|
-
|
|
19
|
+
Facebook = "facebook",
|
|
19
20
|
GitHub = "github",
|
|
20
21
|
LinkedIn = "linkedin"
|
|
21
22
|
}
|
|
@@ -28,10 +29,13 @@ interface SignInProviderSpec {
|
|
|
28
29
|
readonly protocol: SignInProtocol;
|
|
29
30
|
/** The answer is signed, so a studio can check it itself — the only kind an admin may sign in with (C-D6). */
|
|
30
31
|
readonly signedAnswer: boolean;
|
|
31
|
-
/**
|
|
32
|
+
/** The broker has an adapter for it. Whether it is ON (both keys in the broker's env) is the broker's answer to
|
|
33
|
+
* `BrokerApiRoute.Providers`, read at run time — never a release. */
|
|
32
34
|
readonly live: boolean;
|
|
33
35
|
}
|
|
34
36
|
declare const SIGN_IN_PROVIDER_SPECS: Readonly<Record<SignInProvider, SignInProviderSpec>>;
|
|
37
|
+
/** Every provider, in the order a sign-in shows them. */
|
|
38
|
+
declare const SIGN_IN_PROVIDERS: ReadonlyArray<SignInProvider>;
|
|
35
39
|
declare function isSignInProvider(value: unknown): value is SignInProvider;
|
|
36
40
|
declare function isSignInPurpose(value: unknown): value is SignInPurpose;
|
|
37
41
|
/** May `provider` serve `purpose`? Buyers and the portal take any provider; a team member only a signed answer (C-D6). */
|
|
@@ -45,8 +49,18 @@ declare const SIGN_IN_HANDOFF_TTL_SECONDS = 60;
|
|
|
45
49
|
/** The server-to-server routes on the control plane's API host (bearer: the studio's INSTANCE_TOKEN). */
|
|
46
50
|
declare enum BrokerApiRoute {
|
|
47
51
|
Tickets = "instances/me/sign-in/tickets",
|
|
48
|
-
Redeem = "instances/me/sign-in/redeem"
|
|
49
|
-
}
|
|
52
|
+
Redeem = "instances/me/sign-in/redeem",
|
|
53
|
+
/** `GET` → only the providers that are ON: `{ "google": true }` (`SignInProvidersAnswer`). */
|
|
54
|
+
Providers = "instances/me/sign-in/providers"
|
|
55
|
+
}
|
|
56
|
+
/** `GET instances/me/sign-in/providers` — each provider that is ON, `true`; an off one is absent. */
|
|
57
|
+
type SignInProvidersAnswer = Partial<Record<SignInProvider, true>>;
|
|
58
|
+
/** The providers ON in a broker's answer, in the order a sign-in shows them; anything else in the body is ignored. */
|
|
59
|
+
declare function providersOn(answer: unknown): SignInProvider[];
|
|
60
|
+
/** The providers ON at the broker that may serve `purpose` (C-D6: a team member only with a signed answer). */
|
|
61
|
+
declare function providersServing(on: readonly SignInProvider[], purpose: SignInPurpose): SignInProvider[];
|
|
62
|
+
/** How long a studio or the portal may keep the broker's providers answer before asking again. */
|
|
63
|
+
declare const SIGN_IN_PROVIDERS_CACHE_SECONDS = 60;
|
|
50
64
|
/** The browser's routes on `auth.iox.studio`, one pair per provider. */
|
|
51
65
|
declare enum BrokerBrowserRoute {
|
|
52
66
|
Start = "start",
|
|
@@ -104,7 +118,9 @@ declare enum BrokerRefusalCode {
|
|
|
104
118
|
/** 410 */
|
|
105
119
|
CodeUsedOrExpired = "code-used-or-expired",
|
|
106
120
|
/** 403 — another tenant's code. */
|
|
107
|
-
NotYours = "not-yours"
|
|
121
|
+
NotYours = "not-yours",
|
|
122
|
+
/** 400 — a purpose this asker may not use, or a provider that may not serve it (C-D6). */
|
|
123
|
+
InvalidRequest = "invalid-request"
|
|
108
124
|
}
|
|
109
125
|
declare const BROKER_REFUSAL_STATUS: Readonly<Record<BrokerRefusalCode, number>>;
|
|
110
126
|
declare function isBrokerRefusalCode(value: unknown): value is BrokerRefusalCode;
|
|
@@ -112,6 +128,14 @@ declare function isBrokerRefusalCode(value: unknown): value is BrokerRefusalCode
|
|
|
112
128
|
declare const SIGN_IN_HANDOFF_PARAM = "iox_signin";
|
|
113
129
|
/** The failure's query parameter on the return address. */
|
|
114
130
|
declare const SIGN_IN_ERROR_PARAM = "iox_signin_error";
|
|
131
|
+
/** Beside a failure a studio sends back: the provider it was (`?iox_signin_via=github`), so the words can name it. */
|
|
132
|
+
declare const SIGN_IN_VIA_PARAM = "iox_signin_via";
|
|
133
|
+
/**
|
|
134
|
+
* The binding parameter on every return address a studio or the portal asks the broker for: `iox_sb=<sha256 of the
|
|
135
|
+
* random value in the starting browser's httpOnly cookie>`. The redeemed `returnUrl` must carry THIS browser's hash — a
|
|
136
|
+
* hand-off started in another browser is refused (login CSRF).
|
|
137
|
+
*/
|
|
138
|
+
declare const SIGN_IN_BINDING_PARAM = "iox_sb";
|
|
115
139
|
/** Why the browser came back without a person. */
|
|
116
140
|
declare enum SignInReturnError {
|
|
117
141
|
/** The person pressed Cancel on the provider's screen. */
|
|
@@ -182,7 +206,9 @@ declare enum SiteAuthRoute {
|
|
|
182
206
|
SignOut = "auth/signout",
|
|
183
207
|
/** `GET` → `{ customer }` (null when signed out). */
|
|
184
208
|
Me = "me",
|
|
185
|
-
MyOrders = "me/orders"
|
|
209
|
+
MyOrders = "me/orders",
|
|
210
|
+
/** `GET` → `{ methods }` — the ways this site lets a buyer sign in right now (`siteSignInMethods`). Public. */
|
|
211
|
+
Methods = "auth/methods"
|
|
186
212
|
}
|
|
187
213
|
/** Every route a site's sign-in calls, by name (the provider pair is per provider — `siteProviderPath`). */
|
|
188
214
|
declare const SITE_AUTH_ROUTES: Readonly<Record<keyof typeof SiteAuthRoute, SiteAuthRoute>>;
|
|
@@ -252,6 +278,13 @@ declare const SITE_COOKIE_PATH = "/";
|
|
|
252
278
|
declare const SIGN_IN_STATE_MAX_AGE_SECONDS = 600;
|
|
253
279
|
declare function customerCookieName(orgId: string): string;
|
|
254
280
|
declare function signInStateCookieName(orgId: string): string;
|
|
281
|
+
/**
|
|
282
|
+
* A cookie no sibling host can plant (vectoriox/iox-cms#73 — cookie tossing from another `*.iox.studio`): over https the
|
|
283
|
+
* name takes the `__Host-` prefix, which a browser accepts only `Secure`, with `Path=/` and no `Domain`. A server that
|
|
284
|
+
* sets one with this name must set exactly those; plain http (local development) keeps the bare name.
|
|
285
|
+
*/
|
|
286
|
+
declare const HOST_ONLY_COOKIE_PREFIX = "__Host-";
|
|
287
|
+
declare function hostOnlyCookieName(name: string, secure: boolean): string;
|
|
255
288
|
declare const EMAIL_CODE_LENGTH = 6;
|
|
256
289
|
declare const EMAIL_CODE_TTL_MINUTES = 10;
|
|
257
290
|
declare const EMAIL_CODE_TTL_MS: number;
|
|
@@ -270,6 +303,12 @@ declare function emailCodeTriesLeft(wrongTries: number): number;
|
|
|
270
303
|
declare const ACCOUNT_PATH = "account";
|
|
271
304
|
/** The buyer's account page — their orders: `/<orgLabel>/account` (the engine answers it on every studio). */
|
|
272
305
|
declare function accountHref(orgLabel?: string | null): string;
|
|
306
|
+
/** The account page's segment for one order: `/<orgLabel>/account/orders/<number>`. */
|
|
307
|
+
declare const ACCOUNT_ORDERS_SEGMENT = "orders";
|
|
308
|
+
/** One of the signed-in buyer's own orders, under the account page — read by the session, never by a link token. */
|
|
309
|
+
declare function accountOrderHref(orgLabel: string | null | undefined, orderNumber: string | number): string;
|
|
310
|
+
/** `GET /api/site/<org>/me/orders/<number>` — one order of the signed-in buyer (404 for anyone else's). */
|
|
311
|
+
declare function siteMyOrderPath(orgId: string, orderNumber: string | number): string;
|
|
273
312
|
|
|
274
313
|
/**
|
|
275
314
|
* The sign-in dialog's words and its refusals, in English and Hebrew. A string-rendered site has no translation
|
|
@@ -289,7 +328,8 @@ declare enum SignInWord {
|
|
|
289
328
|
SignIn = "signIn",
|
|
290
329
|
SignInTo = "signInTo",
|
|
291
330
|
Why = "why",
|
|
292
|
-
|
|
331
|
+
/** `{provider}` = the brand's own name (`signInProviderName`), never translated. */
|
|
332
|
+
ContinueWith = "continueWith",
|
|
293
333
|
Or = "or",
|
|
294
334
|
Email = "email",
|
|
295
335
|
EmailPlaceholder = "emailPlaceholder",
|
|
@@ -308,7 +348,13 @@ declare enum SignInWord {
|
|
|
308
348
|
Hello = "hello",
|
|
309
349
|
SignedIn = "signedIn",
|
|
310
350
|
SignedOut = "signedOut",
|
|
311
|
-
NoPassword = "noPassword"
|
|
351
|
+
NoPassword = "noPassword",
|
|
352
|
+
/** Before the checkout's "Sign in". */
|
|
353
|
+
HaveAccount = "haveAccount",
|
|
354
|
+
/** The account page with no orders. */
|
|
355
|
+
NoOrders = "noOrders",
|
|
356
|
+
/** An order row on the account page: `{date}`. */
|
|
357
|
+
PlacedOn = "placedOn"
|
|
312
358
|
}
|
|
313
359
|
/** `{site}`, `{email}`, `{name}`, `{minutes}` are filled by `signInWord`. */
|
|
314
360
|
declare const SIGN_IN_WORDS: Readonly<Record<SignInWord, SignInLabel>>;
|
|
@@ -317,7 +363,7 @@ declare function signInWord(word: SignInWord, lang: string | null | undefined, f
|
|
|
317
363
|
declare enum SignInSlot {
|
|
318
364
|
Email = "email",
|
|
319
365
|
Code = "code",
|
|
320
|
-
/** Under "Continue with Google". */
|
|
366
|
+
/** Under the provider buttons ("Continue with Google"). */
|
|
321
367
|
Provider = "provider",
|
|
322
368
|
/** The dialog as a whole. */
|
|
323
369
|
Dialog = "dialog"
|
|
@@ -342,6 +388,8 @@ declare enum SiteSignInRefusalCode {
|
|
|
342
388
|
StateMismatch = "state-mismatch",
|
|
343
389
|
Blocked = "blocked",
|
|
344
390
|
NotSignedIn = "not-signed-in",
|
|
391
|
+
/** The studio has no working mailer, so it cannot send a code (it never says whether the email is known). */
|
|
392
|
+
EmailUnavailable = "email-unavailable",
|
|
345
393
|
Network = "network"
|
|
346
394
|
}
|
|
347
395
|
interface SignInRefusalRule {
|
|
@@ -357,11 +405,55 @@ interface SignInRefusal {
|
|
|
357
405
|
slot: SignInSlot;
|
|
358
406
|
words: string;
|
|
359
407
|
}
|
|
360
|
-
/** One refusal, on its slot, in the visitor's words. */
|
|
361
|
-
declare function signInRefusal(code: unknown, lang: string | null | undefined): SignInRefusal;
|
|
408
|
+
/** One refusal, on its slot, in the visitor's words; a provider's refusal names it (`provider`). */
|
|
409
|
+
declare function signInRefusal(code: unknown, lang: string | null | undefined, provider?: SignInProvider | null): SignInRefusal;
|
|
362
410
|
/** A refused call's body (`{ code }`) — or nothing at all (`network`) — as one refusal. The body's `message` is a log
|
|
363
411
|
* line and is never shown. A 429 with no code is `rate-limited`. */
|
|
364
|
-
declare function signInRefusalOf(body: unknown, lang: string | null | undefined, status?: number | null): SignInRefusal;
|
|
412
|
+
declare function signInRefusalOf(body: unknown, lang: string | null | undefined, status?: number | null, provider?: SignInProvider | null): SignInRefusal;
|
|
413
|
+
/** A provider sign-in that came back refused to a site's page: the site's own code (a studio's `blocked`,
|
|
414
|
+
* `state-mismatch`… kept; a broker return error mapped) and the provider it was (`?iox_signin_via=`), or null. */
|
|
415
|
+
interface SiteSignInReturnRefusal {
|
|
416
|
+
code: SiteSignInRefusalCode;
|
|
417
|
+
provider: SignInProvider | null;
|
|
418
|
+
}
|
|
419
|
+
declare function siteSignInReturnRefusal(search: string | URLSearchParams | null | undefined): SiteSignInReturnRefusal | null;
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Which ways a studio's SITE lets a buyer sign in (Settings ▸ Sign-in, board 18): the email code always, and each
|
|
423
|
+
* provider the owner switched on — while the broker has it ON and it may serve a buyer (C-D6). ONE rule for the studio
|
|
424
|
+
* that enforces it (iox-cms), the site that shows it (the engine, the canvas) and the screen that sets it (cms-client).
|
|
425
|
+
*/
|
|
426
|
+
/** The email code — a `customerIdentities.provider` value beside the broker's providers; it never touches the broker. */
|
|
427
|
+
declare const EMAIL_CODE_PROVIDER: "email-code";
|
|
428
|
+
type EmailCodeProvider = typeof EMAIL_CODE_PROVIDER;
|
|
429
|
+
/** A way a buyer signs in, and the `customerIdentities.provider` it is stored as. */
|
|
430
|
+
type SiteSignInMethod = EmailCodeProvider | SignInProvider;
|
|
431
|
+
/** Every method, in the order a sign-in shows them. */
|
|
432
|
+
declare const SITE_SIGN_IN_METHODS: ReadonlyArray<SiteSignInMethod>;
|
|
433
|
+
declare function isSiteSignInMethod(value: unknown): value is SiteSignInMethod;
|
|
434
|
+
/** The settings type a studio's org stores its choice under (`settings` collection, one row per org). */
|
|
435
|
+
declare const SITE_SIGN_IN_SETTINGS_TYPE = "signIn";
|
|
436
|
+
/** What the owner chose: each provider on or off for buyers. The email code is not a choice — it is always on. */
|
|
437
|
+
interface SiteSignInSettings {
|
|
438
|
+
providers: Record<SignInProvider, boolean>;
|
|
439
|
+
}
|
|
440
|
+
/** A studio that never chose: Google on (C-D6 — "Google on by default, the others as owner switches"). */
|
|
441
|
+
declare const DEFAULT_SITE_SIGN_IN_SETTINGS: Readonly<SiteSignInSettings>;
|
|
442
|
+
/** Any stored or posted value as a whole setting: every provider present, booleans only, unknown keys dropped. */
|
|
443
|
+
declare function normalizeSiteSignInSettings(raw: unknown): SiteSignInSettings;
|
|
444
|
+
/** The methods a site offers right now: the email code, then every provider the owner switched on that the broker has
|
|
445
|
+
* ON (`brokerOn`) and that may serve a buyer. */
|
|
446
|
+
declare function siteSignInMethods(settings: unknown, brokerOn: readonly SignInProvider[]): SiteSignInMethod[];
|
|
447
|
+
/** May a buyer start `provider` on this site right now? */
|
|
448
|
+
declare function siteOffersProvider(settings: unknown, brokerOn: readonly SignInProvider[], provider: SignInProvider): boolean;
|
|
449
|
+
/** `GET api/site/<org>/auth/methods` — public, cacheable. */
|
|
450
|
+
interface SiteSignInMethodsAnswer {
|
|
451
|
+
methods: SiteSignInMethod[];
|
|
452
|
+
}
|
|
453
|
+
/** The methods in an answer (unknown values dropped, in the shown order); the email code is always one of them. */
|
|
454
|
+
declare function siteSignInMethodsOf(answer: unknown): SiteSignInMethod[];
|
|
455
|
+
/** The providers among a site's methods. */
|
|
456
|
+
declare function siteSignInProviders(methods: readonly SiteSignInMethod[]): SignInProvider[];
|
|
365
457
|
|
|
366
458
|
/**
|
|
367
459
|
* THE TRANSPORT a site's sign-in parts speak (commerce E3a, the `CartTransport` rule): the parts own no HTTP. The engine
|
|
@@ -381,6 +473,8 @@ interface SiteAuthTransport {
|
|
|
381
473
|
/** Check the code; the signed-in buyer. */
|
|
382
474
|
verifyCode(email: string, code: string): Promise<SiteCustomer>;
|
|
383
475
|
signOut(): Promise<void>;
|
|
476
|
+
/** The ways this site lets a buyer sign in (`SiteAuthRoute.Methods`). Absent = the parts hide nothing. */
|
|
477
|
+
methods?(): Promise<SiteSignInMethod[]>;
|
|
384
478
|
}
|
|
385
479
|
/** A refused transport call, carrying the code the visitor's words come from (`signInRefusal`). */
|
|
386
480
|
declare class SiteAuthError extends Error {
|
|
@@ -403,7 +497,7 @@ interface SimulatedSiteAuthTransport extends SiteAuthTransport {
|
|
|
403
497
|
* sample buyer under the typed email, any other six digits are `code-wrong`; a provider's start answers the broker's
|
|
404
498
|
* address with a sample ticket (the canvas host never follows it).
|
|
405
499
|
*/
|
|
406
|
-
declare function simulatedSiteAuthTransport(start?: SiteCustomer | null): SimulatedSiteAuthTransport;
|
|
500
|
+
declare function simulatedSiteAuthTransport(start?: SiteCustomer | null, methods?: readonly SiteSignInMethod[]): SimulatedSiteAuthTransport;
|
|
407
501
|
/** A transport that has nothing to reach: `me` is null, every change refused as `network`. */
|
|
408
502
|
declare const NO_SITE_AUTH_TRANSPORT: SiteAuthTransport;
|
|
409
503
|
/** The context slot the account parts bind to (`$customer.initial`, `$customer.name`). */
|
|
@@ -422,5 +516,25 @@ declare function customerInitial(customer: Pick<SiteCustomer, 'name' | 'email'>
|
|
|
422
516
|
declare function customerDisplayName(customer: Pick<SiteCustomer, 'name' | 'email'> | null | undefined): string;
|
|
423
517
|
declare function customerSlotOf(customer: SiteCustomer | null | undefined): CustomerSlot;
|
|
424
518
|
|
|
425
|
-
|
|
426
|
-
|
|
519
|
+
/**
|
|
520
|
+
* How each provider's button presents it — ONE copy for every IOX sign-in (the site's dialog, the admin login, the
|
|
521
|
+
* portal). Each brand's button guidelines: its own name, never translated ("Continue with GitHub" / "המשך עם GitHub"),
|
|
522
|
+
* and its official mark in its own colours, unaltered — Google's four-colour G, LinkedIn's "in" on its blue, Facebook's
|
|
523
|
+
* white f on its blue circle; GitHub's mark is single-colour by its rules, so it takes the button's ink (`currentColor`).
|
|
524
|
+
*/
|
|
525
|
+
interface SignInProviderBrand {
|
|
526
|
+
/** The brand's name, as the brand writes it. */
|
|
527
|
+
readonly name: string;
|
|
528
|
+
/** The mark as one inline SVG (a square `viewBox`, no size — the button sizes it). */
|
|
529
|
+
readonly mark: string;
|
|
530
|
+
/** The mark for an `<img>`, where `currentColor` means nothing — when it differs from `mark`. */
|
|
531
|
+
readonly imageMark?: string;
|
|
532
|
+
}
|
|
533
|
+
declare const SIGN_IN_PROVIDER_BRANDS: Readonly<Record<SignInProvider, SignInProviderBrand>>;
|
|
534
|
+
/** The provider's name as its brand writes it. */
|
|
535
|
+
declare function signInProviderName(provider: SignInProvider | null | undefined): string;
|
|
536
|
+
/** The mark as a `data:` address — for an `<img>` (a builder Image part, an admin button). */
|
|
537
|
+
declare function signInProviderMarkUri(provider: SignInProvider): string;
|
|
538
|
+
|
|
539
|
+
export { ACCOUNT_ORDERS_SEGMENT, ACCOUNT_PATH, BROKER_HOST, BROKER_ORIGIN, BROKER_REFUSAL_STATUS, BROKER_TICKET_PARAM, BrokerApiRoute, BrokerBrowserRoute, BrokerRefusalCode, CUSTOMER_COOKIE_PREFIX, CUSTOMER_SLOT, DEFAULT_SITE_SIGN_IN_SETTINGS, EMAIL_CODE_LENGTH, EMAIL_CODE_MAX_TRIES, EMAIL_CODE_PROVIDER, EMAIL_CODE_TTL_MINUTES, EMAIL_CODE_TTL_MS, HOST_ONLY_COOKIE_PREFIX, NEXT_PATH_MAX_LENGTH, NO_SITE_AUTH_TRANSPORT, SAMPLE_CUSTOMER, SIGN_IN_BINDING_PARAM, SIGN_IN_ERROR_PARAM, SIGN_IN_HANDOFF_PARAM, SIGN_IN_HANDOFF_TTL_SECONDS, SIGN_IN_NEXT_PARAM, SIGN_IN_PROVIDERS, SIGN_IN_PROVIDERS_CACHE_SECONDS, SIGN_IN_PROVIDER_BRANDS, SIGN_IN_PROVIDER_SPECS, SIGN_IN_REFUSALS, SIGN_IN_STATE_COOKIE_PREFIX, SIGN_IN_STATE_MAX_AGE_SECONDS, SIGN_IN_TICKET_TTL_SECONDS, SIGN_IN_VIA_PARAM, SIGN_IN_WORDS, SIMULATED_SIGN_IN_CODE, SITE_AUDIENCE, SITE_AUTH_ROUTES, SITE_COOKIE_PATH, SITE_SIGN_IN_METHODS, SITE_SIGN_IN_SETTINGS_TYPE, SignInLanguage, SignInProtocol, SignInProvider, SignInPurpose, SignInReturnError, SignInSlot, SignInWord, SiteAuthError, SiteAuthRoute, SiteProviderRoute, SiteSignInRefusalCode, accountHref, accountOrderHref, brokerApiPath, brokerBrowserUrl, brokerCallbackUrl, brokerStartUrl, customerCookieName, customerDisplayName, customerInitial, customerSlotOf, emailCodeExpired, emailCodeTriesLeft, hasSiteAudience, hostOnlyCookieName, isAllowedReturnHost, isBrokerRefusalCode, isEmailCodeShape, isLoopbackHost, isSameOriginPath, isSignInProvider, isSignInPurpose, isSignInReturnError, isSiteSessionClaims, isSiteSignInMethod, isSiteSignInRefusalCode, normalizeEmailCode, normalizeHost, normalizeSignInEmail, normalizeSiteSignInSettings, providerServes, providersOn, providersServing, readSignInReturn, safeNextPath, signInLanguage, signInProviderMarkUri, signInProviderName, signInRefusal, signInRefusalOf, signInStateCookieName, signInWord, simulatedSiteAuthTransport, siteAuthErrorCode, siteAuthPath, siteMyOrderPath, siteOffersProvider, siteProviderPath, siteProviderReturnUrl, siteSignInCodeOf, siteSignInMethods, siteSignInMethodsOf, siteSignInProviders, siteSignInReturnRefusal, withSignInError, withSignInHandoff };
|
|
540
|
+
export type { CustomerSlot, EmailCodeProvider, ReturnHostOptions, SignInLabel, SignInProviderBrand, SignInProviderSpec, SignInProvidersAnswer, SignInRedeemAnswer, SignInRedeemRequest, SignInRefusal, SignInReturn, SignInTicketAnswer, SignInTicketRequest, SimulatedSiteAuthTransport, SiteAuthTransport, SiteCodeRequest, SiteCodeVerifyRequest, SiteCustomer, SiteMeAnswer, SiteProviderStartAnswer, SiteProviderStartRequest, SiteSessionClaims, SiteSignInMethod, SiteSignInMethodsAnswer, SiteSignInReturnRefusal, SiteSignInSettings };
|
package/index.d.ts
CHANGED
|
@@ -3583,17 +3583,6 @@ declare function isContextAction(action: ContextActionLike | null | undefined):
|
|
|
3583
3583
|
*/
|
|
3584
3584
|
declare function contextActionEffect(action: ContextActionLike | null | undefined, pass?: 'forward' | 'reverse'): ContextActionEffect | null;
|
|
3585
3585
|
|
|
3586
|
-
/**
|
|
3587
|
-
* Which slot keys are actually IN USE on a page — derived from the layout tree itself.
|
|
3588
|
-
*
|
|
3589
|
-
* A slot only matters at runtime if something writes it (a `setContext`/`clearContext` action) or
|
|
3590
|
-
* reads it (a binding whose `source` names it). Deriving the set from the tree means the runtime
|
|
3591
|
-
* works without waiting on the page model: a DECLARED `IoxContextSlot` adds typing for the bind
|
|
3592
|
-
* picker and a `default`, but is not required for the channel to function.
|
|
3593
|
-
*
|
|
3594
|
-
* Union of declared + in-use, so a declared-but-unused slot still seeds its default, and a slot used
|
|
3595
|
-
* by a symbol dropped onto a page that never declared it still works (it just has no default).
|
|
3596
|
-
*/
|
|
3597
3586
|
declare function collectContextSlotKeys(nodes: readonly unknown[] | undefined,
|
|
3598
3587
|
/** Declared VARIABLES — page resources of `type: 'variable'`, or legacy slot declarations. */
|
|
3599
3588
|
declared?: readonly (IoxContextSlot | {
|
package/package.json
CHANGED
|
@@ -326,6 +326,8 @@ export enum SiteRefusalCode {
|
|
|
326
326
|
Busy = 'busy',
|
|
327
327
|
UnknownOrder = 'unknown-order',
|
|
328
328
|
UnknownSite = 'unknown-site',
|
|
329
|
+
/** The owner blocked this buyer (commerce E3c): no checkout, no order. */
|
|
330
|
+
CustomerBlocked = 'customer-blocked',
|
|
329
331
|
Network = 'network',
|
|
330
332
|
}
|
|
331
333
|
|
|
@@ -371,6 +373,7 @@ export const SITE_REFUSALS: Readonly<Record<SiteRefusalCode, RefusalRule>> = Obj
|
|
|
371
373
|
[SiteRefusalCode.Busy]: { slot: CheckoutSlot.Page, label: TRY_AGAIN },
|
|
372
374
|
[SiteRefusalCode.UnknownOrder]: { slot: CheckoutSlot.Page, label: { en: 'We could not find this order.', he: 'לא מצאנו את ההזמנה הזו.' } },
|
|
373
375
|
[SiteRefusalCode.UnknownSite]: { slot: CheckoutSlot.Page, label: CLOSED },
|
|
376
|
+
[SiteRefusalCode.CustomerBlocked]: { slot: CheckoutSlot.Page, label: { en: 'This account cannot place orders here. Contact the business.', he: 'החשבון הזה לא יכול לבצע הזמנות כאן. פנו לעסק.' } },
|
|
374
377
|
[SiteRefusalCode.Network]: { slot: CheckoutSlot.Page, label: { en: 'We could not reach the shop. Try again.', he: 'לא הצלחנו להגיע לחנות. נסו שוב.' } },
|
|
375
378
|
});
|
|
376
379
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { writeFieldError } from '@vectoriox/iox-ui/design-core';
|
|
2
2
|
import {
|
|
3
3
|
CUSTOMER_SLOT, customerDisplayName, customerSlotOf, EMAIL_CODE_TTL_MINUTES, isEmailCodeShape, normalizeEmailCode, normalizeSignInEmail,
|
|
4
|
-
SignInProvider, signInRefusal, SignInSlot, SignInWord, signInWord, siteAuthErrorCode, SiteAuthTransport, SiteCustomer,
|
|
4
|
+
SIGN_IN_PROVIDERS, SignInProvider, signInRefusal, SignInSlot, SignInWord, signInWord, siteAuthErrorCode, SiteAuthTransport, SiteCustomer,
|
|
5
|
+
SiteSignInMethod, SiteSignInRefusalCode, SiteSignInReturnRefusal,
|
|
5
6
|
} from '@vectoriox/iox-ui/identity-core';
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
|
-
ACCOUNT_HIDDEN_ATTRIBUTE, ACCOUNT_LIVE_CLASS, accountSelector, AccountRole, SIGN_IN_STEP_ATTRIBUTE, SignInStep, SIGNED_IN_ATTRIBUTE,
|
|
9
|
+
ACCOUNT_HIDDEN_ATTRIBUTE, ACCOUNT_LIVE_CLASS, accountSelector, AccountRole, PROVIDER_ROLES, SIGN_IN_STEP_ATTRIBUTE, SignInStep, SIGNED_IN_ATTRIBUTE,
|
|
9
10
|
} from './account';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -35,8 +36,9 @@ export interface AccountHost {
|
|
|
35
36
|
returnPath?: () => string;
|
|
36
37
|
/** The account page (`accountHref(orgLabel)`) — the menu's "Your orders" goes there. */
|
|
37
38
|
accountHref?: () => string;
|
|
38
|
-
/** A provider sign-in that came back refused (`?iox_signin_error
|
|
39
|
-
|
|
39
|
+
/** A provider sign-in that came back refused (`?iox_signin_error=` + `iox_signin_via`, read by the host with
|
|
40
|
+
* identity-core `siteSignInReturnRefusal`) — said in the dialog on load, naming the provider. */
|
|
41
|
+
pendingError?: () => SiteSignInReturnRefusal | string | null;
|
|
40
42
|
/** The signed-in state changed (the host may re-render personal parts). */
|
|
41
43
|
onChange?: (customer: SiteCustomer | null) => void;
|
|
42
44
|
/** Re-sync when the markup under the scope changes (the builder canvas re-renders parts). */
|
|
@@ -86,6 +88,10 @@ export class AccountRuntime {
|
|
|
86
88
|
private syncing = false;
|
|
87
89
|
private syncQueued = false;
|
|
88
90
|
private lastPublished = '';
|
|
91
|
+
/** The ways the site offers right now (`transport.methods`); null until known — nothing is hidden then. */
|
|
92
|
+
private offered: ReadonlySet<SiteSignInMethod> | null = null;
|
|
93
|
+
/** The provider the last start was for — its refusal names it. */
|
|
94
|
+
private provider: SignInProvider | null = null;
|
|
89
95
|
|
|
90
96
|
constructor(readonly scope: HTMLElement, private readonly host: AccountHost) {
|
|
91
97
|
SCOPES.set(scope, this);
|
|
@@ -96,10 +102,17 @@ export class AccountRuntime {
|
|
|
96
102
|
this.observer.observe(scope, { childList: true, subtree: true });
|
|
97
103
|
}
|
|
98
104
|
this.sync();
|
|
105
|
+
void this.host.transport.methods?.().then(methods => {
|
|
106
|
+
if (this.destroyed) return;
|
|
107
|
+
this.offered = new Set(methods);
|
|
108
|
+
this.sync();
|
|
109
|
+
}, () => undefined);
|
|
99
110
|
void this.host.transport.me().then(customer => {
|
|
100
111
|
this.setCustomer(customer);
|
|
101
112
|
const pending = this.host.pendingError?.();
|
|
102
|
-
if (pending)
|
|
113
|
+
if (!pending) return;
|
|
114
|
+
if (typeof pending === 'string') this.openSignIn(pending);
|
|
115
|
+
else { this.provider = pending.provider; this.openSignIn(pending.code); }
|
|
103
116
|
}, () => this.setCustomer(null));
|
|
104
117
|
}
|
|
105
118
|
|
|
@@ -196,7 +209,7 @@ export class AccountRuntime {
|
|
|
196
209
|
|
|
197
210
|
/** Say a refusal on its slot, and move focus to the field it is about. */
|
|
198
211
|
private say(code: unknown): void {
|
|
199
|
-
const refusal = signInRefusal(code, this.lang);
|
|
212
|
+
const refusal = signInRefusal(code, this.lang, this.provider);
|
|
200
213
|
if (refusal.slot === SignInSlot.Email || refusal.slot === SignInSlot.Code) {
|
|
201
214
|
const role = refusal.slot === SignInSlot.Email ? AccountRole.Email : AccountRole.Code;
|
|
202
215
|
const field = fieldElementOf(this.part(role));
|
|
@@ -230,9 +243,10 @@ export class AccountRuntime {
|
|
|
230
243
|
}
|
|
231
244
|
}
|
|
232
245
|
|
|
233
|
-
/** Continue with
|
|
246
|
+
/** Continue with a provider: the studio asks the broker for a ticket; the browser goes to its start address. */
|
|
234
247
|
async startProvider(provider: SignInProvider = SignInProvider.Google, button: HTMLElement | null = null): Promise<void> {
|
|
235
248
|
this.clearErrors();
|
|
249
|
+
this.provider = provider;
|
|
236
250
|
await this.run(button, async () => {
|
|
237
251
|
const { startUrl } = await this.host.transport.startProvider(provider, this.host.returnPath?.() ?? '/');
|
|
238
252
|
this.host.navigate?.(startUrl);
|
|
@@ -330,6 +344,7 @@ export class AccountRuntime {
|
|
|
330
344
|
const line = this.part(role);
|
|
331
345
|
if (line && !wordsOf(line).textContent) setAttr(line, ACCOUNT_HIDDEN_ATTRIBUTE, '');
|
|
332
346
|
}
|
|
347
|
+
this.showOffered(dialog);
|
|
333
348
|
this.prepareInputs();
|
|
334
349
|
}
|
|
335
350
|
} finally {
|
|
@@ -338,6 +353,21 @@ export class AccountRuntime {
|
|
|
338
353
|
}
|
|
339
354
|
}
|
|
340
355
|
|
|
356
|
+
/** Only the providers the site offers right now; with none, the "or" between them and the email goes too. */
|
|
357
|
+
private showOffered(dialog: HTMLElement): void {
|
|
358
|
+
if (!this.offered) return;
|
|
359
|
+
let any = false;
|
|
360
|
+
for (const provider of SIGN_IN_PROVIDERS) {
|
|
361
|
+
const on = this.offered.has(provider);
|
|
362
|
+
for (const button of Array.from(dialog.querySelectorAll<HTMLElement>(sel(PROVIDER_ROLES[provider])))) {
|
|
363
|
+
setAttr(button, ACCOUNT_HIDDEN_ATTRIBUTE, on ? null : '');
|
|
364
|
+
any ||= on;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
setAttr(dialog.querySelector(sel(AccountRole.Providers)), ACCOUNT_HIDDEN_ATTRIBUTE, any ? null : '');
|
|
368
|
+
setAttr(dialog.querySelector(sel(AccountRole.Or)), ACCOUNT_HIDDEN_ATTRIBUTE, any ? null : '');
|
|
369
|
+
}
|
|
370
|
+
|
|
341
371
|
/** What a browser and a phone keyboard need to know about the two inputs (autofill, the one-time code). */
|
|
342
372
|
private prepareInputs(): void {
|
|
343
373
|
const email = controlOf(this.part(AccountRole.Email));
|
|
@@ -380,7 +410,10 @@ export class AccountRuntime {
|
|
|
380
410
|
const entry = button(AccountRole.Entry);
|
|
381
411
|
if (entry) { this.signIn(entry); return; }
|
|
382
412
|
if (!target.closest(sel(AccountRole.SignIn))) return;
|
|
383
|
-
|
|
413
|
+
for (const provider of SIGN_IN_PROVIDERS) {
|
|
414
|
+
const pressed = button(PROVIDER_ROLES[provider]);
|
|
415
|
+
if (pressed) { void this.startProvider(provider, pressed); return; }
|
|
416
|
+
}
|
|
384
417
|
if (button(AccountRole.SendCode)) { void this.sendCode(button(AccountRole.SendCode)); return; }
|
|
385
418
|
if (button(AccountRole.SendAgain)) { void this.sendCode(button(AccountRole.SendAgain)); return; }
|
|
386
419
|
if (button(AccountRole.Verify)) { void this.verify(button(AccountRole.Verify)); return; }
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { roleClass } from '@vectoriox/iox-ui/design-core';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
CUSTOMER_SLOT, EMAIL_CODE_TTL_MINUTES, SIGN_IN_PROVIDERS, SignInLanguage, signInLanguage, SignInProvider, signInProviderMarkUri, signInProviderName,
|
|
4
|
+
SignInWord, signInWord,
|
|
5
|
+
} from '@vectoriox/iox-ui/identity-core';
|
|
3
6
|
|
|
4
7
|
import { CompositeNode, CompositeNodeFactory, writeProp } from './composite-node';
|
|
5
8
|
import { bindSlot, COLUMN, onClick, recipeButton, recipeIcon, recipePart, recipeText, ROW, WORDS, ZERO } from './recipe-parts';
|
|
@@ -15,14 +18,17 @@ import { bindSlot, COLUMN, onClick, recipeButton, recipeIcon, recipePart, recipe
|
|
|
15
18
|
* · Popover account.menu › Text account.menu-greeting · ButtonBlock account.orders (a link to the
|
|
16
19
|
* account page) · ButtonBlock account.sign-out (signOut)
|
|
17
20
|
* Sign-in dialog Dialog account.sign-in › head (Heading account.title · Close) · Text account.why
|
|
18
|
-
* · ButtonBlock account.google
|
|
21
|
+
* · Container account.providers › ButtonBlock account.google / .facebook / .github / .linkedin
|
|
22
|
+
* ("Continue with <brand>", the brand's mark) · Text account.provider-error · Text account.or
|
|
19
23
|
* · Container account.email-step › Field account.email · ButtonBlock account.send-code
|
|
20
24
|
* · Container account.code-step › Text account.code-sent · Field account.code · ButtonBlock account.verify
|
|
21
25
|
* · row (Text account.code-valid · Send again · Use another email)
|
|
22
26
|
* · Text account.dialog-error
|
|
23
27
|
*
|
|
24
28
|
* Words are the recipe's in English (board 12); the runtime writes the visitor's language over the ones it owns
|
|
25
|
-
* (the code-sent line, refusals) and a studio edits the rest like any Text.
|
|
29
|
+
* (the code-sent line, refusals) and a studio edits the rest like any Text. Every provider's button is stamped; the
|
|
30
|
+
* runtime hides the ones the site does not offer right now (`SiteAuthTransport.methods` — Settings ▸ Sign-in and the
|
|
31
|
+
* broker's providers), so a provider switched on later appears with no change to the page.
|
|
26
32
|
*/
|
|
27
33
|
|
|
28
34
|
export enum AccountRole {
|
|
@@ -40,7 +46,11 @@ export enum AccountRole {
|
|
|
40
46
|
Title = 'account.title',
|
|
41
47
|
Close = 'account.close',
|
|
42
48
|
Why = 'account.why',
|
|
49
|
+
Providers = 'account.providers',
|
|
43
50
|
Google = 'account.google',
|
|
51
|
+
Facebook = 'account.facebook',
|
|
52
|
+
GitHub = 'account.github',
|
|
53
|
+
LinkedIn = 'account.linkedin',
|
|
44
54
|
ProviderError = 'account.provider-error',
|
|
45
55
|
Or = 'account.or',
|
|
46
56
|
EmailStep = 'account.email-step',
|
|
@@ -58,6 +68,14 @@ export enum AccountRole {
|
|
|
58
68
|
|
|
59
69
|
export const ACCOUNT_ROLES: ReadonlySet<string> = new Set(Object.values(AccountRole));
|
|
60
70
|
|
|
71
|
+
/** Each provider's button in the sign-in dialog. */
|
|
72
|
+
export const PROVIDER_ROLES: Readonly<Record<SignInProvider, AccountRole>> = Object.freeze({
|
|
73
|
+
[SignInProvider.Google]: AccountRole.Google,
|
|
74
|
+
[SignInProvider.Facebook]: AccountRole.Facebook,
|
|
75
|
+
[SignInProvider.GitHub]: AccountRole.GitHub,
|
|
76
|
+
[SignInProvider.LinkedIn]: AccountRole.LinkedIn,
|
|
77
|
+
});
|
|
78
|
+
|
|
61
79
|
export function isAccountRole(role: string | null | undefined): boolean {
|
|
62
80
|
return !!role && ACCOUNT_ROLES.has(role);
|
|
63
81
|
}
|
|
@@ -102,7 +120,8 @@ export function accountRecipeWords(lang: string | null | undefined = 'en') {
|
|
|
102
120
|
title: w(SignInWord.SignIn),
|
|
103
121
|
close: w(SignInWord.Close),
|
|
104
122
|
why: w(SignInWord.Why),
|
|
105
|
-
|
|
123
|
+
providers: Object.freeze(Object.fromEntries(SIGN_IN_PROVIDERS.map(p => [p, w(SignInWord.ContinueWith, { provider: signInProviderName(p) })]))) as
|
|
124
|
+
Readonly<Record<SignInProvider, string>>,
|
|
106
125
|
or: w(SignInWord.Or),
|
|
107
126
|
email: w(SignInWord.Email),
|
|
108
127
|
emailPlaceholder: w(SignInWord.EmailPlaceholder),
|
|
@@ -229,12 +248,9 @@ export function buildSignInDialogRecipe(create: CompositeNodeFactory, lang: stri
|
|
|
229
248
|
head.children = [title, close];
|
|
230
249
|
|
|
231
250
|
const why = words(create, 'sign-in-why', AccountRole.Why, Style.Small, t.why, 'Why sign in');
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
words(create, 'sign-in-google-label', null, Style.Label, t.google, 'Text', WORDS, 'span'),
|
|
236
|
-
];
|
|
237
|
-
const providerError = words(create, 'sign-in-provider-error', AccountRole.ProviderError, Style.Error, '', 'Google error');
|
|
251
|
+
const providers = recipePart(create, 'sign-in-providers', 'Container', AccountRole.Providers, null, {}, 'Sign-in providers', { ...COLUMN, gap: '8px' });
|
|
252
|
+
providers.children = SIGN_IN_PROVIDERS.map(p => providerButton(create, p, t.providers[p]));
|
|
253
|
+
const providerError = words(create, 'sign-in-provider-error', AccountRole.ProviderError, Style.Error, '', 'Provider error');
|
|
238
254
|
const or = words(create, 'sign-in-or', AccountRole.Or, Style.Small, t.or, 'Or', { ...WORDS, width: '100%', textAlign: 'center' });
|
|
239
255
|
|
|
240
256
|
const emailStep = recipePart(create, 'sign-in-email-step', 'Container', AccountRole.EmailStep, null, {}, 'Email step', { ...COLUMN, gap: '10px' });
|
|
@@ -260,10 +276,22 @@ export function buildSignInDialogRecipe(create: CompositeNodeFactory, lang: stri
|
|
|
260
276
|
again,
|
|
261
277
|
];
|
|
262
278
|
const dialogError = words(create, 'sign-in-dialog-error', AccountRole.DialogError, Style.Error, '', 'Error');
|
|
263
|
-
dialog.children = [head, why,
|
|
279
|
+
dialog.children = [head, why, providers, providerError, or, emailStep, codeStep, dialogError];
|
|
264
280
|
return dialog;
|
|
265
281
|
}
|
|
266
282
|
|
|
283
|
+
/** "Continue with <brand>" with the brand's own mark (its button guidelines), wearing the look's secondary button. */
|
|
284
|
+
function providerButton(create: CompositeNodeFactory, provider: SignInProvider, label: string): CompositeNode {
|
|
285
|
+
const name = signInProviderName(provider);
|
|
286
|
+
const button = recipeButton(create, `sign-in-${provider}`, PROVIDER_ROLES[provider], Style.Secondary, `Continue with ${name}`, '', { ...FULL, gap: '8px' });
|
|
287
|
+
button.children = [
|
|
288
|
+
recipePart(create, `sign-in-${provider}-mark`, 'Image', null, null, { src: signInProviderMarkUri(provider), alt: '' }, `${name} mark`,
|
|
289
|
+
{ width: '18px', height: '18px', minHeight: 'auto', flexShrink: '0' }),
|
|
290
|
+
words(create, `sign-in-${provider}-label`, null, Style.Label, label, 'Text', WORDS, 'span'),
|
|
291
|
+
];
|
|
292
|
+
return button;
|
|
293
|
+
}
|
|
294
|
+
|
|
267
295
|
/** The account recipes, by name. */
|
|
268
296
|
export enum AccountRecipe {
|
|
269
297
|
Entry = 'accountEntry',
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { SignInProvider } from './sign-in';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* How each provider's button presents it — ONE copy for every IOX sign-in (the site's dialog, the admin login, the
|
|
5
|
+
* portal). Each brand's button guidelines: its own name, never translated ("Continue with GitHub" / "המשך עם GitHub"),
|
|
6
|
+
* and its official mark in its own colours, unaltered — Google's four-colour G, LinkedIn's "in" on its blue, Facebook's
|
|
7
|
+
* white f on its blue circle; GitHub's mark is single-colour by its rules, so it takes the button's ink (`currentColor`).
|
|
8
|
+
*/
|
|
9
|
+
export interface SignInProviderBrand {
|
|
10
|
+
/** The brand's name, as the brand writes it. */
|
|
11
|
+
readonly name: string;
|
|
12
|
+
/** The mark as one inline SVG (a square `viewBox`, no size — the button sizes it). */
|
|
13
|
+
readonly mark: string;
|
|
14
|
+
/** The mark for an `<img>`, where `currentColor` means nothing — when it differs from `mark`. */
|
|
15
|
+
readonly imageMark?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const SVG = (viewBox: string, body: string) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}" aria-hidden="true" focusable="false">${body}</svg>`;
|
|
19
|
+
|
|
20
|
+
const GITHUB_PATH = 'M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z';
|
|
21
|
+
|
|
22
|
+
export const SIGN_IN_PROVIDER_BRANDS: Readonly<Record<SignInProvider, SignInProviderBrand>> = Object.freeze({
|
|
23
|
+
[SignInProvider.Google]: {
|
|
24
|
+
name: 'Google',
|
|
25
|
+
mark: SVG('0 0 48 48',
|
|
26
|
+
'<path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/>'
|
|
27
|
+
+ '<path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/>'
|
|
28
|
+
+ '<path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/>'
|
|
29
|
+
+ '<path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/>'),
|
|
30
|
+
},
|
|
31
|
+
[SignInProvider.Facebook]: {
|
|
32
|
+
name: 'Facebook',
|
|
33
|
+
mark: SVG('0 0 24 24',
|
|
34
|
+
'<circle cx="12" cy="12" r="12" fill="#0866FF"/>'
|
|
35
|
+
+ '<path fill="#FFFFFF" d="M16.671 15.469 17.203 12h-3.328V9.749c0-.949.465-1.874 1.956-1.874h1.513V4.922s-1.374-.234-2.686-.234c-2.741 0-4.533 1.66-4.533 4.668V12H7.078v3.469h3.047v8.385a12.09 12.09 0 0 0 3.75 0v-8.385h2.796Z"/>'),
|
|
36
|
+
},
|
|
37
|
+
[SignInProvider.GitHub]: {
|
|
38
|
+
name: 'GitHub',
|
|
39
|
+
mark: SVG('0 0 16 16', `<path fill="currentColor" d="${GITHUB_PATH}"/>`),
|
|
40
|
+
// Black or white only (GitHub's rule): the black mark on its own white disc reads on any button.
|
|
41
|
+
imageMark: SVG('0 0 16 16', `<circle cx="8" cy="8" r="7.5" fill="#FFFFFF"/><path fill="#1F2328" d="${GITHUB_PATH}"/>`),
|
|
42
|
+
},
|
|
43
|
+
[SignInProvider.LinkedIn]: {
|
|
44
|
+
name: 'LinkedIn',
|
|
45
|
+
mark: SVG('0 0 24 24',
|
|
46
|
+
'<rect width="24" height="24" rx="3" fill="#0A66C2"/>'
|
|
47
|
+
+ '<path fill="#FFFFFF" d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 1 1 0-4.125 2.062 2.062 0 0 1 0 4.125zm1.782 13.019H3.555V9h3.564v11.452z"/>'),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The provider's name as its brand writes it. */
|
|
52
|
+
export function signInProviderName(provider: SignInProvider | null | undefined): string {
|
|
53
|
+
return (provider && SIGN_IN_PROVIDER_BRANDS[provider]?.name) || '';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The mark as a `data:` address — for an `<img>` (a builder Image part, an admin button). */
|
|
57
|
+
export function signInProviderMarkUri(provider: SignInProvider): string {
|
|
58
|
+
const brand = SIGN_IN_PROVIDER_BRANDS[provider];
|
|
59
|
+
return `data:image/svg+xml,${encodeURIComponent(brand.imageMark ?? brand.mark)}`;
|
|
60
|
+
}
|