@curless/hotel-storefront 0.60.0 → 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 +163 -74
- package/dist/account/index.js.map +1 -1
- package/dist/account/pages.d.ts +28 -10
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +115 -53
- 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;
|
|
@@ -230,6 +230,24 @@ const otaNotThere = (e) => e instanceof OtaMemberError &&
|
|
|
230
230
|
(e.code === 'timeout' ||
|
|
231
231
|
e.code === 'unreachable' ||
|
|
232
232
|
(typeof e.code === 'number' && e.code >= 500 && !e.envelope));
|
|
233
|
+
/**
|
|
234
|
+
* The backend answered and said no to the credentials (0.59.1, robin 11-09,
|
|
235
|
+
* questions #49): an HTTP 4xx, or its envelope's own no (`code: 500` in an HTTP
|
|
236
|
+
* 200 is its "wrong", as the mall's). The only answers that are the guest's
|
|
237
|
+
* mistake for certain - the only ones the page says "the password" for. A
|
|
238
|
+
* `form`, `not_signed_in`, `wrong_group` or `not_json` is the backend not
|
|
239
|
+
* confirming (the dev backend answers a form for a good password): the page
|
|
240
|
+
* does not blame the password.
|
|
241
|
+
*
|
|
242
|
+
* ⚠️ BUT EVERY ANSWER THAT IS NOT A SIGN-IN COUNTS AGAINST THE NAME (总线程's
|
|
243
|
+
* review of 0.60.1): a backend may well say "wrong password" with a form one
|
|
244
|
+
* day - Spark's shops answer a form to everything now - and an uncounted form
|
|
245
|
+
* would make this page a way to guess a group member's password, eight at a
|
|
246
|
+
* time no more. Only no answer at all (`otaNotThere`) is not counted.
|
|
247
|
+
*/
|
|
248
|
+
const otaWrong = (e) => e instanceof OtaMemberError &&
|
|
249
|
+
typeof e.code === 'number' &&
|
|
250
|
+
((e.code >= 400 && e.code < 500) || e.envelope);
|
|
233
251
|
/** The mall did not answer - not a no. */
|
|
234
252
|
const notThere = (e) => e instanceof MallError &&
|
|
235
253
|
(e.code === 'timeout' ||
|
|
@@ -307,6 +325,32 @@ export const makeAccount = (opts) => {
|
|
|
307
325
|
? memberships.find((m) => m.code.toLowerCase() === code.trim().toLowerCase())
|
|
308
326
|
: undefined;
|
|
309
327
|
const groupName = (m) => m.name || m.code;
|
|
328
|
+
/** The group's name in a page's language - its Chinese one on a Chinese page, where it has one. */
|
|
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
|
+
};
|
|
310
354
|
const ota = makeOtaMembers({
|
|
311
355
|
baseUrl,
|
|
312
356
|
tenant,
|
|
@@ -344,34 +388,48 @@ export const makeAccount = (opts) => {
|
|
|
344
388
|
.filter((w) => !w.includes('••'))
|
|
345
389
|
.join(' ')
|
|
346
390
|
.trim();
|
|
347
|
-
|
|
391
|
+
/**
|
|
392
|
+
* One row a group. `forCard`: for a card or the page; `withNumber` (card and
|
|
393
|
+
* page only): the label as the group wrote it, its number hidden but for its
|
|
394
|
+
* ends, and that number alone as `numberMasked`. Without it the row is the
|
|
395
|
+
* tier alone - what the model is given, and what a card is given by a call
|
|
396
|
+
* that is not its own conversation's.
|
|
397
|
+
*/
|
|
398
|
+
const membershipRows = (s, forCard, withNumber = forCard) => memberships.map((m) => {
|
|
348
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;
|
|
349
402
|
return {
|
|
350
403
|
group: m.code,
|
|
351
404
|
name: groupName(m),
|
|
352
405
|
...(m.names?.zh ? { names: { zh: m.names.zh } } : {}),
|
|
406
|
+
...(logoUrl ? { logoUrl } : {}),
|
|
353
407
|
linked: !!l,
|
|
354
408
|
// The label has the number in it, hidden but for its ends (`maskLabel`):
|
|
355
409
|
// the model is given the tier alone (总线程 11-09: not even hidden).
|
|
356
|
-
...(l?.label && (
|
|
357
|
-
? { label:
|
|
410
|
+
...(l?.label && (withNumber || tierOf(l.label))
|
|
411
|
+
? { label: withNumber ? l.label : tierOf(l.label) }
|
|
358
412
|
: {}),
|
|
359
413
|
// The number, hidden but for its ends, for the card and the page only.
|
|
360
|
-
...(
|
|
414
|
+
...(withNumber && l?.numberMasked ? { numberMasked: l.numberMasked } : {}),
|
|
361
415
|
signIn: m.signIn !== false,
|
|
362
416
|
join: m.join === true,
|
|
363
417
|
};
|
|
364
418
|
});
|
|
365
|
-
const membershipsSaid = (s) => {
|
|
419
|
+
const membershipsSaid = (s, noCards) => {
|
|
366
420
|
if (!linking)
|
|
367
421
|
return '';
|
|
368
422
|
const rows = membershipRows(s, false);
|
|
369
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
|
+
};
|
|
370
428
|
return `Hotel memberships linked to this account: ${linked.length
|
|
371
|
-
? linked.map((r) => `${r.
|
|
429
|
+
? linked.map((r) => `${said(r.group)}${r.label ? ` · ${r.label}` : ''}`).join('; ')
|
|
372
430
|
: 'none'}. Can be linked: ${rows
|
|
373
431
|
.filter((r) => !r.linked)
|
|
374
|
-
.map((r) => `${r.
|
|
432
|
+
.map((r) => `${said(r.group)} (\`${r.group}\`)`)
|
|
375
433
|
.join(', ') || 'none more'} - ${names.link} gives the guest a one-time page for it.`;
|
|
376
434
|
};
|
|
377
435
|
// ── Signing in and out ───────────────────────────────────────────────────
|
|
@@ -494,15 +552,18 @@ export const makeAccount = (opts) => {
|
|
|
494
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';
|
|
495
553
|
const minutes = Math.round(requests.ttlMs / 60_000);
|
|
496
554
|
const accountUrl = `${publicUrl}/account`;
|
|
497
|
-
// ⚠️ THE NAME THE ACCOUNT GOES BY
|
|
498
|
-
//
|
|
499
|
-
//
|
|
500
|
-
// the
|
|
501
|
-
//
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
const
|
|
505
|
-
|
|
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(),
|
|
506
567
|
structured: {
|
|
507
568
|
view: 'account',
|
|
508
569
|
brand,
|
|
@@ -522,17 +583,18 @@ export const makeAccount = (opts) => {
|
|
|
522
583
|
const linkAnswer = async (args, call) => {
|
|
523
584
|
const { key, noCards } = call;
|
|
524
585
|
const m = groupOf(args.group);
|
|
525
|
-
const listed = memberships.map((x) => `\`${x.code}\` (${
|
|
586
|
+
const listed = memberships.map((x) => `\`${x.code}\` (${groupSaid(x, noCards)})`).join(', ');
|
|
526
587
|
if (!m)
|
|
527
588
|
return {
|
|
528
589
|
text: `No such hotel group to link here. The ones that can be linked: ${listed}.`,
|
|
529
590
|
structured: { view: 'error', brand, code: 'no_such_group' },
|
|
530
591
|
isError: true,
|
|
531
592
|
};
|
|
593
|
+
const g = groupSaid(m, noCards);
|
|
532
594
|
const s = await checked(key);
|
|
533
595
|
if (!s)
|
|
534
596
|
return {
|
|
535
|
-
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)}.`,
|
|
536
598
|
structured: { view: 'account', brand, signedIn: false, code: 'not_signed_in' },
|
|
537
599
|
};
|
|
538
600
|
const mode = args.mode === 'unlink' ? 'unlink' : args.mode === 'join' ? 'up' : 'in';
|
|
@@ -541,20 +603,20 @@ export const makeAccount = (opts) => {
|
|
|
541
603
|
if (was)
|
|
542
604
|
log(`[account] ${tag(key)} unlinked a membership`);
|
|
543
605
|
return {
|
|
544
|
-
...signedInAnswer(s, ''),
|
|
606
|
+
...signedInAnswer(s, '', noCards),
|
|
545
607
|
text: was
|
|
546
|
-
? `The ${
|
|
547
|
-
: `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.`,
|
|
548
610
|
};
|
|
549
611
|
}
|
|
550
612
|
if (liveLink(s, m.code))
|
|
551
613
|
return {
|
|
552
|
-
...signedInAnswer(s, ''),
|
|
553
|
-
text: `A ${
|
|
614
|
+
...signedInAnswer(s, '', noCards),
|
|
615
|
+
text: `A ${g} membership is already linked to this ${brand} account. To use another, unlink it first.`,
|
|
554
616
|
};
|
|
555
617
|
if ((mode === 'up' && m.join !== true) || (mode === 'in' && m.signIn === false))
|
|
556
618
|
return {
|
|
557
|
-
text: `A ${
|
|
619
|
+
text: `A ${g} membership cannot be ${mode === 'up' ? 'made' : 'linked'} here.`,
|
|
558
620
|
structured: { view: 'error', brand, code: 'not_offered' },
|
|
559
621
|
isError: true,
|
|
560
622
|
};
|
|
@@ -595,25 +657,24 @@ export const makeAccount = (opts) => {
|
|
|
595
657
|
const url = `${publicUrl}/login?code=${made.code}${mode === 'up' ? '&view=register' : ''}`;
|
|
596
658
|
const expiresAt = new Date(made.expiresAt).toISOString();
|
|
597
659
|
log(`[account] a membership link for ${tag(key)}${noCards ? ' in words' : ''}`);
|
|
598
|
-
const what = mode === 'up'
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
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.`;
|
|
602
664
|
if (noCards)
|
|
603
665
|
return {
|
|
604
|
-
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.`,
|
|
605
667
|
structured: {
|
|
606
668
|
view: 'account-link',
|
|
607
669
|
brand,
|
|
608
670
|
group: m.code,
|
|
609
671
|
url,
|
|
610
|
-
shortCode: made.short,
|
|
611
672
|
expiresAt,
|
|
612
673
|
expiresInSeconds: Math.round(linkRequests.ttlMs / 1000),
|
|
613
674
|
},
|
|
614
675
|
};
|
|
615
676
|
return {
|
|
616
|
-
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.`,
|
|
617
678
|
structured: {
|
|
618
679
|
view: 'account-link',
|
|
619
680
|
brand,
|
|
@@ -621,7 +682,7 @@ export const makeAccount = (opts) => {
|
|
|
621
682
|
expiresAt,
|
|
622
683
|
expiresInSeconds: Math.round(linkRequests.ttlMs / 1000),
|
|
623
684
|
},
|
|
624
|
-
meta: { [LINK_META_KEY]: { url,
|
|
685
|
+
meta: { [LINK_META_KEY]: { url, expiresAt, group: m.code } },
|
|
625
686
|
};
|
|
626
687
|
};
|
|
627
688
|
const handle = async (name, args, call) => {
|
|
@@ -648,7 +709,7 @@ export const makeAccount = (opts) => {
|
|
|
648
709
|
if (name === names.view) {
|
|
649
710
|
const s = await checked(key);
|
|
650
711
|
if (s)
|
|
651
|
-
return signedInAnswer(s, '');
|
|
712
|
+
return signedInAnswer(s, '', noCards);
|
|
652
713
|
const waiting = requests.openFor(key);
|
|
653
714
|
// ⚠️ THE ASSISTANT, WHERE A CARD IS DRAWN, IS NOT TOLD "NOBODY" (0.56.1,
|
|
654
715
|
// robin 11-06): claude.ai sent one conversation's calls by several
|
|
@@ -697,7 +758,7 @@ export const makeAccount = (opts) => {
|
|
|
697
758
|
const s = await checked(key);
|
|
698
759
|
if (s)
|
|
699
760
|
return {
|
|
700
|
-
...signedInAnswer(s, ''),
|
|
761
|
+
...signedInAnswer(s, '', noCards),
|
|
701
762
|
text: `Already signed in to ${whoSaid(s)}: there is nothing to open. To use another account, ${names.signOut} first. ${NO_PRICE}`,
|
|
702
763
|
};
|
|
703
764
|
if (counters.links.count(key) >= ACCOUNT_LIMITS.linksPerConversation) {
|
|
@@ -798,7 +859,7 @@ export const makeAccount = (opts) => {
|
|
|
798
859
|
name: names.view,
|
|
799
860
|
// ⚠️ ONLY WHEN ASKED (robin 11-06, claude.ai): the assistant called it on its
|
|
800
861
|
// own 40 ms after a list, and ended its list with "I can't see your sign-in".
|
|
801
|
-
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.`,
|
|
802
863
|
annotations: {
|
|
803
864
|
title: `My ${brand} account`,
|
|
804
865
|
readOnlyHint: true,
|
|
@@ -826,7 +887,7 @@ export const makeAccount = (opts) => {
|
|
|
826
887
|
name: names.link,
|
|
827
888
|
// ⚠️ NOTHING ABOUT THE GUEST IS ASKED FOR HERE - the group's email and
|
|
828
889
|
// password are typed on our page, never in the chat.
|
|
829
|
-
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(', ')}.`,
|
|
830
891
|
annotations: {
|
|
831
892
|
title: 'Link a hotel membership',
|
|
832
893
|
readOnlyHint: false,
|
|
@@ -920,7 +981,6 @@ export const makeAccount = (opts) => {
|
|
|
920
981
|
group: STR,
|
|
921
982
|
signedIn: { type: 'boolean' },
|
|
922
983
|
url: STR,
|
|
923
|
-
shortCode: STR,
|
|
924
984
|
expiresAt: STR,
|
|
925
985
|
expiresInSeconds: { type: 'number' },
|
|
926
986
|
account: { type: 'object' },
|
|
@@ -1055,6 +1115,10 @@ export const makeAccount = (opts) => {
|
|
|
1055
1115
|
// here. A link opened anywhere else - forwarded, or made by someone holding
|
|
1056
1116
|
// the conversation's trip id - links nothing: a membership could otherwise
|
|
1057
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`).
|
|
1058
1122
|
const linkState = (r) => {
|
|
1059
1123
|
const st = linkRequests.state(r, false);
|
|
1060
1124
|
if (st !== 'open')
|
|
@@ -1068,19 +1132,19 @@ export const makeAccount = (opts) => {
|
|
|
1068
1132
|
? { id: at.id, s: at.s }
|
|
1069
1133
|
: null;
|
|
1070
1134
|
};
|
|
1071
|
-
const accountNameOf = (s) => s.shown.displayName || s.shown.userName || '';
|
|
1072
1135
|
const groupPage = (c, code, r, s, lang, mode, error, values) => {
|
|
1073
1136
|
const m = groupOf(r.link?.group);
|
|
1074
1137
|
return send(c, 200, linkGroupPage(brandPage, {
|
|
1075
1138
|
lang,
|
|
1076
|
-
short: r.short,
|
|
1077
1139
|
code,
|
|
1078
1140
|
csrf: linkCsrf(r),
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1141
|
+
// The group as the page's reader knows it: 「亚朵」 on a Chinese page (0.60.1),
|
|
1142
|
+
// over its logo (0.61.0).
|
|
1143
|
+
group: m ? groupIn(m, lang) : String(r.link?.group),
|
|
1144
|
+
...(m && logoPath(m.code) ? { logo: logoPath(m.code) } : {}),
|
|
1145
|
+
accountName: nameOf(s),
|
|
1082
1146
|
mode: mode === 'up' && m?.join === true ? 'up' : 'in',
|
|
1083
|
-
...(error ? { error: say(lang, error, m ?
|
|
1147
|
+
...(error ? { error: say(lang, error, m ? groupIn(m, lang) : brand) } : {}),
|
|
1084
1148
|
...(values ? { values } : {}),
|
|
1085
1149
|
}));
|
|
1086
1150
|
};
|
|
@@ -1088,11 +1152,10 @@ export const makeAccount = (opts) => {
|
|
|
1088
1152
|
const m = groupOf(r.link?.group);
|
|
1089
1153
|
return send(c, 200, linkReauthPage(brandPage, {
|
|
1090
1154
|
lang,
|
|
1091
|
-
short: r.short,
|
|
1092
1155
|
code,
|
|
1093
1156
|
csrf: linkCsrf(r),
|
|
1094
|
-
|
|
1095
|
-
|
|
1157
|
+
group: m ? groupIn(m, lang) : String(r.link?.group),
|
|
1158
|
+
...(m && logoPath(m.code) ? { logo: logoPath(m.code) } : {}),
|
|
1096
1159
|
...(error ? { error: say(lang, error, brand) } : {}),
|
|
1097
1160
|
}));
|
|
1098
1161
|
};
|
|
@@ -1259,7 +1322,7 @@ export const makeAccount = (opts) => {
|
|
|
1259
1322
|
log(`[account] a membership link for ${tag(r.key)} refused (${codeOf(e)})`);
|
|
1260
1323
|
if (up)
|
|
1261
1324
|
return again('joined_not_linked', 'in', { identity: values.email ?? '' });
|
|
1262
|
-
return again(otaNotThere(e) ? 'link_busy' : 'link_failed');
|
|
1325
|
+
return again(otaNotThere(e) ? 'link_busy' : otaWrong(e) ? 'link_failed' : 'link_unconfirmed');
|
|
1263
1326
|
}
|
|
1264
1327
|
outcome = 'ok';
|
|
1265
1328
|
// Still that sign-in, after the backend kept us waiting?
|
|
@@ -1282,7 +1345,7 @@ export const makeAccount = (opts) => {
|
|
|
1282
1345
|
log(`[account] ${tag(r.key)} linked a ${m.code} membership${up ? ' it made' : ''}`);
|
|
1283
1346
|
return send(c, 200, linkedPage(brandPage, {
|
|
1284
1347
|
lang,
|
|
1285
|
-
group:
|
|
1348
|
+
group: groupIn(m, lang),
|
|
1286
1349
|
...(link.label ? { label: link.label } : {}),
|
|
1287
1350
|
}));
|
|
1288
1351
|
}
|
|
@@ -1470,7 +1533,7 @@ export const makeAccount = (opts) => {
|
|
|
1470
1533
|
log(`[account] ${up ? 'an account was made and signed in' : 'signed in'} for ${tag(r.key)}`);
|
|
1471
1534
|
return send(c, 200, signedInPage(brandPage, {
|
|
1472
1535
|
lang,
|
|
1473
|
-
name: s
|
|
1536
|
+
name: nameOf(s),
|
|
1474
1537
|
account: !!id,
|
|
1475
1538
|
}));
|
|
1476
1539
|
});
|
|
@@ -1490,7 +1553,25 @@ export const makeAccount = (opts) => {
|
|
|
1490
1553
|
lang,
|
|
1491
1554
|
shown: at.s.shown,
|
|
1492
1555
|
csrf: at.ws.csrf,
|
|
1493
|
-
|
|
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
|
+
: {}),
|
|
1494
1575
|
}));
|
|
1495
1576
|
});
|
|
1496
1577
|
app.post('/account', form, async (c) => {
|
|
@@ -1559,25 +1640,27 @@ export const makeAccount = (opts) => {
|
|
|
1559
1640
|
handle,
|
|
1560
1641
|
meta: (key, { cards, ours }) => {
|
|
1561
1642
|
const s = store.get(key);
|
|
1562
|
-
// ⚠️ THE
|
|
1563
|
-
//
|
|
1564
|
-
//
|
|
1565
|
-
//
|
|
1566
|
-
//
|
|
1567
|
-
//
|
|
1568
|
-
//
|
|
1569
|
-
|
|
1570
|
-
//
|
|
1571
|
-
//
|
|
1572
|
-
//
|
|
1573
|
-
//
|
|
1574
|
-
//
|
|
1575
|
-
//
|
|
1576
|
-
const
|
|
1577
|
-
?
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
: 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;
|
|
1581
1664
|
return {
|
|
1582
1665
|
[ACCOUNT_META_KEY]: {
|
|
1583
1666
|
from: opts.from,
|
|
@@ -1587,10 +1670,16 @@ export const makeAccount = (opts) => {
|
|
|
1587
1670
|
: { signIn: names.signIn, view: names.view, signOut: names.signOut, card: names.card },
|
|
1588
1671
|
signedIn: !!s,
|
|
1589
1672
|
...(name !== undefined ? { name } : {}),
|
|
1590
|
-
|
|
1591
|
-
//
|
|
1592
|
-
//
|
|
1593
|
-
|
|
1673
|
+
...(facts && Object.keys(facts).length ? { facts } : {}),
|
|
1674
|
+
// The hotel memberships, one row a group: to a session that draws cards,
|
|
1675
|
+
// whichever conversation the call names (0.59.1, 总线程 11-09). In claude.ai
|
|
1676
|
+
// the card's own calls name the conversation's trip (`ours` is false) and
|
|
1677
|
+
// the model's connection is cards=none, so `ours && cards` gave the card
|
|
1678
|
+
// no rows at all. A row is the group, whether linked and the tier - what
|
|
1679
|
+
// the model reads anyway; the hidden NUMBER is still `ours && cards` only
|
|
1680
|
+
// (the card shows a number only then), and a session that does not draw
|
|
1681
|
+
// cards (or is not known to) is given none, as `_meta` may reach its model.
|
|
1682
|
+
...(linking && cards ? { memberships: membershipRows(s, true, ours) } : {}),
|
|
1594
1683
|
},
|
|
1595
1684
|
};
|
|
1596
1685
|
},
|