@logto/remix 2.2.7 → 3.0.3
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/package.json +3 -5
- package/lib/framework/get-cookie-header-from-request.cjs +0 -5
- package/lib/index.cjs +0 -69
- package/lib/infrastructure/logto/create-client.cjs +0 -17
- package/lib/infrastructure/logto/create-storage.cjs +0 -30
- package/lib/infrastructure/logto/get-context.cjs +0 -12
- package/lib/infrastructure/logto/handle-sign-in-callback.cjs +0 -12
- package/lib/infrastructure/logto/handle-sign-in.cjs +0 -30
- package/lib/infrastructure/logto/handle-sign-out.cjs +0 -26
- package/lib/infrastructure/logto/handle-sign-up.cjs +0 -30
- package/lib/infrastructure/logto/index.cjs +0 -23
- package/lib/useCases/getContext/GetContextController.cjs +0 -21
- package/lib/useCases/getContext/GetContextUseCase.cjs +0 -13
- package/lib/useCases/getContext/index.cjs +0 -19
- package/lib/useCases/handleAuthRoutes/HandleAuthRoutesError.cjs +0 -21
- package/lib/useCases/handleAuthRoutes/index.cjs +0 -48
- package/lib/useCases/handleSignIn/HandleSignInController.cjs +0 -31
- package/lib/useCases/handleSignIn/HandleSignInUseCase.cjs +0 -17
- package/lib/useCases/handleSignIn/index.cjs +0 -19
- package/lib/useCases/handleSignInCallback/HandleSignInCallbackController.cjs +0 -42
- package/lib/useCases/handleSignInCallback/HandleSignInCallbackError.cjs +0 -17
- package/lib/useCases/handleSignInCallback/HandleSignInCallbackUseCase.cjs +0 -16
- package/lib/useCases/handleSignInCallback/index.cjs +0 -19
- package/lib/useCases/handleSignOut/HandleSignOutController.cjs +0 -34
- package/lib/useCases/handleSignOut/HandleSignOutError.cjs +0 -17
- package/lib/useCases/handleSignOut/HandleSignOutUseCase.cjs +0 -17
- package/lib/useCases/handleSignOut/index.cjs +0 -19
- package/lib/useCases/handleSignUp/HandleSignUpController.cjs +0 -31
- package/lib/useCases/handleSignUp/HandleSignUpUseCase.cjs +0 -17
- package/lib/useCases/handleSignUp/index.cjs +0 -19
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/remix",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "./lib/index.cjs",
|
|
6
5
|
"module": "./lib/index.js",
|
|
7
6
|
"types": "./lib/index.d.ts",
|
|
8
7
|
"exports": {
|
|
9
8
|
"types": "./lib/index.d.ts",
|
|
10
|
-
"require": "./lib/index.cjs",
|
|
11
9
|
"import": "./lib/index.js",
|
|
12
10
|
"default": "./lib/index.js"
|
|
13
11
|
},
|
|
@@ -21,13 +19,13 @@
|
|
|
21
19
|
"directory": "packages/remix"
|
|
22
20
|
},
|
|
23
21
|
"dependencies": {
|
|
24
|
-
"@logto/node": "^
|
|
22
|
+
"@logto/node": "^3.0.3"
|
|
25
23
|
},
|
|
26
24
|
"devDependencies": {
|
|
27
25
|
"@remix-run/node": "^2.0.0",
|
|
28
26
|
"@silverhand/eslint-config": "^6.0.1",
|
|
29
27
|
"@silverhand/ts-config": "^6.0.0",
|
|
30
|
-
"@types/node": "^
|
|
28
|
+
"@types/node": "^22.0.0",
|
|
31
29
|
"@vitest/coverage-v8": "^1.6.0",
|
|
32
30
|
"eslint": "^8.57.0",
|
|
33
31
|
"lint-staged": "^15.0.0",
|
package/lib/index.cjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
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
|
-
var LogtoClient = require('@logto/node');
|
|
7
|
-
|
|
8
|
-
const makeLogtoRemix = (config, deps) => {
|
|
9
|
-
const { sessionStorage } = deps;
|
|
10
|
-
const { baseUrl } = config;
|
|
11
|
-
const createLogtoAdapter = index$2.makeLogtoAdapter(config);
|
|
12
|
-
return Object.freeze({
|
|
13
|
-
handleAuthRoutes: index.makeHandleAuthRoutes({
|
|
14
|
-
baseUrl,
|
|
15
|
-
createLogtoAdapter,
|
|
16
|
-
sessionStorage,
|
|
17
|
-
}),
|
|
18
|
-
getContext: (dto) => index$1.makeGetContext(dto, {
|
|
19
|
-
createLogtoAdapter,
|
|
20
|
-
sessionStorage,
|
|
21
|
-
}),
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
Object.defineProperty(exports, "LogtoClientError", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return LogtoClient.LogtoClientError; }
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, "LogtoError", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () { return LogtoClient.LogtoError; }
|
|
32
|
-
});
|
|
33
|
-
Object.defineProperty(exports, "LogtoRequestError", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () { return LogtoClient.LogtoRequestError; }
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, "OidcError", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () { return LogtoClient.OidcError; }
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(exports, "PersistKey", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () { return LogtoClient.PersistKey; }
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(exports, "Prompt", {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () { return LogtoClient.Prompt; }
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(exports, "ReservedScope", {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () { return LogtoClient.ReservedScope; }
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(exports, "UserScope", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
get: function () { return LogtoClient.UserScope; }
|
|
56
|
-
});
|
|
57
|
-
Object.defineProperty(exports, "buildOrganizationUrn", {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: function () { return LogtoClient.buildOrganizationUrn; }
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(exports, "getOrganizationIdFromUrn", {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
get: function () { return LogtoClient.getOrganizationIdFromUrn; }
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(exports, "organizationUrnPrefix", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () { return LogtoClient.organizationUrnPrefix; }
|
|
68
|
-
});
|
|
69
|
-
exports.makeLogtoRemix = makeLogtoRemix;
|
|
@@ -1,17 +0,0 @@
|
|
|
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,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class LogtoStorage {
|
|
4
|
-
static { this.fromSession = (session) => {
|
|
5
|
-
return new LogtoStorage({ session });
|
|
6
|
-
}; }
|
|
7
|
-
constructor(properties) {
|
|
8
|
-
this.properties = properties;
|
|
9
|
-
this.session = this.properties.session;
|
|
10
|
-
this.setItem = async (key, value) => {
|
|
11
|
-
this.session.set(key, value);
|
|
12
|
-
};
|
|
13
|
-
this.getItem = async (key) => {
|
|
14
|
-
const itemExists = this.session.has(key);
|
|
15
|
-
if (!itemExists) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return String(this.session.get(key));
|
|
19
|
-
};
|
|
20
|
-
this.removeItem = async (key) => {
|
|
21
|
-
this.session.unset(key);
|
|
22
|
-
};
|
|
23
|
-
this.save = async () => {
|
|
24
|
-
// Not required as the persistence happens in the integration layer
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const createStorage = (session) => LogtoStorage.fromSession(session);
|
|
29
|
-
|
|
30
|
-
exports.createStorage = createStorage;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const makeGetContext = (deps) => async (request) => {
|
|
4
|
-
const { storage, createClient } = deps;
|
|
5
|
-
const client = createClient();
|
|
6
|
-
const context = await client.getContext(request);
|
|
7
|
-
return {
|
|
8
|
-
context,
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
exports.makeGetContext = makeGetContext;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const makeHandleSignInCallback = (deps) => async (request) => {
|
|
4
|
-
const { storage, createClient } = deps;
|
|
5
|
-
const client = createClient();
|
|
6
|
-
await client.handleSignInCallback(request.callbackUri);
|
|
7
|
-
return {
|
|
8
|
-
session: storage.session,
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
exports.makeHandleSignInCallback = makeHandleSignInCallback;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class HandleSignInCommand {
|
|
4
|
-
static { this.fromDependencies = (dependencies) => new HandleSignInCommand({ createClient: dependencies.createClient }); }
|
|
5
|
-
constructor(properties) {
|
|
6
|
-
this.properties = properties;
|
|
7
|
-
this.navigateToUrl = '/api/sign-in';
|
|
8
|
-
}
|
|
9
|
-
async execute(request) {
|
|
10
|
-
const { createClient } = this.properties;
|
|
11
|
-
const client = createClient((url) => {
|
|
12
|
-
this.navigateToUrl = url;
|
|
13
|
-
});
|
|
14
|
-
await client.signIn(request.redirectUri);
|
|
15
|
-
return {
|
|
16
|
-
navigateToUrl: this.navigateToUrl,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const makeHandleSignIn = (deps) => async (request) => {
|
|
21
|
-
const { storage, createClient } = deps;
|
|
22
|
-
const command = HandleSignInCommand.fromDependencies({ createClient });
|
|
23
|
-
const { navigateToUrl } = await command.execute(request);
|
|
24
|
-
return {
|
|
25
|
-
session: storage.session,
|
|
26
|
-
navigateToUrl,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.makeHandleSignIn = makeHandleSignIn;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class HandleSignOutCommand {
|
|
4
|
-
static { this.fromDependencies = (dependencies) => new HandleSignOutCommand({ createClient: dependencies.createClient }); }
|
|
5
|
-
constructor(properties) {
|
|
6
|
-
this.properties = properties;
|
|
7
|
-
this.navigateToUrl = '/api/sign-in';
|
|
8
|
-
}
|
|
9
|
-
async execute(request) {
|
|
10
|
-
const { createClient } = this.properties;
|
|
11
|
-
const client = createClient((url) => {
|
|
12
|
-
this.navigateToUrl = url;
|
|
13
|
-
});
|
|
14
|
-
await client.signOut(request.redirectUri);
|
|
15
|
-
return {
|
|
16
|
-
navigateToUrl: this.navigateToUrl,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const makeHandleSignOut = (deps) => async (request) => {
|
|
21
|
-
const { createClient } = deps;
|
|
22
|
-
const command = HandleSignOutCommand.fromDependencies({ createClient });
|
|
23
|
-
return command.execute(request);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.makeHandleSignOut = makeHandleSignOut;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class HandleSignUpCommand {
|
|
4
|
-
static { this.fromDependencies = (dependencies) => new HandleSignUpCommand({ createClient: dependencies.createClient }); }
|
|
5
|
-
constructor(properties) {
|
|
6
|
-
this.properties = properties;
|
|
7
|
-
this.navigateToUrl = '/api/sign-up';
|
|
8
|
-
}
|
|
9
|
-
async execute(request) {
|
|
10
|
-
const { createClient } = this.properties;
|
|
11
|
-
const client = createClient((url) => {
|
|
12
|
-
this.navigateToUrl = url;
|
|
13
|
-
});
|
|
14
|
-
await client.signIn({ redirectUri: request.redirectUri, interactionMode: 'signUp' });
|
|
15
|
-
return {
|
|
16
|
-
navigateToUrl: this.navigateToUrl,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const makeHandleSignUp = (deps) => async (request) => {
|
|
21
|
-
const { storage, createClient } = deps;
|
|
22
|
-
const command = HandleSignUpCommand.fromDependencies({ createClient });
|
|
23
|
-
const { navigateToUrl } = await command.execute(request);
|
|
24
|
-
return {
|
|
25
|
-
session: storage.session,
|
|
26
|
-
navigateToUrl,
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.makeHandleSignUp = makeHandleSignUp;
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
var handleSignUp = require('./handle-sign-up.cjs');
|
|
10
|
-
|
|
11
|
-
const makeLogtoAdapter = (config) => (session) => {
|
|
12
|
-
const storage = createStorage.createStorage(session);
|
|
13
|
-
const createClient$1 = createClient.makeLogtoClient(config, storage);
|
|
14
|
-
return {
|
|
15
|
-
handleSignIn: handleSignIn.makeHandleSignIn({ storage, createClient: createClient$1 }),
|
|
16
|
-
handleSignInCallback: handleSignInCallback.makeHandleSignInCallback({ storage, createClient: createClient$1 }),
|
|
17
|
-
handleSignOut: handleSignOut.makeHandleSignOut({ createClient: createClient$1 }),
|
|
18
|
-
handleSignUp: handleSignUp.makeHandleSignUp({ storage, createClient: createClient$1 }),
|
|
19
|
-
getContext: getContext.makeGetContext({ storage, createClient: createClient$1 }),
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.makeLogtoAdapter = makeLogtoAdapter;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var getCookieHeaderFromRequest = require('../../framework/get-cookie-header-from-request.cjs');
|
|
4
|
-
|
|
5
|
-
class GetContextController {
|
|
6
|
-
static { this.fromDto = (dto) => new GetContextController(dto); }
|
|
7
|
-
constructor(properties) {
|
|
8
|
-
this.properties = properties;
|
|
9
|
-
this.useCase = this.properties.useCase;
|
|
10
|
-
this.execute = async (request) => {
|
|
11
|
-
const cookieHeader = getCookieHeaderFromRequest.getCookieHeaderFromRequest(request);
|
|
12
|
-
const result = await this.useCase({
|
|
13
|
-
cookieHeader: cookieHeader ?? undefined,
|
|
14
|
-
...this.properties,
|
|
15
|
-
});
|
|
16
|
-
return result.context;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.GetContextController = GetContextController;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const makeGetContextUseCase = (deps) => async (request) => {
|
|
4
|
-
const { sessionStorage, createLogtoAdapter } = deps;
|
|
5
|
-
const session = await sessionStorage.getSession(request.cookieHeader);
|
|
6
|
-
const logto = createLogtoAdapter(session);
|
|
7
|
-
const response = await logto.getContext(request);
|
|
8
|
-
return {
|
|
9
|
-
context: response.context,
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.makeGetContextUseCase = makeGetContextUseCase;
|
|
@@ -1,19 +0,0 @@
|
|
|
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,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class HandleAuthRoutesError extends Error {
|
|
4
|
-
static { this.becauseNoConfigForPath = (anticipatedPath) => new HandleAuthRoutesError({
|
|
5
|
-
code: 1_665_388_277,
|
|
6
|
-
message: `No configuration available for path "${anticipatedPath}".`,
|
|
7
|
-
}); }
|
|
8
|
-
static { this.becauseOfUnknownRoute = (anticipatedConfigKey) => new HandleAuthRoutesError({
|
|
9
|
-
code: 1_665_388_278,
|
|
10
|
-
message: `The config key "${anticipatedConfigKey}" is invalid.`,
|
|
11
|
-
}); }
|
|
12
|
-
constructor(properties) {
|
|
13
|
-
super(`#[${properties.code}] ${properties.message}`);
|
|
14
|
-
this.properties = properties;
|
|
15
|
-
this.code = this.properties.code;
|
|
16
|
-
this.cause = this.properties.cause;
|
|
17
|
-
this.plainMessage = this.properties.message;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.HandleAuthRoutesError = HandleAuthRoutesError;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index$3 = require('../handleSignIn/index.cjs');
|
|
4
|
-
var index$2 = require('../handleSignInCallback/index.cjs');
|
|
5
|
-
var index = require('../handleSignOut/index.cjs');
|
|
6
|
-
var index$1 = require('../handleSignUp/index.cjs');
|
|
7
|
-
var HandleAuthRoutesError = require('./HandleAuthRoutesError.cjs');
|
|
8
|
-
|
|
9
|
-
const makeHandleAuthRoutes = (deps) => (dto) => async ({ request }) => {
|
|
10
|
-
const anticipatedPath = new URL(request.url).pathname;
|
|
11
|
-
/* eslint-disable no-restricted-syntax */
|
|
12
|
-
const configKey = Object.keys(dto).find((type) => dto[type].path === anticipatedPath);
|
|
13
|
-
const configExists = Boolean(configKey);
|
|
14
|
-
/* eslint-enable no-restricted-syntax */
|
|
15
|
-
if (!configExists) {
|
|
16
|
-
throw HandleAuthRoutesError.HandleAuthRoutesError.becauseNoConfigForPath(anticipatedPath);
|
|
17
|
-
}
|
|
18
|
-
const { sessionStorage, createLogtoAdapter, baseUrl } = deps;
|
|
19
|
-
const config = dto[configKey];
|
|
20
|
-
switch (configKey) {
|
|
21
|
-
case 'sign-in': {
|
|
22
|
-
const handler = index$3.makeHandleSignIn({
|
|
23
|
-
redirectBackTo: `${baseUrl}${config.redirectBackTo}`,
|
|
24
|
-
}, { sessionStorage, createLogtoAdapter });
|
|
25
|
-
return handler(request);
|
|
26
|
-
}
|
|
27
|
-
case 'sign-in-callback': {
|
|
28
|
-
const handler = index$2.makeHandleSignInCallback({
|
|
29
|
-
redirectBackTo: `${baseUrl}${config.redirectBackTo}`,
|
|
30
|
-
}, { sessionStorage, createLogtoAdapter });
|
|
31
|
-
return handler(request);
|
|
32
|
-
}
|
|
33
|
-
case 'sign-up': {
|
|
34
|
-
const handler = index$1.makeHandleSignUp({
|
|
35
|
-
redirectBackTo: `${baseUrl}${config.redirectBackTo}`,
|
|
36
|
-
}, { sessionStorage, createLogtoAdapter });
|
|
37
|
-
return handler(request);
|
|
38
|
-
}
|
|
39
|
-
case 'sign-out': {
|
|
40
|
-
const handler = index.makeHandleSignOut({
|
|
41
|
-
redirectBackTo: `${baseUrl}${config.redirectBackTo}`,
|
|
42
|
-
}, { sessionStorage, createLogtoAdapter });
|
|
43
|
-
return handler(request);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
exports.makeHandleAuthRoutes = makeHandleAuthRoutes;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var node = require('@remix-run/node');
|
|
4
|
-
var getCookieHeaderFromRequest = require('../../framework/get-cookie-header-from-request.cjs');
|
|
5
|
-
|
|
6
|
-
class HandleSignInController {
|
|
7
|
-
static { this.fromDto = (dto) => new HandleSignInController({
|
|
8
|
-
useCase: dto.useCase,
|
|
9
|
-
redirectUri: dto.redirectUri,
|
|
10
|
-
}); }
|
|
11
|
-
constructor(properties) {
|
|
12
|
-
this.properties = properties;
|
|
13
|
-
this.useCase = this.properties.useCase;
|
|
14
|
-
this.redirectUri = this.properties.redirectUri;
|
|
15
|
-
this.execute = async (request) => {
|
|
16
|
-
const cookieHeader = getCookieHeaderFromRequest.getCookieHeaderFromRequest(request);
|
|
17
|
-
const { redirectUri } = this;
|
|
18
|
-
const result = await this.useCase({
|
|
19
|
-
cookieHeader: cookieHeader ?? undefined,
|
|
20
|
-
redirectUri,
|
|
21
|
-
});
|
|
22
|
-
return node.redirect(result.navigateToUrl, {
|
|
23
|
-
headers: {
|
|
24
|
-
'Set-Cookie': result.cookieHeader,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.HandleSignInController = HandleSignInController;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const makeHandleSignInUseCase = (deps) => async (request) => {
|
|
4
|
-
const { sessionStorage, createLogtoAdapter } = deps;
|
|
5
|
-
const session = await sessionStorage.getSession(request.cookieHeader);
|
|
6
|
-
const logto = createLogtoAdapter(session);
|
|
7
|
-
const response = await logto.handleSignIn({
|
|
8
|
-
redirectUri: request.redirectUri,
|
|
9
|
-
});
|
|
10
|
-
const cookieHeader = await sessionStorage.commitSession(response.session);
|
|
11
|
-
return {
|
|
12
|
-
cookieHeader,
|
|
13
|
-
navigateToUrl: response.navigateToUrl,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
exports.makeHandleSignInUseCase = makeHandleSignInUseCase;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var HandleSignInController = require('./HandleSignInController.cjs');
|
|
4
|
-
var HandleSignInUseCase = require('./HandleSignInUseCase.cjs');
|
|
5
|
-
|
|
6
|
-
const makeHandleSignIn = (dto, deps) => async (request) => {
|
|
7
|
-
const { createLogtoAdapter, sessionStorage } = deps;
|
|
8
|
-
const useCase = HandleSignInUseCase.makeHandleSignInUseCase({
|
|
9
|
-
createLogtoAdapter,
|
|
10
|
-
sessionStorage,
|
|
11
|
-
});
|
|
12
|
-
const controller = HandleSignInController.HandleSignInController.fromDto({
|
|
13
|
-
useCase,
|
|
14
|
-
redirectUri: dto.redirectBackTo,
|
|
15
|
-
});
|
|
16
|
-
return controller.execute(request);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.makeHandleSignIn = makeHandleSignIn;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var node = require('@remix-run/node');
|
|
4
|
-
var getCookieHeaderFromRequest = require('../../framework/get-cookie-header-from-request.cjs');
|
|
5
|
-
var HandleSignInCallbackError = require('./HandleSignInCallbackError.cjs');
|
|
6
|
-
|
|
7
|
-
class HandleSignInCallbackController {
|
|
8
|
-
static { this.fromDto = (dto) => new HandleSignInCallbackController({
|
|
9
|
-
useCase: dto.useCase,
|
|
10
|
-
redirectUri: dto.redirectUri,
|
|
11
|
-
}); }
|
|
12
|
-
constructor(properties) {
|
|
13
|
-
this.properties = properties;
|
|
14
|
-
this.useCase = this.properties.useCase;
|
|
15
|
-
this.redirectUri = this.properties.redirectUri;
|
|
16
|
-
this.execute = async (request) => {
|
|
17
|
-
const cookieHeader = getCookieHeaderFromRequest.getCookieHeaderFromRequest(request);
|
|
18
|
-
if (!cookieHeader) {
|
|
19
|
-
throw HandleSignInCallbackError.HandleSignInCallbackError.becauseNoCookieHeaderPresent();
|
|
20
|
-
}
|
|
21
|
-
// In some scenarios, like performing the sign-in callback within a Gitpod
|
|
22
|
-
// environment, the load balancer rewrites the URL and uses `http` as the
|
|
23
|
-
// protocol. Here, we make sure that when the `x-forwarded-proto` HTTP header
|
|
24
|
-
// is present, we will replace `http` with `https` in the `callbackUri`.
|
|
25
|
-
const isForwardedHttpsTraffic = request.headers.get('x-forwarded-proto') === 'https';
|
|
26
|
-
const callbackUri = isForwardedHttpsTraffic
|
|
27
|
-
? request.url.replace('http', 'https')
|
|
28
|
-
: request.url;
|
|
29
|
-
const result = await this.useCase({
|
|
30
|
-
cookieHeader,
|
|
31
|
-
callbackUri,
|
|
32
|
-
});
|
|
33
|
-
return node.redirect(this.redirectUri, {
|
|
34
|
-
headers: {
|
|
35
|
-
'Set-Cookie': result.cookieHeader,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
exports.HandleSignInCallbackController = HandleSignInCallbackController;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class HandleSignInCallbackError extends Error {
|
|
4
|
-
static { this.becauseNoCookieHeaderPresent = () => new HandleSignInCallbackError({
|
|
5
|
-
code: 1_665_388_541,
|
|
6
|
-
message: `The authentication sign-in callback route can't be accessed without a valid cookie.`,
|
|
7
|
-
}); }
|
|
8
|
-
constructor(properties) {
|
|
9
|
-
super(`#[${properties.code}] ${properties.message}`);
|
|
10
|
-
this.properties = properties;
|
|
11
|
-
this.code = this.properties.code;
|
|
12
|
-
this.cause = this.properties.cause;
|
|
13
|
-
this.plainMessage = this.properties.message;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.HandleSignInCallbackError = HandleSignInCallbackError;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const makeHandleSignInCallbackUseCase = (deps) => async (request) => {
|
|
4
|
-
const { sessionStorage, createLogtoAdapter } = deps;
|
|
5
|
-
const session = await sessionStorage.getSession(request.cookieHeader);
|
|
6
|
-
const logto = createLogtoAdapter(session);
|
|
7
|
-
const response = await logto.handleSignInCallback({
|
|
8
|
-
callbackUri: request.callbackUri,
|
|
9
|
-
});
|
|
10
|
-
const cookieHeader = await sessionStorage.commitSession(response.session);
|
|
11
|
-
return {
|
|
12
|
-
cookieHeader,
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.makeHandleSignInCallbackUseCase = makeHandleSignInCallbackUseCase;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var HandleSignInCallbackController = require('./HandleSignInCallbackController.cjs');
|
|
4
|
-
var HandleSignInCallbackUseCase = require('./HandleSignInCallbackUseCase.cjs');
|
|
5
|
-
|
|
6
|
-
const makeHandleSignInCallback = (dto, deps) => async (request) => {
|
|
7
|
-
const { createLogtoAdapter, sessionStorage } = deps;
|
|
8
|
-
const useCase = HandleSignInCallbackUseCase.makeHandleSignInCallbackUseCase({
|
|
9
|
-
createLogtoAdapter,
|
|
10
|
-
sessionStorage,
|
|
11
|
-
});
|
|
12
|
-
const controller = HandleSignInCallbackController.HandleSignInCallbackController.fromDto({
|
|
13
|
-
useCase,
|
|
14
|
-
redirectUri: dto.redirectBackTo,
|
|
15
|
-
});
|
|
16
|
-
return controller.execute(request);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.makeHandleSignInCallback = makeHandleSignInCallback;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var node = require('@remix-run/node');
|
|
4
|
-
var getCookieHeaderFromRequest = require('../../framework/get-cookie-header-from-request.cjs');
|
|
5
|
-
var HandleSignOutError = require('./HandleSignOutError.cjs');
|
|
6
|
-
|
|
7
|
-
class HandleSignOutController {
|
|
8
|
-
static { this.fromDto = (dto) => new HandleSignOutController({
|
|
9
|
-
useCase: dto.useCase,
|
|
10
|
-
redirectUri: dto.redirectUri,
|
|
11
|
-
}); }
|
|
12
|
-
constructor(properties) {
|
|
13
|
-
this.properties = properties;
|
|
14
|
-
this.useCase = this.properties.useCase;
|
|
15
|
-
this.redirectUri = this.properties.redirectUri;
|
|
16
|
-
this.execute = async (request) => {
|
|
17
|
-
const cookieHeader = getCookieHeaderFromRequest.getCookieHeaderFromRequest(request);
|
|
18
|
-
if (!cookieHeader) {
|
|
19
|
-
throw HandleSignOutError.HandleSignOutError.becauseNoCookieHeaderPresent();
|
|
20
|
-
}
|
|
21
|
-
const result = await this.useCase({
|
|
22
|
-
cookieHeader,
|
|
23
|
-
redirectUri: this.redirectUri,
|
|
24
|
-
});
|
|
25
|
-
return node.redirect(result.navigateToUrl, {
|
|
26
|
-
headers: {
|
|
27
|
-
'Set-Cookie': result.cookieHeader,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
exports.HandleSignOutController = HandleSignOutController;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
class HandleSignOutError extends Error {
|
|
4
|
-
static { this.becauseNoCookieHeaderPresent = () => new HandleSignOutError({
|
|
5
|
-
code: 1_665_388_713,
|
|
6
|
-
message: `The authentication sign-out route can't be accessed without a valid cookie.`,
|
|
7
|
-
}); }
|
|
8
|
-
constructor(properties) {
|
|
9
|
-
super(`#[${properties.code}] ${properties.message}`);
|
|
10
|
-
this.properties = properties;
|
|
11
|
-
this.code = this.properties.code;
|
|
12
|
-
this.cause = this.properties.cause;
|
|
13
|
-
this.plainMessage = this.properties.message;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
exports.HandleSignOutError = HandleSignOutError;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const makeHandleSignOutUseCase = (deps) => async (request) => {
|
|
4
|
-
const { sessionStorage, createLogtoAdapter } = deps;
|
|
5
|
-
const session = await sessionStorage.getSession(request.cookieHeader);
|
|
6
|
-
const logto = createLogtoAdapter(session);
|
|
7
|
-
const response = await logto.handleSignOut({
|
|
8
|
-
redirectUri: request.redirectUri,
|
|
9
|
-
});
|
|
10
|
-
const cookieHeader = await sessionStorage.destroySession(session);
|
|
11
|
-
return {
|
|
12
|
-
cookieHeader,
|
|
13
|
-
navigateToUrl: response.navigateToUrl,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
exports.makeHandleSignOutUseCase = makeHandleSignOutUseCase;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var HandleSignOutController = require('./HandleSignOutController.cjs');
|
|
4
|
-
var HandleSignOutUseCase = require('./HandleSignOutUseCase.cjs');
|
|
5
|
-
|
|
6
|
-
const makeHandleSignOut = (dto, deps) => async (request) => {
|
|
7
|
-
const { createLogtoAdapter, sessionStorage } = deps;
|
|
8
|
-
const useCase = HandleSignOutUseCase.makeHandleSignOutUseCase({
|
|
9
|
-
createLogtoAdapter,
|
|
10
|
-
sessionStorage,
|
|
11
|
-
});
|
|
12
|
-
const controller = HandleSignOutController.HandleSignOutController.fromDto({
|
|
13
|
-
useCase,
|
|
14
|
-
redirectUri: dto.redirectBackTo,
|
|
15
|
-
});
|
|
16
|
-
return controller.execute(request);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.makeHandleSignOut = makeHandleSignOut;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var node = require('@remix-run/node');
|
|
4
|
-
var getCookieHeaderFromRequest = require('../../framework/get-cookie-header-from-request.cjs');
|
|
5
|
-
|
|
6
|
-
class HandleSignUpController {
|
|
7
|
-
static { this.fromDto = (dto) => new HandleSignUpController({
|
|
8
|
-
useCase: dto.useCase,
|
|
9
|
-
redirectUri: dto.redirectUri,
|
|
10
|
-
}); }
|
|
11
|
-
constructor(properties) {
|
|
12
|
-
this.properties = properties;
|
|
13
|
-
this.useCase = this.properties.useCase;
|
|
14
|
-
this.redirectUri = this.properties.redirectUri;
|
|
15
|
-
this.execute = async (request) => {
|
|
16
|
-
const cookieHeader = getCookieHeaderFromRequest.getCookieHeaderFromRequest(request);
|
|
17
|
-
const { redirectUri } = this;
|
|
18
|
-
const result = await this.useCase({
|
|
19
|
-
cookieHeader: cookieHeader ?? undefined,
|
|
20
|
-
redirectUri,
|
|
21
|
-
});
|
|
22
|
-
return node.redirect(result.navigateToUrl, {
|
|
23
|
-
headers: {
|
|
24
|
-
'Set-Cookie': result.cookieHeader,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.HandleSignUpController = HandleSignUpController;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const makeHandleSignUpUseCase = (deps) => async (request) => {
|
|
4
|
-
const { sessionStorage, createLogtoAdapter } = deps;
|
|
5
|
-
const session = await sessionStorage.getSession(request.cookieHeader);
|
|
6
|
-
const logto = createLogtoAdapter(session);
|
|
7
|
-
const response = await logto.handleSignUp({
|
|
8
|
-
redirectUri: request.redirectUri,
|
|
9
|
-
});
|
|
10
|
-
const cookieHeader = await sessionStorage.commitSession(response.session);
|
|
11
|
-
return {
|
|
12
|
-
cookieHeader,
|
|
13
|
-
navigateToUrl: response.navigateToUrl,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
exports.makeHandleSignUpUseCase = makeHandleSignUpUseCase;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var HandleSignUpController = require('./HandleSignUpController.cjs');
|
|
4
|
-
var HandleSignUpUseCase = require('./HandleSignUpUseCase.cjs');
|
|
5
|
-
|
|
6
|
-
const makeHandleSignUp = (dto, deps) => async (request) => {
|
|
7
|
-
const { createLogtoAdapter, sessionStorage } = deps;
|
|
8
|
-
const useCase = HandleSignUpUseCase.makeHandleSignUpUseCase({
|
|
9
|
-
createLogtoAdapter,
|
|
10
|
-
sessionStorage,
|
|
11
|
-
});
|
|
12
|
-
const controller = HandleSignUpController.HandleSignUpController.fromDto({
|
|
13
|
-
useCase,
|
|
14
|
-
redirectUri: dto.redirectBackTo,
|
|
15
|
-
});
|
|
16
|
-
return controller.execute(request);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.makeHandleSignUp = makeHandleSignUp;
|