Skip to content

Commit ffe0553

Browse files
chore(auth0-server-js): Remove obsolete MissingStoreOptionsError
1 parent c21beee commit ffe0553

4 files changed

Lines changed: 2 additions & 47 deletions

File tree

packages/auth0-server-js/src/errors.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,4 @@ export class MissingSessionError extends Error {
5757
super(message);
5858
this.name = 'MissingSessionError';
5959
}
60-
}
61-
62-
/**
63-
* Error thrown when the store options are missing.
64-
*/
65-
export class MissingStoreOptionsError extends Error {
66-
public code: string = 'missing_store_options_error';
67-
68-
constructor(message?: string) {
69-
super(message ?? 'The store options are missing, making it impossible to interact with the store.');
70-
this.name = 'MissingStoreOptionsError';
71-
}
7260
}
Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { MissingStoreOptionsError } from './../errors.js';
21
import type { EncryptedStoreOptions, TransactionData } from './../types.js';
32
import { AbstractTransactionStore } from './abstract-transaction-store.js';
43
import type { CookieHandler, CookieSerializeOptions } from './cookie-handler.js';
@@ -16,12 +15,7 @@ export class CookieTransactionStore<TStoreOptions> extends AbstractTransactionSt
1615
transactionData: TransactionData,
1716
removeIfExists?: boolean,
1817
options?: TStoreOptions
19-
): Promise<void> {
20-
// We can not handle cookies when the `StoreOptions` are not provided.
21-
if (!options) {
22-
throw new MissingStoreOptionsError();
23-
}
24-
18+
): Promise<void> {
2519
const maxAge = 60 * 60;
2620
const cookieOpts: CookieSerializeOptions = { httpOnly: true, sameSite: 'lax', path: '/', maxAge };
2721
const expiration = Math.floor(Date.now() / 1000 + maxAge);
@@ -31,11 +25,6 @@ export class CookieTransactionStore<TStoreOptions> extends AbstractTransactionSt
3125
}
3226

3327
async get(identifier: string, options?: TStoreOptions): Promise<TransactionData | undefined> {
34-
// We can not handle cookies when the `StoreOptions` are not provided.
35-
if (!options) {
36-
throw new MissingStoreOptionsError();
37-
}
38-
3928
const cookieValue = this.#cookieHandler.getCookie(identifier, options);
4029

4130
if (cookieValue) {
@@ -44,11 +33,6 @@ export class CookieTransactionStore<TStoreOptions> extends AbstractTransactionSt
4433
}
4534

4635
async delete(identifier: string, options?: TStoreOptions | undefined): Promise<void> {
47-
// We can not handle cookies when the `StoreOptions` are not provided.
48-
if (!options) {
49-
throw new MissingStoreOptionsError();
50-
}
51-
5236
this.#cookieHandler.deleteCookie(identifier, options);
5337
}
5438
}

packages/auth0-server-js/src/store/stateful-state-store.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { MissingStoreOptionsError } from '../errors.js';
21
import type {
32
EncryptedStoreOptions,
43
LogoutTokenClaims,
@@ -44,11 +43,6 @@ export class StatefulStateStore<TStoreOptions> extends AbstractSessionStore<TSto
4443
removeIfExists?: boolean,
4544
options?: TStoreOptions | undefined
4645
): Promise<void> {
47-
// We can not handle cookies when the `StoreOptions` are not provided.
48-
if (!options) {
49-
throw new MissingStoreOptionsError();
50-
}
51-
5246
let sessionId = await this.getSessionId(identifier, options);
5347

5448
// if this is a new session created by a new login we need to remove the old session
@@ -83,11 +77,6 @@ export class StatefulStateStore<TStoreOptions> extends AbstractSessionStore<TSto
8377
}
8478

8579
async get(identifier: string, options?: TStoreOptions | undefined): Promise<StateData | undefined> {
86-
// We can not handle cookies when the `StoreOptions` are not provided.
87-
if (!options) {
88-
throw new MissingStoreOptionsError();
89-
}
90-
9180
const sessionId = await this.getSessionId(identifier, options);
9281

9382
if (sessionId) {
@@ -103,11 +92,6 @@ export class StatefulStateStore<TStoreOptions> extends AbstractSessionStore<TSto
10392
}
10493

10594
async delete(identifier: string, options?: TStoreOptions | undefined): Promise<void> {
106-
// We can not handle cookies when the `StoreOptions` are not provided.
107-
if (!options) {
108-
throw new MissingStoreOptionsError();
109-
}
110-
11195
const sessionId = await this.getSessionId(identifier, options);
11296

11397
if (sessionId) {
@@ -117,7 +101,7 @@ export class StatefulStateStore<TStoreOptions> extends AbstractSessionStore<TSto
117101
this.#cookieHandler.deleteCookie(identifier, options);
118102
}
119103

120-
private async getSessionId(identifier: string, options: TStoreOptions) {
104+
private async getSessionId(identifier: string, options?: TStoreOptions) {
121105
const cookieValue = this.#cookieHandler.getCookie(identifier, options);
122106
if (cookieValue) {
123107
const sessionCookie = await this.decrypt<{ id: string }>(identifier, cookieValue);

packages/auth0-server-js/src/store/stateless-state-store.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { MissingStoreOptionsError } from 'src/errors.js';
21
import type { EncryptedStoreOptions, StateData } from './../types.js';
32
import { AbstractSessionStore } from './abstract-session-store.js';
43
import type { CookieHandler, CookieSerializeOptions } from './cookie-handler.js';

0 commit comments

Comments
 (0)