-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: synced expiries #4159
fix: synced expiries #4159
Conversation
…connect-monorepo into fix/synced-expiries
This is for backwards compat I'm assuming? |
correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 💯 some minor tweaks suggested but LGTM overall
@@ -156,6 +157,8 @@ export class Engine extends IEngine { | |||
|
|||
const publicKey = await this.client.core.crypto.generateKeyPair(); | |||
|
|||
const expiry = ENGINE_RPC_OPTS.wc_sessionPropose.req.ttl || FIVE_MINUTES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ENGINE_RPC_OPTS.wc_sessionPropose.req.ttl
is already a constant right, why do we need the ||
defaulting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's type is actually number | undefined
causing ts to complain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be better just updating it to explicit type number
and not optional
@@ -397,6 +398,16 @@ export class Pairing implements IPairing { | |||
const { message } = getInternalError("MISSING_OR_INVALID", `pair() uri#symKey`); | |||
throw new Error(message); | |||
} | |||
if (uri?.expiryTimestamp) { | |||
const expiration = toMiliseconds(uri?.expiryTimestamp); | |||
if (expiration < Date.now()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably strictly theoretical rather than realistic, but I think there's an edge case here where:
toMiliseconds
simply adds zeroes to the end of seconds-basedexpiration
Date.now()
has non-zero values in the last 3 digits
Either way I think we can ignore because that only applies within the same second :)
@ganchoradkov it's not entirely clear how to apply this fix to override those five minutes. Any documentation on it? Thanks |
Description
Implemented synced expiries for session proposals and session requests. Synced expiries are defined by the sending peer and used by both sending & receiving peers. If no
expiryTimestamp
is received, default values are used.Additionally
Type of change
How has this been tested?
tests
dogfooding
WalletConnect/web-examples#432
Checklist
Additional Information (Optional)
Please include any additional information that may be useful for the reviewer.