@hellocoop/express 1.14.1 → 1.15.3
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 +2 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +11 -11
- package/dist/middleware.js +2 -2
- package/package.json +11 -12
package/dist/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Router, Request, Response } from 'express';
|
|
2
|
-
import { Auth, Claims } from '@hellocoop/
|
|
3
|
-
import { LoginSyncResponse, LogoutSyncResponse, Config } from '@hellocoop/
|
|
2
|
+
import { Auth, Claims } from '@hellocoop/definitions';
|
|
3
|
+
import { LoginSyncResponse, LogoutSyncResponse, Config } from '@hellocoop/api';
|
|
4
4
|
type ExpressLoginParams = {
|
|
5
5
|
token: string;
|
|
6
6
|
payload: Claims;
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAsB,MAAM,SAAS,CAAA;AAEvE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAsB,MAAM,SAAS,CAAA;AAEvE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAIH,iBAAiB,EACjB,kBAAkB,EAKlB,MAAM,EAET,MAAM,gBAAgB,CAAA;AAGvB,KAAK,kBAAkB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,KAAK,mBAAmB,GAAG;IACvB,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,KAAK,gBAAgB,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAClF,KAAK,iBAAiB,GAAG,CAAC,MAAM,EAAE,mBAAmB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAErF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,YAAY,CAAC,GAAG;IACjE,SAAS,EAAE,gBAAgB,CAAC;IAC5B,UAAU,EAAE,iBAAiB,CAAC;CACjC,CAAC;AAuDF,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,IAAI,CAAC,EAAE,IAAI,CAAC;YACZ,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QACD,UAAU,QAAQ;YAChB,SAAS,IAAI,IAAI,CAAC;SACnB;KACF;CACF;AAmBH,eAAO,MAAM,IAAI,WAAsB,MAAM,KAAG,MAiC/C,CAAA"}
|
package/dist/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.auth = void 0;
|
|
4
4
|
const express_1 = require("express");
|
|
5
5
|
const cookie_1 = require("cookie");
|
|
6
|
-
const
|
|
6
|
+
const api_1 = require("@hellocoop/api");
|
|
7
7
|
const convertToHelloRequest = (req, res) => {
|
|
8
8
|
return {
|
|
9
9
|
headers: () => req.headers,
|
|
@@ -25,7 +25,7 @@ const convertToHelloRequest = (req, res) => {
|
|
|
25
25
|
const convertToHelloResponse = (res) => {
|
|
26
26
|
return {
|
|
27
27
|
clearAuth: () => {
|
|
28
|
-
const { name, value, options } = (0,
|
|
28
|
+
const { name, value, options } = (0, api_1.clearAuthCookieParams)();
|
|
29
29
|
res.setHeader('Set-Cookie', (0, cookie_1.serialize)(name, value, options));
|
|
30
30
|
},
|
|
31
31
|
send: (data) => res.type('text/html').send(data),
|
|
@@ -70,32 +70,32 @@ const convertToHelloResponse = (res) => {
|
|
|
70
70
|
// })
|
|
71
71
|
// Configure plugin options if needed
|
|
72
72
|
const auth = function (config) {
|
|
73
|
-
if (!
|
|
74
|
-
(0,
|
|
73
|
+
if (!api_1.isConfigured) {
|
|
74
|
+
(0, api_1.configure)(config);
|
|
75
75
|
}
|
|
76
|
-
console.log({ isConfigured:
|
|
76
|
+
console.log({ isConfigured: api_1.isConfigured, configuration: api_1.configuration });
|
|
77
77
|
const r = (0, express_1.Router)();
|
|
78
78
|
r.use(async (req, res, next) => {
|
|
79
79
|
const helloReq = convertToHelloRequest(req, res);
|
|
80
80
|
req.getAuth = async () => {
|
|
81
|
-
req.auth = await (0,
|
|
81
|
+
req.auth = await (0, api_1.getAuthfromCookies)(helloReq);
|
|
82
82
|
return req.auth;
|
|
83
83
|
};
|
|
84
84
|
res.clearAuth = () => {
|
|
85
|
-
const { name, value, options } = (0,
|
|
85
|
+
const { name, value, options } = (0, api_1.clearAuthCookieParams)();
|
|
86
86
|
res.setHeader('Set-Cookie', (0, cookie_1.serialize)(name, value, options));
|
|
87
87
|
};
|
|
88
88
|
next();
|
|
89
89
|
});
|
|
90
|
-
r.post(
|
|
90
|
+
r.post(api_1.configuration.apiRoute, (0, express_1.text)(), async (req, res) => {
|
|
91
91
|
const helloReq = convertToHelloRequest(req, res);
|
|
92
92
|
const helloRes = convertToHelloResponse(res);
|
|
93
|
-
await (0,
|
|
93
|
+
await (0, api_1.router)(helloReq, helloRes);
|
|
94
94
|
});
|
|
95
|
-
r.get(
|
|
95
|
+
r.get(api_1.configuration.apiRoute, (0, express_1.text)(), async (req, res) => {
|
|
96
96
|
const helloReq = convertToHelloRequest(req, res);
|
|
97
97
|
const helloRes = convertToHelloResponse(res);
|
|
98
|
-
await (0,
|
|
98
|
+
await (0, api_1.router)(helloReq, helloRes);
|
|
99
99
|
});
|
|
100
100
|
return r;
|
|
101
101
|
};
|
package/dist/middleware.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setAuth = exports.unauthorized = exports.redirect = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("@hellocoop/api");
|
|
5
5
|
const redirect = function (target) {
|
|
6
6
|
return async (req, res, next) => {
|
|
7
7
|
const auth = await req.getAuth();
|
|
@@ -17,7 +17,7 @@ const unauthorized = async (req, res, next) => {
|
|
|
17
17
|
if (auth.isLoggedIn)
|
|
18
18
|
next();
|
|
19
19
|
else
|
|
20
|
-
res.setHeader('WWW-Authenticate', `Hello ${
|
|
20
|
+
res.setHeader('WWW-Authenticate', `Hello ${api_1.configuration.clientId}`).status(401).send();
|
|
21
21
|
};
|
|
22
22
|
exports.unauthorized = unauthorized;
|
|
23
23
|
const setAuth = async (req, res, next) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hellocoop/express",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.3",
|
|
4
4
|
"description": "Express SDK for Hellō https://hello.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,21 +36,19 @@
|
|
|
36
36
|
"scripts": {
|
|
37
37
|
"test": "npm run build && npx playwright test",
|
|
38
38
|
"watch": "tsc --watch --declaration",
|
|
39
|
-
"
|
|
40
|
-
"build
|
|
41
|
-
"build:src": "tsc --declaration"
|
|
39
|
+
"prebuild": "rimraf dist node_modules",
|
|
40
|
+
"build": "tsc --declaration"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
44
43
|
"express": "^4"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@hellocoop/mockin": "^1.0.4",
|
|
48
|
-
"@hellocoop/types": "~1.1.6",
|
|
49
47
|
"@playwright/test": "^1.42.1",
|
|
50
48
|
"@tsconfig/node18": "^18.2.2",
|
|
51
|
-
"@types/cookie": "^0.
|
|
49
|
+
"@types/cookie": "^0.6.0",
|
|
52
50
|
"@types/express": "^4.17.20",
|
|
53
|
-
"@types/node": "
|
|
51
|
+
"@types/node": "*",
|
|
54
52
|
"express": "^4.18.2",
|
|
55
53
|
"rimraf": "^5.0.1",
|
|
56
54
|
"typescript": "^5.2.2"
|
|
@@ -59,11 +57,12 @@
|
|
|
59
57
|
"node": ">=18"
|
|
60
58
|
},
|
|
61
59
|
"dependencies": {
|
|
62
|
-
"@hellocoop/
|
|
63
|
-
"@hellocoop/
|
|
64
|
-
"@hellocoop/
|
|
65
|
-
"cookie": "^0.
|
|
60
|
+
"@hellocoop/api": "^2.0.3",
|
|
61
|
+
"@hellocoop/definitions": "^1.0.3",
|
|
62
|
+
"@hellocoop/helper-server": "^2.0.3",
|
|
63
|
+
"cookie": "^1.0.1",
|
|
66
64
|
"cors": "^2.8.5",
|
|
67
65
|
"dotenv": "^16.3.1"
|
|
68
|
-
}
|
|
66
|
+
},
|
|
67
|
+
"gitHead": "018e57826706471620d6ac09e66121e53877c87e"
|
|
69
68
|
}
|