Skip to content

Commit

Permalink
PR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
anku255 committed Jan 22, 2024
1 parent 4449011 commit 57a7149
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion bundle/emailverification.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/website.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions lib/build/recipe/emailverification/emailVerificationClaim.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 36 additions & 33 deletions lib/ts/recipe/emailverification/emailVerificationClaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,46 @@ export class EmailVerificationClaimClass extends BooleanClaim {

this.validators = {
...this.validators,
isVerified: (refetchTimeOnFalseInSeconds = 10, maxAgeInSeconds = 300) => ({
id: this.id,
refresh: this.refresh,
shouldRefresh: (payload, userContext) => {
const DateProvider = DateProviderReference.getReferenceOrThrow().dateProvider;
isVerified: (refetchTimeOnFalseInSeconds = 10, maxAgeInSeconds = 300) => {
const DateProvider = DateProviderReference.getReferenceOrThrow().dateProvider;

if (maxAgeInSeconds < DateProvider.getThresholdInSeconds()) {
throw new Error(
`maxAgeInSeconds must be greater than the DateProvider threshold value -> ${DateProvider.getThresholdInSeconds()}`
);
}
if (maxAgeInSeconds < DateProvider.getThresholdInSeconds()) {
throw new Error(
`maxAgeInSeconds must be greater than the DateProvider threshold value -> ${DateProvider.getThresholdInSeconds()}`
);
}

if (refetchTimeOnFalseInSeconds < DateProvider.getThresholdInSeconds()) {
throw new Error(
`refetchTimeOnFalseInSeconds must be greater than the DateProvider threshold value -> ${DateProvider.getThresholdInSeconds()}`
);
}
if (refetchTimeOnFalseInSeconds < DateProvider.getThresholdInSeconds()) {
throw new Error(
`refetchTimeOnFalseInSeconds must be greater than the DateProvider threshold value -> ${DateProvider.getThresholdInSeconds()}`
);
}

const value = this.getValueFromPayload(payload, userContext);
return (
value === undefined ||
this.getLastFetchedTime(payload, userContext)! < DateProvider.now() - maxAgeInSeconds * 1000 ||
(value === false &&
return {
id: this.id,
refresh: this.refresh,
shouldRefresh: (payload, userContext) => {
const value = this.getValueFromPayload(payload, userContext);
return (
value === undefined ||
this.getLastFetchedTime(payload, userContext)! <
DateProvider.now() - refetchTimeOnFalseInSeconds * 1000)
);
},
validate: async (payload, userContext) => {
const value = this.getValueFromPayload(payload, userContext);
return value === true
? { isValid: true }
: {
isValid: false,
reason: { message: "wrong value", expectedValue: true, actualValue: value },
};
},
}),
DateProvider.now() - maxAgeInSeconds * 1000 ||
(value === false &&
this.getLastFetchedTime(payload, userContext)! <
DateProvider.now() - refetchTimeOnFalseInSeconds * 1000)
);
},
validate: async (payload, userContext) => {
const value = this.getValueFromPayload(payload, userContext);
return value === true
? { isValid: true }
: {
isValid: false,
reason: { message: "wrong value", expectedValue: true, actualValue: value },
};
},
};
},
};
}

Expand Down
5 changes: 3 additions & 2 deletions test/with-typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,8 @@ function getSessionFunctions(original: SessionRecipeInterface): SessionRecipeInt
shouldDoInterceptionBasedOnUrl: function (...input) {
return original.shouldDoInterceptionBasedOnUrl(...input);
},
getClockSkewInMillis: function (input) {
return original.getClockSkewInMillis(input);
calculateClockSkewInMillis: function (input) {
return original.calculateClockSkewInMillis(input);
},
};
}
Expand Down Expand Up @@ -1072,6 +1072,7 @@ const cookieHandlerInput: CookieHandlerInput = (original: CookieHandlerInterface

const dateProviderImplementation: DateProviderInterface = {
getThresholdInSeconds: () => 0,
setThresholdInSeconds: () => {},
getClientClockSkewInMillis: () => 0,
setClientClockSkewInMillis: () => {},
now: () => Date.now(),
Expand Down

0 comments on commit 57a7149

Please sign in to comment.