@peculiar/certificates-viewer 4.7.0 → 4.7.1-alpha.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 (210) hide show
  1. package/components/attribute-certificate-viewer.js +4 -2
  2. package/components/attribute-certificate-viewer.js.map +1 -1
  3. package/components/attribute.js +1 -1
  4. package/components/certificate-chain-viewer.js +1 -1
  5. package/components/certificate-viewer.js +3 -2
  6. package/components/certificate-viewer.js.map +1 -1
  7. package/components/crl-viewer.js +4 -2
  8. package/components/crl-viewer.js.map +1 -1
  9. package/components/csr-viewer.js +2 -2
  10. package/components/download.js +2 -12680
  11. package/components/download.js.map +1 -1
  12. package/components/index.js +2 -1
  13. package/components/index.js.map +1 -1
  14. package/components/index2.js +3 -2
  15. package/components/index2.js.map +1 -1
  16. package/components/issuer_name.js +2 -2
  17. package/components/link.js +14335 -0
  18. package/components/link.js.map +1 -0
  19. package/components/miscellaneous.js +5 -79
  20. package/components/miscellaneous.js.map +1 -1
  21. package/components/peculiar-certificate-decoder.js +32 -16
  22. package/components/peculiar-certificate-decoder.js.map +1 -1
  23. package/components/peculiar-certificates-viewer.js +2 -1
  24. package/components/peculiar-certificates-viewer.js.map +1 -1
  25. package/components/peculiar-ssh-certificate-viewer.d.ts +11 -0
  26. package/components/peculiar-ssh-certificate-viewer.js +12 -0
  27. package/components/peculiar-ssh-certificate-viewer.js.map +1 -0
  28. package/components/peculiar-text-hider.js +1 -32
  29. package/components/peculiar-text-hider.js.map +1 -1
  30. package/components/pkcs10_certificate_request.js +2 -1
  31. package/components/pkcs10_certificate_request.js.map +1 -1
  32. package/components/row.js +87 -0
  33. package/components/row.js.map +1 -0
  34. package/components/ssh-certificate-viewer.js +193 -0
  35. package/components/ssh-certificate-viewer.js.map +1 -0
  36. package/components/subject_name.js +2 -2
  37. package/components/text-hider.js +40 -0
  38. package/components/text-hider.js.map +1 -0
  39. package/dist/cjs/extension-D8YKlAu4.js +110 -0
  40. package/dist/cjs/{extension-CGZpfI3W.js.map → extension-D8YKlAu4.js.map} +1 -1
  41. package/dist/cjs/index.cjs.js +4 -4
  42. package/dist/cjs/loader.cjs.js +1 -1
  43. package/dist/cjs/{miscellaneous-D_RAtkZz.js → miscellaneous-DvVSM5KJ.js} +147 -147
  44. package/dist/cjs/{miscellaneous-D_RAtkZz.js.map → miscellaneous-DvVSM5KJ.js.map} +1 -1
  45. package/dist/cjs/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.peculiar-ssh-certificate-viewer.entry.cjs.js.map +1 -0
  46. package/dist/cjs/{peculiar-attribute-certificate-viewer_4.cjs.entry.js → peculiar-attribute-certificate-viewer_5.cjs.entry.js} +197 -44
  47. package/dist/{peculiar/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.entry.esm.js.map → cjs/peculiar-attribute-certificate-viewer_5.cjs.entry.js.map} +1 -1
  48. package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js +25 -21
  49. package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js.map +1 -1
  50. package/dist/cjs/peculiar-certificate-decoder.entry.cjs.js.map +1 -1
  51. package/dist/cjs/peculiar-certificate-viewer.cjs.entry.js +4 -4
  52. package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js +23 -23
  53. package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js.map +1 -1
  54. package/dist/cjs/peculiar-certificates-viewer.entry.cjs.js.map +1 -1
  55. package/dist/cjs/peculiar.cjs.js +1 -1
  56. package/dist/cjs/pkcs10_certificate_request-BoHhadiA.js +146 -0
  57. package/dist/cjs/{pkcs10_certificate_request-BQkkkT42.js.map → pkcs10_certificate_request-BoHhadiA.js.map} +1 -1
  58. package/dist/cjs/{certification_request-DISQwgjn.js → ssh_certificate-s3-rwdMT.js} +1664 -16
  59. package/dist/cjs/ssh_certificate-s3-rwdMT.js.map +1 -0
  60. package/dist/cjs/{x509_certificate-DGRpZGA2.js → x509_certificate-DfXuxxZp.js} +29 -29
  61. package/dist/cjs/{x509_certificate-DGRpZGA2.js.map → x509_certificate-DfXuxxZp.js.map} +1 -1
  62. package/dist/cjs/{x509_crl-DMvJk_81.js → x509_crl-CxJ2lyGX.js} +32 -32
  63. package/dist/cjs/{x509_crl-DMvJk_81.js.map → x509_crl-CxJ2lyGX.js.map} +1 -1
  64. package/dist/collection/collection-manifest.json +1 -0
  65. package/dist/collection/components/certificate-decoder/certificate-decoder.js +10 -6
  66. package/dist/collection/components/certificate-decoder/certificate-decoder.js.map +1 -1
  67. package/dist/collection/components/ssh-certificate-viewer/-components/basic_information.js +29 -0
  68. package/dist/collection/components/ssh-certificate-viewer/-components/basic_information.js.map +1 -0
  69. package/dist/collection/components/ssh-certificate-viewer/-components/public_key.js +26 -0
  70. package/dist/collection/components/ssh-certificate-viewer/-components/public_key.js.map +1 -0
  71. package/dist/collection/components/ssh-certificate-viewer/-components/signature_key.js +26 -0
  72. package/dist/collection/components/ssh-certificate-viewer/-components/signature_key.js.map +1 -0
  73. package/dist/collection/components/ssh-certificate-viewer/ssh-certificate-viewer.js +193 -0
  74. package/dist/collection/components/ssh-certificate-viewer/ssh-certificate-viewer.js.map +1 -0
  75. package/dist/collection/crypto/index.js +1 -0
  76. package/dist/collection/crypto/index.js.map +1 -1
  77. package/dist/collection/crypto/ssh_certificate.js +68 -0
  78. package/dist/collection/crypto/ssh_certificate.js.map +1 -0
  79. package/dist/collection/locales/en.json +5 -1
  80. package/dist/esm/{extension-CUOKUt7o.js → extension-oK2qpCU6.js} +3 -3
  81. package/dist/{esm-es5/extension-CUOKUt7o.js.map → esm/extension-oK2qpCU6.js.map} +1 -1
  82. package/dist/esm/index.js +2 -2
  83. package/dist/esm/loader.js +1 -1
  84. package/dist/esm/{miscellaneous-DVlekgVM.js → miscellaneous-DrmTXljc.js} +4 -4
  85. package/dist/esm/{miscellaneous-DVlekgVM.js.map → miscellaneous-DrmTXljc.js.map} +1 -1
  86. package/dist/esm/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.peculiar-ssh-certificate-viewer.entry.js.map +1 -0
  87. package/dist/esm/{peculiar-attribute-certificate-viewer_4.entry.js → peculiar-attribute-certificate-viewer_5.entry.js} +166 -14
  88. package/dist/esm/peculiar-attribute-certificate-viewer_5.entry.js.map +1 -0
  89. package/dist/esm/peculiar-certificate-decoder.entry.js +14 -10
  90. package/dist/esm/peculiar-certificate-decoder.entry.js.map +1 -1
  91. package/dist/esm/peculiar-certificate-viewer.entry.js +4 -4
  92. package/dist/esm/peculiar-certificates-viewer.entry.js +3 -3
  93. package/dist/esm/peculiar.js +1 -1
  94. package/dist/esm/{pkcs10_certificate_request-B9Q42jiE.js → pkcs10_certificate_request-Bdt_qA_g.js} +3 -3
  95. package/dist/esm/{pkcs10_certificate_request-B9Q42jiE.js.map → pkcs10_certificate_request-Bdt_qA_g.js.map} +1 -1
  96. package/dist/esm/{certification_request-CSS3OhZq.js → ssh_certificate-Ct-r021h.js} +1664 -17
  97. package/dist/esm/ssh_certificate-Ct-r021h.js.map +1 -0
  98. package/dist/esm/{x509_certificate-fWXLCtc8.js → x509_certificate-5DEbrOA7.js} +4 -4
  99. package/dist/esm/{x509_certificate-fWXLCtc8.js.map → x509_certificate-5DEbrOA7.js.map} +1 -1
  100. package/dist/esm/{x509_crl-Dq33Vv-q.js → x509_crl-CPgNUkh7.js} +5 -5
  101. package/dist/esm/{x509_crl-Dq33Vv-q.js.map → x509_crl-CPgNUkh7.js.map} +1 -1
  102. package/dist/esm-es5/{extension-CUOKUt7o.js → extension-oK2qpCU6.js} +2 -2
  103. package/dist/{esm/extension-CUOKUt7o.js.map → esm-es5/extension-oK2qpCU6.js.map} +1 -1
  104. package/dist/esm-es5/index.js +1 -1
  105. package/dist/esm-es5/loader.js +2 -2
  106. package/dist/esm-es5/{miscellaneous-DVlekgVM.js → miscellaneous-DrmTXljc.js} +2 -2
  107. package/dist/esm-es5/{miscellaneous-DVlekgVM.js.map → miscellaneous-DrmTXljc.js.map} +1 -1
  108. package/dist/esm-es5/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.peculiar-ssh-certificate-viewer.entry.js.map +1 -0
  109. package/dist/esm-es5/{peculiar-attribute-certificate-viewer_4.entry.js → peculiar-attribute-certificate-viewer_5.entry.js} +24 -3
  110. package/dist/esm-es5/peculiar-attribute-certificate-viewer_5.entry.js.map +1 -0
  111. package/dist/esm-es5/peculiar-certificate-decoder.entry.js +1 -1
  112. package/dist/esm-es5/peculiar-certificate-decoder.entry.js.map +1 -1
  113. package/dist/esm-es5/peculiar-certificate-viewer.entry.js +1 -1
  114. package/dist/esm-es5/peculiar-certificates-viewer.entry.js +1 -1
  115. package/dist/esm-es5/peculiar.js +1 -1
  116. package/dist/esm-es5/{pkcs10_certificate_request-B9Q42jiE.js → pkcs10_certificate_request-Bdt_qA_g.js} +2 -2
  117. package/dist/esm-es5/{pkcs10_certificate_request-B9Q42jiE.js.map → pkcs10_certificate_request-Bdt_qA_g.js.map} +1 -1
  118. package/dist/esm-es5/{certification_request-CSS3OhZq.js → ssh_certificate-Ct-r021h.js} +7 -7
  119. package/dist/{peculiar/p-D_WeukQa.system.js.map → esm-es5/ssh_certificate-Ct-r021h.js.map} +1 -1
  120. package/dist/esm-es5/{x509_certificate-fWXLCtc8.js → x509_certificate-5DEbrOA7.js} +2 -2
  121. package/dist/esm-es5/{x509_certificate-fWXLCtc8.js.map → x509_certificate-5DEbrOA7.js.map} +1 -1
  122. package/dist/esm-es5/{x509_crl-Dq33Vv-q.js → x509_crl-CPgNUkh7.js} +2 -2
  123. package/dist/esm-es5/{x509_crl-Dq33Vv-q.js.map → x509_crl-CPgNUkh7.js.map} +1 -1
  124. package/dist/peculiar/index.esm.js +1 -1
  125. package/dist/peculiar/locales/en.json +5 -1
  126. package/dist/peculiar/{p-4cc72a56.entry.js → p-0b895a8e.entry.js} +2 -2
  127. package/dist/peculiar/{p-a193f8fd.system.entry.js → p-11434880.system.entry.js} +2 -2
  128. package/dist/peculiar/{p-DTz3NA_M.system.js → p-2GQYAR0v.system.js} +2 -2
  129. package/dist/peculiar/{p-DTz3NA_M.system.js.map → p-2GQYAR0v.system.js.map} +1 -1
  130. package/dist/peculiar/{p-17ebc78c.system.entry.js → p-364fd32b.system.entry.js} +2 -2
  131. package/dist/peculiar/{p-e7c60082.system.entry.js → p-5df0f22b.system.entry.js} +40 -19
  132. package/dist/{esm-es5/peculiar-attribute-certificate-viewer_4.entry.js.map → peculiar/p-5df0f22b.system.entry.js.map} +1 -1
  133. package/dist/peculiar/{p-a4e74904.entry.js → p-62b723f6.entry.js} +40 -19
  134. package/dist/peculiar/p-62b723f6.entry.js.map +1 -0
  135. package/dist/peculiar/{p-e3967e76.entry.js → p-83a53b4f.entry.js} +2 -2
  136. package/dist/peculiar/{p-DKooqn40.js → p-B2G7qjfV.js} +10 -10
  137. package/dist/peculiar/{p-DKooqn40.js.map → p-B2G7qjfV.js.map} +1 -1
  138. package/dist/peculiar/{p-D8TC0Na9.system.js.map → p-BCsPspKr.system.js.map} +1 -1
  139. package/dist/peculiar/p-BGASC3UX.system.js +1 -1
  140. package/dist/peculiar/p-BGIWeG8l.js +12 -0
  141. package/dist/peculiar/{p-CZuaTO2G.js.map → p-BGIWeG8l.js.map} +1 -1
  142. package/dist/peculiar/{p-CEzxVCEh.system.js → p-BQiABBi1.system.js} +4 -4
  143. package/dist/peculiar/{p-CEzxVCEh.system.js.map → p-BQiABBi1.system.js.map} +1 -1
  144. package/dist/peculiar/{p-DcTXA-2R.system.js → p-BeVuAzsd.system.js} +39 -39
  145. package/dist/peculiar/{p-DcTXA-2R.system.js.map → p-BeVuAzsd.system.js.map} +1 -1
  146. package/dist/peculiar/{p-BTn-wukS.system.js → p-C31rbtuG.system.js} +2 -2
  147. package/dist/peculiar/p-C31rbtuG.system.js.map +1 -0
  148. package/dist/peculiar/p-Ce-IF7_R.system.js.map +1 -0
  149. package/dist/peculiar/p-ClkgAXnd.system.js +135 -0
  150. package/dist/peculiar/{p-CSS3OhZq.js.map → p-ClkgAXnd.system.js.map} +1 -1
  151. package/dist/peculiar/{p-CSS3OhZq.js → p-Ct-r021h.js} +12 -12
  152. package/dist/peculiar/p-Ct-r021h.js.map +1 -0
  153. package/dist/peculiar/{p-Bsy7Sqzl.system.js.map → p-CxtUQdcj.system.js.map} +1 -1
  154. package/dist/peculiar/{p-tl0v45Y7.js → p-D9qq15zG.js} +2 -2
  155. package/dist/peculiar/{p-tl0v45Y7.js.map → p-D9qq15zG.js.map} +1 -1
  156. package/dist/peculiar/{p-BG_D4qzJ.js → p-DOpiv0-8.js} +3 -3
  157. package/dist/peculiar/{p-BG_D4qzJ.js.map → p-DOpiv0-8.js.map} +1 -1
  158. package/dist/peculiar/p-IOtHTzYC.system.js +12 -0
  159. package/dist/peculiar/{p-CgCUixvk.system.js.map → p-IOtHTzYC.system.js.map} +1 -1
  160. package/dist/peculiar/p-LmKU8Smy.system.js.map +1 -0
  161. package/dist/peculiar/{p-CoPYW15U.js → p-RWPI76Dh.js} +4 -4
  162. package/dist/peculiar/{p-CoPYW15U.js.map → p-RWPI76Dh.js.map} +1 -1
  163. package/dist/peculiar/p-da9eb1e7.entry.js +5 -0
  164. package/dist/peculiar/p-da9eb1e7.entry.js.map +1 -0
  165. package/dist/peculiar/p-fd98bb82.system.entry.js +5 -0
  166. package/dist/peculiar/p-fd98bb82.system.entry.js.map +1 -0
  167. package/dist/peculiar/p-zQwWLfga.system.js +19 -0
  168. package/dist/peculiar/{p-7fTYvx_V.system.js.map → p-zQwWLfga.system.js.map} +1 -1
  169. package/dist/peculiar/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.peculiar-ssh-certificate-viewer.entry.esm.js.map +1 -0
  170. package/dist/peculiar/peculiar-certificate-decoder.entry.esm.js.map +1 -1
  171. package/dist/peculiar/peculiar.esm.js +1 -1
  172. package/dist/types/components/certificate-decoder/certificate-decoder.d.ts +4 -4
  173. package/dist/types/components/ssh-certificate-viewer/-components/basic_information.d.ts +21 -0
  174. package/dist/types/components/ssh-certificate-viewer/-components/public_key.d.ts +14 -0
  175. package/dist/types/components/ssh-certificate-viewer/-components/signature_key.d.ts +14 -0
  176. package/dist/types/components/ssh-certificate-viewer/ssh-certificate-viewer.d.ts +43 -0
  177. package/dist/types/components.d.ts +43 -0
  178. package/dist/types/crypto/index.d.ts +1 -0
  179. package/dist/types/crypto/ssh_certificate.d.ts +28 -0
  180. package/dist/types/utils/l10n.d.ts +4 -0
  181. package/hydrate/index.js +1840 -27
  182. package/hydrate/index.mjs +1840 -27
  183. package/package.json +3 -2
  184. package/dist/cjs/certification_request-DISQwgjn.js.map +0 -1
  185. package/dist/cjs/extension-CGZpfI3W.js +0 -110
  186. package/dist/cjs/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.entry.cjs.js.map +0 -1
  187. package/dist/cjs/peculiar-attribute-certificate-viewer_4.cjs.entry.js.map +0 -1
  188. package/dist/cjs/pkcs10_certificate_request-BQkkkT42.js +0 -146
  189. package/dist/esm/certification_request-CSS3OhZq.js.map +0 -1
  190. package/dist/esm/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.entry.js.map +0 -1
  191. package/dist/esm/peculiar-attribute-certificate-viewer_4.entry.js.map +0 -1
  192. package/dist/esm-es5/certification_request-CSS3OhZq.js.map +0 -1
  193. package/dist/esm-es5/peculiar-attribute-certificate-viewer.peculiar-certificate-chain-viewer.peculiar-crl-viewer.peculiar-csr-viewer.entry.js.map +0 -1
  194. package/dist/peculiar/p-7fTYvx_V.system.js +0 -19
  195. package/dist/peculiar/p-BTn-wukS.system.js.map +0 -1
  196. package/dist/peculiar/p-CZuaTO2G.js +0 -12
  197. package/dist/peculiar/p-CgCUixvk.system.js +0 -12
  198. package/dist/peculiar/p-DLsQGkmT.system.js.map +0 -1
  199. package/dist/peculiar/p-D_WeukQa.system.js +0 -135
  200. package/dist/peculiar/p-a4e74904.entry.js.map +0 -1
  201. package/dist/peculiar/p-ce006f1c.system.entry.js +0 -5
  202. package/dist/peculiar/p-ce006f1c.system.entry.js.map +0 -1
  203. package/dist/peculiar/p-e7c60082.system.entry.js.map +0 -1
  204. package/dist/peculiar/p-f465afe6.entry.js +0 -5
  205. package/dist/peculiar/p-f465afe6.entry.js.map +0 -1
  206. package/dist/peculiar/p-tBL0ekYY.system.js.map +0 -1
  207. /package/dist/peculiar/{p-4cc72a56.entry.js.map → p-0b895a8e.entry.js.map} +0 -0
  208. /package/dist/peculiar/{p-a193f8fd.system.entry.js.map → p-11434880.system.entry.js.map} +0 -0
  209. /package/dist/peculiar/{p-17ebc78c.system.entry.js.map → p-364fd32b.system.entry.js.map} +0 -0
  210. /package/dist/peculiar/{p-e3967e76.entry.js.map → p-83a53b4f.entry.js.map} +0 -0
