Skip to content

Commit

Permalink
Fix wallet demo to just be wallet, ignore issuer vs verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
fundthmcalculus committed Jul 8, 2022
1 parent 4702209 commit 184b605
Show file tree
Hide file tree
Showing 8 changed files with 279 additions and 1,571 deletions.
4 changes: 2 additions & 2 deletions python/samples/credential_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async def credential_demo():
)
# }
valid = verify_result.is_valid
print(f"Verification result: {valid}")
assert valid is True
print(f"Verification result: {verify_result}")
assert verify_result.validation_results['SignatureVerification'].is_valid


if __name__ == "__main__":
Expand Down
5 changes: 3 additions & 2 deletions samples/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ async function vaccineDemo() {

// @ts-ignore
trinsic.options.authToken = clinic;
const info = await trinsic.account().info();
const info = await trinsic.account().getInfo();
console.log(info)

// Sign a credential as the clinic and send it to Allison
const credentialJson = getVaccineCertUnsignedJSON()
const credential = await trinsic.credential().issueCredential({documentJson: JSON.stringify(credentialJson)});
const credential = await trinsic.credential().issue({documentJson: JSON.stringify(credentialJson)});

// Alice stores the credential in her cloud wallet.
// @ts-ignore
Expand Down
1,779 changes: 251 additions & 1,528 deletions samples/node/package-lock.json

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions samples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "1.0.0",
"description": "Trinsic production test sample of node",
"main": "index.ts",
"type": "module",
"scripts": {
"main": "node --loader ts-node/esm ./index.ts"
"main": "npx ts-node ./index.ts"
},
"repository": {
"type": "git",
Expand All @@ -18,12 +17,9 @@
},
"homepage": "https://github.com/trinsic-id/sdk#readme",
"dependencies": {
"@trinsic/trinsic": "^1.6.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
"@trinsic/trinsic": "1.6.1-rc2"
},
"devDependencies": {
"@types/node": "^17.0.45",
"tslib": "^2.4.0"
"ts-node": "^10.8.2"
}
}
2 changes: 1 addition & 1 deletion samples/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2017",
"module": "ES2022",
"module": "commonjs",
"composite": true,
"outDir": "dist",
"sourceMap": true,
Expand Down
12 changes: 6 additions & 6 deletions web/src/TrinsicService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,42 @@ export class TrinsicService extends ServiceBase {
public account(): AccountService {
this._account =
this._account || new AccountService(this.options);

this._account.options = this.options;
return this._account!;
}

public credential(): CredentialService {
this._credential =
this._credential || new CredentialService(this.options);

this._credential.options = this.options;
return this._credential!;
}

public provider(): ProviderService {
this._provider =
this._provider || new ProviderService(this.options);

this._provider.options = this.options;
return this._provider!;
}

public template(): TemplateService {
this._template =
this._template || new TemplateService(this.options);

this._template.options = this.options;
return this._template!;
}

public trustRegistry(): TrustRegistryService {
this._trustRegistry =
this._trustRegistry || new TrustRegistryService(this.options);

this._trustRegistry.options = this.options;
return this._trustRegistry!;
}

public wallet(): WalletService {
this._wallet =
this._wallet || new WalletService(this.options);

this._wallet.options = this.options;
return this._wallet!;
}
}
34 changes: 10 additions & 24 deletions web/test/WalletService.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import {
CreateCredentialTemplateRequest,
CreateEcosystemRequest,
CreateProofRequest,
FieldType,
InsertItemRequest,
IssueFromTemplateRequest,
TemplateField,
TrinsicService,
AccountProfile,
CreateCredentialTemplateRequest,
CreateEcosystemRequest,
CreateProofRequest,
FieldType,
InsertItemRequest,
IssueFromTemplateRequest,
TemplateField,
TrinsicService,
} from "../src";
import { getTestServerOptions, setTestTimeout } from "./env";
import { v4 as uuid } from "uuid";
import base64url from "base64url";

let options = getTestServerOptions();

Expand Down Expand Up @@ -58,22 +60,6 @@ describe("wallet service tests", () => {
let searchResponse = await trinsic.wallet().search();
expect(searchResponse).not.toBeNull();
expect(searchResponse.items.length).toBeGreaterThan(0);

let proof = await trinsic.credential().createProof(
CreateProofRequest.fromPartial({
itemId: insertResponse.itemId,
revealDocumentJson: JSON.stringify({
"@context": "https://w3id.org/security/v3-unstable",
}),
})
);
expect(proof).not.toBeNull();

let verifyResponse = await trinsic.credential().verifyProof({
proofDocumentJson: proof.proofDocumentJson,
});
expect(verifyResponse).not.toBeNull();
expect(verifyResponse.isValid).toBeTruthy();
});

it("Demo: template management and credential issuance from template", async () => {
Expand Down
4 changes: 3 additions & 1 deletion web/test/WalletService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ describe("WalletService Unit Tests", () => {
});

it("Demo: create wallet, set profile, search records, issue credential", async () => {
trinsic.options = clinic;
let issueResponse = await trinsic.credential().issue({
documentJson: getVaccineCertUnsignedJSON(),
});

trinsic.options = allison;
// insertItemWallet() {
let insertItemResponse = await trinsic.wallet().insertItem(
InsertItemRequest.fromPartial({
Expand Down Expand Up @@ -92,7 +94,7 @@ describe("WalletService Unit Tests", () => {
});
// }

expect(verifyResponse.isValid).toBeTruthy();
expect(verifyResponse.validationResults['SignatureVerification'].isValid).toBeTruthy();
});

it("Demo: template management and credential issuance from template", async () => {
Expand Down

0 comments on commit 184b605

Please sign in to comment.