Skip to content

Commit

Permalink
Tweaks for tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Oct 30, 2024
1 parent 4f85cf3 commit 1c0aced
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
20 changes: 10 additions & 10 deletions packages/dock-blockchain-modules/tests/integration/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let keyDoc;
let validCredential;
let invalidCredential;
let invalidFormatBlobId;
let CoreResolver;
let dockResolver;

const ctx1 = {
"@context": {
Expand Down Expand Up @@ -88,7 +88,7 @@ describe("Schema Blob Module Integration", () => {
keyDoc = getKeyDoc(dockDID, new Ed25519Keypair(firstKeySeed));

// Create a resolver for dock DIDs
CoreResolver = new CoreResolver(modules);
dockResolver = new CoreResolver(modules);

// Create a valid credential with a schema
validCredential = new VerifiableCredential(
Expand Down Expand Up @@ -162,7 +162,7 @@ describe("Schema Blob Module Integration", () => {
test("Utility method verifyCredential should pass if the subject is compatible with the schema in credentialSchema.", async () => {
await expect(
verifyCredential(validCredential.toJSON(), {
resolver: CoreResolver,
resolver: dockResolver,
compactProof: true,
})
).resolves.toBeDefined();
Expand All @@ -171,7 +171,7 @@ describe("Schema Blob Module Integration", () => {
test("The verify method should pass if the subject is compatible with the schema in credentialSchema.", async () => {
await expect(
validCredential.verify({
resolver: CoreResolver,
resolver: dockResolver,
compactProof: true,
})
).resolves.toBeDefined();
Expand All @@ -187,7 +187,7 @@ describe("Schema Blob Module Integration", () => {

await expect(
verifyCredential(invalidCredential.toJSON(), {
resolver: CoreResolver,
resolver: dockResolver,
compactProof: true,
})
).rejects.toThrow(/Schema validation failed/);
Expand All @@ -196,7 +196,7 @@ describe("Schema Blob Module Integration", () => {
test("The verify method should detect a subject with incompatible schema in credentialSchema.", async () => {
await expect(
invalidCredential.verify({
resolver: CoreResolver,
resolver: dockResolver,
compactProof: true,
})
).rejects.toThrow(/Schema validation failed/);
Expand All @@ -223,7 +223,7 @@ describe("Schema Blob Module Integration", () => {
verifyPresentation(vpInvalid.toJSON(), {
challenge: "some_challenge",
domain: "some_domain",
resolver: CoreResolver,
resolver: dockResolver,
compactProof: true,
})
).rejects.toThrow(/Schema validation failed/);
Expand All @@ -241,7 +241,7 @@ describe("Schema Blob Module Integration", () => {
verifyPresentation(vpValid.toJSON(), {
challenge: "some_challenge",
domain: "some_domain",
resolver: CoreResolver,
resolver: dockResolver,
compactProof: true,
})
).resolves.toBeDefined();
Expand All @@ -268,7 +268,7 @@ describe("Schema Blob Module Integration", () => {
vpInvalid.verify({
challenge: "some_challenge",
domain: "some_domain",
resolver: CoreResolver,
resolver: dockResolver,
compactProof: true,
})
).rejects.toThrow(/Schema validation failed/);
Expand All @@ -286,7 +286,7 @@ describe("Schema Blob Module Integration", () => {
vpValid.verify({
challenge: "some_challenge",
domain: "some_domain",
resolver: CoreResolver,
resolver: dockResolver,
compactProof: true,
})
).resolves.toBeDefined();
Expand Down
12 changes: 8 additions & 4 deletions tutorials/src/tutorial_resolver.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ This is how you resolve a Dock DID:
import { CoreResolver } from "@docknetwork/credential-sdk/resolver";

// Assuming the presence of modules created using `CheqdCoreModules` or `DockCoreModules` from the API object.
const CoreResolver = new CoreResolver(modules);
const dockResolver = new CoreResolver(modules);
// Say you had a DID `did:dock:5D.....`
const didDocument = await CoreResolver.resolve("did:dock:5D.....");
const didDocument = await dockResolver.resolve("did:dock:5D.....");
```

## Creating a resolver class for a different method
Expand All @@ -56,7 +56,9 @@ const ethereumProviderConfig = {
};

// Custom ethereum resolver class
class EtherResolver extends DIDResolver {
class EtherResolver extends Resolver {
prefix = "did";

method = "ethr";

constructor(config) {
Expand Down Expand Up @@ -116,7 +118,9 @@ import {
WILDCARD,
} from "@docknetwork/credential-sdk/resolver";

class MultiDIDResolver extends DIDResolver {
class MultiDIDResolver extends Resolver {
prefix = "did";

method = WILDCARD;

constructor(modules) {
Expand Down

0 comments on commit 1c0aced

Please sign in to comment.