@andrewheberle/serverless-ssh-ca 0.17.5 → 0.17.7

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 (48) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +268 -0
  3. package/dist/api/v3/schema.js +2 -1
  4. package/dist/proof.js +1 -1
  5. package/dist/sshsig/formats.js +1 -1
  6. package/dist/utils.d.ts +2 -1
  7. package/dist/utils.js +1 -2
  8. package/package.json +9 -13
  9. package/dist/src/api/v3/index.d.ts +0 -1
  10. package/dist/src/api/v3/index.js +0 -263
  11. package/dist/src/api/v3/schema.d.ts +0 -217
  12. package/dist/src/api/v3/schema.js +0 -216
  13. package/dist/src/certificate.d.ts +0 -30
  14. package/dist/src/certificate.js +0 -154
  15. package/dist/src/db.d.ts +0 -36
  16. package/dist/src/db.js +0 -111
  17. package/dist/src/index.d.ts +0 -6
  18. package/dist/src/index.js +0 -8
  19. package/dist/src/krl.d.ts +0 -39
  20. package/dist/src/krl.js +0 -317
  21. package/dist/src/logger.d.ts +0 -2
  22. package/dist/src/logger.js +0 -3
  23. package/dist/src/proof.d.ts +0 -51
  24. package/dist/src/proof.js +0 -154
  25. package/dist/src/router.d.ts +0 -14
  26. package/dist/src/router.js +0 -22
  27. package/dist/src/sshsig/armor.d.ts +0 -7
  28. package/dist/src/sshsig/armor.js +0 -18
  29. package/dist/src/sshsig/formats.d.ts +0 -52
  30. package/dist/src/sshsig/formats.js +0 -174
  31. package/dist/src/sshsig/index.d.ts +0 -15
  32. package/dist/src/sshsig/index.js +0 -31
  33. package/dist/src/sshsig/reader.d.ts +0 -20
  34. package/dist/src/sshsig/reader.js +0 -54
  35. package/dist/src/sshsig/sig.d.ts +0 -16
  36. package/dist/src/sshsig/sig.js +0 -1
  37. package/dist/src/sshsig/sig_parser.d.ts +0 -9
  38. package/dist/src/sshsig/sig_parser.js +0 -83
  39. package/dist/src/sshsig/verifier.d.ts +0 -2
  40. package/dist/src/sshsig/verifier.js +0 -37
  41. package/dist/src/sshsig/writer.d.ts +0 -17
  42. package/dist/src/sshsig/writer.js +0 -51
  43. package/dist/src/types.d.ts +0 -42
  44. package/dist/src/types.js +0 -20
  45. package/dist/src/utils.d.ts +0 -76
  46. package/dist/src/utils.js +0 -370
  47. package/dist/src/verify.d.ts +0 -6
  48. package/dist/src/verify.js +0 -17
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Andrew Heberle
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,268 @@
1
+ # Serverless SSH CA on Cloudflare Workers
2
+
3
+ [![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https%3A%2F%2Fgithub.com%2Fandrewheberle%2Fserverless-ssh-ca-template)
4
+
5
+ [![codecov](https://codecov.io/gh/andrewheberle/serverless-ssh-ca/graph/badge.svg?flag=worker&token=AZLFIBTTFK)](https://codecov.io/gh/andrewheberle/serverless-ssh-ca)
6
+
7
+ This repository contains a serverless Certificate Authority (CA) that can be used
8
+ to provide signed certificates for SSH users and hosts running on Cloudflare Workers.
9
+
10
+ ## @andrewheberle/serverless-ssh-ca
11
+
12
+ This is the package that implements the SSH CA functionality which can be deployed
13
+ to Cloudflare as a working solution using the "Deploy to Cloudflare" button.
14
+
15
+ To use the package in your own Worker manually (assuming you have the requried
16
+ bindings in place), the following code in `src/index.ts` (your Worker's main
17
+ file) will work:
18
+
19
+ ```ts
20
+ import app from "@andrewheberle/serverless-ssh-ca"
21
+
22
+ export default app
23
+ ```
24
+
25
+ This package **only** works with Cloudflare Workers and there are no plans to make
26
+ this a generic solution at this time.
27
+
28
+ See the following respositories for additional information:
29
+
30
+
31
+ | Repostitory | Details |
32
+ |---|---|
33
+ | https://github.com/andrewheberle/ssh-ca-client | Contains client code for issuing user and host certificates |
34
+ | https://github.com/andrewheberle/severless-ssh-ca-template | Contains a template repository for deployment to Cloudflare Workers |
35
+
36
+ ## Architecture
37
+
38
+ The solution comprises of the CA running as a Worker, a Go based client
39
+ (found [here](https://github.com/andrewheberle/ssh-ca-client])) and a third
40
+ party OIDC IdP.
41
+
42
+ The IdP may be any OIDC compatible service that returns a JWT with at least
43
+ an `email` claim in the OIDC access token, however at this time only
44
+ Cloudflare Access has been tested.
45
+
46
+ ### User Certificates
47
+
48
+ The flow to obtain a User SSH certificate using the CLI version is as follows:
49
+
50
+ 1. The user initiates `ssh-ca-client-cli login`
51
+ 2. If required a new SSH key is generated and the a browser is opened to
52
+ visit `http://localhost:3000/auth/login`
53
+ 3. The client redirects the user to the configured IdP
54
+ 4. The IdP returns the user to the callback URL (default
55
+ `http://localhost:3000/auth/callback`)
56
+ 5. The client uses the JWT from the IdP as `Authorization: Bearer <TOKEN>`
57
+ in a `POST` request containing the users SSH public key to the CA's
58
+ `/api/v3/user/certificate` endpoint
59
+ 6. The CA verifies the incoming JWT and assuming it is valid and verified, will
60
+ respond with a signed certificate based on the provided public key
61
+ 7. The client saves the certificate and adds the SSH private key and
62
+ certificate to the local SSH Agent.
63
+
64
+ This flow is shown below once the user executes `ssh-ca-client-cli login`:
65
+
66
+ ```mermaid
67
+ sequenceDiagram
68
+ User->>Client: GET /auth/login
69
+ activate Client
70
+ Client-->>User: Redirect to IdP
71
+ deactivate Client
72
+ activate User
73
+ User->>IdP: OIDC authentication flow
74
+ deactivate User
75
+ activate IdP
76
+ IdP-->>User: Redirect to Client
77
+ deactivate IdP
78
+ activate User
79
+ User->>Client: Completes OIDC redirect
80
+ deactivate User
81
+ activate Client
82
+ activate Client
83
+ Client-->>User: Auth flow completed
84
+ deactivate Client
85
+ Client->>CA: POST /api/v3/user/certificate
86
+ deactivate Client
87
+ activate CA
88
+ CA-->>Client: Signed certificate
89
+ deactivate CA
90
+ activate Client
91
+ Client->>SSH Agent: Add key and certificate to Agent
92
+ deactivate Client
93
+ ```
94
+
95
+ If a refresh token is available, the process looks like this when running
96
+ `ssh-ca-client-cli login`:
97
+
98
+ ```mermaid
99
+ sequenceDiagram
100
+ Client->>IdP: Request authentication token
101
+ activate IdP
102
+ IdP-->>Client: Token returned
103
+ deactivate IdP
104
+ activate Client
105
+ Client->>CA: POST /api/v3/user/certificate
106
+ deactivate Client
107
+ activate CA
108
+ CA-->>Client: Signed certificate
109
+ deactivate CA
110
+ activate Client
111
+ Client->>SSH Agent: Add key and certificate to Agent
112
+ deactivate Client
113
+ ```
114
+
115
+ If the process to request a new authentication token fails using the refresh
116
+ token, the standard authentication process is followed which requires user
117
+ interaction.
118
+
119
+ ### Host Certificates
120
+
121
+ #### Initial Request
122
+
123
+ The process to request an intitial Host certificate is similar to obtaining
124
+ a User certificate once `ssh-ca-client-cli host` is run, however instead of
125
+ adding the obtained certificate to a SSH Agent, it is written to
126
+ `<KEYPATH>-cert.pub` instead:
127
+
128
+ ```mermaid
129
+ sequenceDiagram
130
+ User->>Client: GET /auth/login
131
+ activate Client
132
+ Client-->>User: Redirect to IdP
133
+ deactivate Client
134
+ activate User
135
+ User->>IdP: OIDC authentication flow
136
+ deactivate User
137
+ activate IdP
138
+ IdP-->>User: Redirect to Client
139
+ deactivate IdP
140
+ activate User
141
+ User->>Client: Completes OIDC redirect
142
+ deactivate User
143
+ activate Client
144
+ activate Client
145
+ Client-->>User: Auth flow completed
146
+ deactivate Client
147
+ Client->>CA: POST /api/v3/host/certificate
148
+ deactivate Client
149
+ activate CA
150
+ CA-->>Client: Signed certificate
151
+ deactivate CA
152
+ activate Client
153
+ Client->>Writes Certificate: Certificate written to disk
154
+ deactivate Client
155
+ ```
156
+
157
+ #### Renewals
158
+
159
+ Renewals are done using the existing certificate and will succeed if:
160
+
161
+ 1. The certificate is not expired
162
+ 2. It was issued by the CA
163
+ 3. The public key used to obtain the certificate is the same as the one
164
+ currently presented
165
+
166
+ This means the OIDC authentication flow is not required in this case as shown
167
+ below when `ssh-ca-client-cli host --renew` is run:
168
+
169
+ ```mermaid
170
+ sequenceDiagram
171
+ Client->>CA: POST /api/v3/host/renew
172
+ activate CA
173
+ CA-->>Client: Signed certificate
174
+ deactivate CA
175
+ activate Client
176
+ Client->>Writes Certificate: Certificate written to disk
177
+ deactivate Client
178
+ ```
179
+
180
+ ## Configuration
181
+
182
+ ### Identity Provider
183
+
184
+ This example shows the configuration in Cloudflare Access, however other
185
+ OIDC IdP's should be generally equivalent:
186
+
187
+ ![Basic OIDC Settings](images/oidc-example_01.png)
188
+
189
+ The `Redirect URL` must match the configured value in the client.
190
+
191
+ Transfer the IdP settings as follows:
192
+
193
+ ![IdP Settings](images/oidc-example_02.png)
194
+
195
+ The `openid` and `email` scopes are required, with enabling of refresh tokens
196
+ (the `offline_access` scope) being optional, but recommended.
197
+
198
+ ### Client
199
+
200
+ Please visit the client repository for further information:
201
+
202
+ https://github.com/andrewheberle/ssh-ca-client
203
+
204
+ ### SSH Endpoints
205
+
206
+ #### Host Configuration
207
+
208
+ For systems to allow SSH login using certificates the following configuration
209
+ changes must be made:
210
+
211
+ ```ssh
212
+ PubkeyAuthentication yes
213
+ TrustedUserCAKeys /etc/ssh/ca.pub
214
+ AuthorizedPrincipalsFile /etc/ssh/principals.d/%u
215
+ # Uncomment the following lines to enable host certificates
216
+ # HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub
217
+ # HostCertificate /etc/ssh/ssh_host_ecdsa_key-cert.pub
218
+ # HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
219
+ ```
220
+
221
+ The contents of `/etc/ssh/ca.pub` is the public key of the SSH CA, which can be
222
+ retrieved as follows:
223
+
224
+ ```sh
225
+ curl https://ssh-ca.example.com/api/v3/ca | sudo tee /etc/ssh/ca.pub
226
+ ```
227
+
228
+ The `/etc/ssh/principals.d` directory should contain a file corresponding to
229
+ a local user that contains a list of principals that should be allowed
230
+ login.
231
+
232
+ Using the principals list in `SSH_CERTIFICATE_PRINCIPALS` above, the
233
+ following file named `/etc/ssh/principals.d/admin` would allow login
234
+ as the SSH user `admin` for the bearer of an issued (and valid) certificate:
235
+
236
+ ```
237
+ ssh-admin
238
+ ```
239
+
240
+ #### Client Configuration
241
+
242
+ In order for a client to trust a certificate presented by a host the following
243
+ configuration must be added to `/etc/ssh/ssh_known_hosts` (system wide) or
244
+ `~/.ssh/known_hosts` (user specific):
245
+
246
+ ```
247
+ @cert-authority *.example.com ecdsa-sha2-nistp256 ....
248
+ ```
249
+
250
+ The format of the above file is documented in the `ssh(1)` man page however
251
+ the important items of note is the `*.example.com` above tells `ssh` that the
252
+ CA public key (ie `ecdsa-sha2-nistp256 ....`) is trusted for all hosts, that
253
+ match `*.example.com`.
254
+
255
+ This will need adjusting depending on your environment along with the actual
256
+ SSH CA public key which can be retrieved as follows:
257
+
258
+ ```sh
259
+ curl https://ssh-ca.example.com/api/v3/ca
260
+ ```
261
+
262
+ Once the above configuration is completed and host certificates are in place
263
+ clients will not require "trust on first use" (TOFU) as the certificate will be
264
+ verified as being signed by the configured SSH CA.
265
+
266
+ # Attributions
267
+
268
+ The icons used by the client are made by Freepik from [www.flaticon.com](https://www.flaticon.com).
@@ -2,6 +2,7 @@ import z from "zod";
2
2
  import { split, refineCertificateRequest, transformAuthorizationHeader, transformProofOfPossession, transformPublicKey, transformRenewalProofOfPossession, refineHostCertificateRequest, transformCertificate, refineHostCertificateRenewal, refineRevokeCertificate, transformIdentityToken, } from "../../utils";
3
3
  import { ConflictException, contentJson, ForbiddenException, InputValidationException, InternalServerErrorException, UnauthorizedException, UnprocessableEntityException, } from "chanfana";
4
4
  import { seconds } from "itty-time";
5
+ import { isRevoked } from "../../db";
5
6
  const openapiStringByte = z.base64()
6
7
  .transform((v) => {
7
8
  const a = z.util.base64ToUint8Array(v);
@@ -156,7 +157,7 @@ export const createHostCertificateRenewEndpointSchema = (env) => ({
156
157
  .default(seconds(env.SSH_HOST_CERTIFICATE_LIFETIME))
157
158
  .meta({ description: "Lifetime of renewed Host SSH certificate" }),
158
159
  })
159
- .superRefine((val, ctx) => refineHostCertificateRenewal(env, val, ctx))
160
+ .superRefine((val, ctx) => refineHostCertificateRenewal(env, isRevoked, val, ctx))
160
161
  .openapi("Host Certificate Renew"))
161
162
  },
162
163
  responses: {
package/dist/proof.js CHANGED
@@ -48,7 +48,7 @@ export class ProofOfPossession {
48
48
  }
49
49
  const now = options?.from !== undefined ? options?.from : Date.now();
50
50
  const age = now - timestamp;
51
- const skew = options?.skew !== undefined ? options.skew : ms("5 minutes");
51
+ const skew = options?.skew !== undefined ? options.skew : ms("90 seconds");
52
52
  if (age > skew) {
53
53
  throw new PossessionParseError("timestamp too old");
54
54
  }
@@ -105,7 +105,7 @@ export function convertPublicKey(publickey) {
105
105
  else if (pk_algo === "ecdsa-sha2-nistp384") {
106
106
  crv = "P-384";
107
107
  }
108
- {
108
+ else {
109
109
  crv = "P-521";
110
110
  }
111
111
  return {
package/dist/utils.d.ts CHANGED
@@ -3,6 +3,7 @@ import { Certificate, Key, PrivateKey } from "sshpk";
3
3
  import z from "zod";
4
4
  import { CertificateRequestJWTPayload } from "./types";
5
5
  import { RenewalProofOfPossession, ProofOfPossession } from "./proof";
6
+ import type { isRevoked as IsRevokedFn } from "./db";
6
7
  export declare const fatalIssue: (ctx: z.RefinementCtx, message: string, val: unknown) => never;
7
8
  export declare const transformProofOfPossession: (env: SshCaBindings, val: string, ctx: z.core.$RefinementCtx<string>) => ProofOfPossession | never;
8
9
  type AccessToken = {
@@ -47,7 +48,7 @@ type ParsedHostCertificateRenewal = {
47
48
  certificate: Certificate;
48
49
  proof: RenewalProofOfPossession;
49
50
  } & HostCertificateRequest;
50
- export declare const refineHostCertificateRenewal: (env: SshCaBindings, val: ParsedHostCertificateRenewal, ctx: z.RefinementCtx) => Promise<never>;
51
+ export declare const refineHostCertificateRenewal: (env: SshCaBindings, isRevoked: typeof IsRevokedFn, val: ParsedHostCertificateRenewal, ctx: z.RefinementCtx) => Promise<never>;
51
52
  type ParsedRevokeCertificate = {
52
53
  serial: bigint;
53
54
  public_key: Key;
package/dist/utils.js CHANGED
@@ -3,7 +3,6 @@ import { KeyParseError, CertificateParseError, parseCertificate, parseKey, parse
3
3
  import z from "zod";
4
4
  import { verifyJWT } from "./verify";
5
5
  import { RenewalProofOfPossession, ProofOfPossession, PossessionParseError } from "./proof";
6
- import { isRevoked } from "./db";
7
6
  import { logger } from "./logger";
8
7
  import { ms } from "itty-time";
9
8
  export const fatalIssue = (ctx, message, val) => {
@@ -250,7 +249,7 @@ export const refineHostCertificateRequest = async (env, val, ctx) => {
250
249
  return fatalIssue(ctx, "proof of possession verification unhandled error", val);
251
250
  }
252
251
  };
253
- export const refineHostCertificateRenewal = async (env, val, ctx) => {
252
+ export const refineHostCertificateRenewal = async (env, isRevoked, val, ctx) => {
254
253
  const l = logger(env);
255
254
  try {
256
255
  // ensure certificate is signed by CA
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@andrewheberle/serverless-ssh-ca",
3
- "version": "0.17.5",
3
+ "version": "0.17.7",
4
4
  "description": "A serverless SSH CA built on Cloudflare Workers",
5
5
  "type": "module",
6
- "main": "dist/index.js",
7
6
  "types": "./dist/index.d.ts",
8
7
  "files": [
9
8
  "dist"
@@ -16,6 +15,7 @@
16
15
  },
17
16
  "scripts": {
18
17
  "build": "tsc",
18
+ "coverage": "vitest run --coverage",
19
19
  "test": "vitest run",
20
20
  "test:watch": "vitest",
21
21
  "prepublishOnly": "npm run build",
@@ -24,6 +24,7 @@
24
24
  "dependencies": {
25
25
  "@andrewheberle/ts-slog": "^1.3.0",
26
26
  "@cloudflare/actors": "^0.0.1-beta.6",
27
+ "@cloudflare/workers-types": "^4.20260528.1",
27
28
  "chanfana": "^3.0.0",
28
29
  "hono": "^4.10.6",
29
30
  "itty-time": "^2.0.2",
@@ -32,27 +33,22 @@
32
33
  "zod": "^4.0.0"
33
34
  },
34
35
  "devDependencies": {
35
- "@cloudflare/workers-types": "^4.20260528.1",
36
36
  "@types/sshpk": "^1.17.4",
37
+ "@vitest/coverage-istanbul": "^4.1.7",
38
+ "auto-changelog": "^2.5.1",
37
39
  "release-it": "^20.0.1",
38
40
  "tsx": "^4.21.0",
39
- "typescript": "^6.0.0"
41
+ "typescript": "^6.0.0",
42
+ "vitest": "^4.1.7"
40
43
  },
41
44
  "repository": {
42
45
  "type": "git",
43
- "url": "git+https://github.com/andrewheberle/serverless-ssh-ca.git",
44
- "directory": "packages/ssh-ca"
46
+ "url": "git+https://github.com/andrewheberle/serverless-ssh-ca.git"
45
47
  },
46
48
  "homepage": "https://github.com/andrewheberle/serverless-ssh-ca#readme",
47
49
  "bugs": {
48
50
  "url": "https://github.com/andrewheberle/serverless-ssh-ca/issues"
49
51
  },
50
52
  "author": "Andrew Heberle",
51
- "license": "Apache-2.0",
52
- "release-it": {
53
- "git": false,
54
- "npm": {
55
- "skipChecks": true
56
- }
57
- }
53
+ "license": "Apache-2.0"
58
54
  }
@@ -1 +0,0 @@
1
- export declare const api: import("chanfana").HonoOpenAPIRouterType<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;