Skip to content

Commit 3f6ba95

Browse files
update js-sdk to 1.26.0 and verify response typ
1 parent a197115 commit 3f6ba95

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

package-lock.json

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"url": "https://github.com/iden3/js-iden3-auth"
3333
},
3434
"dependencies": {
35-
"@0xpolygonid/js-sdk": "1.23.0",
35+
"@0xpolygonid/js-sdk": "1.26.0",
3636
"@iden3/js-crypto": "1.1.0",
3737
"@iden3/js-iden3-core": "1.4.1",
3838
"@iden3/js-jsonld-merklization": "1.4.1",

src/auth/auth.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ export class Verifier {
419419
opts?: VerifyOpts
420420
): Promise<AuthorizationResponseMessage> {
421421
const msg = await this.packageManager.unpack(byteEncoder.encode(tokenStr));
422+
423+
if (request.body.accept?.length && !request.body.accept.includes(msg.unpackedMediaType)) {
424+
throw new Error('response media type is not accepted by request');
425+
}
426+
422427
const response = msg.unpackedMessage as AuthorizationResponseMessage;
423428
await this.verifyAuthResponse(response, request, opts);
424429
return response;
@@ -438,17 +443,7 @@ export class Verifier {
438443
}
439444
const supportedMediaTypes: PROTOCOL_CONSTANTS.MediaType[] = [];
440445
for (const acceptProfile of profile) {
441-
// 1. check protocol version
442-
const { protocolVersion, env } = parseAcceptProfile(acceptProfile);
443-
const messageTypeVersion = Number(messageType.split('/').at(-2));
444-
if (
445-
protocolVersion !== PROTOCOL_CONSTANTS.ProtocolVersion.V1 ||
446-
(protocolVersion === PROTOCOL_CONSTANTS.ProtocolVersion.V1 &&
447-
(messageTypeVersion < 1 || messageTypeVersion >= 2))
448-
) {
449-
continue;
450-
}
451-
// 2. check packer support
446+
const { env } = parseAcceptProfile(acceptProfile);
452447
if (this.packageManager.isProfileSupported(env, acceptProfile)) {
453448
supportedMediaTypes.push(env);
454449
}

0 commit comments

Comments
 (0)