@denodeio/seshat 0.0.38 → 1.0.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/README.md +2 -54
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -0
- package/index.js +1 -0
- package/{build/cjs/dist/mjs/src/middleware/index.d.ts → lib/middleware.d.ts} +3 -2
- package/lib/middleware.d.ts.map +1 -0
- package/lib/middleware.js +38 -0
- package/lib/seshat.d.ts +5 -0
- package/lib/seshat.d.ts.map +1 -0
- package/lib/seshat.js +4 -0
- package/lib/signer.d.ts +21 -0
- package/lib/signer.d.ts.map +1 -0
- package/lib/signer.js +44 -0
- package/{build/mjs/dist/mjs/src → lib}/types.d.ts +1 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +1 -0
- package/{build/cjs/dist/mjs/src → lib}/utils.d.ts +1 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +6 -0
- package/{build/cjs/dist/mjs/src → lib}/validate.d.ts +2 -1
- package/lib/validate.d.ts.map +1 -0
- package/lib/validate.js +72 -0
- package/package.json +10 -39
- package/build/cjs/dist/mjs/src/index.d.ts +0 -4
- package/build/cjs/dist/mjs/src/signer.d.ts +0 -14
- package/build/cjs/dist/mjs/src/types.d.ts +0 -6
- package/build/cjs/index.d.ts +0 -61
- package/build/cjs/index.js +0 -6725
- package/build/cjs/index.js.map +0 -1
- package/build/cjs/package.json +0 -3
- package/build/mjs/dist/mjs/src/index.d.ts +0 -4
- package/build/mjs/dist/mjs/src/middleware/index.d.ts +0 -9
- package/build/mjs/dist/mjs/src/signer.d.ts +0 -14
- package/build/mjs/dist/mjs/src/utils.d.ts +0 -7
- package/build/mjs/dist/mjs/src/validate.d.ts +0 -30
- package/build/mjs/index.d.ts +0 -61
- package/build/mjs/index.js +0 -6652
- package/build/mjs/index.js.map +0 -1
- package/build/mjs/package.json +0 -3
package/README.md
CHANGED
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
# seshat
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<b>seshat</b> is a library that offers a collection of functions commonly used in Denode backend services.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
To use functions in other services, download seshat as a package:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm i @denodeio/seshat
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Local Build And Deploy
|
|
16
|
-
|
|
17
|
-
To build the project locally and deploy, follow these steps:
|
|
18
|
-
|
|
19
|
-
### 1. Build The Project
|
|
20
|
-
|
|
21
|
-
Run the following command to build the project using Rollup.js, which compiles and generates a bundled version of the project:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
pnpm build
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
This command outputs the compiled code to the "dist" folder, which is used for deployment.
|
|
28
|
-
|
|
29
|
-
### 2. Update Package Version:
|
|
30
|
-
|
|
31
|
-
Open the [package.json](package.json) file and update the version field. For example:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
"version": "0.0.12"
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Ensure that you increment the version number appropriately.
|
|
38
|
-
|
|
39
|
-
### 3. Login to NPM Registry:
|
|
40
|
-
|
|
41
|
-
Use the following command to log in to the [npm registry](https://www.npmjs.com):
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npm login
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
This command will redirect you to the [npm registry](https://www.npmjs.com). Follow the login process on the browser
|
|
48
|
-
|
|
49
|
-
### 4. Publish the New Version:
|
|
50
|
-
|
|
51
|
-
After successful login, you can publish the new version to NPM with the following command:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
npm publish
|
|
55
|
-
```
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../libs/seshat/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./lib/seshat.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { NextFunction, Request, Response } from "express";
|
|
2
2
|
type OptionsInput = {
|
|
3
3
|
fieldName?: string;
|
|
4
4
|
barongJwtPublicKey?: string;
|
|
5
5
|
jwtPublicKey?: string;
|
|
6
6
|
issuer?: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const sessionVerifier: (options: OptionsInput) => (req:
|
|
8
|
+
export declare const sessionVerifier: (options: OptionsInput) => (req: Request, res: Response, next: NextFunction) => void;
|
|
9
9
|
export {};
|
|
10
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../../libs/seshat/src/lib/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGzD,KAAK,YAAY,GAAG;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,eAAe,GAAa,SAAS,YAAY,WAmB1B,OAAO,OAAO,QAAQ,QAAQ,YAAY,SA6B7E,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import jwt from "jsonwebtoken";
|
|
2
|
+
export const sessionVerifier = function (options) {
|
|
3
|
+
const { fieldName = "session", ...actualOptions } = options;
|
|
4
|
+
if (!options || (!options.barongJwtPublicKey && !options.jwtPublicKey)) {
|
|
5
|
+
throw new Error("JWT Public key should be set");
|
|
6
|
+
}
|
|
7
|
+
const jwtPublicKey = options.barongJwtPublicKey || options.jwtPublicKey;
|
|
8
|
+
const defaultOptions = {
|
|
9
|
+
algorithms: ["RS256"],
|
|
10
|
+
issuer: "auth"
|
|
11
|
+
};
|
|
12
|
+
const verificationOptions = { ...defaultOptions, ...actualOptions };
|
|
13
|
+
const middleware = function (req, res, next) {
|
|
14
|
+
let authHeader;
|
|
15
|
+
try {
|
|
16
|
+
authHeader = (req.headers.authorization || "").split("Bearer ")[1];
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
res.status(401);
|
|
20
|
+
res.send("Signature verification raised: Authorization header is missing or malformed");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (!jwtPublicKey) {
|
|
24
|
+
throw new Error("JWT Public key should be set");
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
;
|
|
28
|
+
req[fieldName] = jwt.verify(authHeader, jwtPublicKey, verificationOptions);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
res.status(403);
|
|
32
|
+
res.send(`Signature verification raised: ${error}`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
next();
|
|
36
|
+
};
|
|
37
|
+
return middleware;
|
|
38
|
+
};
|
package/lib/seshat.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seshat.d.ts","sourceRoot":"","sources":["../../../../libs/seshat/src/lib/seshat.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA"}
|
package/lib/seshat.js
ADDED
package/lib/signer.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { KeyObject } from "crypto";
|
|
2
|
+
type SignJwsResponse = {
|
|
3
|
+
payload: string;
|
|
4
|
+
signatures: {
|
|
5
|
+
protected: string;
|
|
6
|
+
header: {
|
|
7
|
+
kid: string;
|
|
8
|
+
};
|
|
9
|
+
signature: string;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
export declare function signJws(payload: string, options: SignDataOptions): SignJwsResponse;
|
|
13
|
+
export declare function signPayload(payload: object, options: SignDataOptions): string;
|
|
14
|
+
type SignDataOptions = {
|
|
15
|
+
privateKey: KeyObject;
|
|
16
|
+
jwtExpirySeconds: number;
|
|
17
|
+
issuer: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function signData(payload: any, options: SignDataOptions): SignJwsResponse;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../libs/seshat/src/lib/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,QAAQ,CAAA;AAG9C,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE;QACV,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE;YACN,GAAG,EAAE,MAAM,CAAA;SACZ,CAAA;QACD,SAAS,EAAE,MAAM,CAAA;KAClB,EAAE,CAAA;CACJ,CAAA;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,eAAe,CAoBlF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAwB7E;AAED,KAAK,eAAe,GAAG;IACrB,UAAU,EAAE,SAAS,CAAA;IACrB,gBAAgB,EAAE,MAAM,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,GAAG,eAAe,CAIhF"}
|
package/lib/signer.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { randomUUID } from "crypto";
|
|
2
|
+
import { sign } from "jsonwebtoken";
|
|
3
|
+
export function signJws(payload, options) {
|
|
4
|
+
const defaultOptions = {
|
|
5
|
+
jwtKid: options.issuer
|
|
6
|
+
};
|
|
7
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
8
|
+
const requestParams = {
|
|
9
|
+
payload: payload.split(".")[1],
|
|
10
|
+
signatures: [
|
|
11
|
+
{
|
|
12
|
+
protected: payload.split(".")[0],
|
|
13
|
+
header: {
|
|
14
|
+
kid: mergedOptions.jwtKid
|
|
15
|
+
},
|
|
16
|
+
signature: payload.split(".")[2]
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
return requestParams;
|
|
21
|
+
}
|
|
22
|
+
export function signPayload(payload, options) {
|
|
23
|
+
const defaultOptions = {
|
|
24
|
+
jwtAlgorithm: "RS256",
|
|
25
|
+
jwtExpireSeconds: options.jwtExpirySeconds
|
|
26
|
+
};
|
|
27
|
+
const mergedOptions = {
|
|
28
|
+
...defaultOptions,
|
|
29
|
+
...options
|
|
30
|
+
};
|
|
31
|
+
const token = sign({
|
|
32
|
+
iss: options.issuer,
|
|
33
|
+
exp: Math.round(Date.now() / 1000) + mergedOptions.jwtExpireSeconds,
|
|
34
|
+
jti: randomUUID(),
|
|
35
|
+
...payload
|
|
36
|
+
}, mergedOptions.privateKey, {
|
|
37
|
+
algorithm: mergedOptions.jwtAlgorithm
|
|
38
|
+
});
|
|
39
|
+
return token;
|
|
40
|
+
}
|
|
41
|
+
export function signData(payload, options) {
|
|
42
|
+
const signedPayload = signPayload(payload, options);
|
|
43
|
+
return signJws(signedPayload, options);
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../libs/seshat/src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEhD,MAAM,MAAM,GAAG,GAAG;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA"}
|
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../libs/seshat/src/lib/utils.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,WAE1C,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,iBAAiB,MAAM,KAAG,eAE9D,CAAA"}
|
package/lib/utils.js
ADDED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Key, Keychain } from "./types";
|
|
1
|
+
import { Key, Keychain } from "./types.js";
|
|
2
2
|
type JwsSignature = {
|
|
3
3
|
protected: string;
|
|
4
4
|
header: {
|
|
@@ -28,3 +28,4 @@ export declare const validateJwsMultisig: <T>(keychain: Keychain, input: JwsPayl
|
|
|
28
28
|
unverified: string[];
|
|
29
29
|
};
|
|
30
30
|
export {};
|
|
31
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../libs/seshat/src/lib/validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1C,KAAK,YAAY,GAAG;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,YAAY,EAAE,CAAA;CAC3B,CAAA;AAED,KAAK,UAAU,CAAC,CAAC,IAAI;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,CAAC,CAAA;KACV,CAAA;IACD,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,KAAK,GAAG,EAAE,OAAO,UAAU,8BAuBzD,CAAA;AAmCD,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,UAAU,QAAQ,EAAE,OAAO,UAAU;;;;;CAuB3E,CAAA"}
|
package/lib/validate.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import jwt from "jsonwebtoken";
|
|
2
|
+
import { parseProtectedHeader } from "./utils.js";
|
|
3
|
+
export const validateJws = (key, input) => {
|
|
4
|
+
for (const signature of input.signatures) {
|
|
5
|
+
const decodedProtectedHeader = parseProtectedHeader(signature.protected);
|
|
6
|
+
if (key === undefined) {
|
|
7
|
+
throw new Error("Invalid key");
|
|
8
|
+
}
|
|
9
|
+
if (key.algorithm !== decodedProtectedHeader.alg) {
|
|
10
|
+
throw new Error("Algorithm mismatch");
|
|
11
|
+
}
|
|
12
|
+
const verified = jwt.verify(`${signature.protected}.${input.payload}.${signature.signature}`, key.value,
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
{ algorithms: [key.algorithm] });
|
|
15
|
+
return verified;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
};
|
|
19
|
+
/*
|
|
20
|
+
* Verifies JWT.
|
|
21
|
+
*
|
|
22
|
+
* @param jwt [Hash]
|
|
23
|
+
* The JWT in the format as defined in RFC 7515.
|
|
24
|
+
* Example:
|
|
25
|
+
* { "payload" => "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ",
|
|
26
|
+
* "signatures" => [
|
|
27
|
+
* { "protected" => "eyJhbGciOiJSUzI1NiJ9",
|
|
28
|
+
* "header" => { "kid" => "2010-12-29" },
|
|
29
|
+
* "signature" => "cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqvhJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrBp0igcN_IoypGlUPQGe77Rw"
|
|
30
|
+
* },
|
|
31
|
+
* { "protected" => "eyJhbGciOiJFUzI1NiJ9",
|
|
32
|
+
* "header" => { "kid" => "e9bc097a-ce51-4036-9562-d2ade882db0d" },
|
|
33
|
+
* "signature" => "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q"
|
|
34
|
+
* }
|
|
35
|
+
* ]
|
|
36
|
+
* }
|
|
37
|
+
* @param public_keychain [Hash]
|
|
38
|
+
* The hash which consists of pairs: key ID => public key.
|
|
39
|
+
* The key may be presented as string in PEM format or as instance of {OpenSSL::PKey::PKey}.
|
|
40
|
+
* The implementation only verifies signatures for which public key exists in keychain.
|
|
41
|
+
* @param options [Hash]
|
|
42
|
+
* The rules for verifying JWT. The variable «algorithms» is always overwritten by the value from JWS header.
|
|
43
|
+
* @return [Hash]
|
|
44
|
+
* The returning value contains payload, list of verified, and unverified signatures (key ID).
|
|
45
|
+
* Example:
|
|
46
|
+
* { payload: { sub: "session", profile: { email: "username@mailbox.example" },
|
|
47
|
+
* verified: [:"backend-1.mycompany.example", :"backend-3.mycompany.example"],
|
|
48
|
+
* unverified: [:"backend-2.mycompany.example"] }
|
|
49
|
+
* }
|
|
50
|
+
* @raise [JWT::DecodeError]
|
|
51
|
+
*/
|
|
52
|
+
export const validateJwsMultisig = (keychain, input) => {
|
|
53
|
+
const verified = [];
|
|
54
|
+
const unverified = [];
|
|
55
|
+
const payload = JSON.parse(Buffer.from(input.payload, "base64").toString());
|
|
56
|
+
for (const signature of input.signatures) {
|
|
57
|
+
const key = keychain.get(signature.header.kid);
|
|
58
|
+
if (key) {
|
|
59
|
+
validateJws(key, input);
|
|
60
|
+
verified.push(signature.header.kid);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
unverified.push(signature.header.kid);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
isVerified: verified.length > 0,
|
|
68
|
+
payload,
|
|
69
|
+
verified,
|
|
70
|
+
unverified
|
|
71
|
+
};
|
|
72
|
+
};
|
package/package.json
CHANGED
|
@@ -1,54 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@denodeio/seshat",
|
|
3
|
+
"version": "1.0.1",
|
|
3
4
|
"private": false,
|
|
4
|
-
"version": "0.0.38",
|
|
5
5
|
"description": "Functions' Library for Denode Ecosystem.",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"types": "
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./index.js",
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"./
|
|
10
|
+
"./"
|
|
11
11
|
],
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
"types": "./index.d.ts",
|
|
15
|
+
"import": "./index.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [],
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "UNLICENSED",
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@rollup/plugin-commonjs": "^25.0.7",
|
|
24
|
-
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
25
|
-
"@rollup/plugin-terser": "^0.4.4",
|
|
26
|
-
"@rollup/plugin-typescript": "^11.1.5",
|
|
27
|
-
"@types/jsonwebtoken": "^9.0.7",
|
|
28
|
-
"@types/node": "^20.9.3",
|
|
29
|
-
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
30
|
-
"@typescript-eslint/parser": "^6.12.0",
|
|
31
|
-
"eslint": "^8.54.0",
|
|
32
|
-
"eslint-config-prettier": "^9.0.0",
|
|
33
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
34
|
-
"prettier": "3.1.0",
|
|
35
|
-
"rollup": "^4.5.0",
|
|
36
|
-
"rollup-plugin-dts": "^6.1.0",
|
|
37
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
38
|
-
"ts-node": "^10.9.1",
|
|
39
|
-
"tslib": "^2.6.2",
|
|
40
|
-
"typescript": "^5.3.2"
|
|
41
|
-
},
|
|
42
22
|
"peerDependencies": {
|
|
43
23
|
"jsonwebtoken": "^9.0.2"
|
|
44
|
-
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "pnpm run clean && pnpm run cjs-compile && pnpm run esm-compile && pnpm run rollup-build && ./exportFix",
|
|
47
|
-
"clean": "rm -fr dist/* && rm -fr build/*",
|
|
48
|
-
"cjs-compile": "tsc -p tsconfig-cjs.json",
|
|
49
|
-
"esm-compile": "tsc -p tsconfig.json",
|
|
50
|
-
"rollup-build": "rollup -c --bundleConfigAsCjs",
|
|
51
|
-
"lint": "eslint . --ext .ts",
|
|
52
|
-
"lintfix": "eslint --fix --ignore-path .gitignore --ext .ts ."
|
|
53
24
|
}
|
|
54
|
-
}
|
|
25
|
+
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
type SignJwsResponse = {
|
|
2
|
-
payload: string;
|
|
3
|
-
signatures: {
|
|
4
|
-
protected: string;
|
|
5
|
-
header: {
|
|
6
|
-
kid: string;
|
|
7
|
-
};
|
|
8
|
-
signature: string;
|
|
9
|
-
}[];
|
|
10
|
-
};
|
|
11
|
-
export declare function signJws(payload: string, options: any): SignJwsResponse;
|
|
12
|
-
export declare function signPayload(payload: any, options: any): string;
|
|
13
|
-
export declare function signData(payload: object, options: any): SignJwsResponse;
|
|
14
|
-
export {};
|
package/build/cjs/index.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Secret, PublicKey } from 'jsonwebtoken';
|
|
2
|
-
|
|
3
|
-
declare const managementSigner: (options: any) => (req: any, res: any, next: any) => void;
|
|
4
|
-
type OptionsInput = {
|
|
5
|
-
fieldName?: string;
|
|
6
|
-
barongJwtPublicKey?: string;
|
|
7
|
-
jwtPublicKey?: string;
|
|
8
|
-
issuer?: string;
|
|
9
|
-
};
|
|
10
|
-
declare const sessionVerifier: (options: OptionsInput) => (req: any, res: any, next: any) => void;
|
|
11
|
-
|
|
12
|
-
type SignJwsResponse = {
|
|
13
|
-
payload: string;
|
|
14
|
-
signatures: {
|
|
15
|
-
protected: string;
|
|
16
|
-
header: {
|
|
17
|
-
kid: string;
|
|
18
|
-
};
|
|
19
|
-
signature: string;
|
|
20
|
-
}[];
|
|
21
|
-
};
|
|
22
|
-
declare function signJws(payload: string, options: any): SignJwsResponse;
|
|
23
|
-
declare function signPayload(payload: any, options: any): string;
|
|
24
|
-
declare function signData(payload: object, options: any): SignJwsResponse;
|
|
25
|
-
|
|
26
|
-
type Key = {
|
|
27
|
-
algorithm: string;
|
|
28
|
-
value: Secret | PublicKey;
|
|
29
|
-
};
|
|
30
|
-
type Keychain = Map<string, Key>;
|
|
31
|
-
|
|
32
|
-
type JwsSignature = {
|
|
33
|
-
protected: string;
|
|
34
|
-
header: {
|
|
35
|
-
kid: string;
|
|
36
|
-
};
|
|
37
|
-
signature: string;
|
|
38
|
-
};
|
|
39
|
-
type JwsPayload = {
|
|
40
|
-
payload: string;
|
|
41
|
-
signatures: JwsSignature[];
|
|
42
|
-
};
|
|
43
|
-
type JwtPayload<T> = {
|
|
44
|
-
iss: string;
|
|
45
|
-
exp: number;
|
|
46
|
-
jti: string;
|
|
47
|
-
event: {
|
|
48
|
-
name: string;
|
|
49
|
-
record: T;
|
|
50
|
-
};
|
|
51
|
-
iat: number;
|
|
52
|
-
};
|
|
53
|
-
declare const validateJws: <T>(key: Key, input: JwsPayload) => JwtPayload<T> | undefined;
|
|
54
|
-
declare const validateJwsMultisig: <T>(keychain: Keychain, input: JwsPayload) => {
|
|
55
|
-
isVerified: boolean;
|
|
56
|
-
payload: T;
|
|
57
|
-
verified: string[];
|
|
58
|
-
unverified: string[];
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export { type Key, type Keychain, managementSigner, sessionVerifier, signData, signJws, signPayload, validateJws, validateJwsMultisig };
|