Skip to content

Commit

Permalink
Merge branch 'main' into feature/onchain-non-merklized-credential-con…
Browse files Browse the repository at this point in the history
…verter
  • Loading branch information
ilya-korotya committed Nov 12, 2024
2 parents e668d12 + a72b951 commit 763a9c6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 233 deletions.
214 changes: 2 additions & 212 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xpolygonid/js-sdk",
"version": "1.21.2",
"version": "1.21.3",
"description": "SDK to work with Polygon ID",
"main": "dist/node/cjs/index.js",
"module": "dist/node/esm/index.js",
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import commonJS from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import packageJson from './package.json' assert { type: 'json' };
import tsConfig from './tsconfig.json' assert { type: 'json' };
import packageJson from './package.json' with { type: 'json' };
import tsConfig from './tsconfig.json' with { type: 'json' };
import virtual from '@rollup/plugin-virtual';
import json from '@rollup/plugin-json';
const empty = 'export default {}';
Expand Down
9 changes: 6 additions & 3 deletions src/storage/filters/jsonQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,14 @@ const betweenOperator = (
throw new Error('$between/$nonbetween operator value should be 2 elements array');
}

const [min, max] = b.map(BigInt);
const predicate = (val: bigint) => val >= min && val <= max;

if (Array.isArray(a)) {
return a.every((val) => val >= b[0] && val <= b[1]);
return a.map(BigInt).every(predicate);
}

return a >= b[0] && a <= b[1];
return predicate(BigInt(a));
};

export const comparatorOptions: { [v in FilterOperatorMethod]: FilterOperatorFunction } = {
Expand All @@ -182,7 +185,7 @@ export const comparatorOptions: { [v in FilterOperatorMethod]: FilterOperatorFun
$gt: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
greaterThan(a, b),
$lt: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
!greaterThan(a, b),
!greaterThanOrEqual(a, b),
$ne: (a, b) => !equalsComparator(a, b),
$gte: (a: ComparableType | ComparableType[], b: ComparableType | ComparableType[]) =>
greaterThanOrEqual(a, b),
Expand Down
35 changes: 20 additions & 15 deletions tests/handlers/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,46 +118,51 @@ describe('auth', () => {

it('request-response flow identity (not profile)', async () => {
const claimReq: CredentialRequest = {
credentialSchema:
'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/kyc-nonmerklized.json',
type: 'KYCAgeCredential',
credentialSchema: 'ipfs://QmWDmZQrtvidcNK7d6rJwq7ZSi8SUygJaKepN7NhKtGryc',
type: 'operators',
credentialSubject: {
id: userDID.string(),
birthday: 19960424,
documentType: 99
boolean1: true,
'date-time1': '2024-11-04T12:39:00Z',
integer1: 4321,
'non-negative-integer1': '654321',
number1: 1234,
'positive-integer1': '123456789',
string1: 'abcd'
},
expiration: 2793526400,
revocationOpts: {
type: CredentialStatusType.Iden3ReverseSparseMerkleTreeProof,
id: RHS_URL
}
};
const issuerCred = await idWallet.issueCredential(issuerDID, claimReq);
const issuerCred = await idWallet.issueCredential(issuerDID, claimReq, {
ipfsNodeURL: IPFS_URL
});

await credWallet.save(issuerCred);

const proofReq: ZeroKnowledgeProofRequest = {
id: 1,
circuitId: CircuitId.AtomicQuerySigV2,
id: 1730736196,
circuitId: CircuitId.AtomicQueryV3,
optional: false,
query: {
allowedIssuers: ['*'],
type: claimReq.type,
context:
'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-nonmerklized.jsonld',
context: 'ipfs://Qmb48rJ5SiQMLXjVkaLQB6fWbT7C8LK75MHsCoHv8GAc15',
credentialSubject: {
documentType: {
$eq: 99
'positive-integer1': {
$between: ['123456789', '1123456789']
}
}
},
type: 'operators'
}
};

const authReqBody: AuthorizationRequestMessageBody = {
callbackUrl: 'http://localhost:8080/callback?id=1234442-123123-123123',
reason: 'reason',
message: 'message',
scope: [proofReq as ZeroKnowledgeProofRequest]
scope: [proofReq]
};

const id = uuid.v4();
Expand Down

0 comments on commit 763a9c6

Please sign in to comment.