yakuza0 2.21.9 → 2.21.10-beta.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yakuza0",
3
- "version": "2.21.9",
3
+ "version": "2.21.10-beta.2",
4
4
  "description": "yakuza0 with nuxt",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -103,12 +103,12 @@
103
103
  "tcp-port-used": "^1.0.1",
104
104
  "ua-parser-js": "^0.7.20",
105
105
  "v8-compile-cache": "^2.0.2",
106
- "yakuza1": "2.6.8"
106
+ "yakuza1": "2.6.10-beta.0"
107
107
  },
108
108
  "peerDependencies": {
109
109
  "@rdc/nuxt": "2.15.8-0",
110
110
  "core-js": "3.10.1",
111
111
  "eslint": "7.2.0",
112
- "yakuza1": "2.6.8"
112
+ "yakuza1": "2.6.10-beta.0"
113
113
  }
114
114
  }
@@ -161,5 +161,6 @@ var serverHeaders = exports.serverHeaders = function serverHeaders(_ref4) {
161
161
  // console.log(crossParams.nuxtAppName);
162
162
  // console.log(nuxtAppConf);
163
163
  // console.log(nuxtAppConf.server.gray, 123);
164
- return _ref5 = {}, (0, _defineProperty3.default)(_ref5, _def.variable.isDevHeader, { data: conf.dev ? '1' : '0' }), (0, _defineProperty3.default)(_ref5, _def.variable.akHeader, { data: conf.ak, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.ipHeader, { data: (0, _server.getClientIP)(req, { stupid: false }) }), (0, _defineProperty3.default)(_ref5, _def.variable.adjoinIpHeader, { data: (0, _server.getClientIP)(req, { stupid: true }) }), (0, _defineProperty3.default)(_ref5, _def.variable.svcKeyHeader, { data: nuxtAppConf.svcKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.domainHeader, { data: nuxtAppConf.domain, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieHeader, { data: crossParams.cookie, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieDomainHeader, { data: crossParams.cookieDomain, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieSameSiteHeader, { data: conf.server.cookieSameSite, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.appKeyHeader, { data: crossParams.nuxtAppKey }), (0, _defineProperty3.default)(_ref5, _def.variable.appNameHeader, { data: crossParams.nuxtAppName }), (0, _defineProperty3.default)(_ref5, _def.variable.encryptSwitchHeader, { data: encryptSwitch, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.encryptTypeHeader, { data: conf.security.encrypt, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.helmetHeader, { data: conf.security.helmet.toString(), noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.projectNameHeader, { data: conf.name, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.shareRuleHeader, { data: (0, _stringify2.default)(conf.shareRule) }), (0, _defineProperty3.default)(_ref5, _def.variable.baseURLHeader, { data: baseURL, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.isHttpsHeader, { data: conf.https ? '1' : '0' }), (0, _defineProperty3.default)(_ref5, _def.variable.appCodeHeader, { data: nuxtAppConf.appCode, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.processKeyHeader, { data: conf.processKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.childKeyHeader, { data: conf.childKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.orbCsrfHeader, { data: verifyTk.csrf, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.f5OfflineHeader, { data: nuxtAppConf.server && nuxtAppConf.server.f5Offline, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.servicesHeader, { data: req.headers[_def.variable.servicesHeader], noWarn: true }), (0, _defineProperty3.default)(_ref5, 'Cookie', { data: _server.Cookies.setByStr((0, _defineProperty3.default)({}, _def.variable.orbCsrfCookie, verifyTk.csrf), req.headers.cookie), noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.ddosSwitchHeader, { data: crossParams.ddosSwitch || '', noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.yk0VersionHeader, { data: conf.version || '', noWarn: true }), _ref5;
164
+ var appCode = req.headers[_def.variable.appCodeHeader.toLowerCase()] || nuxtAppConf.appCode;
165
+ return _ref5 = {}, (0, _defineProperty3.default)(_ref5, _def.variable.isDevHeader, { data: conf.dev ? '1' : '0' }), (0, _defineProperty3.default)(_ref5, _def.variable.akHeader, { data: conf.ak, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.ipHeader, { data: (0, _server.getClientIP)(req, { stupid: false }) }), (0, _defineProperty3.default)(_ref5, _def.variable.adjoinIpHeader, { data: (0, _server.getClientIP)(req, { stupid: true }) }), (0, _defineProperty3.default)(_ref5, _def.variable.svcKeyHeader, { data: nuxtAppConf.svcKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.domainHeader, { data: nuxtAppConf.domain, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieHeader, { data: crossParams.cookie, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieDomainHeader, { data: crossParams.cookieDomain, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.cookieSameSiteHeader, { data: conf.server.cookieSameSite, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.appKeyHeader, { data: crossParams.nuxtAppKey }), (0, _defineProperty3.default)(_ref5, _def.variable.appNameHeader, { data: crossParams.nuxtAppName }), (0, _defineProperty3.default)(_ref5, _def.variable.encryptSwitchHeader, { data: encryptSwitch, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.encryptTypeHeader, { data: conf.security.encrypt, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.helmetHeader, { data: conf.security.helmet.toString(), noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.projectNameHeader, { data: conf.name, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.shareRuleHeader, { data: (0, _stringify2.default)(conf.shareRule) }), (0, _defineProperty3.default)(_ref5, _def.variable.baseURLHeader, { data: baseURL, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.isHttpsHeader, { data: conf.https ? '1' : '0' }), (0, _defineProperty3.default)(_ref5, _def.variable.appCodeHeader, { data: appCode, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.processKeyHeader, { data: conf.processKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.childKeyHeader, { data: conf.childKey, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.orbCsrfHeader, { data: verifyTk.csrf, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.f5OfflineHeader, { data: nuxtAppConf.server && nuxtAppConf.server.f5Offline, noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.servicesHeader, { data: req.headers[_def.variable.servicesHeader], noWarn: true }), (0, _defineProperty3.default)(_ref5, 'Cookie', { data: _server.Cookies.setByStr((0, _defineProperty3.default)({}, _def.variable.orbCsrfCookie, verifyTk.csrf), req.headers.cookie), noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.ddosSwitchHeader, { data: crossParams.ddosSwitch || '', noWarn: true }), (0, _defineProperty3.default)(_ref5, _def.variable.yk0VersionHeader, { data: conf.version || '', noWarn: true }), _ref5;
165
166
  };
@@ -1,4 +1,5 @@
1
1
  import {_, qs, gPwd} from 'yakuza1';
2
+ import {mixin} from 'yakuza1/lib/encrypt';
2
3
  import {fetchDownload, blobInfo} from 'yakuza1/lib/blob';
3
4
  // import {mixin} from 'yakuza1/lib/encrypt';
4
5
  import {errMsg} from "yakuza0/config/msg";
@@ -12,6 +13,11 @@ export default async (ctx, inject) => {
12
13
 
13
14
  return {method, arg1, arg2};
14
15
  }
16
+ const isNFS = (fileUrl) => fileUrl.startsWith("NFS_");
17
+ const nfsUrl = (fileUrl) => {
18
+ const url = fileUrl.split("_")[1];
19
+ return mixin.symmetry.CBC.decrypt(url);
20
+ };
15
21
 
16
22
  $http.methods.forEach(method => {
17
23
  tfs[method] = async (url, arg1, arg2) => {
@@ -86,6 +92,19 @@ export default async (ctx, inject) => {
86
92
  }
87
93
  };
88
94
 
95
+ // 拓展serverless对象存储
96
+ tfs.nfs = async (fileUrl, opt) => {
97
+ if (isNFS(fileUrl)) {
98
+ fileUrl = nfsUrl(fileUrl);
99
+ return await tfs.get(`$/feapiv1/nfs/object/get`, {
100
+ ...opt,
101
+ query: {
102
+ fileUrl,
103
+ }
104
+ })
105
+ }
106
+ };
107
+
89
108
  // 拓展平台对象存储
90
109
  tfs.fastdfs.linear = {};
91
110
  tfs.fastdfs.fake = async (fileUrl) => {
@@ -104,7 +123,7 @@ export default async (ctx, inject) => {
104
123
  }
105
124
  };
106
125
 
107
- // 拓展本地图片
126
+ // 拓展本地图片
108
127
  tfs.local = async (fileUrl) => {
109
128
  if (typeof fileUrl === 'string') {
110
129
  if (fileUrl.startsWith('/')) {
@@ -119,6 +138,10 @@ export default async (ctx, inject) => {
119
138
  return (await blobInfo(await obj(...args))).url;
120
139
  };
121
140
 
141
+ obj.base64 = async (...args) => {
142
+ return (await blobInfo(await obj(...args), {base64: {enabled: true}})).base64;
143
+ };
144
+
122
145
  obj.info = async (...args) => {
123
146
  return await blobInfo(await obj(...args))
124
147
  };
@@ -144,11 +167,13 @@ export default async (ctx, inject) => {
144
167
 
145
168
  // expand(tfs);
146
169
  expand(tfs.fastdfs);
170
+ expand(tfs.nfs);
147
171
  expand(tfs.local);
148
172
 
149
173
  tfs.fastdfs.url = async (...args) => {
174
+ const isN = isNFS(args[0]);
150
175
  if ($yk.security.stupid && !$utils.checkServer()) {
151
- return ((await blobInfo(await tfs.fastdfs(...args))).url) || '';
176
+ return (isN ? ((await blobInfo(await tfs.nfs(...args))).url) : ((await blobInfo(await tfs.fastdfs(...args))).url)) || '';
152
177
  } else {
153
178
  const dm = $yk.server.tfs.fastdfs.domain;
154
179
  const dml = dm.length;
@@ -161,6 +186,9 @@ export default async (ctx, inject) => {
161
186
  }
162
187
  let u = (p || '');
163
188
  let url = `${prefix}/apiv2/px/oss/online/${u}`;
189
+ if (isN) {
190
+ url = `${prefix}/apiv2/nfs/file/online/${nfsUrl(u)}`;
191
+ }
164
192
  const q = {
165
193
  // r: gPwd()
166
194
  };
@@ -178,11 +206,42 @@ export default async (ctx, inject) => {
178
206
  };
179
207
 
180
208
  tfs.fastdfs.download = async (fileUrl, filename) => {
181
- const res = await tfs.fastdfs(fileUrl);
209
+ let res;
210
+ if (isNFS(fileUrl)) {
211
+ res = await tfs.nfs(fileUrl);
212
+ } else {
213
+ res = await tfs.fastdfs(fileUrl);
214
+ }
182
215
  if (res) {
183
216
  fetchDownload(res, filename);
184
217
  }
185
218
  };
219
+ tfs.nfs.url = tfs.fastdfs.url
220
+ tfs.nfs.download = tfs.fastdfs.download
221
+ tfs.nfs.upload = async (files) => {
222
+ const formData = new FormData();
223
+ files.forEach(f => {
224
+ formData.append('file', f);
225
+ })
226
+ const res = await $http.post('$/feapiv1/nfs/object/put', formData, {
227
+ timeout: 2000000
228
+ });
229
+
230
+ const data = res?.data;
231
+ if (_.isArray(data)) {
232
+ return _.map(data, v => {
233
+ return v?.url
234
+ })
235
+ // if (data.length === 1) {
236
+ // return data[0]?.url
237
+ // }
238
+ // if (data.length > 1) {
239
+ // return _.map(data, v => {
240
+ // return v?.url
241
+ // })
242
+ // }
243
+ }
244
+ }
186
245
 
187
246
  tfs.local.download = async (fileUrl, filename) => {
188
247
  const res = await tfs.local(fileUrl);