@andrewheberle/serverless-ssh-ca 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +55 -1
  2. package/dist/api/operations.d.ts +49 -0
  3. package/dist/api/operations.d.ts.map +1 -0
  4. package/dist/api/operations.js +175 -0
  5. package/dist/api/operations.js.map +1 -0
  6. package/dist/api/schema.d.ts +71 -0
  7. package/dist/api/schema.d.ts.map +1 -0
  8. package/dist/api/schema.js +107 -0
  9. package/dist/api/schema.js.map +1 -0
  10. package/dist/api/v3/index.d.ts.map +1 -1
  11. package/dist/api/v3/index.js +13 -202
  12. package/dist/api/v3/index.js.map +1 -1
  13. package/dist/api/v3/schema.d.ts +23 -68
  14. package/dist/api/v3/schema.d.ts.map +1 -1
  15. package/dist/api/v3/schema.js +10 -100
  16. package/dist/api/v3/schema.js.map +1 -1
  17. package/dist/api/v4/index.d.ts +8 -0
  18. package/dist/api/v4/index.d.ts.map +1 -0
  19. package/dist/api/v4/index.js +155 -0
  20. package/dist/api/v4/index.js.map +1 -0
  21. package/dist/api/v4/schema.d.ts +268 -0
  22. package/dist/api/v4/schema.d.ts.map +1 -0
  23. package/dist/api/v4/schema.js +182 -0
  24. package/dist/api/v4/schema.js.map +1 -0
  25. package/dist/certificate.d.ts +9 -6
  26. package/dist/certificate.d.ts.map +1 -1
  27. package/dist/certificate.js +55 -99
  28. package/dist/certificate.js.map +1 -1
  29. package/dist/db/index.d.ts +17 -5
  30. package/dist/db/index.d.ts.map +1 -1
  31. package/dist/db/index.js +39 -23
  32. package/dist/db/index.js.map +1 -1
  33. package/dist/krl.d.ts +1 -1
  34. package/dist/krl.d.ts.map +1 -1
  35. package/dist/krl.js +9 -163
  36. package/dist/krl.js.map +1 -1
  37. package/dist/proof.d.ts +36 -7
  38. package/dist/proof.d.ts.map +1 -1
  39. package/dist/proof.js +53 -21
  40. package/dist/proof.js.map +1 -1
  41. package/dist/router.d.ts.map +1 -1
  42. package/dist/router.js +3 -1
  43. package/dist/router.js.map +1 -1
  44. package/dist/ssh/certificate.d.ts +93 -0
  45. package/dist/ssh/certificate.d.ts.map +1 -0
  46. package/dist/ssh/certificate.js +178 -0
  47. package/dist/ssh/certificate.js.map +1 -0
  48. package/dist/ssh/encoding.d.ts +41 -0
  49. package/dist/ssh/encoding.d.ts.map +1 -0
  50. package/dist/ssh/encoding.js +70 -0
  51. package/dist/ssh/encoding.js.map +1 -0
  52. package/dist/ssh/keys.d.ts +80 -0
  53. package/dist/ssh/keys.d.ts.map +1 -0
  54. package/dist/ssh/keys.js +249 -0
  55. package/dist/ssh/keys.js.map +1 -0
  56. package/dist/ssh/signer.d.ts +35 -0
  57. package/dist/ssh/signer.d.ts.map +1 -0
  58. package/dist/ssh/signer.js +99 -0
  59. package/dist/ssh/signer.js.map +1 -0
  60. package/dist/types.d.ts +12 -17
  61. package/dist/types.d.ts.map +1 -1
  62. package/dist/utils.d.ts +40 -21
  63. package/dist/utils.d.ts.map +1 -1
  64. package/dist/utils.js +87 -54
  65. package/dist/utils.js.map +1 -1
  66. package/openapi.json +1542 -1
  67. package/package.json +4 -3
  68. package/src/api/operations.ts +211 -0
  69. package/src/api/schema.ts +137 -0
  70. package/src/api/v3/index.ts +20 -248
  71. package/src/api/v3/schema.ts +26 -125
  72. package/src/api/v4/index.ts +265 -0
  73. package/src/api/v4/schema.ts +235 -0
  74. package/src/certificate.ts +62 -123
  75. package/src/db/index.ts +41 -26
  76. package/src/krl.ts +10 -195
  77. package/src/proof.ts +65 -31
  78. package/src/router.ts +3 -1
  79. package/src/ssh/certificate.ts +236 -0
  80. package/src/ssh/encoding.ts +81 -0
  81. package/src/ssh/keys.ts +294 -0
  82. package/src/ssh/signer.ts +129 -0
  83. package/src/types.ts +12 -18
  84. package/src/utils.ts +99 -69
