node-opcua-crypto 4.1.0 → 4.3.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.
Files changed (178) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/chunk-5NV4OKIV.mjs +1 -0
  4. package/dist/chunk-KPKFYTZJ.mjs +173 -0
  5. package/dist/chunk-QSSIRHMR.mjs +6243 -0
  6. package/dist/index.js +6521 -0
  7. package/dist/index.mjs +224 -0
  8. package/dist/source/index.js +6346 -0
  9. package/dist/source/index.mjs +192 -0
  10. package/dist/source/index_web.js +6346 -0
  11. package/dist/source/index_web.mjs +191 -0
  12. package/dist/source_nodejs/index.js +4170 -0
  13. package/dist/source_nodejs/index.mjs +37 -0
  14. package/dist-types/index.d.ts +2 -0
  15. package/dist-types/source/common.d.ts +21 -1
  16. package/dist-types/source/crypto_utils2.d.ts +2 -3
  17. package/dist-types/source/make_private_key_from_pem.d.ts +1 -1
  18. package/dist-types/source/x509/_crypto.d.ts +2 -2
  19. package/dist-types/source/x509/coerce_private_key.d.ts +5 -3
  20. package/dist-types/source/x509/create_key_pair.d.ts +6 -0
  21. package/dist-types/source/x509/create_self_signed_certificate.d.ts +4 -0
  22. package/dist-types/source_nodejs/generate_private_key_filename.d.ts +6 -0
  23. package/dist-types/source_nodejs/read.d.ts +1 -0
  24. package/doc/.nojekyll +1 -0
  25. package/doc/assets/highlight.css +71 -0
  26. package/doc/assets/main.js +58 -0
  27. package/doc/assets/search.js +1 -0
  28. package/doc/assets/style.css +1379 -0
  29. package/doc/classes/Subject.html +76 -0
  30. package/doc/functions/combine_der.html +80 -0
  31. package/doc/functions/createPrivateKeyFromNodeJSCrypto.html +81 -0
  32. package/doc/functions/createSelfSignedCertificate.html +76 -0
  33. package/doc/functions/exploreCertificate.html +77 -0
  34. package/doc/functions/exploreCertificateInfo.html +80 -0
  35. package/doc/functions/explorePrivateKey.html +74 -0
  36. package/doc/functions/extractPublicKeyFromCertificate.html +92 -0
  37. package/doc/functions/generatePrivateKey.html +76 -0
  38. package/doc/functions/generatePrivateKeyFileAlternate.html +79 -0
  39. package/doc/functions/makeMessageChunkSignatureWithDerivedKeys.html +78 -0
  40. package/doc/functions/privateKeyToPEM.html +76 -0
  41. package/doc/functions/readCertificate.html +76 -0
  42. package/doc/functions/readPrivateKey.html +76 -0
  43. package/doc/functions/readPrivateKeyPEM.html +75 -0
  44. package/doc/functions/readPrivateRsaKey.html +74 -0
  45. package/doc/functions/readPublicKey.html +76 -0
  46. package/doc/functions/reduceLength.html +79 -0
  47. package/doc/functions/removePadding.html +77 -0
  48. package/doc/functions/rsaLengthPrivateKey.html +80 -0
  49. package/doc/functions/split_der.html +80 -0
  50. package/doc/functions/toPem2.html +80 -0
  51. package/doc/functions/verifyChunkSignature.html +82 -0
  52. package/doc/functions/verifyChunkSignatureWithDerivedKeys.html +78 -0
  53. package/doc/functions/verifyMessageChunkSignature.html +83 -0
  54. package/doc/index.html +128 -0
  55. package/doc/interfaces/CertificateInfo.html +135 -0
  56. package/doc/modules.html +96 -0
  57. package/node-opcua-crypto-4.2.0.tgz +0 -0
  58. package/package.json +84 -90
  59. package/dist-cjs/source/asn1.js +0 -304
  60. package/dist-cjs/source/asn1.js.map +0 -1
  61. package/dist-cjs/source/buffer_utils.js +0 -9
  62. package/dist-cjs/source/buffer_utils.js.map +0 -1
  63. package/dist-cjs/source/common.js +0 -11
  64. package/dist-cjs/source/common.js.map +0 -1
  65. package/dist-cjs/source/crypto_explore_certificate.js +0 -367
  66. package/dist-cjs/source/crypto_explore_certificate.js.map +0 -1
  67. package/dist-cjs/source/crypto_utils.js +0 -200
  68. package/dist-cjs/source/crypto_utils.js.map +0 -1
  69. package/dist-cjs/source/crypto_utils2.js +0 -71
  70. package/dist-cjs/source/crypto_utils2.js.map +0 -1
  71. package/dist-cjs/source/derived_keys.js +0 -133
  72. package/dist-cjs/source/derived_keys.js.map +0 -1
  73. package/dist-cjs/source/explore_certificate.js +0 -37
  74. package/dist-cjs/source/explore_certificate.js.map +0 -1
  75. package/dist-cjs/source/explore_certificate_revocation_list.js +0 -69
  76. package/dist-cjs/source/explore_certificate_revocation_list.js.map +0 -1
  77. package/dist-cjs/source/explore_certificate_signing_request.js +0 -45
  78. package/dist-cjs/source/explore_certificate_signing_request.js.map +0 -1
  79. package/dist-cjs/source/explore_private_key.js +0 -77
  80. package/dist-cjs/source/explore_private_key.js.map +0 -1
  81. package/dist-cjs/source/index.js +0 -38
  82. package/dist-cjs/source/index.js.map +0 -1
  83. package/dist-cjs/source/make_private_key_from_pem.js +0 -8
  84. package/dist-cjs/source/make_private_key_from_pem.js.map +0 -1
  85. package/dist-cjs/source/oid_map.js +0 -300
  86. package/dist-cjs/source/oid_map.js.map +0 -1
  87. package/dist-cjs/source/public_private_match.js +0 -32
  88. package/dist-cjs/source/public_private_match.js.map +0 -1
  89. package/dist-cjs/source/subject.js +0 -92
  90. package/dist-cjs/source/subject.js.map +0 -1
  91. package/dist-cjs/source/verify_certificate_signature.js +0 -117
  92. package/dist-cjs/source/verify_certificate_signature.js.map +0 -1
  93. package/dist-cjs/source/x509/_build_public_key.js +0 -69
  94. package/dist-cjs/source/x509/_build_public_key.js.map +0 -1
  95. package/dist-cjs/source/x509/_crypto.js +0 -50
  96. package/dist-cjs/source/x509/_crypto.js.map +0 -1
  97. package/dist-cjs/source/x509/_get_attributes.js +0 -39
  98. package/dist-cjs/source/x509/_get_attributes.js.map +0 -1
  99. package/dist-cjs/source/x509/coerce_private_key.js +0 -90
  100. package/dist-cjs/source/x509/coerce_private_key.js.map +0 -1
  101. package/dist-cjs/source/x509/create_certificate_signing_request.js +0 -92
  102. package/dist-cjs/source/x509/create_certificate_signing_request.js.map +0 -1
  103. package/dist-cjs/source/x509/create_key_pair.js +0 -123
  104. package/dist-cjs/source/x509/create_key_pair.js.map +0 -1
  105. package/dist-cjs/source/x509/create_self_signed_certificate.js +0 -102
  106. package/dist-cjs/source/x509/create_self_signed_certificate.js.map +0 -1
  107. package/dist-cjs/source_nodejs/generate_private_key_filename.js +0 -67
  108. package/dist-cjs/source_nodejs/generate_private_key_filename.js.map +0 -1
  109. package/dist-cjs/source_nodejs/index.js +0 -21
  110. package/dist-cjs/source_nodejs/index.js.map +0 -1
  111. package/dist-cjs/source_nodejs/read.js +0 -115
  112. package/dist-cjs/source_nodejs/read.js.map +0 -1
  113. package/dist-cjs/source_nodejs/read_certificate_revocation_list.js +0 -64
  114. package/dist-cjs/source_nodejs/read_certificate_revocation_list.js.map +0 -1
  115. package/dist-cjs/source_nodejs/read_certificate_signing_request.js +0 -64
  116. package/dist-cjs/source_nodejs/read_certificate_signing_request.js.map +0 -1
  117. package/dist-esm/source/asn1.js +0 -275
  118. package/dist-esm/source/asn1.js.map +0 -1
  119. package/dist-esm/source/buffer_utils.js +0 -6
  120. package/dist-esm/source/buffer_utils.js.map +0 -1
  121. package/dist-esm/source/common.js +0 -8
  122. package/dist-esm/source/common.js.map +0 -1
  123. package/dist-esm/source/crypto_explore_certificate.js +0 -356
  124. package/dist-esm/source/crypto_explore_certificate.js.map +0 -1
  125. package/dist-esm/source/crypto_utils.js +0 -179
  126. package/dist-esm/source/crypto_utils.js.map +0 -1
  127. package/dist-esm/source/crypto_utils2.js +0 -58
  128. package/dist-esm/source/crypto_utils2.js.map +0 -1
  129. package/dist-esm/source/derived_keys.js +0 -117
  130. package/dist-esm/source/derived_keys.js.map +0 -1
  131. package/dist-esm/source/explore_certificate.js +0 -29
  132. package/dist-esm/source/explore_certificate.js.map +0 -1
  133. package/dist-esm/source/explore_certificate_revocation_list.js +0 -64
  134. package/dist-esm/source/explore_certificate_revocation_list.js.map +0 -1
  135. package/dist-esm/source/explore_certificate_signing_request.js +0 -40
  136. package/dist-esm/source/explore_certificate_signing_request.js.map +0 -1
  137. package/dist-esm/source/explore_private_key.js +0 -73
  138. package/dist-esm/source/explore_private_key.js.map +0 -1
  139. package/dist-esm/source/index.js +0 -19
  140. package/dist-esm/source/index.js.map +0 -1
  141. package/dist-esm/source/make_private_key_from_pem.js +0 -4
  142. package/dist-esm/source/make_private_key_from_pem.js.map +0 -1
  143. package/dist-esm/source/oid_map.js +0 -297
  144. package/dist-esm/source/oid_map.js.map +0 -1
  145. package/dist-esm/source/public_private_match.js +0 -27
  146. package/dist-esm/source/public_private_match.js.map +0 -1
  147. package/dist-esm/source/subject.js +0 -89
  148. package/dist-esm/source/subject.js.map +0 -1
  149. package/dist-esm/source/verify_certificate_signature.js +0 -110
  150. package/dist-esm/source/verify_certificate_signature.js.map +0 -1
  151. package/dist-esm/source/x509/_build_public_key.js +0 -65
  152. package/dist-esm/source/x509/_build_public_key.js.map +0 -1
  153. package/dist-esm/source/x509/_crypto.js +0 -23
  154. package/dist-esm/source/x509/_crypto.js.map +0 -1
  155. package/dist-esm/source/x509/_get_attributes.js +0 -35
  156. package/dist-esm/source/x509/_get_attributes.js.map +0 -1
  157. package/dist-esm/source/x509/coerce_private_key.js +0 -85
  158. package/dist-esm/source/x509/coerce_private_key.js.map +0 -1
  159. package/dist-esm/source/x509/create_certificate_signing_request.js +0 -88
  160. package/dist-esm/source/x509/create_certificate_signing_request.js.map +0 -1
  161. package/dist-esm/source/x509/create_key_pair.js +0 -115
  162. package/dist-esm/source/x509/create_key_pair.js.map +0 -1
  163. package/dist-esm/source/x509/create_self_signed_certificate.js +0 -98
  164. package/dist-esm/source/x509/create_self_signed_certificate.js.map +0 -1
  165. package/dist-esm/source_nodejs/generate_private_key_filename.js +0 -60
  166. package/dist-esm/source_nodejs/generate_private_key_filename.js.map +0 -1
  167. package/dist-esm/source_nodejs/index.js +0 -5
  168. package/dist-esm/source_nodejs/index.js.map +0 -1
  169. package/dist-esm/source_nodejs/read.js +0 -99
  170. package/dist-esm/source_nodejs/read.js.map +0 -1
  171. package/dist-esm/source_nodejs/read_certificate_revocation_list.js +0 -57
  172. package/dist-esm/source_nodejs/read_certificate_revocation_list.js.map +0 -1
  173. package/dist-esm/source_nodejs/read_certificate_signing_request.js +0 -57
  174. package/dist-esm/source_nodejs/read_certificate_signing_request.js.map +0 -1
  175. package/index.d.ts +0 -2
  176. package/index.js +0 -4
  177. package/index_web.d.ts +0 -1
  178. package/index_web.js +0 -3
@@ -1,65 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { getCrypto } from "./_crypto";
38
- export function buildPublicKey(privateKey) {
39
- return __awaiter(this, void 0, void 0, function () {
40
- var crypto, jwk, publicKey;
41
- return __generator(this, function (_a) {
42
- switch (_a.label) {
43
- case 0:
44
- crypto = getCrypto();
45
- return [4, crypto.subtle.exportKey("jwk", privateKey)];
46
- case 1:
47
- jwk = _a.sent();
48
- delete jwk.d;
49
- delete jwk.dp;
50
- delete jwk.dq;
51
- delete jwk.q;
52
- delete jwk.qi;
53
- jwk.key_ops = [
54
- "encrypt",
55
- "sign",
56
- ];
57
- return [4, crypto.subtle.importKey("jwk", jwk, { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" } }, true, [])];
58
- case 2:
59
- publicKey = _a.sent();
60
- return [2, publicKey];
61
- }
62
- });
63
- });
64
- }
65
- //# sourceMappingURL=_build_public_key.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_build_public_key.js","sourceRoot":"","sources":["../../../source/x509/_build_public_key.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,UAAgB,cAAc,CAAC,UAAqB;;;;;;oBAChD,MAAM,GAAG,SAAS,EAAE,CAAC;oBAGf,WAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,EAAA;;oBAAtD,GAAG,GAAG,SAAgD;oBAG5D,OAAO,GAAG,CAAC,CAAC,CAAC;oBACb,OAAO,GAAG,CAAC,EAAE,CAAC;oBACd,OAAO,GAAG,CAAC,EAAE,CAAC;oBACd,OAAO,GAAG,CAAC,CAAC,CAAC;oBACb,OAAO,GAAG,CAAC,EAAE,CAAC;oBACd,GAAG,CAAC,OAAO,GAAG;wBACV,SAAS;wBACT,MAAM;qBAET,CAAC;oBAIgB,WAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,EAI3H,CAAC,EAAA;;oBAJI,SAAS,GAAG,SAIhB;oBAEF,WAAO,SAAS,EAAC;;;;CACpB"}
@@ -1,23 +0,0 @@
1
- var x509 = require("@peculiar/x509");
2
- import { Crypto } from "@peculiar/webcrypto";
3
- var _crypto;
4
- if (typeof window === "undefined") {
5
- _crypto = require("crypto");
6
- if (!(_crypto === null || _crypto === void 0 ? void 0 : _crypto.subtle)) {
7
- _crypto = new Crypto();
8
- console.warn("using @peculiar/webcrypto");
9
- }
10
- else {
11
- console.warn("using nodejs crypto (native)");
12
- }
13
- x509.cryptoProvider.set(_crypto);
14
- }
15
- else {
16
- _crypto = crypto;
17
- x509.cryptoProvider.set(crypto);
18
- }
19
- export function getCrypto() {
20
- return _crypto || crypto || require("crypto");
21
- }
22
- export * as x509 from "@peculiar/x509";
23
- //# sourceMappingURL=_crypto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_crypto.js","sourceRoot":"","sources":["../../../source/x509/_crypto.ts"],"names":[],"mappings":"AAAA,IAAM,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,IAAI,OAA2B,CAAC;AAKhC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC/B,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5B,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA,EAAE;QAClB,OAAO,GAAG,IAAI,MAAM,EAAE,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;KAC7C;SAAM;QACH,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;KAChD;IACD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;CACpC;KAAM;IAEH,OAAO,GAAG,MAAM,CAAC;IACjB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AAGD,MAAM,UAAU,SAAS;IACrB,OAAO,OAAO,IAAI,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;AAClD,CAAC;AACD,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC"}
@@ -1,35 +0,0 @@
1
- import { CertificatePurpose } from "../common.js";
2
- import { x509 } from "./_crypto.js";
3
- var keyUsageApplication = x509.KeyUsageFlags.keyEncipherment |
4
- x509.KeyUsageFlags.nonRepudiation |
5
- x509.KeyUsageFlags.dataEncipherment |
6
- x509.KeyUsageFlags.keyCertSign |
7
- x509.KeyUsageFlags.digitalSignature;
8
- var keyUsageCA = x509.KeyUsageFlags.keyCertSign | x509.KeyUsageFlags.cRLSign;
9
- export function getAttributes(purpose) {
10
- var basicConstraints;
11
- var keyUsageExtension = [];
12
- var usages;
13
- var nsComment;
14
- var extension;
15
- switch (purpose) {
16
- case CertificatePurpose.ForCertificateAuthority:
17
- extension = "v3_ca";
18
- basicConstraints = new x509.BasicConstraintsExtension(true, undefined, false);
19
- usages = keyUsageCA;
20
- keyUsageExtension = [];
21
- nsComment = "Self-signed certificate for CA generated by Node-OPCUA Certificate utility V2";
22
- break;
23
- case CertificatePurpose.ForApplication:
24
- case CertificatePurpose.ForUserAuthentication:
25
- default:
26
- extension = "v3_selfsigned";
27
- basicConstraints = new x509.BasicConstraintsExtension(false, undefined, true);
28
- usages = keyUsageApplication;
29
- keyUsageExtension = [x509.ExtendedKeyUsage.serverAuth, x509.ExtendedKeyUsage.clientAuth];
30
- nsComment = "Self-signed certificate generated by Node-OPCUA Certificate utility V2";
31
- break;
32
- }
33
- return { nsComment: nsComment, basicConstraints: basicConstraints, keyUsageExtension: keyUsageExtension, usages: usages };
34
- }
35
- //# sourceMappingURL=_get_attributes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_get_attributes.js","sourceRoot":"","sources":["../../../source/x509/_get_attributes.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,IAAM,mBAAmB,GACrB,IAAI,CAAC,aAAa,CAAC,eAAe;IAClC,IAAI,CAAC,aAAa,CAAC,cAAc;IACjC,IAAI,CAAC,aAAa,CAAC,gBAAgB;IACnC,IAAI,CAAC,aAAa,CAAC,WAAW;IAC9B,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC;AAGxC,IAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;AAE/E,MAAM,UAAU,aAAa,CAAC,OAA2B;IAMrD,IAAI,gBAAgD,CAAC;IACrD,IAAI,iBAAiB,GAA4B,EAAE,CAAC;IACpD,IAAI,MAA0B,CAAC;IAC/B,IAAI,SAAiB,CAAC;IACtB,IAAI,SAAiB,CAAC;IACtB,QAAQ,OAAO,EAAE;QACb,KAAK,kBAAkB,CAAC,uBAAuB;YAC3C,SAAS,GAAG,OAAO,CAAC;YAUpB,gBAAgB,GAAG,IAAI,IAAI,CAAC,yBAAyB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAC9E,MAAM,GAAG,UAAU,CAAC;YACpB,iBAAiB,GAAG,EAAE,CAAC;YACvB,SAAS,GAAG,+EAA+E,CAAC;YAC5F,MAAM;QACV,KAAK,kBAAkB,CAAC,cAAc,CAAC;QACvC,KAAK,kBAAkB,CAAC,qBAAqB,CAAC;QAC9C;YAWI,SAAS,GAAG,eAAe,CAAC;YAC5B,gBAAgB,GAAG,IAAI,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;YAC9E,MAAM,GAAG,mBAAmB,CAAC;YAC7B,iBAAiB,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;YACzF,SAAS,GAAG,wEAAwE,CAAC;YACrF,MAAM;KACb;IACD,OAAO,EAAE,SAAS,WAAA,EAAE,gBAAgB,kBAAA,EAAE,iBAAiB,mBAAA,EAAE,MAAM,QAAA,EAAE,CAAC;AACtE,CAAC"}
@@ -1,85 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { createPrivateKey as createPrivateKeyFromNodeJSCrypto } from "crypto";
38
- import { getCrypto } from "./_crypto";
39
- import { derToPrivateKey, pemToPrivateKey } from "./create_key_pair";
40
- var crypto = getCrypto();
41
- var doDebug = false;
42
- export function coercePEMorDerToPrivateKey(privateKeyInDerOrPem) {
43
- if (typeof privateKeyInDerOrPem === "string") {
44
- var hidden = createPrivateKeyFromNodeJSCrypto(privateKeyInDerOrPem);
45
- return { hidden: hidden };
46
- }
47
- throw new Error("not implemented");
48
- }
49
- export function _coercePrivateKey(privateKey) {
50
- return __awaiter(this, void 0, void 0, function () {
51
- var KeyObject, privateKey1, privateKey1, err_1;
52
- return __generator(this, function (_a) {
53
- switch (_a.label) {
54
- case 0:
55
- KeyObject = crypto.KeyObject;
56
- if (!(privateKey instanceof Buffer)) return [3, 2];
57
- return [4, derToPrivateKey(privateKey)];
58
- case 1:
59
- privateKey1 = _a.sent();
60
- return [2, KeyObject.from(privateKey1)];
61
- case 2:
62
- if (!(typeof privateKey === "string")) return [3, 7];
63
- _a.label = 3;
64
- case 3:
65
- _a.trys.push([3, 5, , 6]);
66
- return [4, pemToPrivateKey(privateKey)];
67
- case 4:
68
- privateKey1 = _a.sent();
69
- return [2, KeyObject.from(privateKey1)];
70
- case 5:
71
- err_1 = _a.sent();
72
- doDebug && console.log(privateKey);
73
- throw err_1;
74
- case 6: return [3, 8];
75
- case 7:
76
- if (privateKey instanceof KeyObject) {
77
- return [2, privateKey];
78
- }
79
- _a.label = 8;
80
- case 8: throw new Error("Invalid privateKey");
81
- }
82
- });
83
- });
84
- }
85
- //# sourceMappingURL=coerce_private_key.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"coerce_private_key.js","sourceRoot":"","sources":["../../../source/x509/coerce_private_key.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,OAAO,EAAa,gBAAgB,IAAI,gCAAgC,EAAE,MAAM,QAAQ,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGrE,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;AAE3B,IAAM,OAAO,GAAG,KAAK,CAAC;AAGtB,MAAM,UAAU,0BAA0B,CAAC,oBAAoC;IAC3E,IAAI,OAAO,oBAAoB,KAAK,QAAQ,EAAE;QAC1C,IAAM,MAAM,GAAG,gCAAgC,CAAC,oBAAoB,CAAC,CAAC;QACtE,OAAO,EAAE,MAAM,QAAA,EAAC,CAAC;KACpB;IAED,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAEvC,CAAC;AAED,MAAM,UAAgB,iBAAiB,CAAC,UAAe;;;;;;oBAC7C,SAAS,GAAI,MAAc,CAAC,SAAS,CAAC;yBACxC,CAAA,UAAU,YAAY,MAAM,CAAA,EAA5B,cAA4B;oBACR,WAAM,eAAe,CAAC,UAAU,CAAC,EAAA;;oBAA/C,WAAW,GAAG,SAAiC;oBACrD,WAAO,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,EAAC;;yBAC5B,CAAA,OAAO,UAAU,KAAK,QAAQ,CAAA,EAA9B,cAA8B;;;;oBAGb,WAAM,eAAe,CAAC,UAAU,CAAC,EAAA;;oBAA/C,WAAW,GAAG,SAAiC;oBACrD,WAAO,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,EAAC;;;oBAEnC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBACnC,MAAM,KAAG,CAAC;;;oBAEX,IAAI,UAAU,YAAY,SAAS,EAAE;wBACxC,WAAO,UAAU,EAAC;qBACrB;;wBACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;;;;CACzC"}
@@ -1,88 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { Subject } from "../subject.js";
38
- import { getAttributes } from "./_get_attributes.js";
39
- import { getCrypto, x509 } from "./_crypto.js";
40
- import { buildPublicKey } from "./_build_public_key.js";
41
- export function createCertificateSigningRequest(_a) {
42
- var privateKey = _a.privateKey, subject = _a.subject, dns = _a.dns, ip = _a.ip, applicationUri = _a.applicationUri, purpose = _a.purpose;
43
- return __awaiter(this, void 0, void 0, function () {
44
- var crypto, modulusLength, alg, publicKey, keys, alternativeNameExtensions, _b, basicConstraints, usages, s, s1, name, csr;
45
- return __generator(this, function (_c) {
46
- switch (_c.label) {
47
- case 0:
48
- crypto = getCrypto();
49
- modulusLength = 2048;
50
- alg = {
51
- name: "RSASSA-PKCS1-v1_5",
52
- hash: { name: "SHA-256" },
53
- publicExponent: new Uint8Array([1, 0, 1]),
54
- modulusLength: modulusLength,
55
- };
56
- return [4, buildPublicKey(privateKey)];
57
- case 1:
58
- publicKey = _c.sent();
59
- keys = {
60
- privateKey: privateKey,
61
- publicKey: publicKey,
62
- };
63
- alternativeNameExtensions = [];
64
- dns && dns.forEach(function (d) { return alternativeNameExtensions.push({ type: "dns", value: d }); });
65
- ip && ip.forEach(function (d) { return alternativeNameExtensions.push({ type: "ip", value: d }); });
66
- applicationUri && alternativeNameExtensions.push({ type: "url", value: applicationUri });
67
- _b = getAttributes(purpose), basicConstraints = _b.basicConstraints, usages = _b.usages;
68
- s = new Subject(subject || "");
69
- s1 = s.toStringInternal(", ");
70
- name = s1;
71
- return [4, x509.Pkcs10CertificateRequestGenerator.create({
72
- name: name,
73
- keys: keys,
74
- signingAlgorithm: alg,
75
- extensions: [
76
- basicConstraints,
77
- new x509.KeyUsagesExtension(usages, true),
78
- new x509.SubjectAlternativeNameExtension(alternativeNameExtensions),
79
- ],
80
- }, crypto)];
81
- case 2:
82
- csr = _c.sent();
83
- return [2, { csr: csr.toString("pem"), der: csr }];
84
- }
85
- });
86
- });
87
- }
88
- //# sourceMappingURL=create_certificate_signing_request.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create_certificate_signing_request.js","sourceRoot":"","sources":["../../../source/x509/create_certificate_signing_request.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAaxD,MAAM,UAAgB,+BAA+B,CAAC,EAOb;QANrC,UAAU,gBAAA,EACV,OAAO,aAAA,EACP,GAAG,SAAA,EACH,EAAE,QAAA,EACF,cAAc,oBAAA,EACd,OAAO,aAAA;;;;;;oBAED,MAAM,GAAG,SAAS,EAAE,CAAC;oBAErB,aAAa,GAA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gBAAgB,EAAE,GAAG;4BACrB,UAAU,EAAE;gCACR,gBAAgB;gCAChB,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC;gCACzC,IAAI,IAAI,CAAC,+BAA+B,CAAC,yBAAyB,CAAC;6BACtE;yBACJ,EACD,MAAM,CACT,EAAA;;oBAZK,GAAG,GAAG,SAYX;oBACD,WAAO,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAC;;;;CACjD"}
@@ -1,115 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { x509 } from "./_crypto.js";
38
- import { getCrypto } from "./_crypto";
39
- export function generateKeyPair(modulusLength) {
40
- if (modulusLength === void 0) { modulusLength = 2048; }
41
- return __awaiter(this, void 0, void 0, function () {
42
- var crypto, alg, keys;
43
- return __generator(this, function (_a) {
44
- switch (_a.label) {
45
- case 0:
46
- crypto = getCrypto();
47
- alg = {
48
- name: "RSASSA-PKCS1-v1_5",
49
- hash: { name: "SHA-256" },
50
- publicExponent: new Uint8Array([1, 0, 1]),
51
- modulusLength: modulusLength,
52
- };
53
- return [4, crypto.subtle.generateKey(alg, true, ["sign", "verify"])];
54
- case 1:
55
- keys = _a.sent();
56
- return [2, keys];
57
- }
58
- });
59
- });
60
- }
61
- export function generatePrivateKey(modulusLength) {
62
- if (modulusLength === void 0) { modulusLength = 2048; }
63
- return __awaiter(this, void 0, void 0, function () {
64
- return __generator(this, function (_a) {
65
- switch (_a.label) {
66
- case 0: return [4, generateKeyPair(modulusLength)];
67
- case 1: return [2, (_a.sent()).privateKey];
68
- }
69
- });
70
- });
71
- }
72
- export function privateKeyToPEM(privateKey) {
73
- return __awaiter(this, void 0, void 0, function () {
74
- var crypto, privDer, privPem;
75
- return __generator(this, function (_a) {
76
- switch (_a.label) {
77
- case 0:
78
- crypto = getCrypto();
79
- return [4, crypto.subtle.exportKey("pkcs8", privateKey)];
80
- case 1:
81
- privDer = _a.sent();
82
- privPem = x509.PemConverter.encode(privDer, "PRIVATE KEY");
83
- return [2, { privPem: privPem, privDer: privDer }];
84
- }
85
- });
86
- });
87
- }
88
- export function derToPrivateKey(privDer) {
89
- return __awaiter(this, void 0, void 0, function () {
90
- var crypto;
91
- return __generator(this, function (_a) {
92
- switch (_a.label) {
93
- case 0:
94
- crypto = getCrypto();
95
- return [4, crypto.subtle.importKey("pkcs8", privDer, {
96
- name: "RSASSA-PKCS1-v1_5",
97
- hash: { name: "SHA-256" },
98
- }, true, [
99
- "sign",
100
- ])];
101
- case 1: return [2, _a.sent()];
102
- }
103
- });
104
- });
105
- }
106
- export function pemToPrivateKey(pem) {
107
- return __awaiter(this, void 0, void 0, function () {
108
- var privDer;
109
- return __generator(this, function (_a) {
110
- privDer = x509.PemConverter.decode(pem);
111
- return [2, derToPrivateKey(privDer[0])];
112
- });
113
- });
114
- }
115
- //# sourceMappingURL=create_key_pair.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create_key_pair.js","sourceRoot":"","sources":["../../../source/x509/create_key_pair.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,UAAgB,eAAe,CAAC,aAA+C;IAA/C,8BAAA,EAAA,oBAA+C;;;;;;oBAC3E,MAAM,GAAG,SAAS,EAAE,CAAC;oBAErB,GAAG,GAA0B;wBAC/B,IAAI,EAAE,mBAAmB;wBACzB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;wBACzB,cAAc,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;wBACzC,aAAa,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 -1,98 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { Subject } from "../subject.js";
38
- import { getCrypto, x509 } from "./_crypto.js";
39
- import { getAttributes } from "./_get_attributes.js";
40
- import { buildPublicKey } from "./_build_public_key.js";
41
- export function createSelfSignedCertificate(_a) {
42
- var privateKey = _a.privateKey, notAfter = _a.notAfter, notBefore = _a.notBefore, validity = _a.validity, subject = _a.subject, dns = _a.dns, ip = _a.ip, applicationUri = _a.applicationUri, purpose = _a.purpose;
43
- return __awaiter(this, void 0, void 0, function () {
44
- var crypto, publicKey, keys, _b, nsComment, basicConstraints, keyUsageExtension, usages, alternativeNameExtensions, ID_NETSCAPE_COMMENT, s, s1, name, cert, _c, _d, _e;
45
- var _f;
46
- return __generator(this, function (_g) {
47
- switch (_g.label) {
48
- case 0:
49
- crypto = getCrypto();
50
- return [4, buildPublicKey(privateKey)];
51
- case 1:
52
- publicKey = _g.sent();
53
- keys = {
54
- privateKey: privateKey,
55
- publicKey: publicKey,
56
- };
57
- _b = getAttributes(purpose), nsComment = _b.nsComment, basicConstraints = _b.basicConstraints, keyUsageExtension = _b.keyUsageExtension, usages = _b.usages;
58
- notBefore = notBefore || new Date();
59
- validity = validity || 0;
60
- if (!notAfter) {
61
- validity = validity || 365;
62
- }
63
- notAfter = notAfter || new Date(notBefore.getTime() + validity * 24 * 60 * 60 * 1000);
64
- alternativeNameExtensions = [];
65
- dns && dns.forEach(function (d) { return alternativeNameExtensions.push({ type: "dns", value: d }); });
66
- ip && ip.forEach(function (d) { return alternativeNameExtensions.push({ type: "ip", value: d }); });
67
- applicationUri && alternativeNameExtensions.push({ type: "url", value: applicationUri });
68
- ID_NETSCAPE_COMMENT = "2.16.840.1.113730.1.13";
69
- s = new Subject(subject || "");
70
- s1 = s.toStringInternal(", ");
71
- name = s1;
72
- _d = (_c = x509.X509CertificateGenerator).createSelfSigned;
73
- _f = {
74
- serialNumber: Date.now().toString(),
75
- name: name,
76
- notBefore: notBefore,
77
- notAfter: notAfter,
78
- signingAlgorithm: { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" } },
79
- keys: keys
80
- };
81
- _e = [new x509.Extension(ID_NETSCAPE_COMMENT, false, Buffer.from(nsComment, "ascii")),
82
- basicConstraints,
83
- new x509.ExtendedKeyUsageExtension(keyUsageExtension, true),
84
- new x509.KeyUsagesExtension(usages, true)];
85
- return [4, x509.SubjectKeyIdentifierExtension.create(keys.publicKey)];
86
- case 2: return [4, _d.apply(_c, [(_f.extensions = _e.concat([
87
- _g.sent(),
88
- new x509.SubjectAlternativeNameExtension(alternativeNameExtensions)
89
- ]),
90
- _f), crypto])];
91
- case 3:
92
- cert = _g.sent();
93
- return [2, { cert: cert.toString("pem"), der: cert }];
94
- }
95
- });
96
- });
97
- }
98
- //# sourceMappingURL=create_self_signed_certificate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create_self_signed_certificate.js","sourceRoot":"","sources":["../../../source/x509/create_self_signed_certificate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAcxD,MAAM,UAAgB,2BAA2B,CAAC,EAUf;QAT/B,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,QAAQ,cAAA,EACR,OAAO,aAAA,EACP,GAAG,SAAA,EACH,EAAE,QAAA,EACF,cAAc,oBAAA,EACd,OAAO,aAAA;;;;;;;oBAED,MAAM,GAAG,SAAS,EAAE,CAAC;oBAET,WAAM,cAAc,CAAC,UAA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CAAC,IAAI,CAAC,CAAC;oBAC9B,IAAI,GAAG,EAAE,CAAC;oBAEG,KAAA,CAAA,KAAA,IAAI,CAAC,wBAAwB,CAAA,CAAC,gBAAgB,CAAA;;wBAEzD,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;wBACnC,IAAI,MAAA;wBACJ,SAAS,WAAA;wBACT,QAAQ,UAAA;wBAER,gBAAgB,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;wBAE1E,IAAI,MAAA;;0BAGA,IAAI,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;wBAE/E,gBAAgB;wBAChB,IAAI,IAAI,CAAC,yBAAyB,CAAC,iBAAiB,EAAE,IAAI,CAAC;wBAC3D,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC;oBACzC,WAAM,IAAI,CAAC,6BAA6B,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAA;wBAjB9D,WAAM,eAWX,aAAU;4BAMN,SAA+D;4BAC/D,IAAI,IAAI,CAAC,+BAA+B,CAAC,yBAAyB,CAAC;0BACtE;iCAEL,MAAM,EACT,EAAA;;oBAtBK,IAAI,GAAG,SAsBZ;oBAED,WAAO,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAC;;;;CACpD"}
@@ -1,60 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import fs from "fs";
38
- import { generateKeyPair, privateKeyToPEM } from "../source/index.js";
39
- export function generatePrivateKeyFile(privateKeyFilename, modulusLength) {
40
- return __awaiter(this, void 0, void 0, function () {
41
- var keys, privateKeyPem;
42
- return __generator(this, function (_a) {
43
- switch (_a.label) {
44
- case 0: return [4, generateKeyPair(modulusLength)];
45
- case 1:
46
- keys = _a.sent();
47
- return [4, privateKeyToPEM(keys.privateKey)];
48
- case 2:
49
- privateKeyPem = _a.sent();
50
- return [4, fs.promises.writeFile(privateKeyFilename, privateKeyPem.privPem, "utf-8")];
51
- case 3:
52
- _a.sent();
53
- privateKeyPem.privPem = "";
54
- privateKeyPem.privDer = new Uint8Array(0);
55
- return [2];
56
- }
57
- });
58
- });
59
- }
60
- //# sourceMappingURL=generate_private_key_filename.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate_private_key_filename.js","sourceRoot":"","sources":["../../source_nodejs/generate_private_key_filename.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,UAAgB,sBAAsB,CAAC,kBAA0B,EAAE,aAAwC;;;;;wBAChG,WAAM,eAAe,CAAC,aAAa,CAAC,EAAA;;oBAA3C,IAAI,GAAG,SAAoC;oBAC3B,WAAM,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,EAAA;;oBAAtD,aAAa,GAAG,SAAsC;oBAC5D,WAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,kBAAkB,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,EAAA;;oBAA/E,SAA+E,CAAC;oBAChF,aAAa,CAAC,OAAO,GAAG,EAAE,CAAC;oBAC3B,aAAa,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;;;;;CAC7C"}
@@ -1,5 +0,0 @@
1
- export * from "./read.js";
2
- export * from "./read_certificate_revocation_list.js";
3
- export * from "./read_certificate_signing_request.js";
4
- export * from "./generate_private_key_filename.js";
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source_nodejs/index.ts"],"names":[],"mappings":"AAuBA,cAAc,WAAW,CAAC;AAC1B,cAAc,uCAAuC,CAAC;AACtD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC"}