w-converhp 2.0.56 → 2.0.58

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 CHANGED
@@ -221,7 +221,7 @@ downloadLargeFile()
221
221
 
222
222
  [Necessary] Add script for w-converhp-client.
223
223
  ```alias
224
- <script src="https://cdn.jsdelivr.net/npm/w-converhp@2.0.56/dist/w-converhp-client.umd.js"></script>
224
+ <script src="https://cdn.jsdelivr.net/npm/w-converhp@2.0.58/dist/w-converhp-client.umd.js"></script>
225
225
  ```
226
226
 
227
227
  #### Example for w-converhp-client in browser:
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * w-converhp-client v2.0.56
2
+ * w-converhp-client v2.0.58
3
3
  * (c) 2018-2021 yuda-lyu(semisphere)
4
4
  * Released under the MIT License.
5
5
  */
@@ -649,7 +649,7 @@
649
649
  <br class="clear">
650
650
 
651
651
  <footer>
652
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Jul 03 2025 13:34:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
652
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Jul 13 2025 10:18:19 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
653
653
  </footer>
654
654
 
655
655
  <script>prettyPrint();</script>
@@ -1187,7 +1187,7 @@ export default WConverhpClient
1187
1187
  <br class="clear">
1188
1188
 
1189
1189
  <footer>
1190
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Jul 03 2025 13:34:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1190
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Jul 13 2025 10:18:19 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1191
1191
  </footer>
1192
1192
 
1193
1193
  <script>prettyPrint();</script>
@@ -127,7 +127,7 @@
127
127
 
128
128
  <h5 class="h5-examples">Example</h5>
129
129
 
130
- <pre class="prettyprint"><code>import fs from 'fs'
131
130
  port: 8080,
132
131
  apiName: 'api',
133
132
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
134
133
  verifyConn: async ({ apiType, authorization, headers, query }) => {
135
134
  console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
136
135
  let token = w.strdelleft(authorization, 7) //刪除Bearer
137
136
  if (!w.isestr(token)) {
138
137
  return false
139
138
  }
140
139
  // await w.delay(3000)
141
140
  return true
142
141
  },
143
142
  // console.log(`Server[port:${opt.port}]: execute`, func, input)
144
143
  console.log(`Server[port:${opt.port}]: execute`, func)
145
144
  try {
146
145
  if (func === 'add') {
147
146
  if (_.get(input, 'p.d.u8a', null)) {
148
147
  console.log('input.p.d.u8a', input.p.d.u8a)
149
148
  ms.push({ 'input.p.d.u8a': input.p.d.u8a })
150
149
  }
151
150
  let r = {
152
151
  _add: input.p.a + input.p.b,
153
152
  _data: [11, 22.22, 'abc', { x: '21', y: 65.43, z: 'test中文' }],
154
153
  _bin: {
155
154
  name: 'zdata.b2',
156
155
  u8a: new Uint8Array([52, 66, 97, 115]),
157
156
  },
158
157
  }
159
158
  pm.resolve(r)
160
159
  }
161
160
  else {
162
161
  console.log('invalid func')
163
162
  pm.reject('invalid func')
164
163
  }
165
164
  }
166
165
  catch (err) {
167
166
  console.log('execute error', err)
168
167
  pm.reject('execute error')
169
168
  }
170
169
  console.log(`Server[port:${opt.port}]: upload`, input)
171
170
  try {
172
171
  ms.push({ 'receive and return': input })
173
172
  let output = input
174
173
  pm.resolve(output)
175
174
  }
176
175
  catch (err) {
177
176
  console.log('upload error', err)
178
177
  pm.reject('upload error')
179
178
  }
180
179
  console.log(`Server[port:${opt.port}]: download`, input)
181
180
  let streamRead = null
182
181
  try {
183
182
  ms.push({ 'download': input })
184
183
  //fp
185
184
  let fp = `./test/1mb.7z`
186
185
  //check, 檔案存在才往下
187
186
  //fileSize
188
187
  let stats = fs.statSync(fp)
189
188
  let fileSize = stats.size
190
189
  //streamRead
191
190
  streamRead = fs.createReadStream(fp)
192
191
  //filename
193
192
  let filename = `1mb中文.7z` //測試支援中文
194
193
  //fileType
195
194
  let fileType = 'application/x-7z-compressed'
196
195
  //output
197
196
  let output = {
198
197
  streamRead,
199
198
  filename,
200
199
  fileSize,
201
200
  fileType,
202
201
  }
203
202
  pm.resolve(output)
204
203
  }
205
204
  catch (err) {
206
205
  console.log('download error', err)
207
206
  // try {
208
207
  // streamRead.destroy() //若fs.createReadStream早於fs.statSync執行, 但fs.statSync發生錯誤時, stream得要destroy
209
208
  // }
210
209
  // catch (err) {}
211
210
  pm.reject('download error')
212
211
  }
