Skip to content

Commit

Permalink
add cache loader (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmidyllic authored Oct 10, 2023
1 parent fb00bf4 commit 585e57f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iden3/js-iden3-auth",
"version": "1.0.2",
"version": "1.0.3",
"description": "iden3-auth implementation in JavaScript",
"main": "dist/cjs/index.js",
"source": "./src/index.ts",
Expand Down Expand Up @@ -34,7 +34,7 @@
"url": "https://github.com/iden3/js-iden3-auth"
},
"dependencies": {
"@0xpolygonid/js-sdk": "1.1.0",
"@0xpolygonid/js-sdk": "1.2.2",
"@iden3/eslint-config": "https://github.com/iden3/eslint-config",
"@iden3/js-iden3-core": "1.0.2",
"@iden3/js-jsonld-merklization": "1.0.2",
Expand Down
7 changes: 4 additions & 3 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import {
NativeProver,
IZKProver,
FSCircuitStorage,
ICircuitStorage
ICircuitStorage,
cacheLoader
} from '@0xpolygonid/js-sdk';
import { Resolvable } from 'did-resolver';
import { Options, getDocumentLoader, DocumentLoader } from '@iden3/js-jsonld-merklization';
import { Options, DocumentLoader } from '@iden3/js-jsonld-merklization';
import path from 'path';

/**
Expand Down Expand Up @@ -132,7 +133,7 @@ export class Verifier {
*/
static async newVerifier(params: VerifierParams): Promise<Verifier> {
if (!params.suite) {
const documentLoader = getDocumentLoader(params as Options);
const documentLoader = (params as Options).documentLoader ?? cacheLoader(params as Options);
const dirname = params?.circuitsDir ?? path.join(process.cwd(), 'circuits');
const circuitStorage = new FSCircuitStorage({ dirname });
params.suite = {
Expand Down
16 changes: 8 additions & 8 deletions src/types-sdk.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export {
AuthorizationRequestMessage,
AuthorizationResponseMessage,
CredentialsOfferMessage,
ZeroKnowledgeProofRequest,
ZeroKnowledgeProofResponse,
PROTOCOL_CONSTANTS
} from '@0xpolygonid/js-sdk';
export {
AuthorizationRequestMessage,
AuthorizationResponseMessage,
CredentialsOfferMessage,
ZeroKnowledgeProofRequest,
ZeroKnowledgeProofResponse,
PROTOCOL_CONSTANTS
} from '@0xpolygonid/js-sdk';
12 changes: 6 additions & 6 deletions test/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
PROTOCOL_CONSTANTS,
PackageManager,
ZeroKnowledgeProofRequest,
ZeroKnowledgeProofResponse
ZeroKnowledgeProofResponse,
cacheLoader
} from '@0xpolygonid/js-sdk';
import { IStateResolver, ResolvedState, Resolvers } from '@lib/state/resolver';
import { AuthPubSignalsV2 } from '@lib/circuits/authV2';
Expand All @@ -20,15 +21,15 @@ import {
} from '@lib/auth/auth';
import { Circuits, VerifyOpts } from '@lib/circuits/registry';
import { DIDResolutionResult } from 'did-resolver';
import { DocumentLoader, getDocumentLoader } from '@iden3/js-jsonld-merklization';
import { DocumentLoader } from '@iden3/js-jsonld-merklization';
import path from 'path';

describe('auth tests', () => {
let connectionString = process.env.IPFS_URL;
if (!connectionString) {
connectionString = 'https://ipfs.io';
}
const schemaLoader: DocumentLoader = getDocumentLoader({
const schemaLoader: DocumentLoader = cacheLoader({
ipfsNodeURL: connectionString
});
const exampleDidDoc = {
Expand Down Expand Up @@ -493,7 +494,7 @@ describe('auth tests', () => {
const verifier = await Verifier.newVerifier({
stateResolver: resolvers,
circuitsDir: path.join(__dirname, './testdata'),
documentLoader: schemaLoader
ipfsNodeURL: connectionString
});

const token =
Expand Down Expand Up @@ -538,8 +539,7 @@ describe('auth tests', () => {

const verifier = await Verifier.newVerifier({
stateResolver: resolvers,
circuitsDir: path.join(__dirname, './testdata'),
documentLoader: schemaLoader
circuitsDir: path.join(__dirname, './testdata')
});
request.id = '28494007-9c49-4f1a-9694-7700c08865bf';
request.thid = '7f38a193-0918-4a48-9fac-36adfdb8b542'; // because it's used in the response
Expand Down
5 changes: 2 additions & 3 deletions test/query.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { checkQueryRequest, ClaimOutputs, Query } from '@lib/circuits/query';
import { getUnixTimestamp, Id, SchemaHash } from '@iden3/js-iden3-core';
import { getDocumentLoader } from '@iden3/js-jsonld-merklization';
import { byteEncoder, createSchemaHash } from '@0xpolygonid/js-sdk';
import { byteEncoder, cacheLoader, createSchemaHash } from '@0xpolygonid/js-sdk';

const defaultLoader = getDocumentLoader();
const defaultLoader = cacheLoader();
const vpEmployee = JSON.parse(`{
"@type": "VerifiablePresentation",
"@context": [
Expand Down

0 comments on commit 585e57f

Please sign in to comment.