-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delgation iterate, more errors and types
* fix(ucanto): add types and tweaks * feat(ucanto): delegation iterate, server error Co-authored-by: Irakli Gozalishvili <[email protected]>
- Loading branch information
1 parent
a6ca603
commit 0606168
Showing
20 changed files
with
507 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,7 @@ dist | |
.nyc_output | ||
tmp | ||
node_modules | ||
|
||
coverage | ||
.pnpm-debug.log | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -553,3 +553,62 @@ test('delegation with several proofs', async () => { | |
|
||
assert.deepEqual(Delegation.import(invocation.export()), invocation) | ||
}) | ||
|
||
test('delegation iterate over proofs', async () => { | ||
const proof1 = await Delegation.delegate({ | ||
issuer: alice, | ||
audience: bob, | ||
capabilities: [ | ||
{ | ||
can: 'store/add', | ||
with: alice.did(), | ||
}, | ||
], | ||
}) | ||
|
||
const proof2 = await Delegation.delegate({ | ||
issuer: service, | ||
audience: mallory, | ||
capabilities: [ | ||
{ | ||
can: 'identity/prove', | ||
with: 'mailto:[email protected]', | ||
}, | ||
], | ||
}) | ||
|
||
const delegation = await Delegation.delegate({ | ||
issuer: bob, | ||
audience: mallory, | ||
capabilities: [ | ||
{ | ||
can: 'store/add', | ||
with: alice.did(), | ||
}, | ||
], | ||
proofs: [proof1], | ||
}) | ||
|
||
const invocation = await Delegation.delegate({ | ||
issuer: mallory, | ||
audience: service, | ||
capabilities: [ | ||
{ | ||
can: 'store/add', | ||
with: alice.did(), | ||
}, | ||
{ | ||
can: 'identity/prove', | ||
with: 'mailto:[email protected]', | ||
}, | ||
], | ||
proofs: [delegation, proof2], | ||
}) | ||
|
||
const proofs = [] | ||
for (const proof of invocation.iterate()) { | ||
proofs.push(proof.cid) | ||
} | ||
|
||
assert.deepEqual(proofs, [proof1.cid, delegation.cid, proof2.cid]) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.