213
212
  console.log(`Server[port:${opt.port}]: error`, err)
214
213
  // console.log(`Server[port:${opt.port}]: handler`, data)
215
214
  console.log('ms', ms)
216
215
  // console.log('ms', JSON.stringify(ms))
217
216
  wo.stop()
217
+ <pre class="prettyprint"><code>import fs from 'fs'
218
218
  port: 8080,
219
219
  apiName: 'api',
220
220
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
221
221
  verifyConn: async ({ apiType, authorization, query, headers, req }) => {
222
222
  console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
223
223
  let token = w.strdelleft(authorization, 7) //刪除Bearer
224
224
  if (!w.isestr(token)) {
225
225
  return false
226
226
  }
227
227
  // await w.delay(3000)
228
228
  return true
229
229
  },
230
230
  // console.log(`Server[port:${opt.port}]: execute`, func, input)
231
231
  console.log(`Server[port:${opt.port}]: execute`, func)
232
232
  try {
233
233
  if (func === 'add') {
234
234
  if (_.get(input, 'p.d.u8a', null)) {
235
235
  console.log('input.p.d.u8a', input.p.d.u8a)
236
236
  ms.push({ 'input.p.d.u8a': input.p.d.u8a })
237
237
  }
238
238
  let r = {
239
239
  _add: input.p.a + input.p.b,
240
240
  _data: [11, 22.22, 'abc', { x: '21', y: 65.43, z: 'test中文' }],
241
241
  _bin: {
242
242
  name: 'zdata.b2',
243
243
  u8a: new Uint8Array([52, 66, 97, 115]),
244
244
  },
245
245
  }
246
246
  pm.resolve(r)
247
247
  }
248
248
  else {
249
249
  console.log('invalid func')
250
250
  pm.reject('invalid func')
251
251
  }
252
252
  }
253
253
  catch (err) {
254
254
  console.log('execute error', err)
255
255
  pm.reject('execute error')
256
256
  }
257
257
  console.log(`Server[port:${opt.port}]: upload`, input)
258
258
  try {
259
259
  ms.push({ 'receive and return': input })
260
260
  let output = input
261
261
  pm.resolve(output)
262
262
  }
263
263
  catch (err) {
264
264
  console.log('upload error', err)
265
265
  pm.reject('upload error')
266
266
  }
267
267
  console.log(`Server[port:${opt.port}]: download`, input)
268
268
  let streamRead = null
269
269
  try {
270
270
  ms.push({ 'download': input })
271
271
  //fp
272
272
  let fp = `./test/1mb.7z`
273
273
  //check, 檔案存在才往下
274
274
  //fileSize
275
275
  let stats = fs.statSync(fp)
276
276
  let fileSize = stats.size
277
277
  //streamRead
278
278
  streamRead = fs.createReadStream(fp)
279
279
  //filename
280
280
  let filename = `1mb中文.7z` //測試支援中文
281
281
  //fileType
282
282
  let fileType = 'application/x-7z-compressed'
283
283
  //output
284
284
  let output = {
285
285
  streamRead,
286
286
  filename,
287
287
  fileSize,
288
288
  fileType,
289
289
  }
290
290
  pm.resolve(output)
291
291
  }
292
292
  catch (err) {
293
293
  console.log('download error', err)
294
294
  // try {
295
295
  // streamRead.destroy() //若fs.createReadStream早於fs.statSync執行, 但fs.statSync發生錯誤時, stream得要destroy
296
296
  // }
297
297
  // catch (err) {}
298
298
  pm.reject('download error')
299
299
  }
300
300
  console.log(`Server[port:${opt.port}]: error`, err)
301
301
  // console.log(`Server[port:${opt.port}]: handler`, data)
302
302
  console.log('ms', ms)
303
303
  // console.log('ms', JSON.stringify(ms))
304
304
  wo.stop()
305
305
 
306
306
 
307
307
 
@@ -749,7 +749,7 @@
749
749
  <br class="clear">
750
750
 
751
751
  <footer>
752
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Jul 03 2025 13:34:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
752
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Jul 13 2025 10:18:19 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
753
753
  </footer>
754
754
 
755
755
  <script>prettyPrint();</script>
@@ -112,7 +112,7 @@ import checkSlicesHash from './checkSlicesHash.wk.umd.js'
112
112
  * port: 8080,
113
113
  * apiName: 'api',
114
114
  * pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
