@logto/remix 1.1.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/framework/{get-cookie-header-from-request.mjs → get-cookie-header-from-request.cjs} +3 -1
- package/lib/framework/get-cookie-header-from-request.js +1 -3
- package/lib/framework/mocks.d.ts +2 -2
- package/lib/index.cjs +24 -0
- package/lib/index.js +7 -9
- package/lib/infrastructure/logto/create-client.cjs +17 -0
- package/lib/infrastructure/logto/create-client.d.ts +1 -1
- package/lib/infrastructure/logto/create-client.js +3 -9
- package/lib/infrastructure/logto/{create-storage.mjs → create-storage.cjs} +3 -1
- package/lib/infrastructure/logto/create-storage.js +1 -3
- package/lib/infrastructure/logto/{get-context.mjs → get-context.cjs} +3 -1
- package/lib/infrastructure/logto/get-context.d.ts +2 -2
- package/lib/infrastructure/logto/get-context.js +1 -3
- package/lib/infrastructure/logto/{handle-sign-in-callback.mjs → handle-sign-in-callback.cjs} +3 -1
- package/lib/infrastructure/logto/handle-sign-in-callback.d.ts +2 -2
- package/lib/infrastructure/logto/handle-sign-in-callback.js +1 -3
- package/lib/infrastructure/logto/{handle-sign-in.mjs → handle-sign-in.cjs} +3 -1
- package/lib/infrastructure/logto/handle-sign-in.d.ts +2 -2
- package/lib/infrastructure/logto/handle-sign-in.js +1 -3
- package/lib/infrastructure/logto/{handle-sign-out.mjs → handle-sign-out.cjs} +3 -1
- package/lib/infrastructure/logto/handle-sign-out.d.ts +1 -1
- package/lib/infrastructure/logto/handle-sign-out.js +1 -3
- package/lib/infrastructure/logto/index.cjs +21 -0
- package/lib/infrastructure/logto/index.js +13 -15
- package/lib/useCases/getContext/{GetContextController.mjs → GetContextController.cjs} +5 -3
- package/lib/useCases/getContext/GetContextController.d.ts +1 -1
- package/lib/useCases/getContext/GetContextController.js +3 -5
- package/lib/useCases/getContext/{GetContextUseCase.mjs → GetContextUseCase.cjs} +3 -1
- package/lib/useCases/getContext/GetContextUseCase.d.ts +1 -1
- package/lib/useCases/getContext/GetContextUseCase.js +1 -3
- package/lib/useCases/getContext/index.cjs +19 -0
- package/lib/useCases/getContext/index.d.ts +1 -1
- package/lib/useCases/getContext/index.js +5 -7
- package/lib/useCases/handleAuthRoutes/{HandleAuthRoutesError.mjs → HandleAuthRoutesError.cjs} +3 -1
- package/lib/useCases/handleAuthRoutes/HandleAuthRoutesError.js +1 -3
- package/lib/useCases/handleAuthRoutes/{index.mjs → index.cjs} +12 -10
- package/lib/useCases/handleAuthRoutes/index.d.ts +1 -1
- package/lib/useCases/handleAuthRoutes/index.js +10 -12
- package/lib/useCases/handleSignIn/{HandleSignInController.mjs → HandleSignInController.cjs} +7 -5
- package/lib/useCases/handleSignIn/HandleSignInController.d.ts +1 -1
- package/lib/useCases/handleSignIn/HandleSignInController.js +5 -7
- package/lib/useCases/handleSignIn/{HandleSignInUseCase.mjs → HandleSignInUseCase.cjs} +3 -1
- package/lib/useCases/handleSignIn/HandleSignInUseCase.d.ts +1 -1
- package/lib/useCases/handleSignIn/HandleSignInUseCase.js +1 -3
- package/lib/useCases/handleSignIn/index.cjs +19 -0
- package/lib/useCases/handleSignIn/index.d.ts +1 -1
- package/lib/useCases/handleSignIn/index.js +5 -7
- package/lib/useCases/handleSignInCallback/{HandleSignInCallbackController.mjs → HandleSignInCallbackController.cjs} +9 -7
- package/lib/useCases/handleSignInCallback/HandleSignInCallbackController.d.ts +1 -1
- package/lib/useCases/handleSignInCallback/HandleSignInCallbackController.js +7 -9
- package/lib/useCases/handleSignInCallback/{HandleSignInCallbackError.mjs → HandleSignInCallbackError.cjs} +3 -1
- package/lib/useCases/handleSignInCallback/HandleSignInCallbackError.js +1 -3
- package/lib/useCases/handleSignInCallback/{HandleSignInCallbackUseCase.mjs → HandleSignInCallbackUseCase.cjs} +3 -1
- package/lib/useCases/handleSignInCallback/HandleSignInCallbackUseCase.d.ts +1 -1
- package/lib/useCases/handleSignInCallback/HandleSignInCallbackUseCase.js +1 -3
- package/lib/useCases/handleSignInCallback/index.cjs +19 -0
- package/lib/useCases/handleSignInCallback/index.d.ts +1 -1
- package/lib/useCases/handleSignInCallback/index.js +5 -7
- package/lib/useCases/handleSignOut/{HandleSignOutController.mjs → HandleSignOutController.cjs} +9 -7
- package/lib/useCases/handleSignOut/HandleSignOutController.d.ts +1 -1
- package/lib/useCases/handleSignOut/HandleSignOutController.js +7 -9
- package/lib/useCases/handleSignOut/{HandleSignOutError.mjs → HandleSignOutError.cjs} +3 -1
- package/lib/useCases/handleSignOut/HandleSignOutError.js +1 -3
- package/lib/useCases/handleSignOut/{HandleSignOutUseCase.mjs → HandleSignOutUseCase.cjs} +3 -1
- package/lib/useCases/handleSignOut/HandleSignOutUseCase.d.ts +1 -1
- package/lib/useCases/handleSignOut/HandleSignOutUseCase.js +1 -3
- package/lib/useCases/handleSignOut/index.cjs +19 -0
- package/lib/useCases/handleSignOut/index.d.ts +1 -1
- package/lib/useCases/handleSignOut/index.js +5 -7
- package/package.json +23 -24
- package/lib/index.mjs +0 -22
- package/lib/infrastructure/logto/create-client.mjs +0 -11
- package/lib/infrastructure/logto/index.mjs +0 -19
- package/lib/useCases/getContext/index.mjs +0 -17
- package/lib/useCases/handleSignIn/index.mjs +0 -17
- package/lib/useCases/handleSignInCallback/index.mjs +0 -17
- package/lib/useCases/handleSignOut/index.mjs +0 -17
package/lib/framework/mocks.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
2
|
import type { Session, SessionStorage } from '@remix-run/node';
|
|
3
|
-
import type { CreateLogtoAdapter, LogtoContext } from '../infrastructure/logto';
|
|
3
|
+
import type { CreateLogtoAdapter, LogtoContext } from '../infrastructure/logto/index.js';
|
|
4
4
|
export declare const getContext: jest.Mock<Promise<{
|
|
5
5
|
context: LogtoContext;
|
|
6
6
|
}>, []>;
|
|
7
|
-
export declare const storage: import("../infrastructure/logto/create-storage").LogtoStorage;
|
|
7
|
+
export declare const storage: import("../infrastructure/logto/create-storage.js").LogtoStorage;
|
|
8
8
|
export declare const handleSignIn: jest.Mock<Promise<{
|
|
9
9
|
session: Session;
|
|
10
10
|
navigateToUrl: string;
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index$2 = require('./infrastructure/logto/index.cjs');
|
|
4
|
+
var index$1 = require('./useCases/getContext/index.cjs');
|
|
5
|
+
var index = require('./useCases/handleAuthRoutes/index.cjs');
|
|
6
|
+
|
|
7
|
+
const makeLogtoRemix = (config, deps) => {
|
|
8
|
+
const { sessionStorage } = deps;
|
|
9
|
+
const { baseUrl } = config;
|
|
10
|
+
const createLogtoAdapter = index$2.makeLogtoAdapter(config);
|
|
11
|
+
return Object.freeze({
|
|
12
|
+
handleAuthRoutes: index.makeHandleAuthRoutes({
|
|
13
|
+
baseUrl,
|
|
14
|
+
createLogtoAdapter,
|
|
15
|
+
sessionStorage,
|
|
16
|
+
}),
|
|
17
|
+
getContext: (dto) => index$1.makeGetContext(dto, {
|
|
18
|
+
createLogtoAdapter,
|
|
19
|
+
sessionStorage,
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.makeLogtoRemix = makeLogtoRemix;
|
package/lib/index.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var index$1 = require('./useCases/getContext/index.js');
|
|
5
|
-
var index = require('./useCases/handleAuthRoutes/index.js');
|
|
1
|
+
import { makeLogtoAdapter } from './infrastructure/logto/index.js';
|
|
2
|
+
import { makeGetContext } from './useCases/getContext/index.js';
|
|
3
|
+
import { makeHandleAuthRoutes } from './useCases/handleAuthRoutes/index.js';
|
|
6
4
|
|
|
7
5
|
const makeLogtoRemix = (config, deps) => {
|
|
8
6
|
const { sessionStorage } = deps;
|
|
9
7
|
const { baseUrl } = config;
|
|
10
|
-
const createLogtoAdapter =
|
|
8
|
+
const createLogtoAdapter = makeLogtoAdapter(config);
|
|
11
9
|
return Object.freeze({
|
|
12
|
-
handleAuthRoutes:
|
|
10
|
+
handleAuthRoutes: makeHandleAuthRoutes({
|
|
13
11
|
baseUrl,
|
|
14
12
|
createLogtoAdapter,
|
|
15
13
|
sessionStorage,
|
|
16
14
|
}),
|
|
17
|
-
getContext: (dto) =>
|
|
15
|
+
getContext: (dto) => makeGetContext(dto, {
|
|
18
16
|
createLogtoAdapter,
|
|
19
17
|
sessionStorage,
|
|
20
18
|
}),
|
|
21
19
|
});
|
|
22
20
|
};
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
export { makeLogtoRemix };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var LogtoClient = require('@logto/node');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var LogtoClient__default = /*#__PURE__*/_interopDefault(LogtoClient);
|
|
8
|
+
|
|
9
|
+
const makeLogtoClient = (config, storage) =>
|
|
10
|
+
// Have to deactivate the eslint rule here as the `LogtoClient`
|
|
11
|
+
// awaits a `navigate` function.
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
13
|
+
(navigate = () => { }) => {
|
|
14
|
+
return new LogtoClient__default.default(config, { storage, navigate });
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.makeLogtoClient = makeLogtoClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LogtoConfig } from '@logto/node';
|
|
2
2
|
import LogtoClient from '@logto/node';
|
|
3
|
-
import type { LogtoStorage } from './create-storage';
|
|
3
|
+
import type { LogtoStorage } from './create-storage.js';
|
|
4
4
|
export declare const makeLogtoClient: (config: LogtoConfig, storage: LogtoStorage) => (navigate?: (url: string) => void) => LogtoClient;
|
|
5
5
|
export type CreateLogtoClient = ReturnType<typeof makeLogtoClient>;
|
|
6
6
|
export { type LogtoConfig } from '@logto/node';
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var LogtoClient = require('@logto/node');
|
|
4
|
-
|
|
5
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
-
|
|
7
|
-
var LogtoClient__default = /*#__PURE__*/_interopDefault(LogtoClient);
|
|
1
|
+
import LogtoClient from '@logto/node';
|
|
8
2
|
|
|
9
3
|
const makeLogtoClient = (config, storage) =>
|
|
10
4
|
// Have to deactivate the eslint rule here as the `LogtoClient`
|
|
11
5
|
// awaits a `navigate` function.
|
|
12
6
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
13
7
|
(navigate = () => { }) => {
|
|
14
|
-
return new
|
|
8
|
+
return new LogtoClient(config, { storage, navigate });
|
|
15
9
|
};
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
export { makeLogtoClient };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
class LogtoStorage {
|
|
2
4
|
static { this.fromSession = (session) => {
|
|
3
5
|
return new LogtoStorage({ session });
|
|
@@ -25,4 +27,4 @@ class LogtoStorage {
|
|
|
25
27
|
}
|
|
26
28
|
const createStorage = (session) => LogtoStorage.fromSession(session);
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
exports.createStorage = createStorage;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
class LogtoStorage {
|
|
4
2
|
static { this.fromSession = (session) => {
|
|
5
3
|
return new LogtoStorage({ session });
|
|
@@ -27,4 +25,4 @@ class LogtoStorage {
|
|
|
27
25
|
}
|
|
28
26
|
const createStorage = (session) => LogtoStorage.fromSession(session);
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
export { createStorage };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
const makeGetContext = (deps) => async (request) => {
|
|
2
4
|
const { storage, createClient } = deps;
|
|
3
5
|
const client = createClient();
|
|
@@ -7,4 +9,4 @@ const makeGetContext = (deps) => async (request) => {
|
|
|
7
9
|
};
|
|
8
10
|
};
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
exports.makeGetContext = makeGetContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GetContextParameters, LogtoContext } from '@logto/node';
|
|
2
|
-
import type { CreateLogtoClient } from './create-client';
|
|
3
|
-
import type { LogtoStorage } from './create-storage';
|
|
2
|
+
import type { CreateLogtoClient } from './create-client.js';
|
|
3
|
+
import type { LogtoStorage } from './create-storage.js';
|
|
4
4
|
type GetContextResponse = {
|
|
5
5
|
readonly context: LogtoContext;
|
|
6
6
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const makeGetContext = (deps) => async (request) => {
|
|
4
2
|
const { storage, createClient } = deps;
|
|
5
3
|
const client = createClient();
|
|
@@ -9,4 +7,4 @@ const makeGetContext = (deps) => async (request) => {
|
|
|
9
7
|
};
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
export { makeGetContext };
|
package/lib/infrastructure/logto/{handle-sign-in-callback.mjs → handle-sign-in-callback.cjs}
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
const makeHandleSignInCallback = (deps) => async (request) => {
|
|
2
4
|
const { storage, createClient } = deps;
|
|
3
5
|
const client = createClient();
|
|
@@ -7,4 +9,4 @@ const makeHandleSignInCallback = (deps) => async (request) => {
|
|
|
7
9
|
};
|
|
8
10
|
};
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
exports.makeHandleSignInCallback = makeHandleSignInCallback;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Session } from '@remix-run/node';
|
|
2
|
-
import type { CreateLogtoClient } from './create-client';
|
|
3
|
-
import type { LogtoStorage } from './create-storage';
|
|
2
|
+
import type { CreateLogtoClient } from './create-client.js';
|
|
3
|
+
import type { LogtoStorage } from './create-storage.js';
|
|
4
4
|
type HandleSignInCallbackRequest = {
|
|
5
5
|
callbackUri: string;
|
|
6
6
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const makeHandleSignInCallback = (deps) => async (request) => {
|
|
4
2
|
const { storage, createClient } = deps;
|
|
5
3
|
const client = createClient();
|
|
@@ -9,4 +7,4 @@ const makeHandleSignInCallback = (deps) => async (request) => {
|
|
|
9
7
|
};
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
export { makeHandleSignInCallback };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
class HandleSignInCommand {
|
|
2
4
|
static { this.fromDependencies = (dependencies) => new HandleSignInCommand({ createClient: dependencies.createClient }); }
|
|
3
5
|
constructor(properties) {
|
|
@@ -25,4 +27,4 @@ const makeHandleSignIn = (deps) => async (request) => {
|
|
|
25
27
|
};
|
|
26
28
|
};
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
exports.makeHandleSignIn = makeHandleSignIn;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Session } from '@remix-run/node';
|
|
2
|
-
import type { CreateLogtoClient } from './create-client';
|
|
3
|
-
import type { LogtoStorage } from './create-storage';
|
|
2
|
+
import type { CreateLogtoClient } from './create-client.js';
|
|
3
|
+
import type { LogtoStorage } from './create-storage.js';
|
|
4
4
|
type HandleSignInRequest = {
|
|
5
5
|
readonly redirectUri: string;
|
|
6
6
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
class HandleSignInCommand {
|
|
4
2
|
static { this.fromDependencies = (dependencies) => new HandleSignInCommand({ createClient: dependencies.createClient }); }
|
|
5
3
|
constructor(properties) {
|
|
@@ -27,4 +25,4 @@ const makeHandleSignIn = (deps) => async (request) => {
|
|
|
27
25
|
};
|
|
28
26
|
};
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
export { makeHandleSignIn };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
class HandleSignOutCommand {
|
|
2
4
|
static { this.fromDependencies = (dependencies) => new HandleSignOutCommand({ createClient: dependencies.createClient }); }
|
|
3
5
|
constructor(properties) {
|
|
@@ -21,4 +23,4 @@ const makeHandleSignOut = (deps) => async (request) => {
|
|
|
21
23
|
return command.execute(request);
|
|
22
24
|
};
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
exports.makeHandleSignOut = makeHandleSignOut;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
class HandleSignOutCommand {
|
|
4
2
|
static { this.fromDependencies = (dependencies) => new HandleSignOutCommand({ createClient: dependencies.createClient }); }
|
|
5
3
|
constructor(properties) {
|
|
@@ -23,4 +21,4 @@ const makeHandleSignOut = (deps) => async (request) => {
|
|
|
23
21
|
return command.execute(request);
|
|
24
22
|
};
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
export { makeHandleSignOut };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createClient = require('./create-client.cjs');
|
|
4
|
+
var createStorage = require('./create-storage.cjs');
|
|
5
|
+
var getContext = require('./get-context.cjs');
|
|
6
|
+
var handleSignInCallback = require('./handle-sign-in-callback.cjs');
|
|
7
|
+
var handleSignIn = require('./handle-sign-in.cjs');
|
|
8
|
+
var handleSignOut = require('./handle-sign-out.cjs');
|
|
9
|
+
|
|
10
|
+
const makeLogtoAdapter = (config) => (session) => {
|
|
11
|
+
const storage = createStorage.createStorage(session);
|
|
12
|
+
const createClient$1 = createClient.makeLogtoClient(config, storage);
|
|
13
|
+
return {
|
|
14
|
+
handleSignIn: handleSignIn.makeHandleSignIn({ storage, createClient: createClient$1 }),
|
|
15
|
+
handleSignInCallback: handleSignInCallback.makeHandleSignInCallback({ storage, createClient: createClient$1 }),
|
|
16
|
+
handleSignOut: handleSignOut.makeHandleSignOut({ createClient: createClient$1 }),
|
|
17
|
+
getContext: getContext.makeGetContext({ storage, createClient: createClient$1 }),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.makeLogtoAdapter = makeLogtoAdapter;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var handleSignInCallback = require('./handle-sign-in-callback.js');
|
|
8
|
-
var handleSignOut = require('./handle-sign-out.js');
|
|
1
|
+
import { makeLogtoClient } from './create-client.js';
|
|
2
|
+
import { createStorage } from './create-storage.js';
|
|
3
|
+
import { makeGetContext } from './get-context.js';
|
|
4
|
+
import { makeHandleSignInCallback } from './handle-sign-in-callback.js';
|
|
5
|
+
import { makeHandleSignIn } from './handle-sign-in.js';
|
|
6
|
+
import { makeHandleSignOut } from './handle-sign-out.js';
|
|
9
7
|
|
|
10
8
|
const makeLogtoAdapter = (config) => (session) => {
|
|
11
|
-
const storage = createStorage
|
|
12
|
-
const createClient
|
|
9
|
+
const storage = createStorage(session);
|
|
10
|
+
const createClient = makeLogtoClient(config, storage);
|
|
13
11
|
return {
|
|
14
|
-
handleSignIn:
|
|
15
|
-
handleSignInCallback:
|
|
16
|
-
handleSignOut:
|
|
17
|
-
getContext:
|
|
12
|
+
handleSignIn: makeHandleSignIn({ storage, createClient }),
|
|
13
|
+
handleSignInCallback: makeHandleSignInCallback({ storage, createClient }),
|
|
14
|
+
handleSignOut: makeHandleSignOut({ createClient }),
|
|
15
|
+
getContext: makeGetContext({ storage, createClient }),
|
|
18
16
|
};
|
|
19
17
|
};
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
export { makeLogtoAdapter };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var getCookieHeaderFromRequest = require('../../framework/get-cookie-header-from-request.cjs');
|
|
2
4
|
|
|
3
5
|
class GetContextController {
|
|
4
6
|
static { this.fromDto = (dto) => new GetContextController(dto); }
|
|
@@ -6,7 +8,7 @@ class GetContextController {
|
|
|
6
8
|
this.properties = properties;
|
|
7
9
|
this.useCase = this.properties.useCase;
|
|
8
10
|
this.execute = async (request) => {
|
|
9
|
-
const cookieHeader = getCookieHeaderFromRequest(request);
|
|
11
|
+
const cookieHeader = getCookieHeaderFromRequest.getCookieHeaderFromRequest(request);
|
|
10
12
|
const result = await this.useCase({
|
|
11
13
|
cookieHeader: cookieHeader ?? undefined,
|
|
12
14
|
...this.properties,
|
|
@@ -16,4 +18,4 @@ class GetContextController {
|
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
exports.GetContextController = GetContextController;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GetContextParameters, LogtoContext } from '@logto/node';
|
|
2
|
-
import type { GetContextUseCase } from './GetContextUseCase';
|
|
2
|
+
import type { GetContextUseCase } from './GetContextUseCase.js';
|
|
3
3
|
type GetContextControllerDto = GetContextParameters & {
|
|
4
4
|
readonly useCase: GetContextUseCase;
|
|
5
5
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var getCookieHeaderFromRequest = require('../../framework/get-cookie-header-from-request.js');
|
|
1
|
+
import { getCookieHeaderFromRequest } from '../../framework/get-cookie-header-from-request.js';
|
|
4
2
|
|
|
5
3
|
class GetContextController {
|
|
6
4
|
static { this.fromDto = (dto) => new GetContextController(dto); }
|
|
@@ -8,7 +6,7 @@ class GetContextController {
|
|
|
8
6
|
this.properties = properties;
|
|
9
7
|
this.useCase = this.properties.useCase;
|
|
10
8
|
this.execute = async (request) => {
|
|
11
|
-
const cookieHeader = getCookieHeaderFromRequest
|
|
9
|
+
const cookieHeader = getCookieHeaderFromRequest(request);
|
|
12
10
|
const result = await this.useCase({
|
|
13
11
|
cookieHeader: cookieHeader ?? undefined,
|
|
14
12
|
...this.properties,
|
|
@@ -18,4 +16,4 @@ class GetContextController {
|
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
export { GetContextController };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
const makeGetContextUseCase = (deps) => async (request) => {
|
|
2
4
|
const { sessionStorage, createLogtoAdapter } = deps;
|
|
3
5
|
const session = await sessionStorage.getSession(request.cookieHeader);
|
|
@@ -8,4 +10,4 @@ const makeGetContextUseCase = (deps) => async (request) => {
|
|
|
8
10
|
};
|
|
9
11
|
};
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
exports.makeGetContextUseCase = makeGetContextUseCase;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GetContextParameters } from '@logto/node';
|
|
2
2
|
import type { SessionStorage } from '@remix-run/node';
|
|
3
|
-
import type { CreateLogtoAdapter, LogtoContext } from '../../infrastructure/logto';
|
|
3
|
+
import type { CreateLogtoAdapter, LogtoContext } from '../../infrastructure/logto/index.js';
|
|
4
4
|
type GetContextRequest = GetContextParameters & {
|
|
5
5
|
readonly cookieHeader: string | undefined;
|
|
6
6
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
const makeGetContextUseCase = (deps) => async (request) => {
|
|
4
2
|
const { sessionStorage, createLogtoAdapter } = deps;
|
|
5
3
|
const session = await sessionStorage.getSession(request.cookieHeader);
|
|
@@ -10,4 +8,4 @@ const makeGetContextUseCase = (deps) => async (request) => {
|
|
|
10
8
|
};
|
|
11
9
|
};
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
export { makeGetContextUseCase };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var GetContextController = require('./GetContextController.cjs');
|
|
4
|
+
var GetContextUseCase = require('./GetContextUseCase.cjs');
|
|
5
|
+
|
|
6
|
+
const makeGetContext = (dto, deps) => async (request) => {
|
|
7
|
+
const { createLogtoAdapter, sessionStorage } = deps;
|
|
8
|
+
const useCase = GetContextUseCase.makeGetContextUseCase({
|
|
9
|
+
createLogtoAdapter,
|
|
10
|
+
sessionStorage,
|
|
11
|
+
});
|
|
12
|
+
const controller = GetContextController.GetContextController.fromDto({
|
|
13
|
+
useCase,
|
|
14
|
+
...dto,
|
|
15
|
+
});
|
|
16
|
+
return controller.execute(request);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.makeGetContext = makeGetContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GetContextParameters } from '@logto/node';
|
|
2
2
|
import type { SessionStorage } from '@remix-run/node';
|
|
3
|
-
import type { CreateLogtoAdapter } from '../../infrastructure/logto';
|
|
3
|
+
import type { CreateLogtoAdapter } from '../../infrastructure/logto/index.js';
|
|
4
4
|
type HandleGetContextDeps = {
|
|
5
5
|
readonly createLogtoAdapter: CreateLogtoAdapter;
|
|
6
6
|
readonly sessionStorage: SessionStorage;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var GetContextController = require('./GetContextController.js');
|
|
4
|
-
var GetContextUseCase = require('./GetContextUseCase.js');
|
|
1
|
+
import { GetContextController } from './GetContextController.js';
|
|
2
|
+
import { makeGetContextUseCase } from './GetContextUseCase.js';
|
|
5
3
|
|
|
6
4
|
const makeGetContext = (dto, deps) => async (request) => {
|
|
7
5
|
const { createLogtoAdapter, sessionStorage } = deps;
|
|
8
|
-
const useCase =
|
|
6
|
+
const useCase = makeGetContextUseCase({
|
|
9
7
|
createLogtoAdapter,
|
|
10
8
|
sessionStorage,
|
|
11
9
|
});
|
|
12
|
-
const controller = GetContextController.
|
|
10
|
+
const controller = GetContextController.fromDto({
|
|
13
11
|
useCase,
|
|
14
12
|
...dto,
|
|
15
13
|
});
|
|
16
14
|
return controller.execute(request);
|
|
17
15
|
};
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
export { makeGetContext };
|
package/lib/useCases/handleAuthRoutes/{HandleAuthRoutesError.mjs → HandleAuthRoutesError.cjs}
RENAMED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
class HandleAuthRoutesError extends Error {
|
|
2
4
|
static { this.becauseNoConfigForPath = (anticipatedPath) => new HandleAuthRoutesError({
|
|
3
5
|
code: 1_665_388_277,
|
|
@@ -16,4 +18,4 @@ class HandleAuthRoutesError extends Error {
|
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
exports.HandleAuthRoutesError = HandleAuthRoutesError;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
class HandleAuthRoutesError extends Error {
|
|
4
2
|
static { this.becauseNoConfigForPath = (anticipatedPath) => new HandleAuthRoutesError({
|
|
5
3
|
code: 1_665_388_277,
|
|
@@ -18,4 +16,4 @@ class HandleAuthRoutesError extends Error {
|
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
export { HandleAuthRoutesError };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index$2 = require('../handleSignIn/index.cjs');
|
|
4
|
+
var index$1 = require('../handleSignInCallback/index.cjs');
|
|
5
|
+
var index = require('../handleSignOut/index.cjs');
|
|
6
|
+
var HandleAuthRoutesError = require('./HandleAuthRoutesError.cjs');
|
|
5
7
|
|
|
6
8
|
const makeHandleAuthRoutes = (deps) => (dto) => async ({ request }) => {
|
|
7
9
|
const anticipatedPath = new URL(request.url).pathname;
|
|
@@ -10,33 +12,33 @@ const makeHandleAuthRoutes = (deps) => (dto) => async ({ request }) => {
|
|
|
10
12
|
const configExists = Boolean(configKey);
|
|
11
13
|
/* eslint-enable no-restricted-syntax */
|
|
12
14
|
if (!configExists) {
|
|
13
|
-
throw HandleAuthRoutesError.becauseNoConfigForPath(anticipatedPath);
|
|
15
|
+
throw HandleAuthRoutesError.HandleAuthRoutesError.becauseNoConfigForPath(anticipatedPath);
|
|
14
16
|
}
|
|
15
17
|
const { sessionStorage, createLogtoAdapter, baseUrl } = deps;
|
|
16
18
|
const config = dto[configKey];
|
|
17
19
|
switch (configKey) {
|
|
18
20
|
case 'sign-in': {
|
|
19
|
-
const handler = makeHandleSignIn({
|
|
21
|
+
const handler = index$2.makeHandleSignIn({
|
|
20
22
|
redirectBackTo: `${baseUrl}${config.redirectBackTo}`,
|
|
21
23
|
}, { sessionStorage, createLogtoAdapter });
|
|
22
24
|
return handler(request);
|
|
23
25
|
}
|
|
24
26
|
case 'sign-in-callback': {
|
|
25
|
-
const handler = makeHandleSignInCallback({
|
|
27
|
+
const handler = index$1.makeHandleSignInCallback({
|
|
26
28
|
redirectBackTo: `${baseUrl}${config.redirectBackTo}`,
|
|
27
29
|
}, { sessionStorage, createLogtoAdapter });
|
|
28
30
|
return handler(request);
|
|
29
31
|
}
|
|
30
32
|
case 'sign-out': {
|
|
31
|
-
const handler = makeHandleSignOut({
|
|
33
|
+
const handler = index.makeHandleSignOut({
|
|
32
34
|
redirectBackTo: `${baseUrl}${config.redirectBackTo}`,
|
|
33
35
|
}, { sessionStorage, createLogtoAdapter });
|
|
34
36
|
return handler(request);
|
|
35
37
|
}
|
|
36
38
|
default: {
|
|
37
|
-
throw HandleAuthRoutesError.becauseOfUnknownRoute(configKey);
|
|
39
|
+
throw HandleAuthRoutesError.HandleAuthRoutesError.becauseOfUnknownRoute(configKey);
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
exports.makeHandleAuthRoutes = makeHandleAuthRoutes;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LoaderFunction, SessionStorage } from '@remix-run/node';
|
|
2
|
-
import type { CreateLogtoAdapter } from '../../infrastructure/logto';
|
|
2
|
+
import type { CreateLogtoAdapter } from '../../infrastructure/logto/index.js';
|
|
3
3
|
type AuthRouteConfig = {
|
|
4
4
|
readonly path: string;
|
|
5
5
|
readonly redirectBackTo: string;
|