payment-kit 1.20.18 → 1.20.19

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.
@@ -14,6 +14,11 @@ import { VendorFulfillmentService } from '../libs/vendor-util/fulfillment';
14
14
  import { CheckoutSession, Invoice, Subscription } from '../store/models';
15
15
  import { ProductVendor } from '../store/models/product-vendor';
16
16
 
17
+ const VENDOR_DID = {
18
+ launcher: 'z8iZkFBbrVQxZHvcWWB3Sa2TrfGmSeFz9MSU7',
19
+ didnames: 'z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p',
20
+ };
21
+
17
22
  const authAdmin = authenticate<CheckoutSession>({ component: true, roles: ['owner', 'admin'] });
18
23
  const loginAuth = authenticate<CheckoutSession>({ component: true, ensureLogin: true, mine: true });
19
24
 
@@ -25,9 +30,6 @@ const createVendorSchema = Joi.object({
25
30
  app_url: Joi.string().uri().max(512).required(),
26
31
  app_pid: Joi.string().max(255).allow('').optional(),
27
32
  app_logo: Joi.string().max(512).allow('').optional(),
28
- vendor_did: Joi.string()
29
- .pattern(/^(did:abt:)?[1-9A-HJ-NP-Za-km-z]{37}$/)
30
- .required(),
31
33
  status: Joi.string().valid('active', 'inactive').default('active'),
32
34
  metadata: MetadataSchema,
33
35
  }).unknown(false);
@@ -39,9 +41,6 @@ const updateVendorSchema = Joi.object({
39
41
  app_url: Joi.string().uri().max(512).optional(),
40
42
  app_pid: Joi.string().max(255).allow('').optional(),
41
43
  app_logo: Joi.string().max(512).allow('').optional(),
42
- vendor_did: Joi.string()
43
- .pattern(/^(did:abt:)?[1-9A-HJ-NP-Za-km-z]{37}$/)
44
- .required(),
45
44
  status: Joi.string().valid('active', 'inactive').optional(),
46
45
  metadata: MetadataSchema,
47
46
  }).unknown(true);