115
- * verifyConn: async ({ apiType, authorization, headers, query }) => {
115
+ * verifyConn: async ({ apiType, authorization, query, headers, req }) => {
116
116
  * console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
117
117
  * let token = w.strdelleft(authorization, 7) //刪除Bearer
118
118
  * if (!w.isestr(token)) {
@@ -532,7 +532,7 @@ function WConverhpServer(opt = {}) {
532
532
  if (true) {
533
533
 
534
534
  //verifyConn
535
- let m = verifyConn({ apiType: 'main', authorization, headers, query })
535
+ let m = verifyConn({ apiType: 'main', authorization, query, headers, req })
536
536
  if (ispm(m)) {
537
537
  m = await m
538
538
  }
@@ -1485,7 +1485,7 @@ export default WConverhpServer
1485
1485
  <br class="clear">
1486
1486
 
1487
1487
  <footer>
1488
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Jul 03 2025 13:34:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1488
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Jul 13 2025 10:18:19 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1489
1489
  </footer>
1490
1490
 
1491
1491
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Thu Jul 03 2025 13:34:11 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Jul 13 2025 10:18:19 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "w-converhp",
3
- "version": "2.0.56",
3
+ "version": "2.0.58",
4
4
  "main": "dist/w-converhp-server.umd.js",
5
5
  "dependencies": {
6
6
  "@hapi/hapi": "^21.4.0",
7
7
  "@hapi/inert": "^7.1.0",
8
8
  "axios": "^1.10.0",
9
9
  "lodash-es": "^4.17.21",
10
- "wsemi": "^1.8.6"
10
+ "wsemi": "^1.8.14"
11
11
  },
12
12
  "devDependencies": {
13
13
  "form-data": "^4.0.3",
@@ -65,7 +65,7 @@ import checkSlicesHash from './checkSlicesHash.wk.umd.js'
65
65
  * port: 8080,
66
66
  * apiName: 'api',
67
67
  * pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
68
- * verifyConn: async ({ apiType, authorization, headers, query }) => {
68
+ * verifyConn: async ({ apiType, authorization, query, headers, req }) => {
69
69
  * console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
70
70
  * let token = w.strdelleft(authorization, 7) //刪除Bearer
71
71
  * if (!w.isestr(token)) {
@@ -485,7 +485,7 @@ function WConverhpServer(opt = {}) {
485
485
  if (true) {
486
486
 
487
487
  //verifyConn
488
- let m = verifyConn({ apiType: 'main', authorization, headers, query })
488
+ let m = verifyConn({ apiType: 'main', authorization, query, headers, req })
489
489
  if (ispm(m)) {
490
490
  m = await m
491
491
  }
package/srv.mjs CHANGED
@@ -11,7 +11,7 @@ let opt = {
11
11
  port: 8080,
12
12
  apiName: 'api',
13
13
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
14
- verifyConn: async ({ apiType, authorization, headers, query }) => {
14
+ verifyConn: async ({ apiType, authorization, query, headers, req }) => {
15
15
  console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
16
16
  let token = w.strdelleft(authorization, 7) //刪除Bearer
17
17
  if (!w.isestr(token)) {
@@ -18,7 +18,7 @@ describe('downloadLargeFile', function() {
18
18
  port: 8083, //同時test故得要不同port
19
19
  apiName: 'api',
20
20
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
21
- verifyConn: async ({ apiType, authorization, headers, query }) => {
21
+ verifyConn: async ({ apiType, authorization, query, headers, req }) => {
22
22
  // console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
23
23
  let token = w.strdelleft(authorization, 7) //刪除Bearer
24
24
  if (!w.isestr(token)) {
@@ -18,7 +18,7 @@ describe('executeWithFile', function() {
18
18
  port: 8081, //同時test故得要不同port
19
19
  apiName: 'api',
20
20
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
21
- verifyConn: async ({ apiType, authorization, headers, query }) => {
21
+ verifyConn: async ({ apiType, authorization, query, headers, req }) => {
22
22
  // console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
23
23
  let token = w.strdelleft(authorization, 7) //刪除Bearer
24
24
  if (!w.isestr(token)) {
@@ -18,7 +18,7 @@ describe('executeWithU8a', function() {
18
18
  port: 8080,
19
19
  apiName: 'api',
20
20
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
21
- verifyConn: async ({ apiType, authorization, headers, query }) => {
21
+ verifyConn: async ({ apiType, authorization, query, headers, req }) => {
22
22
  // console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
23
23
  let token = w.strdelleft(authorization, 7) //刪除Bearer
24
24
  if (!w.isestr(token)) {
@@ -18,7 +18,7 @@ describe('uploadLargeFile', function() {
18
18
  port: 8082, //同時test故得要不同port
19
19
  apiName: 'api',
20
20
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
21
- verifyConn: async ({ apiType, authorization, headers, query }) => {
21
+ verifyConn: async ({ apiType, authorization, query, headers, req }) => {
22
22
  // console.log('verifyConn', `apiType[${apiType}]`, `authorization[${authorization}]`)
23
23
  let token = w.strdelleft(authorization, 7) //刪除Bearer
24
24
  if (!w.isestr(token)) {