Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/interface/src/capability.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Ability, Capability, DID, Link, Resource } from '@ipld/dag-ucan'
import * as UCAN from '@ipld/dag-ucan'
import {
AuthorityProver,
SessionAuthorizer,
Delegation,
Result,
Failure,
Expand Down Expand Up @@ -378,7 +378,7 @@ export interface ValidationOptions<
PrincipalResolver,
ProofResolver,
RevocationChecker,
Partial<AuthorityProver> {
Partial<SessionAuthorizer> {
capability: CapabilityParser<Match<C, any>>
}

Expand All @@ -389,7 +389,7 @@ export interface ClaimOptions
PrincipalResolver,
ProofResolver,
RevocationChecker,
Partial<AuthorityProver> {}
Partial<SessionAuthorizer> {}

export interface DelegationError extends Failure {
name: 'InvalidClaim'
Expand Down
13 changes: 8 additions & 5 deletions packages/interface/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ export interface HTTPError {
/**
* Options for UCAN validation.
*/
export interface ValidatorOptions extends PrincipalResolver, Partial<AuthorityProver> {
export interface ValidatorOptions extends PrincipalResolver, Partial<SessionAuthorizer> {
/**
* Schema allowing invocations to be accepted for audiences other than the
* service itself.
Expand Down Expand Up @@ -1097,13 +1097,16 @@ export interface PrincipalResolver {
}

/**
* `AuthorityProver` provides a set of proofs of authority.
* `SessionAuthorizer` configures the means for authorizing a session.
*/
export interface AuthorityProver {
export interface SessionAuthorizer {
/**
* Proof(s) of authority.
* Authorities we trust for session authorization. Note the authority for
* UCAN verification is implicitly trusted so need not be included here. This
* is typically used to provide additional authorities that are trusted to
* authorize a session.
*/
proofs: Delegation[]
sessionAuthorities: Principal[]
}

/**
Expand Down
12 changes: 3 additions & 9 deletions packages/validator/src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export const claim = async (
resolveDIDKey = failDIDKeyResolution,
canIssue = isSelfIssued,
resolve = unavailable,
proofs: localProofs = [],
sessionAuthorities = [],
}
) => {
const config = {
Expand All @@ -245,7 +245,7 @@ export const claim = async (
authority,
validateAuthorization,
resolveDIDKey,
proofs: localProofs,
sessionAuthorities,
}

const invalidProofs = []
Expand Down Expand Up @@ -569,13 +569,7 @@ const verifySignature = async (delegation, verifier) => {
*/
const verifySession = async (delegation, proofs, config) => {
// Recognize attestations from all authorized principals, not just authority
const withSchemas = config.proofs
.filter(
p =>
p.capabilities[0].can === 'ucan/attest' &&
p.capabilities[0].with === config.authority.did()
)
.map(p => Schema.literal(p.audience.did()))
const withSchemas = config.sessionAuthorities.map(a => Schema.literal(a.did()))

const withSchema = withSchemas.length
? Schema.union([Schema.literal(config.authority.did()), ...withSchemas])
Expand Down
11 changes: 1 addition & 10 deletions packages/validator/test/session.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,7 @@ test('validate mailto attested by another service', async () => {
}
return { error: new DIDKeyResolutionError(did) }
},
proofs: [
await attest.delegate({
issuer: w3,
audience: other,
with: w3.did()
})
],
sessionAuthorities: [other]
})

assert.containSubset(result, {
Expand Down Expand Up @@ -785,9 +779,6 @@ test('fail with multiple invalid verifiers', async () => {
}
})

console.log('Result:', result)
console.log('Result error:', result.error)

assert.match(
`${result.error}`,
/Proof .* does not has a valid signature from did:key:/
Expand Down