@@ -0,0 +1,93 @@
1
+ import { PublicKey } from "./keys.js";
2
+ import { type Signer } from "./signer.js";
3
+ /**
4
+ * Encoding, decoding and signing of OpenSSH certificates as described in
5
+ * PROTOCOL.certkeys from OpenSSH
6
+ */
7
+ /** Whether a certificate is for a user or a host */
8
+ export type CertificateKind = "user" | "host";
9
+ /** The fields of a certificate that are set by the CA */
10
+ export type CertificateFields = {
11
+ /** Whether the certificate is for a user or a host */
12
+ kind: CertificateKind;
13
+ /** The public key being certified */
14
+ publicKey: PublicKey;
15
+ /** The serial number of the certificate */
16
+ serial: bigint;
17
+ /** The key ID of the certificate, which is logged by sshd when it is used */
18
+ keyId: string;
19
+ /** The users or hosts the certificate is valid for */
20
+ principals: string[];
21
+ /** The time from which the certificate is valid, to the second */
22
+ validAfter: Date;
23
+ /** The time until which the certificate is valid, to the second */
24
+ validBefore: Date;
25
+ /** The names of the extensions to include, which have no data */
26
+ extensions: string[];
27
+ };
28
+ /**
29
+ * Thrown when a certificate cannot be parsed
30
+ */
31
+ export declare class CertificateParseError extends Error {
32
+ constructor(message: string, cause?: unknown);
33
+ }
34
+ /**
35
+ * A signed OpenSSH certificate
36
+ */
37
+ export declare class SshCertificate {
38
+ /** The wire encoding of the certificate */
39
+ readonly bytes: Uint8Array;
40
+ /** The certificate type, for example "ssh-ed25519-cert-v01@openssh.com" */
41
+ readonly type: string;
42
+ readonly kind: CertificateKind;
43
+ /** The public key being certified */
44
+ readonly publicKey: PublicKey;
45
+ readonly serial: bigint;
46
+ readonly keyId: string;
47
+ readonly principals: string[];
48
+ readonly validAfter: Date;
49
+ readonly validBefore: Date;
50
+ /** The names of the extensions on the certificate */
51
+ readonly extensions: string[];
52
+ /** The wire encoding of the public key of the CA that signed the certificate */
53
+ readonly signatureKey: Uint8Array;
54
+ /** The signature of the CA in the SSH wire format */
55
+ readonly signature: Uint8Array;
56
+ /**
57
+ * Decodes a certificate from its wire encoding. This does not verify the
58
+ * signature on the certificate.
59
+ *
60
+ * @param bytes The wire encoding of the certificate
61
+ * @throws {@link CertificateParseError} when the certificate cannot be decoded or its type is not supported
62
+ */
63
+ constructor(bytes: Uint8Array);
64
+ /**
65
+ * Parses a certificate in OpenSSH format, `${type} ${base64}[ ${comment}]`,
66
+ * as found in `-cert.pub` files. This does not verify the signature on the
67
+ * certificate.
68
+ *
69
+ * @param text The certificate
70
+ * @throws {@link CertificateParseError} when the certificate cannot be parsed or its type is not supported
71
+ */
72
+ static parse(text: string): SshCertificate;
73
+ /**
74
+ * Returns whether the certificate was signed by a CA key
75
+ *
76
+ * @param ca The public key of the CA
77
+ */
78
+ isSignedBy(ca: PublicKey): Promise<boolean>;
79
+ /**
80
+ * Returns the certificate in OpenSSH format, as used for `-cert.pub` files
81
+ */
82
+ toString(): string;
83
+ }
84
+ /**
85
+ * Creates and signs an OpenSSH certificate
86
+ *
87
+ * @param fields The fields of the certificate
88
+ * @param signer The CA key to sign the certificate with
89
+ * @returns The signed certificate
90
+ * @throws Error when the type of the public key being certified is not supported
91
+ */
92
+ export declare const signCertificate: (fields: CertificateFields, signer: Signer) => Promise<SshCertificate>;
93
+ //# sourceMappingURL=certificate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certificate.d.ts","sourceRoot":"","sources":["../../src/ssh/certificate.ts"],"names":[],"mappings":"AAUA,OAAO,EAAiB,SAAS,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,aAAa,CAAA;AAEjD;;;GAGG;AAEH,oDAAoD;AACpD,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAA;AAO7C,yDAAyD;AACzD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,sDAAsD;IACtD,IAAI,EAAE,eAAe,CAAA;IACrB,qCAAqC;IACrC,SAAS,EAAE,SAAS,CAAA;IACpB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAA;IACd,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAA;IACb,sDAAsD;IACtD,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,kEAAkE;IAClE,UAAU,EAAE,IAAI,CAAA;I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AAG,OAAO,CAAC,cAAc,CAuBvG,CAAA"}
@@ -0,0 +1,178 @@
1
+ import * as P from "micro-packed";
2
+ import { decodePublicKey, PublicKeyFieldCounts, SSHBytes, SSHOptions, SSHText, SSHTextList, } from "./encoding.js";
3
+ import { base64 } from "@scure/base";
4
+ import { KeyParseError, PublicKey } from "./keys.js";
5
+ import { verify } from "./signer.js";
6
+ const CertificateKinds = {
7
+ user: 1,
8
+ host: 2,
9
+ };
10
+ // the fields of a certificate that follow its type, which are given the
11
+ // number of fields in the public key of the certificate
12
+ const fields = (keyFields) => ({
13
+ nonce: SSHBytes,
14
+ key: P.array(keyFields, SSHBytes),
15
+ serial: P.U64BE,
16
+ kind: P.U32BE,
17
+ keyId: SSHText,
18
+ principals: SSHTextList,
19
+ validAfter: P.U64BE,
20
+ validBefore: P.U64BE,
21
+ criticalOptions: SSHOptions,
22
+ extensions: SSHOptions,
23
+ reserved: SSHBytes,
24
+ signatureKey: SSHBytes,
25
+ });
26
+ const certificateType = (keyType) => `${keyType}-cert-v01@openssh.com`;
27
+ // a certificate without and with its signature, tagged by the certificate type
28
+ const ToBeSigned = P.tag(SSHText, Object.fromEntries(Object.entries(PublicKeyFieldCounts).map(([keyType, count]) => [certificateType(keyType), P.struct(fields(count))])));
29
+ const Certificate = P.tag(SSHText, Object.fromEntries(Object.entries(PublicKeyFieldCounts).map(([keyType, count]) => [certificateType(keyType), P.struct({ ...fields(count), signature: SSHBytes })])));
30
+ const toSeconds = (date) => BigInt(Math.floor(date.getTime() / 1000));
31
+ /**
32
+ * Thrown when a certificate cannot be parsed
33
+ */
34
+ export class CertificateParseError extends Error {
35
+ constructor(message, cause) {
36
+ super(message);
37
+ this.name = "CertificateParseError";
38
+ this.cause = cause;
39
+ Object.setPrototypeOf(this, CertificateParseError.prototype);
40
+ }
41
+ }
42
+ /**
43
+ * A signed OpenSSH certificate
44
+ */
45
+ export class SshCertificate {
46
+ /** The wire encoding of the certificate */
47
+ bytes;
48
+ /** The certificate type, for example "ssh-ed25519-cert-v01@openssh.com" */
49
+ type;
50
+ kind;
51
+ /** The public key being certified */
52
+ publicKey;
53
+ serial;
54
+ keyId;
55
+ principals;
56
+ validAfter;
57
+ validBefore;
58
+ /** The names of the extensions on the certificate */
59
+ extensions;
60
+ /** The wire encoding of the public key of the CA that signed the certificate */
61
+ signatureKey;
62
+ /** The signature of the CA in the SSH wire format */
63
+ signature;
64
+ /**
65
+ * Decodes a certificate from its wire encoding. This does not verify the
66
+ * signature on the certificate.
67
+ *
68
+ * @param bytes The wire encoding of the certificate
69
+ * @throws {@link CertificateParseError} when the certificate cannot be decoded or its type is not supported
70
+ */
71
+ constructor(bytes) {
72
+ let decoded;
73
+ try {
74
+ decoded = Certificate.decode(bytes);
75
+ }
76
+ catch (err) {
77
+ throw new CertificateParseError("certificate could not be decoded", err);
78
+ }
79
+ const { TAG, data } = decoded;
80
+ const kind = Object.keys(CertificateKinds).find((k) => CertificateKinds[k] === data.kind);
81
+ if (kind === undefined) {
82
+ throw new CertificateParseError(`unknown certificate kind: ${data.kind}`);
83
+ }
84
+ const publicKeyType = TAG.replace(/-cert-v01@openssh\.com$/, "");
85
+ try {
86
+ this.publicKey = new PublicKey(P.struct({ type: SSHText, key: P.array(data.key.length, SSHBytes) }).encode({ type: publicKeyType, key: data.key }));
87
+ }
88
+ catch (err) {
89
+ throw new CertificateParseError(err instanceof KeyParseError ? err.message : "certificate public key could not be decoded", err);
90
+ }
91
+ this.bytes = bytes;
92
+ this.type = TAG;
93
+ this.kind = kind;
94
+ this.serial = data.serial;
95
+ this.keyId = data.keyId;
96
+ this.principals = data.principals;
97
+ this.validAfter = new Date(Number(data.validAfter) * 1000);
98
+ this.validBefore = new Date(Number(data.validBefore) * 1000);
99
+ this.extensions = data.extensions.map((e) => e.name);
100
+ this.signatureKey = data.signatureKey;
101
+ this.signature = data.signature;
102
+ }
103
+ /**
104
+ * Parses a certificate in OpenSSH format, `${type} ${base64}[ ${comment}]`,
105
+ * as found in `-cert.pub` files. This does not verify the signature on the
106
+ * certificate.
107
+ *
108
+ * @param text The certificate
109
+ * @throws {@link CertificateParseError} when the certificate cannot be parsed or its type is not supported
110
+ */
111
+ static parse(text) {
112
+ const [type, data] = text.trim().split(/\s+/);
113
+ if (type === undefined || type === "" || data === undefined) {
114
+ throw new CertificateParseError("certificate was not in OpenSSH format");
115
+ }
116
+ let bytes;
117
+ try {
118
+ bytes = base64.decode(data);
119
+ }
120
+ catch (err) {
121
+ throw new CertificateParseError("certificate was not valid base64", err);
122
+ }
123
+ const certificate = new SshCertificate(bytes);
124
+ if (certificate.type !== type) {
125
+ throw new CertificateParseError(`certificate type ${type} did not match encoded type ${certificate.type}`);
126
+ }
127
+ return certificate;
128
+ }
129
+ /**
130
+ * Returns whether the certificate was signed by a CA key
131
+ *
132
+ * @param ca The public key of the CA
133
+ */
134
+ async isSignedBy(ca) {
135
+ if (!ca.equals(new PublicKey(this.signatureKey))) {
136
+ return false;
137
+ }
138
+ // the signature is the last field, so everything before it is signed
139
+ const signed = this.bytes.subarray(0, this.bytes.length - 4 - this.signature.length);
140
+ return await verify(ca, this.signature, new Uint8Array(signed));
141
+ }
142
+ /**
143
+ * Returns the certificate in OpenSSH format, as used for `-cert.pub` files
144
+ */
145
+ toString() {
146
+ return `${this.type} ${base64.encode(this.bytes)}`;
147
+ }
148
+ }
149
+ /**
150
+ * Creates and signs an OpenSSH certificate
151
+ *
152
+ * @param fields The fields of the certificate
153
+ * @param signer The CA key to sign the certificate with
154
+ * @returns The signed certificate
155
+ * @throws Error when the type of the public key being certified is not supported
156
+ */
157
+ export const signCertificate = async (fields, signer) => {
158
+ const { type, fields: key } = decodePublicKey(fields.publicKey.blob);
159
+ const value = {
160
+ nonce: crypto.getRandomValues(new Uint8Array(32)),
161
+ key,
162
+ serial: fields.serial,
163
+ kind: CertificateKinds[fields.kind],
164
+ keyId: fields.keyId,
165
+ principals: fields.principals,
166
+ validAfter: toSeconds(fields.validAfter),
167
+ validBefore: toSeconds(fields.validBefore),
168
+ criticalOptions: [],
169
+ // options must be in lexical order and may each appear only once
170
+ extensions: [...new Set(fields.extensions)].sort().map((name) => ({ name, data: new Uint8Array(0) })),
171
+ reserved: new Uint8Array(0),
172
+ signatureKey: signer.publicKey,
173
+ };
174
+ const tbs = ToBeSigned.encode({ TAG: certificateType(type), data: value });
175
+ const signature = await signer.sign(new Uint8Array(tbs));
176
+ return new SshCertificate(Certificate.encode({ TAG: certificateType(type), data: { ...value, signature } }));
177
+ };
178
+ //# sourceMappingURL=certificate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certificate.js","sourceRoot":"","sources":["../../src/ssh/certificate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EACN,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,OAAO,EACP,WAAW,GACX,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACpD,OAAO,EAAE,MAAM,EAAe,MAAM,aAAa,CAAA;AAUjD,MAAM,gBAAgB,GAA8C;IACnE,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACP,CAAA;AAsBD,wEAAwE;AACxE,wDAAwD;AACxD,MAAM,MAAM,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC;IACtC,KAAK,EAAE,QAAQ;IACf,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC;IACjC,MAAM,EAAE,CAAC,CAAC,KAAK;IACf,IAAI,EAAE,CAAC,CAAC,KAAK;IACb,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,CAAC,CAAC,KAAK;IACnB,WAAW,EAAE,CAAC,CAAC,KAAK;IACpB,eAAe,EAAE,UAAU;IAC3B,UAAU,EAAE,UAAU;IACtB,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CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;IAExD,OAAO,IAAI,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAA;AAC7G,CAAC,CAAA"}
@@ -0,0 +1,41 @@
1
+ import * as P from "micro-packed";
2
+ /**
3
+ * Coders for the SSH wire format (RFC 4251 section 5)
4
+ */
5
+ /** A string of bytes, prefixed by its length as a uint32 */
6
+ export declare const SSHBytes: P.CoderType<P.Bytes>;
7
+ /** A UTF-8 string, prefixed by its length as a uint32 */
8
+ export declare const SSHText: P.CoderType<string>;
9
+ /** A list of strings packed into a string, as used for certificate principals */
10
+ export declare const SSHTextList: P.CoderType<string[]>;
11
+ /**
12
+ * A list of named options packed into a string, as used for certificate
13
+ * critical options and extensions
14
+ */
15
+ export declare const SSHOptions: P.CoderType<P.StructInput<{
16
+ name: string;
17
+ data: P.Bytes;
18
+ }>[]>;
19
+ /**
20
+ * An mpint holding an unsigned integer, decoded to and encoded from its
21
+ * big-endian bytes without leading zeros.
22
+ *
23
+ * An mpint has no leading zero bytes, other than one to keep the value
24
+ * positive when the high bit of the first byte is set.
25
+ */
26
+ export declare const SSHUnsignedMpint: P.CoderType<Uint8Array<ArrayBufferLike>>;
27
+ /** The number of fields that follow the type in the wire encoding of a public key of each type */
28
+ export declare const PublicKeyFieldCounts: Readonly<Record<string, number>>;
29
+ /**
30
+ * Splits the wire encoding of a public key into its type and the encoded
31
+ * fields that follow it
32
+ *
33
+ * @param blob The wire encoding of the public key
34
+ * @returns The key type and its fields
35
+ * @throws Error when the key type is not supported or the encoding is invalid
36
+ */
37
+ export declare const decodePublicKey: (blob: Uint8Array) => {
38
+ type: string;
39
+ fields: Uint8Array[];
40
+ };
41
+ //# sourceMappingURL=encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/ssh/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAEjC;;GAEG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,sBAAmB,CAAA;AAExC,yDAAyD;AACzD,eAAO,MAAM,OAAO,qBAAoB,CAAA;AAExC,iFAAiF;AACjF,eAAO,MAAM,WAAW,uBAA4C,CAAA;AAEpE;;;GAGG;AACH,eAAO,MAAM,UAAU;;;KAGnB,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,0CAoB3B,CAAA;AAEF,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMjE,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,SAAU,UAAU,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAUtF,CAAA"}
@@ -0,0 +1,70 @@
1
+ import * as P from "micro-packed";
2
+ /**
3
+ * Coders for the SSH wire format (RFC 4251 section 5)
4
+ */
5
+ /** A string of bytes, prefixed by its length as a uint32 */
6
+ export const SSHBytes = P.bytes(P.U32BE);
7
+ /** A UTF-8 string, prefixed by its length as a uint32 */
8
+ export const SSHText = P.string(P.U32BE);
9
+ /** A list of strings packed into a string, as used for certificate principals */
10
+ export const SSHTextList = P.prefix(P.U32BE, P.array(null, SSHText));
11
+ /**
12
+ * A list of named options packed into a string, as used for certificate
13
+ * critical options and extensions
14
+ */
15
+ export const SSHOptions = P.prefix(P.U32BE, P.array(null, P.struct({
16
+ name: SSHText,
17
+ data: SSHBytes,
18
+ })));
19
+ /**
20
+ * An mpint holding an unsigned integer, decoded to and encoded from its
21
+ * big-endian bytes without leading zeros.
22
+ *
23
+ * An mpint has no leading zero bytes, other than one to keep the value
24
+ * positive when the high bit of the first byte is set.
25
+ */
26
+ export const SSHUnsignedMpint = P.apply(SSHBytes, {
27
+ encode: (mpint) => {
28
+ let start = 0;
29
+ while (start < mpint.length && mpint[start] === 0) {
30
+ start++;
31
+ }
32
+ return mpint.subarray(start);
33
+ },
34
+ decode: (value) => {
35
+ let start = 0;
36
+ while (start < value.length && value[start] === 0) {
37
+ start++;
38
+ }
39
+ const trimmed = value.subarray(start);
40
+ return trimmed.length > 0 && trimmed[0] & 0x80
41
+ ? P.utils.concatBytes(new Uint8Array([0]), trimmed)
42
+ : trimmed;
43
+ },
44
+ });
45
+ /** The number of fields that follow the type in the wire encoding of a public key of each type */
46
+ export const PublicKeyFieldCounts = {
47
+ "ssh-ed25519": 1, // public key
48
+ "ecdsa-sha2-nistp256": 2, // curve, public key
49
+ "ecdsa-sha2-nistp384": 2,
50
+ "ecdsa-sha2-nistp521": 2,
51
+ "ssh-rsa": 2, // e, n
52
+ };
53
+ /**
54
+ * Splits the wire encoding of a public key into its type and the encoded
55
+ * fields that follow it
56
+ *
57
+ * @param blob The wire encoding of the public key
58
+ * @returns The key type and its fields
59
+ * @throws Error when the key type is not supported or the encoding is invalid
60
+ */
61
+ export const decodePublicKey = (blob) => {
62
+ const type = SSHText.decode(blob, { allowUnreadBytes: true });
63
+ const count = PublicKeyFieldCounts[type];
64
+ if (count === undefined) {
65
+ throw new Error(`unsupported public key type: ${type}`);
66
+ }
67
+ const { fields } = P.struct({ type: SSHText, fields: P.array(count, SSHBytes) }).decode(blob);
68
+ return { type, fields };
69
+ };
70
+ //# sourceMappingURL=encoding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/ssh/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAA;AAEjC;;GAEG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAExC,y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C,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;YACnD,CAAC,CAAC,OAAO,CAAA;IACX,CAAC;CACD,CAAC,CAAA;AAEF,kGAAkG;AAClG,MAAM,CAAC,MAAM,oBAAoB,GAAqC;IACrE,aAAa,EAAE,CAAC,EAAE,aAAa;IAC/B,qBAAqB,EAAE,CAAC,EAAE,oBAAoB;IAC9C,qBAAqB,EAAE,CAAC;IACxB,qBAAqB,EAAE,CAAC;IACxB,SAAS,EAAE,CAAC,EAAE,OAAO;CACrB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAgB,EAA0C,EAAE;IAC3F,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7D,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;IACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAA;IACxD,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAE7F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AACxB,CAAC,CAAA"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Thrown when a key cannot be parsed
3
+ */
4
+ export declare class KeyParseError extends Error {
5
+ constructor(message: string, cause?: unknown);
6
+ }
7
+ /**
8
+ * Thrown when a private key is of a type that cannot be used to sign
9
+ */
10
+ export declare class UnsupportedKeyError extends Error {
11
+ constructor(message: string);
12
+ }
13
+ /**
14
+ * An SSH public key
15
+ */
16
+ export declare class PublicKey {
17
+ /** The key type, for example "ssh-ed25519" */
18
+ readonly type: string;
19
+ /** The wire encoding of the key (RFC 4253 section 6.6) */
20
+ readonly blob: Uint8Array;
21
+ /** The comment of the key, if any */
22
+ readonly comment: string | undefined;
23
+ /**
24
+ * @param blob The wire encoding of the key
25
+ * @param comment The comment of the key
26
+ * @throws {@link KeyParseError} when the key cannot be decoded or its type is not supported
27
+ */
28
+ constructor(blob: Uint8Array, comment?: string);
29
+ /**
30
+ * Parses a public key in OpenSSH format, `${type} ${base64}[ ${comment}]`
31
+ *
32
+ * @param text The public key
33
+ * @throws {@link KeyParseError} when the key cannot be parsed or its type is not supported
34
+ */
35
+ static parse(text: string): PublicKey;
36
+ /**
37
+ * Returns the SHA256 fingerprint of the key, as shown by `ssh-keygen -l`,
38
+ * for example "SHA256:79mq0wtpQMTvS4+Of8VzLN0qmYWNUyTXYmqKwhEgSLs"
39
+ */
40
+ fingerprint(): string;
41
+ /**
42
+ * Returns whether this is the same key as another, ignoring comments
43
+ */
44
+ equals(other: PublicKey): boolean;
45
+ /**
46
+ * Returns a copy of the key with a different comment
47
+ */
48
+ withComment(comment: string | undefined): PublicKey;
49
+ /**
50
+ * Returns the key in OpenSSH format, `${type} ${base64}[ ${comment}]`
51
+ */
52
+ toString(): string;
53
+ }
54
+ /** The ECDSA curves that can be used to sign */
55
+ export type EcdsaCurve = "nistp256" | "nistp384" | "nistp521";
56
+ /**
57
+ * A private key that can be used to sign, with its key material as a JWK for
58
+ * WebCrypto
59
+ */
60
+ export type PrivateKey = {
61
+ readonly type: "ed25519";
62
+ readonly publicKey: PublicKey;
63
+ readonly jwk: JsonWebKey;
64
+ } | {
65
+ readonly type: "ecdsa";
66
+ readonly curve: EcdsaCurve;
67
+ readonly publicKey: PublicKey;
68
+ readonly jwk: JsonWebKey;
69
+ };
70
+ /**
71
+ * Parses an unencrypted Ed25519 or ECDSA private key in OpenSSH format, as
72
+ * created by `ssh-keygen`
73
+ *
74
+ * @param text The private key, starting with `-----BEGIN OPENSSH PRIVATE KEY-----`
75
+ * @returns The private key
76
+ * @throws {@link KeyParseError} when the key cannot be parsed or is encrypted
77
+ * @throws {@link UnsupportedKeyError} when the key is not an Ed25519 or ECDSA key
78
+ */
79
+ export declare const parsePrivateKey: (text: string) => PrivateKey;
80
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/ssh/keys.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACvC,YAAY,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAM3C;CACD;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,OAAO,EAAE,MAAM,EAK1B;CACD;AAMD;;GAEG;AACH,qBAAa,SAAS;IACrB,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAEpC;;;;OAIG;IACH,YAAY,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,EAQ7C;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAmBpC;IAED;;;OAGG;IACH,WAAW,IAAI,MAAM,CAEpB;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEhC;IAED;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAElD;IAED;;OAEG;IACH,QAAQ,IAAI,MAAM,CAIjB;CACD;AAED,gDAAgD;AAChD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,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