Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsmkl committed Sep 1, 2022
1 parent 9f654ed commit 9ffa5f1
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class AuthController {
})
@Public()
token(@Body() clientAssertion: ClientAssertionDto): Promise<LoginDto> {
// console.log('got assertion', clientAssertion)
return this.authService.validateClaim(clientAssertion.grant_type, clientAssertion.assertion);
}

Expand Down
4 changes: 0 additions & 4 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ export class AuthService {
const ddo = await nevermined.assets.resolve(did);
const service = ddo.findServiceByType('nft-access-proof');
if (!service) {
// console.log('its 721');
await this.validateNft721AccessProof(agreement_id, did, consumer_address, buyer, babysig);
return;
}
Expand All @@ -248,7 +247,6 @@ export class AuthService {
if (await nevermined.keeper.nftUpgradeable.balance(consumer_address, did) < numberNfts) {
throw new UnauthorizedException(`Address ${consumer_address} hasn't enough ${did} NFT balance, ${numberNfts.toString()} required`);
}
// console.log('no agreement?');
return;
}
const instanceConfig = {
Expand All @@ -268,13 +266,11 @@ export class AuthService {
throw new UnauthorizedException(`Bad signature for address ${consumer_address}`);
}

// console.log('number', numberNfts.toNumber());
const params = dtp.nftAccessProofTemplate.params(consumer, consumer_address, numberNfts.toNumber());
const conditions = [
{name: 'holder', fulfill: false},
{name: 'access', fulfill: true, condition: dtp.accessProofCondition, extra},
];
// console.log('going to validate', consumer_address);
await validateAgreement({
agreement_id,
did,
Expand Down
3 changes: 0 additions & 3 deletions src/common/guards/shared/jwt.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export const jwtEthVerify = (jwt: string) => {
let publicKey: string;
try {
publicKey = recoverPublicKey(protectedHeader, payload, signature);
// console.log(protectedHeader, "sig", signature, "public", publicKey);
} catch (error) {
throw new Error(`Signature: Failed to validate signature (${(error as Error).message})`);
}
Expand All @@ -102,8 +101,6 @@ export const jwtEthVerify = (jwt: string) => {
throw new Error('Payload: "iss" field is required');
}

// console.log('payload', parsedPayload)

const isValidAddress = ethers.utils.isAddress(parsedPayload.iss);
if (!isValidAddress) {
throw new Error('Payload: "iss" field must be a valid ethereum address');
Expand Down
10 changes: 0 additions & 10 deletions src/common/helpers/agreement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,8 @@ export async function validateAgreement<T>({
params,
conditions,
}: Params<T>) {
// const nevermined = await Nevermined.getInstance(config)
const ddo = await nevermined.assets.resolve(did)
/*
const templateId: string = await nevermined.keeper.agreementStoreManager.call('getAgreementTemplate', [
agreement_id
])
console.log('template', templateId, 'for', agreement_id)
*/
const agreement = await nevermined.keeper.agreementStoreManager.getAgreement(agreement_id)
// console.log('got agreement', agreement)
const agreementData = await template.instanceFromDDO(
agreement.agreementIdSeed,
ddo,
Expand All @@ -81,15 +73,13 @@ export async function validateAgreement<T>({
await Promise.all(conditions.map(async (a,idx) => {
if (!a.fulfill) {
const lock_state = await nevermined.keeper.conditionStoreManager.getCondition(agreementData.instances[idx].id)
// console.log('lock', lock_state)
if (lock_state.state !== ConditionState.Fulfilled) {
throw new UnauthorizedException(`In agreement ${agreement_id}, ${a.name} condition ${agreementData.instances[idx].id} is not fulfilled`)
}
}
}))
for (let {idx, a} of conditions.map((a,idx) => ({idx, a}))) {
if (a.fulfill) {
// console.log('fulfilling', a, idx)
const condInstance = agreementData.instances[idx] as ConditionInstance<{}>
const method = a.delegate ? 'fulfillForDelegate' : 'fulfill'
await a.condition.fulfillInstance(condInstance, a.extra || {}, from, undefined, method)
Expand Down

0 comments on commit 9ffa5f1

Please sign in to comment.