@andrewheberle/serverless-ssh-ca 0.18.1 → 0.19.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.
- package/README.md +14 -2
- package/dist/api/v3/index.d.ts +1 -1
- package/dist/api/v3/index.d.ts.map +1 -1
- package/dist/api/v3/index.js +9 -7
- package/dist/api/v3/index.js.map +1 -1
- package/dist/api/v3/schema.d.ts +13 -13
- package/dist/api/v3/schema.d.ts.map +1 -1
- package/dist/api/v3/schema.js +2 -2
- package/dist/api/v3/schema.js.map +1 -1
- package/dist/certificate.d.ts +2 -2
- package/dist/certificate.d.ts.map +1 -1
- package/dist/certificate.js +4 -2
- package/dist/certificate.js.map +1 -1
- package/dist/db/index.d.ts +2 -2
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +2 -2
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations/index.js +1 -1
- package/dist/db/migrations/index.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/krl.js +1 -1
- package/dist/krl.js.map +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/proof.d.ts +2 -2
- package/dist/proof.d.ts.map +1 -1
- package/dist/proof.js +5 -3
- package/dist/proof.js.map +1 -1
- package/dist/router.d.ts +1 -2
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +2 -2
- package/dist/router.js.map +1 -1
- package/dist/sshsig/formats.d.ts +1 -1
- package/dist/sshsig/formats.d.ts.map +1 -1
- package/dist/sshsig/index.d.ts +1 -1
- package/dist/sshsig/index.d.ts.map +1 -1
- package/dist/sshsig/index.js +2 -2
- package/dist/sshsig/index.js.map +1 -1
- package/dist/sshsig/sig.d.ts +1 -1
- package/dist/sshsig/sig.d.ts.map +1 -1
- package/dist/sshsig/sig_parser.d.ts +1 -1
- package/dist/sshsig/sig_parser.d.ts.map +1 -1
- package/dist/sshsig/sig_parser.js +3 -3
- package/dist/sshsig/sig_parser.js.map +1 -1
- package/dist/sshsig/verifier.d.ts +1 -1
- package/dist/sshsig/verifier.d.ts.map +1 -1
- package/dist/sshsig/verifier.js +2 -2
- package/dist/sshsig/verifier.js.map +1 -1
- package/dist/types.d.ts +25 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +5 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +6 -4
- package/dist/utils.js.map +1 -1
- package/dist/verify.d.ts +2 -2
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +1 -1
- package/dist/verify.js.map +1 -1
- package/package.json +3 -3
- package/src/api/v3/index.ts +13 -12
- package/src/api/v3/schema.ts +3 -3
- package/src/certificate.ts +8 -12
- package/src/db/index.ts +4 -4
- package/src/db/migrations/index.ts +1 -1
- package/src/index.ts +13 -6
- package/src/krl.ts +2 -2
- package/src/logger.ts +1 -1
- package/src/proof.ts +8 -4
- package/src/router.ts +3 -4
- package/src/sshsig/formats.ts +1 -1
- package/src/sshsig/index.ts +3 -3
- package/src/sshsig/sig.ts +1 -1
- package/src/sshsig/sig_parser.ts +4 -4
- package/src/sshsig/verifier.ts +3 -3
- package/src/types.ts +27 -2
- package/src/utils.ts +11 -7
- package/src/verify.ts +3 -3
package/src/router.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { fromHono } from "chanfana"
|
|
2
2
|
import { Hono, type Context } from "hono"
|
|
3
|
-
import { createApi as apiv3 } from "./api/v3"
|
|
3
|
+
import { createApi as apiv3 } from "./api/v3/index.js"
|
|
4
4
|
import { HTTPException } from "hono/http-exception"
|
|
5
|
-
import { logger } from "./logger"
|
|
6
|
-
import type { SshCaBindings } from "./types"
|
|
5
|
+
import { logger } from "./logger.js"
|
|
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/sshsig/formats.ts
CHANGED
package/src/sshsig/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Sig } from "./sig";
|
|
2
|
-
import { verify as rawVerify } from "./verifier";
|
|
3
|
-
import { parse } from "./sig_parser";
|
|
1
|
+
import { Sig } from "./sig.js";
|
|
2
|
+
import { verify as rawVerify } from "./verifier.js";
|
|
3
|
+
import { parse } from "./sig_parser.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Verifies SSH signature against provided data.
|
package/src/sshsig/sig.ts
CHANGED
package/src/sshsig/sig_parser.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Sig } from "./sig";
|
|
2
|
-
import { Reader } from "./reader";
|
|
3
|
-
import { parsePubkey } from "./formats";
|
|
4
|
-
import { dearmor } from "./armor";
|
|
1
|
+
import { Sig } from "./sig.js";
|
|
2
|
+
import { Reader } from "./reader.js";
|
|
3
|
+
import { parsePubkey } from "./formats.js";
|
|
4
|
+
import { dearmor } from "./armor.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* ECDSA signature algorithms whose signatures need converting from SSH
|
package/src/sshsig/verifier.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Sig } from "./sig";
|
|
2
|
-
import { convertAlgorithm, convertHash, convertPublicKey } from "./formats";
|
|
3
|
-
import { Writer } from "./writer";
|
|
1
|
+
import { Sig } from "./sig.js";
|
|
2
|
+
import { convertAlgorithm, convertHash, convertPublicKey } from "./formats.js";
|
|
3
|
+
import { Writer } from "./writer.js";
|
|
4
4
|
|
|
5
5
|
export async function verify(
|
|
6
6
|
subtle: SubtleCrypto,
|
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:
|
|
55
|
+
DB: CaDatabase
|
|
31
56
|
DB_CERTIFICATE_RETENTION: string
|
|
32
|
-
PRIVATE_KEY:
|
|
57
|
+
PRIVATE_KEY: CaSecret
|
|
33
58
|
SSH_CERTIFICATE_EXTENSIONS: string
|
|
34
59
|
SSH_CERTIFICATE_LIFETIME: string
|
|
35
60
|
SSH_CERTIFICATE_INCLUDE_SELF?: string | boolean
|
package/src/utils.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import type { SshCaBindings } from "./types"
|
|
1
|
+
import type { SshCaBindings } from "./types.js"
|
|
2
2
|
import { JWKInvalid, JWKSInvalid, JWSInvalid, JWSSignatureVerificationFailed, JWTClaimValidationFailed, JWTExpired, JWTInvalid } from "jose/errors"
|
|
3
|
-
import
|
|
3
|
+
import sshpk from "sshpk"
|
|
4
|
+
import type { Certificate, Key, PrivateKey } from "sshpk"
|
|
4
5
|
import z from "zod"
|
|
5
|
-
import { verifyJWT } from "./verify"
|
|
6
|
-
import { CertificateRequestJWTPayload } from "./types"
|
|
7
|
-
import { RenewalProofOfPossession, ProofOfPossession, PossessionParseError } from "./proof"
|
|
8
|
-
import type { isRevoked as IsRevokedFn } from "./db"
|
|
9
|
-
import { logger } from "./logger"
|
|
6
|
+
import { verifyJWT } from "./verify.js"
|
|
7
|
+
import { CertificateRequestJWTPayload } from "./types.js"
|
|
8
|
+
import { RenewalProofOfPossession, ProofOfPossession, PossessionParseError } from "./proof.js"
|
|
9
|
+
import type { isRevoked as IsRevokedFn } from "./db/index.js"
|
|
10
|
+
import { logger } from "./logger.js"
|
|
10
11
|
import { ms } from "itty-time"
|
|
11
12
|
import { InternalServerErrorException } from "chanfana"
|
|
12
13
|
|
|
14
|
+
// sshpk is CommonJS and Node's ESM loader cannot detect most of its named exports, so values are taken from the default import
|
|
15
|
+
const { KeyParseError, CertificateParseError, parseCertificate, parseKey, parsePrivateKey } = sshpk
|
|
16
|
+
|
|
13
17
|
export const fatalIssue = (ctx: z.RefinementCtx, message: string, val: unknown) => {
|
|
14
18
|
ctx.issues.push({
|
|
15
19
|
code: "custom",
|
package/src/verify.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRemoteJWKSet, jwtVerify } from "jose"
|
|
2
|
-
import { CertificateRequestJWTPayload } from "./types"
|
|
3
|
-
import type { SshCaBindings } from "./types"
|
|
4
|
-
import { split } from "./utils"
|
|
2
|
+
import { CertificateRequestJWTPayload } from "./types.js"
|
|
3
|
+
import type { SshCaBindings } from "./types.js"
|
|
4
|
+
import { split } from "./utils.js"
|
|
5
5
|
|
|
6
6
|
type VerifyOptions = {
|
|
7
7
|
aud?: string | string[]
|