@iden3/js-iden3-auth
Version:
iden3-auth implementation in JavaScript
13 lines (12 loc) • 613 B
JavaScript
import { DID } from '@iden3/js-iden3-core';
export class IDOwnershipPubSignals {
async verifyIdOwnership(sender, challenge) {
const senderId = DID.idFromDID(DID.parse(sender));
if (senderId.string() !== this.userId.string()) {
throw new Error(`sender id is not used for proof creation, expected ${senderId}, user from public signals: ${this.userId.string()}`);
}
if (challenge !== this.challenge) {
throw new Error(`challenge is not used for proof creation, expected ${challenge}, challenge from public signals: ${this.challenge} `);
}
}
}