@hellocoop/fastify 1.14.5 → 1.14.7-canary.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/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +13 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +4 -2
- package/package.json +62 -62
- package/LICENSE +0 -21
package/dist/auth.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,kBAAkB,EAGlB,oBAAoB,
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,kBAAkB,EAGlB,oBAAoB,EACvB,MAAM,SAAS,CAAA;AAMhB,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EASH,MAAM,EAET,MAAM,gBAAgB,CAAA;AA6DvB,OAAO,QAAQ,SAAS,CAAC;IACrB,UAAU,cAAc;QACpB,IAAI,CAAC,EAAE,IAAI,CAAA;QACX,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAC/B;IACD,UAAU,YAAY;QAClB,SAAS,EAAE,MAAM,IAAI,CAAA;KACxB;CACJ;AAED,MAAM,WAAW,WAAY,SAAQ,oBAAoB,EAAE,MAAM;CAAG;AAgCpE,eAAO,MAAM,IAAI,iCAAkB,CAAA"}
|
package/dist/auth.js
CHANGED
@@ -15,11 +15,17 @@ const { name, version } = package_json_1.default;
|
|
15
15
|
api_1.PackageMetadata.setMetadata(name, version);
|
16
16
|
const convertToHelloRequest = (req, res) => {
|
17
17
|
return {
|
18
|
-
headers: () => {
|
18
|
+
headers: () => {
|
19
|
+
return req.headers;
|
20
|
+
},
|
19
21
|
query: req.query,
|
20
22
|
path: req?.routeOptions?.url || '',
|
21
|
-
getAuth: () => {
|
22
|
-
|
23
|
+
getAuth: () => {
|
24
|
+
return req.auth;
|
25
|
+
},
|
26
|
+
setAuth: (auth) => {
|
27
|
+
req.auth = auth;
|
28
|
+
},
|
23
29
|
method: req.method,
|
24
30
|
body: req.body,
|
25
31
|
frameWork: 'fastify',
|
@@ -43,12 +49,14 @@ const convertToHelloResponse = (res) => {
|
|
43
49
|
setCookie: (name, value, options) => {
|
44
50
|
res.header('Set-Cookie', (0, cookie_1.serialize)(name, value, options));
|
45
51
|
},
|
46
|
-
getHeaders: () => {
|
52
|
+
getHeaders: () => {
|
53
|
+
return res.getHeaders();
|
54
|
+
},
|
47
55
|
setHeader: (name, value) => res.header(name, value),
|
48
56
|
status: (statusCode) => {
|
49
57
|
res.code(statusCode);
|
50
58
|
return {
|
51
|
-
send: (data) => res.send(data)
|
59
|
+
send: (data) => res.send(data),
|
52
60
|
};
|
53
61
|
},
|
54
62
|
};
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { auth, HelloConfig } from './auth';
|
2
2
|
export default auth;
|
3
3
|
export { auth as helloAuth, HelloConfig };
|
4
|
-
export { LoginSyncResponse, LogoutSyncResponse, LoginSyncParams } from '@hellocoop/api';
|
4
|
+
export { LoginSyncResponse, LogoutSyncResponse, LoginSyncParams, } from '@hellocoop/api';
|
5
5
|
export { redirect, unauthorized, setAuth } from './middleware';
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC1C,eAAe,IAAI,CAAA;AACnB,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,WAAW,EAAE,CAAA;AACzC,OAAO,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAC1C,eAAe,IAAI,CAAA;AACnB,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,WAAW,EAAE,CAAA;AACzC,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAClB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/middleware.d.ts
CHANGED
@@ -7,5 +7,5 @@ declare module 'fastify' {
|
|
7
7
|
}
|
8
8
|
export declare const redirect: (target: string) => (request: FastifyRequest, reply: FastifyReply) => Promise<undefined>;
|
9
9
|
export declare const unauthorized: (request: FastifyRequest, reply: FastifyReply) => Promise<undefined>;
|
10
|
-
export declare const setAuth: (request: FastifyRequest
|
10
|
+
export declare const setAuth: (request: FastifyRequest) => Promise<void>;
|
11
11
|
//# sourceMappingURL=middleware.d.ts.map
|
package/dist/middleware.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAG7C,OAAO,QAAQ,SAAS,CAAC;IACrB,UAAU,cAAc;QACpB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAC/B;CACJ;AAED,eAAO,MAAM,QAAQ,WAAY,MAAM,eACZ,cAAc,SAAS,YAAY,uBAQ7D,CAAA;AAED,eAAO,MAAM,YAAY,YACZ,cAAc,SAChB,YAAY,uBAStB,CAAA;AAED,eAAO,MAAM,OAAO,YAAmB,cAAc,kBAEpD,CAAA"}
|
package/dist/middleware.js
CHANGED
@@ -17,12 +17,14 @@ exports.redirect = redirect;
|
|
17
17
|
const unauthorized = async (request, reply) => {
|
18
18
|
const auth = await request.getAuth();
|
19
19
|
if (!auth.isLoggedIn) {
|
20
|
-
reply
|
20
|
+
reply
|
21
|
+
.header('WWW-Authenticate', `Hello ${api_1.configuration.clientId}`)
|
22
|
+
.status(401);
|
21
23
|
return reply.send();
|
22
24
|
}
|
23
25
|
};
|
24
26
|
exports.unauthorized = unauthorized;
|
25
|
-
const setAuth = async (request
|
27
|
+
const setAuth = async (request) => {
|
26
28
|
await request.getAuth();
|
27
29
|
};
|
28
30
|
exports.setAuth = setAuth;
|
package/package.json
CHANGED
@@ -1,64 +1,64 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
2
|
+
"name": "@hellocoop/fastify",
|
3
|
+
"version": "1.14.7-canary.0",
|
4
|
+
"description": "Fastify SDK for Hellō https://hello.dev",
|
5
|
+
"repository": {
|
6
|
+
"type": "git",
|
7
|
+
"url": "git+https://github.com/hellocoop/packages.git"
|
8
|
+
},
|
9
|
+
"homepage": "https://www.hello.dev/docs/sdks/fastify",
|
10
|
+
"main": "./dist/index.js",
|
11
|
+
"types": "./dist/index.d.ts",
|
12
|
+
"exports": {
|
13
|
+
".": "./dist/index.js"
|
14
|
+
},
|
15
|
+
"files": [
|
16
|
+
"dist/"
|
17
|
+
],
|
18
|
+
"keywords": [
|
19
|
+
"fastify",
|
20
|
+
"nodejs",
|
21
|
+
"node.js",
|
22
|
+
"hello",
|
23
|
+
"openid",
|
24
|
+
"oidc",
|
25
|
+
"sso"
|
26
|
+
],
|
27
|
+
"author": {
|
28
|
+
"name": "Hello Identity Co-op",
|
29
|
+
"email": "contact@hello.coop",
|
30
|
+
"url": "https://hello.coop"
|
31
|
+
},
|
32
|
+
"license": "MIT",
|
33
|
+
"bugs": {
|
34
|
+
"url": "https://github.com/hellocoop/packages/issues"
|
35
|
+
},
|
36
|
+
"scripts": {
|
37
|
+
"watch": "tsc --watch --declaration",
|
38
|
+
"prebuild": "rimraf dist node_modules",
|
39
|
+
"build": "tsc --declaration",
|
40
|
+
"test": "npm run build && docker compose -f ./spec/docker-compose.yml up --build --abort-on-container-exit",
|
41
|
+
"test:debug": "npm run build && docker compose -f ./spec/docker-compose.yml -f ./spec/docker-compose.debug.yml up --build --abort-on-container-exit",
|
42
|
+
"spec": "wait-on http://mockin:3333/mock && mocha './spec/**/*.spec.mjs'",
|
43
|
+
"spec:debug": "wait-on http://mockin:3333/mock && node --inspect-brk=0.0.0.0 ./node_modules/.bin/mocha './spec/**/*.spec.mjs'"
|
44
|
+
},
|
45
|
+
"peerDependencies": {
|
46
|
+
"fastify": "^4 || ^5"
|
47
|
+
},
|
48
|
+
"devDependencies": {
|
49
|
+
"@tsconfig/node18": "^18.2.2",
|
50
|
+
"fastify": "^5.3.0",
|
51
|
+
"rimraf": "^5.0.1",
|
52
|
+
"typescript": "^5.2.2"
|
53
|
+
},
|
54
|
+
"engines": {
|
55
|
+
"node": ">=18"
|
56
|
+
},
|
57
|
+
"dependencies": {
|
58
|
+
"@fastify/formbody": "^8.0.2",
|
59
|
+
"@hellocoop/api": "^2.2.7",
|
60
|
+
"dotenv": "^16.3.1",
|
61
|
+
"fastify-plugin": "^5.0.1"
|
62
|
+
},
|
63
|
+
"gitHead": "96cc2f3fa1a3724a4a96b19cc7c5d97f04cc49f8"
|
64
64
|
}
|
package/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2023 Hellō
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|