@@ -6765,6 +6765,10 @@ const crlEntryExtensions = "CRL Entry Extensions";
6765
6765
  const previewCertificate = "Preview certificate";
6766
6766
  const viewDetails = "View details";
6767
6767
  const downloadOptions = "Download options";
6768
+ const keyId = "Key ID";
6769
+ const principals = "Principals";
6770
+ const criticalOptions = "Critical Options";
6771
+ const signingCA = "Signing CA";
6768
6772
  var en = {
6769
6773
  basicInformation: basicInformation,
6770
6774
  subjectName: subjectName,
@@ -6812,7 +6816,11 @@ var en = {
6812
6816
  crlEntryExtensions: crlEntryExtensions,
6813
6817
  previewCertificate: previewCertificate,
6814
6818
  viewDetails: viewDetails,
6815
- downloadOptions: downloadOptions
6819
+ downloadOptions: downloadOptions,
6820
+ keyId: keyId,
6821
+ principals: principals,
6822
+ criticalOptions: criticalOptions,
6823
+ signingCA: signingCA
6816
6824
  };
6817
6825
 
6818
6826
  /**
@@ -9232,13 +9240,13 @@ const OIDs = {
9232
9240
  * This source code is licensed under the MIT license found in the
9233
9241
  * LICENSE file in the root directory of this source tree.
9234
9242
  */
9235
- var __classPrivateFieldSet$1 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9243
+ var __classPrivateFieldSet$2 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9236
9244
  if (kind === "m") throw new TypeError("Private method is not writable");
9237
9245
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9238
9246
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
9239
9247
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9240
9248
  };
9241
- var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9249
+ var __classPrivateFieldGet$2 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9242
9250
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9243
9251
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
9244
9252
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9248,15 +9256,15 @@ class Name {
9248
9256
  constructor(data) {
9249
9257
  _Name_asn.set(this, new Name$1());
9250
9258
  if (buildExports.BufferSourceConverter.isBufferSource(data)) {
9251
- __classPrivateFieldSet$1(this, _Name_asn, AsnParser.parse(data, Name$1), "f");
9259
+ __classPrivateFieldSet$2(this, _Name_asn, AsnParser.parse(data, Name$1), "f");
9252
9260
  }
9253
9261
  else {
9254
- __classPrivateFieldSet$1(this, _Name_asn, data, "f");
9262
+ __classPrivateFieldSet$2(this, _Name_asn, data, "f");
9255
9263
  }
9256
9264
  }
9257
9265
  toJSON() {
9258
9266
  const res = [];
9259
- __classPrivateFieldGet$1(this, _Name_asn, "f").forEach((o) => (o.forEach((a) => {
9267
+ __classPrivateFieldGet$2(this, _Name_asn, "f").forEach((o) => (o.forEach((a) => {
9260
9268
  res.push({
9261
9269
  type: a.type,
9262
9270
  name: OIDs[a.type],
@@ -10797,13 +10805,13 @@ __decorate([
10797
10805
  * This source code is licensed under the MIT license found in the
10798
10806
  * LICENSE file in the root directory of this source tree.
10799
10807
  */
10800
- var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10808
+ var __classPrivateFieldSet$1 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10801
10809
  if (kind === "m") throw new TypeError("Private method is not writable");
10802
10810
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10803
10811
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10804
10812
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10805
10813
  };
10806
- var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10814
+ var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10807
10815
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10808
10816
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10809
10817
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -10816,20 +10824,20 @@ class AsnData {
10816
10824
  _AsnData_raw.set(this, void 0);
10817
10825
  if (args.length === 1) {
10818
10826
  // asn
10819
- __classPrivateFieldSet(this, _AsnData_asn, args[0], "f");
10820
- __classPrivateFieldSet(this, _AsnData_raw, AsnConvert.serialize(__classPrivateFieldGet(this, _AsnData_asn, "f")), "f");
10827
+ __classPrivateFieldSet$1(this, _AsnData_asn, args[0], "f");
10828
+ __classPrivateFieldSet$1(this, _AsnData_raw, AsnConvert.serialize(__classPrivateFieldGet$1(this, _AsnData_asn, "f")), "f");
10821
10829
  }
10822
10830
  else {
10823
10831
  // raw, type
10824
- __classPrivateFieldSet(this, _AsnData_asn, AsnConvert.parse(args[0], args[1]), "f");
10825
- __classPrivateFieldSet(this, _AsnData_raw, buildExports.BufferSourceConverter.toArrayBuffer(args[0]), "f");
10832
+ __classPrivateFieldSet$1(this, _AsnData_asn, AsnConvert.parse(args[0], args[1]), "f");
10833
+ __classPrivateFieldSet$1(this, _AsnData_raw, buildExports.BufferSourceConverter.toArrayBuffer(args[0]), "f");
10826
10834
  }
10827
10835
  }
10828
10836
  get asn() {
10829
- return __classPrivateFieldGet(this, _AsnData_asn, "f");
10837
+ return __classPrivateFieldGet$1(this, _AsnData_asn, "f");
10830
10838
  }
10831
10839
  get raw() {
10832
- return __classPrivateFieldGet(this, _AsnData_raw, "f");
10840
+ return __classPrivateFieldGet$1(this, _AsnData_raw, "f");
10833
10841
  }
10834
10842
  }
10835
10843
  _AsnData_asn = new WeakMap(), _AsnData_raw = new WeakMap();
@@ -12695,7 +12703,1646 @@ __decorate$1([
12695
12703
  AsnProp({ type: AsnPropTypes.BitString })
12696
12704
  ], CertificationRequest.prototype, "signature", void 0);
12697
12705
 
12698
- export { OIDs as $, AsnData as A, id_pkcs9_at_extensionRequest as B, Certificate as C, Download as D, ECParameters as E, id_pkcs9_at_unstructuredName as F, id_pkcs9_at_challengePassword as G, id_ValuationRanking as H, InsuranceValue as I, id_InsuranceValue as J, id_WebGDPR as K, id_ActivityDescription as L, id_TypeRelationship as M, Name as N, id_DomainNameTechnicalOperator as O, PemConverter as P, id_DomainNameOwner as Q, RSAPublicKey as R, id_DomainNameLegalRepresentative as S, TypeRelationship as T, UnstructuredName as U, ValuationRanking as V, WebGDPR as W, id_DomainNameBeneficiary as X, CertificationRequest as Y, l10n as Z, dateShort as _, dateDiff as a, id_ce_subjectDirectoryAttributes as a$, OctetString as a0, ByteStream as a1, SignedCertificateTimestamp as a2, Extension$1 as a3, CabforganizationIdentifier as a4, NonStandardKeyDescription as a5, BaseCRLNumber as a6, CRLNumber as a7, SubjectInfoAccessSyntax as a8, TNAuthorizationList as a9, IssuingDistributionPoint as aA, CRLDistributionPoints as aB, CertificatePolicies as aC, CertificateIssuer as aD, BasicConstraints as aE, AuthorityKeyIdentifier as aF, AuthorityInfoAccessSyntax as aG, id_cabforganizationIdentifier as aH, id_ce_keyDescription as aI, id_ce_deltaCRLIndicator as aJ, id_ce_cRLNumber as aK, id_pe_subjectInfoAccess as aL, id_pe_TNAuthList as aM, id_pe_biometricInfo as aN, id_entrust_entrustVersInfo as aO, id_ce_privateKeyUsagePeriod as aP, id_adbe_archiveRevInfo as aQ, id_adbe_timestamp as aR, id_role as aS, id_lei as aT, id_caVersion as aU, id_netscapeCertType as aV, id_netscapeComment as aW, id_enrollCertType as aX, id_certificateTemplate as aY, id_pe_qcStatements as aZ, id_ce_subjectKeyIdentifier as a_, LogotypeExtn as aa, BiometricSyntax as ab, EntrustVersionInfo as ac, PrivateKeyUsagePeriod as ad, ArchiveRevInfo as ae, Timestamp as af, LeiRole as ag, LeiChoice as ah, CaVersion as ai, NetscapeCertType as aj, NetscapeComment as ak, EnrollCertTypeChoice as al, CertificateTemplate as am, QCStatements as an, SubjectKeyIdentifier as ao, SubjectDirectoryAttributes as ap, SubjectAlternativeName as aq, PolicyMappings as ar, PolicyConstraints as as, NameConstraints as at, KeyUsage as au, IssueAlternativeName as av, InvalidityDate as aw, InhibitAnyPolicy as ax, ExtendedKeyUsage as ay, CRLReason as az, buildExports as b, id_ce_subjectAltName as b0, id_ce_policyMappings as b1, id_ce_policyConstraints as b2, id_ce_nameConstraints as b3, id_ce_keyUsage as b4, id_ce_issuerAltName as b5, id_ce_invalidityDate as b6, id_ce_inhibitAnyPolicy as b7, id_ce_extKeyUsage as b8, id_ce_cRLReasons as b9, AttestationApplicationId as bA, RootOfTrust as bB, IntegerSet as bC, id_ce_issuingDistributionPoint as ba, id_ce_cRLDistributionPoints as bb, id_ce_certificatePolicies as bc, id_ce_certificateIssuer as bd, id_ce_basicConstraints as be, id_ce_authorityKeyIdentifier as bf, id_pe_authorityInfoAccess as bg, SignedData as bh, EncapsulatedContent as bi, CertificateSet as bj, CertificateChoices as bk, ContentInfo as bl, Name$1 as bm, OtherName as bn, DisplayText as bo, UserNotice as bp, EDIPartyName as bq, __decorate$1 as br, AsnProp as bs, AsnPropTypes as bt, AsnType as bu, AsnTypeTypes as bv, AsnArray as bw, id_qcs_pkixQCSyntax_v2 as bx, SemanticsInformation as by, AsnIntegerArrayBufferConverter as bz, certificateRawToBuffer as c, downloadFromBuffer as d, AsnConvert as e, id_rsaEncryption as f, id_composite_key as g, CompositePublicKey as h, id_ecPublicKey as i, id_alg_composite as j, CompositeSignatureValue as k, CompositeParams as l, getCertificateThumbprint as m, AttributeCertificate as n, CertificateList as o, Attribute$1 as p, AsnParser as q, PrivateKeyPossessionStatement as r, ExtensionRequest as s, ChallengePassword as t, ActivityDescription as u, DomainNameTechnicalOperator as v, DomainNameOwner as w, DomainNameLegalRepresentative as x, DomainNameBeneficiary as y, id_at_statementOfPossession as z };
12699
- //# sourceMappingURL=certification_request-CSS3OhZq.js.map
12706
+ let globalCrypto = globalThis.crypto;
12707
+ function getCrypto() {
12708
+ return globalCrypto;
12709
+ }
12710
+
12711
+ class SshError extends Error {
12712
+ code;
12713
+ constructor(message, code) {
12714
+ super(message);
12715
+ this.code = code;
12716
+ this.name = this.constructor.name;
12717
+ if (Error.captureStackTrace) {
12718
+ Error.captureStackTrace(this, this.constructor);
12719
+ }
12720
+ }
12721
+ }
12722
+ class UnsupportedAlgorithmError extends SshError {
12723
+ constructor(algorithm, supportedAlgorithms) {
12724
+ const supported = supportedAlgorithms ? ` Supported: ${supportedAlgorithms.join(', ')}` : '';
12725
+ super(`Unsupported algorithm: ${algorithm}.${supported}`, 'UNSUPPORTED_ALGORITHM');
12726
+ }
12727
+ }
12728
+ class InvalidFormatError extends SshError {
12729
+ constructor(format, expectedFormat) {
12730
+ const expected = expectedFormat ? ` Expected: ${expectedFormat}` : '';
12731
+ super(`Invalid format: ${format}.${expected}`, 'INVALID_FORMAT');
12732
+ }
12733
+ }
12734
+ class UnsupportedKeyTypeError extends SshError {
12735
+ constructor(keyType, supportedTypes) {
12736
+ const supported = supportedTypes ? ` Supported: ${supportedTypes.join(', ')}` : '';
12737
+ super(`Unsupported key type: ${keyType}.${supported}`, 'UNSUPPORTED_KEY_TYPE');
12738
+ }
12739
+ }
12740
+ class InvalidPrivateKeyFormatError extends SshError {
12741
+ constructor(details) {
12742
+ const message = details
12743
+ ? `Invalid SSH private key format: ${details}`
12744
+ : 'Invalid SSH private key format';
12745
+ super(message, 'INVALID_PRIVATE_KEY_FORMAT');
12746
+ }
12747
+ }
12748
+ class EncryptedKeyNotSupportedError extends SshError {
12749
+ constructor(cipher) {
12750
+ const message = cipher
12751
+ ? `Encrypted SSH private keys are not supported (cipher: ${cipher})`
12752
+ : 'Encrypted SSH private keys are not supported';
12753
+ super(message, 'ENCRYPTED_KEY_NOT_SUPPORTED');
12754
+ }
12755
+ }
12756
+ class InvalidKeyDataError extends SshError {
12757
+ constructor(details) {
12758
+ const message = details ? `Invalid key data: ${details}` : 'Invalid key data';
12759
+ super(message, 'INVALID_KEY_DATA');
12760
+ }
12761
+ }
12762
+ class UnexpectedEOFError extends SshError {
12763
+ constructor(expected, actual) {
12764
+ const details = expected !== undefined && actual !== undefined
12765
+ ? ` Expected ${expected} bytes, got ${actual}`
12766
+ : '';
12767
+ super(`Unexpected end of data${details}`, 'UNEXPECTED_EOF');
12768
+ }
12769
+ }
12770
+
12771
+ const encoder = new TextEncoder();
12772
+ const decoder = new TextDecoder();
12773
+
12774
+ class SshReader {
12775
+ buffer;
12776
+ offset;
12777
+ constructor(data) {
12778
+ this.buffer = data;
12779
+ this.offset = 0;
12780
+ }
12781
+ readUint8() {
12782
+ if (this.offset >= this.buffer.length) {
12783
+ throw new UnexpectedEOFError(1, 0);
12784
+ }
12785
+ return this.buffer[this.offset++];
12786
+ }
12787
+ readUint32() {
12788
+ const value = (this.readUint8() << 24) |
12789
+ (this.readUint8() << 16) |
12790
+ (this.readUint8() << 8) |
12791
+ this.readUint8();
12792
+ return value >>> 0;
12793
+ }
12794
+ readUint64() {
12795
+ const high = this.readUint32();
12796
+ const low = this.readUint32();
12797
+ return (BigInt(high) << 32n) | BigInt(low);
12798
+ }
12799
+ readBytes(length) {
12800
+ if (length < 0) {
12801
+ throw new InvalidFormatError(`Invalid length: ${length}`);
12802
+ }
12803
+ if (this.offset + length > this.buffer.length) {
12804
+ throw new UnexpectedEOFError(length, this.buffer.length - this.offset);
12805
+ }
12806
+ const result = this.buffer.subarray(this.offset, this.offset + length);
12807
+ this.offset += length;
12808
+ return result;
12809
+ }
12810
+ readString() {
12811
+ const length = this.readUint32();
12812
+ const bytes = this.readBytes(length);
12813
+ return decoder.decode(bytes);
12814
+ }
12815
+ peekString(length) {
12816
+ if (this.offset + length > this.buffer.length) {
12817
+ throw new UnexpectedEOFError(length, this.buffer.length - this.offset);
12818
+ }
12819
+ const bytes = this.buffer.subarray(this.offset, this.offset + length);
12820
+ return decoder.decode(bytes);
12821
+ }
12822
+ readMpInt(sshEncoding = false) {
12823
+ const length = this.readUint32();
12824
+ const bytes = this.readBytes(length);
12825
+ if (sshEncoding && bytes.length > 1 && bytes[0] === 0x00) {
12826
+ return bytes.subarray(1);
12827
+ }
12828
+ return bytes;
12829
+ }
12830
+ readMpIntSsh() {
12831
+ return this.readMpInt(true);
12832
+ }
12833
+ remaining() {
12834
+ return this.buffer.length - this.offset;
12835
+ }
12836
+ getOffset() {
12837
+ return this.offset;
12838
+ }
12839
+ seek(offset) {
12840
+ if (offset < 0 || offset > this.buffer.length) {
12841
+ throw new InvalidFormatError(`Invalid offset: ${offset}. Buffer length: ${this.buffer.length}`);
12842
+ }
12843
+ this.offset = offset;
12844
+ }
12845
+ }
12846
+
12847
+ class SshWriter {
12848
+ buffer;
12849
+ offset;
12850
+ constructor(initialSize = 1024) {
12851
+ this.buffer = new Uint8Array(initialSize);
12852
+ this.offset = 0;
12853
+ }
12854
+ ensureCapacity(additional) {
12855
+ const required = this.offset + additional;
12856
+ if (required > this.buffer.length) {
12857
+ const newSize = Math.max(required, this.buffer.length * 2);
12858
+ const newBuffer = new Uint8Array(newSize);
12859
+ newBuffer.set(this.buffer.subarray(0, this.offset));
12860
+ this.buffer = newBuffer;
12861
+ }
12862
+ }
12863
+ reserve(minCapacity) {
12864
+ if (minCapacity > this.buffer.length) {
12865
+ const newBuffer = new Uint8Array(minCapacity);
12866
+ newBuffer.set(this.buffer.subarray(0, this.offset));
12867
+ this.buffer = newBuffer;
12868
+ }
12869
+ }
12870
+ writeUint8(value) {
12871
+ this.ensureCapacity(1);
12872
+ this.buffer[this.offset++] = value & 0xff;
12873
+ }
12874
+ writeUint32(value) {
12875
+ this.ensureCapacity(4);
12876
+ this.buffer[this.offset++] = (value >>> 24) & 0xff;
12877
+ this.buffer[this.offset++] = (value >>> 16) & 0xff;
12878
+ this.buffer[this.offset++] = (value >>> 8) & 0xff;
12879
+ this.buffer[this.offset++] = value & 0xff;
12880
+ }
12881
+ writeUint64(value) {
12882
+ this.ensureCapacity(8);
12883
+ const high = Number(value >> 32n);
12884
+ const low = Number(value & 0xffffffffn);
12885
+ this.writeUint32(high);
12886
+ this.writeUint32(low);
12887
+ }
12888
+ writeBytes(data) {
12889
+ this.ensureCapacity(data.length);
12890
+ this.buffer.set(data, this.offset);
12891
+ this.offset += data.length;
12892
+ }
12893
+ writeString(value) {
12894
+ const bytes = encoder.encode(value);
12895
+ this.writeUint32(bytes.length);
12896
+ this.writeBytes(bytes);
12897
+ }
12898
+ writeMpInt(value, sshEncoding = false) {
12899
+ if (sshEncoding && value.length > 0 && (value[0] & 0x80) !== 0) {
12900
+ const paddedBytes = new Uint8Array(value.length + 1);
12901
+ paddedBytes[0] = 0x00;
12902
+ paddedBytes.set(value, 1);
12903
+ this.writeUint32(paddedBytes.length);
12904
+ this.writeBytes(paddedBytes);
12905
+ }
12906
+ else {
12907
+ this.writeUint32(value.length);
12908
+ this.writeBytes(value);
12909
+ }
12910
+ }
12911
+ writeMpIntSsh(value) {
12912
+ this.writeMpInt(value, true);
12913
+ }
12914
+ toUint8Array() {
12915
+ return this.buffer.subarray(0, this.offset);
12916
+ }
12917
+ getOffset() {
12918
+ return this.offset;
12919
+ }
12920
+ seek(offset) {
12921
+ if (offset < 0 || offset > this.buffer.length) {
12922
+ throw new InvalidFormatError('Invalid offset');
12923
+ }
12924
+ this.offset = offset;
12925
+ }
12926
+ }
12927
+
12928
+ class RsaBinding {
12929
+ hash = 'SHA-256';
12930
+ constructor(hash = 'SHA-256') {
12931
+ this.hash = hash;
12932
+ }
12933
+ async importPublicSsh(params) {
12934
+ const { blob, crypto } = params;
12935
+ const reader = new SshReader(blob);
12936
+ reader.readString();
12937
+ const e = reader.readMpInt(true);
12938
+ const n = reader.readMpInt(true);
12939
+ const jwk = {
12940
+ kty: 'RSA',
12941
+ n: buildExports.Convert.ToBase64Url(n),
12942
+ e: buildExports.Convert.ToBase64Url(e),
12943
+ };
12944
+ return crypto.subtle.importKey('jwk', jwk, {
12945
+ name: 'RSASSA-PKCS1-v1_5',
12946
+ hash: this.hash,
12947
+ }, true, ['verify']);
12948
+ }
12949
+ async exportPublicSsh(params) {
12950
+ const { publicKey, crypto } = params;
12951
+ const jwk = await crypto.subtle.exportKey('jwk', publicKey);
12952
+ if (!jwk.n || !jwk.e) {
12953
+ throw new InvalidKeyDataError('RSA JWK missing required parameters (n, e)');
12954
+ }
12955
+ const n = buildExports.BufferSourceConverter.toUint8Array(buildExports.Convert.FromBase64Url(jwk.n));
12956
+ const e = buildExports.BufferSourceConverter.toUint8Array(buildExports.Convert.FromBase64Url(jwk.e));
12957
+ const writer = new SshWriter();
12958
+ writer.writeString('ssh-rsa');
12959
+ writer.writeMpInt(e, true);
12960
+ writer.writeMpInt(n, true);
12961
+ return writer.toUint8Array();
12962
+ }
12963
+ async importPublicSpki(params) {
12964
+ const { spki, crypto } = params;
12965
+ return crypto.subtle.importKey('spki', spki, {
12966
+ name: 'RSASSA-PKCS1-v1_5',
12967
+ hash: this.hash,
12968
+ }, true, ['verify']);
12969
+ }
12970
+ async exportPublicSpki(params) {
12971
+ const { publicKey, crypto } = params;
12972
+ const spki = await crypto.subtle.exportKey('spki', publicKey);
12973
+ return buildExports.BufferSourceConverter.toUint8Array(spki);
12974
+ }
12975
+ async importPrivatePkcs8(params) {
12976
+ const { pkcs8, crypto } = params;
12977
+ return crypto.subtle.importKey('pkcs8', pkcs8, {
12978
+ name: 'RSASSA-PKCS1-v1_5',
12979
+ hash: this.hash,
12980
+ }, true, ['sign']);
12981
+ }
12982
+ async exportPrivatePkcs8(params) {
12983
+ const { privateKey, crypto } = params;
12984
+ const pkcs8 = await crypto.subtle.exportKey('pkcs8', privateKey);
12985
+ return buildExports.BufferSourceConverter.toUint8Array(pkcs8);
12986
+ }
12987
+ async importPrivateSsh(params) {
12988
+ const { sshKey, crypto } = params;
12989
+ const base64Data = sshKey
12990
+ .replace(/-----BEGIN OPENSSH PRIVATE KEY-----/, '')
12991
+ .replace(/-----END OPENSSH PRIVATE KEY-----/, '')
12992
+ .replace(/\s/g, '');
12993
+ const binaryData = buildExports.Convert.FromBase64(base64Data);
12994
+ const reader = new SshReader(buildExports.BufferSourceConverter.toUint8Array(binaryData));
12995
+ const magic = reader.readBytes(15);
12996
+ if (buildExports.Convert.ToHex(magic) !== '6f70656e7373682d6b65792d763100') {
12997
+ throw new InvalidPrivateKeyFormatError('invalid magic string');
12998
+ }
12999
+ const _cipherName = reader.readString();
13000
+ reader.readString();
13001
+ reader.readString();
13002
+ if (_cipherName !== 'none') {
13003
+ throw new EncryptedKeyNotSupportedError(_cipherName);
13004
+ }
13005
+ const numKeys = reader.readUint32();
13006
+ if (numKeys !== 1) {
13007
+ throw new InvalidPrivateKeyFormatError('multiple keys not supported');
13008
+ }
13009
+ const publicKeyLength = reader.readUint32();
13010
+ reader.readBytes(publicKeyLength);
13011
+ const privateKeyLength = reader.readUint32();
13012
+ const privateKeyData = reader.readBytes(privateKeyLength);
13013
+ const privateReader = new SshReader(privateKeyData);
13014
+ const checkint1 = privateReader.readUint32();
13015
+ const checkint2 = privateReader.readUint32();
13016
+ if (checkint1 !== checkint2) {
13017
+ throw new InvalidPrivateKeyFormatError('invalid checkints');
13018
+ }
13019
+ privateReader.readString();
13020
+ const n = privateReader.readMpInt(true);
13021
+ const e = privateReader.readMpInt(true);
13022
+ const d = privateReader.readMpInt(true);
13023
+ const iqmp = privateReader.readMpInt(true);
13024
+ const p = privateReader.readMpInt(true);
13025
+ const q = privateReader.readMpInt(true);
13026
+ privateReader.readString();
13027
+ const dBig = BigInt('0x' + buildExports.Convert.ToHex(d));
13028
+ const pBig = BigInt('0x' + buildExports.Convert.ToHex(p));
13029
+ const qBig = BigInt('0x' + buildExports.Convert.ToHex(q));
13030
+ const dpBig = dBig % (pBig - 1n);
13031
+ const dqBig = dBig % (qBig - 1n);
13032
+ const dpBytes = buildExports.Convert.FromHex(dpBig.toString(16).padStart(p.length * 2, '0'));
13033
+ const dqBytes = buildExports.Convert.FromHex(dqBig.toString(16).padStart(q.length * 2, '0'));
13034
+ const jwk = {
13035
+ kty: 'RSA',
13036
+ n: buildExports.Convert.ToBase64Url(n),
13037
+ e: buildExports.Convert.ToBase64Url(e),
13038
+ d: buildExports.Convert.ToBase64Url(d),
13039
+ p: buildExports.Convert.ToBase64Url(p),
13040
+ q: buildExports.Convert.ToBase64Url(q),
13041
+ dp: buildExports.Convert.ToBase64Url(dpBytes),
13042
+ dq: buildExports.Convert.ToBase64Url(dqBytes),
13043
+ qi: buildExports.Convert.ToBase64Url(iqmp),
13044
+ };
13045
+ return crypto.subtle.importKey('jwk', jwk, {
13046
+ name: 'RSASSA-PKCS1-v1_5',
13047
+ hash: this.hash,
13048
+ }, true, ['sign']);
13049
+ }
13050
+ async exportPrivateSsh(params) {
13051
+ const { privateKey, crypto, jwk: providedJwk } = params;
13052
+ const jwk = providedJwk || (await crypto.subtle.exportKey('jwk', privateKey));
13053
+ if (!jwk.n || !jwk.e || !jwk.d || !jwk.p || !jwk.q) {
13054
+ throw new InvalidKeyDataError('RSA JWK missing required parameters');
13055
+ }
13056
+ const n = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.n));
13057
+ const e = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.e));
13058
+ const d = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.d));
13059
+ const p = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.p));
13060
+ const q = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.q));
13061
+ const qi = jwk.qi ? new Uint8Array(buildExports.Convert.FromBase64Url(jwk.qi)) : new Uint8Array();
13062
+ const writer = new SshWriter();
13063
+ writer.writeString('ssh-rsa');
13064
+ writer.writeMpInt(n, true);
13065
+ writer.writeMpInt(e, true);
13066
+ writer.writeMpInt(d, true);
13067
+ writer.writeMpInt(qi, true);
13068
+ writer.writeMpInt(p, true);
13069
+ writer.writeMpInt(q, true);
13070
+ return writer.toUint8Array();
13071
+ }
13072
+ async sign(params) {
13073
+ const { privateKey, data, crypto, hash } = params;
13074
+ if (hash && hash !== this.hash) {
13075
+ throw new InvalidKeyDataError(`Hash ${hash} not supported for this RSA algorithm`);
13076
+ }
13077
+ if (!privateKey.extractable) {
13078
+ throw new InvalidKeyDataError('Private key is not extractable');
13079
+ }
13080
+ const pkcs8 = await this.exportPrivatePkcs8({ privateKey, crypto });
13081
+ const keyToUse = await this.importPrivatePkcs8({ pkcs8: new Uint8Array(pkcs8), crypto });
13082
+ const signature = await crypto.subtle.sign('RSASSA-PKCS1-v1_5', keyToUse, data);
13083
+ return buildExports.BufferSourceConverter.toUint8Array(signature);
13084
+ }
13085
+ async verify(params) {
13086
+ const { publicKey, signature, data, crypto, hash } = params;
13087
+ if (hash && hash !== this.hash) {
13088
+ return false;
13089
+ }
13090
+ if (!publicKey.extractable) {
13091
+ throw new InvalidKeyDataError('Public key is not extractable');
13092
+ }
13093
+ const spki = await this.exportPublicSpki({ publicKey, crypto });
13094
+ const keyToUse = await this.importPublicSpki({ spki: new Uint8Array(spki), crypto });
13095
+ return crypto.subtle.verify('RSASSA-PKCS1-v1_5', keyToUse, signature, data);
13096
+ }
13097
+ encodeSignature(params) {
13098
+ const { signature, algo } = params;
13099
+ const writer = new SshWriter();
13100
+ writer.writeString(algo);
13101
+ writer.writeUint32(signature.byteLength);
13102
+ writer.writeBytes(signature);
13103
+ return writer.toUint8Array();
13104
+ }
13105
+ decodeSignature(params) {
13106
+ const { signature } = params;
13107
+ const reader = new SshReader(signature);
13108
+ const algo = reader.readString();
13109
+ const sigLength = reader.readUint32();
13110
+ const sig = reader.readBytes(sigLength);
13111
+ return { signature: sig, algo };
13112
+ }
13113
+ supportsCryptoKey(cryptoKey) {
13114
+ return cryptoKey.algorithm.name === 'RSASSA-PKCS1-v1_5';
13115
+ }
13116
+ parsePublicKey(reader) {
13117
+ const publicKeyExponent = reader.readBytes(reader.readUint32());
13118
+ const publicKeyModulus = reader.readBytes(reader.readUint32());
13119
+ const writer = new SshWriter();
13120
+ writer.writeString('ssh-rsa');
13121
+ writer.writeMpInt(publicKeyExponent);
13122
+ writer.writeMpInt(publicKeyModulus);
13123
+ return {
13124
+ type: 'ssh-rsa',
13125
+ keyData: writer.toUint8Array(),
13126
+ };
13127
+ }
13128
+ writePublicKey(writer, publicKey) {
13129
+ const publicKeyReader = new SshReader(publicKey.keyData);
13130
+ publicKeyReader.readString();
13131
+ const e = publicKeyReader.readMpInt();
13132
+ const n = publicKeyReader.readMpInt();
13133
+ writer.writeUint32(e.length);
13134
+ writer.writeBytes(e);
13135
+ writer.writeUint32(n.length);
13136
+ writer.writeBytes(n);
13137
+ }
13138
+ getCertificateType() {
13139
+ return 'ssh-rsa-cert-v01@openssh.com';
13140
+ }
13141
+ getSignatureAlgo() {
13142
+ return this.hash === 'SHA-256' ? 'rsa-sha2-256' : 'rsa-sha2-512';
13143
+ }
13144
+ }
13145
+
13146
+ class EcdsaBinding {
13147
+ curveName;
13148
+ sshType;
13149
+ namedCurve;
13150
+ constructor(curveName, sshType, namedCurve) {
13151
+ this.curveName = curveName;
13152
+ this.sshType = sshType;
13153
+ this.namedCurve = namedCurve;
13154
+ }
13155
+ getHashAlgorithm() {
13156
+ switch (this.namedCurve) {
13157
+ case 'P-256':
13158
+ return 'SHA-256';
13159
+ case 'P-384':
13160
+ return 'SHA-384';
13161
+ case 'P-521':
13162
+ return 'SHA-512';
13163
+ default:
13164
+ return 'SHA-256';
13165
+ }
13166
+ }
13167
+ getExpectedLength() {
13168
+ switch (this.namedCurve) {
13169
+ case 'P-256':
13170
+ return 32;
13171
+ case 'P-384':
13172
+ return 48;
13173
+ case 'P-521':
13174
+ return 66;
13175
+ default:
13176
+ return 32;
13177
+ }
13178
+ }
13179
+ getSignatureCoordLength() {
13180
+ return this.getExpectedLength();
13181
+ }
13182
+ async importPublicSsh(params) {
13183
+ const { blob, crypto } = params;
13184
+ const reader = new SshReader(blob);
13185
+ reader.readString();
13186
+ const curve = reader.readString();
13187
+ if (curve !== this.curveName) {
13188
+ throw new InvalidKeyDataError(`ECDSA curve name ${curve}, expected ${this.curveName}`);
13189
+ }
13190
+ const q = reader.readMpInt();
13191
+ const coordLength = Math.floor((q.length - 1) / 2);
13192
+ const jwk = {
13193
+ kty: 'EC',
13194
+ crv: this.namedCurve,
13195
+ x: buildExports.Convert.ToBase64Url(q.slice(1, 1 + coordLength)),
13196
+ y: buildExports.Convert.ToBase64Url(q.slice(1 + coordLength)),
13197
+ };
13198
+ return crypto.subtle.importKey('jwk', jwk, {
13199
+ name: 'ECDSA',
13200
+ namedCurve: this.namedCurve,
13201
+ }, true, ['verify']);
13202
+ }
13203
+ async exportPublicSsh(params) {
13204
+ const { publicKey, crypto } = params;
13205
+ const jwk = await crypto.subtle.exportKey('jwk', publicKey);
13206
+ if (!jwk.x || !jwk.y) {
13207
+ throw new InvalidKeyDataError('ECDSA JWK missing x or y parameters');
13208
+ }
13209
+ const x = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.x));
13210
+ const y = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.y));
13211
+ const q = new Uint8Array(1 + x.length + y.length);
13212
+ q[0] = 0x04;
13213
+ q.set(x, 1);
13214
+ q.set(y, 1 + x.length);
13215
+ const writer = new SshWriter();
13216
+ writer.writeString(this.sshType);
13217
+ writer.writeString(this.curveName);
13218
+ writer.writeMpInt(q);
13219
+ return writer.toUint8Array();
13220
+ }
13221
+ async importPublicSpki(params) {
13222
+ const { spki, crypto } = params;
13223
+ return crypto.subtle.importKey('spki', spki, {
13224
+ name: 'ECDSA',
13225
+ namedCurve: this.namedCurve,
13226
+ }, true, ['verify']);
13227
+ }
13228
+ async exportPublicSpki(params) {
13229
+ const { publicKey, crypto } = params;
13230
+ const spki = await crypto.subtle.exportKey('spki', publicKey);
13231
+ return buildExports.BufferSourceConverter.toUint8Array(spki);
13232
+ }
13233
+ async importPrivatePkcs8(params) {
13234
+ const { pkcs8, crypto } = params;
13235
+ return crypto.subtle.importKey('pkcs8', pkcs8, {
13236
+ name: 'ECDSA',
13237
+ namedCurve: this.namedCurve,
13238
+ }, true, ['sign']);
13239
+ }
13240
+ async exportPrivatePkcs8(params) {
13241
+ const { privateKey, crypto } = params;
13242
+ const pkcs8 = await crypto.subtle.exportKey('pkcs8', privateKey);
13243
+ return buildExports.BufferSourceConverter.toUint8Array(pkcs8);
13244
+ }
13245
+ async exportPrivateSsh(params) {
13246
+ const { privateKey, crypto, jwk: providedJwk } = params;
13247
+ const jwk = providedJwk || (await crypto.subtle.exportKey('jwk', privateKey));
13248
+ if (!jwk.d || !jwk.x || !jwk.y) {
13249
+ throw new InvalidKeyDataError('ECDSA private key JWK missing required parameters');
13250
+ }
13251
+ const x = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.x));
13252
+ const y = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.y));
13253
+ const d = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.d));
13254
+ const publicPoint = new Uint8Array(1 + x.length + y.length);
13255
+ publicPoint[0] = 0x04;
13256
+ publicPoint.set(x, 1);
13257
+ publicPoint.set(y, 1 + x.length);
13258
+ const writer = new SshWriter();
13259
+ writer.writeString(this.sshType);
13260
+ writer.writeString(this.curveName);
13261
+ writer.writeMpInt(publicPoint);
13262
+ writer.writeMpInt(d);
13263
+ return writer.toUint8Array();
13264
+ }
13265
+ async importPrivateSsh(params) {
13266
+ const { sshKey, crypto } = params;
13267
+ const base64Data = sshKey
13268
+ .replace(/-----BEGIN OPENSSH PRIVATE KEY-----/, '')
13269
+ .replace(/-----END OPENSSH PRIVATE KEY-----/, '')
13270
+ .replace(/\s/g, '');
13271
+ const binaryData = buildExports.Convert.FromBase64(base64Data);
13272
+ const reader = new SshReader(buildExports.BufferSourceConverter.toUint8Array(binaryData));
13273
+ const magic = reader.readBytes(15);
13274
+ if (buildExports.Convert.ToHex(magic) !== '6f70656e7373682d6b65792d763100') {
13275
+ throw new InvalidPrivateKeyFormatError('invalid magic string');
13276
+ }
13277
+ const _cipherName = reader.readString();
13278
+ reader.readString();
13279
+ reader.readString();
13280
+ if (_cipherName !== 'none') {
13281
+ throw new EncryptedKeyNotSupportedError(_cipherName);
13282
+ }
13283
+ const numKeys = reader.readUint32();
13284
+ if (numKeys !== 1) {
13285
+ throw new InvalidPrivateKeyFormatError('multiple keys not supported');
13286
+ }
13287
+ const publicKeyLength = reader.readUint32();
13288
+ reader.readBytes(publicKeyLength);
13289
+ const privateKeyLength = reader.readUint32();
13290
+ const privateKeyData = reader.readBytes(privateKeyLength);
13291
+ const privateReader = new SshReader(privateKeyData);
13292
+ const checkint1 = privateReader.readUint32();
13293
+ const checkint2 = privateReader.readUint32();
13294
+ if (checkint1 !== checkint2) {
13295
+ throw new InvalidPrivateKeyFormatError('invalid checkints');
13296
+ }
13297
+ privateReader.readString();
13298
+ privateReader.readString();
13299
+ const publicKeyPoint = privateReader.readMpInt();
13300
+ const privateKeyValue = privateReader.readMpInt();
13301
+ privateReader.readString();
13302
+ if (publicKeyPoint[0] !== 0x04) {
13303
+ throw new InvalidKeyDataError('invalid ECDSA public key point format');
13304
+ }
13305
+ const coordLength = Math.floor((publicKeyPoint.length - 1) / 2);
13306
+ const x = publicKeyPoint.slice(1, 1 + coordLength);
13307
+ const y = publicKeyPoint.slice(1 + coordLength);
13308
+ const jwk = {
13309
+ kty: 'EC',
13310
+ crv: this.namedCurve,
13311
+ x: buildExports.Convert.ToBase64Url(x),
13312
+ y: buildExports.Convert.ToBase64Url(y),
13313
+ d: buildExports.Convert.ToBase64Url(privateKeyValue),
13314
+ };
13315
+ return crypto.subtle.importKey('jwk', jwk, {
13316
+ name: 'ECDSA',
13317
+ namedCurve: this.namedCurve,
13318
+ }, true, ['sign']);
13319
+ }
13320
+ async sign(params) {
13321
+ const { privateKey, data, crypto, hash } = params;
13322
+ const expectedHash = this.getHashAlgorithm();
13323
+ if (hash && hash !== expectedHash) {
13324
+ throw new InvalidKeyDataError(`ECDSA ${this.namedCurve} requires ${expectedHash}, got ${hash}`);
13325
+ }
13326
+ const signature = await crypto.subtle.sign({
13327
+ name: 'ECDSA',
13328
+ hash: expectedHash,
13329
+ }, privateKey, data);
13330
+ return buildExports.BufferSourceConverter.toUint8Array(signature);
13331
+ }
13332
+ async verify(params) {
13333
+ const { publicKey, signature, data, crypto, hash } = params;
13334
+ const expectedHash = this.getHashAlgorithm();
13335
+ if (hash && hash !== expectedHash) {
13336
+ throw new InvalidKeyDataError(`ECDSA ${this.namedCurve} requires ${expectedHash}, got ${hash}`);
13337
+ }
13338
+ return crypto.subtle.verify({
13339
+ name: 'ECDSA',
13340
+ hash: expectedHash,
13341
+ }, publicKey, signature, data);
13342
+ }
13343
+ encodeSignature(params) {
13344
+ const { signature, algo } = params;
13345
+ if (algo.startsWith('ecdsa-sha2-')) {
13346
+ const coordLength = this.getSignatureCoordLength();
13347
+ const r = signature.subarray(0, coordLength);
13348
+ const s = signature.subarray(coordLength);
13349
+ const writer = new SshWriter();
13350
+ writer.writeString(algo);
13351
+ const sigWriter = new SshWriter();
13352
+ sigWriter.writeMpInt(r, true);
13353
+ sigWriter.writeMpInt(s, true);
13354
+ const sigData = sigWriter.toUint8Array();
13355
+ writer.writeUint32(sigData.length);
13356
+ writer.writeBytes(sigData);
13357
+ return writer.toUint8Array();
13358
+ }
13359
+ const writer = new SshWriter();
13360
+ writer.writeString(algo);
13361
+ writer.writeUint32(signature.byteLength);
13362
+ writer.writeBytes(signature);
13363
+ return writer.toUint8Array();
13364
+ }
13365
+ decodeSignature(params) {
13366
+ const { signature } = params;
13367
+ const reader = new SshReader(signature);
13368
+ const algo = reader.readString();
13369
+ const sigLength = reader.readUint32();
13370
+ const sig = reader.readBytes(sigLength);
13371
+ if (algo.startsWith('ecdsa-sha2-')) {
13372
+ const sigReader = new SshReader(sig);
13373
+ let r = sigReader.readMpInt();
13374
+ let s = sigReader.readMpInt();
13375
+ if (r[0] === 0x00 && r.length > 1 && (r[1] & 0x80) === 0) {
13376
+ r = r.slice(1);
13377
+ }
13378
+ if (s[0] === 0x00 && s.length > 1 && (s[1] & 0x80) === 0) {
13379
+ s = s.slice(1);
13380
+ }
13381
+ const expectedLength = this.getExpectedLength();
13382
+ const rPadded = new Uint8Array(expectedLength);
13383
+ const sPadded = new Uint8Array(expectedLength);
13384
+ if (r.length <= expectedLength) {
13385
+ rPadded.set(r, expectedLength - r.length);
13386
+ }
13387
+ else {
13388
+ rPadded.set(r.slice(r.length - expectedLength), 0);
13389
+ }
13390
+ if (s.length <= expectedLength) {
13391
+ sPadded.set(s, expectedLength - s.length);
13392
+ }
13393
+ else {
13394
+ sPadded.set(s.slice(s.length - expectedLength), 0);
13395
+ }
13396
+ const rawSignature = new Uint8Array([...rPadded, ...sPadded]);
13397
+ return { signature: rawSignature, algo };
13398
+ }
13399
+ return { signature: sig, algo };
13400
+ }
13401
+ supportsCryptoKey(cryptoKey) {
13402
+ return (cryptoKey.algorithm.name === 'ECDSA' &&
13403
+ cryptoKey.algorithm.namedCurve === this.namedCurve);
13404
+ }
13405
+ parsePublicKey(reader) {
13406
+ const curveName = reader.readString();
13407
+ if (curveName !== this.curveName) {
13408
+ throw new InvalidKeyDataError(`ECDSA certificate curve name ${curveName}, expected ${this.curveName}`);
13409
+ }
13410
+ const publicKeyPoint = reader.readBytes(reader.readUint32());
13411
+ const writer = new SshWriter();
13412
+ writer.writeString(this.sshType);
13413
+ writer.writeString(curveName);
13414
+ writer.writeMpInt(publicKeyPoint);
13415
+ return {
13416
+ type: this.sshType,
13417
+ keyData: writer.toUint8Array(),
13418
+ };
13419
+ }
13420
+ writePublicKey(writer, publicKey) {
13421
+ const publicKeyReader = new SshReader(publicKey.keyData);
13422
+ publicKeyReader.readString();
13423
+ const curveName = publicKeyReader.readString();
13424
+ const publicPoint = publicKeyReader.readMpInt();
13425
+ writer.writeString(curveName);
13426
+ writer.writeUint32(publicPoint.length);
13427
+ writer.writeBytes(publicPoint);
13428
+ }
13429
+ getCertificateType() {
13430
+ return `${this.sshType}-cert-v01@openssh.com`;
13431
+ }
13432
+ getSignatureAlgo() {
13433
+ return this.sshType;
13434
+ }
13435
+ }
13436
+ const EcdsaP256Binding = new EcdsaBinding('nistp256', 'ecdsa-sha2-nistp256', 'P-256');
13437
+ const EcdsaP384Binding = new EcdsaBinding('nistp384', 'ecdsa-sha2-nistp384', 'P-384');
13438
+ const EcdsaP521Binding = new EcdsaBinding('nistp521', 'ecdsa-sha2-nistp521', 'P-521');
13439
+
13440
+ class Ed25519Binding {
13441
+ async importPublicSsh(params) {
13442
+ const { blob, crypto } = params;
13443
+ const reader = new SshReader(blob);
13444
+ reader.readString();
13445
+ const keyLength = reader.readUint32();
13446
+ if (keyLength !== 32) {
13447
+ throw new InvalidKeyDataError(`Ed25519 key length ${keyLength}, expected 32`);
13448
+ }
13449
+ const publicKeyBytes = reader.readBytes(keyLength);
13450
+ return crypto.subtle.importKey('raw', publicKeyBytes, 'Ed25519', true, [
13451
+ 'verify',
13452
+ ]);
13453
+ }
13454
+ async exportPublicSsh(params) {
13455
+ const { publicKey, crypto } = params;
13456
+ const jwk = await crypto.subtle.exportKey('jwk', publicKey);
13457
+ if (!jwk.x) {
13458
+ throw new InvalidKeyDataError('Ed25519 JWK missing x parameter');
13459
+ }
13460
+ const keyBytes = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.x));
13461
+ const writer = new SshWriter();
13462
+ writer.writeString('ssh-ed25519');
13463
+ writer.writeUint32(keyBytes.length);
13464
+ writer.writeBytes(keyBytes);
13465
+ return writer.toUint8Array();
13466
+ }
13467
+ async importPublicSpki(params) {
13468
+ const { spki, crypto } = params;
13469
+ return crypto.subtle.importKey('spki', spki, 'Ed25519', true, ['verify']);
13470
+ }
13471
+ async exportPublicSpki(params) {
13472
+ const { publicKey, crypto } = params;
13473
+ const spki = await crypto.subtle.exportKey('spki', publicKey);
13474
+ return buildExports.BufferSourceConverter.toUint8Array(spki);
13475
+ }
13476
+ async importPrivatePkcs8(params) {
13477
+ const { pkcs8, crypto } = params;
13478
+ return crypto.subtle.importKey('pkcs8', pkcs8, 'Ed25519', true, ['sign']);
13479
+ }
13480
+ async exportPrivatePkcs8(params) {
13481
+ const { privateKey, crypto } = params;
13482
+ const pkcs8 = await crypto.subtle.exportKey('pkcs8', privateKey);
13483
+ return buildExports.BufferSourceConverter.toUint8Array(pkcs8);
13484
+ }
13485
+ async exportPrivateSsh(params) {
13486
+ const { privateKey, crypto, jwk: providedJwk } = params;
13487
+ const jwk = providedJwk || (await crypto.subtle.exportKey('jwk', privateKey));
13488
+ if (!jwk.d || !jwk.x) {
13489
+ throw new InvalidKeyDataError('Ed25519 private key JWK missing required parameters');
13490
+ }
13491
+ const privateBytes = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.d));
13492
+ const publicBytes = new Uint8Array(buildExports.Convert.FromBase64Url(jwk.x));
13493
+ const writer = new SshWriter();
13494
+ writer.writeString('ssh-ed25519');
13495
+ writer.writeUint32(publicBytes.length);
13496
+ writer.writeBytes(publicBytes);
13497
+ const privKeyPart = new Uint8Array(64);
13498
+ privKeyPart.set(privateBytes, 0);
13499
+ privKeyPart.set(publicBytes, 32);
13500
+ writer.writeUint32(privKeyPart.length);
13501
+ writer.writeBytes(privKeyPart);
13502
+ return writer.toUint8Array();
13503
+ }
13504
+ async importPrivateSsh(params) {
13505
+ const { sshKey, crypto } = params;
13506
+ const base64Data = sshKey
13507
+ .replace(/-----BEGIN OPENSSH PRIVATE KEY-----/, '')
13508
+ .replace(/-----END OPENSSH PRIVATE KEY-----/, '')
13509
+ .replace(/\s/g, '');
13510
+ const binaryData = buildExports.Convert.FromBase64(base64Data);
13511
+ const reader = new SshReader(buildExports.BufferSourceConverter.toUint8Array(binaryData));
13512
+ const magic = reader.readBytes(15);
13513
+ if (buildExports.Convert.ToHex(magic) !== '6f70656e7373682d6b65792d763100') {
13514
+ throw new InvalidPrivateKeyFormatError('invalid magic string');
13515
+ }
13516
+ const _cipherName = reader.readString();
13517
+ reader.readString();
13518
+ reader.readString();
13519
+ if (_cipherName !== 'none') {
13520
+ throw new EncryptedKeyNotSupportedError(_cipherName);
13521
+ }
13522
+ const numKeys = reader.readUint32();
13523
+ if (numKeys !== 1) {
13524
+ throw new InvalidPrivateKeyFormatError('multiple keys not supported');
13525
+ }
13526
+ const publicKeyLength = reader.readUint32();
13527
+ reader.readBytes(publicKeyLength);
13528
+ const privateKeyLength = reader.readUint32();
13529
+ const privateKeyData = reader.readBytes(privateKeyLength);
13530
+ const privateReader = new SshReader(privateKeyData);
13531
+ const checkint1 = privateReader.readUint32();
13532
+ const checkint2 = privateReader.readUint32();
13533
+ if (checkint1 !== checkint2) {
13534
+ throw new InvalidPrivateKeyFormatError('invalid checkints');
13535
+ }
13536
+ privateReader.readString();
13537
+ const pubKeyLength = privateReader.readUint32();
13538
+ const _publicKeyBytes = privateReader.readBytes(pubKeyLength);
13539
+ const privKeyLength = privateReader.readUint32();
13540
+ const privateKeyBytes = privateReader.readBytes(privKeyLength);
13541
+ privateReader.readString();
13542
+ const privateKey = privateKeyBytes.slice(0, 32);
13543
+ const jwk = {
13544
+ kty: 'OKP',
13545
+ crv: 'Ed25519',
13546
+ d: buildExports.Convert.ToBase64Url(privateKey),
13547
+ x: buildExports.Convert.ToBase64Url(_publicKeyBytes),
13548
+ };
13549
+ return crypto.subtle.importKey('jwk', jwk, 'Ed25519', true, ['sign']);
13550
+ }
13551
+ async sign(params) {
13552
+ const { privateKey, data, crypto } = params;
13553
+ const signature = await crypto.subtle.sign('Ed25519', privateKey, data);
13554
+ return buildExports.BufferSourceConverter.toUint8Array(signature);
13555
+ }
13556
+ async verify(params) {
13557
+ const { publicKey, signature, data, crypto } = params;
13558
+ return crypto.subtle.verify('Ed25519', publicKey, signature, data);
13559
+ }
13560
+ encodeSignature(params) {
13561
+ const { signature, algo } = params;
13562
+ const sigBytes = new Uint8Array(signature);
13563
+ const writer = new SshWriter();
13564
+ writer.writeString(algo);
13565
+ writer.writeUint32(sigBytes.length);
13566
+ writer.writeBytes(sigBytes);
13567
+ return writer.toUint8Array();
13568
+ }
13569
+ decodeSignature(params) {
13570
+ const { signature } = params;
13571
+ const reader = new SshReader(signature);
13572
+ const algo = reader.readString();
13573
+ const sigLength = reader.readUint32();
13574
+ const sigBytes = reader.readBytes(sigLength);
13575
+ return {
13576
+ signature: sigBytes,
13577
+ algo,
13578
+ };
13579
+ }
13580
+ supportsCryptoKey(cryptoKey) {
13581
+ return cryptoKey.algorithm.name === 'Ed25519';
13582
+ }
13583
+ parsePublicKey(reader) {
13584
+ const publicKeyData = reader.readBytes(reader.readUint32());
13585
+ const writer = new SshWriter();
13586
+ writer.writeString('ssh-ed25519');
13587
+ writer.writeUint32(publicKeyData.length);
13588
+ writer.writeBytes(publicKeyData);
13589
+ return {
13590
+ type: 'ssh-ed25519',
13591
+ keyData: writer.toUint8Array(),
13592
+ };
13593
+ }
13594
+ writePublicKey(writer, publicKey) {
13595
+ const publicKeyReader = new SshReader(publicKey.keyData);
13596
+ publicKeyReader.readString();
13597
+ const keyLength = publicKeyReader.readUint32();
13598
+ const rawKeyData = publicKeyReader.readBytes(keyLength);
13599
+ writer.writeUint32(rawKeyData.length);
13600
+ writer.writeBytes(rawKeyData);
13601
+ }
13602
+ getCertificateType() {
13603
+ return 'ssh-ed25519-cert-v01@openssh.com';
13604
+ }
13605
+ getSignatureAlgo() {
13606
+ return 'ssh-ed25519';
13607
+ }
13608
+ }
13609
+
13610
+ const registry = new Map();
13611
+ class AlgorithmRegistry {
13612
+ static get(name) {
13613
+ const binding = registry.get(name);
13614
+ if (!binding) {
13615
+ throw new UnsupportedKeyTypeError(name, Array.from(registry.keys()));
13616
+ }
13617
+ return binding;
13618
+ }
13619
+ static register(name, binding) {
13620
+ registry.set(name, binding);
13621
+ }
13622
+ static getSshTypeFromCryptoKey(cryptoKey) {
13623
+ for (const [sshType, binding] of registry.entries()) {
13624
+ if (binding.supportsCryptoKey(cryptoKey)) {
13625
+ return sshType;
13626
+ }
13627
+ }
13628
+ throw new UnsupportedKeyTypeError(cryptoKey.algorithm.name, Array.from(registry.keys()));
13629
+ }
13630
+ static certTypeToKeyType(certType) {
13631
+ const mapping = {
13632
+ 'ssh-rsa-cert-v01@openssh.com': 'ssh-rsa',
13633
+ 'ssh-ed25519-cert-v01@openssh.com': 'ssh-ed25519',
13634
+ 'ecdsa-sha2-nistp256-cert-v01@openssh.com': 'ecdsa-sha2-nistp256',
13635
+ 'ecdsa-sha2-nistp384-cert-v01@openssh.com': 'ecdsa-sha2-nistp384',
13636
+ 'ecdsa-sha2-nistp521-cert-v01@openssh.com': 'ecdsa-sha2-nistp521',
13637
+ };
13638
+ return mapping[certType];
13639
+ }
13640
+ static getSupportedCertTypes() {
13641
+ return Object.keys({
13642
+ 'ssh-rsa-cert-v01@openssh.com': 'ssh-rsa',
13643
+ 'ssh-ed25519-cert-v01@openssh.com': 'ssh-ed25519',
13644
+ 'ecdsa-sha2-nistp256-cert-v01@openssh.com': 'ecdsa-sha2-nistp256',
13645
+ 'ecdsa-sha2-nistp384-cert-v01@openssh.com': 'ecdsa-sha2-nistp384',
13646
+ 'ecdsa-sha2-nistp521-cert-v01@openssh.com': 'ecdsa-sha2-nistp521',
13647
+ });
13648
+ }
13649
+ }
13650
+ AlgorithmRegistry.register('ssh-ed25519', new Ed25519Binding());
13651
+ AlgorithmRegistry.register('ssh-rsa', new RsaBinding('SHA-256'));
13652
+ AlgorithmRegistry.register('rsa-sha2-256', new RsaBinding('SHA-256'));
13653
+ AlgorithmRegistry.register('rsa-sha2-512', new RsaBinding('SHA-512'));
13654
+ AlgorithmRegistry.register('ecdsa-sha2-nistp256', EcdsaP256Binding);
13655
+ AlgorithmRegistry.register('ecdsa-sha2-nistp384', EcdsaP384Binding);
13656
+ AlgorithmRegistry.register('ecdsa-sha2-nistp521', EcdsaP521Binding);
13657
+
13658
+ function parsePublicKey(input) {
13659
+ const parts = typeof input === 'string' ? input.trim().split(/\s+/) : null;
13660
+ if (!parts || parts.length < 2) {
13661
+ throw new InvalidFormatError('Invalid SSH public key format');
13662
+ }
13663
+ const type = parts[0];
13664
+ const blob = new Uint8Array(buildExports.Convert.FromBase64(parts[1]));
13665
+ const comment = parts.length > 2 ? parts.slice(2).join(' ') : undefined;
13666
+ const reader = new SshReader(blob);
13667
+ const blobType = reader.readString();
13668
+ if (blobType !== type) {
13669
+ throw new InvalidFormatError('Key type mismatch');
13670
+ }
13671
+ return {
13672
+ type,
13673
+ keyData: blob,
13674
+ comment,
13675
+ };
13676
+ }
13677
+ function serializePublicKey(blob) {
13678
+ const base64 = buildExports.Convert.ToBase64(blob.keyData);
13679
+ const parts = [blob.type, base64];
13680
+ if (blob.comment) {
13681
+ parts.push(blob.comment);
13682
+ }
13683
+ return parts.join(' ');
13684
+ }
13685
+
13686
+ function parse(input) {
13687
+ if (typeof input === 'string') {
13688
+ const parts = input.trim().split(/\s+/);
13689
+ if (parts.length < 2) {
13690
+ throw new InvalidFormatError('SSH certificate string', 'type base64 [comment]');
13691
+ }
13692
+ const type = parts[0];
13693
+ const blob = new Uint8Array(buildExports.Convert.FromBase64(parts[1]));
13694
+ const comment = parts.length > 2 ? parts.slice(2).join(' ') : undefined;
13695
+ const reader = new SshReader(blob);
13696
+ const blobType = reader.readString();
13697
+ if (blobType !== type) {
13698
+ throw new InvalidFormatError(`certificate blob type ${blobType}`, `expected ${type}`);
13699
+ }
13700
+ return {
13701
+ type,
13702
+ keyData: blob,
13703
+ comment,
13704
+ };
13705
+ }
13706
+ else {
13707
+ const reader = new SshReader(input);
13708
+ const type = reader.readString();
13709
+ const keyData = input.slice(reader.getOffset());
13710
+ return {
13711
+ type,
13712
+ keyData,
13713
+ };
13714
+ }
13715
+ }
13716
+ function parseCertificateData(keyData) {
13717
+ const reader = new SshReader(keyData);
13718
+ const certType = reader.readString();
13719
+ const nonce = reader.readBytes(reader.readUint32());
13720
+ const mappedKeyType = AlgorithmRegistry.certTypeToKeyType(certType);
13721
+ if (!mappedKeyType) {
13722
+ throw new UnsupportedAlgorithmError(certType, AlgorithmRegistry.getSupportedCertTypes());
13723
+ }
13724
+ const binding = AlgorithmRegistry.get(mappedKeyType);
13725
+ const publicKey = binding.parsePublicKey(reader);
13726
+ const keyType = mappedKeyType;
13727
+ const serial = reader.readUint64();
13728
+ const typeValue = reader.readUint32();
13729
+ const type = typeValue === 1 ? 'user' : 'host';
13730
+ const keyId = reader.readString();
13731
+ const principalsLength = reader.readUint32();
13732
+ const principalsData = reader.readBytes(principalsLength);
13733
+ const validPrincipals = [];
13734
+ if (principalsData.length > 0) {
13735
+ const principalsReader = new SshReader(principalsData);
13736
+ while (principalsReader.getOffset() < principalsData.length) {
13737
+ try {
13738
+ const principal = principalsReader.readString();
13739
+ validPrincipals.push(principal);
13740
+ }
13741
+ catch {
13742
+ break;
13743
+ }
13744
+ }
13745
+ }
13746
+ const validAfter = reader.readUint64();
13747
+ const validBefore = reader.readUint64();
13748
+ const criticalOptions = {};
13749
+ const criticalLength = reader.readUint32();
13750
+ const criticalData = reader.readBytes(criticalLength);
13751
+ if (criticalData.length > 0) {
13752
+ const optionsReader = new SshReader(criticalData);
13753
+ while (optionsReader.getOffset() < criticalData.length) {
13754
+ try {
13755
+ const name = optionsReader.readString();
13756
+ const valueData = optionsReader.readBytes(optionsReader.readUint32());
13757
+ const value = valueData.length === 0 ? '' : decoder.decode(valueData);
13758
+ criticalOptions[name] = value;
13759
+ }
13760
+ catch {
13761
+ break;
13762
+ }
13763
+ }
13764
+ }
13765
+ const extensions = {};
13766
+ const extensionsLength = reader.readUint32();
13767
+ const extensionsData = reader.readBytes(extensionsLength);
13768
+ if (extensionsData.length > 0) {
13769
+ const extReader = new SshReader(extensionsData);
13770
+ while (extReader.getOffset() < extensionsData.length) {
13771
+ try {
13772
+ const name = extReader.readString();
13773
+ const valueData = extReader.readBytes(extReader.readUint32());
13774
+ const value = valueData.length === 0 ? '' : decoder.decode(valueData);
13775
+ extensions[name] = value;
13776
+ }
13777
+ catch {
13778
+ break;
13779
+ }
13780
+ }
13781
+ }
13782
+ const reservedLength = reader.readUint32();
13783
+ const reserved = reader.readBytes(reservedLength);
13784
+ const signatureKeyLength = reader.readUint32();
13785
+ const signatureKeyData = reader.readBytes(signatureKeyLength);
13786
+ const signatureKeyReader = new SshReader(signatureKeyData);
13787
+ const signatureKeyType = signatureKeyReader.readString();
13788
+ const signatureKey = {
13789
+ type: signatureKeyType,
13790
+ keyData: signatureKeyData,
13791
+ };
13792
+ const signatureLength = reader.readUint32();
13793
+ const signature = reader.readBytes(signatureLength);
13794
+ return {
13795
+ nonce,
13796
+ keyType,
13797
+ publicKey,
13798
+ serial,
13799
+ type,
13800
+ keyId,
13801
+ validPrincipals,
13802
+ validAfter,
13803
+ validBefore,
13804
+ criticalOptions,
13805
+ extensions,
13806
+ reserved,
13807
+ signatureKey,
13808
+ signature,
13809
+ };
13810
+ }
13811
+ function serialize(cert) {
13812
+ const base64 = buildExports.Convert.ToBase64(cert.keyData);
13813
+ const parts = [cert.type, base64];
13814
+ if (cert.comment) {
13815
+ parts.push(cert.comment);
13816
+ }
13817
+ return parts.join(' ');
13818
+ }
13819
+
13820
+ function parseSignature(data) {
13821
+ const reader = new SshReader(data);
13822
+ if (data.length >= 6 && new TextDecoder().decode(data.subarray(0, 6)) === 'SSHSIG') {
13823
+ return parseSshSignatureFormat(reader);
13824
+ }
13825
+ else {
13826
+ return parseLegacyFormat(reader);
13827
+ }
13828
+ }
13829
+ function parseSshSignatureFormat(reader) {
13830
+ const magicBytes = reader.readBytes(6);
13831
+ const magic = new TextDecoder().decode(magicBytes);
13832
+ if (magic !== 'SSHSIG') {
13833
+ throw new InvalidFormatError(magic, 'SSHSIG');
13834
+ }
13835
+ const version = reader.readUint32();
13836
+ const publicKeyLength = reader.readUint32();
13837
+ const publicKey = reader.readBytes(publicKeyLength);
13838
+ const namespace = reader.readString();
13839
+ const reserved = reader.readString();
13840
+ const hashAlgorithm = reader.readString();
13841
+ const signatureLength = reader.readUint32();
13842
+ const signatureData = reader.readBytes(signatureLength);
13843
+ const sigReader = new SshReader(signatureData);
13844
+ const algorithm = sigReader.readString();
13845
+ const signatureLength2 = sigReader.readUint32();
13846
+ const signature = sigReader.readBytes(signatureLength2);
13847
+ return {
13848
+ format: 'ssh-signature',
13849
+ algorithm,
13850
+ signature,
13851
+ version,
13852
+ publicKey,
13853
+ namespace,
13854
+ reserved,
13855
+ hashAlgorithm,
13856
+ };
13857
+ }
13858
+ function parseLegacyFormat(reader) {
13859
+ const algorithm = reader.readString();
13860
+ const signatureLength = reader.readUint32();
13861
+ const signature = reader.readBytes(signatureLength);
13862
+ return {
13863
+ format: 'legacy',
13864
+ algorithm,
13865
+ signature,
13866
+ };
13867
+ }
13868
+ function serializeSignature(blob) {
13869
+ if (blob.format === 'ssh-signature') {
13870
+ return serializeSshSignatureFormat(blob);
13871
+ }
13872
+ else {
13873
+ return serializeLegacyFormat(blob);
13874
+ }
13875
+ }
13876
+ function serializeSshSignatureFormat(blob) {
13877
+ const writer = new SshWriter();
13878
+ writer.writeBytes(new TextEncoder().encode('SSHSIG'));
13879
+ writer.writeUint32(blob.version || 1);
13880
+ if (blob.publicKey) {
13881
+ writer.writeUint32(blob.publicKey.length);
13882
+ writer.writeBytes(blob.publicKey);
13883
+ }
13884
+ else {
13885
+ writer.writeUint32(0);
13886
+ }
13887
+ writer.writeString(blob.namespace || 'file');
13888
+ writer.writeString(blob.reserved || '');
13889
+ writer.writeString(blob.hashAlgorithm || 'sha512');
13890
+ const sigWriter = new SshWriter();
13891
+ sigWriter.writeString(blob.algorithm);
13892
+ sigWriter.writeUint32(blob.signature.length);
13893
+ sigWriter.writeBytes(blob.signature);
13894
+ const sigData = sigWriter.toUint8Array();
13895
+ writer.writeUint32(sigData.length);
13896
+ writer.writeBytes(sigData);
13897
+ return writer.toUint8Array();
13898
+ }
13899
+ function serializeLegacyFormat(blob) {
13900
+ const writer = new SshWriter();
13901
+ writer.writeString(blob.algorithm);
13902
+ writer.writeUint32(blob.signature.length);
13903
+ writer.writeBytes(blob.signature);
13904
+ return writer.toUint8Array();
13905
+ }
13906
+
13907
+ class SshObject {
13908
+ }
13909
+
13910
+ class SshPublicKey extends SshObject {
13911
+ static TYPE = 'public-key';
13912
+ type = SshPublicKey.TYPE;
13913
+ blob;
13914
+ cachedCryptoKey;
13915
+ constructor(blob) {
13916
+ super();
13917
+ this.blob = blob;
13918
+ }
13919
+ async getCryptoKey(crypto = getCrypto()) {
13920
+ if (!this.cachedCryptoKey) {
13921
+ const binding = AlgorithmRegistry.get(this.blob.type);
13922
+ this.cachedCryptoKey = await binding.importPublicSsh({ blob: this.blob.keyData, crypto });
13923
+ }
13924
+ return this.cachedCryptoKey;
13925
+ }
13926
+ static async fromSSH(sshKey, crypto = getCrypto()) {
13927
+ const blob = parsePublicKey(sshKey);
13928
+ const binding = AlgorithmRegistry.get(blob.type);
13929
+ await binding.importPublicSsh({ blob: blob.keyData, crypto });
13930
+ return new SshPublicKey(blob);
13931
+ }
13932
+ static async fromSPKI(spki, type, crypto = getCrypto()) {
13933
+ const binding = AlgorithmRegistry.get(type);
13934
+ const cryptoKey = await binding.importPublicSpki({ spki, crypto });
13935
+ const exported = await binding.exportPublicSsh({ publicKey: cryptoKey, crypto });
13936
+ const blob = {
13937
+ type,
13938
+ keyData: exported,
13939
+ };
13940
+ return new SshPublicKey(blob);
13941
+ }
13942
+ static async fromWebCrypto(cryptoKey, type, crypto = getCrypto()) {
13943
+ const sshType = type || AlgorithmRegistry.getSshTypeFromCryptoKey(cryptoKey);
13944
+ const binding = AlgorithmRegistry.get(sshType);
13945
+ const exported = await binding.exportPublicSsh({ publicKey: cryptoKey, crypto });
13946
+ const blob = {
13947
+ type: sshType,
13948
+ keyData: exported,
13949
+ };
13950
+ return new SshPublicKey(blob);
13951
+ }
13952
+ async export(format = 'ssh', crypto = getCrypto()) {
13953
+ if (format === 'ssh') {
13954
+ return serializePublicKey(this.blob);
13955
+ }
13956
+ else if (format === 'spki') {
13957
+ const cryptoKey = await this.getCryptoKey(crypto);
13958
+ const binding = AlgorithmRegistry.get(this.blob.type);
13959
+ const spki = await binding.exportPublicSpki({ publicKey: cryptoKey, crypto });
13960
+ return new Uint8Array(spki);
13961
+ }
13962
+ throw new UnsupportedKeyTypeError(`Unsupported export format: ${format}`);
13963
+ }
13964
+ async toSSH() {
13965
+ const result = await this.export('ssh');
13966
+ return result;
13967
+ }
13968
+ async toSPKI() {
13969
+ const result = await this.export('spki');
13970
+ return result;
13971
+ }
13972
+ async toWebCrypto(crypto = getCrypto()) {
13973
+ return this.getCryptoKey(crypto);
13974
+ }
13975
+ async verify(algorithm, signature, data, crypto = getCrypto()) {
13976
+ const binding = AlgorithmRegistry.get(algorithm);
13977
+ const cryptoKey = await this.toWebCrypto(crypto);
13978
+ return binding.verify({
13979
+ publicKey: cryptoKey,
13980
+ signature,
13981
+ data,
13982
+ crypto,
13983
+ });
13984
+ }
13985
+ get keyType() {
13986
+ return this.blob.type;
13987
+ }
13988
+ get comment() {
13989
+ return this.blob.comment;
13990
+ }
13991
+ getBlob() {
13992
+ return { ...this.blob };
13993
+ }
13994
+ async thumbprint(algorithm = 'sha256', crypto = getCrypto()) {
13995
+ const hashAlgorithm = algorithm === 'sha256' ? 'SHA-256' : 'SHA-512';
13996
+ const data = this.blob.keyData;
13997
+ const hash = await crypto.subtle.digest(hashAlgorithm, data);
13998
+ return new Uint8Array(hash);
13999
+ }
14000
+ }
14001
+
14002
+ class SshSignature extends SshObject {
14003
+ static TYPE = 'signature';
14004
+ type = SshSignature.TYPE;
14005
+ blob;
14006
+ format;
14007
+ algorithm;
14008
+ signature;
14009
+ version;
14010
+ publicKey;
14011
+ namespace;
14012
+ reserved;
14013
+ hashAlgorithm;
14014
+ constructor(blob) {
14015
+ super();
14016
+ this.blob = blob;
14017
+ this.format = blob.format;
14018
+ this.algorithm = blob.algorithm;
14019
+ this.signature = blob.signature;
14020
+ this.version = blob.version;
14021
+ this.namespace = blob.namespace;
14022
+ this.reserved = blob.reserved;
14023
+ this.hashAlgorithm = blob.hashAlgorithm;
14024
+ if (blob.publicKey) {
14025
+ const reader = new SshReader(blob.publicKey);
14026
+ const type = reader.readString();
14027
+ this.publicKey = new SshPublicKey({ type, keyData: blob.publicKey });
14028
+ }
14029
+ }
14030
+ static parse(data) {
14031
+ const blob = parseSignature(data);
14032
+ return new SshSignature(blob);
14033
+ }
14034
+ static fromBlob(blob) {
14035
+ return new SshSignature(blob);
14036
+ }
14037
+ static fromBase64(base64) {
14038
+ const data = new Uint8Array(buildExports.Convert.FromBase64(base64));
14039
+ return SshSignature.parse(data);
14040
+ }
14041
+ static fromText(text) {
14042
+ const base64 = text
14043
+ .replace(/-----BEGIN SSH SIGNATURE-----/, '')
14044
+ .replace(/-----END SSH SIGNATURE-----/, '')
14045
+ .replace(/[\r\n\s]/g, '');
14046
+ return SshSignature.fromBase64(base64);
14047
+ }
14048
+ serialize() {
14049
+ return serializeSignature(this.blob);
14050
+ }
14051
+ toBase64() {
14052
+ return buildExports.Convert.ToBase64(this.serialize());
14053
+ }
14054
+ toText() {
14055
+ const base64 = this.toBase64();
14056
+ const lines = [];
14057
+ for (let i = 0; i < base64.length; i += 70) {
14058
+ lines.push(base64.substring(i, i + 70));
14059
+ }
14060
+ return ['-----BEGIN SSH SIGNATURE-----', ...lines, '-----END SSH SIGNATURE-----'].join('\n');
14061
+ }
14062
+ async toSSH() {
14063
+ return this.toText();
14064
+ }
14065
+ async verify(data, publicKey) {
14066
+ const binding = AlgorithmRegistry.get(this.algorithm);
14067
+ const cryptoKey = await publicKey['getCryptoKey']();
14068
+ const crypto = getCrypto();
14069
+ let dataToVerify = data;
14070
+ if (this.format === 'ssh-signature') {
14071
+ const hashAlg = this.hashAlgorithm || 'sha512';
14072
+ const namespace = this.namespace || 'file';
14073
+ const reserved = this.reserved || '';
14074
+ const hashAlgorithm = hashAlg === 'sha256' ? 'SHA-256' : 'SHA-512';
14075
+ const messageHash = await crypto.subtle.digest(hashAlgorithm, data);
14076
+ const messageHashBytes = new Uint8Array(messageHash);
14077
+ const writer = new SshWriter();
14078
+ writer.writeBytes(new TextEncoder().encode('SSHSIG'));
14079
+ writer.writeString(namespace);
14080
+ writer.writeString(reserved);
14081
+ writer.writeString(hashAlg);
14082
+ writer.writeUint32(messageHashBytes.length);
14083
+ writer.writeBytes(messageHashBytes);
14084
+ dataToVerify = writer.toUint8Array();
14085
+ }
14086
+ let hashAlgorithm;
14087
+ if (this.algorithm === 'rsa-sha2-256') {
14088
+ hashAlgorithm = 'SHA-256';
14089
+ }
14090
+ else if (this.algorithm === 'rsa-sha2-512') {
14091
+ hashAlgorithm = 'SHA-512';
14092
+ }
14093
+ let signatureToVerify;
14094
+ if (this.format === 'legacy' || this.format === 'ssh-signature') {
14095
+ const sigWriter = new SshWriter();
14096
+ sigWriter.writeString(this.algorithm);
14097
+ sigWriter.writeUint32(this.signature.length);
14098
+ sigWriter.writeBytes(this.signature);
14099
+ const wireFormatSignature = sigWriter.toUint8Array();
14100
+ const decodedSig = binding.decodeSignature({
14101
+ signature: wireFormatSignature,
14102
+ });
14103
+ signatureToVerify = decodedSig.signature;
14104
+ }
14105
+ else {
14106
+ signatureToVerify = this.signature;
14107
+ }
14108
+ return binding.verify({
14109
+ publicKey: cryptoKey,
14110
+ signature: signatureToVerify,
14111
+ data: dataToVerify,
14112
+ crypto,
14113
+ hash: hashAlgorithm,
14114
+ });
14115
+ }
14116
+ static fromLegacy(algorithm, signature) {
14117
+ const binding = AlgorithmRegistry.get(algorithm);
14118
+ const encodedSignature = binding.encodeSignature({
14119
+ signature,
14120
+ algo: algorithm,
14121
+ });
14122
+ const sigReader = new SshReader(encodedSignature);
14123
+ sigReader.readString();
14124
+ const sigLength = sigReader.readUint32();
14125
+ const signatureData = sigReader.readBytes(sigLength);
14126
+ return new SshSignature({
14127
+ format: 'legacy',
14128
+ algorithm,
14129
+ signature: signatureData,
14130
+ });
14131
+ }
14132
+ static fromSshSignature(algorithm, signature, options = {}) {
14133
+ const blob = {
14134
+ format: 'ssh-signature',
14135
+ algorithm,
14136
+ signature,
14137
+ version: options.version || 1,
14138
+ publicKey: options.publicKey ? options.publicKey.getBlob().keyData : undefined,
14139
+ namespace: options.namespace || 'file',
14140
+ reserved: options.reserved || '',
14141
+ hashAlgorithm: options.hashAlgorithm || 'sha512',
14142
+ };
14143
+ return new SshSignature(blob);
14144
+ }
14145
+ static async sign(algorithm, privateKey, data, options = {}) {
14146
+ const { format = 'legacy', namespace = 'file' } = options;
14147
+ if (format === 'legacy') {
14148
+ const rawSignature = await privateKey.sign(algorithm, data);
14149
+ const algorithmUsed = algorithm || privateKey.keyType;
14150
+ return SshSignature.fromLegacy(algorithmUsed, rawSignature);
14151
+ }
14152
+ else {
14153
+ const signatureAlgorithm = algorithm;
14154
+ const binding = AlgorithmRegistry.get(signatureAlgorithm);
14155
+ const hashAlgorithm = algorithm === 'rsa-sha2-256' ? 'sha256' : 'sha512';
14156
+ const publicKey = await privateKey.getPublicKey();
14157
+ const crypto = getCrypto();
14158
+ const webCryptoHashAlg = hashAlgorithm === 'sha256' ? 'SHA-256' : 'SHA-512';
14159
+ const messageHash = await crypto.subtle.digest(webCryptoHashAlg, data);
14160
+ const messageHashBytes = new Uint8Array(messageHash);
14161
+ const writer = new SshWriter();
14162
+ writer.writeBytes(new TextEncoder().encode('SSHSIG'));
14163
+ writer.writeString(namespace);
14164
+ writer.writeString('');
14165
+ writer.writeString(hashAlgorithm);
14166
+ writer.writeUint32(messageHashBytes.length);
14167
+ writer.writeBytes(messageHashBytes);
14168
+ const dataToSign = writer.toUint8Array();
14169
+ const rawSignature = await privateKey.sign(signatureAlgorithm, dataToSign);
14170
+ const encodedSignature = binding.encodeSignature({
14171
+ signature: rawSignature,
14172
+ algo: signatureAlgorithm,
14173
+ });
14174
+ const sigReader = new SshReader(encodedSignature);
14175
+ sigReader.readString();
14176
+ const sigLength = sigReader.readUint32();
14177
+ const signatureData = sigReader.readBytes(sigLength);
14178
+ return SshSignature.fromSshSignature(signatureAlgorithm, signatureData, {
14179
+ namespace,
14180
+ hashAlgorithm,
14181
+ publicKey,
14182
+ });
14183
+ }
14184
+ }
14185
+ }
14186
+
14187
+ let SshCertificate$1 = class SshCertificate extends SshObject {
14188
+ static TYPE = 'certificate';
14189
+ type = SshCertificate.TYPE;
14190
+ _blob;
14191
+ data;
14192
+ _validAfter;
14193
+ _validBefore;
14194
+ keyId;
14195
+ principals;
14196
+ certType;
14197
+ serial;
14198
+ validAfter;
14199
+ validBefore;
14200
+ publicKey;
14201
+ signatureKey;
14202
+ criticalOptions;
14203
+ extensions;
14204
+ constructor(blob) {
14205
+ super();
14206
+ this._blob = blob;
14207
+ this.data = parseCertificateData(blob.keyData);
14208
+ this._validAfter = this.data.validAfter;
14209
+ this._validBefore = this.data.validBefore;
14210
+ this.keyId = this.data.keyId;
14211
+ this.principals = this.data.validPrincipals;
14212
+ this.certType = this.data.type;
14213
+ this.serial = this.data.serial;
14214
+ this.validAfter = new Date(Number(this.data.validAfter) * 1000);
14215
+ this.validBefore = new Date(Number(this.data.validBefore) * 1000);
14216
+ this.publicKey = new SshPublicKey(this.data.publicKey);
14217
+ this.signatureKey = new SshPublicKey(this.data.signatureKey);
14218
+ this.criticalOptions = { ...this.data.criticalOptions };
14219
+ this.extensions = { ...this.data.extensions };
14220
+ }
14221
+ static async fromSSH(text) {
14222
+ const blob = parse(text);
14223
+ return new SshCertificate(blob);
14224
+ }
14225
+ static async fromBlob(blob) {
14226
+ return new SshCertificate(blob);
14227
+ }
14228
+ async toSSH() {
14229
+ return serialize(this._blob);
14230
+ }
14231
+ toBlob() {
14232
+ return { ...this._blob };
14233
+ }
14234
+ get blob() {
14235
+ return this.toBlob();
14236
+ }
14237
+ validate(date = new Date()) {
14238
+ const ts = BigInt(Math.floor(date.getTime() / 1000));
14239
+ const after = this._validAfter;
14240
+ const before = this._validBefore;
14241
+ const INFINITY = 0xffffffffffffffffn;
14242
+ const upper = before === INFINITY ? ts : before;
14243
+ return ts >= after && ts <= upper;
14244
+ }
14245
+ async verify(caPublicKey, crypto = getCrypto()) {
14246
+ const verifyKey = caPublicKey || this.signatureKey;
14247
+ const signedData = this.getSignedData();
14248
+ const sshSignature = SshSignature.parse(this.data.signature);
14249
+ const binding = AlgorithmRegistry.get(sshSignature.algorithm);
14250
+ const cryptoKey = await verifyKey.toWebCrypto(crypto);
14251
+ return binding.verify({
14252
+ publicKey: cryptoKey,
14253
+ signature: sshSignature.signature,
14254
+ data: signedData,
14255
+ crypto,
14256
+ });
14257
+ }
14258
+ getSignedData() {
14259
+ const reader = new SshReader(this._blob.keyData);
14260
+ reader.readString();
14261
+ reader.readBytes(reader.readUint32());
14262
+ if (this.data.keyType === 'ssh-ed25519') {
14263
+ reader.readBytes(reader.readUint32());
14264
+ }
14265
+ else if (this.data.keyType === 'ssh-rsa') {
14266
+ reader.readBytes(reader.readUint32());
14267
+ reader.readBytes(reader.readUint32());
14268
+ }
14269
+ else if (this.data.keyType.startsWith('ecdsa-sha2-')) {
14270
+ reader.readString();
14271
+ reader.readBytes(reader.readUint32());
14272
+ }
14273
+ reader.readUint64();
14274
+ reader.readUint32();
14275
+ reader.readBytes(reader.readUint32());
14276
+ reader.readBytes(reader.readUint32());
14277
+ reader.readUint64();
14278
+ reader.readUint64();
14279
+ reader.readBytes(reader.readUint32());
14280
+ reader.readBytes(reader.readUint32());
14281
+ reader.readBytes(reader.readUint32());
14282
+ reader.readBytes(reader.readUint32());
14283
+ const signedDataEnd = reader.getOffset();
14284
+ return this._blob.keyData.slice(0, signedDataEnd);
14285
+ }
14286
+ };
14287
+
14288
+ var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
14289
+ if (kind === "m") throw new TypeError("Private method is not writable");
14290
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14291
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14292
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14293
+ };
14294
+ var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
14295
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
14296
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14297
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
14298
+ };
14299
+ var _SshCertificate_cert;
14300
+ class SshCertificate {
14301
+ constructor(raw) {
14302
+ _SshCertificate_cert.set(this, void 0);
14303
+ const blob = parse(raw.trim());
14304
+ // @ts-expect-error - SshCertificateType is not a constructor
14305
+ __classPrivateFieldSet(this, _SshCertificate_cert, new SshCertificate$1(blob), "f");
14306
+ this.notBefore = __classPrivateFieldGet(this, _SshCertificate_cert, "f").validAfter;
14307
+ this.notAfter = __classPrivateFieldGet(this, _SshCertificate_cert, "f").validBefore;
14308
+ this.validity = dateDiff(this.notBefore, this.notAfter);
14309
+ this.type = [__classPrivateFieldGet(this, _SshCertificate_cert, "f").blob.type, __classPrivateFieldGet(this, _SshCertificate_cert, "f").certType, __classPrivateFieldGet(this, _SshCertificate_cert, "f").type].join(' ');
14310
+ this.serialNumber = __classPrivateFieldGet(this, _SshCertificate_cert, "f").serial.toString();
14311
+ this.keyId = __classPrivateFieldGet(this, _SshCertificate_cert, "f").keyId;
14312
+ this.principals = __classPrivateFieldGet(this, _SshCertificate_cert, "f").principals;
14313
+ this.extensions = __classPrivateFieldGet(this, _SshCertificate_cert, "f").extensions;
14314
+ this.criticalOptions = __classPrivateFieldGet(this, _SshCertificate_cert, "f").criticalOptions;
14315
+ }
14316
+ async parseSignatureKey() {
14317
+ const key = await __classPrivateFieldGet(this, _SshCertificate_cert, "f").signatureKey.toWebCrypto();
14318
+ const blob = __classPrivateFieldGet(this, _SshCertificate_cert, "f").signatureKey.getBlob();
14319
+ const thumbprint = await __classPrivateFieldGet(this, _SshCertificate_cert, "f").signatureKey.thumbprint('sha256');
14320
+ this.signatureKey = {
14321
+ algorithm: key.algorithm.name,
14322
+ type: blob.type,
14323
+ value: await __classPrivateFieldGet(this, _SshCertificate_cert, "f").signatureKey.toSSH(),
14324
+ thumbprint: buildExports.Convert.ToBase64(thumbprint),
14325
+ };
14326
+ }
14327
+ async parsePublicKey() {
14328
+ const key = await __classPrivateFieldGet(this, _SshCertificate_cert, "f").publicKey.toWebCrypto();
14329
+ const blob = __classPrivateFieldGet(this, _SshCertificate_cert, "f").publicKey.getBlob();
14330
+ const thumbprint = await __classPrivateFieldGet(this, _SshCertificate_cert, "f").publicKey.thumbprint('sha256');
14331
+ this.publicKey = {
14332
+ algorithm: key.algorithm.name,
14333
+ type: blob.type,
14334
+ value: await __classPrivateFieldGet(this, _SshCertificate_cert, "f").publicKey.toSSH(),
14335
+ thumbprint: buildExports.Convert.ToBase64(thumbprint),
14336
+ };
14337
+ }
14338
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
14339
+ async toString(_format = 'pem') {
14340
+ return __classPrivateFieldGet(this, _SshCertificate_cert, "f").toSSH();
14341
+ }
14342
+ }
14343
+ _SshCertificate_cert = new WeakMap();
14344
+
14345
+ export { OIDs as $, AsnData as A, id_pkcs9_at_extensionRequest as B, Certificate as C, Download as D, ECParameters as E, id_pkcs9_at_unstructuredName as F, id_pkcs9_at_challengePassword as G, id_ValuationRanking as H, InsuranceValue as I, id_InsuranceValue as J, id_WebGDPR as K, id_ActivityDescription as L, id_TypeRelationship as M, Name as N, id_DomainNameTechnicalOperator as O, PemConverter as P, id_DomainNameOwner as Q, RSAPublicKey as R, id_DomainNameLegalRepresentative as S, TypeRelationship as T, UnstructuredName as U, ValuationRanking as V, WebGDPR as W, id_DomainNameBeneficiary as X, CertificationRequest as Y, l10n as Z, dateShort as _, dateDiff as a, id_ce_subjectDirectoryAttributes as a$, OctetString as a0, ByteStream as a1, SignedCertificateTimestamp as a2, Extension$1 as a3, CabforganizationIdentifier as a4, NonStandardKeyDescription as a5, BaseCRLNumber as a6, CRLNumber as a7, SubjectInfoAccessSyntax as a8, TNAuthorizationList as a9, IssuingDistributionPoint as aA, CRLDistributionPoints as aB, CertificatePolicies as aC, CertificateIssuer as aD, BasicConstraints as aE, AuthorityKeyIdentifier as aF, AuthorityInfoAccessSyntax as aG, id_cabforganizationIdentifier as aH, id_ce_keyDescription as aI, id_ce_deltaCRLIndicator as aJ, id_ce_cRLNumber as aK, id_pe_subjectInfoAccess as aL, id_pe_TNAuthList as aM, id_pe_biometricInfo as aN, id_entrust_entrustVersInfo as aO, id_ce_privateKeyUsagePeriod as aP, id_adbe_archiveRevInfo as aQ, id_adbe_timestamp as aR, id_role as aS, id_lei as aT, id_caVersion as aU, id_netscapeCertType as aV, id_netscapeComment as aW, id_enrollCertType as aX, id_certificateTemplate as aY, id_pe_qcStatements as aZ, id_ce_subjectKeyIdentifier as a_, LogotypeExtn as aa, BiometricSyntax as ab, EntrustVersionInfo as ac, PrivateKeyUsagePeriod as ad, ArchiveRevInfo as ae, Timestamp as af, LeiRole as ag, LeiChoice as ah, CaVersion as ai, NetscapeCertType as aj, NetscapeComment as ak, EnrollCertTypeChoice as al, CertificateTemplate as am, QCStatements as an, SubjectKeyIdentifier as ao, SubjectDirectoryAttributes as ap, SubjectAlternativeName as aq, PolicyMappings as ar, PolicyConstraints as as, NameConstraints as at, KeyUsage as au, IssueAlternativeName as av, InvalidityDate as aw, InhibitAnyPolicy as ax, ExtendedKeyUsage as ay, CRLReason as az, buildExports as b, id_ce_subjectAltName as b0, id_ce_policyMappings as b1, id_ce_policyConstraints as b2, id_ce_nameConstraints as b3, id_ce_keyUsage as b4, id_ce_issuerAltName as b5, id_ce_invalidityDate as b6, id_ce_inhibitAnyPolicy as b7, id_ce_extKeyUsage as b8, id_ce_cRLReasons as b9, AsnIntegerArrayBufferConverter as bA, AttestationApplicationId as bB, RootOfTrust as bC, IntegerSet as bD, id_ce_issuingDistributionPoint as ba, id_ce_cRLDistributionPoints as bb, id_ce_certificatePolicies as bc, id_ce_certificateIssuer as bd, id_ce_basicConstraints as be, id_ce_authorityKeyIdentifier as bf, id_pe_authorityInfoAccess as bg, SignedData as bh, EncapsulatedContent as bi, CertificateSet as bj, CertificateChoices as bk, ContentInfo as bl, SshCertificate as bm, Name$1 as bn, OtherName as bo, DisplayText as bp, UserNotice as bq, EDIPartyName as br, __decorate$1 as bs, AsnProp as bt, AsnPropTypes as bu, AsnType as bv, AsnTypeTypes as bw, AsnArray as bx, id_qcs_pkixQCSyntax_v2 as by, SemanticsInformation as bz, certificateRawToBuffer as c, downloadFromBuffer as d, AsnConvert as e, id_rsaEncryption as f, id_composite_key as g, CompositePublicKey as h, id_ecPublicKey as i, id_alg_composite as j, CompositeSignatureValue as k, CompositeParams as l, getCertificateThumbprint as m, AttributeCertificate as n, CertificateList as o, Attribute$1 as p, AsnParser as q, PrivateKeyPossessionStatement as r, ExtensionRequest as s, ChallengePassword as t, ActivityDescription as u, DomainNameTechnicalOperator as v, DomainNameOwner as w, DomainNameLegalRepresentative as x, DomainNameBeneficiary as y, id_at_statementOfPossession as z };
14346
+ //# sourceMappingURL=ssh_certificate-Ct-r021h.js.map
12700
14347
 
12701
- //# sourceMappingURL=certification_request-CSS3OhZq.js.map
14348
+ //# sourceMappingURL=ssh_certificate-Ct-r021h.js.map