@curless/hotel-storefront 0.65.2 → 0.67.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/fake-ota.d.ts +5 -0
- package/dist/account/fake-ota.d.ts.map +1 -1
- package/dist/account/fake-ota.js +8 -2
- package/dist/account/fake-ota.js.map +1 -1
- package/dist/account/index.d.ts +36 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +208 -26
- package/dist/account/index.js.map +1 -1
- package/dist/account/ota-member.d.ts +2 -0
- package/dist/account/ota-member.d.ts.map +1 -1
- package/dist/account/ota-member.js +2 -0
- package/dist/account/ota-member.js.map +1 -1
- package/dist/account/pages.d.ts +51 -5
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +153 -23
- package/dist/account/pages.js.map +1 -1
- package/dist/account/requests.d.ts +2 -0
- package/dist/account/requests.d.ts.map +1 -1
- package/dist/account/requests.js.map +1 -1
- package/dist/account/store.d.ts +57 -2
- package/dist/account/store.d.ts.map +1 -1
- package/dist/account/store.js +52 -4
- package/dist/account/store.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/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/otaless/backend.d.ts +6 -2
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +58 -9
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/booking.d.ts +190 -28
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +929 -374
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/client.d.ts +120 -34
- package/dist/otaless/client.d.ts.map +1 -1
- package/dist/otaless/client.js +133 -19
- package/dist/otaless/client.js.map +1 -1
- package/dist/otaless/fake.d.ts +59 -10
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +132 -34
- package/dist/otaless/fake.js.map +1 -1
- package/dist/otaless/make.d.ts +2 -0
- package/dist/otaless/make.d.ts.map +1 -1
- package/dist/otaless/make.js +56 -18
- package/dist/otaless/make.js.map +1 -1
- package/dist/otaless/places.d.ts +14 -0
- package/dist/otaless/places.d.ts.map +1 -1
- package/dist/otaless/places.js +108 -1
- package/dist/otaless/places.js.map +1 -1
- package/dist/pictures.d.ts +19 -0
- package/dist/pictures.d.ts.map +1 -0
- package/dist/pictures.js +74 -0
- package/dist/pictures.js.map +1 -0
- package/dist/server.d.ts +15 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +236 -37
- package/dist/server.js.map +1 -1
- package/dist/sessions.d.ts +23 -0
- package/dist/sessions.d.ts.map +1 -1
- package/dist/sessions.js +39 -1
- package/dist/sessions.js.map +1 -1
- package/dist/supplier.js +4 -0
- package/dist/supplier.js.map +1 -1
- package/dist/surface.d.ts +24 -1
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +35 -6
- package/dist/surface.js.map +1 -1
- package/dist/tools.d.ts +24 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +217 -23
- package/dist/tools.js.map +1 -1
- package/dist/trip-ids.d.ts +13 -1
- package/dist/trip-ids.d.ts.map +1 -1
- package/dist/trip-ids.js +30 -3
- package/dist/trip-ids.js.map +1 -1
- package/dist/types.d.ts +88 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/account/index.js
CHANGED
|
@@ -2,10 +2,67 @@ import { createHmac, randomBytes } from 'node:crypto';
|
|
|
2
2
|
import { bodyLimit } from 'hono/body-limit';
|
|
3
3
|
import { WindowCounter } from '../limits.js';
|
|
4
4
|
import { formatMoney } from '../money.js';
|
|
5
|
+
import { withTrip } from '../trip-ids.js';
|
|
5
6
|
import { LIMITS, OtaMemberError, linkOf, makeOtaMembers, maskNumber, } from './ota-member.js';
|
|
6
7
|
import { PAGE_HEADERS, accountPage, linkGroupPage, linkReauthPage, linkedPage, loginPage, say, signedInPage, statePage, termsDonePage, termsPage, termsStatePage, } from './pages.js';
|
|
7
8
|
import { CODE, createSignIns, hashOf, same, } from './requests.js';
|
|
8
|
-
import { AccountStore, WEB_IDLE_MS, WebSessions, shownOf } from './store.js';
|
|
9
|
+
import { AccountStore, WEB_IDLE_MS, WebSessions, nameShown, profileOf, profileShown, shownOf, } from './store.js';
|
|
10
|
+
// THE ACCOUNT: signing in to the deployment's own account - for Otaless, the hotel
|
|
11
|
+
// backend's own (`/ota/register`, `/ota/sign-in`, `/ota/sign-out`: 0.62.0, robin
|
|
12
|
+
// 11-10: 「ota 的登陆注册都是这个里面的…渠道和平台应该是一个接口」; the mall's
|
|
13
|
+
// `/member/*` of 11-06 is not used any more) - on a page of ours, never in the
|
|
14
|
+
// chat. Nexva One's external sign-in (marketplace docs/listing/chatgpt/
|
|
15
|
+
// external-sign-in.md, server/web-signin.mjs), for a conversation instead of a cart.
|
|
16
|
+
//
|
|
17
|
+
// sign_in_<prefix>account a one-time request: a long code (the link's
|
|
18
|
+
// secret) and a short code to compare by eye - on
|
|
19
|
+
// the card where one is drawn, in the words only
|
|
20
|
+
// where none is
|
|
21
|
+
// GET /login?code=… the request's page: the short code, the warning,
|
|
22
|
+
// Sign in and Create account; nothing used by looking
|
|
23
|
+
// POST /login to the backend; done, the conversation is signed in
|
|
24
|
+
// and the card (which asks every few seconds) shows it
|
|
25
|
+
// GET /account the account, in the browser that signed in
|
|
26
|
+
// POST /account sign out - there and in the conversation
|
|
27
|
+
// view_<prefix>account who is signed in, for the card and the assistant
|
|
28
|
+
// sign_out_<prefix>account signed out, here and at the backend
|
|
29
|
+
//
|
|
30
|
+
// ⚠️ NO TOOL TAKES A PASSWORD, AN EMAIL, A PHONE OR AN ADDRESS - OpenAI refused
|
|
31
|
+
// Nexva One 1.0.0 for asking for them. They are typed on our page and go from
|
|
32
|
+
// it to the backend, and nowhere else: never logged, never kept (the email kept
|
|
33
|
+
// masked only), never in an answer.
|
|
34
|
+
//
|
|
35
|
+
// ⚠️ THE BACKEND'S TOKENS NEVER LEAVE THIS PROCESS: not to the disk, a URL, a log,
|
|
36
|
+
// an answer or the card - only back to the backend, and (`bookingAuth`) to this
|
|
37
|
+
// process's own booking calls for the same conversation.
|
|
38
|
+
//
|
|
39
|
+
// ⚠️ WHICH CHANNEL THE ACCOUNT SIGNS IN ON IS NOT SETTLED (questions #50): their
|
|
40
|
+
// `/ota/sign-in` wants a providerCode, and says nothing of the platform's own.
|
|
41
|
+
// Until they answer, `account.signInProvider` - `ascott` by default, the one their
|
|
42
|
+
// own Postman sign-in worked on - and `<envPrefix>_SIGN_IN_PROVIDER` over it.
|
|
43
|
+
//
|
|
44
|
+
// ⚠️ FORWARDED PHISHING (Nexva's review P1-1): a link passed on to someone else
|
|
45
|
+
// signs THEIR account into the conversation it came from. Against it: the short
|
|
46
|
+
// code on both sides - on the card alone where one is drawn, so words slipped
|
|
47
|
+
// into the chat cannot show a matching one - with a warning, 5 minutes, one
|
|
48
|
+
// use, and every other open link of the conversation dead once one is used.
|
|
49
|
+
// What it would reach is held to the least: a name and a user name, and the
|
|
50
|
+
// email and phone masked - nothing is bought or booked with this account yet,
|
|
51
|
+
// and no price changes with it.
|
|
52
|
+
//
|
|
53
|
+
// ⚠️ A MEMBERSHIP LINK HAS NO CODE (0.61.0, 总线程 11-10; robin: 「code是否可以不
|
|
54
|
+
// 要」). Its page opens only in the browser holding the link's own sign-in - the
|
|
55
|
+
// same account, the same sign-in (`ownerOf`) - or after that same account signs in
|
|
56
|
+
// again there (another is refused, `reauth_other`): a forwarded link, or one made
|
|
57
|
+
// with the conversation's trip id, links nothing, and a code would add nothing.
|
|
58
|
+
// The account's own sign-in page (and a loyalty member's, member-login.ts) keeps
|
|
59
|
+
// its code: there nothing else ties the browser to the chat.
|
|
60
|
+
//
|
|
61
|
+
// ⚠️ NO MEMBER PRICE YET (robin, 2026-11-06): what signing in buys is waiting
|
|
62
|
+
// on the backend (docs/otaless-backend-questions.md, 「会员」). Nothing here says
|
|
63
|
+
// it changes a price, and the words say it does not.
|
|
64
|
+
/** An email as the pages check one: something@something.something, no spaces. */
|
|
65
|
+
const EMAIL_SHAPE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
9
66
|
/**
|
|
10
67
|
* The tools, by the deployment's prefix: three the assistant calls -
|
|
11
68
|
* `sign_in_otaless_account` - and one the card calls (`card`, app-only).
|
|
@@ -253,6 +310,13 @@ export const makeAccount = (opts) => {
|
|
|
253
310
|
.toLowerCase();
|
|
254
311
|
if (!/^[a-z0-9_-]{1,32}$/.test(signInProvider))
|
|
255
312
|
throw new Error('account: signInProvider is not a channel code');
|
|
313
|
+
// What the account signs in with (0.66.0, 总线程 11-11) - see `signInIdentity`.
|
|
314
|
+
const signInIdentity = opts.account.signInIdentity ?? 'email-or-username';
|
|
315
|
+
if (signInIdentity !== 'email' && signInIdentity !== 'email-or-username')
|
|
316
|
+
throw new Error('account: signInIdentity is "email" or "email-or-username"');
|
|
317
|
+
const emailOnly = signInIdentity === 'email';
|
|
318
|
+
/** Not an email, where only one is taken: said on the page, nothing sent, nothing counted. */
|
|
319
|
+
const notAnEmail = (typed) => emailOnly && !EMAIL_SHAPE.test(typed);
|
|
256
320
|
// The backend's `/ota/*`: the account's own sign-in, and its hotel memberships'.
|
|
257
321
|
const ota = makeOtaMembers({
|
|
258
322
|
baseUrl,
|
|
@@ -306,6 +370,7 @@ export const makeAccount = (opts) => {
|
|
|
306
370
|
: {}),
|
|
307
371
|
...(opts.operator ? { operator: opts.operator } : {}),
|
|
308
372
|
...(opts.color ? { color: opts.color } : {}),
|
|
373
|
+
...(emailOnly ? { emailSignIn: true } : {}),
|
|
309
374
|
};
|
|
310
375
|
const brand = opts.brand;
|
|
311
376
|
/** "an Otaless", "a Shangri-La". */
|
|
@@ -435,14 +500,14 @@ export const makeAccount = (opts) => {
|
|
|
435
500
|
};
|
|
436
501
|
// ── Signing in and out ───────────────────────────────────────────────────
|
|
437
502
|
/** Signed in now, for this conversation: whatever was there before is ended. */
|
|
438
|
-
const signInWith = (key, shown, platform) => {
|
|
503
|
+
const signInWith = (key, shown, platform, profile) => {
|
|
439
504
|
const was = store.clear(key);
|
|
440
505
|
if (was)
|
|
441
506
|
end(was);
|
|
442
507
|
requests.cancelFor(key);
|
|
443
508
|
linkRequests.cancelFor(key);
|
|
444
509
|
termsRequests.cancelFor(key);
|
|
445
|
-
return store.set(key, shown, platform);
|
|
510
|
+
return store.set(key, shown, platform, profile);
|
|
446
511
|
};
|
|
447
512
|
/** A channel session of the account's own, ended at the backend (not waited for). */
|
|
448
513
|
const endSession = (p) => ota
|
|
@@ -511,12 +576,27 @@ export const makeAccount = (opts) => {
|
|
|
511
576
|
// and the per-name limit on wrong tries still holds). The same name on the
|
|
512
577
|
// card, on the page, in the words and in the structured answer. The real name,
|
|
513
578
|
// the email and the phone are never in the words: the email and phone go to a
|
|
514
|
-
// card, masked, in `_meta` (`meta`), and are on the account page
|
|
515
|
-
|
|
579
|
+
// card, masked, in `_meta` (`meta`), and are on the account page - except that an
|
|
580
|
+
// account with no nickname and no user name but its email goes by that email,
|
|
581
|
+
// MASKED, everywhere (0.66.0, 总线程 11-11: Ascott's sign-in names the member by
|
|
582
|
+
// their email alone, and "signed in" said nothing of whose account it was).
|
|
583
|
+
// 0.66.0 (总线程 11-11): else its email, masked - see store.ts `nameShown`.
|
|
584
|
+
const nameOf = (s) => nameShown(s.shown);
|
|
516
585
|
const shownFor = (s) => (nameOf(s) ? { displayName: nameOf(s) } : {});
|
|
517
586
|
const whoSaid = (s) => nameOf(s) ? `the ${brand} account of ${nameOf(s)}` : `${aBrand} account`;
|
|
587
|
+
/** What a booking takes from the account (0.67.0), masked - said with the sign-in. */
|
|
588
|
+
// ⚠️ WITHOUT THE DETAILS THEMSELVES, NOT EVEN MASKED: the account's own answers tell the
|
|
589
|
+
// model no contact detail (review P2-2) - the booking's words say the masked email.
|
|
590
|
+
const profileSaid = (s) => {
|
|
591
|
+
const p = profileShown(s);
|
|
592
|
+
if (!p?.email)
|
|
593
|
+
return '';
|
|
594
|
+
const has = [p.name ? 'name' : '', 'email', p.phone ? 'phone' : ''].filter(Boolean);
|
|
595
|
+
const said = has.length > 1 ? `${has.slice(0, -1).join(', ')} and ${has.at(-1)}` : (has[0] ?? '');
|
|
596
|
+
return ` A booking here uses this account's ${said} for what the guest leaves out - do not ask them for those.`;
|
|
597
|
+
};
|
|
518
598
|
const signedInAnswer = (s, lead, noCards) => ({
|
|
519
|
-
text: `${lead} Signed in to ${whoSaid(s)}. ${linking ? '' : `${NO_PRICE} `}The guest sees the whole account - its user name, and its email 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(),
|
|
599
|
+
text: `${lead} Signed in to ${whoSaid(s)}. ${linking ? '' : `${NO_PRICE} `}The guest sees the whole account - its user name, and its email 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.${profileSaid(s)}${linking ? ` ${membershipsSaid(s, noCards)}` : ''}`.trim(),
|
|
520
600
|
structured: {
|
|
521
601
|
view: 'account',
|
|
522
602
|
brand,
|
|
@@ -616,7 +696,7 @@ export const makeAccount = (opts) => {
|
|
|
616
696
|
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.`;
|
|
617
697
|
if (noCards)
|
|
618
698
|
return {
|
|
619
|
-
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.`,
|
|
699
|
+
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, call ${names.view}${withTrip(call.trip)}: it shows what is linked.`,
|
|
620
700
|
structured: {
|
|
621
701
|
view: 'account-link',
|
|
622
702
|
brand,
|
|
@@ -643,7 +723,9 @@ export const makeAccount = (opts) => {
|
|
|
643
723
|
* as the terms (`until`), at most ten minutes. Counted against the conversation
|
|
644
724
|
* like a membership link.
|
|
645
725
|
*/
|
|
646
|
-
const makeTerms = (key, ref, lang, until
|
|
726
|
+
const makeTerms = (key, ref, lang, until,
|
|
727
|
+
/** Terms an order came back with (0.66.0): its pages never say "nothing was ordered". */
|
|
728
|
+
order = false) => {
|
|
647
729
|
const s = store.get(key);
|
|
648
730
|
if (!s)
|
|
649
731
|
return undefined;
|
|
@@ -658,7 +740,7 @@ export const makeAccount = (opts) => {
|
|
|
658
740
|
key,
|
|
659
741
|
...(lang ? { lang } : {}),
|
|
660
742
|
words: true,
|
|
661
|
-
terms: { ref, sid: s.sid },
|
|
743
|
+
terms: { ref, sid: s.sid, ...(order ? { order: true } : {}) },
|
|
662
744
|
});
|
|
663
745
|
if (!made)
|
|
664
746
|
return undefined;
|
|
@@ -673,7 +755,7 @@ export const makeAccount = (opts) => {
|
|
|
673
755
|
if (!t)
|
|
674
756
|
return undefined;
|
|
675
757
|
const l = langOf(lang);
|
|
676
|
-
const made = makeTerms(key, ref, l, t.until);
|
|
758
|
+
const made = makeTerms(key, ref, l, t.until, t.changed === true);
|
|
677
759
|
if (!made)
|
|
678
760
|
return undefined;
|
|
679
761
|
log(`[account] a terms link for ${tag(key)} (${t.group})`);
|
|
@@ -800,7 +882,7 @@ export const makeAccount = (opts) => {
|
|
|
800
882
|
log(`[account] a sign-in link for ${tag(key)} (${requests.open()} open)${noCards ? ' in words' : ''}`);
|
|
801
883
|
if (noCards)
|
|
802
884
|
return {
|
|
803
|
-
text: `A one-time ${brand} sign-in page is ready: ${url} - the guest opens it in their browser and signs in, or creates ${aBrand} account, on that page, ${NEVER_IN_CHAT}. The page shows the code ${made.short}: tell the guest it must match the code you give them here, and to close the page if it does not. The link works once, for ${minutes} minutes. When they say they are done, ${names.view} shows that they are signed in. ${NO_PRICE}`,
|
|
885
|
+
text: `A one-time ${brand} sign-in page is ready: ${url} - the guest opens it in their browser and signs in, or creates ${aBrand} account, on that page, ${NEVER_IN_CHAT}. The page shows the code ${made.short}: tell the guest it must match the code you give them here, and to close the page if it does not. The link works once, for ${minutes} minutes. When they say they are done, call ${names.view}${withTrip(call.trip)}: it shows that they are signed in. ${NO_PRICE}`,
|
|
804
886
|
structured: {
|
|
805
887
|
view: 'account-sign-in',
|
|
806
888
|
brand,
|
|
@@ -1034,7 +1116,7 @@ export const makeAccount = (opts) => {
|
|
|
1034
1116
|
? ` HOTEL MEMBERSHIPS: a guest signed in to ${brand} can link a hotel group's loyalty membership to the account - ${memberships.map(groupName).join(', ')} - and that group's prices here are then asked for as the member. ${names.link} gives a one-time page for it (or joins the group, or unlinks); the group's email and password are typed on that page, never in the chat - never ask for or accept them here, and never write one back. Say a price is a member rate only where the answer says so.`
|
|
1035
1117
|
: '';
|
|
1036
1118
|
const instructions = (noCards) => (noCards
|
|
1037
|
-
? `${brand} ACCOUNT: a guest who wants to sign in to their ${brand} account, or create one, is given a one-time page by ${names.signIn}: pass on its link and its code exactly, and say they sign in or create the account on that page. Never ask for, or accept, a password, an email or a phone number in the chat; if the guest types one, never write it back - not even to say which one to change: call it \"the password you typed\" - and tell them to use the page and, as it went into a chat, to choose another. When they say they are done, ${names.view} shows who is signed in
|
|
1119
|
+
? `${brand} ACCOUNT: a guest who wants to sign in to their ${brand} account, or create one, is given a one-time page by ${names.signIn}: pass on its link and its code exactly, and say they sign in or create the account on that page. Never ask for, or accept, a password, an email or a phone number in the chat; if the guest types one, never write it back - not even to say which one to change: call it \"the password you typed\" - and tell them to use the page and, as it went into a chat, to choose another. When they say they are done, ${names.view} - with the conversation's trip, as every call - shows who is signed in; use it only when they ask, never on your own; ${names.signOut} signs them out.${linking ? '' : ' Being signed in changes no price here: say nothing of member rates.'}`
|
|
1038
1120
|
: `${brand} ACCOUNT: the card's Sign in opens ${brand}'s own page, where the guest signs in or creates an account; ${names.signIn} does the same when they ask in words. The card tells you when the guest signs in or out on it - take its word, and do not look again to check. Look at the account (${names.view}) only when the guest asks about it - never on your own, and never beside a list of hotels. Never ask for, or accept, a password, an email or a phone number in the chat; if the guest types one, never write it back - not even to say which one to change: call it \"the password you typed\" - and tell them to use the page and, as it went into a chat, to choose another. ${names.signOut} signs them out.${linking ? '' : ' Being signed in changes no price here: say nothing of member rates.'}`) +
|
|
1039
1121
|
LINK_SAID;
|
|
1040
1122
|
// ── The pages ────────────────────────────────────────────────────────────
|
|
@@ -1194,7 +1276,9 @@ export const makeAccount = (opts) => {
|
|
|
1194
1276
|
const account = formStr(body.account, LIMITS.account).trim();
|
|
1195
1277
|
const password = formStr(body.password, LIMITS.password);
|
|
1196
1278
|
if (!account || !password)
|
|
1197
|
-
return reauthPage(c, code, r, lang, 'missing_in');
|
|
1279
|
+
return reauthPage(c, code, r, lang, emailOnly ? 'missing_in_email' : 'missing_in');
|
|
1280
|
+
if (notAnEmail(account))
|
|
1281
|
+
return reauthPage(c, code, r, lang, 'email_only');
|
|
1198
1282
|
// ⚠️ COUNTED AS A SIGN-IN OF THE ACCOUNT IS (总线程 11-06): by the name -
|
|
1199
1283
|
// the SAME `nameFailures` as the sign-in page (C8: only a no from the backend
|
|
1200
1284
|
// counts, a success clears the name) - and for everyone.
|
|
@@ -1417,7 +1501,9 @@ export const makeAccount = (opts) => {
|
|
|
1417
1501
|
return send(c, 429, statePage(brandPage, lang, 'tries', href));
|
|
1418
1502
|
const as = state === 'used' ? 'used' : state === 'unknown' ? 'unknown' : 'expired';
|
|
1419
1503
|
void wait;
|
|
1420
|
-
|
|
1504
|
+
// An order's terms (0.66.0): the order stands - not "nothing was ordered".
|
|
1505
|
+
const order = termsRequests.find(code)?.terms?.order === true;
|
|
1506
|
+
return send(c, statusOf(state), termsStatePage(brandPage, lang, as, href, undefined, order));
|
|
1421
1507
|
};
|
|
1422
1508
|
const groupLabel = (t, lang) => {
|
|
1423
1509
|
const m = groupOf(t.group);
|
|
@@ -1443,6 +1529,16 @@ export const makeAccount = (opts) => {
|
|
|
1443
1529
|
facts: termsFactsOf(t, lang),
|
|
1444
1530
|
text: t.text,
|
|
1445
1531
|
until: t.until,
|
|
1532
|
+
...(t.source ? { source: t.source } : {}),
|
|
1533
|
+
...(t.askedByGroup ? { askedByGroup: t.askedByGroup } : {}),
|
|
1534
|
+
...(t.changed
|
|
1535
|
+
? {
|
|
1536
|
+
changed: true,
|
|
1537
|
+
...((t.confirmationCode ?? t.bookingId)
|
|
1538
|
+
? { orderCode: t.confirmationCode ?? t.bookingId }
|
|
1539
|
+
: {}),
|
|
1540
|
+
}
|
|
1541
|
+
: {}),
|
|
1446
1542
|
}));
|
|
1447
1543
|
};
|
|
1448
1544
|
const termsReauth = (c, code, r, lang, error, said) => {
|
|
@@ -1477,7 +1573,7 @@ export const makeAccount = (opts) => {
|
|
|
1477
1573
|
setCookie(c, owner.id);
|
|
1478
1574
|
const t = opts.terms.pending(r.key, r.terms.ref);
|
|
1479
1575
|
if (!t)
|
|
1480
|
-
return send(c, 410, termsStatePage(brandPage, lang, 'gone', termsHrefOf(code)));
|
|
1576
|
+
return send(c, 410, termsStatePage(brandPage, lang, 'gone', termsHrefOf(code), undefined, r.terms?.order === true));
|
|
1481
1577
|
return termsView(c, code, r, t, lang);
|
|
1482
1578
|
};
|
|
1483
1579
|
/** Used, once - whatever came of it. (Not `done()`: that would end the conversation's other terms links.) */
|
|
@@ -1485,7 +1581,11 @@ export const makeAccount = (opts) => {
|
|
|
1485
1581
|
r.state = 'done';
|
|
1486
1582
|
r.doneAt = now();
|
|
1487
1583
|
};
|
|
1488
|
-
/**
|
|
1584
|
+
/**
|
|
1585
|
+
* Our words for what the group or the tools refused: [中文, English, nothing was
|
|
1586
|
+
* ordered, how it stands]. Without the fourth, "nothing ordered" is "could not order"
|
|
1587
|
+
* and the rest is not known (0.63.x); 0.66.0's orders cancelled at once say neither.
|
|
1588
|
+
*/
|
|
1489
1589
|
const TERMS_ERRORS = {
|
|
1490
1590
|
'sign-in': [
|
|
1491
1591
|
'下单需要先登录{g}。回到对话,请助手给你登录{g}的链接。',
|
|
@@ -1512,9 +1612,52 @@ export const makeAccount = (opts) => {
|
|
|
1512
1612
|
'These terms have expired or were already used.',
|
|
1513
1613
|
true,
|
|
1514
1614
|
],
|
|
1615
|
+
// ⚠️ 0.66.0: also an order 8 made at another amount and cancelled at once - so
|
|
1616
|
+
// never "nothing was ordered", only what is true of both.
|
|
1515
1617
|
'price-changed': [
|
|
1516
|
-
'
|
|
1517
|
-
'The price is not the one you were shown, so it was not
|
|
1618
|
+
'价格和你看到的不一样,所以没有订成,也没有扣款。回到对话重新查价。',
|
|
1619
|
+
'The price is not the one you were shown, so it was not booked and nothing was charged. Ask for the price again in your chat.',
|
|
1620
|
+
false,
|
|
1621
|
+
'failed',
|
|
1622
|
+
],
|
|
1623
|
+
'order-cancelled': [
|
|
1624
|
+
'{g}生成的订单和你选的不一样,已经立即取消,没有扣款。',
|
|
1625
|
+
'The order {g} made was not the one you chose, so it was cancelled at once and nothing was charged.',
|
|
1626
|
+
false,
|
|
1627
|
+
'failed',
|
|
1628
|
+
],
|
|
1629
|
+
'needs-person': [
|
|
1630
|
+
'{g}生成了一张和你看到的不一样的单,我们没能取消,已转人工,请不要付款。这张单在对话里的「我的预订」中。',
|
|
1631
|
+
'{g} made an order that is not the one you were shown, and we could not cancel it. A person is looking at it - please do not pay it. It is in My bookings in your chat.',
|
|
1632
|
+
false,
|
|
1633
|
+
'person',
|
|
1634
|
+
],
|
|
1635
|
+
'earlier-needs-person': [
|
|
1636
|
+
'这间房上一单还在人工处理,这次没有下单。',
|
|
1637
|
+
'An earlier order for this room is still with a person to sort out, so this time nothing was ordered.',
|
|
1638
|
+
true,
|
|
1639
|
+
],
|
|
1640
|
+
// 0.67.0: an earlier order of this stay has been with a person for hours - it may stand.
|
|
1641
|
+
'earlier-needs-person-overdue': [
|
|
1642
|
+
'这间房上一单还在人工处理,可能已在{g}生成,请先找{g}确认。这次没有下单,再订一次会下新单。',
|
|
1643
|
+
'An earlier order for this room is still with a person and may already exist at {g}: please check with {g} first. This time nothing was ordered; ordering again places a new order.',
|
|
1644
|
+
true,
|
|
1645
|
+
],
|
|
1646
|
+
// 0.67.0: the group wanted its own terms agreed to and did not send them (questions #66).
|
|
1647
|
+
// 0.67.0: the group wants a further confirmation and did not send what to confirm (#68).
|
|
1648
|
+
'group-confirm': [
|
|
1649
|
+
'{g}要求下单后再确认一步,但没把要确认的内容发过来,这次没订上,也没扣款。',
|
|
1650
|
+
'{g} wants one more confirmation step after the order, but did not send what to confirm, so this was not booked and nothing was charged.',
|
|
1651
|
+
true,
|
|
1652
|
+
],
|
|
1653
|
+
'group-terms': [
|
|
1654
|
+
'{g}要先同意它自己的条款,但没把条款发过来,这次没订上,也没扣款。',
|
|
1655
|
+
'{g} wants its own terms agreed to first, but did not send them to show, so this was not booked and nothing was charged.',
|
|
1656
|
+
true,
|
|
1657
|
+
],
|
|
1658
|
+
'earlier-unconfirmed': [
|
|
1659
|
+
'这间房上一单没能确认订没订上,可能已经订上了。这次没有下单;请先向{g}确认,确认后再订一次会下新单。',
|
|
1660
|
+
'An earlier order for this room was never confirmed and may have been made. This time nothing was ordered; please check with {g} first, and once you have, ordering again places a new booking.',
|
|
1518
1661
|
true,
|
|
1519
1662
|
],
|
|
1520
1663
|
'card-only': [
|
|
@@ -1540,13 +1683,15 @@ export const makeAccount = (opts) => {
|
|
|
1540
1683
|
'The order could not be placed. Go back to your chat and ask the assistant to try again.',
|
|
1541
1684
|
true,
|
|
1542
1685
|
];
|
|
1686
|
+
const stands = e[3] ?? (e[2] ? 'failed' : 'uncertain');
|
|
1543
1687
|
return {
|
|
1544
1688
|
kind: 'error',
|
|
1545
1689
|
group,
|
|
1546
1690
|
...(logo ? { logo } : {}),
|
|
1547
1691
|
said: e[lang === 'zh' ? 0 : 1].replace(/\{g\}/g, group),
|
|
1548
1692
|
nothing: e[2],
|
|
1549
|
-
...(
|
|
1693
|
+
...(stands === 'uncertain' ? { uncertain: true } : {}),
|
|
1694
|
+
...(stands === 'person' ? { person: true } : {}),
|
|
1550
1695
|
};
|
|
1551
1696
|
};
|
|
1552
1697
|
const asObj = (v) => v && typeof v === 'object' && !Array.isArray(v) ? v : {};
|
|
@@ -1574,7 +1719,9 @@ export const makeAccount = (opts) => {
|
|
|
1574
1719
|
const account = formStr(body.account, LIMITS.account).trim();
|
|
1575
1720
|
const password = formStr(body.password, LIMITS.password);
|
|
1576
1721
|
if (!account || !password)
|
|
1577
|
-
return termsReauth(c, code, r, lang, 'missing_in');
|
|
1722
|
+
return termsReauth(c, code, r, lang, emailOnly ? 'missing_in_email' : 'missing_in');
|
|
1723
|
+
if (notAnEmail(account))
|
|
1724
|
+
return termsReauth(c, code, r, lang, 'email_only');
|
|
1578
1725
|
const named = `a:${account.toLowerCase()}`;
|
|
1579
1726
|
if (nameFailures.shut(named, ACCOUNT_LIMITS.perName)) {
|
|
1580
1727
|
refusals.names++;
|
|
@@ -1631,7 +1778,7 @@ export const makeAccount = (opts) => {
|
|
|
1631
1778
|
setCookie(c, id);
|
|
1632
1779
|
const t = opts.terms.pending(r.key, r.terms.ref);
|
|
1633
1780
|
if (!t)
|
|
1634
|
-
return send(c, 410, termsStatePage(brandPage, lang, 'gone', termsHrefOf(code)));
|
|
1781
|
+
return send(c, 410, termsStatePage(brandPage, lang, 'gone', termsHrefOf(code), undefined, r.terms?.order === true));
|
|
1635
1782
|
return termsView(c, code, r, t, lang);
|
|
1636
1783
|
}
|
|
1637
1784
|
const owner = ownerOf(c, r);
|
|
@@ -1648,12 +1795,24 @@ export const makeAccount = (opts) => {
|
|
|
1648
1795
|
const groupName = before ? groupLabel(before, lang) : brand;
|
|
1649
1796
|
const logo = before ? logoPath(before.group) : undefined;
|
|
1650
1797
|
if (action === 'decline') {
|
|
1798
|
+
// ⚠️ NOT AGREED: the terms go now (`discardTerms`, 0.66.0) - and an order held
|
|
1799
|
+
// back for them is cancelled (总线程 11-11, D). One use, whatever comes back.
|
|
1800
|
+
let order;
|
|
1801
|
+
try {
|
|
1802
|
+
order = (await opts.terms.discard?.(r.key, ref))?.order;
|
|
1803
|
+
}
|
|
1804
|
+
catch {
|
|
1805
|
+
order = before?.changed
|
|
1806
|
+
? { code: before.confirmationCode ?? before.bookingId ?? '', state: 'unknown' }
|
|
1807
|
+
: undefined;
|
|
1808
|
+
}
|
|
1651
1809
|
termsUsed(r);
|
|
1652
|
-
log(`[account] terms declined k=${tag(r.key)} group=${groupCode} → nothing ordered`);
|
|
1810
|
+
log(`[account] terms declined k=${tag(r.key)} group=${groupCode} → ${order ? `order ${order.state}` : 'nothing ordered'}`);
|
|
1653
1811
|
return send(c, 200, termsDonePage(brandPage, lang, code, {
|
|
1654
1812
|
kind: 'declined',
|
|
1655
1813
|
group: groupName,
|
|
1656
1814
|
...(logo ? { logo } : {}),
|
|
1815
|
+
...(order ? { order } : {}),
|
|
1657
1816
|
}));
|
|
1658
1817
|
}
|
|
1659
1818
|
// ⚠️ AGREE: ONE USE, WHATEVER COMES BACK - the terms are gone at the group's end
|
|
@@ -1673,7 +1832,9 @@ export const makeAccount = (opts) => {
|
|
|
1673
1832
|
const next = Array.isArray(st.terms) ? asObj(st.terms[0]) : {};
|
|
1674
1833
|
const nref = asStr(next.ref);
|
|
1675
1834
|
const again = nref ? opts.terms.pending(r.key, nref) : undefined;
|
|
1676
|
-
const made = again
|
|
1835
|
+
const made = again
|
|
1836
|
+
? makeTerms(r.key, nref ?? '', r.lang, again.until, again.changed === true)
|
|
1837
|
+
: undefined;
|
|
1677
1838
|
if (again && made) {
|
|
1678
1839
|
const fresh = termsRequests.find(made.code);
|
|
1679
1840
|
log(`[account] terms agreed k=${tag(r.key)} group=${groupCode} → terms`);
|
|
@@ -1817,7 +1978,11 @@ export const makeAccount = (opts) => {
|
|
|
1817
1978
|
return again('short_password');
|
|
1818
1979
|
}
|
|
1819
1980
|
else if (!values.account || !password)
|
|
1820
|
-
return again('missing_in');
|
|
1981
|
+
return again(emailOnly ? 'missing_in_email' : 'missing_in');
|
|
1982
|
+
// ⚠️ AN EMAIL WHERE ONLY ONE IS TAKEN (0.66.0, 总线程 11-11): said here, before the
|
|
1983
|
+
// name is looked at - nothing is sent, and nothing counts against the name.
|
|
1984
|
+
else if (notAnEmail(values.account))
|
|
1985
|
+
return again('email_only');
|
|
1821
1986
|
// ⚠️ BY THE NAME TOO (Nexva's member_sign_in): one user name's WRONG
|
|
1822
1987
|
// guesses, from however many links and addresses. Only a no from the backend
|
|
1823
1988
|
// counts (C8, robin 11-09); the check here is a look, the try is reserved
|
|
@@ -1882,7 +2047,7 @@ export const makeAccount = (opts) => {
|
|
|
1882
2047
|
catch (e) {
|
|
1883
2048
|
requests.reopen(r);
|
|
1884
2049
|
logRefused(`[account] an account was made for ${tag(r.key)}; signing in refused (${codeOf(e)})`, e);
|
|
1885
|
-
return again('registered_not_signed_in', 'in', { account: typed }, saidBy(e));
|
|
2050
|
+
return again(emailOnly ? 'registered_not_signed_in_email' : 'registered_not_signed_in', 'in', { account: typed }, saidBy(e));
|
|
1886
2051
|
}
|
|
1887
2052
|
}
|
|
1888
2053
|
else {
|
|
@@ -1912,7 +2077,15 @@ export const makeAccount = (opts) => {
|
|
|
1912
2077
|
nameFailures.leave(who, outcome);
|
|
1913
2078
|
}
|
|
1914
2079
|
// ⚠️ WHAT THE SIGN-IN SAID, AND NOTHING ELSE (0.62.0): there is no /member/info.
|
|
1915
|
-
|
|
2080
|
+
// Just registered here: shown by the user name and nickname they gave (0.66.0).
|
|
2081
|
+
const s = signInWith(r.key, shownOf(got.session, got.profile, typed, up ? { userName: values.userName, nickname: values.nickname } : undefined), got.session,
|
|
2082
|
+
// The guest's details, for a booking (0.67.0) - in memory, with this sign-in.
|
|
2083
|
+
profileOf(got.profile, up
|
|
2084
|
+
? {
|
|
2085
|
+
...(values.nickname ? { nickname: values.nickname } : {}),
|
|
2086
|
+
...(mobile ? { phone: mobile } : {}),
|
|
2087
|
+
}
|
|
2088
|
+
: undefined));
|
|
1916
2089
|
// Every place taken by a live sign-in: none is pushed out (review P3-3).
|
|
1917
2090
|
if (!s) {
|
|
1918
2091
|
requests.reopen(r);
|
|
@@ -2057,10 +2230,14 @@ export const makeAccount = (opts) => {
|
|
|
2057
2230
|
// `_meta` may reach the model of one that does not. Whichever conversation the
|
|
2058
2231
|
// call names, as the hotel memberships' rows are - in claude.ai the card's calls
|
|
2059
2232
|
// all name the trip.
|
|
2233
|
+
// …and what a booking would take from the account (0.67.0, 总线程 11-11): masked,
|
|
2234
|
+
// the card's 「用会员资料」 line - the whole email and phone stay on the server.
|
|
2235
|
+
const booking = s && cards ? profileShown(s) : undefined;
|
|
2060
2236
|
const facts = s && cards
|
|
2061
2237
|
? {
|
|
2062
2238
|
...(s.shown.userName ? { userName: s.shown.userName } : {}),
|
|
2063
2239
|
...(s.shown.email ? { email: s.shown.email } : {}),
|
|
2240
|
+
...(booking ? { profile: booking } : {}),
|
|
2064
2241
|
}
|
|
2065
2242
|
: undefined;
|
|
2066
2243
|
return {
|
|
@@ -2085,6 +2262,11 @@ export const makeAccount = (opts) => {
|
|
|
2085
2262
|
},
|
|
2086
2263
|
};
|
|
2087
2264
|
},
|
|
2265
|
+
profileFor: (key) => {
|
|
2266
|
+
const s = checked(key);
|
|
2267
|
+
const shown = s ? profileShown(s) : undefined;
|
|
2268
|
+
return s?.profile && shown ? { whole: s.profile, shown } : undefined;
|
|
2269
|
+
},
|
|
2088
2270
|
tokenFor: (key, group) => {
|
|
2089
2271
|
if (!linking)
|
|
2090
2272
|
return undefined;
|