@icedevml/tinypki-client-side-cert-req 0.4.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/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/index.js +44127 -0
- package/dist/index.js.map +1 -0
- package/dist/tinypki-client-side-cert-req-lib.js +33 -0
- package/dist/tinypki-client-side-cert-req-lib.js.map +1 -0
- package/dist/types/api/base64ToBuffer.d.ts +2 -0
- package/dist/types/api/exportKeyDERB64.d.ts +1 -0
- package/dist/types/api/generateCSR.d.ts +9 -0
- package/dist/types/api/generatePKCS12.d.ts +13 -0
- package/dist/types/api/generateSelfSignedCert.d.ts +5 -0
- package/dist/types/api/savePKCS12BufferAsFile.d.ts +10 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/internal/pemChainToDERB64Array.d.ts +1 -0
- package/dist/types/internal/toPkcs12Asn1Generic.d.ts +9 -0
- package/package.json +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function exportKeyDERB64(key: CryptoKey): Promise<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface IGenerateCSRParams {
|
|
2
|
+
keys: CryptoKeyPair;
|
|
3
|
+
algorithm: RsaHashedKeyGenParams | RsaPssParams | EcKeyGenParams | EcdsaParams;
|
|
4
|
+
commonName: string;
|
|
5
|
+
subjectAltNames: string[];
|
|
6
|
+
}
|
|
7
|
+
type PEMString = string;
|
|
8
|
+
export declare function generateCSR({ keys, algorithm, commonName, subjectAltNames }: IGenerateCSRParams): Promise<PEMString>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type PEMString = string;
|
|
2
|
+
type Base64EncodedDER = string;
|
|
3
|
+
type PKCS12Algorithm = "3des" | "aes128" | "aes192" | "aes256";
|
|
4
|
+
export interface IGeneratePKCS12Params {
|
|
5
|
+
algorithm: RsaHashedKeyGenParams | EcKeyGenParams;
|
|
6
|
+
certChainPEM: PEMString;
|
|
7
|
+
privKeyDERB64: Base64EncodedDER;
|
|
8
|
+
pkcs12Password: string;
|
|
9
|
+
pkcs12Algorithm?: PKCS12Algorithm | null;
|
|
10
|
+
allowWeakPassword?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function generatePKCS12({ certChainPEM, privKeyDERB64, pkcs12Password, pkcs12Algorithm, allowWeakPassword, }: IGeneratePKCS12Params): Promise<Base64EncodedDER>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface IGenerateSelfSignedCertParams {
|
|
2
|
+
keys: CryptoKeyPair;
|
|
3
|
+
algorithm: RsaHashedKeyGenParams | RsaPssParams | EcKeyGenParams | EcdsaParams;
|
|
4
|
+
}
|
|
5
|
+
export declare function generateSelfSignedCert({ algorithm, keys }: IGenerateSelfSignedCertParams): Promise<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from:
|
|
3
|
+
* https://github.com/PeculiarVentures/PKI.js/blob/1bb60c22567a8608f296a2d06ddc06bd2da7125e/examples/PKCS12SimpleExample/es6.ts#L9
|
|
4
|
+
*/
|
|
5
|
+
interface ISavePKCS12BufferAsFileParams {
|
|
6
|
+
buffer: ArrayBuffer;
|
|
7
|
+
targetName: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function savePKCS12BufferAsFile({ buffer, targetName }: ISavePKCS12BufferAsFileParams): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyPKI ClientSideCertReq Library
|
|
3
|
+
*
|
|
4
|
+
* Single-file JavaScript library for classic HTML web applications. Features client-side CSR generation
|
|
5
|
+
* for RSA/ECDSA key pairs from Web Crypto API, after the certificate is issued, also allows to bundle
|
|
6
|
+
* the certificate chain and the private key together into a locally-generated PKCS#12 container
|
|
7
|
+
* that is easily installable in most operating systems and browsers.
|
|
8
|
+
*/
|
|
9
|
+
import type { IGenerateCSRParams } from "./api/generateCSR";
|
|
10
|
+
import type { IGeneratePKCS12Params } from "./api/generatePKCS12";
|
|
11
|
+
import type { IGenerateSelfSignedCertParams } from "./api/generateSelfSignedCert";
|
|
12
|
+
import { exportKeyDERB64 } from "./api/exportKeyDERB64";
|
|
13
|
+
import { generateCSR } from "./api/generateCSR";
|
|
14
|
+
import { generatePKCS12 } from "./api/generatePKCS12";
|
|
15
|
+
import { savePKCS12BufferAsFile } from "./api/savePKCS12BufferAsFile";
|
|
16
|
+
import { base64ToBuffer } from "./api/base64ToBuffer";
|
|
17
|
+
import { generateSelfSignedCert } from "./api/generateSelfSignedCert";
|
|
18
|
+
export type { IGenerateCSRParams, IGeneratePKCS12Params, IGenerateSelfSignedCertParams, };
|
|
19
|
+
export { generateCSR, generatePKCS12, exportKeyDERB64, base64ToBuffer, savePKCS12BufferAsFile, generateSelfSignedCert, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pemChainToDERB64Array(pemChain: string): string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived from:
|
|
3
|
+
* https://github.com/digitalbazaar/forge/blob/1cea0aff4901589ae86e314f25782bbe312f9f69/lib/pkcs12.js#L800
|
|
4
|
+
*
|
|
5
|
+
* and hacked around to support embedding arbitrary DER-encoded certificates and private keys
|
|
6
|
+
* regardless of their algorithm
|
|
7
|
+
*/
|
|
8
|
+
import * as forge from "node-forge";
|
|
9
|
+
export declare const toPkcs12Asn1Generic: (key: string, cert: string | string[], password: string, options: any) => forge.asn1.Asn1;
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@icedevml/tinypki-client-side-cert-req",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "TinyPKI ClientSideCertReq Library",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rollup -c"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@peculiar/x509": "1.14.3",
|
|
23
|
+
"buffer": "^6.0.3",
|
|
24
|
+
"node-forge": "1.3.3",
|
|
25
|
+
"pkijs": "3.3.3"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
29
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
30
|
+
"@types/node-forge": "^1.3.14",
|
|
31
|
+
"rollup": "^4.59.0",
|
|
32
|
+
"rollup-plugin-dts": "^6.3.0",
|
|
33
|
+
"rollup-plugin-esbuild-minify": "^1.3.0",
|
|
34
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
35
|
+
"typescript": "^5.5.3"
|
|
36
|
+
},
|
|
37
|
+
"packageManager": "yarn@4.12.0"
|
|
38
|
+
}
|