@kybernesis/arp-scope-catalog 0.2.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/LICENSE +21 -0
- package/README.md +80 -0
- package/dist/index.cjs +518 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +144 -0
- package/dist/index.d.ts +144 -0
- package/dist/index.js +501 -0
- package/dist/index.js.map +1 -0
- package/generated/manifest.json +1542 -0
- package/generated/scopes.json +1536 -0
- package/package.json +49 -0
- package/scopes/calendar.availability.read.yaml +35 -0
- package/scopes/calendar.events.cancel.yaml +24 -0
- package/scopes/calendar.events.create.yaml +31 -0
- package/scopes/calendar.events.modify.yaml +24 -0
- package/scopes/calendar.events.propose.yaml +35 -0
- package/scopes/calendar.events.read.yaml +38 -0
- package/scopes/connection.extend.yaml +28 -0
- package/scopes/connection.rescope.request.yaml +21 -0
- package/scopes/contacts.attributes.read.yaml +25 -0
- package/scopes/contacts.introduce.yaml +21 -0
- package/scopes/contacts.search.yaml +26 -0
- package/scopes/contacts.share.yaml +30 -0
- package/scopes/credentials.present.request.yaml +29 -0
- package/scopes/credentials.proof.zk.request.yaml +31 -0
- package/scopes/delegation.forward.task.yaml +36 -0
- package/scopes/files.project.files.delete.yaml +31 -0
- package/scopes/files.project.files.list.yaml +22 -0
- package/scopes/files.project.files.read.yaml +35 -0
- package/scopes/files.project.files.summarize.yaml +30 -0
- package/scopes/files.project.files.write.yaml +34 -0
- package/scopes/files.project.metadata.read.yaml +21 -0
- package/scopes/files.projects.list.yaml +18 -0
- package/scopes/files.share.external.yaml +39 -0
- package/scopes/identity.card.read.yaml +18 -0
- package/scopes/identity.introduction.request.yaml +24 -0
- package/scopes/identity.principal.verify.yaml +19 -0
- package/scopes/knowledge.query.yaml +31 -0
- package/scopes/messaging.chat.send.yaml +27 -0
- package/scopes/messaging.email.draft.compose.yaml +23 -0
- package/scopes/messaging.email.send.reviewed.yaml +36 -0
- package/scopes/messaging.email.summary.yaml +26 -0
- package/scopes/messaging.email.thread.read.yaml +29 -0
- package/scopes/messaging.relay.to_principal.yaml +22 -0
- package/scopes/notes.read.yaml +25 -0
- package/scopes/notes.search.yaml +24 -0
- package/scopes/notes.write.yaml +32 -0
- package/scopes/payments.authorize.capped.yaml +37 -0
- package/scopes/payments.history.read.yaml +28 -0
- package/scopes/payments.quote.request.yaml +18 -0
- package/scopes/payments.refund.request.yaml +24 -0
- package/scopes/tasks.assign.yaml +27 -0
- package/scopes/tasks.create.yaml +31 -0
- package/scopes/tasks.list.yaml +21 -0
- package/scopes/tasks.read.yaml +22 -0
- package/scopes/tasks.status.update.yaml +22 -0
- package/scopes/tools.invoke.mutating.yaml +37 -0
- package/scopes/tools.invoke.read.yaml +28 -0
- package/scopes/work.projects.list.yaml +18 -0
- package/scopes/work.reports.summary.yaml +29 -0
- package/scopes/work.status.read.yaml +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/loader.ts","../src/catalog-manifest.ts","../src/compiler.ts","../src/bundle-compiler.ts","../src/bundles.ts"],"names":["readFileSync","parseYaml","ScopeTemplateSchema","statSync","readdirSync","resolve","createHash","ScopeCatalogManifestSchema","DID_URI_REGEX","Handlebars"],"mappings":";;;;;;;;;;;;;;AAKO,IAAM,cAAA,GAAN,cAA6B,KAAA,CAAM;AAAA,EACxB,IAAA;AAAA,EACA,MAAA;AAAA,EAEhB,WAAA,CAAY,SAAiB,IAAA,EAA4C;AACvE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,IAAI,IAAA,EAAM,IAAA,KAAS,MAAA,EAAW,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AAC/C,IAAA,IAAI,IAAA,EAAM,MAAA,KAAW,MAAA,EAAW,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AAAA,EACrD;AACF;AAOO,SAAS,cAAc,QAAA,EAAiC;AAC7D,EAAA,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c,QAAQ,EAAE,UAAA,EAAY,gBAAe,EAAE;AAAA,MAC3D,EAAE,EAAA,EAAI,YAAA,EAAc,QAAQ,EAAE,UAAA,EAAY,gBAAe,EAAE;AAAA,MAC3D,EAAE,IAAI,cAAA,EAAgB,MAAA,EAAQ,EAAE,UAAA,EAAY,cAAA,EAAgB,WAAA,EAAa,EAAA,EAAG,EAAE;AAAA,MAC9E,EAAE,EAAA,EAAI,qBAAA,EAAuB,QAAQ,EAAE,UAAA,EAAY,gBAAe,EAAE;AAAA,MACpE,EAAE,EAAA,EAAI,cAAA,EAAgB,QAAQ,EAAE,aAAA,EAAe,gBAAe,EAAE;AAAA,MAChE,EAAE,EAAA,EAAI,YAAA,EAAc,QAAQ,EAAE,aAAA,EAAe,gBAAe,EAAE;AAAA,MAC9D,EAAE,IAAI,aAAA,EAAe,MAAA,EAAQ,EAAE,aAAA,EAAe,cAAA,EAAgB,WAAA,EAAa,GAAA,EAAI,EAAE;AAAA,MACjF,EAAE,IAAI,kBAAA,EAAmB;AAAA,MACzB,EAAE,EAAA,EAAI,sBAAA,EAAwB,QAAQ,EAAE,MAAA,EAAQ,QAAO;AAAE;AAC3D;AAEJ;AAEO,SAAS,WAAW,EAAA,EAA0C;AACnE,EAAA,OAAO,QAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,EAAE,CAAA;AACxC","file":"index.cjs","sourcesContent":["import { readdirSync, readFileSync, statSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { parse as parseYaml } from 'yaml';\nimport { ScopeTemplateSchema, type ScopeTemplate } from '@kybernesis/arp-spec';\n\nexport class ScopeLoadError extends Error {\n public readonly file?: string;\n public readonly issues?: unknown;\n\n constructor(message: string, opts?: { file?: string; issues?: unknown }) {\n super(message);\n this.name = 'ScopeLoadError';\n if (opts?.file !== undefined) this.file = opts.file;\n if (opts?.issues !== undefined) this.issues = opts.issues;\n }\n}\n\n/**\n * Load a single YAML scope file, validate it against `ScopeTemplateSchema`,\n * and return the parsed value. Throws `ScopeLoadError` on YAML parse errors\n * or schema validation failures.\n */\nexport function loadScopeFile(filePath: string): ScopeTemplate {\n let raw: string;\n try {\n raw = readFileSync(filePath, 'utf8');\n } catch (e) {\n throw new ScopeLoadError(`cannot read ${filePath}: ${(e as Error).message}`, {\n file: filePath,\n });\n }\n\n let parsed: unknown;\n try {\n parsed = parseYaml(raw);\n } catch (e) {\n throw new ScopeLoadError(`invalid YAML in ${filePath}: ${(e as Error).message}`, {\n file: filePath,\n });\n }\n\n const result = ScopeTemplateSchema.safeParse(parsed);\n if (!result.success) {\n throw new ScopeLoadError(`scope ${filePath} failed schema validation`, {\n file: filePath,\n issues: result.error.issues,\n });\n }\n return result.data;\n}\n\n/**\n * Load every `*.yaml` file under `scopesDir`, validate each, and return the\n * sorted-by-id array. Also verifies that every filename matches the scope's\n * `id` field (`<id>.yaml`) — cheap but valuable invariant.\n */\nexport function loadScopesFromDirectory(scopesDir: string): ScopeTemplate[] {\n const st = statSync(scopesDir);\n if (!st.isDirectory()) {\n throw new ScopeLoadError(`${scopesDir} is not a directory`);\n }\n\n const files = readdirSync(scopesDir)\n .filter((f) => f.endsWith('.yaml') || f.endsWith('.yml'))\n .sort();\n\n const seen = new Set<string>();\n const scopes: ScopeTemplate[] = [];\n\n for (const file of files) {\n const full = resolve(scopesDir, file);\n const scope = loadScopeFile(full);\n const expected = `${scope.id}.yaml`;\n if (file !== expected && !(file === `${scope.id}.yml`)) {\n throw new ScopeLoadError(\n `filename ${file} does not match scope id ${scope.id} (expected ${expected})`,\n { file: full }\n );\n }\n if (seen.has(scope.id)) {\n throw new ScopeLoadError(`duplicate scope id ${scope.id}`, { file: full });\n }\n seen.add(scope.id);\n scopes.push(scope);\n }\n\n scopes.sort((a, b) => a.id.localeCompare(b.id));\n return scopes;\n}\n","import { createHash } from 'node:crypto';\nimport {\n ScopeCatalogManifestSchema,\n type ScopeCatalogManifest,\n type ScopeTemplate,\n} from '@kybernesis/arp-spec';\n\n/**\n * Deterministically canonicalize a value for checksum computation.\n *\n * We implement a minimal RFC 8785 JCS subset here (objects sorted by key,\n * arrays in order, primitives as JSON.stringify encodes them) rather than\n * pulling in the `canonicalize` dep — the catalog only needs this inside the\n * build step, and we control the inputs. Phase 2 (which actually signs\n * canonicalized payloads) will import `canonicalize` properly.\n */\nexport function canonicalize(value: unknown): string {\n if (value === null) return 'null';\n if (typeof value === 'number' && !Number.isFinite(value)) {\n throw new Error('canonicalize: non-finite numbers are not allowed');\n }\n if (typeof value !== 'object') {\n return JSON.stringify(value);\n }\n if (Array.isArray(value)) {\n return `[${value.map(canonicalize).join(',')}]`;\n }\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj).sort();\n const parts = keys.map((k) => `${JSON.stringify(k)}:${canonicalize(obj[k])}`);\n return `{${parts.join(',')}}`;\n}\n\nexport function sha256Hex(input: string): string {\n return createHash('sha256').update(input, 'utf8').digest('hex');\n}\n\nexport interface BuildManifestOptions {\n /** Catalog version label, default \"v1\". */\n version?: string;\n /**\n * `updated_at` timestamp. When computing deterministic checksums, pass a\n * fixed ISO string. Defaults to the current time.\n */\n updatedAt?: string;\n}\n\n/**\n * Build a `ScopeCatalogManifest` from a list of scope templates. The checksum\n * covers the sorted scopes array (not the top-level metadata) so it is\n * stable across re-runs with different `updated_at` values but identical\n * scope content.\n */\nexport function buildCatalogManifest(\n scopes: readonly ScopeTemplate[],\n options: BuildManifestOptions = {}\n): ScopeCatalogManifest {\n const sorted = [...scopes].sort((a, b) => a.id.localeCompare(b.id));\n const canonical = canonicalize(sorted);\n const checksum = `sha256:${sha256Hex(canonical)}`;\n\n const manifest = {\n version: options.version ?? 'v1',\n updated_at: options.updatedAt ?? new Date().toISOString(),\n scope_count: sorted.length,\n checksum,\n scopes: sorted,\n };\n\n const parsed = ScopeCatalogManifestSchema.parse(manifest);\n return parsed;\n}\n","import Handlebars from 'handlebars';\nimport { DID_URI_REGEX, type ScopeTemplate, type ScopeParameter } from '@kybernesis/arp-spec';\n\nexport class ScopeCompileError extends Error {\n public readonly scopeId?: string;\n public readonly parameter?: string;\n\n constructor(message: string, opts?: { scopeId?: string; parameter?: string }) {\n super(message);\n this.name = 'ScopeCompileError';\n if (opts?.scopeId !== undefined) this.scopeId = opts.scopeId;\n if (opts?.parameter !== undefined) this.parameter = opts.parameter;\n }\n}\n\nfunction parseRangeValidation(\n validation: string\n): { min: number; max: number } | null {\n const match = /^(-?\\d+(?:\\.\\d+)?)\\.\\.(-?\\d+(?:\\.\\d+)?)$/.exec(validation);\n if (!match) return null;\n return { min: Number(match[1]), max: Number(match[2]) };\n}\n\nfunction coerceToNumber(value: unknown): number | null {\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n if (typeof value === 'string' && value.trim() !== '') {\n const n = Number(value);\n if (Number.isFinite(n)) return n;\n }\n return null;\n}\n\nfunction validateParameter(\n scopeId: string,\n def: ScopeParameter,\n initial: unknown\n): unknown {\n let value = initial;\n const present = value !== undefined && value !== null;\n if (!present) {\n if (def.default !== undefined) {\n // Required + default is a valid combo in the catalog — \"required\" here\n // means the compiler must end up with a value. If the caller omits,\n // fall through to type-validate the default the same way we'd validate\n // a caller-supplied value.\n value = def.default;\n } else if (def.required) {\n throw new ScopeCompileError(\n `missing required parameter '${def.name}' for scope ${scopeId}`,\n { scopeId, parameter: def.name }\n );\n } else {\n return undefined;\n }\n }\n\n switch (def.type) {\n case 'Integer': {\n const n = coerceToNumber(value);\n if (n === null || !Number.isInteger(n)) {\n throw new ScopeCompileError(\n `parameter '${def.name}' must be an integer`,\n { scopeId, parameter: def.name }\n );\n }\n if (typeof def.validation === 'string') {\n const range = parseRangeValidation(def.validation);\n if (range && (n < range.min || n > range.max)) {\n throw new ScopeCompileError(\n `parameter '${def.name}'=${n} out of range ${def.validation}`,\n { scopeId, parameter: def.name }\n );\n }\n }\n return n;\n }\n case 'Decimal': {\n const n = coerceToNumber(value);\n if (n === null) {\n throw new ScopeCompileError(\n `parameter '${def.name}' must be a number`,\n { scopeId, parameter: def.name }\n );\n }\n if (typeof def.validation === 'string') {\n const range = parseRangeValidation(def.validation);\n if (range && (n < range.min || n > range.max)) {\n throw new ScopeCompileError(\n `parameter '${def.name}'=${n} out of range ${def.validation}`,\n { scopeId, parameter: def.name }\n );\n }\n }\n return n;\n }\n case 'Enum': {\n if (Array.isArray(def.validation) && !def.validation.includes(String(value))) {\n throw new ScopeCompileError(\n `parameter '${def.name}'='${String(value)}' is not one of [${def.validation.join(', ')}]`,\n { scopeId, parameter: def.name }\n );\n }\n return value;\n }\n case 'AgentDID': {\n if (typeof value !== 'string' || !DID_URI_REGEX.test(value)) {\n throw new ScopeCompileError(\n `parameter '${def.name}' must be a valid DID URI`,\n { scopeId, parameter: def.name }\n );\n }\n return value;\n }\n case 'AgentDIDList': {\n if (!Array.isArray(value) || value.length === 0) {\n throw new ScopeCompileError(\n `parameter '${def.name}' must be a non-empty array of DID URIs`,\n { scopeId, parameter: def.name }\n );\n }\n for (const entry of value) {\n if (typeof entry !== 'string' || !DID_URI_REGEX.test(entry)) {\n throw new ScopeCompileError(\n `parameter '${def.name}' contains an invalid DID URI: ${String(entry)}`,\n { scopeId, parameter: def.name }\n );\n }\n }\n return value;\n }\n case 'ToolIDList':\n case 'AttributeList':\n case 'EmailList': {\n if (!Array.isArray(value)) {\n throw new ScopeCompileError(\n `parameter '${def.name}' must be an array`,\n { scopeId, parameter: def.name }\n );\n }\n return value;\n }\n case 'ProjectID': {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new ScopeCompileError(\n `parameter '${def.name}' must be a non-empty string`,\n { scopeId, parameter: def.name }\n );\n }\n return value;\n }\n case 'Duration':\n case 'Timezone':\n case 'IANATimezone': {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new ScopeCompileError(\n `parameter '${def.name}' must be a non-empty string`,\n { scopeId, parameter: def.name }\n );\n }\n return value;\n }\n }\n}\n\n/**\n * Build the Handlebars context for a scope template. Derives list-shaped\n * helpers (`<name>_json`, `<name>_display`, and flag-style `<name>_flag` for\n * enum parameters) so Cedar templates stay declarative.\n */\nfunction buildHandlebarsContext(\n audienceDid: string,\n scope: ScopeTemplate,\n validated: Record<string, unknown>\n): Record<string, unknown> {\n const ctx: Record<string, unknown> = {\n audience_did: audienceDid,\n ...validated,\n };\n\n for (const [key, value] of Object.entries(validated)) {\n if (Array.isArray(value)) {\n ctx[`${key}_json`] = JSON.stringify(value);\n ctx[`${key}_display`] = value.map((v) => String(v)).join(', ');\n }\n }\n\n // Per-scope helpers. Keeping the catalog's consent_text_template compile\n // path decoupled from the Cedar path would duplicate this for both — we\n // share the same context for both.\n if (scope.id === 'calendar.events.read') {\n ctx.include_private_flag =\n (validated.include_private ?? scope.parameters.find((p) => p.name === 'include_private')?.default) ===\n 'yes';\n }\n\n return ctx;\n}\n\nexport interface CompileScopeOptions {\n scope: ScopeTemplate;\n params?: Record<string, unknown>;\n audienceDid: string;\n}\n\n/**\n * Compile a scope template + parameters + audience DID into a Cedar policy\n * string.\n *\n * - Validates parameters against the scope's declared types + validation\n * rules (ranges, enum values, DID shape). Throws `ScopeCompileError` on\n * any mismatch.\n * - Uses Handlebars under the hood; `{{audience_did}}` is always in scope,\n * plus any validated parameters and the derived `<name>_json` /\n * `<name>_display` helpers.\n */\nexport function compileScope({\n scope,\n params = {},\n audienceDid,\n}: CompileScopeOptions): string {\n if (!DID_URI_REGEX.test(audienceDid)) {\n throw new ScopeCompileError(`audienceDid '${audienceDid}' is not a valid DID URI`, {\n scopeId: scope.id,\n });\n }\n\n const validated: Record<string, unknown> = {};\n for (const def of scope.parameters) {\n validated[def.name] = validateParameter(scope.id, def, params[def.name]);\n }\n\n const ctx = buildHandlebarsContext(audienceDid, scope, validated);\n\n const template = Handlebars.compile(scope.cedar_template, { noEscape: true });\n const rendered = template(ctx);\n return normalizeBareEntityTypes(rendered.trim());\n}\n\n/**\n * Post-process the Handlebars output to produce valid Cedar.\n *\n * Several scope templates in ARP-scope-catalog-v1.md §5 use the shorthand\n * `resource == Tool` (and similar bare-type forms) to mean \"any entity of\n * type Tool\". Cedar's parser requires an entity UID on the right-hand side\n * of `==`, not a bare type name — the idiomatic form is `resource is Tool`.\n *\n * We rewrite `<scope> == <TypeName>` → `<scope> is <TypeName>` whenever the\n * right-hand side is a bare UpperCamelCase identifier (no `::\"...\"` UID and\n * no lower-case head, which would indicate a variable or attribute access).\n *\n * Keeps the YAML sources faithful to the spec doc while guaranteeing the\n * compiled output parses with @cedar-policy/cedar-wasm.\n */\nfunction normalizeBareEntityTypes(cedar: string): string {\n return cedar.replace(\n /(principal|resource)\\s*==\\s*([A-Z][A-Za-z0-9_]*)(?=\\s*[,)\\n])/g,\n '$1 is $2'\n );\n}\n","import type { ScopeTemplate, Obligation } from '@kybernesis/arp-spec';\nimport { compileScope, ScopeCompileError } from './compiler.js';\n\nexport interface CompileBundleInput {\n scopeIds: readonly string[];\n paramsMap?: Record<string, Record<string, unknown>>;\n audienceDid: string;\n /** Lookup table from scope id → template. Usually the loader's output. */\n catalog: readonly ScopeTemplate[];\n}\n\nexport interface CompiledBundle {\n policies: string[];\n obligations: Obligation[];\n /** Fully-expanded scope IDs (original + implied, deduped and topologically sorted). */\n expandedScopeIds: string[];\n}\n\nexport class BundleCompileError extends Error {\n public readonly scopeId?: string;\n public readonly conflict?: [string, string];\n\n constructor(message: string, opts?: { scopeId?: string; conflict?: [string, string] }) {\n super(message);\n this.name = 'BundleCompileError';\n if (opts?.scopeId !== undefined) this.scopeId = opts.scopeId;\n if (opts?.conflict !== undefined) this.conflict = opts.conflict;\n }\n}\n\nfunction indexCatalog(catalog: readonly ScopeTemplate[]): Map<string, ScopeTemplate> {\n const map = new Map<string, ScopeTemplate>();\n for (const scope of catalog) {\n map.set(scope.id, scope);\n }\n return map;\n}\n\ninterface ExpansionResult {\n order: string[];\n /** For each implied scope, the id of the scope that pulled it in. */\n impliedBy: Map<string, string>;\n}\n\n/**\n * Transitively expand `implies` relations starting from `seed`.\n * Returns a stable-ordered array: requested scopes first (in their original\n * order), then any implied scopes added by the expansion (in discovery\n * order). Also records the parent that pulled each implied scope in, so\n * callers can inherit parameter values along the implication edge.\n * Guards against cycles.\n */\nfunction expandImplications(\n seed: readonly string[],\n catalog: Map<string, ScopeTemplate>\n): ExpansionResult {\n const order: string[] = [];\n const visited = new Set<string>();\n const impliedBy = new Map<string, string>();\n const queue: Array<{ id: string; parent: string | null }> = seed.map((id) => ({\n id,\n parent: null,\n }));\n\n while (queue.length > 0) {\n const { id, parent } = queue.shift() as { id: string; parent: string | null };\n if (visited.has(id)) continue;\n visited.add(id);\n const scope = catalog.get(id);\n if (!scope) {\n throw new BundleCompileError(`unknown scope id '${id}'`, { scopeId: id });\n }\n order.push(id);\n if (parent !== null && !impliedBy.has(id)) impliedBy.set(id, parent);\n for (const implied of scope.implies) {\n if (!visited.has(implied)) {\n queue.push({ id: implied, parent: id });\n }\n }\n }\n\n return { order, impliedBy };\n}\n\nfunction detectConflicts(\n expanded: readonly string[],\n catalog: Map<string, ScopeTemplate>\n): void {\n const set = new Set(expanded);\n for (const id of expanded) {\n const scope = catalog.get(id);\n // Existence already checked in expandImplications.\n if (!scope) continue;\n for (const conflict of scope.conflicts_with) {\n if (set.has(conflict)) {\n throw new BundleCompileError(\n `scope '${id}' conflicts with '${conflict}' — cannot coexist in the same bundle`,\n { conflict: [id, conflict] }\n );\n }\n }\n }\n}\n\n/**\n * Resolve the parameter map for `scopeId`. Starts from any explicit entry in\n * `paramsMap`, then — if the scope was pulled in via implication — walks up\n * the chain and fills in any missing required parameters that the parent\n * scope also declares (e.g., `project_id` propagates from\n * `files.project.files.read` down to its implied `.list` / `.metadata.read`).\n */\nfunction resolveParamsForScope(\n scope: ScopeTemplate,\n paramsMap: Record<string, Record<string, unknown>>,\n impliedBy: Map<string, string>,\n idx: Map<string, ScopeTemplate>\n): Record<string, unknown> {\n const own = { ...(paramsMap[scope.id] ?? {}) };\n let parentId = impliedBy.get(scope.id);\n while (parentId) {\n const parentParams = paramsMap[parentId];\n if (parentParams) {\n for (const [k, v] of Object.entries(parentParams)) {\n if (own[k] === undefined) own[k] = v;\n }\n }\n // follow any further implication chain (e.g., A→B→C)\n const grandparentId = impliedBy.get(parentId);\n parentId = grandparentId && grandparentId !== parentId ? grandparentId : undefined;\n }\n // nothing more to do — missing required-with-default params are handled by\n // the per-scope compiler using catalog defaults.\n void idx; // reserved for richer inheritance in the future\n return own;\n}\n\n/**\n * Compile a bundle of scopes into a Cedar policy string list + aggregated\n * obligations.\n *\n * Semantics:\n * 1. Expand `implies` transitively (user-requested ids first, implied\n * later). Each implied scope remembers which scope pulled it in.\n * 2. Check `conflicts_with` across the expanded set; throw if any pair\n * conflicts.\n * 3. Compile each scope using `compileScope`. Implied scopes inherit any\n * required parameters (`project_id`, `collection_id`, …) from the\n * scope that implied them if the caller didn't provide their own\n * `paramsMap` entry.\n * 4. Concatenate `obligations_forced` from every expanded scope into the\n * bundle's obligations array.\n */\nexport function compileBundle({\n scopeIds,\n paramsMap = {},\n audienceDid,\n catalog,\n}: CompileBundleInput): CompiledBundle {\n const idx = indexCatalog(catalog);\n const { order, impliedBy } = expandImplications(scopeIds, idx);\n detectConflicts(order, idx);\n\n const policies: string[] = [];\n const obligations: Obligation[] = [];\n\n for (const id of order) {\n const scope = idx.get(id);\n if (!scope) continue;\n const params = resolveParamsForScope(scope, paramsMap, impliedBy, idx);\n try {\n policies.push(\n compileScope({\n scope,\n audienceDid,\n params,\n })\n );\n } catch (e) {\n if (e instanceof ScopeCompileError) throw e;\n throw new BundleCompileError(\n `failed to compile scope '${id}': ${(e as Error).message}`,\n { scopeId: id }\n );\n }\n for (const ob of scope.obligations_forced) {\n obligations.push({ type: ob.type, params: ob.params });\n }\n }\n\n return { policies, obligations, expandedScopeIds: order };\n}\n","/**\n * Named multi-scope bundles offered as one-tap presets in the consent UI.\n *\n * Source: ARP-scope-catalog-v1.md §6.\n *\n * `params` values marked `null` are user-picked (the UI prompts at\n * bundle-activation time). Values marked with a concrete number/string are\n * presets baked into the bundle.\n */\nexport interface BundleDefinition {\n id: string;\n version: string;\n label: string;\n description: string;\n /**\n * Ordered list of scopes. Each has an optional `params` object; values\n * that are `'<user-picks>'` (string) indicate user-supplied inputs at\n * activation time (the UI collects them).\n */\n scopes: Array<{\n id: string;\n params?: Record<string, unknown>;\n }>;\n}\n\nexport const BUNDLES: readonly BundleDefinition[] = [\n {\n id: 'bundle.project_collaboration.v1',\n version: '1.0.0',\n label: 'Project collaboration',\n description:\n 'Collaborate on a project — read files, task status, and notes; no writes or external sharing.',\n scopes: [\n { id: 'files.projects.list' },\n { id: 'files.project.metadata.read', params: { project_id: '<user-picks>' } },\n { id: 'files.project.files.read', params: { project_id: '<user-picks>', max_size_mb: 25 } },\n { id: 'files.project.files.summarize', params: { project_id: '<user-picks>', max_output_words: 2000 } },\n { id: 'tasks.list', params: { project_id: '<user-picks>' } },\n { id: 'tasks.read', params: { project_id: '<user-picks>' } },\n { id: 'tasks.status.update', params: { project_id: '<user-picks>' } },\n { id: 'notes.search', params: { collection_id: '<user-picks>' } },\n { id: 'notes.read', params: { collection_id: '<user-picks>' } },\n ],\n },\n {\n id: 'bundle.scheduling_assistant.v1',\n version: '1.0.0',\n label: 'Scheduling assistant',\n description: 'Coordinate meetings on your calendar.',\n scopes: [\n { id: 'calendar.availability.read', params: { days_ahead: 14 } },\n {\n id: 'calendar.events.propose',\n params: { max_attendees: 10, max_duration_min: 60 },\n },\n { id: 'contacts.search', params: { attribute_allowlist: ['name', 'email'] } },\n { id: 'messaging.relay.to_principal' },\n ],\n },\n {\n id: 'bundle.research_agent.v1',\n version: '1.0.0',\n label: 'Research agent',\n description: 'Pull research without writing.',\n scopes: [\n { id: 'files.projects.list' },\n { id: 'files.project.files.read', params: { project_id: '<user-picks>', max_size_mb: 25 } },\n { id: 'files.project.files.summarize', params: { project_id: '<user-picks>', max_output_words: 2000 } },\n { id: 'notes.search', params: { collection_id: '<user-picks>' } },\n { id: 'notes.read', params: { collection_id: '<user-picks>' } },\n { id: 'knowledge.query', params: { kb_id: '<user-picks>', max_tokens: 8000 } },\n { id: 'credentials.proof.zk.request', params: { attribute: 'verified_human' } },\n ],\n },\n {\n id: 'bundle.procurement_agent.v1',\n version: '1.0.0',\n label: 'Procurement agent',\n description: 'Buy things under tight caps.',\n scopes: [\n { id: 'payments.quote.request' },\n {\n id: 'payments.authorize.capped',\n params: { max_per_txn_usd: 25, max_per_30d_usd: 200 },\n },\n { id: 'payments.history.read', params: { days_back: 90 } },\n { id: 'messaging.relay.to_principal' },\n ],\n },\n {\n id: 'bundle.executive_assistant.v1',\n version: '1.0.0',\n label: 'Executive assistant',\n description: 'Broad assistant; step-up on anything external-facing.',\n scopes: [\n { id: 'calendar.availability.read', params: { days_ahead: 14 } },\n {\n id: 'calendar.events.propose',\n params: { max_attendees: 10, max_duration_min: 60 },\n },\n { id: 'calendar.events.modify' },\n { id: 'messaging.email.summary' },\n { id: 'messaging.email.draft.compose' },\n { id: 'messaging.email.send.reviewed', params: { recipient_allowlist: [] } },\n { id: 'contacts.search', params: { attribute_allowlist: ['name', 'email'] } },\n { id: 'tasks.list', params: { project_id: '<user-picks>' } },\n { id: 'tasks.read', params: { project_id: '<user-picks>' } },\n { id: 'tasks.create', params: { project_id: '<user-picks>', max_per_day: 50 } },\n { id: 'tasks.status.update', params: { project_id: '<user-picks>' } },\n { id: 'notes.search', params: { collection_id: '<user-picks>' } },\n { id: 'notes.read', params: { collection_id: '<user-picks>' } },\n { id: 'notes.write', params: { collection_id: '<user-picks>', max_per_day: 100 } },\n { id: 'work.status.read' },\n { id: 'work.reports.summary', params: { period: 'week' } },\n ],\n },\n] as const;\n\nexport function findBundle(id: string): BundleDefinition | undefined {\n return BUNDLES.find((b) => b.id === id);\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { ScopeTemplate, ScopeCatalogManifest, Obligation } from '@kybernesis/arp-spec';
|
|
2
|
+
|
|
3
|
+
declare class ScopeLoadError extends Error {
|
|
4
|
+
readonly file?: string;
|
|
5
|
+
readonly issues?: unknown;
|
|
6
|
+
constructor(message: string, opts?: {
|
|
7
|
+
file?: string;
|
|
8
|
+
issues?: unknown;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Load a single YAML scope file, validate it against `ScopeTemplateSchema`,
|
|
13
|
+
* and return the parsed value. Throws `ScopeLoadError` on YAML parse errors
|
|
14
|
+
* or schema validation failures.
|
|
15
|
+
*/
|
|
16
|
+
declare function loadScopeFile(filePath: string): ScopeTemplate;
|
|
17
|
+
/**
|
|
18
|
+
* Load every `*.yaml` file under `scopesDir`, validate each, and return the
|
|
19
|
+
* sorted-by-id array. Also verifies that every filename matches the scope's
|
|
20
|
+
* `id` field (`<id>.yaml`) — cheap but valuable invariant.
|
|
21
|
+
*/
|
|
22
|
+
declare function loadScopesFromDirectory(scopesDir: string): ScopeTemplate[];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Deterministically canonicalize a value for checksum computation.
|
|
26
|
+
*
|
|
27
|
+
* We implement a minimal RFC 8785 JCS subset here (objects sorted by key,
|
|
28
|
+
* arrays in order, primitives as JSON.stringify encodes them) rather than
|
|
29
|
+
* pulling in the `canonicalize` dep — the catalog only needs this inside the
|
|
30
|
+
* build step, and we control the inputs. Phase 2 (which actually signs
|
|
31
|
+
* canonicalized payloads) will import `canonicalize` properly.
|
|
32
|
+
*/
|
|
33
|
+
declare function canonicalize(value: unknown): string;
|
|
34
|
+
declare function sha256Hex(input: string): string;
|
|
35
|
+
interface BuildManifestOptions {
|
|
36
|
+
/** Catalog version label, default "v1". */
|
|
37
|
+
version?: string;
|
|
38
|
+
/**
|
|
39
|
+
* `updated_at` timestamp. When computing deterministic checksums, pass a
|
|
40
|
+
* fixed ISO string. Defaults to the current time.
|
|
41
|
+
*/
|
|
42
|
+
updatedAt?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build a `ScopeCatalogManifest` from a list of scope templates. The checksum
|
|
46
|
+
* covers the sorted scopes array (not the top-level metadata) so it is
|
|
47
|
+
* stable across re-runs with different `updated_at` values but identical
|
|
48
|
+
* scope content.
|
|
49
|
+
*/
|
|
50
|
+
declare function buildCatalogManifest(scopes: readonly ScopeTemplate[], options?: BuildManifestOptions): ScopeCatalogManifest;
|
|
51
|
+
|
|
52
|
+
declare class ScopeCompileError extends Error {
|
|
53
|
+
readonly scopeId?: string;
|
|
54
|
+
readonly parameter?: string;
|
|
55
|
+
constructor(message: string, opts?: {
|
|
56
|
+
scopeId?: string;
|
|
57
|
+
parameter?: string;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
interface CompileScopeOptions {
|
|
61
|
+
scope: ScopeTemplate;
|
|
62
|
+
params?: Record<string, unknown>;
|
|
63
|
+
audienceDid: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compile a scope template + parameters + audience DID into a Cedar policy
|
|
67
|
+
* string.
|
|
68
|
+
*
|
|
69
|
+
* - Validates parameters against the scope's declared types + validation
|
|
70
|
+
* rules (ranges, enum values, DID shape). Throws `ScopeCompileError` on
|
|
71
|
+
* any mismatch.
|
|
72
|
+
* - Uses Handlebars under the hood; `{{audience_did}}` is always in scope,
|
|
73
|
+
* plus any validated parameters and the derived `<name>_json` /
|
|
74
|
+
* `<name>_display` helpers.
|
|
75
|
+
*/
|
|
76
|
+
declare function compileScope({ scope, params, audienceDid, }: CompileScopeOptions): string;
|
|
77
|
+
|
|
78
|
+
interface CompileBundleInput {
|
|
79
|
+
scopeIds: readonly string[];
|
|
80
|
+
paramsMap?: Record<string, Record<string, unknown>>;
|
|
81
|
+
audienceDid: string;
|
|
82
|
+
/** Lookup table from scope id → template. Usually the loader's output. */
|
|
83
|
+
catalog: readonly ScopeTemplate[];
|
|
84
|
+
}
|
|
85
|
+
interface CompiledBundle {
|
|
86
|
+
policies: string[];
|
|
87
|
+
obligations: Obligation[];
|
|
88
|
+
/** Fully-expanded scope IDs (original + implied, deduped and topologically sorted). */
|
|
89
|
+
expandedScopeIds: string[];
|
|
90
|
+
}
|
|
91
|
+
declare class BundleCompileError extends Error {
|
|
92
|
+
readonly scopeId?: string;
|
|
93
|
+
readonly conflict?: [string, string];
|
|
94
|
+
constructor(message: string, opts?: {
|
|
95
|
+
scopeId?: string;
|
|
96
|
+
conflict?: [string, string];
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Compile a bundle of scopes into a Cedar policy string list + aggregated
|
|
101
|
+
* obligations.
|
|
102
|
+
*
|
|
103
|
+
* Semantics:
|
|
104
|
+
* 1. Expand `implies` transitively (user-requested ids first, implied
|
|
105
|
+
* later). Each implied scope remembers which scope pulled it in.
|
|
106
|
+
* 2. Check `conflicts_with` across the expanded set; throw if any pair
|
|
107
|
+
* conflicts.
|
|
108
|
+
* 3. Compile each scope using `compileScope`. Implied scopes inherit any
|
|
109
|
+
* required parameters (`project_id`, `collection_id`, …) from the
|
|
110
|
+
* scope that implied them if the caller didn't provide their own
|
|
111
|
+
* `paramsMap` entry.
|
|
112
|
+
* 4. Concatenate `obligations_forced` from every expanded scope into the
|
|
113
|
+
* bundle's obligations array.
|
|
114
|
+
*/
|
|
115
|
+
declare function compileBundle({ scopeIds, paramsMap, audienceDid, catalog, }: CompileBundleInput): CompiledBundle;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Named multi-scope bundles offered as one-tap presets in the consent UI.
|
|
119
|
+
*
|
|
120
|
+
* Source: ARP-scope-catalog-v1.md §6.
|
|
121
|
+
*
|
|
122
|
+
* `params` values marked `null` are user-picked (the UI prompts at
|
|
123
|
+
* bundle-activation time). Values marked with a concrete number/string are
|
|
124
|
+
* presets baked into the bundle.
|
|
125
|
+
*/
|
|
126
|
+
interface BundleDefinition {
|
|
127
|
+
id: string;
|
|
128
|
+
version: string;
|
|
129
|
+
label: string;
|
|
130
|
+
description: string;
|
|
131
|
+
/**
|
|
132
|
+
* Ordered list of scopes. Each has an optional `params` object; values
|
|
133
|
+
* that are `'<user-picks>'` (string) indicate user-supplied inputs at
|
|
134
|
+
* activation time (the UI collects them).
|
|
135
|
+
*/
|
|
136
|
+
scopes: Array<{
|
|
137
|
+
id: string;
|
|
138
|
+
params?: Record<string, unknown>;
|
|
139
|
+
}>;
|
|
140
|
+
}
|
|
141
|
+
declare const BUNDLES: readonly BundleDefinition[];
|
|
142
|
+
declare function findBundle(id: string): BundleDefinition | undefined;
|
|
143
|
+
|
|
144
|
+
export { BUNDLES, type BuildManifestOptions, BundleCompileError, type BundleDefinition, type CompileBundleInput, type CompileScopeOptions, type CompiledBundle, ScopeCompileError, ScopeLoadError, buildCatalogManifest, canonicalize, compileBundle, compileScope, findBundle, loadScopeFile, loadScopesFromDirectory, sha256Hex };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { ScopeTemplate, ScopeCatalogManifest, Obligation } from '@kybernesis/arp-spec';
|
|
2
|
+
|
|
3
|
+
declare class ScopeLoadError extends Error {
|
|
4
|
+
readonly file?: string;
|
|
5
|
+
readonly issues?: unknown;
|
|
6
|
+
constructor(message: string, opts?: {
|
|
7
|
+
file?: string;
|
|
8
|
+
issues?: unknown;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Load a single YAML scope file, validate it against `ScopeTemplateSchema`,
|
|
13
|
+
* and return the parsed value. Throws `ScopeLoadError` on YAML parse errors
|
|
14
|
+
* or schema validation failures.
|
|
15
|
+
*/
|
|
16
|
+
declare function loadScopeFile(filePath: string): ScopeTemplate;
|
|
17
|
+
/**
|
|
18
|
+
* Load every `*.yaml` file under `scopesDir`, validate each, and return the
|
|
19
|
+
* sorted-by-id array. Also verifies that every filename matches the scope's
|
|
20
|
+
* `id` field (`<id>.yaml`) — cheap but valuable invariant.
|
|
21
|
+
*/
|
|
22
|
+
declare function loadScopesFromDirectory(scopesDir: string): ScopeTemplate[];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Deterministically canonicalize a value for checksum computation.
|
|
26
|
+
*
|
|
27
|
+
* We implement a minimal RFC 8785 JCS subset here (objects sorted by key,
|
|
28
|
+
* arrays in order, primitives as JSON.stringify encodes them) rather than
|
|
29
|
+
* pulling in the `canonicalize` dep — the catalog only needs this inside the
|
|
30
|
+
* build step, and we control the inputs. Phase 2 (which actually signs
|
|
31
|
+
* canonicalized payloads) will import `canonicalize` properly.
|
|
32
|
+
*/
|
|
33
|
+
declare function canonicalize(value: unknown): string;
|
|
34
|
+
declare function sha256Hex(input: string): string;
|
|
35
|
+
interface BuildManifestOptions {
|
|
36
|
+
/** Catalog version label, default "v1". */
|
|
37
|
+
version?: string;
|
|
38
|
+
/**
|
|
39
|
+
* `updated_at` timestamp. When computing deterministic checksums, pass a
|
|
40
|
+
* fixed ISO string. Defaults to the current time.
|
|
41
|
+
*/
|
|
42
|
+
updatedAt?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build a `ScopeCatalogManifest` from a list of scope templates. The checksum
|
|
46
|
+
* covers the sorted scopes array (not the top-level metadata) so it is
|
|
47
|
+
* stable across re-runs with different `updated_at` values but identical
|
|
48
|
+
* scope content.
|
|
49
|
+
*/
|
|
50
|
+
declare function buildCatalogManifest(scopes: readonly ScopeTemplate[], options?: BuildManifestOptions): ScopeCatalogManifest;
|
|
51
|
+
|
|
52
|
+
declare class ScopeCompileError extends Error {
|
|
53
|
+
readonly scopeId?: string;
|
|
54
|
+
readonly parameter?: string;
|
|
55
|
+
constructor(message: string, opts?: {
|
|
56
|
+
scopeId?: string;
|
|
57
|
+
parameter?: string;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
interface CompileScopeOptions {
|
|
61
|
+
scope: ScopeTemplate;
|
|
62
|
+
params?: Record<string, unknown>;
|
|
63
|
+
audienceDid: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compile a scope template + parameters + audience DID into a Cedar policy
|
|
67
|
+
* string.
|
|
68
|
+
*
|
|
69
|
+
* - Validates parameters against the scope's declared types + validation
|
|
70
|
+
* rules (ranges, enum values, DID shape). Throws `ScopeCompileError` on
|
|
71
|
+
* any mismatch.
|
|
72
|
+
* - Uses Handlebars under the hood; `{{audience_did}}` is always in scope,
|
|
73
|
+
* plus any validated parameters and the derived `<name>_json` /
|
|
74
|
+
* `<name>_display` helpers.
|
|
75
|
+
*/
|
|
76
|
+
declare function compileScope({ scope, params, audienceDid, }: CompileScopeOptions): string;
|
|
77
|
+
|
|
78
|
+
interface CompileBundleInput {
|
|
79
|
+
scopeIds: readonly string[];
|
|
80
|
+
paramsMap?: Record<string, Record<string, unknown>>;
|
|
81
|
+
audienceDid: string;
|
|
82
|
+
/** Lookup table from scope id → template. Usually the loader's output. */
|
|
83
|
+
catalog: readonly ScopeTemplate[];
|
|
84
|
+
}
|
|
85
|
+
interface CompiledBundle {
|
|
86
|
+
policies: string[];
|
|
87
|
+
obligations: Obligation[];
|
|
88
|
+
/** Fully-expanded scope IDs (original + implied, deduped and topologically sorted). */
|
|
89
|
+
expandedScopeIds: string[];
|
|
90
|
+
}
|
|
91
|
+
declare class BundleCompileError extends Error {
|
|
92
|
+
readonly scopeId?: string;
|
|
93
|
+
readonly conflict?: [string, string];
|
|
94
|
+
constructor(message: string, opts?: {
|
|
95
|
+
scopeId?: string;
|
|
96
|
+
conflict?: [string, string];
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Compile a bundle of scopes into a Cedar policy string list + aggregated
|
|
101
|
+
* obligations.
|
|
102
|
+
*
|
|
103
|
+
* Semantics:
|
|
104
|
+
* 1. Expand `implies` transitively (user-requested ids first, implied
|
|
105
|
+
* later). Each implied scope remembers which scope pulled it in.
|
|
106
|
+
* 2. Check `conflicts_with` across the expanded set; throw if any pair
|
|
107
|
+
* conflicts.
|
|
108
|
+
* 3. Compile each scope using `compileScope`. Implied scopes inherit any
|
|
109
|
+
* required parameters (`project_id`, `collection_id`, …) from the
|
|
110
|
+
* scope that implied them if the caller didn't provide their own
|
|
111
|
+
* `paramsMap` entry.
|
|
112
|
+
* 4. Concatenate `obligations_forced` from every expanded scope into the
|
|
113
|
+
* bundle's obligations array.
|
|
114
|
+
*/
|
|
115
|
+
declare function compileBundle({ scopeIds, paramsMap, audienceDid, catalog, }: CompileBundleInput): CompiledBundle;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Named multi-scope bundles offered as one-tap presets in the consent UI.
|
|
119
|
+
*
|
|
120
|
+
* Source: ARP-scope-catalog-v1.md §6.
|
|
121
|
+
*
|
|
122
|
+
* `params` values marked `null` are user-picked (the UI prompts at
|
|
123
|
+
* bundle-activation time). Values marked with a concrete number/string are
|
|
124
|
+
* presets baked into the bundle.
|
|
125
|
+
*/
|
|
126
|
+
interface BundleDefinition {
|
|
127
|
+
id: string;
|
|
128
|
+
version: string;
|
|
129
|
+
label: string;
|
|
130
|
+
description: string;
|
|
131
|
+
/**
|
|
132
|
+
* Ordered list of scopes. Each has an optional `params` object; values
|
|
133
|
+
* that are `'<user-picks>'` (string) indicate user-supplied inputs at
|
|
134
|
+
* activation time (the UI collects them).
|
|
135
|
+
*/
|
|
136
|
+
scopes: Array<{
|
|
137
|
+
id: string;
|
|
138
|
+
params?: Record<string, unknown>;
|
|
139
|
+
}>;
|
|
140
|
+
}
|
|
141
|
+
declare const BUNDLES: readonly BundleDefinition[];
|
|
142
|
+
declare function findBundle(id: string): BundleDefinition | undefined;
|
|
143
|
+
|
|
144
|
+
export { BUNDLES, type BuildManifestOptions, BundleCompileError, type BundleDefinition, type CompileBundleInput, type CompileScopeOptions, type CompiledBundle, ScopeCompileError, ScopeLoadError, buildCatalogManifest, canonicalize, compileBundle, compileScope, findBundle, loadScopeFile, loadScopesFromDirectory, sha256Hex };
|