Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.4 kB · 42 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243import { ConfigurationError, record, text } from "./validation.ts";
export interface BridgeKey { readonly keyId: string; readonly publicKey: string;}export interface DeploymentRelease { readonly version: string; readonly artifactDigest: string; readonly operationId: string;}export function parseBridgeKey(value: unknown): BridgeKey { const v = record(value, ["keyId", "publicKey"], "bridge"); const keyId = text(v.keyId, "bridge.keyId"); const publicKey = text(v.publicKey, "bridge.publicKey"); if ( !/^[a-zA-Z0-9_-]{1,64}$/.test(keyId) || !/^[A-Za-z0-9_-]{43}$/.test(publicKey) ) throw new ConfigurationError( "bridge", "expected an Ed25519 public key and key ID", ); return Object.freeze({ keyId, publicKey });}export function parseDeploymentRelease(value: unknown): DeploymentRelease { const v = record( value, ["version", "artifactDigest", "operationId"], "release", ); const version = text(v.version, "release.version"); const artifactDigest = text(v.artifactDigest, "release.artifactDigest"); const operationId = text(v.operationId, "release.operationId"); if ( version.length > 128 || !/^[a-f0-9]{64}$/.test(artifactDigest) || !/^[a-f0-9]{32}$/.test(operationId) ) throw new ConfigurationError("release", "invalid deployment identity"); return Object.freeze({ version, artifactDigest, operationId });}