@polyv/utils 2.14.0-beta.1 → 2.14.0-beta.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.
- package/cjs/encrypt.d.ts +2 -1
- package/cjs/encrypt.js +1 -1
- package/es/encrypt.d.ts +2 -1
- package/es/encrypt.js +1 -1
- package/package.json +4 -2
package/cjs/encrypt.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* 生成保利威 API 签名(https://help.polyv.net/index.html#/live/api/buildSign)。
|
|
7
7
|
* @param obj 需要签名的对象。
|
|
8
8
|
* @param appSecret 应用密钥。
|
|
9
|
+
* @param method 签名方法。当 obj.signatureMethod 为 SHA256 时,默认为 sha256,否则默认为 md5。
|
|
9
10
|
* @returns 签名字符串。
|
|
10
11
|
*/
|
|
11
|
-
export declare function genAPISign(obj: Record<string, unknown>, appSecret: string): string;
|
|
12
|
+
export declare function genAPISign(obj: Record<string, unknown>, appSecret: string, method?: 'md5' | 'sha256'): string;
|
package/cjs/encrypt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.genAPISign=genAPISign;var
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.genAPISign=genAPISign;var md5_1=__importDefault(require("md5")),sha256_1=__importDefault(require("sha256"));function genAPISign(e,t,r){var i=Object.keys(e).filter((function(e){return"sign"!==e})).sort(),n="";return i.forEach((function(t){var r=e[t];"object"==typeof r&&(r=JSON.stringify(r)),n+=t+r})),r||(r="sha256"===String(e.signatureMethod).toLowerCase()?"sha256":"md5"),("sha256"===r?sha256_1.default:md5_1.default)(t+n+t).toString().toUpperCase()}
|
package/es/encrypt.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* 生成保利威 API 签名(https://help.polyv.net/index.html#/live/api/buildSign)。
|
|
7
7
|
* @param obj 需要签名的对象。
|
|
8
8
|
* @param appSecret 应用密钥。
|
|
9
|
+
* @param method 签名方法。当 obj.signatureMethod 为 SHA256 时,默认为 sha256,否则默认为 md5。
|
|
9
10
|
* @returns 签名字符串。
|
|
10
11
|
*/
|
|
11
|
-
export declare function genAPISign(obj: Record<string, unknown>, appSecret: string): string;
|
|
12
|
+
export declare function genAPISign(obj: Record<string, unknown>, appSecret: string, method?: 'md5' | 'sha256'): string;
|
package/es/encrypt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import md5 from"md5";import sha256 from"sha256";export function genAPISign(t,e,o){const r=Object.keys(t).filter((t=>"sign"!==t)).sort();let s="";r.forEach((e=>{let o=t[e];"object"==typeof o&&(o=JSON.stringify(o)),s+=e+o})),o||(o="sha256"===String(t.signatureMethod).toLowerCase()?"sha256":"md5");return("sha256"===o?sha256:md5)(e+s+e).toString().toUpperCase()}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polyv/utils",
|
|
3
|
-
"version": "2.14.0-beta.
|
|
3
|
+
"version": "2.14.0-beta.3",
|
|
4
4
|
"description": "Utility functions of Polyv frontend development.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polyv",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"@just4/querystring": "^2.0.0",
|
|
26
26
|
"@just4/ua-info": "^3.2.0",
|
|
27
27
|
"@types/md5": "^2.3.5",
|
|
28
|
-
"
|
|
28
|
+
"@types/sha256": "^0.2.2",
|
|
29
|
+
"md5": "^2.3.0",
|
|
30
|
+
"sha256": "^0.2.0"
|
|
29
31
|
}
|
|
30
32
|
}
|