@arcblock/jwt 1.25.6 → 1.26.1
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/esm/index.d.ts +2 -2
- package/esm/index.js +4 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -2
- package/package.json +5 -5
package/esm/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export type JwtVerifyOptions = Partial<{
|
|
|
31
31
|
* @param {string} [version='1.0.0']
|
|
32
32
|
* @return {*} {string} - hex encoded signature
|
|
33
33
|
*/
|
|
34
|
-
export declare function sign(signer: string, sk?: BytesType, payload?: {}, doSign?: boolean, version?: string): string
|
|
35
|
-
export declare function signV2(signer: string, sk?: BytesType, payload?: any): string
|
|
34
|
+
export declare function sign(signer: string, sk?: BytesType, payload?: {}, doSign?: boolean, version?: string): Promise<string>;
|
|
35
|
+
export declare function signV2(signer: string, sk?: BytesType, payload?: any): Promise<string>;
|
|
36
36
|
export declare function decode(token: string, bodyOnly?: true): JwtBody;
|
|
37
37
|
export declare function decode(token: string, bodyOnly?: false): JwtToken;
|
|
38
38
|
/**
|
package/esm/index.js
CHANGED
|
@@ -20,7 +20,8 @@ const hasher = Hasher.SHA3.hash256;
|
|
|
20
20
|
* @param {string} [version='1.0.0']
|
|
21
21
|
* @return {*} {string} - hex encoded signature
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
// eslint-disable-next-line require-await
|
|
24
|
+
export async function sign(signer, sk, payload = {}, doSign = true, version = '1.0.0') {
|
|
24
25
|
if (isValid(signer) === false) {
|
|
25
26
|
throw new Error('Cannot do sign with invalid signer');
|
|
26
27
|
}
|
|
@@ -77,7 +78,8 @@ export function sign(signer, sk, payload = {}, doSign = true, version = '1.0.0')
|
|
|
77
78
|
const sigB64 = toBase64(sigHex);
|
|
78
79
|
return [headerB64, bodyB64, sigB64].join('.');
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
// eslint-disable-next-line require-await
|
|
82
|
+
export async function signV2(signer, sk, payload = {}) {
|
|
81
83
|
return sign(signer, sk, payload, !!sk, '1.1.0');
|
|
82
84
|
}
|
|
83
85
|
export function decode(token, bodyOnly = true) {
|
package/lib/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export type JwtVerifyOptions = Partial<{
|
|
|
31
31
|
* @param {string} [version='1.0.0']
|
|
32
32
|
* @return {*} {string} - hex encoded signature
|
|
33
33
|
*/
|
|
34
|
-
export declare function sign(signer: string, sk?: BytesType, payload?: {}, doSign?: boolean, version?: string): string
|
|
35
|
-
export declare function signV2(signer: string, sk?: BytesType, payload?: any): string
|
|
34
|
+
export declare function sign(signer: string, sk?: BytesType, payload?: {}, doSign?: boolean, version?: string): Promise<string>;
|
|
35
|
+
export declare function signV2(signer: string, sk?: BytesType, payload?: any): Promise<string>;
|
|
36
36
|
export declare function decode(token: string, bodyOnly?: true): JwtBody;
|
|
37
37
|
export declare function decode(token: string, bodyOnly?: false): JwtToken;
|
|
38
38
|
/**
|
package/lib/index.js
CHANGED
|
@@ -29,7 +29,8 @@ const hasher = mcrypto_1.Hasher.SHA3.hash256;
|
|
|
29
29
|
* @param {string} [version='1.0.0']
|
|
30
30
|
* @return {*} {string} - hex encoded signature
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
// eslint-disable-next-line require-await
|
|
33
|
+
async function sign(signer, sk, payload = {}, doSign = true, version = '1.0.0') {
|
|
33
34
|
if ((0, did_1.isValid)(signer) === false) {
|
|
34
35
|
throw new Error('Cannot do sign with invalid signer');
|
|
35
36
|
}
|
|
@@ -86,7 +87,8 @@ function sign(signer, sk, payload = {}, doSign = true, version = '1.0.0') {
|
|
|
86
87
|
const sigB64 = (0, util_1.toBase64)(sigHex);
|
|
87
88
|
return [headerB64, bodyB64, sigB64].join('.');
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
+
// eslint-disable-next-line require-await
|
|
91
|
+
async function signV2(signer, sk, payload = {}) {
|
|
90
92
|
return sign(signer, sk, payload, !!sk, '1.1.0');
|
|
91
93
|
}
|
|
92
94
|
function decode(token, bodyOnly = true) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/jwt",
|
|
3
3
|
"description": "JSON Web Token variant for arcblock DID solutions",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.26.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "wangshijun",
|
|
7
7
|
"email": "shijun@arcblock.io",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"debug": "^4.3.6",
|
|
22
22
|
"json-stable-stringify": "^1.0.1",
|
|
23
23
|
"semver": "^7.6.3",
|
|
24
|
-
"@arcblock/did": "1.
|
|
25
|
-
"@ocap/mcrypto": "1.
|
|
26
|
-
"@ocap/util": "1.
|
|
27
|
-
"@ocap/wallet": "1.
|
|
24
|
+
"@arcblock/did": "1.26.1",
|
|
25
|
+
"@ocap/mcrypto": "1.26.1",
|
|
26
|
+
"@ocap/util": "1.26.1",
|
|
27
|
+
"@ocap/wallet": "1.26.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@arcblock/eslint-config-ts": "0.3.3",
|