w-converhp 2.0.2 → 2.0.3

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.
@@ -380,14 +380,14 @@ function WConverhpServer(opt = {}) {
380
380
 
381
381
  //token
382
382
  // let token = get(query, 'token', '')
383
- let token = get(headers, 'authorization', '')
384
- token = isestr(token) ? token : ''
383
+ let authorization = get(headers, 'authorization', '')
384
+ authorization = isestr(authorization) ? authorization : ''
385
385
 
386
386
  //check
387
387
  if (true) {
388
388
 
389
389
  //funCheck
390
- let m = funCheck({ apiType: 'main', token, headers, query })
390
+ let m = funCheck({ apiType: 'main', authorization, headers, query })
391
391
  if (ispm(m)) {
392
392
  m = await m
393
393
  }
@@ -538,14 +538,14 @@ function WConverhpServer(opt = {}) {
538
538
 
539
539
  //token
540
540
  // let token = get(query, 'token', '')
541
- let token = get(headers, 'authorization', '')
542
- token = isestr(token) ? token : ''
541
+ let authorization = get(headers, 'authorization', '')
542
+ authorization = isestr(authorization) ? authorization : ''
543
543
 
544
544
  //check
545
545
  if (true) {
546
546
 
547
547
  //funCheck
548
- let m = funCheck({ apiType: 'slice', token, headers, query })
548
+ let m = funCheck({ apiType: 'slice', authorization, headers, query })
549
549
  if (ispm(m)) {
550
550
  m = await m
551
551
  }
@@ -684,14 +684,14 @@ function WConverhpServer(opt = {}) {
684
684
 
685
685
  //token
686
686
  // let token = get(query, 'token', '')
687
- let token = get(headers, 'authorization', '')
688
- token = isestr(token) ? token : ''
687
+ let authorization = get(headers, 'authorization', '')
688
+ authorization = isestr(authorization) ? authorization : ''
689
689
 
690
690
  //check
691
691
  if (true) {
692
692
 
693
693
  //funCheck
694
- let m = funCheck({ apiType: 'merge', token, headers, query })
694
+ let m = funCheck({ apiType: 'merge', authorization, headers, query })
695
695
  if (ispm(m)) {
696
696
  m = await m
697
697
  }
@@ -911,7 +911,7 @@ export default WConverhpServer
911
911
  <br class="clear">
912
912
 
913
913
  <footer>
914
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 19:42:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
914
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Sun Mar 30 2025 20:22:48 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
915
915
  </footer>
916
916
 
917
917
  <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 Sun Mar 30 2025 19:42:30 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 Mar 30 2025 20:22:48 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,6 +1,6 @@
1
1
  {
2
2
  "name": "w-converhp",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "main": "dist/w-converhp-server.umd.js",
5
5
  "dependencies": {
6
6
  "@hapi/hapi": "^21.4.0",
@@ -29,6 +29,7 @@ import now2strp from 'wsemi/src/now2strp.mjs'
29
29
  * @param {String} [opt.url='http://localhost:8080'] 輸入Hapi伺服器網址,預設為'http://localhost:8080'
30
30
  * @param {String} [opt.apiName='api'] 輸入API名稱字串,預設'api'
31
31
  * @param {Function} [opt.getToken=()=>''] 輸入取得使用者token的回調函數,預設()=>''
32
+ * @param {String} [opt.tokenType='Bearer'] 輸入token類型字串,預設'Bearer'
32
33
  * @param {Integer} [opt.sizeSlice=1024*1024] 輸入切片上傳檔案之切片檔案大小整數,單位為Byte,預設為1024*1024
33
34
  * @param {Integer} [opt.retry=3] 輸入傳輸失敗重試次數整數,預設為3
34
35
  * @returns {Object} 回傳事件物件,可使用函數execute、upload
@@ -161,6 +162,12 @@ function WConverhpClient(opt) {
161
162
  }
162
163
  }
163
164
 
165
+ //tokenType
166
+ let tokenType = get(opt, 'tokenType')
167
+ if (!isestr(tokenType)) {
168
+ tokenType = 'Bearer'
169
+ }
170
+
164
171
  //sizeSlice
165
172
  let sizeSlice = get(opt, 'sizeSlice')
166
173
  if (!ispint(sizeSlice)) {
@@ -336,7 +343,7 @@ function WConverhpClient(opt) {
336
343
  url: urlUse,
337
344
  data: dd,
338
345
  headers: {
339
- Authorization: `Bearer ${token}`,
346
+ Authorization: `${tokenType} ${token}`,
340
347
  ...ct,
341
348
  ...headers,
342
349
  },
@@ -333,14 +333,14 @@ function WConverhpServer(opt = {}) {
333
333
 
334
334
  //token
335
335
  // let token = get(query, 'token', '')
336
- let token = get(headers, 'authorization', '')
337
- token = isestr(token) ? token : ''
336
+ let authorization = get(headers, 'authorization', '')
337
+ authorization = isestr(authorization) ? authorization : ''
338
338
 
339
339
  //check
340
340
  if (true) {
341
341
 
342
342
  //funCheck
343
- let m = funCheck({ apiType: 'main', token, headers, query })
343
+ let m = funCheck({ apiType: 'main', authorization, headers, query })
344
344
  if (ispm(m)) {
345
345
  m = await m
346
346
  }
@@ -491,14 +491,14 @@ function WConverhpServer(opt = {}) {
491
491
 
492
492
  //token
493
493
  // let token = get(query, 'token', '')
494
- let token = get(headers, 'authorization', '')
495
- token = isestr(token) ? token : ''
494
+ let authorization = get(headers, 'authorization', '')
495
+ authorization = isestr(authorization) ? authorization : ''
496
496
 
497
497
  //check
498
498
  if (true) {
499
499
 
500
500
  //funCheck
501
- let m = funCheck({ apiType: 'slice', token, headers, query })
501
+ let m = funCheck({ apiType: 'slice', authorization, headers, query })
502
502
  if (ispm(m)) {
503
503
  m = await m
504
504
  }
@@ -637,14 +637,14 @@ function WConverhpServer(opt = {}) {
637
637
 
638
638
  //token
639
639
  // let token = get(query, 'token', '')
640
- let token = get(headers, 'authorization', '')
641
- token = isestr(token) ? token : ''
640
+ let authorization = get(headers, 'authorization', '')
641
+ authorization = isestr(authorization) ? authorization : ''
642
642
 
643
643
  //check
644
644
  if (true) {
645
645
 
646
646
  //funCheck
647
- let m = funCheck({ apiType: 'merge', token, headers, query })
647
+ let m = funCheck({ apiType: 'merge', authorization, headers, query })
648
648
  if (ispm(m)) {
649
649
  m = await m
650
650
  }
package/srv.mjs CHANGED
@@ -6,8 +6,8 @@ let opt = {
6
6
  port: 8080,
7
7
  apiName: 'api',
8
8
  pathStaticFiles: '.', //要存取專案資料夾下web.html, 故不能給dist
9
- funCheck: ({ apiType, token, headers, query }) => {
10
- console.log('funCheck', apiType, token)
9
+ funCheck: ({ apiType, authorization, headers, query }) => {
10
+ console.log('funCheck', `apiType[${apiType}]`, `authorization[${authorization}]`)
11
11
  return true
12
12
  },
13
13
  }