@@ -144,17 +143,19 @@ async function createVendor(req: any, res: any) {
144
143
 
145
144
  const {
146
145
  vendor_key: vendorKey,
147
- vendor_type: vendorType,
146
+ vendor_type: type,
148
147
  name,
149
148
  description,
150
149
  app_url: appUrl,
151
- vendor_did: vendorDid,
152
150
  metadata,
153
151
  app_pid: appPid,
154
152
  app_logo: appLogo,
155
153
  status,
156
154
  } = value;
157
155
 
156
+ const vendorType = (type || 'launcher') as 'launcher' | 'didnames';
157
+ const vendorDid = VENDOR_DID[vendorType];
158
+
158
159
  const existingVendor = await ProductVendor.findOne({
159
160
  where: { vendor_key: vendorKey },
160
161
  });
@@ -164,18 +165,25 @@ async function createVendor(req: any, res: any) {
164
165
 
165
166
  const blockletJson = await getBlockletJson(appUrl);
166
167
 
168
+ const mountPoint =
169
+ blockletJson?.componentMountPoints?.find((item: any) => item.did === vendorDid)?.mountPoint || '/';
170
+
167
171
  const vendor = await ProductVendor.create({
168
172
  vendor_key: vendorKey,
169
- vendor_type: vendorType || 'launcher',
173
+ vendor_type: vendorType,
170
174
  name,
171
175
  description,
172
176
  app_url: appUrl,
173
- vendor_did: vendorDid?.replace('did:abt:', '').trim(),
177
+ vendor_did: vendorDid,
174
178
  status: status || 'active',
175
179
  app_pid: appPid,
176
180
  app_logo: appLogo,
177
- metadata: metadata || {},
181
+ metadata: {
182
+ ...metadata,
183
+ mountPoint,
184
+ },
178
185
  extends: {
186
+ mountPoint,
179
187
  appId: blockletJson?.appId,
180
188
  appPk: blockletJson?.appPk,
181
189
  },
@@ -208,19 +216,24 @@ async function updateVendor(req: any, res: any) {
208
216
  }
209
217
 
210
218
  const {
211
- vendor_type: vendorType,
219
+ vendor_type: type,
212
220
  name,
213
221
  description,
214
222
  app_url: appUrl,
215
- vendor_did: vendorDid,
216
223
  status,
217
224
  metadata,
218
225
  app_pid: appPid,
219
226
  app_logo: appLogo,
220
227
  } = value;
221
228
 
229
+ const vendorType = (type || 'launcher') as 'launcher' | 'didnames';
230
+ const vendorDid = VENDOR_DID[vendorType];
231
+
222
232
  const blockletJson = await getBlockletJson(appUrl);
223
233
 
234
+ const mountPoint =
235
+ blockletJson?.componentMountPoints?.find((item: any) => item.did === vendorDid)?.mountPoint || '/';
236
+
224
237
  if (req.body.vendorKey && req.body.vendorKey !== vendor.vendor_key) {
225
238
  const existingVendor = await ProductVendor.findOne({
226
239
  where: { vendor_key: req.body.vendorKey },
@@ -236,11 +249,15 @@ async function updateVendor(req: any, res: any) {
236
249
  app_url: appUrl,
237
250
  vendor_did: vendorDid,
238
251
  status,
239
- metadata,
252
+ metadata: {
253
+ ...metadata,
254
+ mountPoint,
255
+ },
240
256
  app_pid: appPid,
241
257
  app_logo: appLogo,
242
258
  vendor_key: req.body.vendor_key,
243
259
  extends: {
260
+ mountPoint,
244
261
  appId: blockletJson?.appId,
245
262
  appPk: blockletJson?.appPk,
246
263
  },
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.20.18
17
+ version: 1.20.19
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.20.18",
3
+ "version": "1.20.19",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "lint": "tsc --noEmit && eslint src api/src --ext .mjs,.js,.jsx,.ts,.tsx",
@@ -56,9 +56,9 @@
56
56
  "@blocklet/error": "^0.2.5",
57
57
  "@blocklet/js-sdk": "^1.16.52-beta-20250912-112002-e3499e9c",
58
58
  "@blocklet/logger": "^1.16.52-beta-20250912-112002-e3499e9c",
59
- "@blocklet/payment-broker-client": "1.20.18",
60
- "@blocklet/payment-react": "1.20.18",
61
- "@blocklet/payment-vendor": "1.20.18",
59
+ "@blocklet/payment-broker-client": "1.20.19",
60
+ "@blocklet/payment-react": "1.20.19",
61
+ "@blocklet/payment-vendor": "1.20.19",
62
62
  "@blocklet/sdk": "^1.16.52-beta-20250912-112002-e3499e9c",
63
63
  "@blocklet/ui-react": "^3.1.41",
64
64
  "@blocklet/uploader": "^0.2.12",
@@ -128,7 +128,7 @@
128
128
  "devDependencies": {
129
129
  "@abtnode/types": "^1.16.52-beta-20250912-112002-e3499e9c",
130
130
  "@arcblock/eslint-config-ts": "^0.3.3",
131
- "@blocklet/payment-types": "1.20.18",
131
+ "@blocklet/payment-types": "1.20.19",
132
132
  "@types/cookie-parser": "^1.4.9",
133
133
  "@types/cors": "^2.8.19",
134
134
  "@types/debug": "^4.1.12",
@@ -175,5 +175,5 @@
175
175
  "parser": "typescript"
176
176
  }
177
177
  },
178
- "gitHead": "94e4020fb0d4121ebf0430de2db1fd642676c8ae"
178
+ "gitHead": "13703fca3eb2151623b303605df104c4a1199741"
179
179
  }
@@ -37,7 +37,7 @@ export default function VendorActions({ data, variant = 'compact', onChange }: V
37
37
  try {
38
38
  setState({ loading: true });
39
39
  const newStatus = data.status === 'active' ? 'inactive' : 'active';
40
- await api.put(`/api/vendors/${data.id}`, { status: newStatus }).then((res: any) => res.data);
40
+ await api.put(`/api/vendors/${data.id}`, { ...data, status: newStatus }).then((res: any) => res.data);
41
41
  Toast.success(t('common.saved'));
42
42
  onChange(state.action);
43
43
  } catch (err) {
@@ -1099,7 +1099,7 @@ export default flat({
1099
1099
  vendorType: '供应商类型',
1100
1100
  vendorTypeRequired: '供应商类型是必填项',
1101
1101
  didnames: 'DID Names',
1102
- launcher: '启动器',
1102
+ launcher: 'Launcher',
1103
1103
  vendorKey: '供应商标识',
1104
1104
  vendorKeyRequired: '供应商标识是必填项',
1105
1105
  vendorKeyHelp: '供应商的唯一标识符',
@@ -30,7 +30,6 @@ interface Vendor {
30
30
  name: string;
31
31
  description: string;
32
32
  app_url: string;
33
- vendor_did?: string;
34
33
  status: 'active' | 'inactive';
35
34
  metadata: Record<string, any>;
36
35
  created_at: string;
@@ -50,7 +49,6 @@ interface VendorFormData {
50
49
  name: string;
51
50
  description: string;
52
51
  app_url: string;
53
- vendor_did?: string;
54
52
  status: 'active' | 'inactive';
55
53
  metadata: Array<{ key: string; value: string }>;
56
54
  app_pid?: string;
@@ -80,13 +78,12 @@ export default function VendorCreate({
80
78
  }
81
79
  : {
82
80
  vendor_key: '',
83
- vendor_type: 'didnames',
81
+ vendor_type: 'launcher',
84
82
  name: '',
85
83
  description: '',
86
84
  app_url: '',
87
- vendor_did: '',
88
85
  status: 'inactive' as const,
89
- metadata: [],
86
+ metadata: [{ key: 'blockletMetaUrl', value: '' }],
90
87
  app_pid: '',
91
88
  app_logo: '',
92
89
  };
@@ -117,16 +114,6 @@ export default function VendorCreate({
117
114
  }
118
115
  };
119
116
 
120
- const validateDid = (did: string | undefined) => {
121
- if (!did) return true; // DID 是可选的
122
- // DID 格式验证
123
- const didPattern = /^(did:abt:)?[1-9A-HJ-NP-Za-km-z]{37}$/;
124
- if (!didPattern.test(did.trim())) {
125
- return t('admin.vendor.vendorDidInvalid');
126
- }
127
- return true;
128
- };
129
-
130
117
  const onSubmit = async (data: VendorFormData) => {
131
118
  try {
132
119
  setLoading(true);
@@ -157,7 +144,6 @@ export default function VendorCreate({
157
144
 
158
145
  const submitData = {
159
146
  ...restData,
160
- vendor_did: restData.vendor_did?.replace('did:abt:', '').trim(),
161
147
  metadata: metadataObj,
162
148
  };
163
149
 
@@ -181,10 +167,6 @@ export default function VendorCreate({
181
167
  // 从响应中获取appPid和appLogo
182
168
  const blockletInfo = await response.json();
183
169
  if (blockletInfo) {
184
- const component = blockletInfo.componentMountPoints?.find((x: any) => x.did === submitData.vendor_did);
185
- if (component && !['', '/'].includes(component.mountPoint) && submitData.metadata) {
186
- submitData.metadata.mountPoint = component.mountPoint;
187
- }
188
170
  submitData.app_pid = blockletInfo.pid || blockletInfo.appPid;
189
171
  submitData.app_logo = blockletInfo.logo || blockletInfo.appLogo;
190
172
  }
@@ -326,24 +308,6 @@ export default function VendorCreate({
326
308
  )}
327
309
  />
328
310
 
329
- <Controller
330
- name="vendor_did"
331
- control={control}
332
- rules={{
333
- required: t('admin.vendor.vendorDidRequired'),
334
- validate: validateDid,
335
- }}
336
- render={({ field }) => (
337
- <TextField
338
- {...field}
339
- label={t('admin.vendor.vendorDid')}
340
- fullWidth
341
- error={!!errors.vendor_did}
342
- helperText={errors.vendor_did?.message || t('admin.vendor.vendorDidHelp')}
343
- />
344
- )}
345
- />
346
-
347
311
  <MetadataForm title={t('common.metadata.label')} />
348
312
 
349
313
  <Controller
@@ -187,7 +187,7 @@ export default function VendorsList() {
187
187
 
188
188
  const handleCopyPublicKey = async () => {
189
189
  try {
190
- await navigator.clipboard.writeText(data.pk);
190
+ await navigator.clipboard.writeText(window.blocklet.appPk);
191
191
  setCopySuccess(true);
192
192
  setTimeout(() => setCopySuccess(false), 2000);
193
193
  } catch (err) {