-
Notifications
You must be signed in to change notification settings - Fork 59
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
use /status to get time drift before sending any intents #605
Conversation
packages/waas/src/auth.ts
Outdated
const res = await fetch(`${this.config.rpcServer}/status`) | ||
const date = res.headers.get('Date') | ||
if (!date) { | ||
throw new Error('missing Date header value') |
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.
change error to, failed to get Date header value from /status
... and probably better is to have a well-defined error in the waas ridl for any error type.. but the above message will do for now
packages/waas/src/intents/base.ts
Outdated
@@ -11,9 +11,22 @@ export type SignedIntent<T> = Omit<RawIntent, 'data'> & { data: T } | |||
const INTENTS_VERSION = 1 | |||
const VERSION = `${INTENTS_VERSION} (Web ${PACKAGE_VERSION})` | |||
|
|||
export function getTimeDrift() { | |||
const drift = sessionStorage.getItem('timeDrift') |
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.
your code will throw in react native and node
packages/waas/src/intents/base.ts
Outdated
|
||
export function getTimeDrift() { | ||
if (isSessionStorageAvailable()) { | ||
const drift = sessionStorage.getItem(timeDriftKey) |
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.
should we use window.sessionStorage.getItem(..)
to be explicit..? the "window" part that is..?
No description provided.