From 50059fb922bad08648cd8e936920d2d7db7686a0 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Thu, 18 Jan 2024 13:44:32 +0530 Subject: [PATCH 1/4] feat: Add docs for using DateProvider in SessionClaimValidator --- .../sessions/claims/claim-validators.mdx | 20 ++++++++++++++++++- .../sessions/claims/claim-validators.mdx | 20 ++++++++++++++++++- .../sessions/claims/claim-validators.mdx | 20 ++++++++++++++++++- .../sessions/claims/claim-validators.mdx | 20 ++++++++++++++++++- .../sessions/claims/claim-validators.mdx | 20 ++++++++++++++++++- .../sessions/claims/claim-validators.mdx | 20 ++++++++++++++++++- 6 files changed, 114 insertions(+), 6 deletions(-) diff --git a/v2/emailpassword/common-customizations/sessions/claims/claim-validators.mdx b/v2/emailpassword/common-customizations/sessions/claims/claim-validators.mdx index 12eeee0c0..8900a22f7 100644 --- a/v2/emailpassword/common-customizations/sessions/claims/claim-validators.mdx +++ b/v2/emailpassword/common-customizations/sessions/claims/claim-validators.mdx @@ -267,7 +267,25 @@ type ClaimValidationResult = { isValid: true } | { isValid: false; reason?: any - The `refresh` function is the same as the one in the frontend claim interface. -- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. +- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. When implementing this function for a `SessionClaimValidator` and using `Date.now`, it's advisable to use `DateProvider.now` from our SDK. This mitigates potential clock skew issues by accounting for the time difference between the frontend and backend. Use `DateProvider` as shown: + + + +```tsx +import { DateProviderReference } from "supertokens-auth-react/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + + + + +```tsx +import { DateProviderReference } from "supertokens-web-js/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + - The `validate` function checks the `accessTokenPayload` for the value of the claim and returns an appropriate response. diff --git a/v2/passwordless/common-customizations/sessions/claims/claim-validators.mdx b/v2/passwordless/common-customizations/sessions/claims/claim-validators.mdx index 12eeee0c0..8900a22f7 100644 --- a/v2/passwordless/common-customizations/sessions/claims/claim-validators.mdx +++ b/v2/passwordless/common-customizations/sessions/claims/claim-validators.mdx @@ -267,7 +267,25 @@ type ClaimValidationResult = { isValid: true } | { isValid: false; reason?: any - The `refresh` function is the same as the one in the frontend claim interface. -- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. +- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. When implementing this function for a `SessionClaimValidator` and using `Date.now`, it's advisable to use `DateProvider.now` from our SDK. This mitigates potential clock skew issues by accounting for the time difference between the frontend and backend. Use `DateProvider` as shown: + + + +```tsx +import { DateProviderReference } from "supertokens-auth-react/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + + + + +```tsx +import { DateProviderReference } from "supertokens-web-js/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + - The `validate` function checks the `accessTokenPayload` for the value of the claim and returns an appropriate response. diff --git a/v2/session/common-customizations/sessions/claims/claim-validators.mdx b/v2/session/common-customizations/sessions/claims/claim-validators.mdx index 12eeee0c0..8900a22f7 100644 --- a/v2/session/common-customizations/sessions/claims/claim-validators.mdx +++ b/v2/session/common-customizations/sessions/claims/claim-validators.mdx @@ -267,7 +267,25 @@ type ClaimValidationResult = { isValid: true } | { isValid: false; reason?: any - The `refresh` function is the same as the one in the frontend claim interface. -- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. +- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. When implementing this function for a `SessionClaimValidator` and using `Date.now`, it's advisable to use `DateProvider.now` from our SDK. This mitigates potential clock skew issues by accounting for the time difference between the frontend and backend. Use `DateProvider` as shown: + + + +```tsx +import { DateProviderReference } from "supertokens-auth-react/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + + + + +```tsx +import { DateProviderReference } from "supertokens-web-js/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + - The `validate` function checks the `accessTokenPayload` for the value of the claim and returns an appropriate response. diff --git a/v2/thirdparty/common-customizations/sessions/claims/claim-validators.mdx b/v2/thirdparty/common-customizations/sessions/claims/claim-validators.mdx index 12eeee0c0..8900a22f7 100644 --- a/v2/thirdparty/common-customizations/sessions/claims/claim-validators.mdx +++ b/v2/thirdparty/common-customizations/sessions/claims/claim-validators.mdx @@ -267,7 +267,25 @@ type ClaimValidationResult = { isValid: true } | { isValid: false; reason?: any - The `refresh` function is the same as the one in the frontend claim interface. -- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. +- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. When implementing this function for a `SessionClaimValidator` and using `Date.now`, it's advisable to use `DateProvider.now` from our SDK. This mitigates potential clock skew issues by accounting for the time difference between the frontend and backend. Use `DateProvider` as shown: + + + +```tsx +import { DateProviderReference } from "supertokens-auth-react/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + + + + +```tsx +import { DateProviderReference } from "supertokens-web-js/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + - The `validate` function checks the `accessTokenPayload` for the value of the claim and returns an appropriate response. diff --git a/v2/thirdpartyemailpassword/common-customizations/sessions/claims/claim-validators.mdx b/v2/thirdpartyemailpassword/common-customizations/sessions/claims/claim-validators.mdx index 12eeee0c0..8900a22f7 100644 --- a/v2/thirdpartyemailpassword/common-customizations/sessions/claims/claim-validators.mdx +++ b/v2/thirdpartyemailpassword/common-customizations/sessions/claims/claim-validators.mdx @@ -267,7 +267,25 @@ type ClaimValidationResult = { isValid: true } | { isValid: false; reason?: any - The `refresh` function is the same as the one in the frontend claim interface. -- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. +- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. When implementing this function for a `SessionClaimValidator` and using `Date.now`, it's advisable to use `DateProvider.now` from our SDK. This mitigates potential clock skew issues by accounting for the time difference between the frontend and backend. Use `DateProvider` as shown: + + + +```tsx +import { DateProviderReference } from "supertokens-auth-react/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + + + + +```tsx +import { DateProviderReference } from "supertokens-web-js/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + - The `validate` function checks the `accessTokenPayload` for the value of the claim and returns an appropriate response. diff --git a/v2/thirdpartypasswordless/common-customizations/sessions/claims/claim-validators.mdx b/v2/thirdpartypasswordless/common-customizations/sessions/claims/claim-validators.mdx index 12eeee0c0..8900a22f7 100644 --- a/v2/thirdpartypasswordless/common-customizations/sessions/claims/claim-validators.mdx +++ b/v2/thirdpartypasswordless/common-customizations/sessions/claims/claim-validators.mdx @@ -267,7 +267,25 @@ type ClaimValidationResult = { isValid: true } | { isValid: false; reason?: any - The `refresh` function is the same as the one in the frontend claim interface. -- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. +- `shouldRefresh` is function which determines if the claim should be checked against the backend before calling `validate`. This usually returns `true` if the claim value is too old or if it is not present in the `accessTokenPayload`. When implementing this function for a `SessionClaimValidator` and using `Date.now`, it's advisable to use `DateProvider.now` from our SDK. This mitigates potential clock skew issues by accounting for the time difference between the frontend and backend. Use `DateProvider` as shown: + + + +```tsx +import { DateProviderReference } from "supertokens-auth-react/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + + + + +```tsx +import { DateProviderReference } from "supertokens-web-js/utils/dateProvider"; +DateProviderReference.getReferenceOrThrow().dateProvider.now(); +``` + + - The `validate` function checks the `accessTokenPayload` for the value of the claim and returns an appropriate response. From 60e3674c1e335d065bf812e078301f0288271727 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Mon, 29 Jan 2024 16:47:09 +0530 Subject: [PATCH 2/4] update dependencies version --- v2/src/plugins/codeTypeChecking/jsEnv/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/v2/src/plugins/codeTypeChecking/jsEnv/package.json b/v2/src/plugins/codeTypeChecking/jsEnv/package.json index 53cadb10b..6131a2d03 100644 --- a/v2/src/plugins/codeTypeChecking/jsEnv/package.json +++ b/v2/src/plugins/codeTypeChecking/jsEnv/package.json @@ -55,13 +55,13 @@ "react-router-dom5": "npm:react-router-dom@^5.3.0", "socket.io": "^4.6.1", "socketio": "^1.0.0", - "supertokens-auth-react": "^0.36.0", + "supertokens-auth-react": "^0.37.0", "supertokens-node": "^16.7.0", "supertokens-node7": "npm:supertokens-node@7.3", "supertokens-react-native": "^4.0.0", - "supertokens-web-js": "^0.8.0", + "supertokens-web-js": "^0.9.0", "supertokens-web-js-script": "github:supertokens/supertokens-web-js#0.8", - "supertokens-website": "^17.0.0", + "supertokens-website": "^18.0.0", "supertokens-website-script": "github:supertokens/supertokens-website#17.0", "typescript": "^4.9.5" } From 858fda5930964fa7d48025a6eab1ce1d32eaf012 Mon Sep 17 00:00:00 2001 From: Rishabh Poddar Date: Mon, 29 Jan 2024 16:51:43 +0530 Subject: [PATCH 3/4] Update v2/src/plugins/codeTypeChecking/jsEnv/package.json --- v2/src/plugins/codeTypeChecking/jsEnv/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/src/plugins/codeTypeChecking/jsEnv/package.json b/v2/src/plugins/codeTypeChecking/jsEnv/package.json index 6131a2d03..1a0e884ba 100644 --- a/v2/src/plugins/codeTypeChecking/jsEnv/package.json +++ b/v2/src/plugins/codeTypeChecking/jsEnv/package.json @@ -60,7 +60,7 @@ "supertokens-node7": "npm:supertokens-node@7.3", "supertokens-react-native": "^4.0.0", "supertokens-web-js": "^0.9.0", - "supertokens-web-js-script": "github:supertokens/supertokens-web-js#0.8", + "supertokens-web-js-script": "github:supertokens/supertokens-web-js#0.9", "supertokens-website": "^18.0.0", "supertokens-website-script": "github:supertokens/supertokens-website#17.0", "typescript": "^4.9.5" From 9ecb9d14b864478b6447728b2aca92e244f16351 Mon Sep 17 00:00:00 2001 From: Rishabh Poddar Date: Mon, 29 Jan 2024 16:51:48 +0530 Subject: [PATCH 4/4] Update v2/src/plugins/codeTypeChecking/jsEnv/package.json --- v2/src/plugins/codeTypeChecking/jsEnv/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/src/plugins/codeTypeChecking/jsEnv/package.json b/v2/src/plugins/codeTypeChecking/jsEnv/package.json index 1a0e884ba..8fb27cc14 100644 --- a/v2/src/plugins/codeTypeChecking/jsEnv/package.json +++ b/v2/src/plugins/codeTypeChecking/jsEnv/package.json @@ -62,7 +62,7 @@ "supertokens-web-js": "^0.9.0", "supertokens-web-js-script": "github:supertokens/supertokens-web-js#0.9", "supertokens-website": "^18.0.0", - "supertokens-website-script": "github:supertokens/supertokens-website#17.0", + "supertokens-website-script": "github:supertokens/supertokens-website#18.0", "typescript": "^4.9.5" } }