Skip to content

Commit

Permalink
fix constants import
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Nov 26, 2024
1 parent 83a0e04 commit 30a5273
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
10 changes: 3 additions & 7 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ import { Options, DocumentLoader } from '@iden3/js-jsonld-merklization';
import path from 'path';
import { DID, getUnixTimestamp } from '@iden3/js-iden3-core';
import { ZeroKnowledgeProofRequest } from '@0xpolygonid/js-sdk';
import {
MediaType,
ProtocolVersion
} from '@0xpolygonid/js-sdk/dist/types/iden3comm/constants';

/**
* Options to pass to createAuthorizationRequest function
Expand Down Expand Up @@ -440,14 +436,14 @@ export class Verifier {
if (!profile?.length) {
return;
}
const supportedMediaTypes: MediaType[] = [];
const supportedMediaTypes: PROTOCOL_CONSTANTS.MediaType[] = [];
for (const acceptProfile of profile) {
// 1. check protocol version
const { protocolVersion, env } = parseAcceptProfile(acceptProfile);
const messageTypeVersion = Number(messageType.split('/').at(-2));
if (
protocolVersion !== ProtocolVersion.V1 ||
(protocolVersion === ProtocolVersion.V1 &&
protocolVersion !== PROTOCOL_CONSTANTS.ProtocolVersion.V1 ||
(protocolVersion === PROTOCOL_CONSTANTS.ProtocolVersion.V1 &&
(messageTypeVersion < 1 || messageTypeVersion >= 2))
) {
continue;
Expand Down
11 changes: 3 additions & 8 deletions test/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,14 @@ import { Circuits } from '@lib/circuits/registry';
import path from 'path';
import { resolveDIDDocument, resolvers, schemaLoader, testOpts } from './mocks';
import { getDateFromUnixTimestamp, getUnixTimestamp } from '@iden3/js-iden3-core';
import {
AcceptAuthCircuits,
MediaType,
ProtocolVersion
} from '@0xpolygonid/js-sdk/dist/types/iden3comm/constants';

describe('auth tests', () => {
const connectionString = process.env.IPFS_URL ?? 'https://ipfs.io';
const acceptProfile = buildAccept([
{
protocolVersion: ProtocolVersion.V1,
env: MediaType.ZKPMessage,
circuits: [AcceptAuthCircuits.AuthV2]
protocolVersion: PROTOCOL_CONSTANTS.ProtocolVersion.V1,
env: PROTOCOL_CONSTANTS.MediaType.ZKPMessage,
circuits: [PROTOCOL_CONSTANTS.AcceptAuthCircuits.AuthV2]
}
]);
const expiresTime = getDateFromUnixTimestamp(getUnixTimestamp(new Date()) + 5 * 60);
Expand Down

0 comments on commit 30a5273

Please sign in to comment.