generated from digitalcredentials/isomorphic-lib-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
03ce9c5
commit 8bc1061
Showing
6 changed files
with
96 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default function TransactionException(code, message, stack) { | ||
this.code = code | ||
this.message = message | ||
this.stack = stack | ||
} | ||
|
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 |
---|---|---|
@@ -1,12 +1,33 @@ | ||
import {verify} from '@digitalbazaar/vc'; | ||
import {signPresentation, createPresentation, verify} from '@digitalbazaar/vc'; | ||
import {Ed25519VerificationKey2020} from '@digitalbazaar/ed25519-verification-key-2020'; | ||
import {Ed25519Signature2020} from '@digitalbazaar/ed25519-signature-2020'; | ||
import { securityLoader } from './securityLoader.js'; | ||
|
||
const documentLoader = securityLoader().build() | ||
const suite = new Ed25519Signature2020(); | ||
|
||
const signingKeyPairForTesting = await Ed25519VerificationKey2020.generate( | ||
{ | ||
seed: new Uint8Array ([ | ||
217, 87, 166, 30, 75, 106, 132, 55, | ||
32, 120, 171, 23, 116, 73, 254, 74, | ||
230, 16, 127, 91, 2, 252, 224, 96, | ||
184, 172, 245, 157, 58, 217, 91, 240 | ||
]), | ||
controller: "did:key:z6MkvL5yVCgPhYvQwSoSRQou6k6ZGfD5mNM57HKxufEXwfnP" | ||
} | ||
) | ||
const suiteForSigning = new Ed25519Signature2020({key: signingKeyPairForTesting}); | ||
const suiteForVerification = new Ed25519Signature2020(); | ||
|
||
export const getSignedDIDAuth = async (holder = 'did:ex:12345', challenge) => { | ||
const presentation = createPresentation({holder}); | ||
return await signPresentation({ | ||
presentation, suite: suiteForSigning, challenge, documentLoader | ||
}); | ||
} | ||
|
||
export const verifyDIDAuth = async ({presentation, challenge}) => { | ||
const result = await verify({presentation, challenge, suite, documentLoader}); | ||
const result = await verify({presentation, challenge, suite: suiteForVerification, documentLoader}); | ||
return result.verified | ||
} | ||
|
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