@wral/studio.mods.auth 0.3.7 → 1.0.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/README.md +39 -47
- package/bitbucket-pipelines.yml +25 -1
- package/dist/auth.cjs.js +326 -1467
- package/dist/auth.es.js +1081 -3093
- package/dist/lib.cjs.js +1 -1
- package/dist/lib.es.js +13 -7
- package/eslint.config.mjs +41 -34
- package/index.html +83 -18
- package/jest.config.mjs +24 -0
- package/jest.setup.mjs +5 -0
- package/package.json +15 -28
- package/src/auth.mjs +204 -69
- package/src/auth.test.mjs +97 -0
- package/src/components/auth-app.mjs +26 -0
- package/src/components/forgot-password-form.mjs +217 -0
- package/src/components/login-form.mjs +288 -0
- package/src/config.mjs +27 -0
- package/src/helper.mjs +31 -0
- package/src/helper.test.mjs +44 -0
- package/src/index.mjs +17 -0
- package/src/login-layout.mjs +32 -0
- package/src/login.mjs +20 -0
- package/src/routes/change-password.mjs +158 -0
- package/src/routes/dashboard.mjs +17 -0
- package/src/routes/index.mjs +15 -0
- package/src/state.mjs +61 -0
- package/src/state.test.mjs +58 -0
- package/src/styles.mjs +9 -0
- package/src/token.mjs +40 -0
- package/src/utils.mjs +3 -0
- package/vellum-fixture.mjs +86 -0
- package/vite.config.mjs +12 -0
- package/components.html +0 -43
- package/development.md +0 -41
- package/src/components/mod-auth-login-form.mjs +0 -133
- package/src/components/studio-change-password.mjs +0 -84
- package/src/components/studio-login.mjs +0 -94
- package/src/components/studio-profile-view.mjs +0 -56
- package/src/components/studio-reset-password.mjs +0 -110
- package/src/lib.mjs +0 -16
- package/src/tool-dummy.mjs +0 -84
- package/src/util.mjs +0 -194
- package/src/util.test.mjs +0 -171
- package/vite.config.js +0 -12
- package/web-test-runner.config.mjs +0 -28
package/README.md
CHANGED
|
@@ -1,56 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Vellum Auth Mod
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This mod provides an Authentication mechanism via JWTs.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
In a vellum project, add the following mod:
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
17
|
-
</head>
|
|
18
|
-
<body>
|
|
19
|
-
<studio-app>
|
|
20
|
-
|
|
21
|
-
<!-- Hello, World! Studio Mod -->
|
|
22
|
-
<studio-mod src="https://cdn.wral.studio/mods/auth/release/latest/auth.es.js"></studio-mod>
|
|
23
|
-
|
|
24
|
-
</studio-app>
|
|
25
|
-
</body>
|
|
26
|
-
</html>
|
|
10
|
+
<vellum-app>
|
|
11
|
+
<vellum-mod name="auth" src="https://cdn.wral.studio/mods/auth/release/v1.0.0/auth.es.js"
|
|
12
|
+
api="https://api.wral.com/auth"
|
|
13
|
+
force-login>
|
|
14
|
+
</vellum-mod>
|
|
15
|
+
</vellum-app>
|
|
27
16
|
```
|
|
28
17
|
|
|
29
|
-
|
|
18
|
+
### Attributes
|
|
19
|
+
* `api`: _required_ auth api endpoint (without version or trailing slash)
|
|
20
|
+
* `force-login`: _optional_ force login on first page load
|
|
21
|
+
* session-key: _optional_ session key to use. Defaults to `token`
|
|
22
|
+
|
|
23
|
+
### Requesting an auth token
|
|
24
|
+
|
|
25
|
+
Consuming apps that would like an Auth token should dispatch an event:
|
|
26
|
+
|
|
27
|
+
```es6
|
|
28
|
+
const callback = (token) => {
|
|
29
|
+
// do something with the token
|
|
30
|
+
};
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
The auth mod provides bearer tokens to other mods by request. Other mods can
|
|
36
|
-
request a token by publishing a `token-request` event and providing a callback.
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
/**
|
|
40
|
-
* @param {Studio} studio
|
|
41
|
-
* @return {Promise<string>} bearer token
|
|
42
|
-
*/
|
|
43
|
-
async function getToken(studio) {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
studio.pub('studio.wral::mod-auth', 'token-request', {
|
|
46
|
-
callback: (token, error) => {
|
|
47
|
-
if (error) {
|
|
48
|
-
reject(error);
|
|
49
|
-
} else {
|
|
50
|
-
resolve(token);
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
32
|
+
toolkit.dispatchAction({
|
|
33
|
+
type: 'auth:requestToken',
|
|
34
|
+
detail: { callback },
|
|
35
|
+
});
|
|
56
36
|
```
|
|
37
|
+
|
|
38
|
+
Alternatively, `lib.es.js` contains a promise-based wrapper:
|
|
39
|
+
```es6
|
|
40
|
+
import { getToken } from 'https://cdn.wral.studio/mods/auth/release/v1.0.0/lib.es.js';
|
|
41
|
+
|
|
42
|
+
const elem = document.querySelector('vellum-app'); // any element within the app
|
|
43
|
+
|
|
44
|
+
getToken(elem).then((token) => {
|
|
45
|
+
// do something with the token
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
package/bitbucket-pipelines.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
image: node:
|
|
2
|
+
image: node:22-alpine
|
|
3
3
|
|
|
4
4
|
definitions:
|
|
5
5
|
caches:
|
|
@@ -13,6 +13,10 @@ definitions:
|
|
|
13
13
|
script:
|
|
14
14
|
- npm ci
|
|
15
15
|
- npm run lint
|
|
16
|
+
after-script:
|
|
17
|
+
- pipe: docker://public.ecr.aws/cbcrnd/pipe-witness-testify
|
|
18
|
+
variables:
|
|
19
|
+
FAIL_ONLY: 'true'
|
|
16
20
|
- step: &test
|
|
17
21
|
name: Run tests
|
|
18
22
|
image: node:18
|
|
@@ -26,6 +30,10 @@ definitions:
|
|
|
26
30
|
- npm run test
|
|
27
31
|
artifacts:
|
|
28
32
|
- coverage/**
|
|
33
|
+
after-script:
|
|
34
|
+
- pipe: docker://public.ecr.aws/cbcrnd/pipe-witness-testify
|
|
35
|
+
variables:
|
|
36
|
+
FAIL_ONLY: 'true'
|
|
29
37
|
- step: &build
|
|
30
38
|
name: Build Distribution
|
|
31
39
|
caches:
|
|
@@ -35,6 +43,10 @@ definitions:
|
|
|
35
43
|
- npm run build
|
|
36
44
|
artifacts:
|
|
37
45
|
- dist/**
|
|
46
|
+
after-script:
|
|
47
|
+
- pipe: docker://public.ecr.aws/cbcrnd/pipe-witness-testify
|
|
48
|
+
variables:
|
|
49
|
+
FAIL_ONLY: 'true'
|
|
38
50
|
- step: &publish-cdn
|
|
39
51
|
name: Publish to CDN
|
|
40
52
|
script:
|
|
@@ -45,6 +57,10 @@ definitions:
|
|
|
45
57
|
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
|
|
46
58
|
S3_BUCKET: ${S3_BUCKET}/mods/${MOD_NAME:-$BITBUCKET_REPO_SLUG}/release/${BITBUCKET_TAG}
|
|
47
59
|
LOCAL_PATH: 'dist'
|
|
60
|
+
after-script:
|
|
61
|
+
- pipe: docker://public.ecr.aws/cbcrnd/pipe-witness-testify
|
|
62
|
+
variables:
|
|
63
|
+
FAIL_ONLY: 'true'
|
|
48
64
|
- step: &publish-latest
|
|
49
65
|
name: Publish to CDN as latest version
|
|
50
66
|
script:
|
|
@@ -62,6 +78,10 @@ definitions:
|
|
|
62
78
|
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
|
|
63
79
|
DISTRIBUTION_ID: ${AWS_DISTRIBUTION_ID}
|
|
64
80
|
PATHS: '/mods/${MOD_NAME:-$BITBUCKET_REPO_SLUG}/release/latest/*'
|
|
81
|
+
after-script:
|
|
82
|
+
- pipe: docker://public.ecr.aws/cbcrnd/pipe-witness-testify
|
|
83
|
+
variables:
|
|
84
|
+
FAIL_ONLY: 'true'
|
|
65
85
|
- step: &publish-npm
|
|
66
86
|
name: Publish to NPM
|
|
67
87
|
script:
|
|
@@ -73,6 +93,10 @@ definitions:
|
|
|
73
93
|
else
|
|
74
94
|
npm publish --access public --tag $BITBUCKET_TAG
|
|
75
95
|
fi
|
|
96
|
+
after-script:
|
|
97
|
+
- pipe: docker://public.ecr.aws/cbcrnd/pipe-witness-testify
|
|
98
|
+
variables:
|
|
99
|
+
FAIL_ONLY: 'true'
|
|
76
100
|
- step: &testify
|
|
77
101
|
name: Testify to the Witness
|
|
78
102
|
script:
|