MCPcopy Index your code
hub / github.com/zenstackhq/zenstack / normalizePublicKey

Function normalizePublicKey

packages/cli/src/actions/proxy.ts:68–76  ·  view source on GitHub ↗

* Accepts a public key in either PEM format or as a raw base64 / base64url DER string * (without the `-----BEGIN PUBLIC KEY-----` markers) and always returns a PEM string.

(key: string)

Source from the content-addressed store, hash-verified

66 * (without the `-----BEGIN PUBLIC KEY-----` markers) and always returns a PEM string.
67 */
68function normalizePublicKey(key: string): string {
69 key = key.trim();
70 if (key.startsWith('-----BEGIN PUBLIC KEY-----')) {
71 return key;
72 }
73 // Convert base64url → standard base64, then wrap in PEM markers.
74 const b64 = key.replace(/-/g, '+').replace(/_/g, '/');
75 return `-----BEGIN PUBLIC KEY-----\n${b64}\n-----END PUBLIC KEY-----`;
76}
77
78export async function run(options: Options) {
79 // Resolve public key: CLI arg takes precedence, then ZENSTACK_STUDIO_AUTH_KEY env var.

Callers 1

createProxyAppFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected