Skip to content

Commit

Permalink
Add illustrative example of using requestedContextParameters property…
Browse files Browse the repository at this point in the history
… on ConditionContext.
  • Loading branch information
derekpierre committed Aug 19, 2024
1 parent 99732a9 commit 1e528aa
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions examples/taco/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,21 @@ const decryptFromBytes = async (encryptedBytes: Uint8Array) => {
domain: 'localhost',
uri: 'http://localhost:3000',
};
const authProvider = new EIP4361AuthProvider(
provider,
consumerSigner,
siweParams,
);
const conditionContext =
conditions.context.ConditionContext.fromMessageKit(messageKit);
conditionContext.addAuthProvider(USER_ADDRESS_PARAM_DEFAULT, authProvider);

// illustrative optional example of checking what context parameters are required
// unnecessary if you already know what the condition contains
if (
conditionContext.requestedContextParameters.has(USER_ADDRESS_PARAM_DEFAULT)
) {
const authProvider = new EIP4361AuthProvider(
provider,
consumerSigner,
siweParams,
);
conditionContext.addAuthProvider(USER_ADDRESS_PARAM_DEFAULT, authProvider);
}
return decrypt(provider, domain, messageKit, conditionContext);
};

Expand Down

0 comments on commit 1e528aa

Please sign in to comment.