UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

58 lines • 2.12 kB
/** * Pinned canonical KMS key-policy templates (custody design 3.1 and 6.6(a)). * * A device accepts a custody or registry key only if its policy is byte-equal to one of these templates * rendered for pinned role ARNs. No template contains an account-root statement or grants * `kms:PutKeyPolicy`, `kms:CreateGrant` or `kms:ReplicateKey` to anyone, so the checked policy holds for * the key's life. A template change is a new version shipped in a client release before any key uses it. */ import { canonicalJson } from "@earendil-works/pi-agent-core"; const USE_ACTIONS = { "custody-kem": ["kms:DeriveSharedSecret", "kms:GetPublicKey"], "custody-sig": ["kms:GetPublicKey", "kms:Sign"], registry: ["kms:GetPublicKey", "kms:Sign"], }; const ADMIN_ACTIONS = [ "kms:CancelKeyDeletion", "kms:DescribeKey", "kms:DisableKey", "kms:EnableKey", "kms:GetKeyPolicy", "kms:GetPublicKey", "kms:ScheduleKeyDeletion", "kms:TagResource", ]; const READ_ACTIONS = [ "kms:DescribeKey", "kms:GetKeyPolicy", "kms:GetPublicKey", "kms:ListGrants", "kms:ListResourceTags", ]; const BREAKGLASS_ACTIONS = [ "kms:CancelKeyDeletion", "kms:DescribeKey", "kms:DisableKey", "kms:GetKeyPolicy", "kms:ListGrants", "kms:ScheduleKeyDeletion", ]; function statement(sid, principal, actions) { return { Sid: sid, Effect: "Allow", Principal: { AWS: principal }, Action: [...actions], Resource: "*" }; } export const KEY_POLICY_TEMPLATE_V1 = { render({ keyKind, roles }) { const user = keyKind === "registry" ? roles.registrySigner : roles.runtime; return canonicalJson({ Version: "2012-10-17", Id: `omo-custody-${keyKind}-v1`, Statement: [ statement("Use", user, USE_ACTIONS[keyKind]), statement("Admin", roles.provisioning, ADMIN_ACTIONS), statement("Read", roles.reader, READ_ACTIONS), statement("BreakGlass", roles.breakglass, BREAKGLASS_ACTIONS), ], }); }, }; //# sourceMappingURL=key-policy-template.js.map