@mirrormedia/lilith-google-auth 0.1.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/@types/google.d.ts +21 -0
- package/@types/index.d.ts +11 -0
- package/@types/log.d.ts +31 -0
- package/@types/mini-app.d.ts +8 -0
- package/@types/password-guard.d.ts +15 -0
- package/@types/password-plugin.d.ts +30 -0
- package/@types/redirect.d.ts +5 -0
- package/@types/session.d.ts +20 -0
- package/@types/signin-page.d.ts +8 -0
- package/@types/state-cookie.d.ts +12 -0
- package/@types/types.d.ts +69 -0
- package/@types/with-google-auth.d.ts +46 -0
- package/README.md +237 -0
- package/lib/google.js +59 -0
- package/lib/index.js +57 -0
- package/lib/log.js +68 -0
- package/lib/mini-app.js +267 -0
- package/lib/password-guard.js +66 -0
- package/lib/password-plugin.js +86 -0
- package/lib/redirect.js +21 -0
- package/lib/session.js +59 -0
- package/lib/signin-page.js +55 -0
- package/lib/state-cookie.js +64 -0
- package/lib/types.js +5 -0
- package/lib/with-google-auth.js +54 -0
- package/package.json +46 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withGoogleAuth = withGoogleAuth;
|
|
7
|
+
|
|
8
|
+
var _miniApp = require("./mini-app");
|
|
9
|
+
|
|
10
|
+
var _passwordPlugin = require("./password-plugin");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Wraps a Keystone config with Google sign-in: mounts the mini-app at the head
|
|
14
|
+
* of `server.extendExpressApp` and, when the password kill switch is on, adds
|
|
15
|
+
* the Apollo block plugin the mini-app's HTTP guard cannot replace.
|
|
16
|
+
*
|
|
17
|
+
* Mounting first is what lets the mini-app answer `/signin` before the Admin
|
|
18
|
+
* UI middleware claims it; it also means the mini-app stamps its own
|
|
19
|
+
* `X-Robots-Tag` rather than inheriting the host's.
|
|
20
|
+
*/
|
|
21
|
+
function withGoogleAuth(config, options) {
|
|
22
|
+
var _config$server;
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
isEnabled,
|
|
26
|
+
...miniAppOptions
|
|
27
|
+
} = options;
|
|
28
|
+
if (isEnabled === false) return config;
|
|
29
|
+
const originalExtendExpressApp = (_config$server = config.server) === null || _config$server === void 0 ? void 0 : _config$server.extendExpressApp;
|
|
30
|
+
const next = { ...config,
|
|
31
|
+
server: { ...config.server,
|
|
32
|
+
extendExpressApp: async (app, context) => {
|
|
33
|
+
app.use((0, _miniApp.createGoogleAuthMiniApp)({ ...miniAppOptions,
|
|
34
|
+
// Keystone's generated context is structurally compatible with
|
|
35
|
+
// the narrow KeystoneContext this package declares.
|
|
36
|
+
keystoneContext: context
|
|
37
|
+
}));
|
|
38
|
+
await (originalExtendExpressApp === null || originalExtendExpressApp === void 0 ? void 0 : originalExtendExpressApp(app, context));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
if (options.passwordLoginEnabled === false) {
|
|
44
|
+
var _config$graphql, _config$graphql2, _config$graphql2$apol;
|
|
45
|
+
|
|
46
|
+
next.graphql = { ...config.graphql,
|
|
47
|
+
apolloConfig: { ...((_config$graphql = config.graphql) === null || _config$graphql === void 0 ? void 0 : _config$graphql.apolloConfig),
|
|
48
|
+
plugins: [(0, _passwordPlugin.createPasswordLoginBlockPlugin)(), ...(((_config$graphql2 = config.graphql) === null || _config$graphql2 === void 0 ? void 0 : (_config$graphql2$apol = _config$graphql2.apolloConfig) === null || _config$graphql2$apol === void 0 ? void 0 : _config$graphql2$apol.plugins) ?? [])]
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return next;
|
|
54
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mirrormedia/lilith-google-auth",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Google Workspace sign-in mini-app for Lilith Keystone CMS packages",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "@types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "make build",
|
|
9
|
+
"clean": "make clean",
|
|
10
|
+
"test": "tsx --test 'src/**/*.test.ts'"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/mirror-media/Lilith.git",
|
|
15
|
+
"directory": "packages/google-auth"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"Google Workspace",
|
|
19
|
+
"OAuth",
|
|
20
|
+
"KeystoneJS",
|
|
21
|
+
"Keystone 6",
|
|
22
|
+
"CMS"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"files": [
|
|
26
|
+
"lib",
|
|
27
|
+
"@types"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@types/express": "^4.17.14",
|
|
31
|
+
"cookie": "^0.5.0",
|
|
32
|
+
"google-auth-library": "^10.5.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"express": "^4.17.1",
|
|
36
|
+
"graphql": "^16"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/cookie": "^0.5.1",
|
|
40
|
+
"express": "^4.17.1",
|
|
41
|
+
"graphql": "^16.12.0",
|
|
42
|
+
"graphql-upload": "^15.0.2",
|
|
43
|
+
"tsx": "^4.23.13",
|
|
44
|
+
"typescript": "^4.7.4"
|
|
45
|
+
}
|
|
46
|
+
}
|