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

add cache loader #75

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
*/
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 Expand Up @@ -257,7 +258,7 @@
await verifier.verifyStates(this.stateResolver, opts);

// verify id ownership
await verifier.verifyIdOwnership(response.from!, BigInt(proofResp.id));

Check warning on line 261 in src/auth/auth.ts

View workflow job for this annotation

GitHub Actions / build (18.14.0)

Forbidden non-null assertion
}
}

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
Loading