-
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.
- Loading branch information
Showing
24 changed files
with
717 additions
and
345 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as Signature from '@ipld/dag-ucan/signature' | ||
import * as UCAN from '@ipld/dag-ucan' | ||
|
||
/** | ||
* @template {UCAN.DID} ID | ||
* @param {{id: ID }} id | ||
* @returns {UCAN.Signer<ID, Signature.NON_STANDARD>} | ||
*/ | ||
export const from = ({ id }) => new Absentee(id) | ||
|
||
/** | ||
* An absentee is a special type of signer that produces an absent signature, | ||
* which signals that verifier needs to verify authorization interactively. | ||
* | ||
* @template {UCAN.DID} ID | ||
* @implements {UCAN.Signer<ID, Signature.NON_STANDARD>} | ||
*/ | ||
class Absentee { | ||
/** | ||
* @param {ID} id | ||
*/ | ||
constructor(id) { | ||
this.id = id | ||
} | ||
did() { | ||
return this.id | ||
} | ||
/* c8 ignore next 3 */ | ||
get signatureCode() { | ||
return Signature.NON_STANDARD | ||
} | ||
get signatureAlgorithm() { | ||
return '' | ||
} | ||
sign() { | ||
return Signature.createNonStandard( | ||
this.signatureAlgorithm, | ||
new Uint8Array(0) | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import * as ed25519 from './ed25519.js' | ||
import * as RSA from './rsa.js' | ||
import * as Absentee from './absentee.js' | ||
|
||
export const Verifier = ed25519.Verifier.or(RSA.Verifier) | ||
export const Signer = ed25519.or(RSA) | ||
|
||
export { ed25519, RSA } | ||
export { ed25519, RSA, Absentee } |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Absentee } from '../src/lib.js' | ||
import { assert } from 'chai' | ||
|
||
export const utf8 = new TextEncoder() | ||
describe('Absentee', async () => { | ||
it('it can sign', async () => { | ||
const absentee = Absentee.from({ id: 'did:mailto:web.mail:alice' }) | ||
assert.deepEqual(absentee.did(), 'did:mailto:web.mail:alice') | ||
assert.deepEqual(absentee.signatureAlgorithm, '') | ||
assert.deepEqual(absentee.signatureCode, 0xd000) | ||
|
||
const signature = await absentee.sign(utf8.encode('hello world')) | ||
assert.deepEqual(signature.code, 0xd000) | ||
assert.deepEqual(signature.algorithm, '') | ||
assert.deepEqual(signature.raw, new Uint8Array()) | ||
}) | ||
}) |
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.