Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme Example Errors and Fix, Ed25519Signature2020 loading issue #123

Open
Wind4Greg opened this issue Aug 11, 2022 · 0 comments
Open

Readme Example Errors and Fix, Ed25519Signature2020 loading issue #123

Wind4Greg opened this issue Aug 11, 2022 · 0 comments

Comments

@Wind4Greg
Copy link

Hi, ran into some problems getting the examples from the README and NPM to run. By borrowing code from the mocha tests the following works to issue a sample credential.

// To run in Node.js use put this in a *.mjs file or set "type": "module" in
// your package.json file.

import {
    Ed25519VerificationKey2018
} from '@digitalbazaar/ed25519-verification-key-2018';
import { Ed25519Signature2018 } from '@digitalbazaar/ed25519-signature-2018';
import {issue} from '@digitalbazaar/vc';

let keyPair = await Ed25519VerificationKey2018.generate({
    id: 'https://example.edu/issuers/keys/1',
    controller: 'https://example.edu/issuers/565049'
});
console.log(keyPair);

// Set up the signature suite, using the generated key
let suite = new Ed25519Signature2018({
    verificationMethod: 'https://example.edu/issuers/keys/1',
    key: keyPair
});
console.log(suite);

const mockCredential = {
    '@context': [
        'https://www.w3.org/2018/credentials/v1',
        'https://www.w3.org/2018/credentials/examples/v1'
    ],
    id: 'http://example.edu/credentials/1872',
    type: ['VerifiableCredential', 'AlumniCredential'],
    issuer: 'https://example.edu/issuers/565049',
    issuanceDate: '2010-01-01T19:23:24Z',
    credentialSubject: {
        id: 'did:example:ebfeb1f712ebc6f1c276e12ec21',
        alumniOf: '<span lang="en">Example University</span>'
    }
};

let verifiableCredential = await issue({
    credential: mockCredential,
    suite
});

console.log(verifiableCredential);

If I try to use the Ed25519VerificationKey2020 and Ed25519Signature2020 packages I get the following error:

code: 'loading remote context failed',
url: 'https://w3id.org/security/suites/ed25519-2020/v1',
cause: Error: Document loader unable to load URL "https://w3id.org/security/suites/ed25519-2020/v1".

However the JSON document seems resolvable in my web browser. Any ideas of what is going wrong. Note that the Mocha tests do not test the *2020 packages.

Cheers
Greg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant