kempo-oauth 0.1.2 → 0.1.4
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/README.md +4 -0
- package/kempo-config.json +15 -0
- package/package.json +4 -2
- package/public/components/AccountsWidget.js +48 -0
package/README.md
CHANGED
|
@@ -70,3 +70,7 @@ DATABASE_URL=postgresql://kempo:kempo@localhost:5445/kempo_oauth_test SETTINGS_E
|
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
Check for `(SKIPPED)` in the output: database suites skip themselves, and a skip reads as a pass. They also refuse any database not named `*_test`.
|
|
73
|
+
|
|
74
|
+
## Dashboard widget
|
|
75
|
+
|
|
76
|
+
Adds a **Social sign-in** widget to the kempo admin dashboard showing how many accounts are linked and which providers are offered, with a **Provider settings** button. It is declared in `widgets` in `kempo-config.json` and registered when the extension is installed or updated; people only see it if they hold its permission, and can hide, reorder or resize it from the dashboard's Customize dialog. Needs a kempo with the dashboard (see kempo's `docs/dashboard.md`); on an older kempo the entry is ignored.
|
package/kempo-config.json
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
"git": "https://github.com/dustinpoissant/kempo-oauth",
|
|
4
4
|
"public-scope": "oauth",
|
|
5
5
|
"schema": "./server/db/schema.js",
|
|
6
|
+
"widgets": [
|
|
7
|
+
{
|
|
8
|
+
"key": "accounts",
|
|
9
|
+
"title": "Social sign-in",
|
|
10
|
+
"description": "How many accounts are linked to a sign-in provider and which providers are offered.",
|
|
11
|
+
"icon": "login",
|
|
12
|
+
"element": "k-oauth-widget",
|
|
13
|
+
"module": "/oauth/components/AccountsWidget.js",
|
|
14
|
+
"defaultWidth": 2,
|
|
15
|
+
"defaultHeight": 1,
|
|
16
|
+
"minWidth": 1,
|
|
17
|
+
"permission": "oauth:view",
|
|
18
|
+
"priority": 110
|
|
19
|
+
}
|
|
20
|
+
],
|
|
6
21
|
"permissions": [
|
|
7
22
|
{
|
|
8
23
|
"name": "oauth:view",
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo-oauth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Sign in with Google, GitHub, Facebook, X and Microsoft for kempo — OAuth 2.0 login and registration buttons, with the keys managed in the admin portal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Dustin Poissant",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "sdk.js",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "kempo-test -l minimal",
|
|
10
|
+
"test": "node scripts/run-tests.js unit kempo-test -l minimal",
|
|
11
|
+
"test:integration": "node scripts/run-tests.js integration kempo-test -l minimal",
|
|
11
12
|
"link:local": "npm install ../kempo ../kempo-server ../kempo-ui --no-save --no-legacy-peer-deps --force"
|
|
12
13
|
},
|
|
13
14
|
"kempo": {
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"kempo-ui": ">=0.4.53"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
46
|
+
"@electric-sql/pglite": "^0.5.9",
|
|
45
47
|
"drizzle-kit": "^0.31.10",
|
|
46
48
|
"kempo-testing-framework": "^1.4.11",
|
|
47
49
|
"postgres": "^3.4.9"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import DashboardWidget from '/kempo/components/DashboardWidget.js';
|
|
2
|
+
import { html } from '/kempo-ui/lit-all.min.js';
|
|
3
|
+
import { getAccounts } from '/oauth/sdk.js';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
How many accounts are linked to a provider, and the providers available.
|
|
7
|
+
*/
|
|
8
|
+
export default class AccountsWidget extends DashboardWidget {
|
|
9
|
+
static properties = {
|
|
10
|
+
...DashboardWidget.properties,
|
|
11
|
+
total: { state: true },
|
|
12
|
+
providers: { state: true }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
constructor(){
|
|
16
|
+
super();
|
|
17
|
+
this.total = 0;
|
|
18
|
+
this.providers = [];
|
|
19
|
+
this.cta = { label: 'Provider settings', icon: 'settings', href: '/admin/extension/kempo-oauth/', permission: 'oauth:settings' };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Public Methods
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
load = async () => {
|
|
27
|
+
const { total, providers } = await this.unwrap(getAccounts({ limit: 1 }));
|
|
28
|
+
this.total = total;
|
|
29
|
+
this.providers = providers;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
Rendering
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
renderContent(){
|
|
37
|
+
if(!this.total){
|
|
38
|
+
return html`<p class="tc-muted mbh">No accounts linked yet.</p><div class="small tc-muted">Providers: ${this.providers.map(provider => provider.label).join(', ')}</div>`;
|
|
39
|
+
}
|
|
40
|
+
return html`
|
|
41
|
+
<div class="h2 m0">${this.total}</div>
|
|
42
|
+
<div class="small tc-muted mb">Linked ${this.total === 1 ? 'account' : 'accounts'}</div>
|
|
43
|
+
<div class="small tc-muted">${this.providers.map(provider => provider.label).join(', ')}</div>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
customElements.define('k-oauth-widget', AccountsWidget);
|