@tsed/jwks 6.88.1 → 6.89.0
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/lib/{getJwks.d.ts → cjs/getJwks.d.ts} +0 -0
- package/lib/{getJwks.js → cjs/getJwks.js} +5 -5
- package/lib/cjs/getJwks.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +6 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/esm/getJwks.js +31 -0
- package/lib/esm/getJwks.js.map +1 -0
- package/lib/esm/index.js +3 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/types/getJwks.d.ts +10 -0
- package/lib/types/index.d.ts +2 -0
- package/package.json +12 -5
- package/tsconfig.compile.esm.json +23 -0
- package/lib/getJwks.js.map +0 -1
- package/lib/index.js +0 -6
- package/lib/index.js.map +0 -1
|
File without changes
|
|
@@ -9,7 +9,7 @@ function generateJwks(options = {}) {
|
|
|
9
9
|
const keystore = new jose2_1.JWKS.KeyStore();
|
|
10
10
|
if (certificates) {
|
|
11
11
|
certificates.forEach(({ path, ...options }) => {
|
|
12
|
-
const content = fs_extra_1.readFileSync(path, { encoding: "utf-8" });
|
|
12
|
+
const content = (0, fs_extra_1.readFileSync)(path, { encoding: "utf-8" });
|
|
13
13
|
const isPrivate = content.includes("PRIVATE KEY");
|
|
14
14
|
if (!isPrivate) {
|
|
15
15
|
keystore.add(jose2_1.JWK.asKey(content, options));
|
|
@@ -25,12 +25,12 @@ function generateJwks(options = {}) {
|
|
|
25
25
|
}
|
|
26
26
|
exports.generateJwks = generateJwks;
|
|
27
27
|
function getJwks(options) {
|
|
28
|
-
fs_extra_1.ensureDirSync(path_1.dirname(options.path));
|
|
29
|
-
if (!fs_extra_1.existsSync(options.path)) {
|
|
28
|
+
(0, fs_extra_1.ensureDirSync)((0, path_1.dirname)(options.path));
|
|
29
|
+
if (!(0, fs_extra_1.existsSync)(options.path)) {
|
|
30
30
|
const keys = generateJwks(options);
|
|
31
|
-
fs_extra_1.writeFileSync(options.path, JSON.stringify(keys, null, 2));
|
|
31
|
+
(0, fs_extra_1.writeFileSync)(options.path, JSON.stringify(keys, null, 2));
|
|
32
32
|
}
|
|
33
|
-
return JSON.parse(fs_extra_1.readFileSync(options.path, { encoding: "utf-8" }));
|
|
33
|
+
return JSON.parse((0, fs_extra_1.readFileSync)(options.path, { encoding: "utf-8" }));
|
|
34
34
|
}
|
|
35
35
|
exports.getJwks = getJwks;
|
|
36
36
|
//# sourceMappingURL=getJwks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getJwks.js","sourceRoot":"","sources":["../../src/getJwks.ts"],"names":[],"mappings":";;;AAAA,uCAAgF;AAChF,iCAA+C;AAC/C,+BAA6B;AAW7B,SAAgB,YAAY,CAAC,UAAgC,EAAE;IAC7D,MAAM,EAAC,YAAY,EAAC,GAAG,OAAO,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,YAAI,CAAC,QAAQ,EAAE,CAAC;IAErC,IAAI,YAAY,EAAE;QAChB,YAAY,CAAC,OAAO,CAAC,CAAC,EAAC,IAAI,EAAE,GAAG,OAAO,EAAC,EAAE,EAAE;YAC1C,MAAM,OAAO,GAAG,IAAA,uBAAY,EAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC;YACxD,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAElD,IAAI,CAAC,SAAS,EAAE;gBACd,QAAQ,CAAC,GAAG,CAAC,WAAG,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;aAC3C;QACH,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;QACjD,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC;QACjE,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC;KACrE;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AApBD,oCAoBC;AAED,SAAgB,OAAO,CAAC,OAAoB;IAC1C,IAAA,wBAAa,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAErC,IAAI,CAAC,IAAA,qBAAU,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC7B,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACnC,IAAA,wBAAa,EAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KAC5D;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,uBAAY,EAAC,OAAO,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AATD,0BASC","sourcesContent":["import {ensureDirSync, existsSync, readFileSync, writeFileSync} from \"fs-extra\";\nimport {JWK, JWKS, KeyParameters} from \"jose2\";\nimport {dirname} from \"path\";\n\nexport interface JwksKeyParameters extends KeyParameters {\n path: string;\n}\n\nexport interface JwksOptions {\n path: string;\n certificates?: JwksKeyParameters[];\n}\n\nexport function generateJwks(options: Partial<JwksOptions> = {}) {\n const {certificates} = options;\n const keystore = new JWKS.KeyStore();\n\n if (certificates) {\n certificates.forEach(({path, ...options}) => {\n const content = readFileSync(path, {encoding: \"utf-8\"});\n const isPrivate = content.includes(\"PRIVATE KEY\");\n\n if (!isPrivate) {\n keystore.add(JWK.asKey(content, options));\n }\n });\n } else {\n keystore.generateSync(\"RSA\", 2048, {use: \"sig\"});\n keystore.generateSync(\"EC\", \"P-256\", {use: \"sig\", alg: \"ES256\"});\n keystore.generateSync(\"OKP\", \"Ed25519\", {use: \"sig\", alg: \"EdDSA\"});\n }\n\n return keystore.toJWKS(true);\n}\n\nexport function getJwks(options: JwksOptions) {\n ensureDirSync(dirname(options.path));\n\n if (!existsSync(options.path)) {\n const keys = generateJwks(options);\n writeFileSync(options.path, JSON.stringify(keys, null, 2));\n }\n\n return JSON.parse(readFileSync(options.path, {encoding: \"utf-8\"}));\n}\n"]}
|
|
File without changes
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAsB;AACtB,yDAA0B","sourcesContent":["export * from \"jose2\";\nexport * from \"./getJwks\";\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ensureDirSync, existsSync, readFileSync, writeFileSync } from "fs-extra";
|
|
2
|
+
import { JWK, JWKS } from "jose2";
|
|
3
|
+
import { dirname } from "path";
|
|
4
|
+
export function generateJwks(options = {}) {
|
|
5
|
+
const { certificates } = options;
|
|
6
|
+
const keystore = new JWKS.KeyStore();
|
|
7
|
+
if (certificates) {
|
|
8
|
+
certificates.forEach(({ path, ...options }) => {
|
|
9
|
+
const content = readFileSync(path, { encoding: "utf-8" });
|
|
10
|
+
const isPrivate = content.includes("PRIVATE KEY");
|
|
11
|
+
if (!isPrivate) {
|
|
12
|
+
keystore.add(JWK.asKey(content, options));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
keystore.generateSync("RSA", 2048, { use: "sig" });
|
|
18
|
+
keystore.generateSync("EC", "P-256", { use: "sig", alg: "ES256" });
|
|
19
|
+
keystore.generateSync("OKP", "Ed25519", { use: "sig", alg: "EdDSA" });
|
|
20
|
+
}
|
|
21
|
+
return keystore.toJWKS(true);
|
|
22
|
+
}
|
|
23
|
+
export function getJwks(options) {
|
|
24
|
+
ensureDirSync(dirname(options.path));
|
|
25
|
+
if (!existsSync(options.path)) {
|
|
26
|
+
const keys = generateJwks(options);
|
|
27
|
+
writeFileSync(options.path, JSON.stringify(keys, null, 2));
|
|
28
|
+
}
|
|
29
|
+
return JSON.parse(readFileSync(options.path, { encoding: "utf-8" }));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=getJwks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getJwks.js","sourceRoot":"","sources":["../../src/getJwks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AAChF,OAAO,EAAC,GAAG,EAAE,IAAI,EAAgB,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAW7B,MAAM,UAAU,YAAY,CAAC,UAAgC,EAAE;IAC7D,MAAM,EAAC,YAAY,EAAC,GAAG,OAAO,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;IAErC,IAAI,YAAY,EAAE;QAChB,YAAY,CAAC,OAAO,CAAC,CAAC,EAAC,IAAI,EAAE,GAAG,OAAO,EAAC,EAAE,EAAE;YAC1C,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC;YACxD,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAElD,IAAI,CAAC,SAAS,EAAE;gBACd,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;aAC3C;QACH,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;QACjD,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC;QACjE,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAC,CAAC,CAAC;KACrE;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,OAAoB;IAC1C,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAErC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC7B,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACnC,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KAC5D;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import {ensureDirSync, existsSync, readFileSync, writeFileSync} from \"fs-extra\";\nimport {JWK, JWKS, KeyParameters} from \"jose2\";\nimport {dirname} from \"path\";\n\nexport interface JwksKeyParameters extends KeyParameters {\n path: string;\n}\n\nexport interface JwksOptions {\n path: string;\n certificates?: JwksKeyParameters[];\n}\n\nexport function generateJwks(options: Partial<JwksOptions> = {}) {\n const {certificates} = options;\n const keystore = new JWKS.KeyStore();\n\n if (certificates) {\n certificates.forEach(({path, ...options}) => {\n const content = readFileSync(path, {encoding: \"utf-8\"});\n const isPrivate = content.includes(\"PRIVATE KEY\");\n\n if (!isPrivate) {\n keystore.add(JWK.asKey(content, options));\n }\n });\n } else {\n keystore.generateSync(\"RSA\", 2048, {use: \"sig\"});\n keystore.generateSync(\"EC\", \"P-256\", {use: \"sig\", alg: \"ES256\"});\n keystore.generateSync(\"OKP\", \"Ed25519\", {use: \"sig\", alg: \"EdDSA\"});\n }\n\n return keystore.toJWKS(true);\n}\n\nexport function getJwks(options: JwksOptions) {\n ensureDirSync(dirname(options.path));\n\n if (!existsSync(options.path)) {\n const keys = generateJwks(options);\n writeFileSync(options.path, JSON.stringify(keys, null, 2));\n }\n\n return JSON.parse(readFileSync(options.path, {encoding: \"utf-8\"}));\n}\n"]}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC","sourcesContent":["export * from \"jose2\";\nexport * from \"./getJwks\";\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeyParameters } from "jose2";
|
|
2
|
+
export interface JwksKeyParameters extends KeyParameters {
|
|
3
|
+
path: string;
|
|
4
|
+
}
|
|
5
|
+
export interface JwksOptions {
|
|
6
|
+
path: string;
|
|
7
|
+
certificates?: JwksKeyParameters[];
|
|
8
|
+
}
|
|
9
|
+
export declare function generateJwks(options?: Partial<JwksOptions>): import("jose2").JSONWebKeySet;
|
|
10
|
+
export declare function getJwks(options: JwksOptions): any;
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/jwks",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.89.0",
|
|
4
4
|
"description": "Utils to generate jwks pair keys",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
|
-
"main": "./lib/index.js",
|
|
7
|
-
"typings": "./lib/index.d.ts",
|
|
8
|
-
"
|
|
6
|
+
"main": "./lib/cjs/index.js",
|
|
7
|
+
"typings": "./lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./lib/types/index.d.ts",
|
|
10
|
+
"import": "./lib/esm/index.js",
|
|
11
|
+
"require": "./lib/cjs/index.js",
|
|
12
|
+
"default": "./lib/esm/index.js"
|
|
13
|
+
},
|
|
9
14
|
"scripts": {
|
|
10
|
-
"build": "
|
|
15
|
+
"build": "yarn run build:esm && yarn run build:cjs",
|
|
16
|
+
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
17
|
+
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
11
18
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts"
|
|
12
19
|
},
|
|
13
20
|
"dependencies": {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.compile.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"module": "ES2020",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "./lib/esm",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationDir": "./lib/types"
|
|
10
|
+
},
|
|
11
|
+
"exclude": [
|
|
12
|
+
"node_modules",
|
|
13
|
+
"test",
|
|
14
|
+
"lib",
|
|
15
|
+
"benchmark",
|
|
16
|
+
"coverage",
|
|
17
|
+
"spec",
|
|
18
|
+
"**/*.benchmark.ts",
|
|
19
|
+
"**/*.spec.ts",
|
|
20
|
+
"keys",
|
|
21
|
+
"jest.config.js"
|
|
22
|
+
]
|
|
23
|
+
}
|
package/lib/getJwks.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getJwks.js","sourceRoot":"","sources":["../src/getJwks.ts"],"names":[],"mappings":";;;AAAA,uCAAgF;AAChF,iCAA+C;AAC/C,+BAA6B;AAW7B,SAAgB,YAAY,CAAC,UAAgC,EAAE;IAC7D,MAAM,EAAC,YAAY,EAAC,GAAG,OAAO,CAAC;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CAAC,CAAC,CAAC,CAAC;KAC5D;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,uBAAY,CAAC,OAAO,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;AACrE,CAAC;AATD,0BASC","sourcesContent":["import {ensureDirSync, existsSync, readFileSync, writeFileSync} from \"fs-extra\";\nimport {JWK, JWKS, KeyParameters} from \"jose2\";\nimport {dirname} from \"path\";\n\nexport interface JwksKeyParameters extends KeyParameters {\n path: string;\n}\n\nexport interface JwksOptions {\n path: string;\n certificates?: JwksKeyParameters[];\n}\n\nexport function generateJwks(options: Partial<JwksOptions> = {}) {\n const {certificates} = options;\n const keystore = new JWKS.KeyStore();\n\n if (certificates) {\n certificates.forEach(({path, ...options}) => {\n const content = readFileSync(path, {encoding: \"utf-8\"});\n const isPrivate = content.includes(\"PRIVATE KEY\");\n\n if (!isPrivate) {\n keystore.add(JWK.asKey(content, options));\n }\n });\n } else {\n keystore.generateSync(\"RSA\", 2048, {use: \"sig\"});\n keystore.generateSync(\"EC\", \"P-256\", {use: \"sig\", alg: \"ES256\"});\n keystore.generateSync(\"OKP\", \"Ed25519\", {use: \"sig\", alg: \"EdDSA\"});\n }\n\n return keystore.toJWKS(true);\n}\n\nexport function getJwks(options: JwksOptions) {\n ensureDirSync(dirname(options.path));\n\n if (!existsSync(options.path)) {\n const keys = generateJwks(options);\n writeFileSync(options.path, JSON.stringify(keys, null, 2));\n }\n\n return JSON.parse(readFileSync(options.path, {encoding: \"utf-8\"}));\n}\n"]}
|
package/lib/index.js
DELETED
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB;AACtB,oDAA0B","sourcesContent":["export * from \"jose2\";\nexport * from \"./getJwks\";\n"]}
|