@curless/hotel-storefront 0.80.2 → 0.81.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 +14 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +427 -43
- package/dist/account/index.js.map +1 -1
- package/dist/account/pages.d.ts +15 -2
- package/dist/account/pages.d.ts.map +1 -1
- package/dist/account/pages.js +13 -10
- package/dist/account/pages.js.map +1 -1
- package/dist/account/wallet-pages.d.ts +84 -0
- package/dist/account/wallet-pages.d.ts.map +1 -0
- package/dist/account/wallet-pages.js +229 -0
- package/dist/account/wallet-pages.js.map +1 -0
- package/dist/account/wallet.d.ts +163 -0
- package/dist/account/wallet.d.ts.map +1 -0
- package/dist/account/wallet.js +365 -0
- package/dist/account/wallet.js.map +1 -0
- package/dist/backend.d.ts +18 -0
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js.map +1 -1
- package/dist/card-v168.generated.d.ts +6 -0
- package/dist/card-v168.generated.d.ts.map +1 -0
- package/dist/card-v168.generated.js +10 -0
- package/dist/card-v168.generated.js.map +1 -0
- 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 +48 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -1
- package/dist/config.js.map +1 -1
- package/dist/huazhu/ari-sync.d.ts.map +1 -1
- package/dist/huazhu/ari-sync.js +15 -4
- package/dist/huazhu/ari-sync.js.map +1 -1
- package/dist/huazhu/check.d.ts.map +1 -1
- package/dist/huazhu/check.js +4 -1
- package/dist/huazhu/check.js.map +1 -1
- package/dist/huazhu/client.d.ts +48 -2
- package/dist/huazhu/client.d.ts.map +1 -1
- package/dist/huazhu/client.js +263 -3
- package/dist/huazhu/client.js.map +1 -1
- package/dist/huazhu/make.d.ts.map +1 -1
- package/dist/huazhu/make.js +6 -1
- package/dist/huazhu/make.js.map +1 -1
- package/dist/legal.d.ts.map +1 -1
- package/dist/legal.js +26 -4
- package/dist/legal.js.map +1 -1
- package/dist/otaless/client.d.ts +109 -0
- package/dist/otaless/client.d.ts.map +1 -1
- package/dist/otaless/client.js +44 -4
- package/dist/otaless/client.js.map +1 -1
- package/dist/otaless/fake.d.ts +92 -0
- package/dist/otaless/fake.d.ts.map +1 -1
- package/dist/otaless/fake.js +265 -0
- package/dist/otaless/fake.js.map +1 -1
- package/dist/otaless/make.d.ts +40 -1
- package/dist/otaless/make.d.ts.map +1 -1
- package/dist/otaless/make.js +150 -2
- package/dist/otaless/make.js.map +1 -1
- package/dist/otaless/shop-answers.d.ts +72 -0
- package/dist/otaless/shop-answers.d.ts.map +1 -0
- package/dist/otaless/shop-answers.js +344 -0
- package/dist/otaless/shop-answers.js.map +1 -0
- package/dist/otaless/shop-client.d.ts +133 -0
- package/dist/otaless/shop-client.d.ts.map +1 -0
- package/dist/otaless/shop-client.js +201 -0
- package/dist/otaless/shop-client.js.map +1 -0
- package/dist/otaless/shop-fake.d.ts +100 -0
- package/dist/otaless/shop-fake.d.ts.map +1 -0
- package/dist/otaless/shop-fake.js +259 -0
- package/dist/otaless/shop-fake.js.map +1 -0
- package/dist/otaless/shop-service.d.ts +105 -0
- package/dist/otaless/shop-service.d.ts.map +1 -0
- package/dist/otaless/shop-service.js +187 -0
- package/dist/otaless/shop-service.js.map +1 -0
- package/dist/otaless/shop.d.ts +160 -0
- package/dist/otaless/shop.d.ts.map +1 -0
- package/dist/otaless/shop.js +715 -0
- package/dist/otaless/shop.js.map +1 -0
- package/dist/otaless/wallet.d.ts +160 -0
- package/dist/otaless/wallet.d.ts.map +1 -0
- package/dist/otaless/wallet.js +650 -0
- package/dist/otaless/wallet.js.map +1 -0
- package/dist/server.d.ts +14 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +41 -12
- package/dist/server.js.map +1 -1
- package/dist/surface.d.ts +7 -0
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +14 -0
- package/dist/surface.js.map +1 -1
- package/dist/tools.d.ts +98 -93
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +239 -1
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/account/index.js
CHANGED
|
@@ -9,6 +9,8 @@ import { LIMITS, OTA_PATHS, OtaMemberError, linkOf, makeOtaMembers, maskLabel, m
|
|
|
9
9
|
import { PAGE_HEADERS, accountPage, linkGroupPage, linkReauthPage, linkedPage, loginPage, say, signedInPage, statePage, termsDonePage, termsPage, termsStatePage, } from './pages.js';
|
|
10
10
|
import { CODE, createSignIns, hashOf, same, } from './requests.js';
|
|
11
11
|
import { AccountStore, WEB_IDLE_MS, WebSessions, nameShown, nicknameOf, profileOf, profileShown, shownOf, } from './store.js';
|
|
12
|
+
import { WALLET_CSS, addCardPage, confirmPage, confirmWords, noteOf, walletBlocks, } from './wallet-pages.js';
|
|
13
|
+
import { centsOfUsd, limitOf, makeWalletPart, usd as usdOfCents, } from './wallet.js';
|
|
12
14
|
// THE ACCOUNT: signing in to the deployment's own account - for Otaless, the hotel
|
|
13
15
|
// backend's own (`/ota/register`, `/ota/sign-in`, `/ota/sign-out`: 0.62.0, robin
|
|
14
16
|
// 11-10: 「ota 的登陆注册都是这个里面的…渠道和平台应该是一个接口」; the mall's
|
|
@@ -120,6 +122,17 @@ export const SIGN_IN_META_KEY = 'curless/account-sign-in';
|
|
|
120
122
|
/** …and beside a membership link's answer (0.58.0): the link and its group - no code (0.61.0). */
|
|
121
123
|
export const LINK_META_KEY = 'curless/account-link';
|
|
122
124
|
export const COOKIE = '__Host-hotel_account';
|
|
125
|
+
/**
|
|
126
|
+
* ⚠️ ONE COOKIE NAME PER DEPLOYMENT ON A SHARED ORIGIN (0.81.0, the Claude-only Otaless process
|
|
127
|
+
* at mcp.otaless.ai/claude beside the one at mcp.otaless.ai): a `__Host-` cookie is always
|
|
128
|
+
* `Path=/`, so two account pages on one host would each read the other's session id, find
|
|
129
|
+
* none, and sign the browser out of it. A deployment at the host's root keeps `COOKIE` as it
|
|
130
|
+
* was (its signed-in browsers stay signed in); one under a path gets that path in the name.
|
|
131
|
+
*/
|
|
132
|
+
export const cookieFor = (basePath) => {
|
|
133
|
+
const tail = basePath.replace(/^\/+|\/+$/g, '').replace(/[^A-Za-z0-9]+/g, '_');
|
|
134
|
+
return tail ? `${COOKIE}_${tail}` : COOKIE;
|
|
135
|
+
};
|
|
123
136
|
/** How many of what, and over how long - each refusal said as "too many requests". */
|
|
124
137
|
/** Accounts whose links are remembered (`account-links.json`): the one touched longest ago goes first. */
|
|
125
138
|
const MAX_REMEMBERED_ACCOUNTS = 20_000;
|
|
@@ -409,6 +422,7 @@ export const makeAccount = (opts) => {
|
|
|
409
422
|
const publicUrl = opts.publicUrl.replace(/\/+$/, '');
|
|
410
423
|
const origin = new URL(publicUrl).origin;
|
|
411
424
|
const base = new URL(publicUrl).pathname.replace(/\/+$/, '');
|
|
425
|
+
const cookie = cookieFor(base);
|
|
412
426
|
const brandPage = {
|
|
413
427
|
brand: opts.brand,
|
|
414
428
|
base,
|
|
@@ -891,6 +905,206 @@ export const makeAccount = (opts) => {
|
|
|
891
905
|
* held to our own day (`MAX_SESSION_S`), and two idle hours (store.ts).
|
|
892
906
|
*/
|
|
893
907
|
const checked = (key) => store.get(key);
|
|
908
|
+
// ⚠️ THE CONVERSATION'S OWN SIGN-IN AT THAT GROUP (see `Account.bookingAuth`).
|
|
909
|
+
// `account`: their member_user id as the digits they sent (ota-member.ts
|
|
910
|
+
// `exactId`) - with none given, who `shownOf` says. ⚠️ THE TOKEN IS THE
|
|
911
|
+
// CONVERSATION'S ONE, the latest sign-in's (0.72.0); the `Mcp-Session-Id` is still
|
|
912
|
+
// the group's own sign-in's (whether a newer sign-in replaces it too is questions #77).
|
|
913
|
+
const bookingAuth = (key, group) => {
|
|
914
|
+
const s = store.get(key);
|
|
915
|
+
if (!s)
|
|
916
|
+
return undefined;
|
|
917
|
+
const code = group.trim().toLowerCase();
|
|
918
|
+
const account = s.platform.memberUserId || s.shown.id;
|
|
919
|
+
const l = linking ? liveLink(s, code) : undefined;
|
|
920
|
+
if (l)
|
|
921
|
+
return {
|
|
922
|
+
token: s.platform.access,
|
|
923
|
+
...(l.mcpSessionId ? { mcpSessionId: l.mcpSessionId } : {}),
|
|
924
|
+
account,
|
|
925
|
+
};
|
|
926
|
+
// ⚠️ THE ACCOUNT'S OWN SIGN-IN BOOKS EVERY GROUP (0.74.0, robin 11-17: 「登陆平台就好,酒店
|
|
927
|
+
// 预订不需要每次登陆」): no group is asked to be linked before it is booked - its token
|
|
928
|
+
// goes, and the backend finds the group's linked credentials itself (its document:
|
|
929
|
+
// 「memberToken 为空时从 Redis 渠道凭据包取绑定的 mcpToken」, questions #78). Where it
|
|
930
|
+
// says the group is not linked (its 4012 again after a handshake, or its own words),
|
|
931
|
+
// booking.ts asks for the link then. The `Mcp-Session-Id`: a live link's, the account's
|
|
932
|
+
// own where it signed in on that group's channel, else none - booking.ts makes one (16).
|
|
933
|
+
return {
|
|
934
|
+
token: s.platform.access,
|
|
935
|
+
...(s.platform.provider === code && s.platform.mcpSessionId
|
|
936
|
+
? { mcpSessionId: s.platform.mcpSessionId }
|
|
937
|
+
: {}),
|
|
938
|
+
account,
|
|
939
|
+
};
|
|
940
|
+
};
|
|
941
|
+
// ── The Otaless wallet (docs/otaless-hotels.md §17) ────────────────────────
|
|
942
|
+
// ⚠️ OFF UNLESS THE DEPLOYMENT PASSES ONE (`data.otaless.wallet`): with none, nothing below is
|
|
943
|
+
// offered, drawn or said - the tools, schemas, instructions and pages are as they were (the
|
|
944
|
+
// frozen listing, otaless-wallet-account-0810-freeze.test.ts). The credential is the account's
|
|
945
|
+
// own token (`bookingAuth`), never logged or returned.
|
|
946
|
+
const walletMeta = (code) => {
|
|
947
|
+
const m = groupOf(code);
|
|
948
|
+
const logo = opts.groupLogo?.(code);
|
|
949
|
+
return {
|
|
950
|
+
code,
|
|
951
|
+
name: m ? groupName(m) : code,
|
|
952
|
+
...(m?.names?.zh ? { names: { zh: m.names.zh } } : {}),
|
|
953
|
+
...(logo ? { logo } : {}),
|
|
954
|
+
};
|
|
955
|
+
};
|
|
956
|
+
// ⚠️ A WALLET GROUP IS A MEMBERSHIP GROUP: its wallet sits with that group's membership row and
|
|
957
|
+
// is there only while the row is linked - a wallet group the account cannot link is a mistake.
|
|
958
|
+
for (const g of opts.wallet?.groups ?? [])
|
|
959
|
+
if (!groupOf(g))
|
|
960
|
+
throw new Error(`account: wallet group "${g}" is not one of account.memberships - the wallet is shown with the group's membership, which must be linkable`);
|
|
961
|
+
const walletPart = opts.wallet
|
|
962
|
+
? makeWalletPart({ wallet: opts.wallet, meta: walletMeta, now, log })
|
|
963
|
+
: undefined;
|
|
964
|
+
/** The account page's wallet block - the page the guest does everything on. */
|
|
965
|
+
const walletUrl = (lang) => `${publicUrl}/account?lang=${lang}#wallet`;
|
|
966
|
+
const walletCtx = (s, key, ip) => ({
|
|
967
|
+
// The same rows the page and the card show: linked, and not one that needs linking again.
|
|
968
|
+
linkedOf: (group) => {
|
|
969
|
+
const code = groupOf(group)?.code;
|
|
970
|
+
return !!code && membershipRows(s, false).some((r) => r.group === code && r.linked);
|
|
971
|
+
},
|
|
972
|
+
credOf: (group) => {
|
|
973
|
+
const a = bookingAuth(key, group);
|
|
974
|
+
return a
|
|
975
|
+
? { token: a.token, ...(a.mcpSessionId ? { session: a.mcpSessionId } : {}) }
|
|
976
|
+
: undefined;
|
|
977
|
+
},
|
|
978
|
+
account: s.platform.memberUserId || s.shown.id,
|
|
979
|
+
key,
|
|
980
|
+
who: { conversation: key, ...(ip ? { address: ip } : {}) },
|
|
981
|
+
});
|
|
982
|
+
const walletSaid = (c, noCards) => groupSaid({ code: c.group, name: c.name, ...(c.names ? { names: c.names } : {}) }, noCards);
|
|
983
|
+
const walletWords = (cards, lang, noCards) => walletPart?.textOf(cards, {
|
|
984
|
+
noCards,
|
|
985
|
+
url: walletUrl(lang),
|
|
986
|
+
...(linking ? { linkTool: names.link } : {}),
|
|
987
|
+
said: (c) => walletSaid(c, noCards),
|
|
988
|
+
}) ?? '';
|
|
989
|
+
/** An answer with the wallets read now: the same facts in the structure (the card's, the model's) and in the words. */
|
|
990
|
+
const withWallets = async (s, key, answer, lang, noCards, ip) => {
|
|
991
|
+
if (!walletPart)
|
|
992
|
+
return answer;
|
|
993
|
+
const wallets = await walletPart.readAll(walletCtx(s, key, ip));
|
|
994
|
+
return {
|
|
995
|
+
...answer,
|
|
996
|
+
text: `${answer.text}\n\n${walletWords(wallets, lang, noCards)}`,
|
|
997
|
+
structured: { ...answer.structured, wallets, walletUrl: walletUrl(lang) },
|
|
998
|
+
};
|
|
999
|
+
};
|
|
1000
|
+
const RESULT_WORDS = {
|
|
1001
|
+
'not-offered': 'that group has no wallet here',
|
|
1002
|
+
'signed-out': 'the guest is not signed in',
|
|
1003
|
+
'not-linked': 'the group membership is not linked just now',
|
|
1004
|
+
busy: 'it is busy or limited just now - try again in a few minutes',
|
|
1005
|
+
unavailable: 'the wallet could not be reached just now',
|
|
1006
|
+
'bad-input': 'what was sent is not valid',
|
|
1007
|
+
'no-such-card': 'that card is not on the account now',
|
|
1008
|
+
declined: 'the group did not accept it',
|
|
1009
|
+
'nothing-to-renew': 'there is nothing to renew',
|
|
1010
|
+
'bad-link': 'the card page could not be made',
|
|
1011
|
+
used: 'that confirmation was already used with other values',
|
|
1012
|
+
};
|
|
1013
|
+
const resultWords = (r) => {
|
|
1014
|
+
const what = {
|
|
1015
|
+
'add-card': 'adding a card',
|
|
1016
|
+
authorize: 'the authorization',
|
|
1017
|
+
limits: 'the change of limits',
|
|
1018
|
+
renew: 'the renewal',
|
|
1019
|
+
'remove-card': 'removing the card',
|
|
1020
|
+
}[r.action];
|
|
1021
|
+
if (r.outcome === 'unknown')
|
|
1022
|
+
return `Not known whether ${what} went through - it was not sent again; the wallet below is as read now. Do not say it is done or that it failed.`;
|
|
1023
|
+
if (r.outcome === 'changed')
|
|
1024
|
+
return 'Nothing was done: the wallet changed since the confirm screen. The wallet below is as read now; the guest asks again from it.';
|
|
1025
|
+
if (r.outcome === 'refused')
|
|
1026
|
+
return `Nothing was done: ${RESULT_WORDS[r.reason ?? 'unavailable']}.`;
|
|
1027
|
+
if (r.action === 'add-card')
|
|
1028
|
+
return 'A one-time page to add a card is ready; the guest opens it from the card. The card number is typed only on that page.';
|
|
1029
|
+
if (r.action === 'remove-card')
|
|
1030
|
+
return `Done: the card was removed.${r.heldUsd && r.heldUsd !== '0.00' ? ` US$${r.heldUsd} of a booking's hold is still on the credit line.` : ''}${r.releasedUsd ? ` US$${r.releasedUsd} of unused credit was released.` : ''}${r.releasedUsd === undefined ? ' The backend gave no released amount; the wallet below is as read now.' : ''}`;
|
|
1031
|
+
return `Done: ${what} went through. An authorization is a credit line, not a deposit.`;
|
|
1032
|
+
};
|
|
1033
|
+
/** The card's wallet steps (`wallet_*`): only the card's own tool reaches here (server.ts refuses a client that draws no card). */
|
|
1034
|
+
const walletAction = async (args, call) => {
|
|
1035
|
+
const { key } = call;
|
|
1036
|
+
const lang = langOf(args.lang) ?? 'en';
|
|
1037
|
+
const s = checked(key);
|
|
1038
|
+
const action = {
|
|
1039
|
+
wallet_add_card: 'add-card',
|
|
1040
|
+
wallet_authorize: 'authorize',
|
|
1041
|
+
wallet_limits: 'limits',
|
|
1042
|
+
wallet_renew: 'renew',
|
|
1043
|
+
wallet_remove_card: 'remove-card',
|
|
1044
|
+
}[String(args.action)];
|
|
1045
|
+
const part = walletPart;
|
|
1046
|
+
if (!part || !action || !s) {
|
|
1047
|
+
const base = await handle(names.view, { ...args, action: 'view' }, call);
|
|
1048
|
+
const result = {
|
|
1049
|
+
action: action ?? 'add-card',
|
|
1050
|
+
outcome: 'refused',
|
|
1051
|
+
reason: s ? 'bad-input' : 'signed-out',
|
|
1052
|
+
};
|
|
1053
|
+
return { ...base, structured: { ...base.structured, walletResult: result } };
|
|
1054
|
+
}
|
|
1055
|
+
const text = (v, re) => (typeof v === 'string' && re.test(v) ? v : undefined);
|
|
1056
|
+
const group = text(args.walletGroup, /^[A-Za-z0-9_-]{1,32}$/) ??
|
|
1057
|
+
(part.groups.length === 1 ? part.groups[0] : undefined);
|
|
1058
|
+
const cardId = text(args.cardId, /^[A-Za-z0-9_-]{1,64}$/);
|
|
1059
|
+
const press = text(args.press, /^[A-Za-z0-9_-]{16,64}$/);
|
|
1060
|
+
const ctx = walletCtx(s, key, call.ip);
|
|
1061
|
+
const bad = { action, outcome: 'refused', reason: 'bad-input' };
|
|
1062
|
+
let result;
|
|
1063
|
+
if (!group)
|
|
1064
|
+
result = bad;
|
|
1065
|
+
else if (action === 'add-card')
|
|
1066
|
+
result = await part.addCard(ctx, { group, lang });
|
|
1067
|
+
else if (action === 'renew')
|
|
1068
|
+
result = cardId ? await part.renew(ctx, { group, cardId }) : bad;
|
|
1069
|
+
else if (action === 'remove-card')
|
|
1070
|
+
result = cardId && press ? await part.removeCard(ctx, { group, cardId, press }) : bad;
|
|
1071
|
+
else if (action === 'authorize') {
|
|
1072
|
+
const amountCents = centsOfUsd(args.amountUsd);
|
|
1073
|
+
result =
|
|
1074
|
+
cardId && press && amountCents !== undefined
|
|
1075
|
+
? await part.authorize(ctx, { group, cardId, amountCents, press })
|
|
1076
|
+
: bad;
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
const perTxn = limitOf(args.perTxnUsd);
|
|
1080
|
+
const perDay = limitOf(args.perDayUsd);
|
|
1081
|
+
// `'unknown'`: the screen showed no current limit (the backend does not give one).
|
|
1082
|
+
const seenOf = (v) => (v === 'unknown' ? 'unknown' : limitOf(v));
|
|
1083
|
+
const seenPerTxn = seenOf(args.seenPerTxnUsd);
|
|
1084
|
+
const seenPerDay = seenOf(args.seenPerDayUsd);
|
|
1085
|
+
result =
|
|
1086
|
+
press &&
|
|
1087
|
+
perTxn !== undefined &&
|
|
1088
|
+
perDay !== undefined &&
|
|
1089
|
+
seenPerTxn !== undefined &&
|
|
1090
|
+
seenPerDay !== undefined
|
|
1091
|
+
? await part.setLimits(ctx, { group, perTxn, perDay, seenPerTxn, seenPerDay, press })
|
|
1092
|
+
: bad;
|
|
1093
|
+
}
|
|
1094
|
+
log(`[account] ${tag(key)} wallet ${action}: ${result.outcome}${result.reason ? ` (${result.reason})` : ''}`);
|
|
1095
|
+
// ⚠️ ONE FRESH READ AFTER THE WRITE: what the guest sees is what the wallet says now.
|
|
1096
|
+
const wallets = await part.readAll(ctx);
|
|
1097
|
+
const base = signedInAnswer(s, '', false);
|
|
1098
|
+
return {
|
|
1099
|
+
text: `${resultWords(result)}\n\n${base.text}\n\n${walletWords(wallets, lang, false)}`,
|
|
1100
|
+
structured: {
|
|
1101
|
+
...base.structured,
|
|
1102
|
+
wallets,
|
|
1103
|
+
walletUrl: walletUrl(lang),
|
|
1104
|
+
walletResult: result,
|
|
1105
|
+
},
|
|
1106
|
+
};
|
|
1107
|
+
};
|
|
894
1108
|
// ── The tools ────────────────────────────────────────────────────────────
|
|
895
1109
|
const NO_PRICE = linking
|
|
896
1110
|
? `Being signed in to ${brand} itself changes no price or room shown here; a hotel group's membership linked to the account (${names.link}) asks that group for its prices as the member.`
|
|
@@ -1132,6 +1346,8 @@ export const makeAccount = (opts) => {
|
|
|
1132
1346
|
const { key, noCards } = call;
|
|
1133
1347
|
// The card's own: the same three, by `action`.
|
|
1134
1348
|
if (name === names.card) {
|
|
1349
|
+
if (walletPart && typeof args.action === 'string' && args.action.startsWith('wallet_'))
|
|
1350
|
+
return walletAction(args, { ...call, noCards: false, fromCard: true });
|
|
1135
1351
|
const act = args.action === 'sign_in'
|
|
1136
1352
|
? names.signIn
|
|
1137
1353
|
: args.action === 'sign_out'
|
|
@@ -1155,7 +1371,7 @@ export const makeAccount = (opts) => {
|
|
|
1155
1371
|
// when it is fresh, and nothing shown where `/ota/info` does not answer.
|
|
1156
1372
|
if (s) {
|
|
1157
1373
|
await infos.get(s.shown.id, s.platform.access);
|
|
1158
|
-
return signedInAnswer(s, '', noCards);
|
|
1374
|
+
return withWallets(s, key, signedInAnswer(s, '', noCards), langOf(args.lang) ?? 'en', !!noCards, call.ip);
|
|
1159
1375
|
}
|
|
1160
1376
|
const waiting = requests.openFor(key);
|
|
1161
1377
|
// ⚠️ THE ASSISTANT, WHERE A CARD IS DRAWN, IS NOT TOLD "NOBODY" (0.56.1,
|
|
@@ -1280,6 +1496,27 @@ export const makeAccount = (opts) => {
|
|
|
1280
1496
|
};
|
|
1281
1497
|
};
|
|
1282
1498
|
const STR = { type: 'string' };
|
|
1499
|
+
const WALLET_ACTIONS = [
|
|
1500
|
+
'wallet_add_card',
|
|
1501
|
+
'wallet_authorize',
|
|
1502
|
+
'wallet_limits',
|
|
1503
|
+
'wallet_renew',
|
|
1504
|
+
'wallet_remove_card',
|
|
1505
|
+
];
|
|
1506
|
+
/** The wallet groups as the descriptions and the words name them. */
|
|
1507
|
+
const walletNamesSaid = (walletPart?.groups ?? []).map((g) => walletMeta(g).name).join(', ');
|
|
1508
|
+
/** The card tool's wallet properties - only with the switch on (the frozen listing). */
|
|
1509
|
+
const walletProps = () => ({
|
|
1510
|
+
walletGroup: { type: 'string', enum: [...(walletPart?.groups ?? [])] },
|
|
1511
|
+
cardId: { type: 'string', pattern: '^[A-Za-z0-9_-]{1,64}$' },
|
|
1512
|
+
amountUsd: { type: 'string', pattern: '^[0-9]{1,4}(\\.[0-9]{1,2})?$' },
|
|
1513
|
+
perTxnUsd: { type: 'string', pattern: '^([0-9]{1,4}(\\.[0-9]{1,2})?|none)$' },
|
|
1514
|
+
perDayUsd: { type: 'string', pattern: '^([0-9]{1,4}(\\.[0-9]{1,2})?|none)$' },
|
|
1515
|
+
// `unknown`: the card showed no current limit (the backend does not give one) - not compared.
|
|
1516
|
+
seenPerTxnUsd: { type: 'string', pattern: '^([0-9]{1,4}(\\.[0-9]{1,2})?|none|unknown)$' },
|
|
1517
|
+
seenPerDayUsd: { type: 'string', pattern: '^([0-9]{1,4}(\\.[0-9]{1,2})?|none|unknown)$' },
|
|
1518
|
+
press: { type: 'string', pattern: '^[A-Za-z0-9_-]{16,64}$' },
|
|
1519
|
+
});
|
|
1283
1520
|
const tools = () => [
|
|
1284
1521
|
{
|
|
1285
1522
|
name: names.signIn,
|
|
@@ -1312,7 +1549,7 @@ export const makeAccount = (opts) => {
|
|
|
1312
1549
|
// That rule is the SERVER INSTRUCTIONS' (`instructions` below, both versions), not this
|
|
1313
1550
|
// description's (0.75.0, T1: OpenAI - a description says what a tool does, not how the
|
|
1314
1551
|
// model should use it).
|
|
1315
|
-
description: `Whether the guest is signed in to their ${brand} account in this conversation, and the name the account goes by (its nickname where it has one). Its contact details are not given: they are on ${brand}'s account page
|
|
1552
|
+
description: `Whether the guest is signed in to their ${brand} account in this conversation, and the name the account goes by (its nickname where it has one). Its contact details are not given: they are on ${brand}'s account page.${walletPart ? ` It also reads the guest's ${walletNamesSaid} wallet, read only: available, authorized, charged and held credit in US dollars, the cards on it (brand, last four digits, expiry), its limits and the latest transactions.` : ''}`,
|
|
1316
1553
|
annotations: {
|
|
1317
1554
|
title: `My ${brand} account`,
|
|
1318
1555
|
readOnlyHint: true,
|
|
@@ -1376,7 +1613,7 @@ export const makeAccount = (opts) => {
|
|
|
1376
1613
|
{
|
|
1377
1614
|
name: names.card,
|
|
1378
1615
|
// The card's own (app-only, server.ts): never offered to the assistant.
|
|
1379
|
-
description: `The booking card's own way to sign in to the ${brand} account, see who is signed in, or sign out - for the conversation the card was drawn for. The same steps as ${names.signIn}, ${linking ? `${names.view}, ${names.signOut} and ${names.link}` : `${names.view} and ${names.signOut}`}, called by the card itself
|
|
1616
|
+
description: `The booking card's own way to sign in to the ${brand} account, see who is signed in, or sign out - for the conversation the card was drawn for. The same steps as ${names.signIn}, ${linking ? `${names.view}, ${names.signOut} and ${names.link}` : `${names.view} and ${names.signOut}`}, called by the card itself.${walletPart ? ` And the ${walletNamesSaid} wallet's steps, each pressed by the guest on the card: add a card, authorize an amount, change limits, renew, remove a card.` : ''}`,
|
|
1380
1617
|
annotations: {
|
|
1381
1618
|
title: `${brand} account (card)`,
|
|
1382
1619
|
readOnlyHint: false,
|
|
@@ -1390,12 +1627,16 @@ export const makeAccount = (opts) => {
|
|
|
1390
1627
|
properties: {
|
|
1391
1628
|
action: {
|
|
1392
1629
|
type: 'string',
|
|
1393
|
-
enum:
|
|
1394
|
-
|
|
1395
|
-
|
|
1630
|
+
enum: [
|
|
1631
|
+
...(linking
|
|
1632
|
+
? ['sign_in', 'view', 'sign_out', 'link', 'join', 'unlink']
|
|
1633
|
+
: ['sign_in', 'view', 'sign_out']),
|
|
1634
|
+
...(walletPart ? WALLET_ACTIONS : []),
|
|
1635
|
+
],
|
|
1396
1636
|
},
|
|
1397
1637
|
lang: { type: 'string', enum: ['zh', 'en'] },
|
|
1398
1638
|
...(linking ? { group: { type: 'string', enum: memberships.map((m) => m.code) } } : {}),
|
|
1639
|
+
...(walletPart ? walletProps() : {}),
|
|
1399
1640
|
},
|
|
1400
1641
|
required: ['action'],
|
|
1401
1642
|
},
|
|
@@ -1423,6 +1664,9 @@ export const makeAccount = (opts) => {
|
|
|
1423
1664
|
accountUrl: STR,
|
|
1424
1665
|
code: STR,
|
|
1425
1666
|
...(linking ? { memberships: { type: 'array' }, group: STR } : {}),
|
|
1667
|
+
...(walletPart
|
|
1668
|
+
? { wallets: { type: 'array' }, walletUrl: STR, walletResult: { type: 'object' } }
|
|
1669
|
+
: {}),
|
|
1426
1670
|
},
|
|
1427
1671
|
required: ['view'],
|
|
1428
1672
|
},
|
|
@@ -1474,6 +1718,7 @@ export const makeAccount = (opts) => {
|
|
|
1474
1718
|
account: { type: 'object' },
|
|
1475
1719
|
accountUrl: STR,
|
|
1476
1720
|
...(linking ? { memberships: { type: 'array' } } : {}),
|
|
1721
|
+
...(walletPart ? { wallets: { type: 'array' }, walletUrl: STR } : {}),
|
|
1477
1722
|
},
|
|
1478
1723
|
required: ['view'],
|
|
1479
1724
|
},
|
|
@@ -1491,10 +1736,14 @@ export const makeAccount = (opts) => {
|
|
|
1491
1736
|
const LINK_SAID = linking
|
|
1492
1737
|
? ` 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.`
|
|
1493
1738
|
: '';
|
|
1739
|
+
const WALLET_SAID = (noCards) => walletPart
|
|
1740
|
+
? ` ${walletNamesSaid.toUpperCase()} WALLET: the account view (${names.view}) also shows the guest's ${walletNamesSaid} wallet - a credit line in US dollars that the guest authorizes on their own bank card, not a deposit. Read it for them when they ask and say what it shows. Adding a card, authorizing an amount, changing limits, renewing and removing a card are done by the guest ${noCards ? 'on the account page whose link the answer gives' : 'on the card or on the account page'}, never by you for them: do not offer to do them, and never say that money was added - an authorization is not a deposit.`
|
|
1741
|
+
: '';
|
|
1494
1742
|
const instructions = (noCards) => (noCards
|
|
1495
1743
|
? `${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 in the chat, nor the email or phone number to sign in or link a membership with; if the guest types one of them, never write it back, whole or in part - not even to say which one to change or not to use again: call it \"the password you typed\" - and tell them to use the page and, as it went into a chat, to choose another, without naming the old one. The name, email and phone number a booking asks for are the booking's own details, not the account's: ask for them in the chat, as that booking tool needs them. 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 and never beside a list of hotels or a search; ${names.signOut} signs them out.${linking ? '' : ' Being signed in changes no price here: say nothing of member rates.'}`
|
|
1496
1744
|
: `${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 in the chat, nor the email or phone number to sign in or link a membership with; if the guest types one of them, never write it back, whole or in part - not even to say which one to change or not to use again: call it \"the password you typed\" - and tell them to use the page and, as it went into a chat, to choose another, without naming the old one. The name, email and phone number a booking asks for are the booking's own details, not the account's: the guest fills them in on the card's booking form. ${names.signOut} signs them out.${linking ? '' : ' Being signed in changes no price here: say nothing of member rates.'}`) +
|
|
1497
|
-
LINK_SAID
|
|
1745
|
+
LINK_SAID +
|
|
1746
|
+
WALLET_SAID(noCards);
|
|
1498
1747
|
// ── The pages ────────────────────────────────────────────────────────────
|
|
1499
1748
|
const send = (c, status, html) => c.html(html, status, PAGE_HEADERS);
|
|
1500
1749
|
const langFor = (c, r, form) => langOf(c.req.query('lang')) ??
|
|
@@ -1515,13 +1764,13 @@ export const makeAccount = (opts) => {
|
|
|
1515
1764
|
const cookieOf = (c) => {
|
|
1516
1765
|
for (const part of String(c.req.header('cookie') ?? '').split(';')) {
|
|
1517
1766
|
const at = part.indexOf('=');
|
|
1518
|
-
if (at > 0 && part.slice(0, at).trim() ===
|
|
1767
|
+
if (at > 0 && part.slice(0, at).trim() === cookie)
|
|
1519
1768
|
return part.slice(at + 1).trim();
|
|
1520
1769
|
}
|
|
1521
1770
|
return null;
|
|
1522
1771
|
};
|
|
1523
|
-
const setCookie = (c, id) => c.header('Set-Cookie', `${
|
|
1524
|
-
const clearCookie = (c) => c.header('Set-Cookie', `${
|
|
1772
|
+
const setCookie = (c, id) => c.header('Set-Cookie', `${cookie}=${id}; Path=/; Max-Age=${WEB_IDLE_MS / 1000}; HttpOnly; Secure; SameSite=Strict`, { append: true });
|
|
1773
|
+
const clearCookie = (c) => c.header('Set-Cookie', `${cookie}=; Path=/; Max-Age=0; HttpOnly; Secure; SameSite=Strict`, {
|
|
1525
1774
|
append: true,
|
|
1526
1775
|
});
|
|
1527
1776
|
const statusOf = (state) => state === 'unknown'
|
|
@@ -2570,6 +2819,149 @@ export const makeAccount = (opts) => {
|
|
|
2570
2819
|
account: !!id,
|
|
2571
2820
|
}));
|
|
2572
2821
|
});
|
|
2822
|
+
/**
|
|
2823
|
+
* The wallet's steps on the account page (`wallet_*` forms): this browser is the account's, the
|
|
2824
|
+
* origin and the CSRF token were checked by the caller. ⚠️ AUTHORIZE, LIMITS AND REMOVE ARE TWO
|
|
2825
|
+
* STEPS: the `wallet_review_*` post draws a confirm page from a FRESH read and makes a
|
|
2826
|
+
* one-time ticket for exactly what it shows (this web session's, ten minutes, one use);
|
|
2827
|
+
* only `wallet_confirm` with that ticket sends anything. A note on the way back is a short
|
|
2828
|
+
* code - no amount, no card digits in the URL.
|
|
2829
|
+
*/
|
|
2830
|
+
const walletPost = async (c, at, body, lang) => {
|
|
2831
|
+
const part = walletPart;
|
|
2832
|
+
if (!part)
|
|
2833
|
+
return send(c, 400, statePage(brandPage, lang, 'checked', plainHref('/account')));
|
|
2834
|
+
const act = formStr(body.action, 40);
|
|
2835
|
+
const group = formStr(body.group, 32);
|
|
2836
|
+
const ctx = walletCtx(at.s, at.ws.key, ipOf(c));
|
|
2837
|
+
const back = (code) => c.redirect(`${base}/account?lang=${lang}&wallet=${code}#wallet`, 303);
|
|
2838
|
+
const nameIn = (code) => {
|
|
2839
|
+
const meta = walletMeta(code);
|
|
2840
|
+
return lang === 'zh' && meta.names?.zh ? meta.names.zh : meta.name;
|
|
2841
|
+
};
|
|
2842
|
+
if (!part.offers(group))
|
|
2843
|
+
return send(c, 400, statePage(brandPage, lang, 'checked', plainHref('/account')));
|
|
2844
|
+
const owner = hashOf(at.id ?? '');
|
|
2845
|
+
const cardId = formStr(body.cardId, 64);
|
|
2846
|
+
const code = (r) => r.outcome === 'done'
|
|
2847
|
+
? 'done'
|
|
2848
|
+
: r.outcome === 'unknown'
|
|
2849
|
+
? 'unknown'
|
|
2850
|
+
: r.outcome === 'changed'
|
|
2851
|
+
? 'changed'
|
|
2852
|
+
: 'refused';
|
|
2853
|
+
if (act === 'wallet_add_card') {
|
|
2854
|
+
const r = await part.addCard(ctx, { group, lang });
|
|
2855
|
+
return send(c, 200, addCardPage(brandPage, lang, {
|
|
2856
|
+
...(r.link ? { url: r.link.url } : {}),
|
|
2857
|
+
minutes: 15,
|
|
2858
|
+
group: nameIn(group),
|
|
2859
|
+
}));
|
|
2860
|
+
}
|
|
2861
|
+
if (act === 'wallet_renew') {
|
|
2862
|
+
if (!cardId)
|
|
2863
|
+
return back('refused');
|
|
2864
|
+
return back(code(await part.renew(ctx, { group, cardId })));
|
|
2865
|
+
}
|
|
2866
|
+
// ── Step one: a fresh read, a confirm page, a ticket.
|
|
2867
|
+
if (act === 'wallet_review_authorize' ||
|
|
2868
|
+
act === 'wallet_review_limits' ||
|
|
2869
|
+
act === 'wallet_review_remove') {
|
|
2870
|
+
const fresh = await part.readGroup(ctx, group, 0);
|
|
2871
|
+
const v = fresh.view;
|
|
2872
|
+
if (!v)
|
|
2873
|
+
return back('refused');
|
|
2874
|
+
const confirm = (ticket, words) => ticket
|
|
2875
|
+
? send(c, 200, confirmPage({
|
|
2876
|
+
b: brandPage,
|
|
2877
|
+
lang,
|
|
2878
|
+
csrf: at.ws.csrf,
|
|
2879
|
+
ticket,
|
|
2880
|
+
group,
|
|
2881
|
+
...words,
|
|
2882
|
+
}))
|
|
2883
|
+
: send(c, 429, statePage(brandPage, lang, 'limited', plainHref('/account')));
|
|
2884
|
+
if (act === 'wallet_review_authorize') {
|
|
2885
|
+
const amountCents = centsOfUsd(formStr(body.amount, 12).trim());
|
|
2886
|
+
const card = v.cards.find((x) => x.id === cardId);
|
|
2887
|
+
if (amountCents === undefined || !card)
|
|
2888
|
+
return back('refused');
|
|
2889
|
+
return confirm(part.issue(owner, { kind: 'authorize', group, cardId, amountCents }), confirmWords.authorize(lang, {
|
|
2890
|
+
usd: usdOfCents(amountCents),
|
|
2891
|
+
brand: card.brand,
|
|
2892
|
+
last4: card.last4,
|
|
2893
|
+
group: nameIn(group),
|
|
2894
|
+
available: usdOfCents(v.credit.availableCents),
|
|
2895
|
+
authorized: usdOfCents(v.credit.authorizedCents),
|
|
2896
|
+
}));
|
|
2897
|
+
}
|
|
2898
|
+
if (act === 'wallet_review_limits') {
|
|
2899
|
+
const field = (x) => {
|
|
2900
|
+
const t = formStr(x, 12).trim();
|
|
2901
|
+
return t === '' ? null : limitOf(t);
|
|
2902
|
+
};
|
|
2903
|
+
const perTxnCents = field(body.perTxn);
|
|
2904
|
+
const perDayCents = field(body.perDay);
|
|
2905
|
+
if (perTxnCents === undefined || perDayCents === undefined)
|
|
2906
|
+
return back('refused');
|
|
2907
|
+
const shown = (n) => (n === null ? null : usdOfCents(n));
|
|
2908
|
+
return confirm(part.issue(owner, {
|
|
2909
|
+
kind: 'limits',
|
|
2910
|
+
group,
|
|
2911
|
+
perTxnCents,
|
|
2912
|
+
perDayCents,
|
|
2913
|
+
seenPerTxnCents: v.limits ? v.limits.perTxnCents : 'unknown',
|
|
2914
|
+
seenPerDayCents: v.limits ? v.limits.perDayCents : 'unknown',
|
|
2915
|
+
}), confirmWords.limits(lang, {
|
|
2916
|
+
group: nameIn(group),
|
|
2917
|
+
perTxn: shown(perTxnCents),
|
|
2918
|
+
perDay: shown(perDayCents),
|
|
2919
|
+
// ⚠️ absent = the page says the current limits cannot be read - never "no limit".
|
|
2920
|
+
...(v.limits
|
|
2921
|
+
? { nowTxn: shown(v.limits.perTxnCents), nowDay: shown(v.limits.perDayCents) }
|
|
2922
|
+
: {}),
|
|
2923
|
+
}));
|
|
2924
|
+
}
|
|
2925
|
+
const card = v.cards.find((x) => x.id === cardId);
|
|
2926
|
+
if (!card)
|
|
2927
|
+
return back('refused');
|
|
2928
|
+
return confirm(part.issue(owner, { kind: 'remove', group, cardId }), confirmWords.remove(lang, {
|
|
2929
|
+
brand: card.brand,
|
|
2930
|
+
last4: card.last4,
|
|
2931
|
+
group: nameIn(group),
|
|
2932
|
+
held: usdOfCents(v.credit.heldCents),
|
|
2933
|
+
}));
|
|
2934
|
+
}
|
|
2935
|
+
// ── Step two: the ticket is taken (used) before anything is sent.
|
|
2936
|
+
if (act === 'wallet_confirm') {
|
|
2937
|
+
const ticketCode = formStr(body.ticket, 64);
|
|
2938
|
+
const t = part.take(owner, ticketCode);
|
|
2939
|
+
if (!t)
|
|
2940
|
+
return back('expired');
|
|
2941
|
+
// The ticket's own group, whatever the form says.
|
|
2942
|
+
const press = ticketCode;
|
|
2943
|
+
const r = t.kind === 'authorize'
|
|
2944
|
+
? await part.authorize(ctx, {
|
|
2945
|
+
group: t.group,
|
|
2946
|
+
cardId: t.cardId,
|
|
2947
|
+
amountCents: t.amountCents,
|
|
2948
|
+
press,
|
|
2949
|
+
})
|
|
2950
|
+
: t.kind === 'limits'
|
|
2951
|
+
? await part.setLimits(ctx, {
|
|
2952
|
+
group: t.group,
|
|
2953
|
+
perTxn: t.perTxnCents,
|
|
2954
|
+
perDay: t.perDayCents,
|
|
2955
|
+
seenPerTxn: t.seenPerTxnCents,
|
|
2956
|
+
seenPerDay: t.seenPerDayCents,
|
|
2957
|
+
press,
|
|
2958
|
+
})
|
|
2959
|
+
: await part.removeCard(ctx, { group: t.group, cardId: t.cardId, press });
|
|
2960
|
+
log(`[account] ${tag(at.ws.key)} wallet ${r.action} on the account page: ${r.outcome}${r.reason ? ` (${r.reason})` : ''}`);
|
|
2961
|
+
return back(code(r));
|
|
2962
|
+
}
|
|
2963
|
+
return send(c, 400, statePage(brandPage, lang, 'checked', plainHref('/account')));
|
|
2964
|
+
};
|
|
2573
2965
|
app.get('/account', async (c) => {
|
|
2574
2966
|
// A group's booking terms, on this same path (0.63.0): told apart by the query.
|
|
2575
2967
|
const termsCode = c.req.query('terms');
|
|
@@ -2589,6 +2981,10 @@ export const makeAccount = (opts) => {
|
|
|
2589
2981
|
// The account's own level, points and growth points (0.73.0): asked for as the page
|
|
2590
2982
|
// opens - from what is known when fresh; nothing shown where it does not answer.
|
|
2591
2983
|
const info = await infos.get(at.s.shown.id, at.s.platform.access);
|
|
2984
|
+
// The wallet, read as the page opens (only with the switch on): the balance alone, fresh.
|
|
2985
|
+
const walletCards = walletPart
|
|
2986
|
+
? await walletPart.readAll(walletCtx(at.s, at.ws.key, ipOf(c)), 0)
|
|
2987
|
+
: undefined;
|
|
2592
2988
|
// Still signed in after the wait? Signed out meanwhile, the page says so.
|
|
2593
2989
|
if (store.get(at.ws.key)?.sid !== at.s.sid) {
|
|
2594
2990
|
clearCookie(c);
|
|
@@ -2612,6 +3008,23 @@ export const makeAccount = (opts) => {
|
|
|
2612
3008
|
: {}),
|
|
2613
3009
|
csrf: at.ws.csrf,
|
|
2614
3010
|
...(c.req.query('note') === 'session' ? { note: 'unlinkedStale' } : {}),
|
|
3011
|
+
...(walletCards
|
|
3012
|
+
? {
|
|
3013
|
+
wallet: {
|
|
3014
|
+
css: WALLET_CSS,
|
|
3015
|
+
subs: walletBlocks({
|
|
3016
|
+
b: brandPage,
|
|
3017
|
+
lang,
|
|
3018
|
+
csrf: at.ws.csrf,
|
|
3019
|
+
cards: walletCards,
|
|
3020
|
+
nameOf: (w) => (lang === 'zh' && w.names?.zh ? w.names.zh : w.name),
|
|
3021
|
+
...(noteOf(c.req.query('wallet'))
|
|
3022
|
+
? { note: noteOf(c.req.query('wallet')) }
|
|
3023
|
+
: {}),
|
|
3024
|
+
}),
|
|
3025
|
+
},
|
|
3026
|
+
}
|
|
3027
|
+
: {}),
|
|
2615
3028
|
// The card's rows, in the page's language and with each group's logo (0.61.0).
|
|
2616
3029
|
...(linking
|
|
2617
3030
|
? {
|
|
@@ -2658,6 +3071,9 @@ export const makeAccount = (opts) => {
|
|
|
2658
3071
|
refusals.csrf++;
|
|
2659
3072
|
return send(c, 403, statePage(brandPage, lang, 'checked', plainHref('/account')));
|
|
2660
3073
|
}
|
|
3074
|
+
// The wallet's steps (only with the switch on): after the origin and CSRF checks above.
|
|
3075
|
+
if (walletPart && typeof body.action === 'string' && body.action.startsWith('wallet_'))
|
|
3076
|
+
return walletPost(c, { id: at.id, ws: at.ws, s: at.s }, body, lang);
|
|
2661
3077
|
// A hotel group's membership, from the account page itself (0.58.0): this
|
|
2662
3078
|
// browser is the account's, so a link is made for it and opened here.
|
|
2663
3079
|
const m = linking ? groupOf(body.group) : undefined;
|
|
@@ -2866,39 +3282,7 @@ export const makeAccount = (opts) => {
|
|
|
2866
3282
|
if (inferLink(s, code))
|
|
2867
3283
|
log(`[account] ${tag(key)}: a booking at ${code} went through - remembered as linked (inferred from the booking)`);
|
|
2868
3284
|
},
|
|
2869
|
-
|
|
2870
|
-
// `account`: their member_user id as the digits they sent (ota-member.ts
|
|
2871
|
-
// `exactId`) - with none given, who `shownOf` says. ⚠️ THE TOKEN IS THE
|
|
2872
|
-
// CONVERSATION'S ONE, the latest sign-in's (0.72.0); the `Mcp-Session-Id` is still
|
|
2873
|
-
// the group's own sign-in's (whether a newer sign-in replaces it too is questions #77).
|
|
2874
|
-
bookingAuth: (key, group) => {
|
|
2875
|
-
const s = store.get(key);
|
|
2876
|
-
if (!s)
|
|
2877
|
-
return undefined;
|
|
2878
|
-
const code = group.trim().toLowerCase();
|
|
2879
|
-
const account = s.platform.memberUserId || s.shown.id;
|
|
2880
|
-
const l = linking ? liveLink(s, code) : undefined;
|
|
2881
|
-
if (l)
|
|
2882
|
-
return {
|
|
2883
|
-
token: s.platform.access,
|
|
2884
|
-
...(l.mcpSessionId ? { mcpSessionId: l.mcpSessionId } : {}),
|
|
2885
|
-
account,
|
|
2886
|
-
};
|
|
2887
|
-
// ⚠️ THE ACCOUNT'S OWN SIGN-IN BOOKS EVERY GROUP (0.74.0, robin 11-17: 「登陆平台就好,酒店
|
|
2888
|
-
// 预订不需要每次登陆」): no group is asked to be linked before it is booked - its token
|
|
2889
|
-
// goes, and the backend finds the group's linked credentials itself (its document:
|
|
2890
|
-
// 「memberToken 为空时从 Redis 渠道凭据包取绑定的 mcpToken」, questions #78). Where it
|
|
2891
|
-
// says the group is not linked (its 4012 again after a handshake, or its own words),
|
|
2892
|
-
// booking.ts asks for the link then. The `Mcp-Session-Id`: a live link's, the account's
|
|
2893
|
-
// own where it signed in on that group's channel, else none - booking.ts makes one (16).
|
|
2894
|
-
return {
|
|
2895
|
-
token: s.platform.access,
|
|
2896
|
-
...(s.platform.provider === code && s.platform.mcpSessionId
|
|
2897
|
-
? { mcpSessionId: s.platform.mcpSessionId }
|
|
2898
|
-
: {}),
|
|
2899
|
-
account,
|
|
2900
|
-
};
|
|
2901
|
-
},
|
|
3285
|
+
bookingAuth,
|
|
2902
3286
|
termsLink,
|
|
2903
3287
|
instructions,
|
|
2904
3288
|
mount,
|