Skip to content

Commit 4fb3dbf

Browse files
authored
feat: remove default max age claims (#162)
* feat: remove default max age from claims * chore: update changelog
1 parent 3e1bf01 commit 4fb3dbf

File tree

8 files changed

+25
-21
lines changed

8 files changed

+25
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
###
11+
12+
- Removed default max age from claims
13+
1014
## [13.1.0] - 2022-09-14
1115
### Added
1216

bundle/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/claims/primitiveArrayClaim.d.ts

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/claims/primitiveArrayClaim.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/claims/primitiveClaim.d.ts

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/claims/primitiveClaim.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ts/claims/primitiveArrayClaim.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export type PrimitiveArrayClaimConfig = {
99
export class PrimitiveArrayClaim<ValueType> {
1010
public readonly id: string;
1111
public readonly refresh: SessionClaimValidator["refresh"];
12-
public readonly defaultMaxAgeInSeconds: number;
12+
public readonly defaultMaxAgeInSeconds: number | undefined;
1313

1414
constructor(config: PrimitiveArrayClaimConfig) {
1515
this.id = config.id;
1616
this.refresh = config.refresh;
17-
this.defaultMaxAgeInSeconds = config.defaultMaxAgeInSeconds === undefined ? 300 : config.defaultMaxAgeInSeconds;
17+
this.defaultMaxAgeInSeconds = config.defaultMaxAgeInSeconds;
1818
}
1919

2020
getValueFromPayload(payload: any, _userContext?: any): ValueType[] {
@@ -28,7 +28,7 @@ export class PrimitiveArrayClaim<ValueType> {
2828
validators = {
2929
includes: (
3030
val: ValueType,
31-
maxAgeInSeconds: number = this.defaultMaxAgeInSeconds,
31+
maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds,
3232
id?: string
3333
): SessionClaimValidator => {
3434
return {
@@ -69,7 +69,7 @@ export class PrimitiveArrayClaim<ValueType> {
6969
},
7070
excludes: (
7171
val: ValueType,
72-
maxAgeInSeconds: number = this.defaultMaxAgeInSeconds,
72+
maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds,
7373
id?: string
7474
): SessionClaimValidator => {
7575
return {
@@ -114,7 +114,7 @@ export class PrimitiveArrayClaim<ValueType> {
114114
},
115115
includesAll: (
116116
val: ValueType[],
117-
maxAgeInSeconds: number = this.defaultMaxAgeInSeconds,
117+
maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds,
118118
id?: string
119119
): SessionClaimValidator => {
120120
return {
@@ -156,7 +156,7 @@ export class PrimitiveArrayClaim<ValueType> {
156156
},
157157
excludesAll: (
158158
val: ValueType[],
159-
maxAgeInSeconds: number = this.defaultMaxAgeInSeconds,
159+
maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds,
160160
id?: string
161161
): SessionClaimValidator => {
162162
return {

lib/ts/claims/primitiveClaim.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export type PrimitiveClaimConfig = {
99
export class PrimitiveClaim<ValueType> {
1010
public readonly id: string;
1111
public readonly refresh: SessionClaimValidator["refresh"];
12-
public readonly defaultMaxAgeInSeconds: number;
12+
public readonly defaultMaxAgeInSeconds: number | undefined;
1313

1414
constructor(config: PrimitiveClaimConfig) {
1515
this.id = config.id;
1616
this.refresh = config.refresh;
17-
this.defaultMaxAgeInSeconds = config.defaultMaxAgeInSeconds === undefined ? 300 : config.defaultMaxAgeInSeconds;
17+
this.defaultMaxAgeInSeconds = config.defaultMaxAgeInSeconds;
1818
}
1919

2020
getValueFromPayload(payload: any, _userContext?: any): ValueType {
@@ -28,7 +28,7 @@ export class PrimitiveClaim<ValueType> {
2828
validators = {
2929
hasValue: (
3030
val: ValueType,
31-
maxAgeInSeconds: number = this.defaultMaxAgeInSeconds,
31+
maxAgeInSeconds: number | undefined = this.defaultMaxAgeInSeconds,
3232
id?: string
3333
): SessionClaimValidator => {
3434
return {
@@ -37,7 +37,7 @@ export class PrimitiveClaim<ValueType> {
3737
shouldRefresh: (payload, ctx) =>
3838
this.getValueFromPayload(payload, ctx) === undefined ||
3939
// We know payload[this.id] is defined since the value is not undefined in this branch
40-
payload[this.id].t < Date.now() - maxAgeInSeconds * 1000,
40+
(maxAgeInSeconds !== undefined && payload[this.id].t < Date.now() - maxAgeInSeconds * 1000),
4141
validate: (payload, ctx) => {
4242
const claimVal = this.getValueFromPayload(payload, ctx);
4343
if (claimVal === undefined) {

0 commit comments

Comments
 (0)