@staffbase/create-staffbase-plugin 1.0.6 → 1.0.8
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/.github/CODEOWNERS +3 -3
- package/.github/workflows/auto-merge.yml +1 -1
- package/.github/workflows/publish-npm.yml +23 -0
- package/{README.MD → README.md} +6 -4
- package/catalog-info.yaml +14 -0
- package/package.json +4 -4
- package/scaffoldTpl/app.js +32 -30
- package/scaffoldTpl/package.json +3 -3
- package/scaffoldTpl/views/index.html +77 -40
- package/scaffoldTpl/package-lock.json +0 -1300
package/.github/CODEOWNERS
CHANGED
|
@@ -4,7 +4,7 @@ on: pull_request
|
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
6
|
dependabot:
|
|
7
|
-
uses: Staffbase/gha-workflows/.github/workflows/template_automerge_dependabot.yml@
|
|
7
|
+
uses: Staffbase/gha-workflows/.github/workflows/template_automerge_dependabot.yml@v7.2.0
|
|
8
8
|
secrets:
|
|
9
9
|
app_id: ${{ vars.STAFFBASE_ACTIONS_APP_ID }}
|
|
10
10
|
private_key: ${{ secrets.STAFFBASE_ACTIONS_PRIVATE_KEY }}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Publish to NPM Registry
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [created]
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read # we need to read secrets
|
|
8
|
+
id-token: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
- name: Setup Node
|
|
17
|
+
uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
registry-url: 'https://registry.npmjs.org'
|
|
20
|
+
- name: Publish package on NPM 📦
|
|
21
|
+
run: npm publish --access public
|
|
22
|
+
env:
|
|
23
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/{README.MD → README.md}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Create-Staffbase-SSO-CLI Documentation
|
|
2
2
|

