Skip to content

Commit 1e528aa

Browse files
committed
Add illustrative example of using requestedContextParameters property on ConditionContext.
1 parent 99732a9 commit 1e528aa

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

examples/taco/nodejs/src/index.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,21 @@ const decryptFromBytes = async (encryptedBytes: Uint8Array) => {
109109
domain: 'localhost',
110110
uri: 'http://localhost:3000',
111111
};
112-
const authProvider = new EIP4361AuthProvider(
113-
provider,
114-
consumerSigner,
115-
siweParams,
116-
);
117112
const conditionContext =
118113
conditions.context.ConditionContext.fromMessageKit(messageKit);
119-
conditionContext.addAuthProvider(USER_ADDRESS_PARAM_DEFAULT, authProvider);
114+
115+
// illustrative optional example of checking what context parameters are required
116+
// unnecessary if you already know what the condition contains
117+
if (
118+
conditionContext.requestedContextParameters.has(USER_ADDRESS_PARAM_DEFAULT)
119+
) {
120+
const authProvider = new EIP4361AuthProvider(
121+
provider,
122+
consumerSigner,
123+
siweParams,
124+
);
125+
conditionContext.addAuthProvider(USER_ADDRESS_PARAM_DEFAULT, authProvider);
126+
}
120127
return decrypt(provider, domain, messageKit, conditionContext);
121128
};
122129

0 commit comments

Comments
 (0)