@orangecheck/agent-core 1.1.0 → 1.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/dist/index.mjs CHANGED
@@ -1101,6 +1101,37 @@ function fail(code, message) {
1101
1101
  return { ok: false, code, message };
1102
1102
  }
1103
1103
 
1104
- export { AgentError, DEFAULT_MAX_CHAIN_DEPTH, ENVELOPE_VERSION, REGISTERED_SCOPES, ScopeParseError, actionCanonicalBytes, actionCanonicalMessage, canonicalActionBytes, canonicalDelegationBytes, canonicalRevocationBytes, canonicalizeAction, canonicalizeDelegation, canonicalizeRevocation, canonicalizeScope, canonicalizeScopeString, canonicalizeScopes, computeActionId, computeDelegationId, computeFederationDescriptorId, computeRevocationId, computeSubdelegationId, decodeScopesPayload, delegationCanonicalBytes, delegationCanonicalMessage, encodeScopesPayload, federationDescriptorCanonicalMessage, hasPrivateScopes, isSubScope, parseAndCanonicalizeScopes, parseScope, revocationCanonicalBytes, revocationCanonicalMessage, sealScopes, sha256Hex, subdelegationCanonicalBytes, subdelegationCanonicalMessage, unsealScopes, validateScope, verifyAction, verifyDelegation, verifyFederationDelegation, verifyFederationRevocation, verifyRevocation, verifySubdelegation };
1104
+ // src/assert-scope.ts
1105
+ var ScopeNotGrantedError = class extends Error {
1106
+ constructor(reason, message) {
1107
+ super(message);
1108
+ this.name = "ScopeNotGrantedError";
1109
+ this.reason = reason;
1110
+ }
1111
+ };
1112
+ function assertScopeGranted(delegation, scopeExercised, fnName) {
1113
+ if (hasPrivateScopes(delegation)) {
1114
+ throw new ScopeNotGrantedError(
1115
+ "scopes_encrypted",
1116
+ `${fnName}: this delegation uses v1.2 private scopes \u2014 \`scopes_encrypted\` is set and \`scopes\` is absent, so the granted set cannot be read here. Decrypt it with decryptPrivateScopes() using a matching device key and pass the recovered scopes as \`delegation.scopes\`. Refusing to stamp \`${scopeExercised}\` against an unreadable grant.`
1117
+ );
1118
+ }
1119
+ const scopes = delegation.scopes;
1120
+ if (scopes === void 0 || scopes.length === 0) {
1121
+ throw new ScopeNotGrantedError(
1122
+ "no_scopes",
1123
+ `${fnName}: delegation grants no scopes, so \`${scopeExercised}\` cannot be exercised. An absent or empty \`scopes\` means nothing is granted, never everything.`
1124
+ );
1125
+ }
1126
+ const exercised = parseScope(scopeExercised);
1127
+ if (!scopes.map(parseScope).some((g) => isSubScope(exercised, g))) {
1128
+ throw new ScopeNotGrantedError(
1129
+ "not_subscope",
1130
+ `${fnName}: scope_exercised (${scopeExercised}) is not a sub-scope of any granted scope (${scopes.join(", ")})`
1131
+ );
1132
+ }
1133
+ }
1134
+
1135
+ export { AgentError, DEFAULT_MAX_CHAIN_DEPTH, ENVELOPE_VERSION, REGISTERED_SCOPES, ScopeNotGrantedError, ScopeParseError, actionCanonicalBytes, actionCanonicalMessage, assertScopeGranted, canonicalActionBytes, canonicalDelegationBytes, canonicalRevocationBytes, canonicalizeAction, canonicalizeDelegation, canonicalizeRevocation, canonicalizeScope, canonicalizeScopeString, canonicalizeScopes, computeActionId, computeDelegationId, computeFederationDescriptorId, computeRevocationId, computeSubdelegationId, decodeScopesPayload, delegationCanonicalBytes, delegationCanonicalMessage, encodeScopesPayload, federationDescriptorCanonicalMessage, hasPrivateScopes, isSubScope, parseAndCanonicalizeScopes, parseScope, revocationCanonicalBytes, revocationCanonicalMessage, sealScopes, sha256Hex, subdelegationCanonicalBytes, subdelegationCanonicalMessage, unsealScopes, validateScope, verifyAction, verifyDelegation, verifyFederationDelegation, verifyFederationRevocation, verifyRevocation, verifySubdelegation };
1105
1136
  //# sourceMappingURL=index.mjs.map
1106
1137
  //# sourceMappingURL=index.mjs.map