node-opcua-crypto 4.2.0 → 4.3.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.
Files changed (143) 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/coerce_private_key.d.ts +5 -3
  19. package/dist-types/source/x509/create_key_pair.d.ts +6 -0
  20. package/dist-types/source/x509/create_self_signed_certificate.d.ts +4 -0
  21. package/dist-types/source_nodejs/read.d.ts +1 -0
  22. package/node-opcua-crypto-4.2.0.tgz +0 -0
  23. package/package.json +84 -91
  24. package/dist-cjs/source/asn1.js +0 -304
  25. package/dist-cjs/source/asn1.js.map +0 -1
  26. package/dist-cjs/source/buffer_utils.js +0 -9
  27. package/dist-cjs/source/buffer_utils.js.map +0 -1
  28. package/dist-cjs/source/common.js +0 -11
  29. package/dist-cjs/source/common.js.map +0 -1
  30. package/dist-cjs/source/crypto_explore_certificate.js +0 -367
  31. package/dist-cjs/source/crypto_explore_certificate.js.map +0 -1
  32. package/dist-cjs/source/crypto_utils.js +0 -200
  33. package/dist-cjs/source/crypto_utils.js.map +0 -1
  34. package/dist-cjs/source/crypto_utils2.js +0 -71
  35. package/dist-cjs/source/crypto_utils2.js.map +0 -1
  36. package/dist-cjs/source/derived_keys.js +0 -133
  37. package/dist-cjs/source/derived_keys.js.map +0 -1
  38. package/dist-cjs/source/explore_certificate.js +0 -37
  39. package/dist-cjs/source/explore_certificate.js.map +0 -1
  40. package/dist-cjs/source/explore_certificate_revocation_list.js +0 -69
  41. package/dist-cjs/source/explore_certificate_revocation_list.js.map +0 -1
  42. package/dist-cjs/source/explore_certificate_signing_request.js +0 -45
  43. package/dist-cjs/source/explore_certificate_signing_request.js.map +0 -1
  44. package/dist-cjs/source/explore_private_key.js +0 -77
  45. package/dist-cjs/source/explore_private_key.js.map +0 -1
  46. package/dist-cjs/source/index.js +0 -38
  47. package/dist-cjs/source/index.js.map +0 -1
  48. package/dist-cjs/source/make_private_key_from_pem.js +0 -8
  49. package/dist-cjs/source/make_private_key_from_pem.js.map +0 -1
  50. package/dist-cjs/source/oid_map.js +0 -300
  51. package/dist-cjs/source/oid_map.js.map +0 -1
  52. package/dist-cjs/source/public_private_match.js +0 -32
  53. package/dist-cjs/source/public_private_match.js.map +0 -1
  54. package/dist-cjs/source/subject.js +0 -92
  55. package/dist-cjs/source/subject.js.map +0 -1
  56. package/dist-cjs/source/verify_certificate_signature.js +0 -117
  57. package/dist-cjs/source/verify_certificate_signature.js.map +0 -1
  58. package/dist-cjs/source/x509/_build_public_key.js +0 -69
  59. package/dist-cjs/source/x509/_build_public_key.js.map +0 -1
  60. package/dist-cjs/source/x509/_crypto.js +0 -52
  61. package/dist-cjs/source/x509/_crypto.js.map +0 -1
  62. package/dist-cjs/source/x509/_get_attributes.js +0 -39
  63. package/dist-cjs/source/x509/_get_attributes.js.map +0 -1
  64. package/dist-cjs/source/x509/coerce_private_key.js +0 -90
  65. package/dist-cjs/source/x509/coerce_private_key.js.map +0 -1
  66. package/dist-cjs/source/x509/create_certificate_signing_request.js +0 -92
  67. package/dist-cjs/source/x509/create_certificate_signing_request.js.map +0 -1
  68. package/dist-cjs/source/x509/create_key_pair.js +0 -123
  69. package/dist-cjs/source/x509/create_key_pair.js.map +0 -1
  70. package/dist-cjs/source/x509/create_self_signed_certificate.js +0 -103
  71. package/dist-cjs/source/x509/create_self_signed_certificate.js.map +0 -1
  72. package/dist-cjs/source_nodejs/generate_private_key_filename.js +0 -88
  73. package/dist-cjs/source_nodejs/generate_private_key_filename.js.map +0 -1
  74. package/dist-cjs/source_nodejs/index.js +0 -21
  75. package/dist-cjs/source_nodejs/index.js.map +0 -1
  76. package/dist-cjs/source_nodejs/read.js +0 -115
  77. package/dist-cjs/source_nodejs/read.js.map +0 -1
  78. package/dist-cjs/source_nodejs/read_certificate_revocation_list.js +0 -64
  79. package/dist-cjs/source_nodejs/read_certificate_revocation_list.js.map +0 -1
  80. package/dist-cjs/source_nodejs/read_certificate_signing_request.js +0 -64
  81. package/dist-cjs/source_nodejs/read_certificate_signing_request.js.map +0 -1
  82. package/dist-esm/source/asn1.js +0 -275
  83. package/dist-esm/source/asn1.js.map +0 -1
  84. package/dist-esm/source/buffer_utils.js +0 -6
  85. package/dist-esm/source/buffer_utils.js.map +0 -1
  86. package/dist-esm/source/common.js +0 -8
  87. package/dist-esm/source/common.js.map +0 -1
  88. package/dist-esm/source/crypto_explore_certificate.js +0 -356
  89. package/dist-esm/source/crypto_explore_certificate.js.map +0 -1
  90. package/dist-esm/source/crypto_utils.js +0 -179
  91. package/dist-esm/source/crypto_utils.js.map +0 -1
  92. package/dist-esm/source/crypto_utils2.js +0 -58
  93. package/dist-esm/source/crypto_utils2.js.map +0 -1
  94. package/dist-esm/source/derived_keys.js +0 -117
  95. package/dist-esm/source/derived_keys.js.map +0 -1
  96. package/dist-esm/source/explore_certificate.js +0 -29
  97. package/dist-esm/source/explore_certificate.js.map +0 -1
  98. package/dist-esm/source/explore_certificate_revocation_list.js +0 -64
  99. package/dist-esm/source/explore_certificate_revocation_list.js.map +0 -1
  100. package/dist-esm/source/explore_certificate_signing_request.js +0 -40
  101. package/dist-esm/source/explore_certificate_signing_request.js.map +0 -1
  102. package/dist-esm/source/explore_private_key.js +0 -73
  103. package/dist-esm/source/explore_private_key.js.map +0 -1
  104. package/dist-esm/source/index.js +0 -19
  105. package/dist-esm/source/index.js.map +0 -1
  106. package/dist-esm/source/make_private_key_from_pem.js +0 -4
  107. package/dist-esm/source/make_private_key_from_pem.js.map +0 -1
  108. package/dist-esm/source/oid_map.js +0 -297
  109. package/dist-esm/source/oid_map.js.map +0 -1
  110. package/dist-esm/source/public_private_match.js +0 -27
  111. package/dist-esm/source/public_private_match.js.map +0 -1
  112. package/dist-esm/source/subject.js +0 -89
  113. package/dist-esm/source/subject.js.map +0 -1
  114. package/dist-esm/source/verify_certificate_signature.js +0 -110
  115. package/dist-esm/source/verify_certificate_signature.js.map +0 -1
  116. package/dist-esm/source/x509/_build_public_key.js +0 -65
  117. package/dist-esm/source/x509/_build_public_key.js.map +0 -1
  118. package/dist-esm/source/x509/_crypto.js +0 -25
  119. package/dist-esm/source/x509/_crypto.js.map +0 -1
  120. package/dist-esm/source/x509/_get_attributes.js +0 -35
  121. package/dist-esm/source/x509/_get_attributes.js.map +0 -1
  122. package/dist-esm/source/x509/coerce_private_key.js +0 -85
  123. package/dist-esm/source/x509/coerce_private_key.js.map +0 -1
  124. package/dist-esm/source/x509/create_certificate_signing_request.js +0 -88
  125. package/dist-esm/source/x509/create_certificate_signing_request.js.map +0 -1
  126. package/dist-esm/source/x509/create_key_pair.js +0 -115
  127. package/dist-esm/source/x509/create_key_pair.js.map +0 -1
  128. package/dist-esm/source/x509/create_self_signed_certificate.js +0 -99
  129. package/dist-esm/source/x509/create_self_signed_certificate.js.map +0 -1
  130. package/dist-esm/source_nodejs/generate_private_key_filename.js +0 -80
  131. package/dist-esm/source_nodejs/generate_private_key_filename.js.map +0 -1
  132. package/dist-esm/source_nodejs/index.js +0 -5
  133. package/dist-esm/source_nodejs/index.js.map +0 -1
  134. package/dist-esm/source_nodejs/read.js +0 -99
  135. package/dist-esm/source_nodejs/read.js.map +0 -1
  136. package/dist-esm/source_nodejs/read_certificate_revocation_list.js +0 -57
  137. package/dist-esm/source_nodejs/read_certificate_revocation_list.js.map +0 -1
  138. package/dist-esm/source_nodejs/read_certificate_signing_request.js +0 -57
  139. package/dist-esm/source_nodejs/read_certificate_signing_request.js.map +0 -1
  140. package/index.d.ts +0 -2
  141. package/index.js +0 -4
  142. package/index_web.d.ts +0 -1
  143. 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,25 +0,0 @@
1
- var x509 = require("@peculiar/x509");
2
- import { Crypto as PeculiarWebCrypto } from "@peculiar/webcrypto";
3
- var _crypto;
4
- var ignoreCrypto = process.env.IGNORE_SUBTLE_FROM_CRYPTO;
5
- if (typeof window === "undefined") {
6
- _crypto = require("crypto");
7
- if (!(_crypto === null || _crypto === void 0 ? void 0 : _crypto.subtle) || ignoreCrypto) {
8
- _crypto = new PeculiarWebCrypto();
9
- console.warn("using @peculiar/webcrypto");
10
- }
11
- else {
12
- console.warn("using nodejs crypto (native)");
13
- }
14
- x509.cryptoProvider.set(_crypto);
15
- }
16
- else {
17
- console.warn("using browser crypto (native)");
18
- _crypto = crypto;
19
- x509.cryptoProvider.set(crypto);
20
- }
21
- export function getCrypto() {
22
- return _crypto || crypto || require("crypto");
23
- }
24
- export * as x509 from "@peculiar/x509";
25
- //# 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,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAElE,IAAI,OAAsC,CAAC;AAK3C,IAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;AAE3D,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,IAAI,YAAY,EAAE;QAClC,OAAO,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAClC,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,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC9C,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,aA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F,KAA+B,aAAa,CAAC,OAAO,CAAC,EAAnD,gBAAgB,sBAAA,EAAE,MAAM,YAAA,CAA4B;oBAEtD,CAAC,GAAG,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;oBAC/B,EAAE,GAAG,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;oBAC9B,IAAI,GAAG,EAAE,CAAC;oBAEJ,WAAM,IAAI,CAAC,iCAAiC,CAAC,MAAM,CAC3D;4BACI,IAAI,MAAA;4BACJ,IAAI,MAAA;4BACJ,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,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I,EAAE,mBAAmB;4BACzB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;yBAC5B,EACD,IAAI,EACJ;4BACI,MAAM;yBAQT,CACJ,EAAA;wBAlBD,WAAO,SAkBN,EAAC;;;;CACL;AAED,MAAM,UAAgB,eAAe,CAAC,GAAW;;;;YAEvC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC9C,WAAO,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAC;;;CACtC"}
@@ -1,99 +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
- import { AsnConvert, AsnUtf8StringConverter } from "@peculiar/asn1-schema";
42
- export function createSelfSignedCertificate(_a) {
43
- 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;
44
- return __awaiter(this, void 0, void 0, function () {
45
- var crypto, publicKey, keys, _b, nsComment, basicConstraints, keyUsageExtension, usages, alternativeNameExtensions, ID_NETSCAPE_COMMENT, s, s1, name, cert, _c, _d, _e;
46
- var _f;
47
- return __generator(this, function (_g) {
48
- switch (_g.label) {
49
- case 0:
50
- crypto = getCrypto();
51
- return [4, buildPublicKey(privateKey)];
52
- case 1:
53
- publicKey = _g.sent();
54
- keys = {
55
- privateKey: privateKey,
56
- publicKey: publicKey,
57
- };
58
- _b = getAttributes(purpose), nsComment = _b.nsComment, basicConstraints = _b.basicConstraints, keyUsageExtension = _b.keyUsageExtension, usages = _b.usages;
59
- notBefore = notBefore || new Date();
60
- validity = validity || 0;
61
- if (!notAfter) {
62
- validity = validity || 365;
63
- }
64
- notAfter = notAfter || new Date(notBefore.getTime() + validity * 24 * 60 * 60 * 1000);
65
- alternativeNameExtensions = [];
66
- dns && dns.forEach(function (d) { return alternativeNameExtensions.push({ type: "dns", value: d }); });
67
- ip && ip.forEach(function (d) { return alternativeNameExtensions.push({ type: "ip", value: d }); });
68
- applicationUri && alternativeNameExtensions.push({ type: "url", value: applicationUri });
69
- ID_NETSCAPE_COMMENT = "2.16.840.1.113730.1.13";
70
- s = new Subject(subject || "");
71
- s1 = s.toStringInternal(", ");
72
- name = s1;
73
- _d = (_c = x509.X509CertificateGenerator).createSelfSigned;
74
- _f = {
75
- serialNumber: Date.now().toString(),
76
- name: name,
77
- notBefore: notBefore,
78
- notAfter: notAfter,
79
- signingAlgorithm: { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" } },
80
- keys: keys
81
- };
82
- _e = [new x509.Extension(ID_NETSCAPE_COMMENT, false, AsnConvert.serialize(AsnUtf8StringConverter.toASN(nsComment))),
83
- basicConstraints,
84
- new x509.ExtendedKeyUsageExtension(keyUsageExtension, true),
85
- new x509.KeyUsagesExtension(usages, true)];
86
- return [4, x509.SubjectKeyIdentifierExtension.create(keys.publicKey)];
87
- case 2: return [4, _d.apply(_c, [(_f.extensions = _e.concat([
88
- _g.sent(),
89
- new x509.SubjectAlternativeNameExtension(alternativeNameExtensions)
90
- ]),
91
- _f), crypto])];
92
- case 3:
93
- cert = _g.sent();
94
- return [2, { cert: cert.toString("pem"), der: cert }];
95
- }
96
- });
97
- });
98
- }
99
- //# 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,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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,80 +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
- export function generatePrivateKeyFileAlternate(privateKeyFilename, modulusLength) {
61
- return __awaiter(this, void 0, void 0, function () {
62
- var rs, kp, prv, pub, prvpem, pubpem;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0:
66
- rs = require("jsrsasign");
67
- kp = rs.KEYUTIL.generateKeypair("RSA", modulusLength);
68
- prv = kp.prvKeyObj;
69
- pub = kp.pubKeyObj;
70
- prvpem = rs.KEYUTIL.getPEM(prv, "PKCS8PRV");
71
- pubpem = rs.KEYUTIL.getPEM(pub, "PKCS8PUB");
72
- return [4, fs.promises.writeFile(privateKeyFilename, prvpem, "utf-8")];
73
- case 1:
74
- _a.sent();
75
- return [2];
76
- }
77
- });
78
- });
79
- }
80
- //# 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;AAOD,MAAM,UAAgB,+BAA+B,CAAC,kBAA0B,EAAE,aAAiC;;;;;;oBACzG,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;oBAC1B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;oBACtD,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;oBACnB,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;oBACnB,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;oBAC5C,MAAM,GAAG,EAA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