@curless/hotel-storefront 0.60.1 → 0.61.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/account/index.d.ts +9 -2
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +120 -64
- package/dist/account/index.js.map +1 -1
- package/dist/account/pages.d.ts +26 -9
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +108 -51
- package/dist/account/pages.js.map +1 -1
- package/dist/card.generated.d.ts +1 -1
- package/dist/card.generated.js +2 -2
- package/dist/card.generated.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +14 -2
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/account/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export type AccountToolNames = ReturnType<typeof accountToolNames>;
|
|
|
49
49
|
export declare const ACCOUNT_META_KEY = "curless/account";
|
|
50
50
|
/** Beside a sign-in's answer where a card is drawn: the link and its short code, the card's alone. */
|
|
51
51
|
export declare const SIGN_IN_META_KEY = "curless/account-sign-in";
|
|
52
|
-
/** …and beside a membership link's answer (0.58.0): the
|
|
52
|
+
/** …and beside a membership link's answer (0.58.0): the link and its group - no code (0.61.0). */
|
|
53
53
|
export declare const LINK_META_KEY = "curless/account-link";
|
|
54
54
|
/** The mall is asked at most this often whether a sign-in is still theirs. */
|
|
55
55
|
export declare const CHECK_EVERY_MS: number;
|
|
@@ -104,7 +104,9 @@ export type Account = {
|
|
|
104
104
|
/**
|
|
105
105
|
* What every answer carries for the card's header. `cards`: the session said
|
|
106
106
|
* it draws cards; `ours`: the call acted on its own conversation, naming no
|
|
107
|
-
* trip or its own.
|
|
107
|
+
* trip or its own. The name (nickname, else user name) is in it either way
|
|
108
|
+
* (0.61.0); the masked facts and the hotel memberships only where `cards`, and
|
|
109
|
+
* a membership's masked number only with both.
|
|
108
110
|
*/
|
|
109
111
|
meta: (key: string, who: {
|
|
110
112
|
cards: boolean;
|
|
@@ -134,6 +136,11 @@ export type AccountOptions = {
|
|
|
134
136
|
now?: () => number;
|
|
135
137
|
logoUrl?: string;
|
|
136
138
|
logoDarkUrl?: string;
|
|
139
|
+
/**
|
|
140
|
+
* A hotel group's logo, by its code - the address the hotel list uses
|
|
141
|
+
* (`/suppliers/<code>/logo.png?v=…`, server.ts), or none: its initials (0.61.0).
|
|
142
|
+
*/
|
|
143
|
+
groupLogo?: (code: string) => string | undefined;
|
|
137
144
|
operator?: string;
|
|
138
145
|
log?: (line: string) => void;
|
|
139
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/account/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AA4B1C,OAAO,EAEL,KAAK,IAAI,EAMV,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/account/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AA4B1C,OAAO,EAEL,KAAK,IAAI,EAMV,MAAM,eAAe,CAAC;AAmDvB,MAAM,MAAM,aAAa,GAAG;IAC1B,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iGAAiG;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAA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O;IAN1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA+B;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;gBAG/B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,MAAM,EACjB,OAAO,SAAS;IAGnC,OAAO,CAAC,MAAM;IAKd,8FAA8F;IAC9F,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAIvC,uEAAuE;IACvE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAMxC,wGAAwG;IACxG,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI;CAyB/D;AAED,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,QAAc,CAAC;AAkC5C,eAAO,MAAM,WAAW,GAAI,MAAM,cAAc,KAAG,OAkiDlD,CAAC"}
|
package/dist/account/index.js
CHANGED
|
@@ -30,7 +30,7 @@ export const accountToolNames = (prefix) => ({
|
|
|
30
30
|
export const ACCOUNT_META_KEY = 'curless/account';
|
|
31
31
|
/** Beside a sign-in's answer where a card is drawn: the link and its short code, the card's alone. */
|
|
32
32
|
export const SIGN_IN_META_KEY = 'curless/account-sign-in';
|
|
33
|
-
/** …and beside a membership link's answer (0.58.0): the
|
|
33
|
+
/** …and beside a membership link's answer (0.58.0): the link and its group - no code (0.61.0). */
|
|
34
34
|
export const LINK_META_KEY = 'curless/account-link';
|
|
35
35
|
/** The mall is asked at most this often whether a sign-in is still theirs. */
|
|
36
36
|
export const CHECK_EVERY_MS = 5 * 60_000;
|
|
@@ -327,6 +327,30 @@ export const makeAccount = (opts) => {
|
|
|
327
327
|
const groupName = (m) => m.name || m.code;
|
|
328
328
|
/** The group's name in a page's language - its Chinese one on a Chinese page, where it has one. */
|
|
329
329
|
const groupIn = (m, lang) => lang === 'zh' && m.names?.zh ? m.names.zh : groupName(m);
|
|
330
|
+
/**
|
|
331
|
+
* The group as the words say it (0.61.0): where no card is drawn, its Chinese
|
|
332
|
+
* name beside - 「Atour(亚朵)」, as tools.ts `withZh` says a hotel - so the
|
|
333
|
+
* assistant tells a Chinese guest the name they know it by. A card host's words
|
|
334
|
+
* say the plain name: its card says the Chinese.
|
|
335
|
+
*/
|
|
336
|
+
const groupSaid = (m, noCards) => {
|
|
337
|
+
const plain = groupName(m);
|
|
338
|
+
const zh = noCards ? m.names?.zh : undefined;
|
|
339
|
+
return zh && zh !== plain && !/\p{Script=Han}/u.test(plain) ? `${plain}(${zh})` : plain;
|
|
340
|
+
};
|
|
341
|
+
/** A group's logo for a page: our own path - the page's CSP takes 'self' alone. */
|
|
342
|
+
const logoPath = (code) => {
|
|
343
|
+
const url = opts.groupLogo?.(code);
|
|
344
|
+
if (!url)
|
|
345
|
+
return undefined;
|
|
346
|
+
try {
|
|
347
|
+
const u = new URL(url);
|
|
348
|
+
return u.origin === new URL(opts.publicUrl).origin ? u.pathname + u.search : undefined;
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
330
354
|
const ota = makeOtaMembers({
|
|
331
355
|
baseUrl,
|
|
332
356
|
tenant,
|
|
@@ -373,10 +397,13 @@ export const makeAccount = (opts) => {
|
|
|
373
397
|
*/
|
|
374
398
|
const membershipRows = (s, forCard, withNumber = forCard) => memberships.map((m) => {
|
|
375
399
|
const l = s ? liveLink(s, m.code) : undefined;
|
|
400
|
+
// The group's logo, for the card (0.61.0) - the hotel list's address; none, its initials.
|
|
401
|
+
const logoUrl = forCard ? opts.groupLogo?.(m.code) : undefined;
|
|
376
402
|
return {
|
|
377
403
|
group: m.code,
|
|
378
404
|
name: groupName(m),
|
|
379
405
|
...(m.names?.zh ? { names: { zh: m.names.zh } } : {}),
|
|
406
|
+
...(logoUrl ? { logoUrl } : {}),
|
|
380
407
|
linked: !!l,
|
|
381
408
|
// The label has the number in it, hidden but for its ends (`maskLabel`):
|
|
382
409
|
// the model is given the tier alone (总线程 11-09: not even hidden).
|
|
@@ -389,16 +416,20 @@ export const makeAccount = (opts) => {
|
|
|
389
416
|
join: m.join === true,
|
|
390
417
|
};
|
|
391
418
|
});
|
|
392
|
-
const membershipsSaid = (s) => {
|
|
419
|
+
const membershipsSaid = (s, noCards) => {
|
|
393
420
|
if (!linking)
|
|
394
421
|
return '';
|
|
395
422
|
const rows = membershipRows(s, false);
|
|
396
423
|
const linked = rows.filter((r) => r.linked);
|
|
424
|
+
const said = (code) => {
|
|
425
|
+
const m = groupOf(code);
|
|
426
|
+
return m ? groupSaid(m, noCards) : code;
|
|
427
|
+
};
|
|
397
428
|
return `Hotel memberships linked to this account: ${linked.length
|
|
398
|
-
? linked.map((r) => `${r.
|
|
429
|
+
? linked.map((r) => `${said(r.group)}${r.label ? ` · ${r.label}` : ''}`).join('; ')
|
|
399
430
|
: 'none'}. Can be linked: ${rows
|
|
400
431
|
.filter((r) => !r.linked)
|
|
401
|
-
.map((r) => `${r.
|
|
432
|
+
.map((r) => `${said(r.group)} (\`${r.group}\`)`)
|
|
402
433
|
.join(', ') || 'none more'} - ${names.link} gives the guest a one-time page for it.`;
|
|
403
434
|
};
|
|
404
435
|
// ── Signing in and out ───────────────────────────────────────────────────
|
|
@@ -521,15 +552,18 @@ export const makeAccount = (opts) => {
|
|
|
521
552
|
const NEVER_IN_CHAT = 'never in this chat: do not ask for, or accept, a password, an email or a phone number here, and never write back one the guest typed - not even to say which to change';
|
|
522
553
|
const minutes = Math.round(requests.ttlMs / 60_000);
|
|
523
554
|
const accountUrl = `${publicUrl}/account`;
|
|
524
|
-
// ⚠️ THE NAME THE ACCOUNT GOES BY
|
|
525
|
-
//
|
|
526
|
-
//
|
|
527
|
-
// the
|
|
528
|
-
//
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const
|
|
532
|
-
|
|
555
|
+
// ⚠️ THE NAME THE ACCOUNT GOES BY: ITS NICKNAME, ELSE ITS USER NAME (0.61.0,
|
|
556
|
+
// robin 11-10: 「没昵称是不是应该和网页一样显示用户名」; 总线程 weighed it: the user
|
|
557
|
+
// name stands with the nickname - a trip id lives in its conversation alone,
|
|
558
|
+
// and the per-name limit on wrong tries still holds). The same name on the
|
|
559
|
+
// card, on the page, in the words and in the structured answer. The real name,
|
|
560
|
+
// the email and the phone are never in the words: the email and phone go to a
|
|
561
|
+
// card, masked, in `_meta` (`meta`), and are on the account page.
|
|
562
|
+
const nameOf = (s) => s.shown.displayName || s.shown.userName || '';
|
|
563
|
+
const shownFor = (s) => (nameOf(s) ? { displayName: nameOf(s) } : {});
|
|
564
|
+
const whoSaid = (s) => nameOf(s) ? `the ${brand} account of ${nameOf(s)}` : `${aBrand} account`;
|
|
565
|
+
const signedInAnswer = (s, lead, noCards) => ({
|
|
566
|
+
text: `${lead} Signed in to ${whoSaid(s)}. ${linking ? '' : `${NO_PRICE} `}The guest sees the whole account - its user name, and its email and phone partly hidden - on ${brand}'s account page, ${accountUrl}, in the browser they signed in with, for ${WEB_IDLE_MS / 60_000} minutes after. ${names.signOut} signs them out.${linking ? ` ${membershipsSaid(s, noCards)}` : ''}`.trim(),
|
|
533
567
|
structured: {
|
|
534
568
|
view: 'account',
|
|
535
569
|
brand,
|
|
@@ -549,17 +583,18 @@ export const makeAccount = (opts) => {
|
|
|
549
583
|
const linkAnswer = async (args, call) => {
|
|
550
584
|
const { key, noCards } = call;
|
|
551
585
|
const m = groupOf(args.group);
|
|
552
|
-
const listed = memberships.map((x) => `\`${x.code}\` (${
|
|
586
|
+
const listed = memberships.map((x) => `\`${x.code}\` (${groupSaid(x, noCards)})`).join(', ');
|
|
553
587
|
if (!m)
|
|
554
588
|
return {
|
|
555
589
|
text: `No such hotel group to link here. The ones that can be linked: ${listed}.`,
|
|
556
590
|
structured: { view: 'error', brand, code: 'no_such_group' },
|
|
557
591
|
isError: true,
|
|
558
592
|
};
|
|
593
|
+
const g = groupSaid(m, noCards);
|
|
559
594
|
const s = await checked(key);
|
|
560
595
|
if (!s)
|
|
561
596
|
return {
|
|
562
|
-
text: `Linking a ${
|
|
597
|
+
text: `Linking a ${g} membership needs the guest signed in to ${aBrand} account first: ${names.signIn} gives them a one-time page for that. ${NEVER_IN_CHAT[0]?.toUpperCase()}${NEVER_IN_CHAT.slice(1)}.`,
|
|
563
598
|
structured: { view: 'account', brand, signedIn: false, code: 'not_signed_in' },
|
|
564
599
|
};
|
|
565
600
|
const mode = args.mode === 'unlink' ? 'unlink' : args.mode === 'join' ? 'up' : 'in';
|
|
@@ -568,20 +603,20 @@ export const makeAccount = (opts) => {
|
|
|
568
603
|
if (was)
|
|
569
604
|
log(`[account] ${tag(key)} unlinked a membership`);
|
|
570
605
|
return {
|
|
571
|
-
...signedInAnswer(s, ''),
|
|
606
|
+
...signedInAnswer(s, '', noCards),
|
|
572
607
|
text: was
|
|
573
|
-
? `The ${
|
|
574
|
-
: `No ${
|
|
608
|
+
? `The ${g} membership is unlinked from this ${brand} account: its prices here are the standard ones again.`
|
|
609
|
+
: `No ${g} membership was linked, so nothing changed.`,
|
|
575
610
|
};
|
|
576
611
|
}
|
|
577
612
|
if (liveLink(s, m.code))
|
|
578
613
|
return {
|
|
579
|
-
...signedInAnswer(s, ''),
|
|
580
|
-
text: `A ${
|
|
614
|
+
...signedInAnswer(s, '', noCards),
|
|
615
|
+
text: `A ${g} membership is already linked to this ${brand} account. To use another, unlink it first.`,
|
|
581
616
|
};
|
|
582
617
|
if ((mode === 'up' && m.join !== true) || (mode === 'in' && m.signIn === false))
|
|
583
618
|
return {
|
|
584
|
-
text: `A ${
|
|
619
|
+
text: `A ${g} membership cannot be ${mode === 'up' ? 'made' : 'linked'} here.`,
|
|
585
620
|
structured: { view: 'error', brand, code: 'not_offered' },
|
|
586
621
|
isError: true,
|
|
587
622
|
};
|
|
@@ -622,25 +657,24 @@ export const makeAccount = (opts) => {
|
|
|
622
657
|
const url = `${publicUrl}/login?code=${made.code}${mode === 'up' ? '&view=register' : ''}`;
|
|
623
658
|
const expiresAt = new Date(made.expiresAt).toISOString();
|
|
624
659
|
log(`[account] a membership link for ${tag(key)}${noCards ? ' in words' : ''}`);
|
|
625
|
-
const what = mode === 'up'
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
const
|
|
660
|
+
const what = mode === 'up' ? `join ${g} and link the new membership` : `link their ${g} membership`;
|
|
661
|
+
const typed = `the ${g} email (or user name) and password are typed on that page, never in this chat: do not ask for, or accept, them here, and never write back one the guest typed`;
|
|
662
|
+
// ⚠️ NO CODE (0.61.0) - see the top of this file: the page is the account's own browser's.
|
|
663
|
+
const where = `The page opens only in the browser they signed in to ${brand} with; anywhere else it first asks them to sign in to that same ${brand} account again.`;
|
|
629
664
|
if (noCards)
|
|
630
665
|
return {
|
|
631
|
-
text: `A one-time page is ready for the guest to ${what} to their ${brand} account: ${url} - ${typed}.
|
|
666
|
+
text: `A one-time page is ready for the guest to ${what} to their ${brand} account: ${url} - ${typed}. ${where} The link works once, for ${minutes} minutes. When they say they are done, ${names.view} shows what is linked.`,
|
|
632
667
|
structured: {
|
|
633
668
|
view: 'account-link',
|
|
634
669
|
brand,
|
|
635
670
|
group: m.code,
|
|
636
671
|
url,
|
|
637
|
-
shortCode: made.short,
|
|
638
672
|
expiresAt,
|
|
639
673
|
expiresInSeconds: Math.round(linkRequests.ttlMs / 1000),
|
|
640
674
|
},
|
|
641
675
|
};
|
|
642
676
|
return {
|
|
643
|
-
text: `A one-time page is ready for the guest to ${what} to their ${brand} account, opened from the card: ${typed}. The
|
|
677
|
+
text: `A one-time page is ready for the guest to ${what} to their ${brand} account, opened from the card: ${typed}. ${where} The link works once, for ${minutes} minutes.`,
|
|
644
678
|
structured: {
|
|
645
679
|
view: 'account-link',
|
|
646
680
|
brand,
|
|
@@ -648,7 +682,7 @@ export const makeAccount = (opts) => {
|
|
|
648
682
|
expiresAt,
|
|
649
683
|
expiresInSeconds: Math.round(linkRequests.ttlMs / 1000),
|
|
650
684
|
},
|
|
651
|
-
meta: { [LINK_META_KEY]: { url,
|
|
685
|
+
meta: { [LINK_META_KEY]: { url, expiresAt, group: m.code } },
|
|
652
686
|
};
|
|
653
687
|
};
|
|
654
688
|
const handle = async (name, args, call) => {
|
|
@@ -675,7 +709,7 @@ export const makeAccount = (opts) => {
|
|
|
675
709
|
if (name === names.view) {
|
|
676
710
|
const s = await checked(key);
|
|
677
711
|
if (s)
|
|
678
|
-
return signedInAnswer(s, '');
|
|
712
|
+
return signedInAnswer(s, '', noCards);
|
|
679
713
|
const waiting = requests.openFor(key);
|
|
680
714
|
// ⚠️ THE ASSISTANT, WHERE A CARD IS DRAWN, IS NOT TOLD "NOBODY" (0.56.1,
|
|
681
715
|
// robin 11-06): claude.ai sent one conversation's calls by several
|
|
@@ -724,7 +758,7 @@ export const makeAccount = (opts) => {
|
|
|
724
758
|
const s = await checked(key);
|
|
725
759
|
if (s)
|
|
726
760
|
return {
|
|
727
|
-
...signedInAnswer(s, ''),
|
|
761
|
+
...signedInAnswer(s, '', noCards),
|
|
728
762
|
text: `Already signed in to ${whoSaid(s)}: there is nothing to open. To use another account, ${names.signOut} first. ${NO_PRICE}`,
|
|
729
763
|
};
|
|
730
764
|
if (counters.links.count(key) >= ACCOUNT_LIMITS.linksPerConversation) {
|
|
@@ -825,7 +859,7 @@ export const makeAccount = (opts) => {
|
|
|
825
859
|
name: names.view,
|
|
826
860
|
// ⚠️ ONLY WHEN ASKED (robin 11-06, claude.ai): the assistant called it on its
|
|
827
861
|
// own 40 ms after a list, and ended its list with "I can't see your sign-in".
|
|
828
|
-
description: `Whether the guest is signed in to their ${brand} account in this conversation, and the name the account goes by - only when the guest asks about their account or whether they are signed in; never on your own, and not alongside a search. Its
|
|
862
|
+
description: `Whether the guest is signed in to their ${brand} account in this conversation, and the name the account goes by (its nickname, or its user name where it has none) - only when the guest asks about their account or whether they are signed in; never on your own, and not alongside a search. Its contact details are not given: they are on ${brand}'s account page.`,
|
|
829
863
|
annotations: {
|
|
830
864
|
title: `My ${brand} account`,
|
|
831
865
|
readOnlyHint: true,
|
|
@@ -853,7 +887,7 @@ export const makeAccount = (opts) => {
|
|
|
853
887
|
name: names.link,
|
|
854
888
|
// ⚠️ NOTHING ABOUT THE GUEST IS ASKED FOR HERE - the group's email and
|
|
855
889
|
// password are typed on our page, never in the chat.
|
|
856
|
-
description: `Links one hotel group's loyalty membership to the guest's ${brand} account - or joins that group and links the new membership, or unlinks it - on ${brand}'s own web page: answers with a one-time link
|
|
890
|
+
description: `Links one hotel group's loyalty membership to the guest's ${brand} account - or joins that group and links the new membership, or unlinks it - on ${brand}'s own web page: answers with a one-time link, which opens in the browser the guest signed in to ${brand} with. Needs the guest signed in to ${brand}. Takes no personal details. Groups: ${memberships.map((m) => `\`${m.code}\` (${groupName(m)})`).join(', ')}.`,
|
|
857
891
|
annotations: {
|
|
858
892
|
title: 'Link a hotel membership',
|
|
859
893
|
readOnlyHint: false,
|
|
@@ -947,7 +981,6 @@ export const makeAccount = (opts) => {
|
|
|
947
981
|
group: STR,
|
|
948
982
|
signedIn: { type: 'boolean' },
|
|
949
983
|
url: STR,
|
|
950
|
-
shortCode: STR,
|
|
951
984
|
expiresAt: STR,
|
|
952
985
|
expiresInSeconds: { type: 'number' },
|
|
953
986
|
account: { type: 'object' },
|
|
@@ -1082,6 +1115,10 @@ export const makeAccount = (opts) => {
|
|
|
1082
1115
|
// here. A link opened anywhere else - forwarded, or made by someone holding
|
|
1083
1116
|
// the conversation's trip id - links nothing: a membership could otherwise
|
|
1084
1117
|
// be put on somebody else's account, or somebody else's taken onto ours.
|
|
1118
|
+
// That is the whole of its guard: the pages show no code to compare (0.61.0,
|
|
1119
|
+
// 总线程 11-10) - another account's cookie is asked to sign in again
|
|
1120
|
+
// (`ownerOf` wants the same conversation AND the same sign-in), and signing in
|
|
1121
|
+
// again as another account is refused (`reauth_other`).
|
|
1085
1122
|
const linkState = (r) => {
|
|
1086
1123
|
const st = linkRequests.state(r, false);
|
|
1087
1124
|
if (st !== 'open')
|
|
@@ -1095,18 +1132,17 @@ export const makeAccount = (opts) => {
|
|
|
1095
1132
|
? { id: at.id, s: at.s }
|
|
1096
1133
|
: null;
|
|
1097
1134
|
};
|
|
1098
|
-
const accountNameOf = (s) => s.shown.displayName || s.shown.userName || '';
|
|
1099
1135
|
const groupPage = (c, code, r, s, lang, mode, error, values) => {
|
|
1100
1136
|
const m = groupOf(r.link?.group);
|
|
1101
1137
|
return send(c, 200, linkGroupPage(brandPage, {
|
|
1102
1138
|
lang,
|
|
1103
|
-
short: r.short,
|
|
1104
1139
|
code,
|
|
1105
1140
|
csrf: linkCsrf(r),
|
|
1106
|
-
|
|
1107
|
-
//
|
|
1141
|
+
// The group as the page's reader knows it: 「亚朵」 on a Chinese page (0.60.1),
|
|
1142
|
+
// over its logo (0.61.0).
|
|
1108
1143
|
group: m ? groupIn(m, lang) : String(r.link?.group),
|
|
1109
|
-
|
|
1144
|
+
...(m && logoPath(m.code) ? { logo: logoPath(m.code) } : {}),
|
|
1145
|
+
accountName: nameOf(s),
|
|
1110
1146
|
mode: mode === 'up' && m?.join === true ? 'up' : 'in',
|
|
1111
1147
|
...(error ? { error: say(lang, error, m ? groupIn(m, lang) : brand) } : {}),
|
|
1112
1148
|
...(values ? { values } : {}),
|
|
@@ -1116,11 +1152,10 @@ export const makeAccount = (opts) => {
|
|
|
1116
1152
|
const m = groupOf(r.link?.group);
|
|
1117
1153
|
return send(c, 200, linkReauthPage(brandPage, {
|
|
1118
1154
|
lang,
|
|
1119
|
-
short: r.short,
|
|
1120
1155
|
code,
|
|
1121
1156
|
csrf: linkCsrf(r),
|
|
1122
|
-
|
|
1123
|
-
|
|
1157
|
+
group: m ? groupIn(m, lang) : String(r.link?.group),
|
|
1158
|
+
...(m && logoPath(m.code) ? { logo: logoPath(m.code) } : {}),
|
|
1124
1159
|
...(error ? { error: say(lang, error, brand) } : {}),
|
|
1125
1160
|
}));
|
|
1126
1161
|
};
|
|
@@ -1310,7 +1345,7 @@ export const makeAccount = (opts) => {
|
|
|
1310
1345
|
log(`[account] ${tag(r.key)} linked a ${m.code} membership${up ? ' it made' : ''}`);
|
|
1311
1346
|
return send(c, 200, linkedPage(brandPage, {
|
|
1312
1347
|
lang,
|
|
1313
|
-
group:
|
|
1348
|
+
group: groupIn(m, lang),
|
|
1314
1349
|
...(link.label ? { label: link.label } : {}),
|
|
1315
1350
|
}));
|
|
1316
1351
|
}
|
|
@@ -1498,7 +1533,7 @@ export const makeAccount = (opts) => {
|
|
|
1498
1533
|
log(`[account] ${up ? 'an account was made and signed in' : 'signed in'} for ${tag(r.key)}`);
|
|
1499
1534
|
return send(c, 200, signedInPage(brandPage, {
|
|
1500
1535
|
lang,
|
|
1501
|
-
name: s
|
|
1536
|
+
name: nameOf(s),
|
|
1502
1537
|
account: !!id,
|
|
1503
1538
|
}));
|
|
1504
1539
|
});
|
|
@@ -1518,7 +1553,25 @@ export const makeAccount = (opts) => {
|
|
|
1518
1553
|
lang,
|
|
1519
1554
|
shown: at.s.shown,
|
|
1520
1555
|
csrf: at.ws.csrf,
|
|
1521
|
-
|
|
1556
|
+
// The card's rows, in the page's language and with each group's logo (0.61.0).
|
|
1557
|
+
...(linking
|
|
1558
|
+
? {
|
|
1559
|
+
memberships: membershipRows(at.s, true).map((row) => {
|
|
1560
|
+
const m = groupOf(row.group);
|
|
1561
|
+
const logo = logoPath(row.group);
|
|
1562
|
+
return {
|
|
1563
|
+
group: row.group,
|
|
1564
|
+
name: m ? groupIn(m, lang) : row.name,
|
|
1565
|
+
...(logo ? { logo } : {}),
|
|
1566
|
+
linked: row.linked,
|
|
1567
|
+
...(row.label ? { label: row.label } : {}),
|
|
1568
|
+
...(row.numberMasked ? { numberMasked: row.numberMasked } : {}),
|
|
1569
|
+
signIn: row.signIn,
|
|
1570
|
+
join: row.join,
|
|
1571
|
+
};
|
|
1572
|
+
}),
|
|
1573
|
+
}
|
|
1574
|
+
: {}),
|
|
1522
1575
|
}));
|
|
1523
1576
|
});
|
|
1524
1577
|
app.post('/account', form, async (c) => {
|
|
@@ -1587,25 +1640,27 @@ export const makeAccount = (opts) => {
|
|
|
1587
1640
|
handle,
|
|
1588
1641
|
meta: (key, { cards, ours }) => {
|
|
1589
1642
|
const s = store.get(key);
|
|
1590
|
-
// ⚠️ THE
|
|
1591
|
-
//
|
|
1592
|
-
//
|
|
1593
|
-
//
|
|
1594
|
-
//
|
|
1595
|
-
//
|
|
1596
|
-
//
|
|
1597
|
-
|
|
1598
|
-
//
|
|
1599
|
-
//
|
|
1600
|
-
//
|
|
1601
|
-
//
|
|
1602
|
-
//
|
|
1603
|
-
//
|
|
1604
|
-
const
|
|
1605
|
-
?
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
: s.shown.
|
|
1643
|
+
// ⚠️ THE NAME IT GOES BY - THE NICKNAME, ELSE THE USER NAME - TO EVERY CALL
|
|
1644
|
+
// (0.61.0, robin 11-10; 总线程 weighed it): the words say the same name (`nameOf`),
|
|
1645
|
+
// and the card in claude.ai, whose calls name the conversation's trip (ours=false),
|
|
1646
|
+
// showed 「已登录」 for want of it. Before, a call naming a trip had the nickname at
|
|
1647
|
+
// most (0.59.0, review C2: the user name, with the per-name limit, could lock the
|
|
1648
|
+
// member out); 总线程 11-10: a trip id lives in its conversation alone, the user
|
|
1649
|
+
// name stands with the nickname, and the per-name limit still holds.
|
|
1650
|
+
const name = s ? nameOf(s) || undefined : undefined;
|
|
1651
|
+
// ⚠️ THE ACCOUNT'S FACTS, FOR A CARD ALONE (0.61.0, robin 11-10: the card's account
|
|
1652
|
+
// view is the web page's): the user name, and the email and phone MASKED as the page
|
|
1653
|
+
// masks them (store.ts `shownOf`) - never whole, never the real name, never in the
|
|
1654
|
+
// words. Only to a session that draws cards: `_meta` may reach the model of one
|
|
1655
|
+
// that does not. Whichever conversation the call names, as the hotel memberships'
|
|
1656
|
+
// rows are - in claude.ai the card's calls all name the trip.
|
|
1657
|
+
const facts = s && cards
|
|
1658
|
+
? {
|
|
1659
|
+
...(s.shown.userName ? { userName: s.shown.userName } : {}),
|
|
1660
|
+
...(s.shown.email ? { email: s.shown.email } : {}),
|
|
1661
|
+
...(s.shown.mobile ? { mobile: s.shown.mobile } : {}),
|
|
1662
|
+
}
|
|
1663
|
+
: undefined;
|
|
1609
1664
|
return {
|
|
1610
1665
|
[ACCOUNT_META_KEY]: {
|
|
1611
1666
|
from: opts.from,
|
|
@@ -1615,6 +1670,7 @@ export const makeAccount = (opts) => {
|
|
|
1615
1670
|
: { signIn: names.signIn, view: names.view, signOut: names.signOut, card: names.card },
|
|
1616
1671
|
signedIn: !!s,
|
|
1617
1672
|
...(name !== undefined ? { name } : {}),
|
|
1673
|
+
...(facts && Object.keys(facts).length ? { facts } : {}),
|
|
1618
1674
|
// The hotel memberships, one row a group: to a session that draws cards,
|
|
1619
1675
|
// whichever conversation the call names (0.59.1, 总线程 11-09). In claude.ai
|
|
1620
1676
|
// the card's own calls name the conversation's trip (`ours` is false) and
|