@harrylabsj/kiwi 0.12.32 → 0.12.33
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/README.md +8 -0
- package/dist/a2a/inquiry-nonce-store.d.ts +12 -1
- package/dist/a2a/inquiry-nonce-store.js +49 -17
- package/dist/a2a/inquiry-nonce-store.js.map +1 -1
- package/dist/a2a/negotiate.d.ts +30 -1
- package/dist/a2a/negotiate.js +121 -32
- package/dist/a2a/negotiate.js.map +1 -1
- package/dist/a2a/node.d.ts +3 -0
- package/dist/a2a/node.js +13 -3
- package/dist/a2a/node.js.map +1 -1
- package/dist/a2a/open-inquiry-session.d.ts +1 -0
- package/dist/a2a/open-inquiry-session.js +3 -1
- package/dist/a2a/open-inquiry-session.js.map +1 -1
- package/dist/a2a/open-inquiry-verifier.js +2 -2
- package/dist/a2a/open-inquiry-verifier.js.map +1 -1
- package/dist/a2a/server/errors.d.ts +4 -3
- package/dist/a2a/server/errors.js +10 -2
- package/dist/a2a/server/errors.js.map +1 -1
- package/dist/a2a/server/merchant-handler.d.ts +41 -1
- package/dist/a2a/server/merchant-handler.js +259 -89
- package/dist/a2a/server/merchant-handler.js.map +1 -1
- package/dist/a2a/server/merchant-procurement.d.ts +90 -0
- package/dist/a2a/server/merchant-procurement.js +75 -0
- package/dist/a2a/server/merchant-procurement.js.map +1 -0
- package/dist/a2a/server/merchant-product-facts.d.ts +2 -0
- package/dist/a2a/server/merchant-product-facts.js.map +1 -1
- package/dist/a2a/server/negotiation-approvals.d.ts +11 -0
- package/dist/a2a/server/negotiation-approvals.js +43 -0
- package/dist/a2a/server/negotiation-approvals.js.map +1 -1
- package/dist/a2a/server/pipeline.js +4 -1
- package/dist/a2a/server/pipeline.js.map +1 -1
- package/dist/a2a/server/server.js +4 -3
- package/dist/a2a/server/server.js.map +1 -1
- package/dist/a2a/server/types.d.ts +2 -1
- package/dist/agent/alipay-native-view.d.ts +27 -0
- package/dist/agent/alipay-native-view.js +113 -0
- package/dist/agent/alipay-native-view.js.map +1 -0
- package/dist/agent/buyer/buyer-tools.d.ts +20 -0
- package/dist/agent/buyer/buyer-tools.js +241 -48
- package/dist/agent/buyer/buyer-tools.js.map +1 -1
- package/dist/agent/buyer/types.d.ts +1 -1
- package/dist/agent/buyer/types.js.map +1 -1
- package/dist/agent/chat-tui.js +16 -1
- package/dist/agent/chat-tui.js.map +1 -1
- package/dist/agent/kernel-builder.d.ts +2 -0
- package/dist/agent/kernel-builder.js +14 -0
- package/dist/agent/kernel-builder.js.map +1 -1
- package/dist/agent/kernel.d.ts +8 -0
- package/dist/agent/kernel.js +67 -1
- package/dist/agent/kernel.js.map +1 -1
- package/dist/buyer-core/a2a-accept-terms.d.ts +11 -0
- package/dist/buyer-core/a2a-accept-terms.js +28 -0
- package/dist/buyer-core/a2a-accept-terms.js.map +1 -0
- package/dist/buyer-core/a2a-knp.d.ts +3 -0
- package/dist/buyer-core/a2a-knp.js +3 -3
- package/dist/buyer-core/a2a-knp.js.map +1 -1
- package/dist/buyer-core/a2a-negotiator.d.ts +16 -0
- package/dist/buyer-core/a2a-negotiator.js +53 -16
- package/dist/buyer-core/a2a-negotiator.js.map +1 -1
- package/dist/buyer-core/a2a-quote-fetcher.d.ts +0 -15
- package/dist/buyer-core/a2a-quote-fetcher.js +10 -15
- package/dist/buyer-core/a2a-quote-fetcher.js.map +1 -1
- package/dist/buyer-core/merchant-index.d.ts +2 -2
- package/dist/buyer-core/merchant-index.js +23 -5
- package/dist/buyer-core/merchant-index.js.map +1 -1
- package/dist/buyer-core/procurement/cases.d.ts +441 -0
- package/dist/buyer-core/procurement/cases.js +457 -0
- package/dist/buyer-core/procurement/cases.js.map +1 -0
- package/dist/buyer-core/procurement/quote-comparison.d.ts +137 -0
- package/dist/buyer-core/procurement/quote-comparison.js +106 -0
- package/dist/buyer-core/procurement/quote-comparison.js.map +1 -0
- package/dist/buyer-core/procurement/quote-normalizer.d.ts +45 -0
- package/dist/buyer-core/procurement/quote-normalizer.js +153 -0
- package/dist/buyer-core/procurement/quote-normalizer.js.map +1 -0
- package/dist/buyer-core/procurement/requirements.d.ts +50 -0
- package/dist/buyer-core/procurement/requirements.js +43 -0
- package/dist/buyer-core/procurement/requirements.js.map +1 -0
- package/dist/buyer-core/procurement/source-observation.d.ts +57 -0
- package/dist/buyer-core/procurement/source-observation.js +54 -0
- package/dist/buyer-core/procurement/source-observation.js.map +1 -0
- package/dist/buyer-core/procurement/store.d.ts +21 -0
- package/dist/buyer-core/procurement/store.js +68 -0
- package/dist/buyer-core/procurement/store.js.map +1 -0
- package/dist/buyer-core/protocol-recovery.d.ts +8 -0
- package/dist/buyer-core/protocol-recovery.js +17 -2
- package/dist/buyer-core/protocol-recovery.js.map +1 -1
- package/dist/buyer-core/quote-quantity.d.ts +5 -0
- package/dist/buyer-core/quote-quantity.js +15 -0
- package/dist/buyer-core/quote-quantity.js.map +1 -0
- package/dist/buyer-core/service.d.ts +71 -3
- package/dist/buyer-core/service.js +271 -28
- package/dist/buyer-core/service.js.map +1 -1
- package/dist/buyer-core/store.d.ts +13 -0
- package/dist/buyer-core/store.js +25 -3
- package/dist/buyer-core/store.js.map +1 -1
- package/dist/cli.js +13 -17
- package/dist/cli.js.map +1 -1
- package/dist/cloud/alipay-collection-http.d.ts +44 -0
- package/dist/cloud/alipay-collection-http.js +111 -0
- package/dist/cloud/alipay-collection-http.js.map +1 -0
- package/dist/cloud/bootstrap.js +77 -12
- package/dist/cloud/bootstrap.js.map +1 -1
- package/dist/cloud/http-router.d.ts +2 -0
- package/dist/cloud/http-router.js +5 -0
- package/dist/cloud/http-router.js.map +1 -1
- package/dist/commerce/receipt/dispatcher.d.ts +2 -1
- package/dist/commerce/receipt/dispatcher.js +18 -0
- package/dist/commerce/receipt/dispatcher.js.map +1 -1
- package/dist/commerce/receipt/receipts.d.ts +7 -0
- package/dist/commerce/receipt/receipts.js +43 -5
- package/dist/commerce/receipt/receipts.js.map +1 -1
- package/dist/discovery/catalog-source/buyer-follows.d.ts +3 -3
- package/dist/discovery/catalog-source/buyer-follows.js +6 -3
- package/dist/discovery/catalog-source/buyer-follows.js.map +1 -1
- package/dist/discovery/catalog-source/kiwi-record.d.ts +2 -0
- package/dist/discovery/catalog-source/kiwi-record.js.map +1 -1
- package/dist/discovery/catalog-source/kiwi-source.js +4 -0
- package/dist/discovery/catalog-source/kiwi-source.js.map +1 -1
- package/dist/handoff/alipay-collection.d.ts +23 -0
- package/dist/handoff/alipay-collection.js +70 -0
- package/dist/handoff/alipay-collection.js.map +1 -0
- package/dist/handoff/order-receipts.js +2 -1
- package/dist/handoff/order-receipts.js.map +1 -1
- package/dist/handoff/ucp-checkout/channel.d.ts +1 -0
- package/dist/handoff/ucp-checkout/channel.js +42 -17
- package/dist/handoff/ucp-checkout/channel.js.map +1 -1
- package/dist/http/merchant-management/api.d.ts +8 -0
- package/dist/http/merchant-management/api.js +309 -3
- package/dist/http/merchant-management/api.js.map +1 -1
- package/dist/http/merchant-management/page.d.ts +1 -0
- package/dist/http/merchant-management/page.js +333 -3
- package/dist/http/merchant-management/page.js.map +1 -1
- package/dist/http/server.js +9 -2
- package/dist/http/server.js.map +1 -1
- package/dist/mcp/cli.d.ts +3 -1
- package/dist/mcp/cli.js +12 -2
- package/dist/mcp/cli.js.map +1 -1
- package/dist/mcp/merchant-runtime-assembly.js +1 -8
- package/dist/mcp/merchant-runtime-assembly.js.map +1 -1
- package/dist/mcp/procurement-tools.d.ts +10 -0
- package/dist/mcp/procurement-tools.js +173 -0
- package/dist/mcp/procurement-tools.js.map +1 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.js +63 -9
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +4 -1
- package/dist/mcp/tools.js +76 -27
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/types.d.ts +1 -0
- package/dist/mcp/types.js.map +1 -1
- package/dist/merchant/application/actor.d.ts +2 -0
- package/dist/merchant/application/actor.js +6 -0
- package/dist/merchant/application/actor.js.map +1 -1
- package/dist/merchant/negotiation-ops.d.ts +2 -0
- package/dist/merchant/negotiation-ops.js +4 -0
- package/dist/merchant/negotiation-ops.js.map +1 -1
- package/dist/merchant/weixin-channel.d.ts +68 -0
- package/dist/merchant/weixin-channel.js +313 -0
- package/dist/merchant/weixin-channel.js.map +1 -0
- package/dist/merchant/workbench-server.js +13 -0
- package/dist/merchant/workbench-server.js.map +1 -1
- package/dist/merchant-core/collection/alipay-store.d.ts +22 -0
- package/dist/merchant-core/collection/alipay-store.js +125 -0
- package/dist/merchant-core/collection/alipay-store.js.map +1 -0
- package/dist/merchant-core/commercial/calculate.js +6 -6
- package/dist/merchant-core/commercial/calculate.js.map +1 -1
- package/dist/merchant-core/operating/repository.d.ts +0 -1
- package/dist/merchant-core/operating/repository.js +2 -17
- package/dist/merchant-core/operating/repository.js.map +1 -1
- package/dist/merchant-core/opportunity/repository.d.ts +0 -1
- package/dist/merchant-core/opportunity/repository.js +2 -17
- package/dist/merchant-core/opportunity/repository.js.map +1 -1
- package/dist/merchant-core/orders/model.d.ts +1 -8
- package/dist/merchant-core/orders/model.js +10 -2
- package/dist/merchant-core/orders/model.js.map +1 -1
- package/dist/merchant-core/orders/repository.d.ts +0 -1
- package/dist/merchant-core/orders/repository.js +3 -18
- package/dist/merchant-core/orders/repository.js.map +1 -1
- package/dist/merchant-core/orders/service.js +34 -8
- package/dist/merchant-core/orders/service.js.map +1 -1
- package/dist/merchant-core/proposal/engine.js +2 -0
- package/dist/merchant-core/proposal/engine.js.map +1 -1
- package/dist/merchant-core/proposal/publish.d.ts +0 -6
- package/dist/merchant-core/proposal/publish.js +37 -3
- package/dist/merchant-core/proposal/publish.js.map +1 -1
- package/dist/merchant-core/proposal/repository.d.ts +0 -7
- package/dist/merchant-core/proposal/repository.js +8 -17
- package/dist/merchant-core/proposal/repository.js.map +1 -1
- package/dist/merchant-core/proposal/types.d.ts +1 -0
- package/dist/merchant-core/proposal/types.js.map +1 -1
- package/dist/merchant-core/rfq/policy.d.ts +1 -0
- package/dist/merchant-core/rfq/policy.js +6 -7
- package/dist/merchant-core/rfq/policy.js.map +1 -1
- package/dist/merchant-core/rfq/repository.d.ts +0 -1
- package/dist/merchant-core/rfq/repository.js +2 -17
- package/dist/merchant-core/rfq/repository.js.map +1 -1
- package/dist/merchant-core/rfq/service.d.ts +2 -1
- package/dist/merchant-core/rfq/service.js +2 -4
- package/dist/merchant-core/rfq/service.js.map +1 -1
- package/dist/merchant-core/storage/transaction.d.ts +4 -11
- package/dist/merchant-core/storage/transaction.js +43 -65
- package/dist/merchant-core/storage/transaction.js.map +1 -1
- package/dist/negotiation/domain/objects.d.ts +2 -0
- package/dist/negotiation/domain/objects.js +3 -0
- package/dist/negotiation/domain/objects.js.map +1 -1
- package/dist/negotiation/ledger/store.d.ts +4 -0
- package/dist/negotiation/ledger/store.js +20 -0
- package/dist/negotiation/ledger/store.js.map +1 -1
- package/dist/product-init.d.ts +1 -0
- package/dist/product-init.js +4 -1
- package/dist/product-init.js.map +1 -1
- package/dist/trust/identity/message-signature.d.ts +1 -1
- package/dist/trust/identity/message-signature.js +6 -1
- package/dist/trust/identity/message-signature.js.map +1 -1
- package/dist/trust/identity/nonce.d.ts +5 -0
- package/dist/trust/identity/nonce.js +2 -0
- package/dist/trust/identity/nonce.js.map +1 -1
- package/dist/weixin/ilink-client.d.ts +3 -2
- package/dist/weixin/ilink-client.js +9 -2
- package/dist/weixin/ilink-client.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IncomingMessage } from "node:http";
|
|
2
|
+
import type { CloudRequestListener } from "./http-router.js";
|
|
3
|
+
export declare const ALIPAY_PRIVATE_PATH = "/buyer/v1/collection/alipay";
|
|
4
|
+
export declare const ALIPAY_LANDING_PREFIX = "/collect/alipay/";
|
|
5
|
+
export interface AlipayCollectionReadBinding {
|
|
6
|
+
negotiationId: string;
|
|
7
|
+
offerId: string;
|
|
8
|
+
version: string;
|
|
9
|
+
agreementId: string;
|
|
10
|
+
termsDigest: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AlipayCollectionQuote {
|
|
13
|
+
version: string;
|
|
14
|
+
totalMinor: number;
|
|
15
|
+
currency: "CNY";
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
}
|
|
18
|
+
/** 读敏感资料时要求单个完整签名与随机 nonce;身份、签名及重放仍由 A2A verifier 验证。 */
|
|
19
|
+
export declare function hasAlipayReadSignature(signatureInput: unknown): boolean;
|
|
20
|
+
type VerifiedCollectionBuyer = {
|
|
21
|
+
merchantId: string;
|
|
22
|
+
buyerPrincipalId: string;
|
|
23
|
+
};
|
|
24
|
+
interface Options {
|
|
25
|
+
merchantId: string;
|
|
26
|
+
verifyBuyer: (req: IncomingMessage, body: Buffer) => Promise<VerifiedCollectionBuyer | "temporarily_unavailable" | undefined>;
|
|
27
|
+
lookup: (input: AlipayCollectionReadBinding & {
|
|
28
|
+
buyerPrincipalId: string;
|
|
29
|
+
}) => AlipayCollectionQuote | undefined;
|
|
30
|
+
current: () => {
|
|
31
|
+
version: string;
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
recipient: string;
|
|
34
|
+
account?: string;
|
|
35
|
+
qrPngBase64?: string;
|
|
36
|
+
} | undefined;
|
|
37
|
+
now?: () => number;
|
|
38
|
+
}
|
|
39
|
+
/** 公开地址仅供安全探测;完整收款资料仅从验签 API 返回。 */
|
|
40
|
+
export declare function createAlipayCollectionHttp(options: Options): {
|
|
41
|
+
landing: CloudRequestListener;
|
|
42
|
+
privateDetails: CloudRequestListener;
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* Copyright 2026 harrylabsj
|
|
2
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
*/
|
|
4
|
+
import { NONCE_RETRY_AFTER_SECONDS } from "../trust/identity/nonce.js";
|
|
5
|
+
import { DEFAULT_COVERED_COMPONENTS, parseSignatureInput } from "../trust/identity/index.js";
|
|
6
|
+
export const ALIPAY_PRIVATE_PATH = "/buyer/v1/collection/alipay";
|
|
7
|
+
export const ALIPAY_LANDING_PREFIX = "/collect/alipay/";
|
|
8
|
+
const PRIVATE_HEADERS = {
|
|
9
|
+
"cache-control": "no-store",
|
|
10
|
+
"referrer-policy": "no-referrer",
|
|
11
|
+
"x-content-type-options": "nosniff",
|
|
12
|
+
"content-security-policy": "default-src 'none'; frame-ancestors 'none'; base-uri 'none'",
|
|
13
|
+
};
|
|
14
|
+
const MAX_SIGNATURE_INPUT_BYTES = 2048;
|
|
15
|
+
/** 读敏感资料时要求单个完整签名与随机 nonce;身份、签名及重放仍由 A2A verifier 验证。 */
|
|
16
|
+
export function hasAlipayReadSignature(signatureInput) {
|
|
17
|
+
if (typeof signatureInput !== "string" || signatureInput.length > MAX_SIGNATURE_INPUT_BYTES)
|
|
18
|
+
return false;
|
|
19
|
+
try {
|
|
20
|
+
const [entry, ...rest] = parseSignatureInput(signatureInput);
|
|
21
|
+
return entry !== undefined && rest.length === 0 && /^[a-f0-9]{32}$/.test(entry.params.nonce ?? "") &&
|
|
22
|
+
DEFAULT_COVERED_COMPONENTS.every((component) => entry.components.includes(component));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function json(res, status, value) {
|
|
29
|
+
res.writeHead(status, { ...PRIVATE_HEADERS, "content-type": "application/json; charset=utf-8" });
|
|
30
|
+
res.end(JSON.stringify(value));
|
|
31
|
+
}
|
|
32
|
+
function bindingFrom(raw) {
|
|
33
|
+
try {
|
|
34
|
+
const input = JSON.parse(raw.toString("utf8"));
|
|
35
|
+
if (input === null || typeof input !== "object" || Array.isArray(input) || Object.keys(input).length !== 5)
|
|
36
|
+
return;
|
|
37
|
+
const { negotiationId, offerId, version, agreementId, termsDigest } = input;
|
|
38
|
+
const id = (v) => typeof v === "string" && /^[a-zA-Z0-9_-]{1,128}$/.test(v);
|
|
39
|
+
if (!id(negotiationId) || !id(offerId) || !id(version) || !id(agreementId) ||
|
|
40
|
+
typeof termsDigest !== "string" || !/^sha256:[0-9a-f]{64}$/.test(termsDigest))
|
|
41
|
+
return;
|
|
42
|
+
return { negotiationId, offerId, version, agreementId, termsDigest };
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function readBinding(req) {
|
|
49
|
+
const chunks = [];
|
|
50
|
+
let size = 0;
|
|
51
|
+
// Do not destroy the connection on iterator early exit: return a bounded error.
|
|
52
|
+
for await (const value of req.iterator({ destroyOnReturn: false })) {
|
|
53
|
+
const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
54
|
+
size += chunk.length;
|
|
55
|
+
if (size > 2048)
|
|
56
|
+
return undefined;
|
|
57
|
+
chunks.push(chunk);
|
|
58
|
+
}
|
|
59
|
+
return Buffer.concat(chunks, size);
|
|
60
|
+
}
|
|
61
|
+
/** 公开地址仅供安全探测;完整收款资料仅从验签 API 返回。 */
|
|
62
|
+
export function createAlipayCollectionHttp(options) {
|
|
63
|
+
const landing = (req, res) => {
|
|
64
|
+
if (req.method !== "HEAD" && req.method !== "GET") {
|
|
65
|
+
res.writeHead(405, { ...PRIVATE_HEADERS, allow: "GET, HEAD" });
|
|
66
|
+
res.end();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
res.writeHead(200, { ...PRIVATE_HEADERS, "content-type": "text/html; charset=utf-8" });
|
|
70
|
+
res.end(req.method === "HEAD" ? undefined : "<!doctype html><html lang=zh-CN><meta charset=utf-8><title>Kiwi 支付宝收款</title><p>如已确认交接,请回到 Kiwi 买家端查看收款指引。本页不收款,也不确认到账。</p></html>");
|
|
71
|
+
};
|
|
72
|
+
const privateDetails = (req, res) => {
|
|
73
|
+
void (async () => {
|
|
74
|
+
if (req.method !== "POST" || req.url !== ALIPAY_PRIVATE_PATH) {
|
|
75
|
+
json(res, 404, { error: "collection_unavailable" });
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const raw = await readBinding(req);
|
|
79
|
+
const binding = raw === undefined ? undefined : bindingFrom(raw);
|
|
80
|
+
if (raw === undefined || binding === undefined) {
|
|
81
|
+
json(res, 400, { error: "invalid_collection_request" });
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const buyer = await options.verifyBuyer(req, raw);
|
|
85
|
+
if (buyer === "temporarily_unavailable") {
|
|
86
|
+
res.setHeader("Retry-After", NONCE_RETRY_AFTER_SECONDS);
|
|
87
|
+
json(res, 503, { error: buyer, retry_after: NONCE_RETRY_AFTER_SECONDS });
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const quote = buyer?.merchantId === options.merchantId
|
|
91
|
+
? options.lookup({ ...binding, buyerPrincipalId: buyer.buyerPrincipalId }) : undefined;
|
|
92
|
+
const config = quote === undefined ? undefined : options.current();
|
|
93
|
+
if (quote === undefined || config?.enabled !== true || config.version !== binding.version || quote.version !== config.version ||
|
|
94
|
+
!(Date.parse(quote.expiresAt) > (options.now ?? Date.now)())) {
|
|
95
|
+
json(res, 404, { error: "collection_unavailable" });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
json(res, 200, { ...quote, recipient: config.recipient,
|
|
99
|
+
...(config.account === undefined ? {} : { account: config.account }),
|
|
100
|
+
...(config.qrPngBase64 === undefined ? {} : { qrPngBase64: config.qrPngBase64 }),
|
|
101
|
+
});
|
|
102
|
+
})().catch(() => {
|
|
103
|
+
if (!res.headersSent)
|
|
104
|
+
json(res, 404, { error: "collection_unavailable" });
|
|
105
|
+
else
|
|
106
|
+
res.destroy();
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return { landing, privateDetails };
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=alipay-collection-http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alipay-collection-http.js","sourceRoot":"","sources":["../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,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,OAAO;gBACzH,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBACjE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC;gBACpD,OAAO;YACT,CAAC;YACD,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS;gBACpD,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpE,GAAG,CAAC,MAAM,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;aACjF,CAAC,CAAC;QACL,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,WAAW;gBAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC;;gBACrE,GAAG,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;AACrC,CAAC"}
|
package/dist/cloud/bootstrap.js
CHANGED
|
@@ -36,12 +36,17 @@ import { DatabaseSync } from "node:sqlite";
|
|
|
36
36
|
import { a2aCardSigningIdentity, createA2aNodeCore, createA2aAuthVerifier } from "../a2a/node.js";
|
|
37
37
|
import { isOpenInquiryIdentity } from "../a2a/open-inquiry-identity.js";
|
|
38
38
|
import { InquiryNonceStore } from "../a2a/inquiry-nonce-store.js";
|
|
39
|
+
import { AlipayCollectionStore } from "../merchant-core/collection/alipay-store.js";
|
|
40
|
+
import { NegotiationApprovalStore } from "../a2a/server/negotiation-approvals.js";
|
|
41
|
+
import { createNegotiationOps } from "../merchant/negotiation-ops.js";
|
|
42
|
+
import { ALIPAY_PRIVATE_PATH, createAlipayCollectionHttp, hasAlipayReadSignature } from "./alipay-collection-http.js";
|
|
39
43
|
import { OpenInquiryLocalPolicy } from "./access/open-inquiry-policy.js";
|
|
40
44
|
import { closeDatabase, closeHttpServer, createCleanup, CleanupError } from "../lifecycle/close.js";
|
|
41
45
|
import { A2A_SIGNING_KEY_FILE, loadA2aSigningIdentityFromFile, loadOrCreateA2aSigningIdentity, toJwsSigningIdentity } from "../a2a/signing-key.js";
|
|
42
46
|
import { publicKeyThumbprint } from "../trust/binding/thumbprint.js";
|
|
43
47
|
import { loadProfile, ProfileError } from "../config/profile.js";
|
|
44
48
|
import { createMerchantManagementApiHandler } from "../http/merchant-management/api.js";
|
|
49
|
+
import { MerchantWeixinChannel } from "../merchant/weixin-channel.js";
|
|
45
50
|
import { createMerchantFeedApiHandler } from "../http/merchant-feed-api.js";
|
|
46
51
|
import { createMerchantFollowApiHandler } from "../http/merchant-follow-api.js";
|
|
47
52
|
import { createMerchantEngagementApiHandler } from "../http/merchant-engagement-api.js";
|
|
@@ -454,6 +459,33 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
454
459
|
: undefined;
|
|
455
460
|
const openInquiryPolicy = new OpenInquiryLocalPolicy(config.dataDir, config.publicOrigin);
|
|
456
461
|
let inquiryNonces;
|
|
462
|
+
const lastNonceWarning = new Map();
|
|
463
|
+
function warnNonceUnavailable(reason, scope) {
|
|
464
|
+
const time = Date.now();
|
|
465
|
+
const signal = `${reason}|${scope}`;
|
|
466
|
+
const last = lastNonceWarning.get(signal);
|
|
467
|
+
if (last !== undefined && time - last < 60_000)
|
|
468
|
+
return;
|
|
469
|
+
lastNonceWarning.set(signal, time);
|
|
470
|
+
log(`[kiwi-cloud] WARNING a2a_nonce_store_unavailable reason=${reason} scope=${scope}; requests fail closed\n`);
|
|
471
|
+
}
|
|
472
|
+
function checkCloudNonce(key, scope) {
|
|
473
|
+
try {
|
|
474
|
+
inquiryNonces ??= new InquiryNonceStore(config.dataDir, { onUnavailable: warnNonceUnavailable });
|
|
475
|
+
}
|
|
476
|
+
catch {
|
|
477
|
+
warnNonceUnavailable("open", scope);
|
|
478
|
+
return "unavailable";
|
|
479
|
+
}
|
|
480
|
+
return inquiryNonces.record(scope === "signed" ? `signed:${key}` : key, scope);
|
|
481
|
+
}
|
|
482
|
+
function cloudNonceStore(scope) {
|
|
483
|
+
return {
|
|
484
|
+
record: (key) => checkCloudNonce(key, scope),
|
|
485
|
+
checkAndSet: (key) => checkCloudNonce(key, scope) === "fresh",
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
let collectionStore;
|
|
457
489
|
const authVerifier = createA2aAuthVerifier({
|
|
458
490
|
mode: config.a2aAuth.mode,
|
|
459
491
|
...(bearerToken !== undefined ? { bearerToken } : {}),
|
|
@@ -461,16 +493,9 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
461
493
|
signingKeyId: signingIdentity?.keyid ?? config.publicOrigin,
|
|
462
494
|
advertisedBase: config.publicOrigin,
|
|
463
495
|
...(config.a2aAuth.mode === "signature" ? {
|
|
496
|
+
signatureNonceStore: cloudNonceStore("signed"),
|
|
464
497
|
openInquiryEnabled: () => !config.a2aKillSwitch && openInquiryPolicy.isEnabled(),
|
|
465
|
-
openInquiryNonceStore:
|
|
466
|
-
try {
|
|
467
|
-
inquiryNonces ??= new InquiryNonceStore(config.dataDir);
|
|
468
|
-
return inquiryNonces.checkAndSet(key);
|
|
469
|
-
}
|
|
470
|
-
catch {
|
|
471
|
-
return false;
|
|
472
|
-
}
|
|
473
|
-
} },
|
|
498
|
+
openInquiryNonceStore: cloudNonceStore("open_inquiry"),
|
|
474
499
|
} : {}),
|
|
475
500
|
// 云端必须按声明 origin 重建目标 URI:平台网关会改写入站 Host(M0 事实 #4)。
|
|
476
501
|
authoritySource: "declared",
|
|
@@ -540,6 +565,9 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
540
565
|
a2aPath: CLOUD_A2A_PATH,
|
|
541
566
|
dataDir: config.dataDir,
|
|
542
567
|
authVerifier,
|
|
568
|
+
...(config.a2aAuth.mode === "signature" && new URL(config.publicOrigin).protocol === "https:" ? {
|
|
569
|
+
alipayCollection: { origin: config.publicOrigin, current: () => collectionStore?.current() },
|
|
570
|
+
} : {}),
|
|
543
571
|
...(a2aSigningIdentity !== undefined ? { signingIdentity: a2aSigningIdentity } : {}),
|
|
544
572
|
...(fileProductSource !== undefined ? { productSource: fileProductSource.source } : {}),
|
|
545
573
|
...(serviceAvailability !== undefined ? { serviceAvailability } : {}),
|
|
@@ -626,10 +654,12 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
626
654
|
const adminOptions = assembly.serverOptions.admin;
|
|
627
655
|
const productsFilePath = config.productsFile;
|
|
628
656
|
const applyPolicyOverride = assembly.service.policyApplier;
|
|
657
|
+
const weixinChannel = adminOptions === undefined ? undefined : new MerchantWeixinChannel({ dataDir: config.dataDir, merchantId: profile.owner_id });
|
|
629
658
|
let managementDb;
|
|
630
659
|
let merchantApiHandler;
|
|
631
660
|
let publicFeedHandler;
|
|
632
661
|
let buyerHandler;
|
|
662
|
+
let alipayLandingHandler;
|
|
633
663
|
let reconciliationTimer;
|
|
634
664
|
let clockTimer;
|
|
635
665
|
let bindingReconcileTimer;
|
|
@@ -655,6 +685,9 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
655
685
|
// 立即 SQLITE_BUSY;WAL 允许单写多读。
|
|
656
686
|
managementDb.exec("PRAGMA journal_mode = WAL");
|
|
657
687
|
managementDb.exec("PRAGMA busy_timeout = 5000");
|
|
688
|
+
if (config.a2aAuth.mode === "signature" && new URL(config.publicOrigin).protocol === "https:") {
|
|
689
|
+
collectionStore = new AlipayCollectionStore(managementDb, profile.owner_id);
|
|
690
|
+
}
|
|
658
691
|
// M1 收尾(D-M0-05/D-M0-08):三个独立迁移账本与 data_grants 在功能装配前
|
|
659
692
|
// 就绪;learning/memory/jobs 任一开启时 CAS 获取实例所有权并心跳续约。
|
|
660
693
|
// 获取失败只关闭新功能并记录原因(X12),现有接待/经营路径保持原行为
|
|
@@ -974,9 +1007,9 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
974
1007
|
merchantId: profile.owner_id,
|
|
975
1008
|
store: feedStore,
|
|
976
1009
|
});
|
|
977
|
-
const
|
|
1010
|
+
const authenticateBuyerRequest = async (request, body) => {
|
|
978
1011
|
const socketTls = request.socket;
|
|
979
|
-
|
|
1012
|
+
return await authVerifier.verify({
|
|
980
1013
|
remoteAddress: request.socket.remoteAddress,
|
|
981
1014
|
authorizationHeader: request.headers.authorization,
|
|
982
1015
|
method: request.method ?? "",
|
|
@@ -985,6 +1018,8 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
985
1018
|
headers: request.headers,
|
|
986
1019
|
body,
|
|
987
1020
|
});
|
|
1021
|
+
};
|
|
1022
|
+
const asVerifiedBuyer = (result) => {
|
|
988
1023
|
if (!result.authenticated ||
|
|
989
1024
|
result.identityVerified !== true ||
|
|
990
1025
|
typeof result.identity !== "string" ||
|
|
@@ -997,6 +1032,7 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
997
1032
|
buyerPrincipalId: result.identity,
|
|
998
1033
|
};
|
|
999
1034
|
};
|
|
1035
|
+
const resolveVerifiedBuyer = async (request, body) => asVerifiedBuyer(await authenticateBuyerRequest(request, body));
|
|
1000
1036
|
const followHandler = createMerchantFollowApiHandler({
|
|
1001
1037
|
merchantId: profile.owner_id,
|
|
1002
1038
|
store: followStore,
|
|
@@ -1013,9 +1049,23 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
1013
1049
|
store: retentionStore,
|
|
1014
1050
|
resolveBuyer: resolveVerifiedBuyer,
|
|
1015
1051
|
});
|
|
1052
|
+
const alipay = collectionStore === undefined || core.resolveAlipayCollection === undefined ? undefined : createAlipayCollectionHttp({
|
|
1053
|
+
merchantId: profile.owner_id,
|
|
1054
|
+
verifyBuyer: async (request, body) => {
|
|
1055
|
+
if (config.a2aKillSwitch || !hasAlipayReadSignature(request.headers["signature-input"]))
|
|
1056
|
+
return undefined;
|
|
1057
|
+
const result = await authenticateBuyerRequest(request, body);
|
|
1058
|
+
return result.protocolCode === "temporarily_unavailable" ? result.protocolCode : asVerifiedBuyer(result);
|
|
1059
|
+
},
|
|
1060
|
+
lookup: core.resolveAlipayCollection,
|
|
1061
|
+
current: () => collectionStore?.current(),
|
|
1062
|
+
});
|
|
1063
|
+
alipayLandingHandler = alipay?.landing;
|
|
1016
1064
|
buyerHandler = (request, response) => {
|
|
1017
1065
|
const pathname = new URL(request.url ?? "/", "http://buyer.internal").pathname;
|
|
1018
|
-
if (pathname ===
|
|
1066
|
+
if (pathname === ALIPAY_PRIVATE_PATH && alipay !== undefined)
|
|
1067
|
+
alipay.privateDetails(request, response);
|
|
1068
|
+
else if (pathname === "/buyer/v1/follow")
|
|
1019
1069
|
followHandler(request, response);
|
|
1020
1070
|
else if (pathname.startsWith("/buyer/v1/privacy-requests")) {
|
|
1021
1071
|
privacyHandler(request, response);
|
|
@@ -1024,6 +1074,7 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
1024
1074
|
engagementHandler(request, response);
|
|
1025
1075
|
};
|
|
1026
1076
|
merchantApiHandler = createMerchantManagementApiHandler({
|
|
1077
|
+
...(weixinChannel !== undefined ? { weixinChannel } : {}),
|
|
1027
1078
|
merchantId: profile.owner_id,
|
|
1028
1079
|
merchantName: profile.name ?? "待设置商家名称",
|
|
1029
1080
|
merchantNameNeedsUpdate: config.merchantNameNeedsUpdate && profile.name === "待设置商家名称",
|
|
@@ -1033,6 +1084,16 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
1033
1084
|
sessions: adminOptions.sessions,
|
|
1034
1085
|
...(adminOptions.secureCookies === true ? { secureCookies: true } : {}),
|
|
1035
1086
|
allowedOrigins: [config.publicOrigin],
|
|
1087
|
+
...(collectionStore === undefined ? {} : {
|
|
1088
|
+
alipayCollection: collectionStore,
|
|
1089
|
+
alipayCollectionOwnerActorId: profile.agent_id,
|
|
1090
|
+
alipayNegotiationApprovals: createNegotiationOps({
|
|
1091
|
+
ledgerDir: path.join(config.dataDir, "a2a"),
|
|
1092
|
+
approvals: NegotiationApprovalStore.forDataDir(config.dataDir),
|
|
1093
|
+
merchantId: profile.owner_id,
|
|
1094
|
+
version: PRODUCT_VERSION,
|
|
1095
|
+
}),
|
|
1096
|
+
}),
|
|
1036
1097
|
listPending: () => adminOptions.surface.listPending(),
|
|
1037
1098
|
mintCandidateConfirmation: (input) => adminOptions.store.createConfirmation(input),
|
|
1038
1099
|
executeDecision: async (input) => {
|
|
@@ -1381,6 +1442,7 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
1381
1442
|
productAuthority: fileProductSource !== undefined ? "file" : "exact",
|
|
1382
1443
|
catalogConnection: directConnection !== undefined,
|
|
1383
1444
|
workbuddyAccess: new URL(config.publicOrigin).hostname.endsWith(".app.workbuddy.host"),
|
|
1445
|
+
weixinChannel: weixinChannel !== undefined,
|
|
1384
1446
|
}));
|
|
1385
1447
|
};
|
|
1386
1448
|
if (signingIdentity !== undefined) {
|
|
@@ -1400,6 +1462,7 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
1400
1462
|
...(merchantApiHandler !== undefined ? { merchantApiHandler } : {}),
|
|
1401
1463
|
...(publicFeedHandler !== undefined ? { publicFeedHandler } : {}),
|
|
1402
1464
|
...(buyerHandler !== undefined ? { buyerHandler } : {}),
|
|
1465
|
+
...(alipayLandingHandler !== undefined ? { alipayLandingHandler } : {}),
|
|
1403
1466
|
trustedPageHandler: createTrustedWorkbenchPageHandler(),
|
|
1404
1467
|
merchantHomePage,
|
|
1405
1468
|
readiness,
|
|
@@ -1464,6 +1527,7 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
1464
1527
|
{ id: "heartbeat", run: () => enrollmentHeartbeat?.stop() },
|
|
1465
1528
|
{ id: "operations_scheduler", run: () => operationsScheduler?.stop() },
|
|
1466
1529
|
{ id: "customer_data_maintenance", run: () => customerDataMaintenance?.stop() },
|
|
1530
|
+
{ id: "weixin_channel", run: () => weixinChannel?.close() },
|
|
1467
1531
|
{ id: "http_server", run: () => closeHttpServer(server) },
|
|
1468
1532
|
{ id: "background_work", after: ["timers"], run: async () => {
|
|
1469
1533
|
await Promise.allSettled([directConnectionWork, bindingReconcileWork]);
|
|
@@ -1504,6 +1568,7 @@ export async function bootstrapCloudRuntime(options = {}) {
|
|
|
1504
1568
|
}
|
|
1505
1569
|
throw err;
|
|
1506
1570
|
}
|
|
1571
|
+
weixinChannel?.restore();
|
|
1507
1572
|
const summary = describeCloudConfig(config);
|
|
1508
1573
|
log(`[kiwi-cloud] listening ${config.bindHost}:${config.port}` +
|
|
1509
1574
|
`(origin=${summary.publicOrigin},a2a=${CLOUD_A2A_PATH},auth=${summary.a2aAuth},` +
|