Skip to content

Commit

Permalink
rm unused fn
Browse files Browse the repository at this point in the history
  • Loading branch information
gobengo committed Nov 1, 2023
1 parent 079d50d commit b63f49c
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions packages/access-client/src/agent-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,39 +199,3 @@ export function getSessionProofs(data) {
}
return proofs
}

/**
* Given a UCAN, return whether it is a session proof matching some options
*
* @param {Ucanto.Delegation} ucan
* @param {object} options
* @param {Ucanto.DID} [options.issuer] - issuer of session proof
* @param {import('@ucanto/interface').UCANLink} [options.attestedProof] - CID of proof that the session proof attests to
* @param {boolean} [options.allowExpired]
* @returns {boolean} whether the ucan matches the options
*/
export function matchSessionProof(ucan, options) {
if (!isSessionProof(ucan)) {
return false
}
const cap = ucan.capabilities[0]
const matchesRequiredIssuer =
options.issuer === undefined || options.issuer === ucan.issuer.did()
const isExpiredButNotAllowed = !options.allowExpired && isExpired(ucan)
const matchesRequiredProof =
!options.attestedProof ||
options.attestedProof.toString() === cap.nb.proof.toString()
if (!isSessionProof(ucan)) {
return false
}
if (isExpiredButNotAllowed) {
return false
}
if (!matchesRequiredIssuer) {
return false
}
if (!matchesRequiredProof) {
return false
}
return true
}

0 comments on commit b63f49c

Please sign in to comment.