@hellocoop/nextjs 3.2.8 → 3.2.9-canary.2
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 +1 -2
- package/dist/app.d.ts +4 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +20 -8
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +3 -2
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +11 -7
- package/package.json +70 -70
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
[Hellō](https://hello.dev) is an identity network that provides login and registration using the standard OpenID Connect protocol. Hellō offers your users choice between all popular social login providers.
|
|
4
4
|
|
|
5
5
|
This [Next.js](https://nextjs.org/) package provides:
|
|
6
|
+
|
|
6
7
|
- an endpoint that handles all protocol interactions and sets an encrypted cookie with the the logged in user's information.
|
|
7
8
|
- convenience functions to retrieve the user's information from the cookie
|
|
8
9
|
- React components for buttons and logged in context
|
|
9
10
|
|
|
10
|
-
|
|
11
11
|
The [Hellō Next.js Sample](https://github.com/hellocoop/hello-nextjs-sample) uses this package and [npx `@hellocoop/quickstart --nextjs`](https://www.hello.dev/docs/sdks/quickstart#nextjs) to be configured in seconds. Check it out deployed on [Vercel](https://hello-nextjs-sample.vercel.app).
|
|
12
12
|
|
|
13
13
|
See the [Next.js Quickstart documentation](https://www.hello.dev/docs/quickstarts/nextjs) for how to add Hellō to your Next.js app in minutes, and the [Next.js SDK documentation](https://www.hello.dev/docs/sdks/nextjs) for details.
|
|
14
|
-
|
package/dist/app.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ declare module 'next/server' {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
type HandlerFunction = (req: NextRequest) => Promise<NextResponse>;
|
|
10
|
-
export declare const appAuth: (config: Config) =>
|
|
10
|
+
export declare const appAuth: (config: Config) => {
|
|
11
|
+
GET: HandlerFunction;
|
|
12
|
+
POST: HandlerFunction;
|
|
13
|
+
};
|
|
11
14
|
export {};
|
|
12
15
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAOH,MAAM,EACT,MAAM,gBAAgB,CAAA;AAEvB,OAAO,QAAQ,aAAa,CAAC;IACzB,UAAU,WAAW;QACjB,IAAI,CAAC,EAAE,IAAI,CAAA;KACd;CACJ;AA6FD,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;AAiClE,eAAO,MAAM,OAAO,WAAY,MAAM;;;CAKrC,CAAA"}
|
package/dist/app.js
CHANGED
|
@@ -26,11 +26,15 @@ function urlSearchParamsToObject(params) {
|
|
|
26
26
|
}
|
|
27
27
|
const convertToHelloRequest = (req, res) => {
|
|
28
28
|
return {
|
|
29
|
-
headers: () => {
|
|
29
|
+
headers: () => {
|
|
30
|
+
return headersToObject(req.headers);
|
|
31
|
+
},
|
|
30
32
|
query: urlSearchParamsToObject(req.nextUrl.searchParams),
|
|
31
33
|
path: req.nextUrl.pathname,
|
|
32
34
|
getAuth: () => req.auth,
|
|
33
|
-
setAuth: (auth) => {
|
|
35
|
+
setAuth: (auth) => {
|
|
36
|
+
req.auth = auth;
|
|
37
|
+
},
|
|
34
38
|
method: req.method,
|
|
35
39
|
body: req.body,
|
|
36
40
|
loginSyncWrapper: (loginSync, params) => {
|
|
@@ -52,8 +56,8 @@ const convertToHelloResponse = (res) => {
|
|
|
52
56
|
res.body = data;
|
|
53
57
|
res.headers.set('Content-Type', 'text/html');
|
|
54
58
|
},
|
|
55
|
-
json: (json) => res.json = json,
|
|
56
|
-
redirect: (url) => res.redirect = url,
|
|
59
|
+
json: (json) => (res.json = json),
|
|
60
|
+
redirect: (url) => (res.redirect = url),
|
|
57
61
|
setCookie: (name, value, options) => {
|
|
58
62
|
res.headers.append('Set-Cookie', (0, cookie_1.serialize)(name, value, options));
|
|
59
63
|
},
|
|
@@ -72,12 +76,12 @@ const convertToHelloResponse = (res) => {
|
|
|
72
76
|
send: (data) => {
|
|
73
77
|
res.body = data;
|
|
74
78
|
res.headers.set('Content-Type', 'text/html');
|
|
75
|
-
}
|
|
79
|
+
},
|
|
76
80
|
};
|
|
77
81
|
},
|
|
78
82
|
};
|
|
79
83
|
};
|
|
80
|
-
const
|
|
84
|
+
const appAuthHandler = (config) => {
|
|
81
85
|
if (!api_1.isConfigured) {
|
|
82
86
|
(0, api_1.configure)(config);
|
|
83
87
|
}
|
|
@@ -92,13 +96,21 @@ const appAuth = (config) => {
|
|
|
92
96
|
if (internalResponse.redirect)
|
|
93
97
|
return server_1.NextResponse.redirect(new URL(internalResponse.redirect, req.url), { headers: internalResponse.headers });
|
|
94
98
|
if (internalResponse.json)
|
|
95
|
-
return server_1.NextResponse.json(internalResponse.json, {
|
|
99
|
+
return server_1.NextResponse.json(internalResponse.json, {
|
|
100
|
+
headers: internalResponse.headers,
|
|
101
|
+
});
|
|
96
102
|
const res = new server_1.NextResponse(internalResponse.body, {
|
|
97
103
|
status: internalResponse.status,
|
|
98
|
-
headers: internalResponse.headers
|
|
104
|
+
headers: internalResponse.headers,
|
|
99
105
|
});
|
|
100
106
|
return res;
|
|
101
107
|
};
|
|
102
108
|
return r;
|
|
103
109
|
};
|
|
110
|
+
const appAuth = (config) => {
|
|
111
|
+
return {
|
|
112
|
+
GET: appAuthHandler(config),
|
|
113
|
+
POST: appAuthHandler(config),
|
|
114
|
+
};
|
|
115
|
+
};
|
|
104
116
|
exports.appAuth = appAuth;
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,wBAAwB,CAAA;AAc1D,eAAO,MAAM,IAAI,QAAsB,OAAO,CAAC,IAAI,CAUlD,CAAA"}
|
package/dist/auth.js
CHANGED
|
@@ -17,10 +17,11 @@ api_1.PackageMetadata.setMetadata(name, version);
|
|
|
17
17
|
// https://nextjs.org/docs/app/api-reference/functions/unstable_cache
|
|
18
18
|
const auth = async function () {
|
|
19
19
|
var _a;
|
|
20
|
-
const
|
|
20
|
+
const cookieStore = await (0, headers_1.cookies)();
|
|
21
|
+
const authCookie = (_a = cookieStore.get(api_1.configuration.cookies.authName)) === null || _a === void 0 ? void 0 : _a.value;
|
|
21
22
|
if (!authCookie)
|
|
22
23
|
return definitions_1.NotLoggedIn;
|
|
23
|
-
const a = await (0, helper_server_1.decryptObj)(authCookie, api_1.configuration.secret);
|
|
24
|
+
const a = (await (0, helper_server_1.decryptObj)(authCookie, api_1.configuration.secret));
|
|
24
25
|
if (!a)
|
|
25
26
|
return definitions_1.NotLoggedIn;
|
|
26
27
|
return a;
|
package/dist/pages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,cAAc,EAEjB,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAQH,MAAM,EACT,MAAM,gBAAgB,CAAA;AAIvB,OAAO,QAAQ,MAAM,CAAC;IAClB,UAAU,cAAc;QACpB,IAAI,CAAC,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACR,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,cAAc,EAEjB,MAAM,MAAM,CAAA;AAEb,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAQH,MAAM,EACT,MAAM,gBAAgB,CAAA;AAIvB,OAAO,QAAQ,MAAM,CAAC;IAClB,UAAU,cAAc;QACpB,IAAI,CAAC,EAAE,IAAI,CAAA;KACd;CACJ;AA6DD,eAAO,MAAM,kBAAkB,YAClB,yBAAyB,KACnC,OAAO,CAAC,wBAAwB,CAAC;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAclD,CAAA;AAED,eAAO,MAAM,OAAO,QAAwB,cAAc,KAAG,OAAO,CAAC,IAAI,CAMxE,CAAA;AAED,eAAO,MAAM,QAAQ,WAAqB,MAAM,KAAG,cAUlD,CAAA;AAED,eAAO,MAAM,SAAS,WAZoB,MAAM,KAAG,cAYlB,CAAA"}
|
package/dist/pages.js
CHANGED
|
@@ -12,7 +12,9 @@ const convertToHelloRequest = (req, res) => {
|
|
|
12
12
|
query: req.query,
|
|
13
13
|
path: req.url ? (_a = (0, url_1.parse)(req.url, true)) === null || _a === void 0 ? void 0 : _a.pathname : '/',
|
|
14
14
|
getAuth: () => req.auth,
|
|
15
|
-
setAuth: (auth) => {
|
|
15
|
+
setAuth: (auth) => {
|
|
16
|
+
req.auth = auth;
|
|
17
|
+
},
|
|
16
18
|
method: req.method,
|
|
17
19
|
body: req.body,
|
|
18
20
|
frameWork: 'nextjs',
|
|
@@ -39,7 +41,7 @@ const convertToHelloResponse = (res) => {
|
|
|
39
41
|
setHeader: (name, value) => {
|
|
40
42
|
if (Array.isArray(value)) {
|
|
41
43
|
if (name.toLowerCase() === 'set-cookie') {
|
|
42
|
-
value.forEach(val => res.setHeader(name, val)); // Append each cookie individually
|
|
44
|
+
value.forEach((val) => res.setHeader(name, val)); // Append each cookie individually
|
|
43
45
|
}
|
|
44
46
|
else {
|
|
45
47
|
res.setHeader(name, value.join(', ')); // Combine array values into a single string separated by commas
|
|
@@ -49,13 +51,15 @@ const convertToHelloResponse = (res) => {
|
|
|
49
51
|
res.setHeader(name, value);
|
|
50
52
|
}
|
|
51
53
|
},
|
|
52
|
-
getHeaders: () => {
|
|
54
|
+
getHeaders: () => {
|
|
55
|
+
throw new Error('getHeaders not implemented');
|
|
56
|
+
}, // not implemented
|
|
53
57
|
status: (statusCode) => {
|
|
54
58
|
res.status(statusCode);
|
|
55
59
|
return {
|
|
56
|
-
send: (data) => res.send(data)
|
|
60
|
+
send: (data) => res.send(data),
|
|
57
61
|
};
|
|
58
|
-
}
|
|
62
|
+
},
|
|
59
63
|
};
|
|
60
64
|
};
|
|
61
65
|
const getServerSideProps = async function (context) {
|
|
@@ -63,13 +67,13 @@ const getServerSideProps = async function (context) {
|
|
|
63
67
|
const res = context.res;
|
|
64
68
|
if (req.auth)
|
|
65
69
|
return {
|
|
66
|
-
props: { auth: req.auth }
|
|
70
|
+
props: { auth: req.auth },
|
|
67
71
|
};
|
|
68
72
|
const helloReq = convertToHelloRequest(req, res);
|
|
69
73
|
const helloRes = convertToHelloResponse(context.res);
|
|
70
74
|
const auth = await (0, api_1.getAuthfromCookies)(helloReq, helloRes);
|
|
71
75
|
return {
|
|
72
|
-
props: { auth }
|
|
76
|
+
props: { auth },
|
|
73
77
|
};
|
|
74
78
|
};
|
|
75
79
|
exports.getServerSideProps = getServerSideProps;
|
package/package.json
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
2
|
+
"name": "@hellocoop/nextjs",
|
|
3
|
+
"version": "3.2.9-canary.2",
|
|
4
|
+
"description": "Next.js 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/nextjs",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./dist/index.js",
|
|
14
|
+
"./react": "./dist/react.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"nextjs",
|
|
21
|
+
"next",
|
|
22
|
+
"next.js",
|
|
23
|
+
"hello",
|
|
24
|
+
"openid",
|
|
25
|
+
"oidc",
|
|
26
|
+
"sso"
|
|
27
|
+
],
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "Hello Identity Co-op",
|
|
30
|
+
"email": "contact@hello.coop",
|
|
31
|
+
"url": "https://hello.coop"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/hellocoop/packages/issues"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"watch": "tsc --watch --declaration",
|
|
39
|
+
"prebuild": "rimraf dist node_modules",
|
|
40
|
+
"build": "tsc --declaration"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"next": ">=10",
|
|
44
|
+
"react": ">=17",
|
|
45
|
+
"react-dom": ">=17"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@hellocoop/definitions": "^1.0.9",
|
|
49
|
+
"@tsconfig/node18": "^18.2.2",
|
|
50
|
+
"@types/cookie": "^0.6.0",
|
|
51
|
+
"@types/cors": "^2.8.14",
|
|
52
|
+
"@types/react": "^18.2.21",
|
|
53
|
+
"eslint-config-next": "^13.5.1",
|
|
54
|
+
"next": "15.2.3",
|
|
55
|
+
"react": "^19.0.0",
|
|
56
|
+
"react-dom": "^19.0.0",
|
|
57
|
+
"rimraf": "^5.0.1",
|
|
58
|
+
"typescript": "^5.2.2"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@hellocoop/api": "^2.2.7",
|
|
65
|
+
"@hellocoop/helper-server": "^2.2.1",
|
|
66
|
+
"@hellocoop/react": "^3.1.9",
|
|
67
|
+
"cookie": "^1.0.1",
|
|
68
|
+
"cors": "^2.8.5",
|
|
69
|
+
"swr": "^2.2.2"
|
|
70
|
+
},
|
|
71
|
+
"gitHead": "96cc2f3fa1a3724a4a96b19cc7c5d97f04cc49f8"
|
|
72
72
|
}
|
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.
|