|
|
3
|
+
|
|
3
4
|
## Getting started
|
|
4
5
|
Install the package in your global namespace and then run the command.
|
|
5
6
|
|
|
@@ -15,6 +16,7 @@ Example:
|
|
|
15
16
|
```bash
|
|
16
17
|
$ yarn create @staffbase/staffbase-plugin /home/user1/work/staffbase-server/ --name staffbase-sso-server
|
|
17
18
|
```
|
|
19
|
+
|
|
18
20
|
## Interactive Mode
|
|
19
21
|
You can also run the command without passing any arguments to get into interactive
|
|
20
22
|
mode which would ask you the name of your app and the path where it need to be installed.
|
|
@@ -74,7 +76,7 @@ $ npm start
|
|
|
74
76
|
|
|
75
77
|
## License
|
|
76
78
|
|
|
77
|
-
Copyright 2017-
|
|
79
|
+
Copyright 2017-2025 Staffbase SE.
|
|
78
80
|
|
|
79
81
|
Licensed under the Apache License, Version 2.0: https://www.apache.org/licenses/LICENSE-2.0
|
|
80
82
|
|
|
@@ -84,9 +86,9 @@ Licensed under the Apache License, Version 2.0: https://www.apache.org/licenses/
|
|
|
84
86
|
<img src="docs/assets/images/staffbase.png" alt="Staffbase GmbH" width="96" />
|
|
85
87
|
</td>
|
|
86
88
|
<td>
|
|
87
|
-
<b>Staffbase
|
|
88
|
-
<br />Staffbase is an internal communications platform built to revolutionize the way you work and unite your company. Staffbase is hiring: <a href="https://
|
|
89
|
-
<br /><a href="https://github.com/Staffbase" target="_blank" rel="noreferrer">GitHub</a> | <a href="https://staffbase.com/" target="_blank" rel="noreferrer">Website</a> | <a href="https://
|
|
89
|
+
<b>Staffbase SE</b>
|
|
90
|
+
<br />Staffbase is an internal communications platform built to revolutionize the way you work and unite your company. Staffbase is hiring: <a href="https://staffbase.com/jobs/" target="_blank" rel="noreferrer">https://staffbase.com/jobs</a>
|
|
91
|
+
<br /><a href="https://github.com/Staffbase" target="_blank" rel="noreferrer">GitHub</a> | <a href="https://staffbase.com/" target="_blank" rel="noreferrer">Website</a> | <a href="https://staffbase.com/jobs/" target="_blank" rel="noreferrer">Jobs</a>
|
|
90
92
|
</td>
|
|
91
93
|
</tr>
|
|
92
94
|
</table>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
apiVersion: backstage.io/v1alpha1
|
|
2
|
+
kind: Component
|
|
3
|
+
metadata:
|
|
4
|
+
name: create-staffbase-plugin-nodejs
|
|
5
|
+
description: Node.js plugin skeleton generator provided by Staffbase
|
|
6
|
+
annotations:
|
|
7
|
+
github.com/project-slug: Staffbase/create-staffbase-plugin-nodejs
|
|
8
|
+
jfrog-artifactory/image-name: create-staffbase-plugin-nodejs
|
|
9
|
+
tags:
|
|
10
|
+
- js
|
|
11
|
+
- nodejs
|
|
12
|
+
spec:
|
|
13
|
+
type: service
|
|
14
|
+
lifecycle: production
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@staffbase/create-staffbase-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"bin": {
|
|
5
5
|
"create-staffbase-plugin": "csss.js"
|
|
6
6
|
},
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
|
36
36
|
"@typescript-eslint/parser": "^5.50.0",
|
|
37
37
|
"eslint": "^8.33.0",
|
|
38
|
+
"eslint-config-google": "^0.14.0",
|
|
38
39
|
"eslint-config-prettier": "^8.6.0",
|
|
39
|
-
"eslint-plugin-react": "^7.32.2",
|
|
40
40
|
"eslint-plugin-import-helpers": "^1.1.0",
|
|
41
|
+
"eslint-plugin-react": "^7.32.2",
|
|
41
42
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
42
43
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
43
|
-
"eslint-config-google": "^0.14.0",
|
|
44
44
|
"highlight.js": "^10.0.3",
|
|
45
45
|
"husky": "^4.2.5",
|
|
46
|
-
"jest": "^
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
47
|
"markdown-it": "^12.3.2",
|
|
48
48
|
"marked": "^4.0.10",
|
|
49
49
|
"typescript": "^4.9.5"
|
package/scaffoldTpl/app.js
CHANGED
|
@@ -1,77 +1,79 @@
|
|
|
1
|
-
let express = require(
|
|
2
|
-
let path = require(
|
|
3
|
-
let favicon = require(
|
|
4
|
-
let logger = require(
|
|
5
|
-
let cookieParser = require(
|
|
6
|
-
let bodyParser = require(
|
|
1
|
+
let express = require("express");
|
|
2
|
+
let path = require("path");
|
|
3
|
+
let favicon = require("serve-favicon");
|
|
4
|
+
let logger = require("morgan");
|
|
5
|
+
let cookieParser = require("cookie-parser");
|
|
6
|
+
let bodyParser = require("body-parser");
|
|
7
7
|
|
|
8
|
-
let index = require(
|
|
9
|
-
let users = require(
|
|
8
|
+
let index = require("./routes/index");
|
|
9
|
+
let users = require("./routes/users");
|
|
10
10
|
|
|
11
11
|
let app = express();
|
|
12
12
|
|
|
13
13
|
const staffbaseKey = null;
|
|
14
14
|
const pluginID = null;
|
|
15
15
|
let ssoMiddleWare;
|
|
16
|
-
ssoMiddleWare = require(
|
|
17
|
-
|
|
16
|
+
ssoMiddleWare = require("@staffbase/staffbase-plugin-sdk").middleware(
|
|
17
|
+
staffbaseKey,
|
|
18
|
+
pluginID
|
|
19
|
+
);
|
|
18
20
|
|
|
19
21
|
// view engine setup
|
|
20
|
-
app.set(
|
|
21
|
-
app.set(
|
|
22
|
+
app.set("views", path.join(__dirname, "views"));
|
|
23
|
+
app.set("view engine", "pug");
|
|
22
24
|
|
|
23
25
|
// uncomment after placing your favicon in /public
|
|
24
26
|
// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
|
|
25
|
-
app.use(logger(
|
|
27
|
+
app.use(logger("dev"));
|
|
26
28
|
app.use(bodyParser.json());
|
|
27
|
-
app.use(bodyParser.urlencoded({extended: false}));
|
|
29
|
+
app.use(bodyParser.urlencoded({ extended: false }));
|
|
28
30
|
app.use(cookieParser());
|
|
29
|
-
app.use(express.static(path.join(__dirname,
|
|
31
|
+
app.use(express.static(path.join(__dirname, "public")));
|
|
30
32
|
|
|
31
|
-
app.use(
|
|
32
|
-
app.use(
|
|
33
|
+
app.use("/", index);
|
|
34
|
+
app.use("/users", users);
|
|
33
35
|
|
|
34
36
|
// Frontend Handler
|
|
35
|
-
app.use(
|
|
36
|
-
app.get(
|
|
37
|
-
res.render(
|
|
37
|
+
app.use("/frontEnd", ssoMiddleWare);
|
|
38
|
+
app.get("/frontEnd", function (req, res) {
|
|
39
|
+
res.render("plugin", req.sbSSO);
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
// Setup SSO Milleware on the endpoint server
|
|
41
|
-
app.use(
|
|
43
|
+
app.use("/staffbase/sso/backoffice", ssoMiddleWare);
|
|
42
44
|
|
|
43
45
|
// Handle SSO response from server with decoded data
|
|
44
|
-
app.get(
|
|
46
|
+
app.get("/staffbase/sso/backoffice", function (req, res) {
|
|
45
47
|
// Middleware was able to decode the token
|
|
46
48
|
if (req.sbSSO) {
|
|
47
|
-
console.log(
|
|
48
|
-
res.render(
|
|
49
|
+
console.log("Decoded data on backend(admin):", req.sbSSO);
|
|
50
|
+
res.render("plugin", req.sbSSO);
|
|
49
51
|
return res.end();
|
|
50
52
|
}
|
|
51
53
|
res.json({
|
|
52
54
|
error: {
|
|
53
|
-
msg:
|
|
55
|
+
msg: "Unable to get token information.",
|
|
54
56
|
},
|
|
55
57
|
});
|
|
56
58
|
return res.end();
|
|
57
59
|
});
|
|
58
60
|
|
|
59
61
|
// catch 404 and forward to error handler
|
|
60
|
-
app.use(function(req, res, next) {
|
|
61
|
-
let err = new Error(
|
|
62
|
+
app.use(function (req, res, next) {
|
|
63
|
+
let err = new Error("Not Found");
|
|
62
64
|
err.status = 404;
|
|
63
65
|
next(err);
|
|
64
66
|
});
|
|
65
67
|
|
|
66
68
|
// error handler
|
|
67
|
-
app.use(function(err, req, res, next) {
|
|
69
|
+
app.use(function (err, req, res, next) {
|
|
68
70
|
// set locals, only providing error in development
|
|
69
71
|
res.locals.message = err.message;
|
|
70
|
-
res.locals.error = req.app.get(
|
|
72
|
+
res.locals.error = req.app.get("env") === "development" ? err : {};
|
|
71
73
|
|
|
72
74
|
// render the error page
|
|
73
75
|
res.status(err.status || 500);
|
|
74
|
-
res.render(
|
|
76
|
+
res.render("error");
|
|
75
77
|
});
|
|
76
78
|
|
|
77
79
|
module.exports = app;
|
package/scaffoldTpl/package.json
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@staffbase/staffbase-plugin-sdk": "^1.3.1",
|
|
10
|
-
"body-parser": "~1.
|
|
10
|
+
"body-parser": "~1.20.3",
|
|
11
11
|
"cookie-parser": "~1.4.5",
|
|
12
|
-
"debug": "~4.
|
|
13
|
-
"express": "~4.
|
|
12
|
+
"debug": "~4.4.0",
|
|
13
|
+
"express": "~4.21.2",
|
|
14
14
|
"morgan": "~1.10.0",
|
|
15
15
|
"pug": ">=3.0.1",
|
|
16
16
|
"serve-favicon": "~2.5.0"
|
|
@@ -1,19 +1,40 @@
|
|
|
1
|
-
<p
|
|
2
|
-
<
|
|
3
|
-
|
|
1
|
+
<p>
|
|
2
|
+
<img
|
|
3
|
+
src="https://staffbase.com/wp-content/themes/staffbase-theme/img/logo-blau.svg"
|
|
4
|
+
alt="Staffbase Logo"
|
|
5
|
+
/>
|
|
6
|
+
</p>
|
|
7
|
+
<p>
|
|
8
|
+
Welcome to your Staffbase SSO plugin server. Please follow the following
|
|
9
|
+
instructions to get started with your Plugin Application.
|
|
10
|
+
</p>
|
|
4
11
|
<h2>Prerequisites</h2>
|
|
5
|
-
<p>
|
|
6
|
-
|
|
12
|
+
<p>
|
|
13
|
+
In order to get connected with the Staffbase SSO interface, you need a Valid
|
|
14
|
+
Secret and an Audience ID.
|
|
15
|
+
</p>
|
|
16
|
+
<p>
|
|
17
|
+
If you are here, you probably have a secret and audience ID registered with
|
|
18
|
+
Staffbase. If you are not sure about it or you need more information about
|
|
19
|
+
Staffbase SSO, feel free to contact the Customer Success team at Staffbase.
|
|
20
|
+
</p>
|
|
7
21
|
<h2>Configuration</h2>
|
|
8
|
-
<p>
|
|
9
|
-
|
|
22
|
+
<p>
|
|
23
|
+
After the scaffolding is complete, you need to provide some values for
|
|
24
|
+
configuring your plugin server. The following values need to be configured.
|
|
25
|
+
</p>
|
|
10
26
|
<ul>
|
|
11
|
-
<li>Plugin Secret</li>
|
|
12
|
-
<li>Plugin Audience</li>
|
|
27
|
+
<li>Plugin Secret</li>
|
|
28
|
+
<li>Plugin Audience</li>
|
|
13
29
|
</ul>
|
|
14
|
-
<p>
|
|
15
|
-
|
|
16
|
-
|
|
30
|
+
<p>
|
|
31
|
+
You can either specify these values in environment variables or directly
|
|
32
|
+
passing the values in the <code>app.js</code> file where the middleware is
|
|
33
|
+
initialized.
|
|
34
|
+
</p>
|
|
35
|
+
<p>
|
|
36
|
+
To configure values in <code>app.js</code> file, change the following lines:
|
|
37
|
+
</p>
|
|
17
38
|
<p>app.js</p>
|
|
18
39
|
<pre><code class="language-javascript">12 ...
|
|
19
40
|
13 ...
|
|
@@ -21,40 +42,56 @@ the values in the <code>app.js</code> file where the middleware is initialized.<
|
|
|
21
42
|
15 const pluginID = null;
|
|
22
43
|
16 ...
|
|
23
44
|
</code></pre>
|
|
24
|
-
<p>
|
|
25
|
-
|
|
45
|
+
<p>
|
|
46
|
+
You can also specify these values using environment variables. Refer to the
|
|
47
|
+
table to see which environment variables can be used.
|
|
48
|
+
</p>
|
|
26
49
|
<table>
|
|
27
|
-
<thead>
|
|
28
|
-
<tr>
|
|
29
|
-
<th style="text-align:left"><em>Value</em></th>
|
|
30
|
-
<th style="text-align:center"><em>Environment Variable</em></th>
|
|
31
|
-
</tr>
|
|
32
|
-
</thead>
|
|
33
|
-
<tbody>
|
|
34
|
-
<tr>
|
|
35
|
-
<td style="text-align:left">Secret</td>
|
|
36
|
-
<td style="text-align:center">STAFFBASE_SSO_SECRET</td>
|
|
37
|
-
</tr>
|
|
38
|
-
<tr>
|
|
39
|
-
<td style="text-align:left">Audience</td>
|
|
40
|
-
<td style="text-align:center">STAFFBASE_SSO_AUDIENCE</td>
|
|
41
|
-
</tr>
|
|
42
|
-
<tr>
|
|
43
|
-
<td style="text-align:left">Server Port</td>
|
|
44
|
-
<td style="text-align:center">PORT</td>
|
|
45
|
-
</tr>
|
|
46
|
-
</tbody>
|
|
50
|
+
<thead>
|
|
51
|
+
<tr>
|
|
52
|
+
<th style="text-align: left"><em>Value</em></th>
|
|
53
|
+
<th style="text-align: center"><em>Environment Variable</em></th>
|
|
54
|
+
</tr>
|
|
55
|
+
</thead>
|
|
56
|
+
<tbody>
|
|
57
|
+
<tr>
|
|
58
|
+
<td style="text-align: left">Secret</td>
|
|
59
|
+
<td style="text-align: center">STAFFBASE_SSO_SECRET</td>
|
|
60
|
+
</tr>
|
|
61
|
+
<tr>
|
|
62
|
+
<td style="text-align: left">Audience</td>
|
|
63
|
+
<td style="text-align: center">STAFFBASE_SSO_AUDIENCE</td>
|
|
64
|
+
</tr>
|
|
65
|
+
<tr>
|
|
66
|
+
<td style="text-align: left">Server Port</td>
|
|
67
|
+
<td style="text-align: center">PORT</td>
|
|
68
|
+
</tr>
|
|
69
|
+
</tbody>
|
|
47
70
|
</table>
|
|
48
71
|
<h2>Running the server</h2>
|
|
49
|
-
<p
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
<p>
|
|
73
|
+
<em>create-staffbase-plugin</em> installs the project dependencies for you.
|
|
74
|
+
After configurations is done, the only thing you need to do is navigate to the
|
|
75
|
+
folder where your app was generated and start the express server.
|
|
76
|
+
</p>
|
|
52
77
|
<pre><code class="language-bash">$ cd [path of generated app]
|
|
53
78
|
$ npm start
|
|
54
79
|
</code></pre>
|
|
55
80
|
<h2>Further Reading</h2>
|
|
56
|
-
<p>
|
|
81
|
+
<p>
|
|
82
|
+
For getting more information about Staffbase SSO, please check out the
|
|
83
|
+
following links:
|
|
84
|
+
</p>
|
|
57
85
|
<ul>
|
|
58
|
-
<li
|
|
59
|
-
<
|
|
86
|
+
<li>
|
|
87
|
+
<a href="https://developers.staffbase.com/concepts/customplugin-overview/"
|
|
88
|
+
>Developer Portal: Custom Plugins</a
|
|
89
|
+
>
|
|
90
|
+
</li>
|
|
91
|
+
<li>
|
|
92
|
+
<a
|
|
93
|
+
href="https://github.com/Staffbase/plugins-sdk-nodejs/blob/master/README.md"
|
|
94
|
+
>Staffbase Plugins SDK for Node.js</a
|
|
95
|
+
>
|
|
96
|
+
</li>
|
|
60
97
|
</ul>
|