@andrewheberle/serverless-ssh-ca 0.18.2 → 0.19.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.
package/package.json CHANGED
@@ -1,24 +1,26 @@
1
1
  {
2
2
  "name": "@andrewheberle/serverless-ssh-ca",
3
- "version": "0.18.2",
3
+ "version": "0.19.1",
4
4
  "description": "A serverless SSH CA built on Cloudflare Workers",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "files": [
8
8
  "dist",
9
- "src"
9
+ "src",
10
+ "openapi.json"
10
11
  ],
11
12
  "exports": {
12
13
  ".": {
13
14
  "types": "./dist/index.d.ts",
14
15
  "default": "./dist/index.js"
15
- }
16
+ },
17
+ "./openapi.json": "./openapi.json"
16
18
  },
17
19
  "scripts": {
18
20
  "build": "tsc",
19
21
  "coverage": "vitest run --coverage",
20
22
  "lint": "eslint",
21
- "prepublishOnly": "npm run build",
23
+ "prepublishOnly": "npm run build && npm run schema",
22
24
  "release": "release-it",
23
25
  "release:ci": "npm run release:patch",
24
26
  "release:ci:major": "release-it major --ci",
@@ -31,17 +33,17 @@
31
33
  },
32
34
  "dependencies": {
33
35
  "@andrewheberle/ts-slog": "^1.3.0",
34
- "@cloudflare/workers-types": "^5.0.0",
35
36
  "chanfana": "^3.0.0",
36
37
  "hono": "^4.10.6",
37
38
  "itty-time": "^2.0.2",
38
39
  "jose": "^6.0.12",
39
- "workers-qb": "^1.14.0",
40
40
  "sshpk": "^1.18.0",
41
+ "workers-qb": "^1.14.0",
41
42
  "zod": "^4.0.0"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@eslint/js": "^10.0.1",
46
+ "@types/node": "^24.19.1",
45
47
  "@types/sshpk": "^1.17.4",
46
48
  "@vitest/coverage-v8": "^4.1.7",
47
49
  "eslint": "^10.4.1",
package/src/index.ts CHANGED
@@ -1,7 +1,14 @@
1
+ import type { ExecutionContext } from "hono"
1
2
  import { dbCleanup } from "./db/index.js"
2
3
  import { createApp } from "./router.js"
3
4
  import type { SshCaBindings } from "./types.js"
4
- export type { SshCaBindings } from "./types.js"
5
+ export type { CaDatabase, CaSecret, SshCaBindings } from "./types.js"
6
+
7
+ // the handlers the CA exposes, compatible with a Cloudflare Workers ExportedHandler
8
+ type SshCaHandler = {
9
+ fetch(req: Request, env: SshCaBindings, ctx: ExecutionContext): Response | Promise<Response>
10
+ scheduled(controller: unknown, env: SshCaBindings, ctx: ExecutionContext): Promise<void>
11
+ }
5
12
 
6
13
  let app: ReturnType<typeof createApp> | undefined
7
14
 
@@ -12,7 +19,7 @@ export default {
12
19
  }
13
20
  return app.fetch(req, env, ctx)
14
21
  },
15
- async scheduled(controller: ScheduledController, env: SshCaBindings, ctx: ExecutionContext) {
22
+ async scheduled(controller: unknown, env: SshCaBindings, ctx: ExecutionContext) {
16
23
  ctx.waitUntil(dbCleanup(env))
17
24
  },
18
- } satisfies ExportedHandler<SshCaBindings>
25
+ } satisfies SshCaHandler
package/src/krl.ts CHANGED
@@ -123,7 +123,7 @@ function base64url(bytes: Uint8Array): string {
123
123
  async function importPrivateKey(caKey: PrivateKey): Promise<{
124
124
  cryptoKey: CryptoKey
125
125
  sigAlgo: string // SSH signature algorithm name
126
- webCryptoAlgo: SubtleCryptoSignAlgorithm
126
+ webCryptoAlgo: Parameters<SubtleCrypto["sign"]>[0]
127
127
  }> {
128
128
  const type = caKey.type // "ed25519" | "ecdsa" | etc.
129
129
  const curve = (caKey as unknown as { curve?: string }).curve
package/src/router.ts CHANGED
@@ -5,7 +5,6 @@ import { HTTPException } from "hono/http-exception"
5
5
  import { logger } from "./logger.js"
6
6
  import type { SshCaBindings } from "./types.js"
7
7
 
8
- export type CFArgs = [SshCaBindings, ExecutionContext]
9
8
  export type AppContext = Context<{ Bindings: SshCaBindings }>
10
9
 
11
10
  export const createApp = (env: SshCaBindings) => {
package/src/types.ts CHANGED
@@ -26,10 +26,35 @@ export type SSHExtension = {
26
26
  data: Buffer<ArrayBuffer>
27
27
  }
28
28
 
29
+ /**
30
+ * The subset of a Cloudflare D1 database binding used by the CA.
31
+ *
32
+ * A Workers `D1Database` binding satisfies this structurally, so the package
33
+ * does not need to depend on `@cloudflare/workers-types`.
34
+ */
35
+ export interface CaDatabase {
36
+ prepare(query: string): unknown
37
+ batch(statements: never[]): Promise<unknown>
38
+ exec(query: string): Promise<unknown>
39
+ }
40
+
41
+ /**
42
+ * The subset of a Cloudflare Secrets Store binding used to load the CA private key.
43
+ *
44
+ * A Workers `SecretsStoreSecret` binding satisfies this structurally.
45
+ */
46
+ export interface CaSecret {
47
+ get(): Promise<string>
48
+ }
49
+
50
+ /**
51
+ * The bindings (environment) the CA expects, see {@link CaDatabase} and
52
+ * {@link CaSecret} for the non-string bindings.
53
+ */
29
54
  export interface SshCaBindings {
30
- DB: D1Database
55
+ DB: CaDatabase
31
56
  DB_CERTIFICATE_RETENTION: string
32
- PRIVATE_KEY: SecretsStoreSecret
57
+ PRIVATE_KEY: CaSecret
33
58
  SSH_CERTIFICATE_EXTENSIONS: string
34
59
  SSH_CERTIFICATE_LIFETIME: string
35
60
  SSH_CERTIFICATE_INCLUDE_SELF?: string | boolean