@xiashe/sdk 0.1.32 → 0.1.34

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/alipayWallet.mjs CHANGED
@@ -278,7 +278,19 @@ async function readPaymentState(resourceUrl, options = {}) {
278
278
  const { statePath } = statePaths(resourceUrl, options);
279
279
  try {
280
280
  const parsed = JSON.parse(await readFile(statePath, 'utf8'));
281
- return parsed && parsed.version === 1 && parsed.resourceDigest === digest(resourceUrl) ? parsed : null;
281
+ if (!parsed || parsed.version !== 1 || parsed.resourceDigest !== digest(resourceUrl)) {
282
+ return null;
283
+ }
284
+ // Earlier bridge releases accidentally kept the host business session in
285
+ // the local retry state. It is required only for the initial official
286
+ // wallet invocation; status queries use their separate query credential.
287
+ // Remove it as soon as an old state file is read.
288
+ if (Object.prototype.hasOwnProperty.call(parsed, 'sessionId')) {
289
+ const { sessionId: _legacySessionId, ...withoutSession } = parsed;
290
+ await writePrivateFile(statePath, `${JSON.stringify(withoutSession)}\n`);
291
+ return withoutSession;
292
+ }
293
+ return parsed;
282
294
  } catch (error) {
283
295
  if (error?.code === 'ENOENT') return null;
284
296
  throw new AlipayWalletError('ALIPAY_PAYMENT_STATE_INVALID', '本地支付宝付款状态无法读取;请重新发起本次付款。');
@@ -804,7 +816,6 @@ export async function payAlipay402Resource(input, options = {}) {
804
816
  version: 1,
805
817
  resourceUrl,
806
818
  resourceDigest: digest(resourceUrl),
807
- sessionId: null,
808
819
  paymentNeededPath: null,
809
820
  createdAt: new Date().toISOString(),
810
821
  updatedAt: new Date().toISOString()
@@ -824,7 +835,6 @@ export async function payAlipay402Resource(input, options = {}) {
824
835
  version: 1,
825
836
  resourceUrl,
826
837
  resourceDigest: digest(resourceUrl),
827
- sessionId,
828
838
  paymentNeededPath: paths.paymentNeededPath,
829
839
  queryCredential: null,
830
840
  merchantResource: {
@@ -843,7 +853,7 @@ export async function payAlipay402Resource(input, options = {}) {
843
853
  // name is intentionally private and random. The exact Payment-Needed
844
854
  // content, original resource URL, and active Agent business session are
845
855
  // what define the payment request.
846
- '--session-id', state.sessionId,
856
+ '--session-id', sessionId,
847
857
  '--file', state.paymentNeededPath,
848
858
  '--resource-url', resourceUrl,
849
859
  '--intent-summary', intentSummary
@@ -920,7 +930,6 @@ export async function queryAlipay402Resource(input, options = {}) {
920
930
  version: 1,
921
931
  resourceUrl,
922
932
  resourceDigest: digest(resourceUrl),
923
- sessionId: null,
924
933
  paymentNeededPath: null,
925
934
  queryCredential: null,
926
935
  status: 'querying',
package/index.mjs CHANGED
@@ -6,7 +6,7 @@ import path from 'node:path';
6
6
  import { ConvexHttpClient } from 'convex/browser';
7
7
  import { anyApi as api } from 'convex/server';
8
8
 
9
- export const VERSION = '0.1.32';
9
+ export const VERSION = '0.1.34';
10
10
 
11
11
  export const DEFAULTS = {
12
12
  cn: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiashe/sdk",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "type": "module",
5
5
  "main": "index.mjs",
6
6
  "exports": {