From 1e528aa196c4a774a192a4dcde1d1f09e31d06cf Mon Sep 17 00:00:00 2001 From: derekpierre Date: Mon, 19 Aug 2024 09:48:12 -0400 Subject: [PATCH] Add illustrative example of using requestedContextParameters property on ConditionContext. --- examples/taco/nodejs/src/index.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/taco/nodejs/src/index.ts b/examples/taco/nodejs/src/index.ts index 7b31aa5c..37e8974a 100644 --- a/examples/taco/nodejs/src/index.ts +++ b/examples/taco/nodejs/src/index.ts @@ -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); };