payment-kit 1.17.3 → 1.17.4

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.
@@ -57,7 +57,7 @@ export async function mintNftForCheckoutSession(id: string) {
57
57
  client.getAccountState({ address: wallet.address }),
58
58
  ]);
59
59
 
60
- const preMint = preMintFromFactory({
60
+ const preMint = await preMintFromFactory({
61
61
  factory: formatFactoryState(factoryState as any),
62
62
  inputs: inputs || {},
63
63
  owner: nftOwner,
@@ -12,7 +12,7 @@ export function ensureI18n() {
12
12
  };
13
13
  }
14
14
 
15
- export function contextMiddleware(req: Request, _res: Response, next: NextFunction) {
15
+ export async function contextMiddleware(req: Request, _res: Response, next: NextFunction) {
16
16
  const requestId =
17
17
  (req.headers['x-request-id'] as string) || `req_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
18
18
  let requestedBy = 'system';
@@ -22,7 +22,7 @@ export function contextMiddleware(req: Request, _res: Response, next: NextFuncti
22
22
  const componentDid = req.get('x-component-did');
23
23
  if (sig && componentDid) {
24
24
  const data = typeof req.body === 'undefined' ? {} : req.body;
25
- const verified = verify(data, sig);
25
+ const verified = await verify(data, sig);
26
26
  if (verified) {
27
27
  requestedBy = componentDid;
28
28
  }
@@ -34,7 +34,7 @@ export function authenticate<T extends Model>({ component, roles, record, mine,
34
34
  const sig = req.get('x-component-sig');
35
35
  if (component && sig) {
36
36
  const { data } = getVerifyData(req as any, 'component');
37
- const verified = verify(data, sig);
37
+ const verified = await verify(data, sig);
38
38
  if (!verified) {
39
39
  return res.status(401).json({ error: 'Invalid signature for component call' });
40
40
  }
@@ -56,7 +56,7 @@ export function authenticate<T extends Model>({ component, roles, record, mine,
56
56
  const id = req.params.id || req.query.subscription_id || '';
57
57
  if (embed && token && id) {
58
58
  try {
59
- const verified = wallet.verify(id as string, token as string);
59
+ const verified = await wallet.verify(id as string, token as string);
60
60
  if (!verified) {
61
61
  return res.status(401).json({ error: `Invalid signature for embed: ${id}` });
62
62
  }
@@ -194,8 +194,8 @@ export default flat({
194
194
  },
195
195
 
196
196
  overdraftProtectionExhausted: {
197
- title: 'Insufficient Credit for SubGuard',
198
- body: 'Your subscription to {productName} has insufficient staked credit for SubGuard. Please increase your stake to maintain the service or disable it if no longer needed.',
197
+ title: 'Insufficient Credit for SubGuard',
198
+ body: 'Your subscription to {productName} has insufficient staked credit for SubGuard™. Please increase your stake to maintain the service or disable it if no longer needed.',
199
199
  },
200
200
  },
201
201
  });
package/blocklet.yml CHANGED
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.17.3
17
+ version: 1.17.4
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.17.3",
3
+ "version": "1.17.4",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "eject": "vite eject",
@@ -43,30 +43,30 @@
43
43
  ]
44
44
  },
45
45
  "dependencies": {
46
- "@abtnode/cron": "^1.16.36",
47
- "@arcblock/did": "^1.18.166",
46
+ "@abtnode/cron": "^1.16.37",
47
+ "@arcblock/did": "^1.19.2",
48
48
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
49
- "@arcblock/did-connect": "^2.11.15",
50
- "@arcblock/did-util": "^1.18.166",
51
- "@arcblock/jwt": "^1.18.166",
52
- "@arcblock/ux": "^2.11.15",
53
- "@arcblock/validator": "^1.18.166",
54
- "@blocklet/js-sdk": "^1.16.36",
55
- "@blocklet/logger": "^1.16.36",
56
- "@blocklet/payment-react": "1.17.3",
57
- "@blocklet/sdk": "^1.16.36",
58
- "@blocklet/ui-react": "^2.11.15",
59
- "@blocklet/uploader": "^0.1.62",
60
- "@blocklet/xss": "^0.1.19",
49
+ "@arcblock/did-connect": "^2.11.23",
50
+ "@arcblock/did-util": "^1.19.2",
51
+ "@arcblock/jwt": "^1.19.2",
52
+ "@arcblock/ux": "^2.11.23",
53
+ "@arcblock/validator": "^1.19.2",
54
+ "@blocklet/js-sdk": "^1.16.37",
55
+ "@blocklet/logger": "^1.16.37",
56
+ "@blocklet/payment-react": "1.17.4",
57
+ "@blocklet/sdk": "^1.16.37",
58
+ "@blocklet/ui-react": "^2.11.23",
59
+ "@blocklet/uploader": "^0.1.63",
60
+ "@blocklet/xss": "^0.1.20",
61
61
  "@mui/icons-material": "^5.16.6",
62
62
  "@mui/lab": "^5.0.0-alpha.173",
63
63
  "@mui/material": "^5.16.6",
64
64
  "@mui/system": "^5.16.6",
65
- "@ocap/asset": "^1.18.166",
66
- "@ocap/client": "^1.18.166",
67
- "@ocap/mcrypto": "^1.18.166",
68
- "@ocap/util": "^1.18.166",
69
- "@ocap/wallet": "^1.18.166",
65
+ "@ocap/asset": "^1.19.2",
66
+ "@ocap/client": "^1.19.2",
67
+ "@ocap/mcrypto": "^1.19.2",
68
+ "@ocap/util": "^1.19.2",
69
+ "@ocap/wallet": "^1.19.2",
70
70
  "@stripe/react-stripe-js": "^2.7.3",
71
71
  "@stripe/stripe-js": "^2.4.0",
72
72
  "ahooks": "^3.8.0",
@@ -118,9 +118,9 @@
118
118
  "validator": "^13.12.0"
119
119
  },
120
120
  "devDependencies": {
121
- "@abtnode/types": "^1.16.36",
121
+ "@abtnode/types": "^1.16.37",
122
122
  "@arcblock/eslint-config-ts": "^0.3.3",
123
- "@blocklet/payment-types": "1.17.3",
123
+ "@blocklet/payment-types": "1.17.4",
124
124
  "@types/cookie-parser": "^1.4.7",
125
125
  "@types/cors": "^2.8.17",
126
126
  "@types/debug": "^4.1.12",
@@ -166,5 +166,5 @@
166
166
  "parser": "typescript"
167
167
  }
168
168
  },
169
- "gitHead": "bc8adef7ff5a032048eef64dc1753bcee88acb98"
169
+ "gitHead": "2d25cbcf146ba2195b1c3434ab3f64566f851893"
170
170
  }
@@ -17,6 +17,7 @@ import {
17
17
  RadioGroup,
18
18
  Radio,
19
19
  Link,
20
+ Skeleton,
20
21
  } from '@mui/material';
21
22
  import Dialog from '@arcblock/ux/lib/Dialog';
22
23
  import { EventHandler, useState } from 'react';
@@ -105,6 +106,7 @@ export default function OverdraftProtectionDialog({
105
106
  amount: '0',
106
107
  gas: '0',
107
108
  },
109
+ loading: cycleAmountLoading,
108
110
  } = useRequest(
109
111
  () =>
110
112
  fetchCycleAmount(subscription.id, {
@@ -356,62 +358,91 @@ export default function OverdraftProtectionDialog({
356
358
  </Typography>
357
359
 
358
360
  <Grid container spacing={2} ml={-2} sx={{ mt: -1 }}>
359
- {presetAmounts.map(({ amount: presetAmount, cycles }) => (
360
- <Grid item xs={6} sm={4} key={presetAmount}>
361
- <Card
362
- variant="outlined"
363
- sx={{
364
- height: '100%',
365
- transition: 'all 0.3s',
366
- cursor: 'pointer',
367
- '&:hover': {
368
- transform: 'translateY(-4px)',
369
- boxShadow: 3,
370
- },
371
- ...(amount === presetAmount && !customAmount
372
- ? { borderColor: 'primary.main', borderWidth: 2 }
373
- : {}),
374
- }}>
375
- <CardActionArea
376
- onClick={() => {
377
- methods.setValue('amount', presetAmount);
378
- setCustomAmount(false);
379
- }}
380
- sx={{ height: '100%', p: 1 }}>
381
- <Stack spacing={1} alignItems="center">
382
- <Typography variant="h6" sx={{ fontWeight: 600 }}>
383
- {presetAmount} {currency.symbol}
384
- </Typography>
385
- <Typography variant="caption" color="text.secondary">
386
- {formatEstimatedDuration(cycles)}
387
- </Typography>
388
- </Stack>
389
- </CardActionArea>
390
- </Card>
391
- </Grid>
392
- ))}
393
- <Grid item xs={6} sm={4}>
394
- <Card
395
- variant="outlined"
396
- sx={{
397
- height: '100%',
398
- transition: 'all 0.3s',
399
- cursor: 'pointer',
400
- '&:hover': {
401
- transform: 'translateY(-4px)',
402
- boxShadow: 3,
403
- },
404
- ...(customAmount ? { borderColor: 'primary.main', borderWidth: 2 } : {}),
405
- }}>
406
- <CardActionArea onClick={handleCustomSelect} sx={{ height: '100%', p: 2 }}>
407
- <Stack spacing={1} alignItems="center">
408
- <Typography variant="h6" sx={{ fontWeight: 600 }}>
409
- {t('common.custom')}
410
- </Typography>
411
- </Stack>
412
- </CardActionArea>
413
- </Card>
414
- </Grid>
361
+ {cycleAmountLoading ? (
362
+ // 加载状态的占位
363
+ <>
364
+ {[1, 2, 3, 4, 5].map((key) => (
365
+ <Grid item xs={6} sm={4} key={key}>
366
+ <Card variant="outlined" sx={{ height: '100%' }}>
367
+ <CardActionArea sx={{ height: '100%', p: 1 }}>
368
+ <Stack spacing={1} alignItems="center">
369
+ <Skeleton variant="rectangular" width={80} height={32} />
370
+ <Skeleton width={100} />
371
+ </Stack>
372
+ </CardActionArea>
373
+ </Card>
374
+ </Grid>
375
+ ))}
376
+ <Grid item xs={6} sm={4}>
377
+ <Card variant="outlined" sx={{ height: '100%' }}>
378
+ <CardActionArea sx={{ height: '100%', p: 2 }}>
379
+ <Stack spacing={1} alignItems="center">
380
+ <Skeleton variant="rectangular" width={80} height={24} />
381
+ </Stack>
382
+ </CardActionArea>
383
+ </Card>
384
+ </Grid>
385
+ </>
386
+ ) : (
387
+ <>
388
+ {presetAmounts.map(({ amount: presetAmount, cycles }) => (
389
+ <Grid item xs={6} sm={4} key={presetAmount}>
390
+ <Card
391
+ variant="outlined"
392
+ sx={{
393
+ height: '100%',
394
+ transition: 'all 0.3s',
395
+ cursor: 'pointer',
396
+ '&:hover': {
397
+ transform: 'translateY(-4px)',
398
+ boxShadow: 3,
399
+ },
400
+ ...(amount === presetAmount && !customAmount
401
+ ? { borderColor: 'primary.main', borderWidth: 2 }
402
+ : {}),
403
+ }}>
404
+ <CardActionArea
405
+ onClick={() => {
406
+ methods.setValue('amount', presetAmount);
407
+ setCustomAmount(false);
408
+ }}
409
+ sx={{ height: '100%', p: 1 }}>
410
+ <Stack spacing={1} alignItems="center">
411
+ <Typography variant="h6" sx={{ fontWeight: 600 }}>
412
+ {presetAmount} {currency.symbol}
413
+ </Typography>
414
+ <Typography variant="caption" color="text.secondary">
415
+ {formatEstimatedDuration(cycles)}
416
+ </Typography>
417
+ </Stack>
418
+ </CardActionArea>
419
+ </Card>
420
+ </Grid>
421
+ ))}
422
+ <Grid item xs={6} sm={4}>
423
+ <Card
424
+ variant="outlined"
425
+ sx={{
426
+ height: '100%',
427
+ transition: 'all 0.3s',
428
+ cursor: 'pointer',
429
+ '&:hover': {
430
+ transform: 'translateY(-4px)',
431
+ boxShadow: 3,
432
+ },
433
+ ...(customAmount ? { borderColor: 'primary.main', borderWidth: 2 } : {}),
434
+ }}>
435
+ <CardActionArea onClick={handleCustomSelect} sx={{ height: '100%', p: 2 }}>
436
+ <Stack spacing={1} alignItems="center">
437
+ <Typography variant="h6" sx={{ fontWeight: 600 }}>
438
+ {t('common.custom')}
439
+ </Typography>
440
+ </Stack>
441
+ </CardActionArea>
442
+ </Card>
443
+ </Grid>
444
+ </>
445
+ )}
415
446
  </Grid>
416
447
 
417
448
  {customAmount && (
@@ -652,39 +652,39 @@ export default flat({
652
652
  error: 'Delegate failed',
653
653
  },
654
654
  overdraftProtection: {
655
- title: 'SubGuard',
656
- setting: 'Set SubGuard',
657
- tip: 'To avoid service interruption due to unpaid invoices, you can enable SubGuard by staking. Timely payment will not incur additional fees. Please settle your invoices promptly. If your available stake is insufficient or payment is overdue, we will deduct the amount from your stake and charge a service fee.',
655
+ title: 'SubGuard',
656
+ setting: 'Set SubGuard',
657
+ tip: 'To avoid service interruption due to unpaid invoices, you can enable SubGuard by staking. Timely payment will not incur additional fees. Please settle your invoices promptly. If your available stake is insufficient or payment is overdue, we will deduct the amount from your stake and charge a service fee.',
658
658
  enabled: 'Enabled',
659
659
  disabled: 'Disabled',
660
660
  returnRemaining: 'Return Remaining Stake',
661
661
  returnRemainingTip:
662
- 'Once the remaining stake is returned, the SubGuard will be automatically disabled. Please confirm the action.',
662
+ 'Once the remaining stake is returned, the SubGuard will be automatically disabled. Please confirm the action.',
663
663
  applyRemainingSuccess: 'Stake return application successful',
664
664
  remaining:
665
665
  'Your current remaining stake: {amount} {symbol}, estimated required stake per cycle: {estimateAmount} {symbol}.',
666
666
  noRemaining:
667
- 'No remaining stake available. Please stake at least {estimateAmount} {symbol} as soon as possible to ensure SubGuard is enabled.',
667
+ 'No remaining stake available. Please stake at least {estimateAmount} {symbol} as soon as possible to ensure SubGuard is enabled.',
668
668
  remainingNotEnough:
669
669
  'You have unpaid invoices totaling {due} {symbol}. If not paid, your remaining stake will be insufficient to cover the next invoice. Available stake: {unused} {symbol}. Please stake at least {min} {symbol}.',
670
670
  due: 'Please pay the outstanding amount first',
671
671
  insufficient: 'Insufficient Stake to cover the next invoice, please add stake',
672
- insufficientTip: 'Insufficient Stake, please stake to ensure SubGuard is enabled.',
672
+ insufficientTip: 'Insufficient Stake, please stake to ensure SubGuard is enabled.',
673
673
  intervals: 'cycles',
674
674
  estimatedDuration: '{duration} {unit} est.',
675
675
  rule: 'Rule: N * ( P + Fee )',
676
676
  ruleTip:
677
- 'N is the number of cycles, P is the subscription bill amount, Fee is the SubGuard service fee, the single fee is {gas} {symbol}',
677
+ 'N is the number of cycles, P is the subscription bill amount, Fee is the SubGuard service fee, the single fee is {gas} {symbol}',
678
678
  min: 'The amount must be greater or equal to {min} {symbol}',
679
- settingSuccess: 'Set SubGuard Successful',
680
- settingError: 'Set SubGuard Failed',
681
- keepStake: 'Keep Remaining Stake For SubGuard',
679
+ settingSuccess: 'Set SubGuard Successful',
680
+ settingError: 'Set SubGuard Failed',
681
+ keepStake: 'Keep Remaining Stake For SubGuard',
682
682
  returnStake: 'Return Remaining Stake',
683
683
  stake: 'Stake',
684
684
  address: 'Staking Address',
685
685
  total: 'Total Stake: {total} {symbol}, ',
686
686
  disableConfirm: 'You currently have unpaid invoices, please settle your invoices first.',
687
- open: 'Enable SubGuard',
687
+ open: 'Enable SubGuard',
688
688
  payerAddress: 'Payer',
689
689
  stakingAddress: 'Staking Address',
690
690
  },