Skip to content

Commit d35a6f3

Browse files
authored
Doc update and fix the test build (#585)
* migrate docs to vitepress * fix: unit tests
1 parent 78a8ef1 commit d35a6f3

File tree

16 files changed

+2225
-2626
lines changed

16 files changed

+2225
-2626
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Deploy VitePress Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- 'docs/**'
9+
- '.github/workflows/deploy-docs.yml'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: false
20+
21+
jobs:
22+
build-and-deploy:
23+
runs-on: ubuntu-latest
24+
environment:
25+
name: github-pages
26+
url: ${{ steps.deployment.outputs.page_url }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 18
37+
cache: 'yarn'
38+
39+
- name: Install dependencies
40+
run: yarn install --frozen-lockfile
41+
42+
- name: Build VitePress
43+
run: yarn docs:build
44+
45+
- name: Setup Pages
46+
uses: actions/configure-pages@v4
47+
48+
- name: Upload artifact
49+
uses: actions/upload-pages-artifact@v3
50+
with:
51+
path: docs/.vitepress/dist
52+
53+
- name: Deploy to GitHub Pages
54+
id: deployment
55+
uses: actions/deploy-pages@v4
56+

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ types/
3333

3434
*.tgz
3535

36-
package-lock.json
36+
package-lock.json
37+
38+
*.vitepress

docs/_coverpage.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/_media/favicon.ico

-82.3 KB
Binary file not shown.

docs/_media/lock.png

-3.21 KB
Binary file not shown.

docs/_media/padlock.png

2.88 KB
Loading

docs/_sidebar.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

docs/index.html

Lines changed: 0 additions & 34 deletions
This file was deleted.

docs/index.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
layout: home
3+
4+
hero:
5+
name: samlify
6+
text: Node.js SAML2 API
7+
tagline: Nodejs library for Single Sign On with SAML 2.0
8+
image:
9+
src: /_media/padlock.png
10+
alt: samlify
11+
actions:
12+
- theme: brand
13+
text: Get Started
14+
link: /prerequistite
15+
- theme: alt
16+
text: View on GitHub
17+
link: https://github.com/tngan/samlify
18+
19+
features:
20+
- title: Simple and Active Maintenance
21+
details: Easy to use API with active community support and regular updates
22+
- title: Identity and Service Provider
23+
details: Includes both Identity Provider and Service Provider implementations
24+
- title: Highly Configurable
25+
details: Flexible configuration options to fit your specific use case
26+
---
27+
28+
## Installation
29+
30+
To install the stable version
31+
32+
```bash
33+
npm install samlify
34+
```
35+
36+
or
37+
38+
```bash
39+
yarn add samlify
40+
```
41+
42+
## Use cases
43+
44+
- IdP-initiated Single Sign On
45+
- IdP-initiated Single Log-out
46+
- SP-initiated Single Sign On
47+
- SP-initiated Single Log-out (in development)
48+
49+
Simple solution of Identity Provider is provided in this module for test and educational use. Work with other 3rd party Identity Provider is also supported.
50+
51+
## Glimpse of code
52+
53+
::: warning API Changes
54+
**API is changed since v2. All file attributes like metadata and keyFile, it's expected to be normalized as string. It allows easy integration with database storage and import from local file system.**
55+
56+
**The constructor of entity is also modified to accept a single configuration object instead of putting metadata and advanced configurations in separate arguments.**
57+
:::
58+
59+
```javascript
60+
const saml = require('samlify');
61+
// configure a service provider
62+
const sp = saml.ServiceProvider({
63+
metadata: fs.readFileSync('./metadata_sp.xml')
64+
});
65+
// configure the corresponding identity provider
66+
const idp = saml.IdentityProvider({
67+
metadata: fs.readFileSync('./metadata_idp.xml')
68+
});
69+
// parse when receive a SAML Response from IdP
70+
router.post('/acs', (req, res) => {
71+
sp.parseLoginResponse(idp, 'post', req)
72+
.then(parseResult => {
73+
// Write your own validation and render function here
74+
})
75+
.catch(console.error);
76+
});
77+
```
78+
79+
Our default validation is to validate signature and the issuer name of Identity Provider. The code base is self explained. More use cases are provided in this documentation to fit in the real world application.
80+
81+
## License
82+
83+
MIT
84+
85+
---
86+
87+
<div style="font-size: 0.9em; color: #666;">
88+
<a href="https://www.flaticon.com/free-icons/password" title="password icons">Password icons created by Pixel perfect - Flaticon</a>
89+
</div>
90+

package.json

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313
"typings": "types/index.d.ts",
1414
"scripts": {
1515
"build": "yarn audit;make rebuild",
16-
"docs": "docsify serve -o docs",
16+
"docs:dev": "vitepress dev docs",
17+
"docs:build": "vitepress build docs",
18+
"docs:preview": "vitepress preview docs",
1719
"lint": "tslint -p .",
1820
"lint:fix": "tslint -p . --fix",
1921
"pretest": "make pretest",
20-
"test": "NODE_ENV=test nyc ava",
21-
"coverage": "nyc report --reporter=text-lcov | coveralls",
22+
"test": "NODE_ENV=test vitest run",
23+
"test:watch": "NODE_ENV=test vitest",
24+
"coverage": "vitest run --coverage",
2225
"hooks:postinstall": "ln -sf $PWD/.pre-commit.sh $PWD/.git/hooks/pre-commit"
2326
},
2427
"contributors": [
@@ -45,30 +48,17 @@
4548
},
4649
"devDependencies": {
4750
"@authenio/samlify-xsd-schema-validator": "^1.0.5",
48-
"@ava/typescript": "^1.1.1",
4951
"@types/node": "^11.11.3",
5052
"@types/node-forge": "^1.0.1",
5153
"@types/node-rsa": "^1.1.1",
5254
"@types/pako": "^1.0.1",
5355
"@types/uuid": "^8.3.4",
5456
"@types/xmldom": "^0.1.31",
55-
"ava": "^4.1.0",
56-
"coveralls": "^3.1.1",
57-
"nyc": "^15.1.0",
5857
"timekeeper": "^2.2.0",
5958
"ts-node": "^10.7.0",
6059
"tslint": "^6.1.3",
61-
"typescript": "^4.4.2"
62-
},
63-
"ava": {
64-
"extensions": [
65-
"ts"
66-
],
67-
"require": [
68-
"ts-node/register"
69-
],
70-
"files": [
71-
"!**/*.d.ts"
72-
]
60+
"typescript": "^4.4.2",
61+
"vitepress": "^1.0.0",
62+
"vitest": "^1.0.0"
7363
}
7464
}

0 commit comments

Comments
 (0)