mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
42 Commits
chore/docs
...
@next-auth
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5dd901b03 | ||
|
|
62f672ae30 | ||
|
|
2c669b32fc | ||
|
|
2dea8919e5 | ||
|
|
6fdb0da6eb | ||
|
|
5c4a9a697d | ||
|
|
eddd8fd7f9 | ||
|
|
b74bfc68e8 | ||
|
|
0a140cdf87 | ||
|
|
157269e0fb | ||
|
|
221bc8e99c | ||
|
|
f856363ac8 | ||
|
|
f3291025e6 | ||
|
|
bc0912cc71 | ||
|
|
b19b2bcb3f | ||
|
|
63c2a15717 | ||
|
|
9209b48dbe | ||
|
|
0fcc6a0d04 | ||
|
|
cbf8c7a59f | ||
|
|
0e6c51adec | ||
|
|
c4352a7d56 | ||
|
|
7e91d7df54 | ||
|
|
c1424136db | ||
|
|
f2a07932b9 | ||
|
|
25c7ce1d2b | ||
|
|
227a233bd8 | ||
|
|
cf9f133aa3 | ||
|
|
2301c1be44 | ||
|
|
6e408e24bf | ||
|
|
f277989c69 | ||
|
|
6146e93288 | ||
|
|
1ff565da6c | ||
|
|
41f75cf870 | ||
|
|
dd591ed8d0 | ||
|
|
297bc2317f | ||
|
|
b170138e70 | ||
|
|
a307079e0f | ||
|
|
d52b7a6b7d | ||
|
|
30b69a07eb | ||
|
|
0d1757814f | ||
|
|
068f9b50b8 | ||
|
|
dac490b7a1 |
1
.github/ISSUE_TEMPLATE/3_bug_adapter.yml
vendored
1
.github/ISSUE_TEMPLATE/3_bug_adapter.yml
vendored
@@ -31,6 +31,7 @@ body:
|
||||
- "@next-auth/pouchdb-adapter"
|
||||
- "@next-auth/prisma-adapter"
|
||||
- "@next-auth/sequelize-adapter"
|
||||
- "@next-auth/supabase-adapter"
|
||||
- "@next-auth/typeorm-legacy-adapter"
|
||||
- "@next-auth/upstash-redis-adapter"
|
||||
- "@next-auth/xata-adapter"
|
||||
|
||||
2
.github/actions/issue-validator/.gitignore
vendored
Normal file
2
.github/actions/issue-validator/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
!dist
|
||||
!package-lock.json
|
||||
7
.github/actions/issue-validator/index.mjs
vendored
Normal file
7
.github/actions/issue-validator/index.mjs
vendored
Normal file
File diff suppressed because one or more lines are too long
652
.github/actions/issue-validator/licenses.txt
vendored
Normal file
652
.github/actions/issue-validator/licenses.txt
vendored
Normal file
@@ -0,0 +1,652 @@
|
||||
@actions/core
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/github
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@octokit/auth-token
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@octokit/core
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@octokit/endpoint
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2018 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@octokit/graphql
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2018 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@octokit/plugin-paginate-rest
|
||||
MIT
|
||||
MIT License Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@octokit/plugin-rest-endpoint-methods
|
||||
MIT
|
||||
MIT License Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@octokit/request
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2018 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@octokit/request-error
|
||||
MIT
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
@vercel/ncc
|
||||
MIT
|
||||
Copyright 2018 ZEIT, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
before-after-hook
|
||||
Apache-2.0
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2018 Gregor Martynus and other contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
deprecation
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Gregor Martynus and contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
is-plain-object
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
node-fetch
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 David Frank
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
|
||||
once
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
root
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2018-2021, Iain Collins
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
tr46
|
||||
MIT
|
||||
|
||||
tunnel
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
universal-user-agent
|
||||
ISC
|
||||
# [ISC License](https://spdx.org/licenses/ISC)
|
||||
|
||||
Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m)
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
uuid
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
webidl-conversions
|
||||
BSD-2-Clause
|
||||
# The BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2014, Domenic Denicola
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
whatwg-url
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015–2016 Sebastian Mayr
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
wrappy
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
445
.github/actions/issue-validator/package-lock.json
generated
vendored
Normal file
445
.github/actions/issue-validator/package-lock.json
generated
vendored
Normal file
@@ -0,0 +1,445 @@
|
||||
{
|
||||
"name": "issue-validator",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@actions/core": "1.10.0",
|
||||
"@actions/github": "5.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "0.34.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/github": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||
"integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==",
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@octokit/core": "^3.6.0",
|
||||
"@octokit/plugin-paginate-rest": "^2.17.0",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^5.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||
"dependencies": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/auth-token": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz",
|
||||
"integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/core": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz",
|
||||
"integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==",
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^2.4.4",
|
||||
"@octokit/graphql": "^4.5.8",
|
||||
"@octokit/request": "^5.6.3",
|
||||
"@octokit/request-error": "^2.0.5",
|
||||
"@octokit/types": "^6.0.3",
|
||||
"before-after-hook": "^2.2.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/endpoint": {
|
||||
"version": "6.0.12",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz",
|
||||
"integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/graphql": {
|
||||
"version": "4.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz",
|
||||
"integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==",
|
||||
"dependencies": {
|
||||
"@octokit/request": "^5.6.0",
|
||||
"@octokit/types": "^6.0.3",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/openapi-types": {
|
||||
"version": "12.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.10.1.tgz",
|
||||
"integrity": "sha512-P+SukKanjFY0ZhsK6wSVnQmxTP2eVPPE8OPSNuxaMYtgVzwJZgfGdwlYjf4RlRU4vLEw4ts2fsE2icG4nZ5ddQ=="
|
||||
},
|
||||
"node_modules/@octokit/plugin-paginate-rest": {
|
||||
"version": "2.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz",
|
||||
"integrity": "sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.40.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=2"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/plugin-rest-endpoint-methods": {
|
||||
"version": "5.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz",
|
||||
"integrity": "sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.39.0",
|
||||
"deprecation": "^2.3.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=3"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request": {
|
||||
"version": "5.6.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz",
|
||||
"integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==",
|
||||
"dependencies": {
|
||||
"@octokit/endpoint": "^6.0.1",
|
||||
"@octokit/request-error": "^2.1.0",
|
||||
"@octokit/types": "^6.16.1",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request-error": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz",
|
||||
"integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3",
|
||||
"deprecation": "^2.0.0",
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/types": {
|
||||
"version": "6.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.40.0.tgz",
|
||||
"integrity": "sha512-MFZOU5r8SwgJWDMhrLUSvyJPtVsqA6VnbVI3TNbsmw+Jnvrktzvq2fYES/6RiJA/5Ykdwq4mJmtlYUfW7CGjmw==",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^12.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vercel/ncc": {
|
||||
"version": "0.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.34.0.tgz",
|
||||
"integrity": "sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"ncc": "dist/ncc/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/before-after-hook": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.2.tgz",
|
||||
"integrity": "sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ=="
|
||||
},
|
||||
"node_modules/deprecation": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
|
||||
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
|
||||
},
|
||||
"node_modules/is-plain-object": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.7",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||
},
|
||||
"node_modules/tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
||||
"engines": {
|
||||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/universal-user-agent": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
||||
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||
"requires": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
},
|
||||
"@actions/github": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz",
|
||||
"integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==",
|
||||
"requires": {
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@octokit/core": "^3.6.0",
|
||||
"@octokit/plugin-paginate-rest": "^2.17.0",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^5.13.0"
|
||||
}
|
||||
},
|
||||
"@actions/http-client": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||
"requires": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"@octokit/auth-token": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz",
|
||||
"integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==",
|
||||
"requires": {
|
||||
"@octokit/types": "^6.0.3"
|
||||
}
|
||||
},
|
||||
"@octokit/core": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz",
|
||||
"integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==",
|
||||
"requires": {
|
||||
"@octokit/auth-token": "^2.4.4",
|
||||
"@octokit/graphql": "^4.5.8",
|
||||
"@octokit/request": "^5.6.3",
|
||||
"@octokit/request-error": "^2.0.5",
|
||||
"@octokit/types": "^6.0.3",
|
||||
"before-after-hook": "^2.2.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/endpoint": {
|
||||
"version": "6.0.12",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz",
|
||||
"integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==",
|
||||
"requires": {
|
||||
"@octokit/types": "^6.0.3",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/graphql": {
|
||||
"version": "4.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz",
|
||||
"integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==",
|
||||
"requires": {
|
||||
"@octokit/request": "^5.6.0",
|
||||
"@octokit/types": "^6.0.3",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/openapi-types": {
|
||||
"version": "12.10.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.10.1.tgz",
|
||||
"integrity": "sha512-P+SukKanjFY0ZhsK6wSVnQmxTP2eVPPE8OPSNuxaMYtgVzwJZgfGdwlYjf4RlRU4vLEw4ts2fsE2icG4nZ5ddQ=="
|
||||
},
|
||||
"@octokit/plugin-paginate-rest": {
|
||||
"version": "2.21.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz",
|
||||
"integrity": "sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==",
|
||||
"requires": {
|
||||
"@octokit/types": "^6.40.0"
|
||||
}
|
||||
},
|
||||
"@octokit/plugin-rest-endpoint-methods": {
|
||||
"version": "5.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz",
|
||||
"integrity": "sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==",
|
||||
"requires": {
|
||||
"@octokit/types": "^6.39.0",
|
||||
"deprecation": "^2.3.1"
|
||||
}
|
||||
},
|
||||
"@octokit/request": {
|
||||
"version": "5.6.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz",
|
||||
"integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==",
|
||||
"requires": {
|
||||
"@octokit/endpoint": "^6.0.1",
|
||||
"@octokit/request-error": "^2.1.0",
|
||||
"@octokit/types": "^6.16.1",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@octokit/request-error": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz",
|
||||
"integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==",
|
||||
"requires": {
|
||||
"@octokit/types": "^6.0.3",
|
||||
"deprecation": "^2.0.0",
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"@octokit/types": {
|
||||
"version": "6.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.40.0.tgz",
|
||||
"integrity": "sha512-MFZOU5r8SwgJWDMhrLUSvyJPtVsqA6VnbVI3TNbsmw+Jnvrktzvq2fYES/6RiJA/5Ykdwq4mJmtlYUfW7CGjmw==",
|
||||
"requires": {
|
||||
"@octokit/openapi-types": "^12.10.0"
|
||||
}
|
||||
},
|
||||
"@vercel/ncc": {
|
||||
"version": "0.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.34.0.tgz",
|
||||
"integrity": "sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A==",
|
||||
"dev": true
|
||||
},
|
||||
"before-after-hook": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.2.tgz",
|
||||
"integrity": "sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ=="
|
||||
},
|
||||
"deprecation": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
|
||||
"integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="
|
||||
},
|
||||
"is-plain-object": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.7",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
|
||||
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
|
||||
"requires": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||
},
|
||||
"tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
|
||||
},
|
||||
"universal-user-agent": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
|
||||
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||
},
|
||||
"webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
|
||||
},
|
||||
"whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"requires": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
|
||||
}
|
||||
}
|
||||
}
|
||||
14
.github/actions/issue-validator/package.json
vendored
Normal file
14
.github/actions/issue-validator/package.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"private": true,
|
||||
"exports": "./index.mjs",
|
||||
"scripts": {
|
||||
"build": "ncc -m -o . build src/index.mjs --license licenses.txt"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "0.34.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "1.10.0",
|
||||
"@actions/github": "5.1.1"
|
||||
}
|
||||
}
|
||||
38
.github/actions/issue-validator/repro.md
vendored
Normal file
38
.github/actions/issue-validator/repro.md
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
We cannot recreate the issue with the provided information. **Please add a reproduction in order for us to be able to investigate.**
|
||||
|
||||
### **Why was this issue marked with the `incomplete` label?**
|
||||
|
||||
To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository ([template](https://github.com/nextauthjs/next-auth-example)), but you can also use a tool like [CodeSandbox](https://codesandbox.io/s/github/nextauthjs/next-auth-example/tree/main) or [StackBlitz](https://stackblitz.com/fork/github/nextauthjs/next-auth-example).
|
||||
|
||||
To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as **minimal** as possible. This means that you should **remove unnecessary code, files, and dependencies** that do not contribute to the issue.
|
||||
|
||||
Please test your reproduction against the latest version of NextAuth.js (`next-auth@latest`) to make sure your issue has not already been fixed.
|
||||
|
||||
### **I added a link, why was it still marked?**
|
||||
|
||||
Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "[example.com](http://example.com/)", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.
|
||||
|
||||
### **What happens if I don't provide a sufficient minimal reproduction?**
|
||||
|
||||
Issues with the `incomplete` label that receives no meaningful activity (e.g. new comments with a reproduction link) are automatically closed and locked after 30 days.
|
||||
|
||||
If your issue has _not_ been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.
|
||||
|
||||
### **I did not open this issue, but it is relevant to me, what can I do to help?**
|
||||
|
||||
Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please **do not** comment "I have the same issue" without repro steps). Then, we can sort issues by votes to prioritize.
|
||||
|
||||
### **I think my reproduction is good enough, why aren't you looking into it quicker?**
|
||||
|
||||
We look into every NextAuth.js issue and constantly monitor open issues for new comments.
|
||||
|
||||
However, sometimes we might miss one or two. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.
|
||||
|
||||
Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.
|
||||
|
||||
### **Useful Resources**
|
||||
|
||||
- [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve)
|
||||
- [Reporting a NextAuth.js bug](https://github.com/nextauthjs/next-auth/blob/main/.github/ISSUE_TEMPLATE/1_bug_framework.yml)
|
||||
- [How to Contribute to Open Source (Next.js)](https://www.youtube.com/watch?v=cuoNzXFLitc)
|
||||
|
||||
88
.github/actions/issue-validator/src/index.mjs
vendored
Normal file
88
.github/actions/issue-validator/src/index.mjs
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
// @ts-check
|
||||
// @ts-expect-error
|
||||
import * as github from "@actions/github"
|
||||
// @ts-expect-error
|
||||
import * as core from "@actions/core"
|
||||
import { readFileSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
|
||||
const addReproductionLabel = "incomplete"
|
||||
const __dirname =
|
||||
"/home/runner/work/nextauthjs/next-auth/.github/actions/issue-validator"
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* id :number
|
||||
* node_id :string
|
||||
* url :string
|
||||
* name :string
|
||||
* description :string
|
||||
* color :string
|
||||
* default :boolean
|
||||
* }} Label
|
||||
*
|
||||
* @typedef {{
|
||||
* pull_request: any
|
||||
* issue?: {body: string, number: number, labels: Label[]}
|
||||
* label: Label
|
||||
* }} Payload
|
||||
*
|
||||
* @typedef {{
|
||||
* payload: Payload
|
||||
* repo: any
|
||||
* }} Context
|
||||
*/
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
/** @type {Context} */
|
||||
const { payload, repo } = github.context
|
||||
const {
|
||||
issue,
|
||||
pull_request,
|
||||
label: { name: newLabel },
|
||||
} = payload
|
||||
|
||||
if (pull_request || !issue?.body || !process.env.GITHUB_TOKEN) return
|
||||
|
||||
const labels = issue.labels.map((l) => l.name)
|
||||
// const isBugReport =
|
||||
// labels.includes(bugLabel) || newLabel === bugLabel || !labels.length
|
||||
|
||||
if (
|
||||
// !(isBugReport && issue.number > 43554) &&
|
||||
![addReproductionLabel].includes(newLabel) &&
|
||||
!labels.includes(addReproductionLabel)
|
||||
) {
|
||||
return core.info(
|
||||
"Not a bug report or not manually labeled or already labeled."
|
||||
)
|
||||
}
|
||||
|
||||
const client = github.getOctokit(process.env.GITHUB_TOKEN).rest
|
||||
const issueCommon = { ...repo, issue_number: issue.number }
|
||||
|
||||
if (
|
||||
newLabel === addReproductionLabel
|
||||
// || !hasValidRepro
|
||||
) {
|
||||
await Promise.all([
|
||||
client.issues.addLabels({
|
||||
...issueCommon,
|
||||
labels: [addReproductionLabel],
|
||||
}),
|
||||
client.issues.createComment({
|
||||
...issueCommon,
|
||||
body: readFileSync(join(__dirname, "repro.md"), "utf8"),
|
||||
}),
|
||||
])
|
||||
return core.info(
|
||||
"Commented on issue, because it did not have a sufficient reproduction."
|
||||
)
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
3
.github/issue-labeler.yml
vendored
3
.github/issue-labeler.yml
vendored
@@ -30,6 +30,9 @@ prisma:
|
||||
sequelize:
|
||||
- "@next-auth/sequelize-adapter"
|
||||
|
||||
supabase:
|
||||
- "@next-auth/supabase-adapter"
|
||||
|
||||
typeorm-legacy:
|
||||
- "@next-auth/typeorm-legacy-adapter"
|
||||
|
||||
|
||||
3
.github/pr-labeler.yml
vendored
3
.github/pr-labeler.yml
vendored
@@ -42,6 +42,9 @@ prisma:
|
||||
sequelize:
|
||||
- packages/adapter-sequelize/**
|
||||
|
||||
supabase:
|
||||
- packages/adapter-supabase/**
|
||||
|
||||
typeorm-legacy:
|
||||
- packages/adapter-typeorm-legacy/**
|
||||
|
||||
|
||||
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -18,10 +18,10 @@ jobs:
|
||||
language: ["javascript"]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
@@ -11,7 +11,7 @@ jobs:
|
||||
name: Triage
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: github/issue-labeler@v2.4.1
|
||||
- uses: github/issue-labeler@v2.5
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
configuration-path: ".github/issue-labeler.yml"
|
||||
17
.github/workflows/issue-validator.yml
vendored
Normal file
17
.github/workflows/issue-validator.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
name: Validate issue
|
||||
on:
|
||||
issues:
|
||||
types: [labeled]
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- name: 'Run issue validator'
|
||||
run: node ./.github/actions/issue-validator/index.mjs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -10,7 +10,7 @@ jobs:
|
||||
name: Triage
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@v3
|
||||
- uses: actions/labeler@v4
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
configuration-path: ".github/pr-labeler.yml"
|
||||
14
.github/workflows/release.yml
vendored
14
.github/workflows/release.yml
vendored
@@ -15,11 +15,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Init
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.2.1
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.5.1
|
||||
- name: Setup Node
|
||||
@@ -49,11 +49,11 @@ jobs:
|
||||
environment: Production
|
||||
steps:
|
||||
- name: Init
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.2.1
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.5.1
|
||||
- name: Setup Node
|
||||
@@ -81,9 +81,9 @@ jobs:
|
||||
environment: Preview
|
||||
steps:
|
||||
- name: Init
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v2.2.1
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.5.1
|
||||
- name: Setup Node
|
||||
@@ -106,7 +106,7 @@ jobs:
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PKG }}
|
||||
- name: Comment version on PR
|
||||
uses: NejcZdovc/comment-pr@v1
|
||||
uses: NejcZdovc/comment-pr@v2
|
||||
with:
|
||||
message:
|
||||
"🎉 Experimental release [published 📦️ on npm](https://npmjs.com/package/next-auth/v/${{ env.VERSION }})!\n \
|
||||
|
||||
2
.github/workflows/sync-examples.yml
vendored
2
.github/workflows/sync-examples.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Run GitHub File Sync
|
||||
# Can update to v1 when https://github.com/BetaHuhn/repo-file-sync-action/issues/168 is resolved
|
||||
uses: BetaHuhn/repo-file-sync-action@v1.16.5
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -65,6 +65,7 @@ dev.db*
|
||||
packages/adapter-prisma/prisma/dev.db
|
||||
packages/adapter-prisma/prisma/migrations
|
||||
db.sqlite
|
||||
packages/adapter-supabase/supabase/.branches
|
||||
|
||||
# Tests
|
||||
coverage
|
||||
|
||||
@@ -87,6 +87,7 @@ If you think your custom provider might be useful to others, we encourage you to
|
||||
|
||||
1. Add your config: [`src/providers/{provider}.js`](https://github.com/nextauthjs/next-auth/tree/main/packages/next-auth/src/providers) (Make sure you use a named default export, like `export default function YourProvider`!)
|
||||
2. Add provider documentation: [`www/docs/providers/{provider}.md`](https://github.com/nextauthjs/next-auth/tree/main/www/docs/providers)
|
||||
3. Add provider logo svgs, like `google-dark.svg` (dark mode) and `google.svg` (light mode) to the `/packages/next-auth/provider-logos/` directory. Don't forget to set the provider's styling options in the `provider.style` config object.
|
||||
|
||||
That's it! 🎉 Others will be able to discover this provider much more easily now!
|
||||
|
||||
|
||||
@@ -48,4 +48,11 @@ EMAIL_FROM=user@gmail.com
|
||||
DATABASE_URL=
|
||||
|
||||
WIKIMEDIA_ID=
|
||||
WIKIMEDIA_SECRET=
|
||||
WIKIMEDIA_SECRET=
|
||||
|
||||
# Supabase Example Configuration
|
||||
# Supabase Example Configuration
|
||||
# NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321
|
||||
# SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSJ9.vI9obAHOGyVVKa3pD--kJlyxp-Z2zV9UUMAhKpNLAcU
|
||||
# SUPABASE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long
|
||||
# NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs
|
||||
@@ -90,6 +90,12 @@ export default function Header() {
|
||||
<li className={styles.navItem}>
|
||||
<Link href="/middleware-protected">Middleware protected</Link>
|
||||
</li>
|
||||
<li className={styles.navItem}>
|
||||
<Link href="/supabase-client-rls">Supabase RLS</Link>
|
||||
</li>
|
||||
<li className={styles.navItem}>
|
||||
<Link href="/supabase-ssr">Supabase RLS(SSR)</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
@@ -16,16 +16,19 @@
|
||||
"dependencies": {
|
||||
"@next-auth/fauna-adapter": "workspace:*",
|
||||
"@next-auth/prisma-adapter": "workspace:*",
|
||||
"@next-auth/supabase-adapter": "workspace:*",
|
||||
"@next-auth/typeorm-legacy-adapter": "workspace:*",
|
||||
"@prisma/client": "^3",
|
||||
"@supabase/supabase-js": "^2.0.5",
|
||||
"faunadb": "^4",
|
||||
"next": "13.0.2",
|
||||
"next": "13.0.6",
|
||||
"next-auth": "workspace:*",
|
||||
"nodemailer": "^6",
|
||||
"react": "^18",
|
||||
"react-dom": "^18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jsonwebtoken": "^8.5.5",
|
||||
"@types/react": "^18.0.15",
|
||||
"@types/react-dom": "^18.0.6",
|
||||
"fake-smtp-server": "^0.8.0",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import NextAuth from "next-auth"
|
||||
import type { NextAuthOptions } from "next-auth"
|
||||
import NextAuth, { type NextAuthOptions } from "next-auth"
|
||||
|
||||
// Providers
|
||||
import Apple from "next-auth/providers/apple"
|
||||
@@ -18,7 +17,6 @@ import Freshbooks from "next-auth/providers/freshbooks"
|
||||
import GitHub from "next-auth/providers/github"
|
||||
import Gitlab from "next-auth/providers/gitlab"
|
||||
import Google from "next-auth/providers/google"
|
||||
import Hubspot from "next-auth/providers/hubspot"
|
||||
import IDS4 from "next-auth/providers/identity-server4"
|
||||
import Instagram from "next-auth/providers/instagram"
|
||||
import Keycloak from "next-auth/providers/keycloak"
|
||||
@@ -30,16 +28,12 @@ import Osu from "next-auth/providers/osu"
|
||||
import Patreon from "next-auth/providers/patreon"
|
||||
import Slack from "next-auth/providers/slack"
|
||||
import Spotify from "next-auth/providers/spotify"
|
||||
import Todoist from "next-auth/providers/todoist"
|
||||
import Trakt from "next-auth/providers/trakt"
|
||||
import Twitch from "next-auth/providers/twitch"
|
||||
import Twitter, { TwitterLegacy } from "next-auth/providers/twitter"
|
||||
import Vk from "next-auth/providers/vk"
|
||||
import Wikimedia from "next-auth/providers/wikimedia"
|
||||
import WorkOS from "next-auth/providers/workos"
|
||||
import Zitadel from "next-auth/providers/zitadel"
|
||||
|
||||
// Adapters
|
||||
|
||||
// // Prisma
|
||||
// import { PrismaClient } from "@prisma/client"
|
||||
@@ -65,6 +59,13 @@ import Zitadel from "next-auth/providers/zitadel"
|
||||
// synchronize: true,
|
||||
// })
|
||||
|
||||
// // Supabase
|
||||
// import { SupabaseAdapter } from "@next-auth/supabase-adapter"
|
||||
// const adapter = SupabaseAdapter({
|
||||
// url: process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
// secret: process.env.SUPABASE_SERVICE_ROLE_KEY,
|
||||
// })
|
||||
|
||||
export const authOptions: NextAuthOptions = {
|
||||
// adapter,
|
||||
debug: process.env.NODE_ENV !== "production",
|
||||
@@ -94,7 +95,6 @@ export const authOptions: NextAuthOptions = {
|
||||
GitHub({ clientId: process.env.GITHUB_ID, clientSecret: process.env.GITHUB_SECRET }),
|
||||
Gitlab({ clientId: process.env.GITLAB_ID, clientSecret: process.env.GITLAB_SECRET }),
|
||||
Google({ clientId: process.env.GOOGLE_ID, clientSecret: process.env.GOOGLE_SECRET }),
|
||||
Hubspot({ clientId: process.env.HUBSPOT_ID, clientSecret: process.env.HUBSPOT_SECRET }),
|
||||
IDS4({ clientId: process.env.IDS4_ID, clientSecret: process.env.IDS4_SECRET, issuer: process.env.IDS4_ISSUER }),
|
||||
Instagram({ clientId: process.env.INSTAGRAM_ID, clientSecret: process.env.INSTAGRAM_SECRET }),
|
||||
Keycloak({ clientId: process.env.KEYCLOAK_ID, clientSecret: process.env.KEYCLOAK_SECRET, issuer: process.env.KEYCLOAK_ISSUER }),
|
||||
@@ -106,7 +106,6 @@ export const authOptions: NextAuthOptions = {
|
||||
Patreon({ clientId: process.env.PATREON_ID, clientSecret: process.env.PATREON_SECRET }),
|
||||
Slack({ clientId: process.env.SLACK_ID, clientSecret: process.env.SLACK_SECRET }),
|
||||
Spotify({ clientId: process.env.SPOTIFY_ID, clientSecret: process.env.SPOTIFY_SECRET }),
|
||||
Todoist({ clientId: process.env.TODOIST_ID, clientSecret: process.env.TODOIST_SECRET }),
|
||||
Trakt({ clientId: process.env.TRAKT_ID, clientSecret: process.env.TRAKT_SECRET }),
|
||||
Twitch({ clientId: process.env.TWITCH_ID, clientSecret: process.env.TWITCH_SECRET }),
|
||||
Twitter({ version: "2.0", clientId: process.env.TWITTER_ID, clientSecret: process.env.TWITTER_SECRET }),
|
||||
@@ -114,7 +113,6 @@ export const authOptions: NextAuthOptions = {
|
||||
Vk({ clientId: process.env.VK_ID, clientSecret: process.env.VK_SECRET }),
|
||||
Wikimedia({ clientId: process.env.WIKIMEDIA_ID, clientSecret: process.env.WIKIMEDIA_SECRET }),
|
||||
WorkOS({ clientId: process.env.WORKOS_ID, clientSecret: process.env.WORKOS_SECRET }),
|
||||
Zitadel({ issuer: process.env.ZITADEL_ISSUER, clientId: process.env.ZITADEL_CLIENT_ID, clientSecret: process.env.ZITADEL_CLIENT_SECRET }),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
30
apps/dev/pages/api/examples/supabase-rls.js
Normal file
30
apps/dev/pages/api/examples/supabase-rls.js
Normal file
@@ -0,0 +1,30 @@
|
||||
// This is an example of how to query data from Supabase with RLS.
|
||||
// Learn more about Row Levele Security (RLS): https://supabase.com/docs/guides/auth/row-level-security
|
||||
import { unstable_getServerSession } from "next-auth/next"
|
||||
import { authOptions } from "../auth/[...nextauth]"
|
||||
import { createClient } from "@supabase/supabase-js"
|
||||
|
||||
export default async (req, res) => {
|
||||
const session = await unstable_getServerSession(req, res, authOptions)
|
||||
|
||||
if (!session)
|
||||
return res.send(JSON.stringify({ error: "No session!" }, null, 2))
|
||||
|
||||
const { supabaseAccessToken } = session
|
||||
|
||||
const supabase = createClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
|
||||
{
|
||||
global: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${supabaseAccessToken}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
// Now you can query with RLS enabled.
|
||||
const { data, error } = await supabase.from("users").select("*")
|
||||
|
||||
res.send(JSON.stringify({ supabaseAccessToken, data, error }, null, 2))
|
||||
}
|
||||
49
apps/dev/pages/supabase-client-rls.js
Normal file
49
apps/dev/pages/supabase-client-rls.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import Layout from "../components/layout"
|
||||
import { useState, useEffect } from "react"
|
||||
import { useSession } from "next-auth/react"
|
||||
import { createClient } from "@supabase/supabase-js"
|
||||
|
||||
export default function Page() {
|
||||
const { data: session } = useSession()
|
||||
const [data, setData] = useState(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (session) {
|
||||
console.log(session)
|
||||
// User is logged in, let's fetch their data.
|
||||
const { supabaseAccessToken } = session
|
||||
const supabase = createClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
|
||||
{
|
||||
global: {
|
||||
headers: { Authorization: `Bearer ${supabaseAccessToken}` },
|
||||
},
|
||||
}
|
||||
)
|
||||
// Fetch data with RLS enabled.
|
||||
supabase
|
||||
.from("users")
|
||||
.select("*")
|
||||
.then(({ data }) => setData(data))
|
||||
}
|
||||
}, [session])
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<h1>Fetch Data from Supabase with RLS</h1>
|
||||
<h2>Client-side data fetching with RLS:</h2>
|
||||
<pre>{JSON.stringify(data, null, 2)}</pre>
|
||||
<h2>API Example</h2>
|
||||
<p>
|
||||
You can also use Supabase in API routes. See the code in the
|
||||
`/pages/api/examples/supabase-rls.js` file.
|
||||
</p>
|
||||
<p>
|
||||
<em>You must be signed in to see responses.</em>
|
||||
</p>
|
||||
<p>/api/examples/supabase-rls</p>
|
||||
<iframe src="/api/examples/supabase-rls" />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
68
apps/dev/pages/supabase-ssr.js
Normal file
68
apps/dev/pages/supabase-ssr.js
Normal file
@@ -0,0 +1,68 @@
|
||||
// This is an example of how to protect content using server rendering
|
||||
// and fetching data from Supabase with RLS enabled.
|
||||
import { unstable_getServerSession } from "next-auth/next"
|
||||
import { authOptions } from "./api/auth/[...nextauth]"
|
||||
import { createClient } from "@supabase/supabase-js"
|
||||
import Layout from "../components/layout"
|
||||
import AccessDenied from "../components/access-denied"
|
||||
|
||||
export default function Page({ data, session }) {
|
||||
// If no session exists, display access denied message
|
||||
if (!session) {
|
||||
return (
|
||||
<Layout>
|
||||
<AccessDenied />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
// If session exists, display content
|
||||
return (
|
||||
<Layout>
|
||||
<h1>Protected Page</h1>
|
||||
<p>Data fetched during SSR from Supabase with RSL enabled:</p>
|
||||
<pre>{JSON.stringify(data, null, 2)}</pre>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context) {
|
||||
const session = await unstable_getServerSession(
|
||||
context.req,
|
||||
context.res,
|
||||
authOptions
|
||||
)
|
||||
|
||||
if (!session)
|
||||
return {
|
||||
props: {
|
||||
session,
|
||||
data: null,
|
||||
error: "No session",
|
||||
},
|
||||
}
|
||||
|
||||
const { supabaseAccessToken } = session
|
||||
|
||||
const supabase = createClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
|
||||
{
|
||||
global: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${supabaseAccessToken}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
// Now you can query with RLS enabled.
|
||||
const { data, error } = await supabase.from("users").select("*")
|
||||
|
||||
return {
|
||||
props: {
|
||||
session,
|
||||
data,
|
||||
error,
|
||||
},
|
||||
}
|
||||
}
|
||||
2
apps/dev/types/nextauth.d.ts
vendored
2
apps/dev/types/nextauth.d.ts
vendored
@@ -6,6 +6,8 @@ declare module "next-auth" {
|
||||
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
|
||||
*/
|
||||
interface Session {
|
||||
// A JWT which can be used as Authorization header with supabase-js for RLS.
|
||||
supabaseAccessToken?: string
|
||||
user: {
|
||||
/** The user's postal address. */
|
||||
address: string
|
||||
|
||||
@@ -15,9 +15,9 @@ The MongoDB adapter does not handle connections automatically, so you will have
|
||||
npm install next-auth @next-auth/mongodb-adapter mongodb
|
||||
```
|
||||
|
||||
2. Add `lib/mongodb.js`
|
||||
2. Add `lib/mongodb.ts`
|
||||
|
||||
```js
|
||||
```ts
|
||||
// This approach is taken from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb
|
||||
import { MongoClient } from 'mongodb'
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ We have a list of official adapters that are distributed as their own packages u
|
||||
- [`neo4j`](./neo4j)
|
||||
- [`typeorm-legacy`](./typeorm)
|
||||
- [`sequelize`](./sequelize)
|
||||
- [`supabase`](./supabase)
|
||||
- [`dgraph`](./dgraph)
|
||||
- [`upstash-redis`](./upstash-redis)
|
||||
|
||||
|
||||
309
docs/docs/adapters/supabase.md
Normal file
309
docs/docs/adapters/supabase.md
Normal file
@@ -0,0 +1,309 @@
|
||||
---
|
||||
id: supabase
|
||||
title: Supabase
|
||||
---
|
||||
|
||||
# Supabase
|
||||
|
||||
This is the Supabase Adapter for [`next-auth`](https://next-auth.js.org). This package can only be used in conjunction with the primary `next-auth` package. It is not a standalone package.
|
||||
|
||||
:::note
|
||||
This adapter is developed by the community and not officially maintained or supported by Supabase. It uses the Supabase Database to store user and session data in a separate `next_auth` schema. It is a standalone Auth server that does not interface with Supabase Auth and therefore provides a different feature set.
|
||||
|
||||
If you’re looking for an officially maintained Auth server with additional features like [built-in email server](https://supabase.com/docs/guides/auth/auth-email#configure-email-settings?utm_source=next-auth-docs&medium=referral&campaign=next-auth), [phone auth](https://supabase.com/docs/guides/auth/auth-twilio?utm_source=next-auth-docs&medium=referral&campaign=next-auth), and [Multi Factor Authentication (MFA / 2FA)](https://supabase.com/contact/mfa?utm_source=next-auth-docs&medium=referral&campaign=next-auth), please use [Supabase Auth](https://supabase.com/auth) with the [Auth Helpers for Next.js](https://supabase.com/docs/guides/auth/auth-helpers/nextjs?utm_source=next-auth-docs&medium=referral&campaign=next-auth).
|
||||
:::
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Install `@supabase/supabase-js`, `next-auth` and `@next-auth/supabase-adapter`.
|
||||
|
||||
```bash npm2yarn2pnpm
|
||||
npm install @supabase/supabase-js next-auth @next-auth/supabase-adapter
|
||||
```
|
||||
|
||||
2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
|
||||
|
||||
```js title="pages/api/auth/[...nextauth].js"
|
||||
import NextAuth from "next-auth"
|
||||
import { SupabaseAdapter } from "@next-auth/supabase-adapter"
|
||||
|
||||
// For more information on each option (and a full list of options) go to
|
||||
// https://next-auth.js.org/configuration/options
|
||||
export default NextAuth({
|
||||
// https://next-auth.js.org/configuration/providers
|
||||
providers: [...],
|
||||
adapter: SupabaseAdapter({
|
||||
url: process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
secret: process.env.SUPABASE_SERVICE_ROLE_KEY,
|
||||
}),
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
### Create the `next_auth` schema in Supabase
|
||||
|
||||
Setup your database as described in our main [schema](/adapters/models), by copying the SQL schema below in the Supabase [SQL Editor](https://app.supabase.com/project/_/sql).
|
||||
|
||||
Alternatively you can select the NextAuth Quickstart card on the [SQL Editor page](https://app.supabase.com/project/_/sql), or [create a migration with the Supabase CLI](https://supabase.com/docs/guides/cli/local-development#database-migrations?utm_source=next-auth-docs&medium=referral&campaign=next-auth).
|
||||
|
||||
```sql
|
||||
--
|
||||
-- Name: next_auth; Type: SCHEMA;
|
||||
--
|
||||
CREATE SCHEMA next_auth;
|
||||
|
||||
GRANT USAGE ON SCHEMA next_auth TO service_role;
|
||||
GRANT ALL ON SCHEMA next_auth TO postgres;
|
||||
|
||||
--
|
||||
-- Create users table
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS next_auth.users
|
||||
(
|
||||
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
name text,
|
||||
email text,
|
||||
"emailVerified" timestamp with time zone,
|
||||
image text,
|
||||
CONSTRAINT users_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT email_unique UNIQUE (email)
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE next_auth.users TO postgres;
|
||||
GRANT ALL ON TABLE next_auth.users TO service_role;
|
||||
|
||||
--- uid() function to be used in RLS policies
|
||||
CREATE FUNCTION next_auth.uid() RETURNS uuid
|
||||
LANGUAGE sql STABLE
|
||||
AS $$
|
||||
select
|
||||
coalesce(
|
||||
nullif(current_setting('request.jwt.claim.sub', true), ''),
|
||||
(nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub')
|
||||
)::uuid
|
||||
$$;
|
||||
|
||||
--
|
||||
-- Create sessions table
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS next_auth.sessions
|
||||
(
|
||||
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
expires timestamp with time zone NOT NULL,
|
||||
"sessionToken" text NOT NULL,
|
||||
"userId" uuid,
|
||||
CONSTRAINT sessions_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT sessionToken_unique UNIQUE ("sessionToken"),
|
||||
CONSTRAINT "sessions_userId_fkey" FOREIGN KEY ("userId")
|
||||
REFERENCES next_auth.users (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE next_auth.sessions TO postgres;
|
||||
GRANT ALL ON TABLE next_auth.sessions TO service_role;
|
||||
|
||||
--
|
||||
-- Create accounts table
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS next_auth.accounts
|
||||
(
|
||||
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
type text NOT NULL,
|
||||
provider text NOT NULL,
|
||||
"providerAccountId" text NOT NULL,
|
||||
refresh_token text,
|
||||
access_token text,
|
||||
expires_at bigint,
|
||||
token_type text,
|
||||
scope text,
|
||||
id_token text,
|
||||
session_state text,
|
||||
oauth_token_secret text,
|
||||
oauth_token text,
|
||||
"userId" uuid,
|
||||
CONSTRAINT accounts_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT provider_unique UNIQUE (provider, "providerAccountId"),
|
||||
CONSTRAINT "accounts_userId_fkey" FOREIGN KEY ("userId")
|
||||
REFERENCES next_auth.users (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE next_auth.accounts TO postgres;
|
||||
GRANT ALL ON TABLE next_auth.accounts TO service_role;
|
||||
|
||||
--
|
||||
-- Create verification_tokens table
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS next_auth.verification_tokens
|
||||
(
|
||||
identifier text,
|
||||
token text,
|
||||
expires timestamp with time zone NOT NULL,
|
||||
CONSTRAINT verification_tokens_pkey PRIMARY KEY (token),
|
||||
CONSTRAINT token_unique UNIQUE (token),
|
||||
CONSTRAINT token_identifier_unique UNIQUE (token, identifier)
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE next_auth.verification_tokens TO postgres;
|
||||
GRANT ALL ON TABLE next_auth.verification_tokens TO service_role;
|
||||
```
|
||||
|
||||
### Expose the `next_auth` schema in Supabase
|
||||
|
||||
Expose the `next_auth` schema via the Serverless API in the [API settings](https://app.supabase.com/project/_/settings/api) by adding `next_auth` to the "Exposed schemas" list.
|
||||
|
||||
When developing locally add `next_auth` to the `schemas` array in the `config.toml` file in the `supabase` folder that was generated by the [Supabase CLI](https://supabase.com/docs/guides/cli/local-development#initialize-your-project?utm_source=next-auth-docs&medium=referral&campaign=next-auth).
|
||||
|
||||
## Enabling Row Level Security (RLS)
|
||||
|
||||
Postgres provides a powerful feature called [Row Level Security (RLS)](https://supabase.com/docs/guides/auth/row-level-security?utm_source=next-auth-docs&medium=referral&campaign=next-auth) to limit access to data.
|
||||
|
||||
This works by sending a signed JWT to your [Supabase Serverless API](https://supabase.com/docs/guides/api?utm_source=next-auth-docs&medium=referral&campaign=next-auth). There is two steps to make this work with NextAuth:
|
||||
|
||||
### 1. Generate the Supabase `access_token` JWT in the session callback
|
||||
|
||||
To sign the JWT use the `jsonwebtoken` package:
|
||||
|
||||
```bash npm2yarn2pnpm
|
||||
npm install jsonwebtoken
|
||||
```
|
||||
|
||||
Using the [NexthAuth Session callback](https://next-auth.js.org/configuration/callbacks#session-callback) create the Supabase `access_token` and append it to the `session` object.
|
||||
|
||||
To sign the JWT use the Supabase JWT secret which can be found in the [API settings](https://app.supabase.com/project/_/settings/api)
|
||||
|
||||
```js title="pages/api/auth/[...nextauth].js"
|
||||
import NextAuth from "next-auth"
|
||||
import { SupabaseAdapter } from "@next-auth/supabase-adapter"
|
||||
import jwt from "jsonwebtoken"
|
||||
|
||||
// For more information on each option (and a full list of options) go to
|
||||
// https://next-auth.js.org/configuration/options
|
||||
export default NextAuth({
|
||||
// https://next-auth.js.org/configuration/providers
|
||||
providers: [...],
|
||||
adapter: SupabaseAdapter({
|
||||
url: process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
secret: process.env.SUPABASE_SERVICE_ROLE_KEY,
|
||||
}),
|
||||
callbacks: {
|
||||
async session({ session, user }) {
|
||||
const signingSecret = process.env.SUPABASE_JWT_SECRET
|
||||
if (signingSecret) {
|
||||
const payload = {
|
||||
aud: "authenticated",
|
||||
exp: Math.floor(new Date(session.expires).getTime() / 1000),
|
||||
sub: user.id,
|
||||
email: user.email,
|
||||
role: "authenticated",
|
||||
}
|
||||
session.supabaseAccessToken = jwt.sign(payload, signingSecret)
|
||||
}
|
||||
return session
|
||||
},
|
||||
},
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
### 2. Inject the Supabase `access_token` JWT into the Supabase Client
|
||||
|
||||
For example, given the following public schema:
|
||||
|
||||
```sql
|
||||
/**
|
||||
* USERS
|
||||
* Note: This table contains user data. Users should only be able to view and update their own data.
|
||||
*/
|
||||
create table users (
|
||||
-- UUID from next_auth.users
|
||||
id uuid not null primary key,
|
||||
name text,
|
||||
email text,
|
||||
image text,
|
||||
constraint "users_id_fkey" foreign key ("id")
|
||||
references next_auth.users (id) match simple
|
||||
on update no action
|
||||
on delete cascade -- if user is deleted in NextAuth they will also be deleted in our public table.
|
||||
);
|
||||
alter table users enable row level security;
|
||||
create policy "Can view own user data." on users for select using (next_auth.uid() = id);
|
||||
create policy "Can update own user data." on users for update using (next_auth.uid() = id);
|
||||
|
||||
/**
|
||||
* This trigger automatically creates a user entry when a new user signs up via NextAuth.
|
||||
*/
|
||||
create function public.handle_new_user()
|
||||
returns trigger as $$
|
||||
begin
|
||||
insert into public.users (id, name, email, image)
|
||||
values (new.id, new.name, new.email, new.image);
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql security definer;
|
||||
create trigger on_auth_user_created
|
||||
after insert on next_auth.users
|
||||
for each row execute procedure public.handle_new_user();
|
||||
```
|
||||
|
||||
The `supabaseAccessToken` is now available on the `session` object and can be passed to the supabase-js client. This works in any environment: client-side, server-side (API routes, SSR), as well as in middleware edge functions!
|
||||
|
||||
```js
|
||||
// ...
|
||||
// Use `useSession()` or `unstable_getServerSession()` to get the NextAuth session.
|
||||
|
||||
const { supabaseAccessToken } = session
|
||||
|
||||
const supabase = createClient(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
|
||||
{
|
||||
global: {
|
||||
headers: {
|
||||
Authorization: `Bearer ${supabaseAccessToken}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
// Now you can query with RLS enabled.
|
||||
const { data, error } = await supabase.from("users").select("*")
|
||||
```
|
||||
|
||||
## Usage with TypeScript
|
||||
|
||||
You can pass types that were [generated with the Supabase CLI](/docs/reference/javascript/typescript-support#generating-types) to the Supabase Client to get enhanced type safety and auto completion.
|
||||
|
||||
Creating a new supabase client object:
|
||||
|
||||
```tsx
|
||||
import { createClient } from "@supabase/supabase-js"
|
||||
import { Database } from "../database.types"
|
||||
|
||||
const supabase = createClient<Database>()
|
||||
```
|
||||
|
||||
### Extend the session type with the `supabaseAccessToken`
|
||||
|
||||
In order to extend the `session` object with the `supabaseAccessToken` we need to extend the `session` interface in a `types/next-auth.d.ts` file:
|
||||
|
||||
```ts title="types/next-auth.d.ts"
|
||||
import NextAuth, { DefaultSession } from "next-auth"
|
||||
|
||||
declare module "next-auth" {
|
||||
/**
|
||||
* Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
|
||||
*/
|
||||
interface Session {
|
||||
// A JWT which can be used as Authorization header with supabase-js for RLS.
|
||||
supabaseAccessToken?: string
|
||||
user: {
|
||||
/** The user's postal address. */
|
||||
address: string
|
||||
} & DefaultSession["user"]
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -75,9 +75,10 @@ You can also use `unstable_getServerSession` in Next.js' server components:
|
||||
|
||||
```tsx
|
||||
import { unstable_getServerSession } from "next-auth/next"
|
||||
import { authOptions } from "pages/api/auth/[...nextauth]"
|
||||
|
||||
export default async function Page() {
|
||||
const session = await unstable_getServerSession()
|
||||
const session = await unstable_getServerSession(authOptions)
|
||||
return <pre>{JSON.stringify(session, null, 2)}</pre>
|
||||
}
|
||||
```
|
||||
|
||||
@@ -472,7 +472,8 @@ cookies: {
|
||||
httpOnly: true,
|
||||
sameSite: 'lax',
|
||||
path: '/',
|
||||
secure: useSecureCookies
|
||||
secure: useSecureCookies,
|
||||
maxAge: 900
|
||||
}
|
||||
},
|
||||
state: {
|
||||
@@ -482,6 +483,7 @@ cookies: {
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
secure: useSecureCookies,
|
||||
maxAge: 900
|
||||
},
|
||||
},
|
||||
nonce: {
|
||||
|
||||
@@ -13,7 +13,7 @@ Adding support for signing in via email in addition to one or more OAuth service
|
||||
Configuration is similar to other providers, but the options are different:
|
||||
|
||||
```js title="pages/api/auth/[...nextauth].js"
|
||||
import EmailProvider from `next-auth/providers/email`
|
||||
import EmailProvider from "next-auth/providers/email"
|
||||
...
|
||||
providers: [
|
||||
EmailProvider({
|
||||
|
||||
@@ -174,6 +174,10 @@ interface OAuthConfig {
|
||||
issuer?: string
|
||||
client?: Partial<ClientMetadata>
|
||||
allowDangerousEmailAccountLinking?: boolean
|
||||
/**
|
||||
* Object containing the settings for the styling of the providers sign-in buttons
|
||||
*/
|
||||
style: ProviderStyleType
|
||||
}
|
||||
```
|
||||
|
||||
@@ -428,7 +432,8 @@ If you think your custom provider might be useful to others, we encourage you to
|
||||
You only need to add three changes:
|
||||
|
||||
1. Add your config: [`src/providers/{provider}.ts`](https://github.com/nextauthjs/next-auth/tree/main/packages/next-auth/src/providers)<br />
|
||||
• make sure you use a named default export, like this: `export default function YourProvider`
|
||||
- Make sure you use a named default export, like this: `export default function YourProvider`
|
||||
- Add two SVG's of the provider logo, like `google-dark.svg` (dark mode) and `google.svg` (light mode), to the `/packages/next-auth/provider-logos/` directory as well as the styling config to the provider config object. See existing provider for example
|
||||
2. Add provider documentation: [`/docs/providers/{provider}.md`](https://github.com/nextauthjs/next-auth/tree/main/docs/docs/providers)
|
||||
3. Add the new provider name to the `Provider type` dropdown options in [`the provider issue template`](<[http](https://github.com/nextauthjs/next-auth/edit/main/.github/ISSUE_TEMPLATE/2_bug_provider.yml)>)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ http://developers.strava.com/docs/reference/
|
||||
|
||||
The **Strava Provider** comes with a set of default options:
|
||||
|
||||
- [Strava Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/strava.js)
|
||||
- [Strava Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/strava.ts)
|
||||
|
||||
You can override any of the options to suit your own use case. Ensure the redirect_uri configuration fits your needs accordingly.
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@ title: Tutorials and Explainers
|
||||
- Learn how to use Sign-In With Ethereum to authenticate your users with their existing Ethereum wallets - identifiers they personally control.
|
||||
- Example application: [spruceid/siwe-next-auth-example](https://github.com/spruceid/siwe-next-auth-example)
|
||||
|
||||
#### [Next.js Authentication with Okta and NextAuth.js 4.0](https://thetombomb.com/posts/nextjs-nextauth-okta) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- Learn how to perform authentication with an OIDC Application in Okta and NextAuth.js.
|
||||
|
||||
## Fullstack
|
||||
|
||||
#### [Build a FullStack App with Next.js, NextAuth.js, Supabase & Prisma](https://themodern.dev/courses/build-a-fullstack-app-with-nextjs-supabase-and-prisma-322389284337222224) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
@@ -61,7 +61,7 @@ For the time being, the `withAuth` middleware only supports `"jwt"` as [session
|
||||
More details can be found [here](https://next-auth.js.org/configuration/nextjs#middleware).
|
||||
|
||||
:::tip
|
||||
To inclue all `dashboard` nested routes (sub pages like `/dashboard/settings`, `/dashboard/profile`) you can pass `matcher: "/dashboard/:path*"` to `config`.
|
||||
To include all `dashboard` nested routes (sub pages like `/dashboard/settings`, `/dashboard/profile`) you can pass `matcher: "/dashboard/:path*"` to `config`.
|
||||
|
||||
For other patterns check out the [Next.js Middleware documentation](https://nextjs.org/docs/advanced-features/middleware#matcher).
|
||||
:::
|
||||
|
||||
@@ -65,6 +65,7 @@ module.exports = {
|
||||
"adapters/neo4j",
|
||||
"adapters/typeorm",
|
||||
"adapters/sequelize",
|
||||
"adapters/supabase",
|
||||
"adapters/mikro-orm",
|
||||
"adapters/dgraph",
|
||||
"adapters/upstash-redis",
|
||||
|
||||
@@ -14,6 +14,10 @@ If you did not find a guide or tutorial covering your use case, please [open an
|
||||
- How to restrict access to pages and API routes.
|
||||
- [Usage with class components](/tutorials/usage-with-class-components)
|
||||
- How to use `useSession()` hook with class components.
|
||||
- [Next.js Authentication with Okta and NextAuth.js 4.0](https://thetombomb.com/posts/nextjs-nextauth-okta)
|
||||
- Learn how to perform authentication with an OIDC Application in Okta and NextAuth.js.
|
||||
|
||||
|
||||
|
||||
### Advanced
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@next-auth/firebase-adapter",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Firebase adapter for next-auth.",
|
||||
"homepage": "https://next-auth.js.org",
|
||||
"repository": "https://github.com/nextauthjs/next-auth",
|
||||
@@ -29,7 +29,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "FIRESTORE_EMULATOR_HOST=localhost:8080 firebase emulators:exec --only firestore --project next-auth-test jest"
|
||||
"test": "FIRESTORE_EMULATOR_HOST=localhost:8080 firebase --token '$FIREBASE_TOKEN' emulators:exec --only firestore --project next-auth-test jest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"firebase": "^9.7.0",
|
||||
@@ -38,9 +38,9 @@
|
||||
"devDependencies": {
|
||||
"@next-auth/adapter-test": "workspace:*",
|
||||
"@next-auth/tsconfig": "workspace:*",
|
||||
"firebase": "^9.7.0",
|
||||
"firebase-tools": "^10.7.2",
|
||||
"firebase": "^9.14.0",
|
||||
"firebase-tools": "^11.16.1",
|
||||
"jest": "^27.4.3",
|
||||
"next-auth": "workspace:*"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,10 +86,10 @@ export function FirestoreAdapter({
|
||||
async getUserByEmail(email) {
|
||||
const userQuery = query(Users, where("email", "==", email), limit(1))
|
||||
const userSnapshots = await getDocs(userQuery)
|
||||
const userSnpashot = userSnapshots.docs[0]
|
||||
const userSnapshot = userSnapshots.docs[0]
|
||||
|
||||
if (userSnpashot?.exists() && Users.converter) {
|
||||
return Users.converter.fromFirestore(userSnpashot)
|
||||
if (userSnapshot?.exists() && Users.converter) {
|
||||
return Users.converter.fromFirestore(userSnapshot)
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "@next-auth/tsconfig/tsconfig.base.json",
|
||||
"extends": "@next-auth/tsconfig/tsconfig.adapters.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@next-auth/pouchdb-adapter",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.5",
|
||||
"description": "PouchDB adapter for next-auth.",
|
||||
"homepage": "https://next-auth.js.org",
|
||||
"repository": "https://github.com/nextauthjs/next-auth",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "@next-auth/tsconfig/tsconfig.base.json",
|
||||
"extends": "@next-auth/tsconfig/tsconfig.adapters.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@next-auth/sequelize-adapter",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"description": "Sequelize adapter for next-auth.",
|
||||
"homepage": "https://next-auth.js.org",
|
||||
"repository": "https://github.com/nextauthjs/next-auth",
|
||||
@@ -42,4 +42,4 @@
|
||||
"jest": {
|
||||
"preset": "@next-auth/adapter-test/jest"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export const Account = {
|
||||
expires_at: { type: DataTypes.INTEGER },
|
||||
token_type: { type: DataTypes.STRING },
|
||||
scope: { type: DataTypes.STRING },
|
||||
id_token: { type: DataTypes.STRING },
|
||||
id_token: { type: DataTypes.TEXT },
|
||||
session_state: { type: DataTypes.STRING },
|
||||
userId: { type: DataTypes.UUID },
|
||||
}
|
||||
|
||||
3
packages/adapter-supabase/.env.example
Normal file
3
packages/adapter-supabase/.env.example
Normal file
@@ -0,0 +1,3 @@
|
||||
# Run `supabase start` in this directory to get the Supabase API URL and service role key!
|
||||
SUPABASE_URL=http://localhost:54321
|
||||
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSJ9.vI9obAHOGyVVKa3pD--kJlyxp-Z2zV9UUMAhKpNLAcU
|
||||
57
packages/adapter-supabase/README.md
Normal file
57
packages/adapter-supabase/README.md
Normal file
@@ -0,0 +1,57 @@
|
||||
<p align="center">
|
||||
<br/>
|
||||
<a href="https://next-auth.js.org" target="_blank">
|
||||
<img height="64px" src="https://next-auth.js.org/img/logo/logo-sm.png" /></a><img height="64px" src="./logo.svg" />
|
||||
<h3 align="center"><b>Supabase Adapter</b> - NextAuth.js</h3>
|
||||
<p align="center">
|
||||
Open Source. Full Stack. Own Your Data.
|
||||
</p>
|
||||
<p align="center" style="align: center;">
|
||||
<img src="https://github.com/nextauthjs/next-auth/actions/workflows/release.yml/badge.svg?branch=main" alt="Build Test" />
|
||||
<img src="https://img.shields.io/bundlephobia/minzip/@next-auth/supabase-adapter/latest" alt="Bundle Size"/>
|
||||
<img src="https://img.shields.io/npm/v/@next-auth/supabase-adapter" alt="@next-auth/supabase-adapter Version" />
|
||||
</p>
|
||||
</p>
|
||||
|
||||
## Overview
|
||||
|
||||
This is the Supabase Adapter for [`next-auth`](https://next-auth.js.org). This package can only be used in conjunction with the primary `next-auth` package. It is not a standalone package.
|
||||
|
||||
You can find more Supabase information in the docs at [next-auth.js.org/adapters/supabase](https://next-auth.js.org/adapters/supabase).
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Install `@supabase/supabase-js`, `next-auth` and `@next-auth/supabase-adapter`.
|
||||
|
||||
```js
|
||||
npm install @supabase/supabase-js next-auth @next-auth/supabase-adapter
|
||||
```
|
||||
|
||||
2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
|
||||
|
||||
```js
|
||||
import NextAuth from "next-auth"
|
||||
import { SupabaseAdapter } from "@next-auth/supabase-adapter"
|
||||
|
||||
// For more information on each option (and a full list of options) go to
|
||||
// https://next-auth.js.org/configuration/options
|
||||
export default NextAuth({
|
||||
// https://next-auth.js.org/configuration/providers
|
||||
providers: [
|
||||
// ...
|
||||
],
|
||||
adapter: SupabaseAdapter({
|
||||
url: process.env.NEXT_PUBLIC_SUPABASE_URL,
|
||||
secret: process.env.SUPABASE_SERVICE_ROLE_KEY,
|
||||
}),
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/next-auth/blob/main/CONTRIBUTING.md).
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
15
packages/adapter-supabase/logo.svg
Normal file
15
packages/adapter-supabase/logo.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<svg width="109" height="113" viewBox="0 0 109 113" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M63.7076 110.284C60.8481 113.885 55.0502 111.912 54.9813 107.314L53.9738 40.0627L99.1935 40.0627C107.384 40.0627 111.952 49.5228 106.859 55.9374L63.7076 110.284Z" fill="url(#paint0_linear)"/>
|
||||
<path d="M63.7076 110.284C60.8481 113.885 55.0502 111.912 54.9813 107.314L53.9738 40.0627L99.1935 40.0627C107.384 40.0627 111.952 49.5228 106.859 55.9374L63.7076 110.284Z" fill="url(#paint1_linear)" fill-opacity="0.2"/>
|
||||
<path d="M45.317 2.07103C48.1765 -1.53037 53.9745 0.442937 54.0434 5.041L54.4849 72.2922H9.83113C1.64038 72.2922 -2.92775 62.8321 2.1655 56.4175L45.317 2.07103Z" fill="#3ECF8E"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear" x1="53.9738" y1="54.974" x2="94.1635" y2="71.8295" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#249361"/>
|
||||
<stop offset="1" stop-color="#3ECF8E"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear" x1="36.1558" y1="30.578" x2="54.4844" y2="65.0806" gradientUnits="userSpaceOnUse">
|
||||
<stop/>
|
||||
<stop offset="1" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
40
packages/adapter-supabase/package.json
Normal file
40
packages/adapter-supabase/package.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@next-auth/supabase-adapter",
|
||||
"version": "0.2.0",
|
||||
"description": "Supabase adapter for next-auth.",
|
||||
"homepage": "https://next-auth.js.org",
|
||||
"repository": "https://github.com/nextauthjs/next-auth",
|
||||
"bugs": {
|
||||
"url": "https://github.com/nextauthjs/next-auth/issues"
|
||||
},
|
||||
"author": "Martin Sonnberger <martin.sonnberger@icloud.com>",
|
||||
"main": "dist/index.js",
|
||||
"keywords": [
|
||||
"next-auth",
|
||||
"next.js",
|
||||
"supabase"
|
||||
],
|
||||
"license": "ISC",
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "./tests/test.sh"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@supabase/supabase-js": "^2.0.5",
|
||||
"next-auth": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next-auth/adapter-test": "workspace:^0.0.0",
|
||||
"@next-auth/tsconfig": "workspace:^0.0.0",
|
||||
"@supabase/supabase-js": "^2.0.5",
|
||||
"jest": "^27.4.3",
|
||||
"next-auth": "workspace:*"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "@next-auth/adapter-test/jest"
|
||||
}
|
||||
}
|
||||
140
packages/adapter-supabase/src/database.types.ts
Normal file
140
packages/adapter-supabase/src/database.types.ts
Normal file
@@ -0,0 +1,140 @@
|
||||
export type Json =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null
|
||||
| { [key: string]: Json }
|
||||
| Json[]
|
||||
|
||||
export interface Database {
|
||||
next_auth: {
|
||||
Tables: {
|
||||
accounts: {
|
||||
Row: {
|
||||
id: string
|
||||
type: string | null
|
||||
provider: string | null
|
||||
providerAccountId: string | null
|
||||
refresh_token: string | null
|
||||
access_token: string | null
|
||||
expires_at: number | null
|
||||
token_type: string | null
|
||||
scope: string | null
|
||||
id_token: string | null
|
||||
session_state: string | null
|
||||
oauth_token_secret: string | null
|
||||
oauth_token: string | null
|
||||
userId: string | null
|
||||
}
|
||||
Insert: {
|
||||
id?: string
|
||||
type?: string | null
|
||||
provider?: string | null
|
||||
providerAccountId?: string | null
|
||||
refresh_token?: string | null
|
||||
access_token?: string | null
|
||||
expires_at?: number | null
|
||||
token_type?: string | null
|
||||
scope?: string | null
|
||||
id_token?: string | null
|
||||
session_state?: string | null
|
||||
oauth_token_secret?: string | null
|
||||
oauth_token?: string | null
|
||||
userId?: string | null
|
||||
}
|
||||
Update: {
|
||||
id?: string
|
||||
type?: string | null
|
||||
provider?: string | null
|
||||
providerAccountId?: string | null
|
||||
refresh_token?: string | null
|
||||
access_token?: string | null
|
||||
expires_at?: number | null
|
||||
token_type?: string | null
|
||||
scope?: string | null
|
||||
id_token?: string | null
|
||||
session_state?: string | null
|
||||
oauth_token_secret?: string | null
|
||||
oauth_token?: string | null
|
||||
userId?: string | null
|
||||
}
|
||||
}
|
||||
sessions: {
|
||||
Row: {
|
||||
expires: string | null
|
||||
sessionToken: string | null
|
||||
userId: string | null
|
||||
id: string
|
||||
}
|
||||
Insert: {
|
||||
expires?: string | null
|
||||
sessionToken?: string | null
|
||||
userId?: string | null
|
||||
id?: string
|
||||
}
|
||||
Update: {
|
||||
expires?: string | null
|
||||
sessionToken?: string | null
|
||||
userId?: string | null
|
||||
id?: string
|
||||
}
|
||||
}
|
||||
users: {
|
||||
Row: {
|
||||
name: string | null
|
||||
email: string | null
|
||||
emailVerified: string | null
|
||||
image: string | null
|
||||
id: string
|
||||
}
|
||||
Insert: {
|
||||
name?: string | null
|
||||
email?: string | null
|
||||
emailVerified?: string | null
|
||||
image?: string | null
|
||||
id?: string
|
||||
}
|
||||
Update: {
|
||||
name?: string | null
|
||||
email?: string | null
|
||||
emailVerified?: string | null
|
||||
image?: string | null
|
||||
id?: string
|
||||
}
|
||||
}
|
||||
verification_tokens: {
|
||||
Row: {
|
||||
id: number
|
||||
identifier: string | null
|
||||
token: string | null
|
||||
expires: string | null
|
||||
}
|
||||
Insert: {
|
||||
id?: number
|
||||
identifier?: string | null
|
||||
token?: string | null
|
||||
expires?: string | null
|
||||
}
|
||||
Update: {
|
||||
id?: number
|
||||
identifier?: string | null
|
||||
token?: string | null
|
||||
expires?: string | null
|
||||
}
|
||||
}
|
||||
}
|
||||
Views: {
|
||||
[_ in never]: never
|
||||
}
|
||||
Functions: {
|
||||
uid: {
|
||||
Args: Record<PropertyKey, never>
|
||||
Returns: string
|
||||
}
|
||||
}
|
||||
Enums: {
|
||||
[_ in never]: never
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
212
packages/adapter-supabase/src/index.ts
Normal file
212
packages/adapter-supabase/src/index.ts
Normal file
@@ -0,0 +1,212 @@
|
||||
import { createClient } from "@supabase/supabase-js"
|
||||
import { Database } from "./database.types"
|
||||
import {
|
||||
Adapter,
|
||||
AdapterSession,
|
||||
AdapterUser,
|
||||
VerificationToken,
|
||||
} from "next-auth/adapters"
|
||||
|
||||
function isDate(date: any) {
|
||||
return (
|
||||
new Date(date).toString() !== "Invalid Date" && !isNaN(Date.parse(date))
|
||||
)
|
||||
}
|
||||
|
||||
export function format<T>(obj: Record<string, any>): T {
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value === null) {
|
||||
delete obj[key]
|
||||
}
|
||||
|
||||
if (isDate(value)) {
|
||||
obj[key] = new Date(value)
|
||||
}
|
||||
}
|
||||
|
||||
return obj as T
|
||||
}
|
||||
|
||||
export const SupabaseAdapter = ({
|
||||
url,
|
||||
secret,
|
||||
}: {
|
||||
url: string
|
||||
secret: string
|
||||
}): Adapter => {
|
||||
const supabase = createClient<Database, "next_auth">(url, secret, {
|
||||
db: { schema: "next_auth" },
|
||||
global: {
|
||||
headers: { "X-Client-Info": "@next-auth/supabase-adapter@0.1.0" },
|
||||
},
|
||||
})
|
||||
return {
|
||||
async createUser(user) {
|
||||
const { data, error } = await supabase
|
||||
.from("users")
|
||||
.insert({
|
||||
...user,
|
||||
emailVerified: user.emailVerified?.toISOString(),
|
||||
})
|
||||
.select()
|
||||
.single()
|
||||
|
||||
if (error) throw error
|
||||
|
||||
return format<AdapterUser>(data)
|
||||
},
|
||||
async getUser(id) {
|
||||
const { data, error } = await supabase
|
||||
.from("users")
|
||||
.select()
|
||||
.eq("id", id)
|
||||
.maybeSingle()
|
||||
|
||||
if (error) throw error
|
||||
if (!data) return null
|
||||
|
||||
return format<AdapterUser>(data)
|
||||
},
|
||||
async getUserByEmail(email) {
|
||||
const { data, error } = await supabase
|
||||
.from("users")
|
||||
.select()
|
||||
.eq("email", email)
|
||||
.maybeSingle()
|
||||
|
||||
if (error) throw error
|
||||
if (!data) return null
|
||||
|
||||
return format<AdapterUser>(data)
|
||||
},
|
||||
async getUserByAccount({ providerAccountId, provider }) {
|
||||
const { data, error } = await supabase
|
||||
.from("accounts")
|
||||
.select("users (*)")
|
||||
.match({ provider, providerAccountId })
|
||||
.maybeSingle()
|
||||
|
||||
if (error) throw error
|
||||
if (!data || !data.users) return null
|
||||
|
||||
return format<AdapterUser>(data.users)
|
||||
},
|
||||
async updateUser(user) {
|
||||
const { data, error } = await supabase
|
||||
.from("users")
|
||||
.update({
|
||||
...user,
|
||||
emailVerified: user.emailVerified?.toISOString(),
|
||||
})
|
||||
.eq("id", user.id)
|
||||
.select()
|
||||
.single()
|
||||
|
||||
if (error) throw error
|
||||
|
||||
return format<AdapterUser>(data)
|
||||
},
|
||||
async deleteUser(userId) {
|
||||
const { error } = await supabase.from("users").delete().eq("id", userId)
|
||||
|
||||
if (error) throw error
|
||||
},
|
||||
async linkAccount(account) {
|
||||
const { error } = await supabase.from("accounts").insert(account)
|
||||
|
||||
if (error) throw error
|
||||
},
|
||||
async unlinkAccount({ providerAccountId, provider }) {
|
||||
const { error } = await supabase
|
||||
.from("accounts")
|
||||
.delete()
|
||||
.match({ provider, providerAccountId })
|
||||
|
||||
if (error) throw error
|
||||
},
|
||||
async createSession({ sessionToken, userId, expires }) {
|
||||
const { data, error } = await supabase
|
||||
.from("sessions")
|
||||
.insert({ sessionToken, userId, expires: expires.toISOString() })
|
||||
.select()
|
||||
.single()
|
||||
|
||||
if (error) throw error
|
||||
|
||||
return format<AdapterSession>(data)
|
||||
},
|
||||
async getSessionAndUser(sessionToken) {
|
||||
const { data, error } = await supabase
|
||||
.from("sessions")
|
||||
.select("*, users(*)")
|
||||
.eq("sessionToken", sessionToken)
|
||||
.maybeSingle()
|
||||
|
||||
if (error) throw error
|
||||
if (!data) return null
|
||||
|
||||
const { users: user, ...session } = data
|
||||
|
||||
return {
|
||||
user: format<AdapterUser>(
|
||||
user as Database["next_auth"]["Tables"]["users"]["Row"]
|
||||
),
|
||||
session: format<AdapterSession>(session),
|
||||
}
|
||||
},
|
||||
async updateSession(session) {
|
||||
const { data, error } = await supabase
|
||||
.from("sessions")
|
||||
.update({
|
||||
...session,
|
||||
expires: session.expires?.toISOString(),
|
||||
})
|
||||
.eq("sessionToken", session.sessionToken)
|
||||
.select()
|
||||
.single()
|
||||
|
||||
if (error) throw error
|
||||
|
||||
return format<AdapterSession>(data)
|
||||
},
|
||||
async deleteSession(sessionToken) {
|
||||
const { error } = await supabase
|
||||
.from("sessions")
|
||||
.delete()
|
||||
.eq("sessionToken", sessionToken)
|
||||
|
||||
if (error) throw error
|
||||
},
|
||||
async createVerificationToken(token) {
|
||||
const { data, error } = await supabase
|
||||
.from("verification_tokens")
|
||||
.insert({
|
||||
...token,
|
||||
expires: token.expires.toISOString(),
|
||||
})
|
||||
.select()
|
||||
.single()
|
||||
|
||||
if (error) throw error
|
||||
|
||||
const { id, ...verificationToken } = data
|
||||
|
||||
return format<VerificationToken>(verificationToken)
|
||||
},
|
||||
async useVerificationToken({ identifier, token }) {
|
||||
const { data, error } = await supabase
|
||||
.from("verification_tokens")
|
||||
.delete()
|
||||
.match({ identifier, token })
|
||||
.select()
|
||||
.maybeSingle()
|
||||
|
||||
if (error) throw error
|
||||
if (!data) return null
|
||||
|
||||
const { id, ...verificationToken } = data
|
||||
|
||||
return format<VerificationToken>(verificationToken)
|
||||
},
|
||||
}
|
||||
}
|
||||
44
packages/adapter-supabase/supabase/config.toml
Normal file
44
packages/adapter-supabase/supabase/config.toml
Normal file
@@ -0,0 +1,44 @@
|
||||
# A string used to distinguish different Supabase projects on the same host. Defaults to the working
|
||||
# directory name when running `supabase init`.
|
||||
project_id = "nextauth"
|
||||
|
||||
[api]
|
||||
# Port to use for the API URL.
|
||||
port = 54321
|
||||
# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API
|
||||
# endpoints. public and storage are always included.
|
||||
schemas = ["next_auth"]
|
||||
# Extra schemas to add to the search_path of every request.
|
||||
extra_search_path = ["extensions"]
|
||||
# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size
|
||||
# for accidental or malicious requests.
|
||||
max_rows = 1000
|
||||
|
||||
[db]
|
||||
# Port to use for the local database URL.
|
||||
port = 54322
|
||||
# The database major version to use. This has to be the same as your remote database's. Run `SHOW
|
||||
# server_version;` on the remote database to check.
|
||||
major_version = 14
|
||||
|
||||
[studio]
|
||||
# Port to use for Supabase Studio.
|
||||
port = 54323
|
||||
|
||||
# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they
|
||||
# are monitored, and you can view the emails that would have been sent from the web interface.
|
||||
[inbucket]
|
||||
# Port to use for the email testing server web interface.
|
||||
port = 54324
|
||||
|
||||
[auth]
|
||||
# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used
|
||||
# in emails.
|
||||
site_url = "http://localhost:3000"
|
||||
# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
|
||||
additional_redirect_urls = ["https://localhost:3000"]
|
||||
# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one
|
||||
# week).
|
||||
jwt_expiry = 3600
|
||||
# Allow/disallow new user signups to your project.
|
||||
enable_signup = true
|
||||
@@ -0,0 +1,101 @@
|
||||
--
|
||||
-- Name: next_auth; Type: SCHEMA;
|
||||
--
|
||||
CREATE SCHEMA next_auth;
|
||||
|
||||
GRANT USAGE ON SCHEMA next_auth TO service_role;
|
||||
GRANT ALL ON SCHEMA next_auth TO postgres;
|
||||
|
||||
--
|
||||
-- Create users table
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS next_auth.users
|
||||
(
|
||||
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
name text,
|
||||
email text,
|
||||
"emailVerified" timestamp with time zone,
|
||||
image text,
|
||||
CONSTRAINT users_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT email_unique UNIQUE (email)
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE next_auth.users TO postgres;
|
||||
GRANT ALL ON TABLE next_auth.users TO service_role;
|
||||
|
||||
--- uid() function to be used in RLS policies
|
||||
CREATE FUNCTION next_auth.uid() RETURNS uuid
|
||||
LANGUAGE sql STABLE
|
||||
AS $$
|
||||
select
|
||||
coalesce(
|
||||
nullif(current_setting('request.jwt.claim.sub', true), ''),
|
||||
(nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub')
|
||||
)::uuid
|
||||
$$;
|
||||
|
||||
--
|
||||
-- Create sessions table
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS next_auth.sessions
|
||||
(
|
||||
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
expires timestamp with time zone NOT NULL,
|
||||
"sessionToken" text NOT NULL,
|
||||
"userId" uuid,
|
||||
CONSTRAINT sessions_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT sessionToken_unique UNIQUE ("sessionToken"),
|
||||
CONSTRAINT "sessions_userId_fkey" FOREIGN KEY ("userId")
|
||||
REFERENCES next_auth.users (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE next_auth.sessions TO postgres;
|
||||
GRANT ALL ON TABLE next_auth.sessions TO service_role;
|
||||
|
||||
--
|
||||
-- Create accounts table
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS next_auth.accounts
|
||||
(
|
||||
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
type text NOT NULL,
|
||||
provider text NOT NULL,
|
||||
"providerAccountId" text NOT NULL,
|
||||
refresh_token text,
|
||||
access_token text,
|
||||
expires_at bigint,
|
||||
token_type text,
|
||||
scope text,
|
||||
id_token text,
|
||||
session_state text,
|
||||
oauth_token_secret text,
|
||||
oauth_token text,
|
||||
"userId" uuid,
|
||||
CONSTRAINT accounts_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT provider_unique UNIQUE (provider, "providerAccountId"),
|
||||
CONSTRAINT "accounts_userId_fkey" FOREIGN KEY ("userId")
|
||||
REFERENCES next_auth.users (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE next_auth.accounts TO postgres;
|
||||
GRANT ALL ON TABLE next_auth.accounts TO service_role;
|
||||
|
||||
--
|
||||
-- Create verification_tokens table
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS next_auth.verification_tokens
|
||||
(
|
||||
identifier text,
|
||||
token text,
|
||||
expires timestamp with time zone NOT NULL,
|
||||
CONSTRAINT verification_tokens_pkey PRIMARY KEY (token),
|
||||
CONSTRAINT token_unique UNIQUE (token),
|
||||
CONSTRAINT token_identifier_unique UNIQUE (token, identifier)
|
||||
);
|
||||
|
||||
GRANT ALL ON TABLE next_auth.verification_tokens TO postgres;
|
||||
GRANT ALL ON TABLE next_auth.verification_tokens TO service_role;
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* USERS
|
||||
* Note: This table contains user data. Users should only be able to view and update their own data.
|
||||
*/
|
||||
create table users (
|
||||
-- UUID from next_auth.users
|
||||
id uuid not null primary key,
|
||||
name text,
|
||||
email text,
|
||||
image text,
|
||||
constraint "users_id_fkey" foreign key ("id")
|
||||
references next_auth.users (id) match simple
|
||||
on update no action
|
||||
on delete cascade -- if user is deleted in NextAuth they will also be deleted in our public table.
|
||||
);
|
||||
alter table users enable row level security;
|
||||
create policy "Can view own user data." on users for select using (next_auth.uid() = id);
|
||||
create policy "Can update own user data." on users for update using (next_auth.uid() = id);
|
||||
|
||||
/**
|
||||
* This trigger automatically creates a user entry when a new user signs up via NextAuth.
|
||||
*/
|
||||
create function public.handle_new_user()
|
||||
returns trigger as $$
|
||||
begin
|
||||
insert into public.users (id, name, email, image)
|
||||
values (new.id, new.name, new.email, new.image);
|
||||
return new;
|
||||
end;
|
||||
$$ language plpgsql security definer;
|
||||
create trigger on_auth_user_created
|
||||
after insert on next_auth.users
|
||||
for each row execute procedure public.handle_new_user();
|
||||
76
packages/adapter-supabase/tests/index.test.ts
Normal file
76
packages/adapter-supabase/tests/index.test.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { runBasicTests } from "@next-auth/adapter-test"
|
||||
import { format, SupabaseAdapter } from "../src"
|
||||
import { createClient } from "@supabase/supabase-js"
|
||||
import type {
|
||||
AdapterSession,
|
||||
AdapterUser,
|
||||
VerificationToken,
|
||||
} from "next-auth/adapters"
|
||||
import type { Account } from "next-auth"
|
||||
|
||||
const supabase = createClient(
|
||||
process.env.SUPABASE_URL ?? "http://localhost:54321",
|
||||
process.env.SUPABASE_SERVICE_ROLE_KEY ??
|
||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSJ9.vI9obAHOGyVVKa3pD--kJlyxp-Z2zV9UUMAhKpNLAcU",
|
||||
{ db: { schema: "next_auth" } }
|
||||
)
|
||||
|
||||
runBasicTests({
|
||||
adapter: SupabaseAdapter({
|
||||
url: process.env.SUPABASE_URL ?? "http://localhost:54321",
|
||||
secret:
|
||||
process.env.SUPABASE_SERVICE_ROLE_KEY ??
|
||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSJ9.vI9obAHOGyVVKa3pD--kJlyxp-Z2zV9UUMAhKpNLAcU",
|
||||
}),
|
||||
db: {
|
||||
async session(sessionToken) {
|
||||
const { data, error } = await supabase
|
||||
.from("sessions")
|
||||
.select()
|
||||
.eq("sessionToken", sessionToken)
|
||||
.maybeSingle()
|
||||
|
||||
if (error) throw error
|
||||
if (!data) return null
|
||||
|
||||
return format<AdapterSession>(data)
|
||||
},
|
||||
async user(id) {
|
||||
const { data, error } = await supabase
|
||||
.from("users")
|
||||
.select()
|
||||
.eq("id", id)
|
||||
.maybeSingle()
|
||||
|
||||
if (error) throw error
|
||||
if (!data) return null
|
||||
|
||||
return format<AdapterUser>(data)
|
||||
},
|
||||
async account({ provider, providerAccountId }) {
|
||||
const { data, error } = await supabase
|
||||
.from("accounts")
|
||||
.select()
|
||||
.match({ provider, providerAccountId })
|
||||
.maybeSingle()
|
||||
|
||||
if (error) throw error
|
||||
if (!data) return null
|
||||
|
||||
return format<Account>(data)
|
||||
},
|
||||
async verificationToken({ identifier, token }) {
|
||||
const { data, error } = await supabase
|
||||
.from("verification_tokens")
|
||||
.select()
|
||||
.match({ identifier, token })
|
||||
.single()
|
||||
|
||||
if (error) throw error
|
||||
|
||||
const { id, ...verificationToken } = data
|
||||
|
||||
return format<VerificationToken>(verificationToken)
|
||||
},
|
||||
},
|
||||
})
|
||||
19
packages/adapter-supabase/tests/test.sh
Executable file
19
packages/adapter-supabase/tests/test.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# install Supabase CLI when run on CI
|
||||
if [ "$CI" = true ]; then
|
||||
wget -O supabase.deb https://github.com/supabase/cli/releases/download/v0.29.0/supabase_0.29.0_linux_amd64.deb
|
||||
sudo dpkg -i supabase.deb
|
||||
fi
|
||||
|
||||
# Start Supabase, grep key and set it as SUPABASE_SERVICE_ROLE_KEY environment variable
|
||||
line=$(supabase start | grep 'service_role key')
|
||||
IFS=':'; arr=($line); unset IFS;
|
||||
export SUPABASE_SERVICE_ROLE_KEY=${arr[1]}
|
||||
|
||||
# Always stop Supabase, but exit with 1 when tests are failing
|
||||
if npx jest; then
|
||||
supabase stop
|
||||
else
|
||||
supabase stop && exit 1
|
||||
fi
|
||||
8
packages/adapter-supabase/tsconfig.json
Normal file
8
packages/adapter-supabase/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@next-auth/tsconfig/tsconfig.adapters.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "src",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": ["tests", "dist", "jest.config.js"]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "next-auth",
|
||||
"version": "4.16.4",
|
||||
"version": "4.18.5",
|
||||
"description": "Authentication for Next.js",
|
||||
"homepage": "https://next-auth.js.org",
|
||||
"repository": "https://github.com/nextauthjs/next-auth.git",
|
||||
@@ -120,7 +120,7 @@
|
||||
"jest-environment-jsdom": "^28.1.1",
|
||||
"jest-watch-typeahead": "^1.1.0",
|
||||
"msw": "^0.42.3",
|
||||
"next": "13.0.2",
|
||||
"next": "13.0.6",
|
||||
"postcss": "^8.4.14",
|
||||
"postcss-cli": "^9.1.0",
|
||||
"postcss-nested": "^5.0.6",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { IncomingMessage } from "http"
|
||||
import type { LoggerInstance, Session } from ".."
|
||||
|
||||
export interface NextAuthClientConfig {
|
||||
export interface AuthClientConfig {
|
||||
baseUrl: string
|
||||
basePath: string
|
||||
baseUrlServer: string
|
||||
@@ -31,7 +31,7 @@ export interface CtxOrReq {
|
||||
*/
|
||||
export async function fetchData<T = any>(
|
||||
path: string,
|
||||
__NEXTAUTH: NextAuthClientConfig,
|
||||
__NEXTAUTH: AuthClientConfig,
|
||||
logger: LoggerInstance,
|
||||
{ ctx, req = ctx?.req }: CtxOrReq = {}
|
||||
): Promise<T | null> {
|
||||
@@ -50,7 +50,7 @@ export async function fetchData<T = any>(
|
||||
}
|
||||
}
|
||||
|
||||
export function apiBaseUrl(__NEXTAUTH: NextAuthClientConfig) {
|
||||
export function apiBaseUrl(__NEXTAUTH: AuthClientConfig) {
|
||||
if (typeof window === "undefined") {
|
||||
// Return absolute path when called server side
|
||||
return `${__NEXTAUTH.baseUrlServer}${__NEXTAUTH.basePathServer}`
|
||||
|
||||
@@ -72,6 +72,16 @@ export class InvalidCallbackUrl extends UnknownError {
|
||||
code = "INVALID_CALLBACK_URL_ERROR"
|
||||
}
|
||||
|
||||
export class UnknownAction extends UnknownError {
|
||||
name = "UnknownAction"
|
||||
code = "UNKNOWN_ACTION_ERROR"
|
||||
}
|
||||
|
||||
export class UntrustedHost extends UnknownError {
|
||||
name = "UntrustedHost"
|
||||
code = "UNTRUST_HOST_ERROR"
|
||||
}
|
||||
|
||||
type Method = (...args: any[]) => Promise<any>
|
||||
|
||||
export function upperSnake(s: string) {
|
||||
|
||||
@@ -1,92 +1,55 @@
|
||||
import logger, { setLogger } from "../utils/logger"
|
||||
import { detectHost } from "../utils/detect-host"
|
||||
import * as routes from "./routes"
|
||||
import renderPage from "./pages"
|
||||
import { toInternalRequest, toResponse } from "../utils/web"
|
||||
import { init } from "./init"
|
||||
import { assertConfig } from "./lib/assert"
|
||||
import { SessionStore } from "./lib/cookie"
|
||||
import renderPage from "./pages"
|
||||
import * as routes from "./routes"
|
||||
|
||||
import type { NextAuthAction, NextAuthOptions } from "./types"
|
||||
import { UntrustedHost } from "./errors"
|
||||
import type { Cookie } from "./lib/cookie"
|
||||
import type { ErrorType } from "./pages/error"
|
||||
import { parse as parseCookie } from "cookie"
|
||||
import type { AuthAction, AuthOptions } from "./types"
|
||||
|
||||
/** @internal */
|
||||
export interface RequestInternal {
|
||||
/** @default "http://localhost:3000" */
|
||||
host?: string
|
||||
method?: string
|
||||
url: URL
|
||||
/** @default "GET" */
|
||||
method: string
|
||||
cookies?: Partial<Record<string, string>>
|
||||
headers?: Record<string, any>
|
||||
query?: Record<string, any>
|
||||
body?: Record<string, any>
|
||||
action: NextAuthAction
|
||||
action: AuthAction
|
||||
providerId?: string
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface NextAuthHeader {
|
||||
key: string
|
||||
value: string
|
||||
}
|
||||
|
||||
export interface OutgoingResponse<
|
||||
/** @internal */
|
||||
export interface ResponseInternal<
|
||||
Body extends string | Record<string, any> | any[] = any
|
||||
> {
|
||||
status?: number
|
||||
headers?: NextAuthHeader[]
|
||||
headers?: Record<string, string>
|
||||
body?: Body
|
||||
redirect?: string
|
||||
cookies?: Cookie[]
|
||||
}
|
||||
|
||||
export interface NextAuthHandlerParams {
|
||||
req: Request | RequestInternal
|
||||
options: NextAuthOptions
|
||||
}
|
||||
const configErrorMessage =
|
||||
"There is a problem with the server configuration. Check the server logs for more information."
|
||||
|
||||
async function getBody(req: Request): Promise<Record<string, any> | undefined> {
|
||||
try {
|
||||
return await req.json()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
async function toInternalRequest(
|
||||
req: RequestInternal | Request
|
||||
): Promise<RequestInternal> {
|
||||
if (req instanceof Request) {
|
||||
const url = new URL(req.url)
|
||||
// TODO: handle custom paths?
|
||||
const nextauth = url.pathname.split("/").slice(3)
|
||||
const headers = Object.fromEntries(req.headers)
|
||||
const query: Record<string, any> = Object.fromEntries(url.searchParams)
|
||||
query.nextauth = nextauth
|
||||
|
||||
return {
|
||||
action: nextauth[0] as NextAuthAction,
|
||||
method: req.method,
|
||||
headers,
|
||||
body: await getBody(req),
|
||||
cookies: parseCookie(req.headers.get("cookie") ?? ""),
|
||||
providerId: nextauth[1],
|
||||
error: url.searchParams.get("error") ?? nextauth[1],
|
||||
host: detectHost(headers["x-forwarded-host"] ?? headers.host),
|
||||
query,
|
||||
}
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
export async function NextAuthHandler<
|
||||
async function AuthHandlerInternal<
|
||||
Body extends string | Record<string, any> | any[]
|
||||
>(params: NextAuthHandlerParams): Promise<OutgoingResponse<Body>> {
|
||||
const { options: userOptions, req: incomingRequest } = params
|
||||
>(params: {
|
||||
req: RequestInternal
|
||||
options: AuthOptions
|
||||
/** REVIEW: Is this the best way to skip parsing the body in Node.js? */
|
||||
parsedBody?: any
|
||||
}): Promise<ResponseInternal<Body>> {
|
||||
const { options: authOptions, req } = params
|
||||
|
||||
const req = await toInternalRequest(incomingRequest)
|
||||
|
||||
setLogger(userOptions.logger, userOptions.debug)
|
||||
|
||||
const assertionResult = assertConfig({ options: userOptions, req })
|
||||
const assertionResult = assertConfig({ options: authOptions, req })
|
||||
|
||||
if (Array.isArray(assertionResult)) {
|
||||
assertionResult.forEach(logger.warn)
|
||||
@@ -96,14 +59,13 @@ export async function NextAuthHandler<
|
||||
|
||||
const htmlPages = ["signin", "signout", "error", "verify-request"]
|
||||
if (!htmlPages.includes(req.action) || req.method !== "GET") {
|
||||
const message = `There is a problem with the server configuration. Check the server logs for more information.`
|
||||
return {
|
||||
status: 500,
|
||||
headers: [{ key: "Content-Type", value: "application/json" }],
|
||||
body: { message } as any,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: { message: configErrorMessage } as any,
|
||||
}
|
||||
}
|
||||
const { pages, theme } = userOptions
|
||||
const { pages, theme } = authOptions
|
||||
|
||||
const authOnErrorPage =
|
||||
pages?.error && req.query?.callbackUrl?.startsWith(pages.error)
|
||||
@@ -126,13 +88,13 @@ export async function NextAuthHandler<
|
||||
}
|
||||
}
|
||||
|
||||
const { action, providerId, error, method = "GET" } = req
|
||||
const { action, providerId, error, method } = req
|
||||
|
||||
const { options, cookies } = await init({
|
||||
userOptions,
|
||||
authOptions,
|
||||
action,
|
||||
providerId,
|
||||
host: req.host,
|
||||
url: req.url,
|
||||
callbackUrl: req.body?.callbackUrl ?? req.query?.callbackUrl,
|
||||
csrfToken: req.body?.csrfToken,
|
||||
cookies: req.cookies,
|
||||
@@ -154,11 +116,12 @@ export async function NextAuthHandler<
|
||||
case "session": {
|
||||
const session = await routes.session({ options, sessionStore })
|
||||
if (session.cookies) cookies.push(...session.cookies)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
||||
return { ...session, cookies } as any
|
||||
}
|
||||
case "csrf":
|
||||
return {
|
||||
headers: [{ key: "Content-Type", value: "application/json" }],
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: { csrfToken: options.csrfToken } as any,
|
||||
cookies,
|
||||
}
|
||||
@@ -275,7 +238,7 @@ export async function NextAuthHandler<
|
||||
}
|
||||
break
|
||||
case "_log":
|
||||
if (userOptions.logger) {
|
||||
if (authOptions.logger) {
|
||||
try {
|
||||
const { code, level, ...metadata } = req.body ?? {}
|
||||
logger[level](code, metadata)
|
||||
@@ -294,3 +257,51 @@ export async function NextAuthHandler<
|
||||
body: `Error: This action with HTTP ${method} is not supported by NextAuth.js` as any,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The core functionality of `next-auth`.
|
||||
* It receives a standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
||||
* and returns a standard [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
||||
*/
|
||||
export async function AuthHandler(
|
||||
request: Request,
|
||||
options: AuthOptions
|
||||
): Promise<Response> {
|
||||
setLogger(options.logger, options.debug)
|
||||
|
||||
if (!options.trustHost) {
|
||||
const error = new UntrustedHost(
|
||||
`Host must be trusted. URL was: ${request.url}`
|
||||
)
|
||||
logger.error(error.code, error)
|
||||
|
||||
return new Response(JSON.stringify({ message: configErrorMessage }), {
|
||||
status: 500,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
})
|
||||
}
|
||||
|
||||
const req = await toInternalRequest(request)
|
||||
if (req instanceof Error) {
|
||||
logger.error((req as any).code, req)
|
||||
return new Response(
|
||||
`Error: This action with HTTP ${request.method} is not supported.`,
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
const internalResponse = await AuthHandlerInternal({ req, options })
|
||||
|
||||
const response = await toResponse(internalResponse)
|
||||
|
||||
// If the request expects a return URL, send it as JSON
|
||||
// instead of doing an actual redirect.
|
||||
const redirect = response.headers.get("Location")
|
||||
if (request.headers.has("X-Auth-Return-Redirect") && redirect) {
|
||||
response.headers.delete("Location")
|
||||
response.headers.set("Content-Type", "application/json")
|
||||
return new Response(JSON.stringify({ url: redirect }), {
|
||||
headers: response.headers,
|
||||
})
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { randomBytes, randomUUID } from "crypto"
|
||||
import { NextAuthOptions } from ".."
|
||||
import { AuthOptions } from ".."
|
||||
import logger from "../utils/logger"
|
||||
import parseUrl from "../utils/parse-url"
|
||||
import { adapterErrorHandler, eventsErrorHandler } from "./errors"
|
||||
import parseProviders from "./lib/providers"
|
||||
import { createSecret } from "./lib/utils"
|
||||
@@ -13,10 +12,11 @@ import { createCallbackUrl } from "./lib/callback-url"
|
||||
import { RequestInternal } from "."
|
||||
|
||||
import type { InternalOptions } from "./types"
|
||||
import parseUrl from "../utils/parse-url"
|
||||
|
||||
interface InitParams {
|
||||
host?: string
|
||||
userOptions: NextAuthOptions
|
||||
url: URL
|
||||
authOptions: AuthOptions
|
||||
providerId?: string
|
||||
action: InternalOptions["action"]
|
||||
/** Callback URL value extracted from the incoming request. */
|
||||
@@ -30,10 +30,10 @@ interface InitParams {
|
||||
|
||||
/** Initialize all internal options and cookies. */
|
||||
export async function init({
|
||||
userOptions,
|
||||
authOptions,
|
||||
providerId,
|
||||
action,
|
||||
host,
|
||||
url: reqUrl,
|
||||
cookies: reqCookies,
|
||||
callbackUrl: reqCallbackUrl,
|
||||
csrfToken: reqCsrfToken,
|
||||
@@ -42,12 +42,17 @@ export async function init({
|
||||
options: InternalOptions
|
||||
cookies: cookie.Cookie[]
|
||||
}> {
|
||||
const url = parseUrl(host)
|
||||
// TODO: move this to web.ts
|
||||
const parsed = parseUrl(
|
||||
reqUrl.origin +
|
||||
reqUrl.pathname.replace(`/${action}`, "").replace(`/${providerId}`, "")
|
||||
)
|
||||
const url = new URL(parsed.toString())
|
||||
|
||||
const secret = createSecret({ userOptions, url })
|
||||
const secret = createSecret({ authOptions, url })
|
||||
|
||||
const { providers, provider } = parseProviders({
|
||||
providers: userOptions.providers,
|
||||
providers: authOptions.providers,
|
||||
url,
|
||||
providerId,
|
||||
})
|
||||
@@ -66,7 +71,7 @@ export async function init({
|
||||
buttonText: "",
|
||||
},
|
||||
// Custom options override defaults
|
||||
...userOptions,
|
||||
...authOptions,
|
||||
// These computed settings can have values in userOptions but we override them
|
||||
// and are request-specific.
|
||||
url,
|
||||
@@ -75,24 +80,24 @@ export async function init({
|
||||
provider,
|
||||
cookies: {
|
||||
...cookie.defaultCookies(
|
||||
userOptions.useSecureCookies ?? url.base.startsWith("https://")
|
||||
authOptions.useSecureCookies ?? url.protocol === "https:"
|
||||
),
|
||||
// Allow user cookie options to override any cookie settings above
|
||||
...userOptions.cookies,
|
||||
...authOptions.cookies,
|
||||
},
|
||||
secret,
|
||||
providers,
|
||||
// Session options
|
||||
session: {
|
||||
// If no adapter specified, force use of JSON Web Tokens (stateless)
|
||||
strategy: userOptions.adapter ? "database" : "jwt",
|
||||
strategy: authOptions.adapter ? "database" : "jwt",
|
||||
maxAge,
|
||||
updateAge: 24 * 60 * 60,
|
||||
generateSessionToken: () => {
|
||||
// Use `randomUUID` if available. (Node 15.6+)
|
||||
return randomUUID?.() ?? randomBytes(32).toString("hex")
|
||||
},
|
||||
...userOptions.session,
|
||||
...authOptions.session,
|
||||
},
|
||||
// JWT options
|
||||
jwt: {
|
||||
@@ -100,13 +105,13 @@ export async function init({
|
||||
maxAge, // same as session maxAge,
|
||||
encode: jwt.encode,
|
||||
decode: jwt.decode,
|
||||
...userOptions.jwt,
|
||||
...authOptions.jwt,
|
||||
},
|
||||
// Event messages
|
||||
events: eventsErrorHandler(userOptions.events ?? {}, logger),
|
||||
adapter: adapterErrorHandler(userOptions.adapter, logger),
|
||||
events: eventsErrorHandler(authOptions.events ?? {}, logger),
|
||||
adapter: adapterErrorHandler(authOptions.adapter, logger),
|
||||
// Callback functions
|
||||
callbacks: { ...defaultCallbacks, ...userOptions.callbacks },
|
||||
callbacks: { ...defaultCallbacks, ...authOptions.callbacks },
|
||||
logger,
|
||||
callbackUrl: url.origin,
|
||||
}
|
||||
|
||||
@@ -7,12 +7,11 @@ import {
|
||||
InvalidCallbackUrl,
|
||||
MissingAdapterMethods,
|
||||
} from "../errors"
|
||||
import parseUrl from "../../utils/parse-url"
|
||||
import { defaultCookies } from "./cookie"
|
||||
|
||||
import type { RequestInternal } from ".."
|
||||
import type { WarningCode } from "../../utils/logger"
|
||||
import type { NextAuthOptions } from "../types"
|
||||
import type { AuthOptions } from "../types"
|
||||
|
||||
type ConfigError =
|
||||
| MissingAPIRoute
|
||||
@@ -40,15 +39,15 @@ function isValidHttpUrl(url: string, baseUrl: string) {
|
||||
* REVIEW: Make some of these and corresponding docs less Next.js specific?
|
||||
*/
|
||||
export function assertConfig(params: {
|
||||
options: NextAuthOptions
|
||||
options: AuthOptions
|
||||
req: RequestInternal
|
||||
}): ConfigError | WarningCode[] {
|
||||
const { options, req } = params
|
||||
|
||||
const { url } = req
|
||||
const warnings: WarningCode[] = []
|
||||
|
||||
if (!warned) {
|
||||
if (!req.host) warnings.push("NEXTAUTH_URL")
|
||||
if (!url.origin) warnings.push("NEXTAUTH_URL")
|
||||
|
||||
// TODO: Make this throw an error in next major. This will also get rid of `NODE_ENV`
|
||||
if (!options.secret && process.env.NODE_ENV !== "production")
|
||||
@@ -70,21 +69,19 @@ export function assertConfig(params: {
|
||||
|
||||
const callbackUrlParam = req.query?.callbackUrl as string | undefined
|
||||
|
||||
const url = parseUrl(req.host)
|
||||
|
||||
if (callbackUrlParam && !isValidHttpUrl(callbackUrlParam, url.base)) {
|
||||
if (callbackUrlParam && !isValidHttpUrl(callbackUrlParam, url.origin)) {
|
||||
return new InvalidCallbackUrl(
|
||||
`Invalid callback URL. Received: ${callbackUrlParam}`
|
||||
)
|
||||
}
|
||||
|
||||
const { callbackUrl: defaultCallbackUrl } = defaultCookies(
|
||||
options.useSecureCookies ?? url.base.startsWith("https://")
|
||||
options.useSecureCookies ?? url.protocol === "https://"
|
||||
)
|
||||
const callbackUrlCookie =
|
||||
req.cookies?.[options.cookies?.callbackUrl?.name ?? defaultCallbackUrl.name]
|
||||
|
||||
if (callbackUrlCookie && !isValidHttpUrl(callbackUrlCookie, url.base)) {
|
||||
if (callbackUrlCookie && !isValidHttpUrl(callbackUrlCookie, url.origin)) {
|
||||
return new InvalidCallbackUrl(
|
||||
`Invalid callback URL. Received: ${callbackUrlCookie}`
|
||||
)
|
||||
|
||||
@@ -93,6 +93,7 @@ export function defaultCookies(useSecureCookies: boolean): CookiesOptions {
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
secure: useSecureCookies,
|
||||
maxAge: 60 * 15, // 15 minutes in seconds
|
||||
},
|
||||
},
|
||||
state: {
|
||||
@@ -102,6 +103,7 @@ export function defaultCookies(useSecureCookies: boolean): CookiesOptions {
|
||||
sameSite: "lax",
|
||||
path: "/",
|
||||
secure: useSecureCookies,
|
||||
maxAge: 60 * 15, // 15 minutes in seconds
|
||||
},
|
||||
},
|
||||
nonce: {
|
||||
|
||||
@@ -26,13 +26,15 @@ export async function createPKCE(options: InternalOptions<"oauth">): Promise<
|
||||
const code_verifier = generators.codeVerifier()
|
||||
const code_challenge = generators.codeChallenge(code_verifier)
|
||||
|
||||
const maxAge = cookies.pkceCodeVerifier.options.maxAge ?? PKCE_MAX_AGE
|
||||
|
||||
const expires = new Date()
|
||||
expires.setTime(expires.getTime() + PKCE_MAX_AGE * 1000)
|
||||
expires.setTime(expires.getTime() + maxAge * 1000)
|
||||
|
||||
// Encrypt code_verifier and save it to an encrypted cookie
|
||||
const encryptedCodeVerifier = await jwt.encode({
|
||||
...options.jwt,
|
||||
maxAge: PKCE_MAX_AGE,
|
||||
maxAge,
|
||||
token: { code_verifier },
|
||||
})
|
||||
|
||||
@@ -40,7 +42,7 @@ export async function createPKCE(options: InternalOptions<"oauth">): Promise<
|
||||
code_challenge,
|
||||
code_challenge_method: PKCE_CODE_CHALLENGE_METHOD,
|
||||
code_verifier,
|
||||
PKCE_MAX_AGE,
|
||||
maxAge,
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
@@ -17,17 +17,18 @@ export async function createState(
|
||||
}
|
||||
|
||||
const state = generators.state()
|
||||
const maxAge = cookies.state.options.maxAge ?? STATE_MAX_AGE
|
||||
|
||||
const encodedState = await jwt.encode({
|
||||
...jwt,
|
||||
maxAge: STATE_MAX_AGE,
|
||||
maxAge,
|
||||
token: { state },
|
||||
})
|
||||
|
||||
logger.debug("CREATE_STATE", { state, maxAge: STATE_MAX_AGE })
|
||||
logger.debug("CREATE_STATE", { state, maxAge })
|
||||
|
||||
const expires = new Date()
|
||||
expires.setTime(expires.getTime() + STATE_MAX_AGE * 1000)
|
||||
expires.setTime(expires.getTime() + maxAge * 1000)
|
||||
return {
|
||||
value: state,
|
||||
cookie: {
|
||||
|
||||
@@ -2,11 +2,10 @@ import { merge } from "../../utils/merge"
|
||||
|
||||
import type { InternalProvider } from "../types"
|
||||
import type {
|
||||
InternalOAuthConfig,
|
||||
OAuthConfigInternal,
|
||||
OAuthConfig,
|
||||
Provider,
|
||||
} from "../../providers"
|
||||
import type { InternalUrl } from "../../utils/parse-url"
|
||||
|
||||
/**
|
||||
* Adds `signinUrl` and `callbackUrl` to each provider
|
||||
@@ -14,7 +13,7 @@ import type { InternalUrl } from "../../utils/parse-url"
|
||||
*/
|
||||
export default function parseProviders(params: {
|
||||
providers: Provider[]
|
||||
url: InternalUrl
|
||||
url: URL
|
||||
providerId?: string
|
||||
}): {
|
||||
providers: InternalProvider[]
|
||||
@@ -59,7 +58,7 @@ function normalizeOAuthOptions(
|
||||
if (!oauthOptions) return
|
||||
|
||||
const normalized = Object.entries(oauthOptions).reduce<
|
||||
InternalOAuthConfig<Record<string, unknown>>
|
||||
OAuthConfigInternal<Record<string, unknown>>
|
||||
>(
|
||||
(acc, [key, value]) => {
|
||||
if (
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { createHash } from "crypto"
|
||||
|
||||
import type { NextAuthOptions } from "../.."
|
||||
import type { AuthOptions } from "../.."
|
||||
import type { InternalOptions } from "../types"
|
||||
import type { InternalUrl } from "../../utils/parse-url"
|
||||
|
||||
/**
|
||||
* Takes a number in seconds and returns the date in the future.
|
||||
@@ -28,17 +27,14 @@ export function hashToken(token: string, options: InternalOptions<"email">) {
|
||||
* If no secret option is specified then it creates one on the fly
|
||||
* based on options passed here. If options contains unique data, such as
|
||||
* OAuth provider secrets and database credentials it should be sufficent. If no secret provided in production, we throw an error. */
|
||||
export function createSecret(params: {
|
||||
userOptions: NextAuthOptions
|
||||
url: InternalUrl
|
||||
}) {
|
||||
const { userOptions, url } = params
|
||||
export function createSecret(params: { authOptions: AuthOptions; url: URL }) {
|
||||
const { authOptions, url } = params
|
||||
|
||||
return (
|
||||
userOptions.secret ??
|
||||
authOptions.secret ??
|
||||
// TODO: Remove falling back to default secret, and error in dev if one isn't provided
|
||||
createHash("sha256")
|
||||
.update(JSON.stringify({ ...url, ...userOptions }))
|
||||
.update(JSON.stringify({ ...url, ...authOptions }))
|
||||
.digest("hex")
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Theme } from "../.."
|
||||
import { InternalUrl } from "../../utils/parse-url"
|
||||
|
||||
/**
|
||||
* The following errors are passed as error query parameters to the default or overridden error page.
|
||||
@@ -12,7 +11,7 @@ export type ErrorType =
|
||||
| "verification"
|
||||
|
||||
export interface ErrorProps {
|
||||
url?: InternalUrl
|
||||
url?: URL
|
||||
theme?: Theme
|
||||
error?: ErrorType
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import ErrorPage from "./error"
|
||||
import css from "../../css"
|
||||
|
||||
import type { InternalOptions } from "../types"
|
||||
import type { RequestInternal, OutgoingResponse } from ".."
|
||||
import type { RequestInternal, ResponseInternal } from ".."
|
||||
import type { Cookie } from "../lib/cookie"
|
||||
import type { ErrorType } from "./error"
|
||||
|
||||
@@ -27,11 +27,11 @@ type RenderPageParams = {
|
||||
export default function renderPage(params: RenderPageParams) {
|
||||
const { url, theme, query, cookies } = params
|
||||
|
||||
function send({ html, title, status }: any): OutgoingResponse {
|
||||
function send({ html, title, status }: any): ResponseInternal {
|
||||
return {
|
||||
cookies,
|
||||
status,
|
||||
headers: [{ key: "Content-Type", value: "text/html" }],
|
||||
headers: { "Content-Type": "text/html" },
|
||||
body: `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><style>${css()}</style><title>${title}</title></head><body class="__next-auth-theme-${
|
||||
theme?.colorScheme ?? "auto"
|
||||
}"><div class="page">${renderToString(html)}</div></body></html>`,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Theme } from "../.."
|
||||
import { InternalUrl } from "../../utils/parse-url"
|
||||
|
||||
export interface SignoutProps {
|
||||
url: InternalUrl
|
||||
url: URL
|
||||
csrfToken: string
|
||||
theme: Theme
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { hashToken } from "../lib/utils"
|
||||
import getAdapterUserFromEmail from "../lib/email/getUserFromEmail"
|
||||
|
||||
import type { InternalOptions } from "../types"
|
||||
import type { RequestInternal, OutgoingResponse } from ".."
|
||||
import type { RequestInternal, ResponseInternal } from ".."
|
||||
import type { Cookie, SessionStore } from "../lib/cookie"
|
||||
import type { User } from "../.."
|
||||
import type { AdapterSession } from "../../adapters"
|
||||
@@ -18,7 +18,7 @@ export default async function callback(params: {
|
||||
headers: RequestInternal["headers"]
|
||||
cookies: RequestInternal["cookies"]
|
||||
sessionStore: SessionStore
|
||||
}): Promise<OutgoingResponse> {
|
||||
}): Promise<ResponseInternal> {
|
||||
const { options, query, body, method, headers, sessionStore } = params
|
||||
const {
|
||||
provider,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { OutgoingResponse } from ".."
|
||||
import type { ResponseInternal } from ".."
|
||||
import type { InternalProvider } from "../types"
|
||||
|
||||
export interface PublicProvider {
|
||||
@@ -16,9 +16,9 @@ export interface PublicProvider {
|
||||
*/
|
||||
export default function providers(
|
||||
providers: InternalProvider[]
|
||||
): OutgoingResponse<Record<string, PublicProvider>> {
|
||||
): ResponseInternal<Record<string, PublicProvider>> {
|
||||
return {
|
||||
headers: [{ key: "Content-Type", value: "application/json" }],
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: providers.reduce<Record<string, PublicProvider>>(
|
||||
(acc, { id, name, type, signinUrl, callbackUrl }) => {
|
||||
acc[id] = { id, name, type, signinUrl, callbackUrl }
|
||||
|
||||
@@ -2,7 +2,7 @@ import { fromDate } from "../lib/utils"
|
||||
|
||||
import type { Adapter } from "../../adapters"
|
||||
import type { InternalOptions } from "../types"
|
||||
import type { OutgoingResponse } from ".."
|
||||
import type { ResponseInternal } from ".."
|
||||
import type { Session } from "../.."
|
||||
import type { SessionStore } from "../lib/cookie"
|
||||
|
||||
@@ -18,7 +18,7 @@ interface SessionParams {
|
||||
|
||||
export default async function session(
|
||||
params: SessionParams
|
||||
): Promise<OutgoingResponse<Session | {}>> {
|
||||
): Promise<ResponseInternal<Session | {}>> {
|
||||
const { options, sessionStore } = params
|
||||
const {
|
||||
adapter,
|
||||
@@ -29,9 +29,9 @@ export default async function session(
|
||||
session: { strategy: sessionStrategy, maxAge: sessionMaxAge },
|
||||
} = options
|
||||
|
||||
const response: OutgoingResponse<Session | {}> = {
|
||||
const response: ResponseInternal<Session | {}> = {
|
||||
body: {},
|
||||
headers: [{ key: "Content-Type", value: "application/json" }],
|
||||
headers: { "Content-Type": "application/json" },
|
||||
cookies: [],
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import getAuthorizationUrl from "../lib/oauth/authorization-url"
|
||||
import emailSignin from "../lib/email/signin"
|
||||
import getAdapterUserFromEmail from "../lib/email/getUserFromEmail"
|
||||
import type { RequestInternal, OutgoingResponse } from ".."
|
||||
import type { RequestInternal, ResponseInternal } from ".."
|
||||
import type { InternalOptions } from "../types"
|
||||
import type { Account } from "../.."
|
||||
|
||||
@@ -10,7 +10,7 @@ export default async function signin(params: {
|
||||
options: InternalOptions<"oauth" | "email">
|
||||
query: RequestInternal["query"]
|
||||
body: RequestInternal["body"]
|
||||
}): Promise<OutgoingResponse> {
|
||||
}): Promise<ResponseInternal> {
|
||||
const { options, query, body } = params
|
||||
const { url, callbacks, logger, provider } = options
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { Adapter } from "../../adapters"
|
||||
import type { InternalOptions } from "../types"
|
||||
import type { OutgoingResponse } from ".."
|
||||
import type { ResponseInternal } from ".."
|
||||
import type { SessionStore } from "../lib/cookie"
|
||||
|
||||
/** Handle requests to /api/auth/signout */
|
||||
export default async function signout(params: {
|
||||
options: InternalOptions
|
||||
sessionStore: SessionStore
|
||||
}): Promise<OutgoingResponse> {
|
||||
}): Promise<ResponseInternal> {
|
||||
const { options, sessionStore } = params
|
||||
const { adapter, events, jwt, callbackUrl, logger, session } = options
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import type {
|
||||
ProviderType,
|
||||
EmailConfig,
|
||||
CredentialsConfig,
|
||||
InternalOAuthConfig,
|
||||
OAuthConfigInternal,
|
||||
} from "../providers"
|
||||
import type { TokenSetParameters } from "openid-client"
|
||||
import type { JWT, JWTOptions } from "../jwt"
|
||||
@@ -14,8 +14,6 @@ import type { CookieSerializeOptions } from "cookie"
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from "next"
|
||||
|
||||
import type { InternalUrl } from "../utils/parse-url"
|
||||
|
||||
export type Awaitable<T> = T | PromiseLike<T>
|
||||
|
||||
export type { LoggerInstance }
|
||||
@@ -25,7 +23,7 @@ export type { LoggerInstance }
|
||||
*
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#options)
|
||||
*/
|
||||
export interface NextAuthOptions {
|
||||
export interface AuthOptions {
|
||||
/**
|
||||
* An array of authentication providers for signing in
|
||||
* (e.g. Google, Facebook, Twitter, GitHub, Email, etc) in any order.
|
||||
@@ -38,10 +36,10 @@ export interface NextAuthOptions {
|
||||
providers: Provider[]
|
||||
/**
|
||||
* A random string used to hash tokens, sign cookies and generate cryptographic keys.
|
||||
* If not specified, it falls back to `jwt.secret` or `NEXTAUTH_SECRET` from environment vairables.
|
||||
* Otherwise it will use a hash of all configuration options, including Client ID / Secrets for entropy.
|
||||
* If not specified, it falls back to `jwt.secret` or `NEXTAUTH_SECRET` from environment variables.
|
||||
* Otherwise, it will use a hash of all configuration options, including Client ID / Secrets for entropy.
|
||||
*
|
||||
* NOTE: The last behavior is extrmely volatile, and will throw an error in production.
|
||||
* NOTE: The last behavior is extremely volatile, and will throw an error in production.
|
||||
* * **Default value**: `string` (SHA hash of the "options" object)
|
||||
* * **Required**: No - **but strongly recommended**!
|
||||
*
|
||||
@@ -203,6 +201,16 @@ export interface NextAuthOptions {
|
||||
* [Documentation](https://next-auth.js.org/configuration/options#cookies) | [Usage example](https://next-auth.js.org/configuration/options#example)
|
||||
*/
|
||||
cookies?: Partial<CookiesOptions>
|
||||
/**
|
||||
* If set to `true`, NextAuth.js will use either the `x-forwarded-host` or `host` headers,
|
||||
* instead of `NEXTAUTH_URL`
|
||||
* Make sure that reading `x-forwarded-host` on your hosting platform can be trusted.
|
||||
* - ⚠ **This is an advanced option.** Advanced options are passed the same way as basic options,
|
||||
* but **may have complex implications** or side effects.
|
||||
* You should **try to avoid using advanced options** unless you are very comfortable using them.
|
||||
* @default Boolean(process.env.NEXTAUTH_URL ?? process.env.AUTH_TRUST_HOST ?? process.env.VERCEL)
|
||||
*/
|
||||
trustHost?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,7 +499,7 @@ export interface User extends DefaultUser {}
|
||||
|
||||
/** @internal */
|
||||
export type InternalProvider<T = ProviderType> = (T extends "oauth"
|
||||
? InternalOAuthConfig<any>
|
||||
? OAuthConfigInternal<any>
|
||||
: T extends "email"
|
||||
? EmailConfig
|
||||
: T extends "credentials"
|
||||
@@ -501,7 +509,7 @@ export type InternalProvider<T = ProviderType> = (T extends "oauth"
|
||||
callbackUrl: string
|
||||
}
|
||||
|
||||
export type NextAuthAction =
|
||||
export type AuthAction =
|
||||
| "providers"
|
||||
| "session"
|
||||
| "csrf"
|
||||
@@ -518,12 +526,8 @@ export interface InternalOptions<
|
||||
WithVerificationToken = TProviderType extends "email" ? true : false
|
||||
> {
|
||||
providers: InternalProvider[]
|
||||
/**
|
||||
* Parsed from `NEXTAUTH_URL` or `x-forwarded-host` on Vercel.
|
||||
* @default "http://localhost:3000/api/auth"
|
||||
*/
|
||||
url: InternalUrl
|
||||
action: NextAuthAction
|
||||
url: URL
|
||||
action: AuthAction
|
||||
provider: InternalProvider<TProviderType>
|
||||
csrfToken?: string
|
||||
csrfTokenVerified?: boolean
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
export * from "./core/types"
|
||||
|
||||
export type { RequestInternal, OutgoingResponse } from "./core"
|
||||
|
||||
export type { AuthOptions as NextAuthOptions } from "./core/types"
|
||||
export * from "./next"
|
||||
export { default } from "./next"
|
||||
|
||||
@@ -94,7 +94,7 @@ export async function getToken<R extends boolean = false>(
|
||||
const authorizationHeader =
|
||||
req.headers instanceof Headers
|
||||
? req.headers.get("authorization")
|
||||
: req.headers.authorization
|
||||
: req.headers?.authorization
|
||||
|
||||
if (!token && authorizationHeader?.split(" ")[0] === "Bearer") {
|
||||
const urlEncodedToken = authorizationHeader.split(" ")[1]
|
||||
|
||||
@@ -1,101 +1,99 @@
|
||||
import { NextAuthHandler } from "../core"
|
||||
import { detectHost } from "../utils/detect-host"
|
||||
import { setCookie } from "./utils"
|
||||
import { AuthHandler } from "../core"
|
||||
import { getBody, getURL, setHeaders } from "../utils/node"
|
||||
|
||||
import type {
|
||||
GetServerSidePropsContext,
|
||||
NextApiRequest,
|
||||
NextApiResponse,
|
||||
} from "next"
|
||||
import type { NextAuthOptions, Session } from ".."
|
||||
import type { AuthOptions, Session } from ".."
|
||||
import type {
|
||||
NextAuthAction,
|
||||
CallbacksOptions,
|
||||
NextAuthRequest,
|
||||
NextAuthResponse,
|
||||
} from "../core/types"
|
||||
|
||||
async function NextAuthNextHandler(
|
||||
async function NextAuthHandler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
options: NextAuthOptions
|
||||
options: AuthOptions
|
||||
) {
|
||||
const { nextauth, ...query } = req.query
|
||||
|
||||
options.secret =
|
||||
options.secret ?? options.jwt?.secret ?? process.env.NEXTAUTH_SECRET
|
||||
|
||||
const handler = await NextAuthHandler({
|
||||
req: {
|
||||
host: detectHost(req.headers["x-forwarded-host"]),
|
||||
body: req.body,
|
||||
query,
|
||||
cookies: req.cookies,
|
||||
headers: req.headers,
|
||||
method: req.method,
|
||||
action: nextauth?.[0] as NextAuthAction,
|
||||
providerId: nextauth?.[1],
|
||||
error: (req.query.error as string | undefined) ?? nextauth?.[1],
|
||||
},
|
||||
options,
|
||||
})
|
||||
|
||||
res.status(handler.status ?? 200)
|
||||
|
||||
handler.cookies?.forEach((cookie) => setCookie(res, cookie))
|
||||
|
||||
handler.headers?.forEach((h) => res.setHeader(h.key, h.value))
|
||||
|
||||
if (handler.redirect) {
|
||||
// If the request expects a return URL, send it as JSON
|
||||
// instead of doing an actual redirect.
|
||||
if (req.body?.json !== "true") {
|
||||
// Could chain. .end() when lowest target is Node 14
|
||||
// https://github.com/nodejs/node/issues/33148
|
||||
res.status(302).setHeader("Location", handler.redirect)
|
||||
return res.end()
|
||||
}
|
||||
return res.json({ url: handler.redirect })
|
||||
const headers = new Headers(req.headers as any)
|
||||
const url = getURL(req.url, headers)
|
||||
if (url instanceof Error) {
|
||||
if (process.env.NODE_ENV !== "production") throw url
|
||||
const errorLogger = options.logger?.error ?? console.error
|
||||
errorLogger("INVALID_URL", url)
|
||||
res.status(400)
|
||||
return res.json({
|
||||
message:
|
||||
"There is a problem with the server configuration. Check the server logs for more information.",
|
||||
})
|
||||
}
|
||||
|
||||
return res.send(handler.body)
|
||||
const request = new Request(url, {
|
||||
headers,
|
||||
method: req.method,
|
||||
...getBody(req),
|
||||
})
|
||||
|
||||
options.secret ??= options.jwt?.secret ?? process.env.NEXTAUTH_SECRET
|
||||
options.trustHost ??= !!(
|
||||
process.env.NEXTAUTH_URL ??
|
||||
process.env.AUTH_TRUST_HOST ??
|
||||
process.env.VERCEL ??
|
||||
process.env.NODE_ENV !== "production"
|
||||
)
|
||||
|
||||
const response = await AuthHandler(request, options)
|
||||
res.status(response.status)
|
||||
setHeaders(response.headers, res)
|
||||
|
||||
return res.send(await response.text())
|
||||
}
|
||||
|
||||
function NextAuth(options: NextAuthOptions): any
|
||||
function NextAuth(options: AuthOptions): any
|
||||
function NextAuth(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse,
|
||||
options: NextAuthOptions
|
||||
options: AuthOptions
|
||||
): any
|
||||
|
||||
/** The main entry point to next-auth */
|
||||
function NextAuth(
|
||||
...args:
|
||||
| [NextAuthOptions]
|
||||
| [NextApiRequest, NextApiResponse, NextAuthOptions]
|
||||
...args: [AuthOptions] | [NextApiRequest, NextApiResponse, AuthOptions]
|
||||
) {
|
||||
if (args.length === 1) {
|
||||
return async (req: NextAuthRequest, res: NextAuthResponse) =>
|
||||
await NextAuthNextHandler(req, res, args[0])
|
||||
await NextAuthHandler(req, res, args[0])
|
||||
}
|
||||
|
||||
return NextAuthNextHandler(args[0], args[1], args[2])
|
||||
return NextAuthHandler(args[0], args[1], args[2])
|
||||
}
|
||||
|
||||
export default NextAuth
|
||||
|
||||
let experimentalWarningShown = false
|
||||
let experimentalRSCWarningShown = false
|
||||
export async function unstable_getServerSession(
|
||||
|
||||
type GetServerSessionOptions = Partial<Omit<AuthOptions, "callbacks">> & {
|
||||
callbacks?: Omit<AuthOptions["callbacks"], "session"> & {
|
||||
session?: (...args: Parameters<CallbacksOptions["session"]>) => any
|
||||
}
|
||||
}
|
||||
|
||||
export async function unstable_getServerSession<
|
||||
O extends GetServerSessionOptions,
|
||||
R = O["callbacks"] extends { session: (...args: any[]) => infer U }
|
||||
? U
|
||||
: Session
|
||||
>(
|
||||
...args:
|
||||
| [
|
||||
GetServerSidePropsContext["req"],
|
||||
GetServerSidePropsContext["res"],
|
||||
NextAuthOptions
|
||||
]
|
||||
| [NextApiRequest, NextApiResponse, NextAuthOptions]
|
||||
| [NextAuthOptions]
|
||||
| [GetServerSidePropsContext["req"], GetServerSidePropsContext["res"], O]
|
||||
| [NextApiRequest, NextApiResponse, O]
|
||||
| [O]
|
||||
| []
|
||||
): Promise<Session | null> {
|
||||
): Promise<R | null> {
|
||||
if (!experimentalWarningShown && process.env.NODE_ENV !== "production") {
|
||||
console.warn(
|
||||
"[next-auth][warn][EXPERIMENTAL_API]",
|
||||
@@ -121,9 +119,10 @@ export async function unstable_getServerSession(
|
||||
experimentalRSCWarningShown = true
|
||||
}
|
||||
|
||||
let req, res, options: NextAuthOptions
|
||||
let req, res, options: AuthOptions
|
||||
if (isRSC) {
|
||||
options = args[0] ?? { providers: [] }
|
||||
options = Object.assign({}, args[0], { providers: [] })
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { headers, cookies } = require("next/headers")
|
||||
req = {
|
||||
@@ -138,44 +137,42 @@ export async function unstable_getServerSession(
|
||||
} else {
|
||||
req = args[0]
|
||||
res = args[1]
|
||||
options = args[2]
|
||||
options = Object.assign({}, args[2], { providers: [] })
|
||||
}
|
||||
|
||||
options.secret = options.secret ?? process.env.NEXTAUTH_SECRET
|
||||
|
||||
const session = await NextAuthHandler<Session | {} | string>({
|
||||
options,
|
||||
req: {
|
||||
host: detectHost(req.headers["x-forwarded-host"]),
|
||||
action: "session",
|
||||
method: "GET",
|
||||
cookies: req.cookies,
|
||||
headers: req.headers,
|
||||
},
|
||||
})
|
||||
|
||||
const { body, cookies, status = 200 } = session
|
||||
|
||||
cookies?.forEach((cookie) => setCookie(res, cookie))
|
||||
|
||||
if (body && typeof body !== "string" && Object.keys(body).length) {
|
||||
if (status === 200) {
|
||||
// @ts-expect-error
|
||||
if (isRSC) delete body.expires
|
||||
return body as Session
|
||||
}
|
||||
throw new Error((body as any).message)
|
||||
const url = getURL("/api/auth/session", new Headers(req.headers))
|
||||
if (url instanceof Error) {
|
||||
if (process.env.NODE_ENV !== "production") throw url
|
||||
const errorLogger = options.logger?.error ?? console.error
|
||||
errorLogger("INVALID_URL", url)
|
||||
res.status(400)
|
||||
return res.json({
|
||||
message:
|
||||
"There is a problem with the server configuration. Check the server logs for more information.",
|
||||
})
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
NEXTAUTH_URL?: string
|
||||
VERCEL?: "1"
|
||||
}
|
||||
}
|
||||
const request = new Request(url, { headers: new Headers(req.headers) })
|
||||
|
||||
options.secret ??= process.env.NEXTAUTH_SECRET
|
||||
options.trustHost = true
|
||||
const response = await AuthHandler(request, options)
|
||||
|
||||
const { status = 200, headers } = response
|
||||
|
||||
setHeaders(headers, res)
|
||||
|
||||
// This would otherwise break rendering
|
||||
// with `getServerSideProps` that needs to always return HTML
|
||||
res.removeHeader?.("Content-Type")
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
if (!data || !Object.keys(data).length) return null
|
||||
|
||||
if (status === 200) {
|
||||
if (isRSC) delete data.expires
|
||||
return data as R
|
||||
}
|
||||
throw new Error(data.message)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import type { NextMiddleware, NextFetchEvent } from "next/server"
|
||||
import type { Awaitable, CookieOption, NextAuthOptions } from ".."
|
||||
import type { Awaitable, CookieOption, AuthOptions } from ".."
|
||||
import type { JWT, JWTOptions } from "../jwt"
|
||||
|
||||
import { NextResponse, NextRequest } from "next/server"
|
||||
|
||||
import { getToken } from "../jwt"
|
||||
import parseUrl from "../utils/parse-url"
|
||||
import { detectHost } from "../utils/web"
|
||||
|
||||
type AuthorizedCallback = (params: {
|
||||
token: JWT | null
|
||||
@@ -20,7 +21,7 @@ export interface NextAuthMiddlewareOptions {
|
||||
* ---
|
||||
* [Documentation](https://next-auth.js.org/configuration/pages)
|
||||
*/
|
||||
pages?: NextAuthOptions["pages"]
|
||||
pages?: AuthOptions["pages"]
|
||||
|
||||
/**
|
||||
* You can override the default cookie names and options for any of the cookies
|
||||
@@ -38,7 +39,7 @@ export interface NextAuthMiddlewareOptions {
|
||||
*/
|
||||
cookies?: Partial<
|
||||
Record<
|
||||
keyof Pick<keyof NextAuthOptions["cookies"], "sessionToken">,
|
||||
keyof Pick<keyof AuthOptions["cookies"], "sessionToken">,
|
||||
Omit<CookieOption, "options">
|
||||
>
|
||||
>
|
||||
@@ -56,7 +57,7 @@ export interface NextAuthMiddlewareOptions {
|
||||
* Callback that receives the user's JWT payload
|
||||
* and returns `true` to allow the user to continue.
|
||||
*
|
||||
* This is similar to the `signIn` callback in `NextAuthOptions`.
|
||||
* This is similar to the `signIn` callback in `AuthOptions`.
|
||||
*
|
||||
* If it returns `false`, the user is redirected to the sign-in page instead
|
||||
*
|
||||
@@ -89,23 +90,43 @@ export interface NextAuthMiddlewareOptions {
|
||||
* The same `secret` used in the `NextAuth` configuration.
|
||||
* Defaults to the `NEXTAUTH_SECRET` environment variable.
|
||||
*/
|
||||
secret?: string
|
||||
secret?: AuthOptions["secret"]
|
||||
/**
|
||||
* If set to `true`, NextAuth.js will use either the `x-forwarded-host` or `host` headers,
|
||||
* instead of `NEXTAUTH_URL`
|
||||
* Make sure that reading `x-forwarded-host` on your hosting platform can be trusted.
|
||||
* - ⚠ **This is an advanced option.** Advanced options are passed the same way as basic options,
|
||||
* but **may have complex implications** or side effects.
|
||||
* You should **try to avoid using advanced options** unless you are very comfortable using them.
|
||||
* @default Boolean(process.env.VERCEL ?? process.env.AUTH_TRUST_HOST)
|
||||
*/
|
||||
trustHost?: AuthOptions["trustHost"]
|
||||
}
|
||||
|
||||
// TODO: `NextMiddleware` should allow returning `void`
|
||||
// Simplify when https://github.com/vercel/next.js/pull/38625 is merged.
|
||||
type NextMiddlewareResult = ReturnType<NextMiddleware> | void // eslint-disable-line @typescript-eslint/no-invalid-void-type
|
||||
|
||||
async function handleMiddleware(
|
||||
req: NextRequest,
|
||||
options: NextAuthMiddlewareOptions | undefined,
|
||||
onSuccess?: (token: JWT | null) => Promise<NextMiddlewareResult>
|
||||
options: NextAuthMiddlewareOptions | undefined = {},
|
||||
onSuccess?: (token: JWT | null) => ReturnType<NextMiddleware>
|
||||
) {
|
||||
const { pathname, search, origin, basePath } = req.nextUrl
|
||||
|
||||
const signInPage = options?.pages?.signIn ?? "/api/auth/signin"
|
||||
const errorPage = options?.pages?.error ?? "/api/auth/error"
|
||||
const authPath = parseUrl(process.env.NEXTAUTH_URL).path
|
||||
|
||||
options.trustHost ??= !!(
|
||||
process.env.NEXTAUTH_URL ??
|
||||
process.env.VERCEL ??
|
||||
process.env.AUTH_TRUST_HOST
|
||||
)
|
||||
|
||||
const host = detectHost(
|
||||
options.trustHost,
|
||||
req.headers?.get("x-forwarded-host"),
|
||||
process.env.NEXTAUTH_URL ??
|
||||
(process.env.NODE_ENV !== "production" && "http://localhost:3000")
|
||||
)
|
||||
const authPath = parseUrl(host).path
|
||||
|
||||
const publicPaths = ["/_next", "/favicon.ico"]
|
||||
|
||||
// Avoid infinite redirects/invalid response
|
||||
@@ -118,8 +139,8 @@ async function handleMiddleware(
|
||||
return
|
||||
}
|
||||
|
||||
const secret = options?.secret ?? process.env.NEXTAUTH_SECRET
|
||||
if (!secret) {
|
||||
options.secret ??= process.env.NEXTAUTH_SECRET
|
||||
if (!options.secret) {
|
||||
console.error(
|
||||
`[next-auth][error][NO_SECRET]`,
|
||||
`\nhttps://next-auth.js.org/errors#no_secret`
|
||||
@@ -133,9 +154,9 @@ async function handleMiddleware(
|
||||
|
||||
const token = await getToken({
|
||||
req,
|
||||
decode: options?.jwt?.decode,
|
||||
decode: options.jwt?.decode,
|
||||
cookieName: options?.cookies?.sessionToken?.name,
|
||||
secret,
|
||||
secret: options.secret,
|
||||
})
|
||||
|
||||
const isAuthorized =
|
||||
@@ -146,7 +167,10 @@ async function handleMiddleware(
|
||||
|
||||
// the user is not logged in, redirect to the sign-in page
|
||||
const signInUrl = new URL(`${basePath}${signInPage}`, origin)
|
||||
signInUrl.searchParams.append("callbackUrl", `${basePath}${pathname}${search}`)
|
||||
signInUrl.searchParams.append(
|
||||
"callbackUrl",
|
||||
`${basePath}${pathname}${search}`
|
||||
)
|
||||
return NextResponse.redirect(signInUrl)
|
||||
}
|
||||
|
||||
@@ -157,7 +181,7 @@ export interface NextRequestWithAuth extends NextRequest {
|
||||
export type NextMiddlewareWithAuth = (
|
||||
request: NextRequestWithAuth,
|
||||
event: NextFetchEvent
|
||||
) => NextMiddlewareResult | Promise<NextMiddlewareResult>
|
||||
) => ReturnType<NextMiddleware>
|
||||
|
||||
export type WithAuthArgs =
|
||||
| [NextRequestWithAuth]
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { serialize } from "cookie"
|
||||
import { Cookie } from "../core/lib/cookie"
|
||||
|
||||
export function setCookie(res, cookie: Cookie) {
|
||||
// Preserve any existing cookies that have already been set in the same session
|
||||
let setCookieHeader = res.getHeader("Set-Cookie") ?? []
|
||||
// If not an array (i.e. a string with a single cookie) convert it into an array
|
||||
if (!Array.isArray(setCookieHeader)) {
|
||||
setCookieHeader = [setCookieHeader]
|
||||
}
|
||||
const { name, value, options } = cookie
|
||||
const cookieHeader = serialize(name, value, options)
|
||||
setCookieHeader.push(cookieHeader)
|
||||
res.setHeader("Set-Cookie", setCookieHeader)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export default function Naver<P extends NaverProfile>(
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.response.id,
|
||||
name: profile.response.name,
|
||||
name: profile.response.nickname,
|
||||
email: profile.response.email,
|
||||
image: profile.response.profile_image,
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ export interface OAuthConfig<P> extends CommonProviderOptions, PartialIssuer {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface InternalOAuthConfig<P>
|
||||
export interface OAuthConfigInternal<P>
|
||||
extends Omit<OAuthConfig<P>, "authorization" | "token" | "userinfo"> {
|
||||
authorization?: AuthorizationEndpointHandler
|
||||
token?: TokenEndpointHandler
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
apiBaseUrl,
|
||||
fetchData,
|
||||
now,
|
||||
NextAuthClientConfig,
|
||||
AuthClientConfig,
|
||||
} from "../client/_utils"
|
||||
|
||||
import type {
|
||||
@@ -46,7 +46,7 @@ export * from "./types"
|
||||
// relative URLs are valid in that context and so defaults to empty.
|
||||
// 2. When invoked server side the value is picked up from an environment
|
||||
// variable and defaults to 'http://localhost:3000'.
|
||||
const __NEXTAUTH: NextAuthClientConfig = {
|
||||
const __NEXTAUTH: AuthClientConfig = {
|
||||
baseUrl: parseUrl(process.env.NEXTAUTH_URL ?? process.env.VERCEL_URL).origin,
|
||||
basePath: parseUrl(process.env.NEXTAUTH_URL).path,
|
||||
baseUrlServer: parseUrl(
|
||||
@@ -241,13 +241,13 @@ export async function signIn<
|
||||
method: "post",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"X-Auth-Return-Redirect": "1",
|
||||
},
|
||||
// @ts-expect-error
|
||||
body: new URLSearchParams({
|
||||
...options,
|
||||
csrfToken: await getCsrfToken(),
|
||||
callbackUrl,
|
||||
json: true,
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -291,12 +291,11 @@ export async function signOut<R extends boolean = true>(
|
||||
method: "post",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"X-Auth-Return-Redirect": "1",
|
||||
},
|
||||
// @ts-expect-error
|
||||
body: new URLSearchParams({
|
||||
csrfToken: await getCsrfToken(),
|
||||
csrfToken: (await getCsrfToken()) ?? "",
|
||||
callbackUrl,
|
||||
json: true,
|
||||
}),
|
||||
}
|
||||
const res = await fetch(`${baseUrl}/signout`, fetchOptions)
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/** Extract the host from the environment */
|
||||
export function detectHost(forwardedHost: any) {
|
||||
// If we detect a Vercel environment, we can trust the host
|
||||
if (process.env.VERCEL ?? process.env.AUTH_TRUST_HOST)
|
||||
return forwardedHost
|
||||
// If `NEXTAUTH_URL` is `undefined` we fall back to "http://localhost:3000"
|
||||
return process.env.NEXTAUTH_URL
|
||||
}
|
||||
161
packages/next-auth/src/utils/node.ts
Normal file
161
packages/next-auth/src/utils/node.ts
Normal file
@@ -0,0 +1,161 @@
|
||||
import type { IncomingMessage, ServerResponse } from "http"
|
||||
import type { GetServerSidePropsContext, NextApiRequest } from "next"
|
||||
|
||||
export function setCookie(res, value: string) {
|
||||
// Preserve any existing cookies that have already been set in the same session
|
||||
let setCookieHeader = res.getHeader("Set-Cookie") ?? []
|
||||
// If not an array (i.e. a string with a single cookie) convert it into an array
|
||||
if (!Array.isArray(setCookieHeader)) {
|
||||
setCookieHeader = [setCookieHeader]
|
||||
}
|
||||
setCookieHeader.push(value)
|
||||
res.setHeader("Set-Cookie", setCookieHeader)
|
||||
}
|
||||
|
||||
export function getBody(
|
||||
req: IncomingMessage | NextApiRequest | GetServerSidePropsContext["req"]
|
||||
) {
|
||||
if (!("body" in req) || !req.body || req.method !== "POST") {
|
||||
return
|
||||
}
|
||||
|
||||
if (req.body instanceof ReadableStream) {
|
||||
return { body: req.body }
|
||||
}
|
||||
return { body: JSON.stringify(req.body) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the full request URL from the environment.
|
||||
* NOTE: It does not verify if the host should be trusted.
|
||||
*/
|
||||
export function getURL(url: string | undefined, headers: Headers): URL | Error {
|
||||
try {
|
||||
if (!url) throw new Error("Missing url")
|
||||
if (process.env.NEXTAUTH_URL) {
|
||||
const base = new URL(process.env.NEXTAUTH_URL)
|
||||
if (!["http:", "https:"].includes(base.protocol)) {
|
||||
throw new Error("Invalid protocol")
|
||||
}
|
||||
const hasCustomPath = base.pathname !== "/"
|
||||
|
||||
if (hasCustomPath) {
|
||||
const apiAuthRe = /\/api\/auth\/?$/
|
||||
const basePathname = base.pathname.match(apiAuthRe)
|
||||
? base.pathname.replace(apiAuthRe, "")
|
||||
: base.pathname
|
||||
return new URL(basePathname.replace(/\/$/, "") + url, base.origin)
|
||||
}
|
||||
return new URL(url, base)
|
||||
}
|
||||
const proto =
|
||||
headers.get("x-forwarded-proto") ??
|
||||
(process.env.NODE_ENV !== "production" ? "http" : "https")
|
||||
const host = headers.get("x-forwarded-host") ?? headers.get("host")
|
||||
if (!["http", "https"].includes(proto)) throw new Error("Invalid protocol")
|
||||
const origin = `${proto}://${host}`
|
||||
if (!host) throw new Error("Missing host")
|
||||
return new URL(url, origin)
|
||||
} catch (error) {
|
||||
return error as Error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
|
||||
* that are within a single set-cookie field-value, such as in the Expires portion.
|
||||
* This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
|
||||
* Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
|
||||
* Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
|
||||
* Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
|
||||
* @source https://github.com/nfriedly/set-cookie-parser/blob/3eab8b7d5d12c8ed87832532861c1a35520cf5b3/lib/set-cookie.js#L144
|
||||
*/
|
||||
function getSetCookies(cookiesString: string) {
|
||||
if (typeof cookiesString !== "string") {
|
||||
return []
|
||||
}
|
||||
|
||||
const cookiesStrings: string[] = []
|
||||
let pos = 0
|
||||
let start
|
||||
let ch
|
||||
let lastComma: number
|
||||
let nextStart
|
||||
let cookiesSeparatorFound
|
||||
|
||||
function skipWhitespace() {
|
||||
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
||||
pos += 1
|
||||
}
|
||||
return pos < cookiesString.length
|
||||
}
|
||||
|
||||
function notSpecialChar() {
|
||||
ch = cookiesString.charAt(pos)
|
||||
|
||||
return ch !== "=" && ch !== ";" && ch !== ","
|
||||
}
|
||||
|
||||
while (pos < cookiesString.length) {
|
||||
start = pos
|
||||
cookiesSeparatorFound = false
|
||||
|
||||
while (skipWhitespace()) {
|
||||
ch = cookiesString.charAt(pos)
|
||||
if (ch === ",") {
|
||||
// ',' is a cookie separator if we have later first '=', not ';' or ','
|
||||
lastComma = pos
|
||||
pos += 1
|
||||
|
||||
skipWhitespace()
|
||||
nextStart = pos
|
||||
|
||||
while (pos < cookiesString.length && notSpecialChar()) {
|
||||
pos += 1
|
||||
}
|
||||
|
||||
// currently special character
|
||||
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
||||
// we found cookies separator
|
||||
cookiesSeparatorFound = true
|
||||
// pos is inside the next cookie, so back up and return it.
|
||||
pos = nextStart
|
||||
cookiesStrings.push(cookiesString.substring(start, lastComma))
|
||||
start = pos
|
||||
} else {
|
||||
// in param ',' or param separator ';',
|
||||
// we continue from that comma
|
||||
pos = lastComma + 1
|
||||
}
|
||||
} else {
|
||||
pos += 1
|
||||
}
|
||||
}
|
||||
|
||||
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
||||
cookiesStrings.push(cookiesString.substring(start, cookiesString.length))
|
||||
}
|
||||
}
|
||||
|
||||
return cookiesStrings
|
||||
}
|
||||
|
||||
export function setHeaders(headers: Headers, res: ServerResponse) {
|
||||
for (const [key, val] of headers.entries()) {
|
||||
// See: https://github.com/whatwg/fetch/issues/973
|
||||
const value = key === "set-cookie" ? getSetCookies(val) : val
|
||||
res.setHeader(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace NodeJS {
|
||||
interface ProcessEnv {
|
||||
AUTH_TRUST_HOST?: string
|
||||
NEXTAUTH_URL?: string
|
||||
NEXTAUTH_SECRET?: string
|
||||
VERCEL?: "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,14 @@ export interface InternalUrl {
|
||||
toString: () => string
|
||||
}
|
||||
|
||||
/** Returns an `URL` like object to make requests/redirects from server-side */
|
||||
export default function parseUrl(url?: string): InternalUrl {
|
||||
/**
|
||||
* TODO: Can we remove this?
|
||||
* Returns an `URL` like object to make requests/redirects from server-side
|
||||
*/
|
||||
export default function parseUrl(url?: string | URL): InternalUrl {
|
||||
const defaultUrl = new URL("http://localhost:3000/api/auth")
|
||||
|
||||
if (url && !url.startsWith("http")) {
|
||||
if (url && !url.toString().startsWith("http")) {
|
||||
url = `https://${url}`
|
||||
}
|
||||
|
||||
|
||||
135
packages/next-auth/src/utils/web.ts
Normal file
135
packages/next-auth/src/utils/web.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
import { serialize, parse as parseCookie } from "cookie"
|
||||
import { UnknownAction } from "../core/errors"
|
||||
import type { ResponseInternal, RequestInternal } from "../core"
|
||||
import type { AuthAction } from "../core/types"
|
||||
|
||||
const decoder = new TextDecoder()
|
||||
|
||||
async function streamToString(stream): Promise<string> {
|
||||
const chunks: Uint8Array[] = []
|
||||
return await new Promise((resolve, reject) => {
|
||||
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)))
|
||||
stream.on("error", (err) => reject(err))
|
||||
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")))
|
||||
})
|
||||
}
|
||||
|
||||
async function readJSONBody(
|
||||
body: ReadableStream | Buffer
|
||||
): Promise<Record<string, any> | undefined> {
|
||||
try {
|
||||
if ("getReader" in body) {
|
||||
const reader = body.getReader()
|
||||
const bytes: number[] = []
|
||||
while (true) {
|
||||
const { value, done } = await reader.read()
|
||||
if (done) break
|
||||
bytes.push(...value)
|
||||
}
|
||||
const b = new Uint8Array(bytes)
|
||||
return JSON.parse(decoder.decode(b))
|
||||
}
|
||||
|
||||
// node-fetch
|
||||
|
||||
if (typeof Buffer !== "undefined" && Buffer.isBuffer(body)) {
|
||||
return JSON.parse(body.toString("utf8"))
|
||||
}
|
||||
|
||||
return JSON.parse(await streamToString(body))
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
const actions: AuthAction[] = [ "providers", "session", "csrf", "signin", "signout", "callback", "verify-request", "error", "_log" ]
|
||||
|
||||
export async function toInternalRequest(
|
||||
req: Request
|
||||
): Promise<RequestInternal | Error> {
|
||||
try {
|
||||
// TODO: .toString() should not inclide action and providerId
|
||||
// see init.ts
|
||||
const url = new URL(req.url.replace(/\/$/, ""))
|
||||
const { pathname } = url
|
||||
|
||||
const action = actions.find((a) => pathname.includes(a))
|
||||
if (!action) {
|
||||
throw new UnknownAction("Cannot detect action.")
|
||||
}
|
||||
|
||||
const providerIdOrAction = pathname.split("/").pop()
|
||||
let providerId
|
||||
if (
|
||||
providerIdOrAction &&
|
||||
!action.includes(providerIdOrAction) &&
|
||||
["signin", "callback"].includes(action)
|
||||
) {
|
||||
providerId = providerIdOrAction
|
||||
}
|
||||
|
||||
const cookieHeader = req.headers.get("cookie") ?? ""
|
||||
|
||||
return {
|
||||
url,
|
||||
action,
|
||||
providerId,
|
||||
method: req.method ?? "GET",
|
||||
headers: Object.fromEntries(req.headers),
|
||||
body: req.body ? await readJSONBody(req.body) : undefined,
|
||||
cookies:
|
||||
parseCookie(
|
||||
Array.isArray(cookieHeader) ? cookieHeader.join(";") : cookieHeader
|
||||
) ?? {},
|
||||
error: url.searchParams.get("error") ?? undefined,
|
||||
query: Object.fromEntries(url.searchParams),
|
||||
}
|
||||
} catch (error) {
|
||||
return error
|
||||
}
|
||||
}
|
||||
|
||||
export function toResponse(res: ResponseInternal): Response {
|
||||
const headers = new Headers(res.headers)
|
||||
|
||||
res.cookies?.forEach((cookie) => {
|
||||
const { name, value, options } = cookie
|
||||
const cookieHeader = serialize(name, value, options)
|
||||
if (headers.has("Set-Cookie")) {
|
||||
headers.append("Set-Cookie", cookieHeader)
|
||||
} else {
|
||||
headers.set("Set-Cookie", cookieHeader)
|
||||
}
|
||||
})
|
||||
|
||||
const body =
|
||||
headers.get("content-type") === "application/json"
|
||||
? JSON.stringify(res.body)
|
||||
: res.body
|
||||
|
||||
const response = new Response(body, {
|
||||
headers,
|
||||
status: res.redirect ? 302 : res.status ?? 200,
|
||||
})
|
||||
|
||||
if (res.redirect) {
|
||||
response.headers.set("Location", res.redirect)
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
// TODO: Remove
|
||||
/** Extract the host from the environment */
|
||||
export function detectHost(
|
||||
trusted: boolean,
|
||||
forwardedValue: string | string[] | undefined | null,
|
||||
defaultValue: string | false
|
||||
): string | undefined {
|
||||
if (trusted && forwardedValue) {
|
||||
return Array.isArray(forwardedValue) ? forwardedValue[0] : forwardedValue
|
||||
}
|
||||
|
||||
return defaultValue || undefined
|
||||
}
|
||||
@@ -4,12 +4,12 @@ import {
|
||||
MissingAdapterMethods,
|
||||
MissingSecret,
|
||||
} from "../src/core/errors"
|
||||
import { handler } from "./lib"
|
||||
import { handler } from "./utils"
|
||||
import EmailProvider from "../src/providers/email"
|
||||
|
||||
it("Show error page if secret is not defined", async () => {
|
||||
const { res, log } = await handler(
|
||||
{ providers: [], secret: undefined },
|
||||
{ providers: [], secret: undefined, trustHost: true },
|
||||
{ prod: true }
|
||||
)
|
||||
|
||||
@@ -28,6 +28,7 @@ it("Show error page if adapter is missing functions when using with email", asyn
|
||||
adapter: missingFunctionAdapter,
|
||||
providers: [EmailProvider({ sendVerificationRequest })],
|
||||
secret: "secret",
|
||||
trustHost: true,
|
||||
},
|
||||
{ prod: true }
|
||||
)
|
||||
@@ -48,6 +49,7 @@ it("Show error page if adapter is not configured when using with email", async (
|
||||
{
|
||||
providers: [EmailProvider({ sendVerificationRequest })],
|
||||
secret: "secret",
|
||||
trustHost: true,
|
||||
},
|
||||
{ prod: true }
|
||||
)
|
||||
@@ -64,7 +66,7 @@ it("Show error page if adapter is not configured when using with email", async (
|
||||
|
||||
it("Should show configuration error page on invalid `callbackUrl`", async () => {
|
||||
const { res, log } = await handler(
|
||||
{ providers: [] },
|
||||
{ providers: [], trustHost: true },
|
||||
{ prod: true, params: { callbackUrl: "invalid-callback" } }
|
||||
)
|
||||
|
||||
@@ -80,7 +82,7 @@ it("Should show configuration error page on invalid `callbackUrl`", async () =>
|
||||
|
||||
it("Allow relative `callbackUrl`", async () => {
|
||||
const { res, log } = await handler(
|
||||
{ providers: [] },
|
||||
{ providers: [], trustHost: true },
|
||||
{ prod: true, params: { callbackUrl: "/callback" } }
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { createCSRF, handler, mockAdapter } from "./lib"
|
||||
import { createCSRF, handler, mockAdapter } from "./utils"
|
||||
import EmailProvider from "../src/providers/email"
|
||||
|
||||
it("Send e-mail to the only address correctly", async () => {
|
||||
const { secret, csrf } = await createCSRF()
|
||||
|
||||
const sendVerificationRequest = jest.fn()
|
||||
const signIn = jest.fn(() => true)
|
||||
|
||||
@@ -13,12 +14,13 @@ it("Send e-mail to the only address correctly", async () => {
|
||||
providers: [EmailProvider({ sendVerificationRequest })],
|
||||
callbacks: { signIn },
|
||||
secret,
|
||||
trustHost: true,
|
||||
},
|
||||
{
|
||||
path: "signin/email",
|
||||
requestInit: {
|
||||
method: "POST",
|
||||
headers: { cookie: csrf.cookie },
|
||||
headers: { cookie: csrf.cookie, "content-type": "application/json" },
|
||||
body: JSON.stringify({ email: email, csrfToken: csrf.value }),
|
||||
},
|
||||
}
|
||||
@@ -53,12 +55,13 @@ it("Send e-mail to first address only", async () => {
|
||||
providers: [EmailProvider({ sendVerificationRequest })],
|
||||
callbacks: { signIn },
|
||||
secret,
|
||||
trustHost: true,
|
||||
},
|
||||
{
|
||||
path: "signin/email",
|
||||
requestInit: {
|
||||
method: "POST",
|
||||
headers: { cookie: csrf.cookie },
|
||||
headers: { cookie: csrf.cookie, "content-type": "application/json" },
|
||||
body: JSON.stringify({ email: email, csrfToken: csrf.value }),
|
||||
},
|
||||
}
|
||||
@@ -93,12 +96,13 @@ it("Send e-mail to address with first domain", async () => {
|
||||
providers: [EmailProvider({ sendVerificationRequest })],
|
||||
callbacks: { signIn },
|
||||
secret,
|
||||
trustHost: true,
|
||||
},
|
||||
{
|
||||
path: "signin/email",
|
||||
requestInit: {
|
||||
method: "POST",
|
||||
headers: { cookie: csrf.cookie },
|
||||
headers: { cookie: csrf.cookie, "content-type": "application/json" },
|
||||
body: JSON.stringify({ email: email, csrfToken: csrf.value }),
|
||||
},
|
||||
}
|
||||
@@ -139,12 +143,13 @@ it("Redirect to error page if multiple addresses aren't allowed", async () => {
|
||||
}),
|
||||
],
|
||||
secret,
|
||||
trustHost: true,
|
||||
},
|
||||
{
|
||||
path: "signin/email",
|
||||
requestInit: {
|
||||
method: "POST",
|
||||
headers: { cookie: csrf.cookie },
|
||||
headers: { cookie: csrf.cookie, "content-type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
email: "email@email.com,email@email2.com",
|
||||
csrfToken: csrf.value,
|
||||
@@ -156,7 +161,6 @@ it("Redirect to error page if multiple addresses aren't allowed", async () => {
|
||||
expect(signIn).toBeCalledTimes(0)
|
||||
expect(sendVerificationRequest).toBeCalledTimes(0)
|
||||
|
||||
// @ts-expect-error
|
||||
expect(log.error.mock.calls[0]).toEqual([
|
||||
"SIGNIN_EMAIL_ERROR",
|
||||
{ error, providerId: "email" },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as core from "../src/core"
|
||||
import { MissingSecret } from "../src/core/errors"
|
||||
import { unstable_getServerSession } from "../src/next"
|
||||
import { mockLogger } from "./lib"
|
||||
import { mockLogger } from "./utils"
|
||||
|
||||
const originalWarn = console.warn
|
||||
let logger = mockLogger()
|
||||
@@ -83,9 +83,9 @@ describe("Return correct data", () => {
|
||||
})
|
||||
|
||||
it("Should return null if there is no session", async () => {
|
||||
const spy = jest.spyOn(core, "NextAuthHandler")
|
||||
// @ts-expect-error
|
||||
spy.mockReturnValue({ body: {} })
|
||||
const spy = jest.spyOn(core, "AuthHandler")
|
||||
// @ts-expect-error [Response.json](https://developer.mozilla.org/en-US/docs/Web/API/Response/json)
|
||||
spy.mockReturnValue(Promise.resolve(Response.json(null)))
|
||||
|
||||
const session = await unstable_getServerSession(req, res, {
|
||||
providers: [],
|
||||
@@ -97,21 +97,19 @@ describe("Return correct data", () => {
|
||||
})
|
||||
|
||||
it("Should return the session if one is found", async () => {
|
||||
const mockedResponse = {
|
||||
body: {
|
||||
user: {
|
||||
name: "John Doe",
|
||||
email: "test@example.com",
|
||||
image: "",
|
||||
id: "1234",
|
||||
},
|
||||
expires: "",
|
||||
const mockedBody = {
|
||||
user: {
|
||||
name: "John Doe",
|
||||
email: "test@example.com",
|
||||
image: "",
|
||||
id: "1234",
|
||||
},
|
||||
expires: "",
|
||||
}
|
||||
|
||||
const spy = jest.spyOn(core, "NextAuthHandler")
|
||||
// @ts-expect-error
|
||||
spy.mockReturnValue(mockedResponse)
|
||||
const spy = jest.spyOn(core, "AuthHandler")
|
||||
// @ts-expect-error [Response.json](https://developer.mozilla.org/en-US/docs/Web/API/Response/json)
|
||||
spy.mockReturnValue(Promise.resolve(Response.json(mockedBody)))
|
||||
|
||||
const session = await unstable_getServerSession(req, res, {
|
||||
providers: [],
|
||||
@@ -119,6 +117,6 @@ describe("Return correct data", () => {
|
||||
secret: "secret",
|
||||
})
|
||||
|
||||
expect(session).toEqual(mockedResponse.body)
|
||||
expect(session).toEqual(mockedBody)
|
||||
})
|
||||
})
|
||||
|
||||
138
packages/next-auth/tests/getURL.test.ts
Normal file
138
packages/next-auth/tests/getURL.test.ts
Normal file
@@ -0,0 +1,138 @@
|
||||
import { getURL as getURLOriginal } from "../src/utils/node"
|
||||
|
||||
it("Should return error when missing url", () => {
|
||||
expect(getURL(undefined, {})).toEqual(new Error("Missing url"))
|
||||
})
|
||||
|
||||
it("Should return error when missing host", () => {
|
||||
expect(getURL("/", {})).toEqual(new Error("Missing host"))
|
||||
})
|
||||
|
||||
it("Should return error when invalid protocol", () => {
|
||||
expect(
|
||||
getURL("/", { host: "localhost", "x-forwarded-proto": "file" })
|
||||
).toEqual(new Error("Invalid protocol"))
|
||||
})
|
||||
|
||||
it("Should return error when invalid host", () => {
|
||||
expect(getURL("/", { host: "/" })).toEqual(
|
||||
new TypeError("Invalid base URL: http:///")
|
||||
)
|
||||
})
|
||||
|
||||
it("Should read host headers", () => {
|
||||
expect(getURL("/api/auth/session", { host: "localhost" })).toBeURL(
|
||||
"http://localhost/api/auth/session"
|
||||
)
|
||||
|
||||
expect(
|
||||
getURL("/custom/api/auth/session", { "x-forwarded-host": "localhost:3000" })
|
||||
).toBeURL("http://localhost:3000/custom/api/auth/session")
|
||||
|
||||
// Prefer x-forwarded-host over host
|
||||
expect(
|
||||
getURL("/", { host: "localhost", "x-forwarded-host": "localhost:3000" })
|
||||
).toBeURL("http://localhost:3000/")
|
||||
})
|
||||
|
||||
it("Should read protocol headers", () => {
|
||||
expect(
|
||||
getURL("/", { host: "localhost", "x-forwarded-proto": "http" })
|
||||
).toBeURL("http://localhost/")
|
||||
})
|
||||
|
||||
describe("process.env.NEXTAUTH_URL", () => {
|
||||
afterEach(() => delete process.env.NEXTAUTH_URL)
|
||||
|
||||
it("Should prefer over headers if present", () => {
|
||||
process.env.NEXTAUTH_URL = "http://localhost:3000"
|
||||
expect(getURL("/api/auth/session", { host: "localhost" })).toBeURL(
|
||||
"http://localhost:3000/api/auth/session"
|
||||
)
|
||||
})
|
||||
|
||||
it("catch errors", () => {
|
||||
process.env.NEXTAUTH_URL = "invald-url"
|
||||
expect(getURL("/api/auth/session", {})).toEqual(
|
||||
new TypeError("Invalid URL: invald-url")
|
||||
)
|
||||
|
||||
process.env.NEXTAUTH_URL = "file://localhost"
|
||||
expect(getURL("/api/auth/session", {})).toEqual(
|
||||
new TypeError("Invalid protocol")
|
||||
)
|
||||
})
|
||||
|
||||
it("Supports custom base path", () => {
|
||||
process.env.NEXTAUTH_URL = "http://localhost:3000/custom/api/auth"
|
||||
expect(getURL("/api/auth/session", {})).toBeURL(
|
||||
"http://localhost:3000/custom/api/auth/session"
|
||||
)
|
||||
|
||||
// With trailing slash
|
||||
process.env.NEXTAUTH_URL = "http://localhost:3000/custom/api/auth/"
|
||||
expect(getURL("/api/auth/session", {})).toBeURL(
|
||||
"http://localhost:3000/custom/api/auth/session"
|
||||
)
|
||||
|
||||
// Multiple custom segments
|
||||
process.env.NEXTAUTH_URL = "http://localhost:3000/custom/path/api/auth"
|
||||
expect(getURL("/api/auth/session", {})).toBeURL(
|
||||
"http://localhost:3000/custom/path/api/auth/session"
|
||||
)
|
||||
|
||||
process.env.NEXTAUTH_URL = "http://localhost:3000/custom/path/api/auth/"
|
||||
expect(getURL("/api/auth/session", {})).toBeURL(
|
||||
"http://localhost:3000/custom/path/api/auth/session"
|
||||
)
|
||||
|
||||
// No /api/auth
|
||||
process.env.NEXTAUTH_URL = "http://localhost:3000/custom/nextauth"
|
||||
expect(getURL("/session", {})).toBeURL(
|
||||
"http://localhost:3000/custom/nextauth/session"
|
||||
)
|
||||
|
||||
// No /api/auth, with trailing slash
|
||||
process.env.NEXTAUTH_URL = "http://localhost:3000/custom/nextauth/"
|
||||
expect(getURL("/session", {})).toBeURL(
|
||||
"http://localhost:3000/custom/nextauth/session"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
// Utils
|
||||
|
||||
function getURL(
|
||||
url: Parameters<typeof getURLOriginal>[0],
|
||||
headers: HeadersInit
|
||||
) {
|
||||
return getURLOriginal(url, new Headers(headers))
|
||||
}
|
||||
|
||||
expect.extend({
|
||||
toBeURL(rec, exp) {
|
||||
const r = rec.toString()
|
||||
const e = exp.toString()
|
||||
const printR = this.utils.printReceived
|
||||
const printE = this.utils.printExpected
|
||||
if (r === e) {
|
||||
return {
|
||||
message: () => `expected ${printE(e)} not to be ${printR(r)}`,
|
||||
pass: true,
|
||||
}
|
||||
}
|
||||
return {
|
||||
message: () => `expected ${printE(e)}, got ${printR(r)}`,
|
||||
pass: false,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace jest {
|
||||
interface Matchers<R> {
|
||||
toBeURL: (expected: string) => R
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import { createHash } from "crypto"
|
||||
import { NextAuthHandler } from "../src/core"
|
||||
import type { LoggerInstance, NextAuthOptions } from "../src"
|
||||
import type { Adapter } from "../src/adapters"
|
||||
|
||||
export const mockLogger: () => LoggerInstance = () => ({
|
||||
error: jest.fn(() => {}),
|
||||
warn: jest.fn(() => {}),
|
||||
debug: jest.fn(() => {}),
|
||||
})
|
||||
|
||||
interface HandlerOptions {
|
||||
prod?: boolean
|
||||
path?: string
|
||||
params?: URLSearchParams | Record<string, string>
|
||||
requestInit?: RequestInit
|
||||
}
|
||||
|
||||
export async function handler(
|
||||
options: NextAuthOptions,
|
||||
{ prod, path, params, requestInit }: HandlerOptions
|
||||
) {
|
||||
// @ts-expect-error
|
||||
if (prod) process.env.NODE_ENV = "production"
|
||||
|
||||
const url = new URL(
|
||||
`http://localhost/api/auth/${path ?? "signin"}?${new URLSearchParams(
|
||||
params ?? {}
|
||||
)}`
|
||||
)
|
||||
const req = new Request(url, { headers: { host: "" }, ...requestInit })
|
||||
const logger = mockLogger()
|
||||
const response = await NextAuthHandler({
|
||||
req,
|
||||
options: { secret: "secret", ...options, logger },
|
||||
})
|
||||
// @ts-expect-error
|
||||
if (prod) process.env.NODE_ENV = "test"
|
||||
|
||||
return {
|
||||
res: {
|
||||
...response,
|
||||
html:
|
||||
response.headers?.[0].value === "text/html" ? response.body : undefined,
|
||||
},
|
||||
log: logger,
|
||||
}
|
||||
}
|
||||
|
||||
export function createCSRF() {
|
||||
const secret = "secret"
|
||||
const value = "csrf"
|
||||
const token = createHash("sha256").update(`${value}${secret}`).digest("hex")
|
||||
|
||||
return {
|
||||
secret,
|
||||
csrf: { value, token, cookie: `next-auth.csrf-token=${value}|${token}` },
|
||||
}
|
||||
}
|
||||
|
||||
export function mockAdapter(): Adapter {
|
||||
const adapter: Adapter = {
|
||||
createVerificationToken: jest.fn(() => {}),
|
||||
useVerificationToken: jest.fn(() => {}),
|
||||
getUserByEmail: jest.fn(() => {}),
|
||||
}
|
||||
return adapter
|
||||
}
|
||||
@@ -1,95 +1,69 @@
|
||||
import { NextMiddleware } from "next/server"
|
||||
import { NextMiddleware, NextRequest } from "next/server"
|
||||
import { NextAuthMiddlewareOptions, withAuth } from "../src/next/middleware"
|
||||
|
||||
it("should not match pages as public paths", async () => {
|
||||
const options: NextAuthMiddlewareOptions = {
|
||||
pages: {
|
||||
signIn: "/",
|
||||
error: "/",
|
||||
},
|
||||
pages: { signIn: "/", error: "/" },
|
||||
secret: "secret",
|
||||
}
|
||||
|
||||
const nextUrl: any = {
|
||||
pathname: "/protected/pathA",
|
||||
search: "",
|
||||
origin: "http://127.0.0.1",
|
||||
}
|
||||
const req: any = { nextUrl, headers: { authorization: "" } }
|
||||
|
||||
const handleMiddleware = withAuth(options) as NextMiddleware
|
||||
const res = await handleMiddleware(req, null as any)
|
||||
expect(res).toBeDefined()
|
||||
expect(res?.status).toBe(307)
|
||||
|
||||
const response = await handleMiddleware(
|
||||
new NextRequest("http://127.0.0.1/protected/pathA"),
|
||||
null as any
|
||||
)
|
||||
|
||||
expect(response?.status).toBe(307)
|
||||
expect(response?.headers.get("location")).toBe(
|
||||
"http://localhost/?callbackUrl=%2Fprotected%2FpathA"
|
||||
)
|
||||
})
|
||||
|
||||
it("should not redirect on public paths", async () => {
|
||||
const options: NextAuthMiddlewareOptions = {
|
||||
secret: "secret",
|
||||
}
|
||||
const nextUrl: any = {
|
||||
pathname: "/_next/foo",
|
||||
search: "",
|
||||
origin: "http://127.0.0.1",
|
||||
}
|
||||
const req: any = { nextUrl, headers: { authorization: "" } }
|
||||
const options: NextAuthMiddlewareOptions = { secret: "secret" }
|
||||
|
||||
const req = new NextRequest("http://127.0.0.1/_next/foo")
|
||||
|
||||
const handleMiddleware = withAuth(options) as NextMiddleware
|
||||
const res = await handleMiddleware(req, null as any)
|
||||
expect(res).toBeUndefined()
|
||||
})
|
||||
|
||||
it("should redirect according to nextUrl basePath", async () => {
|
||||
const options: NextAuthMiddlewareOptions = {
|
||||
secret: "secret"
|
||||
}
|
||||
const nextUrl: any = {
|
||||
pathname: "/protected/pathA",
|
||||
search: "",
|
||||
origin: "http://127.0.0.1",
|
||||
basePath: "/custom-base-path",
|
||||
}
|
||||
const req: any = { nextUrl, headers: { authorization: "" } }
|
||||
|
||||
const handleMiddleware = withAuth(options) as NextMiddleware
|
||||
const res = await handleMiddleware(req, null as any)
|
||||
expect(res).toBeDefined()
|
||||
expect(res.status).toEqual(307)
|
||||
expect(res.headers.get('location')).toContain("http://127.0.0.1/custom-base-path/api/auth/signin?callbackUrl=%2Fcustom-base-path%2Fprotected%2FpathA")
|
||||
})
|
||||
|
||||
it("should redirect according to nextUrl basePath", async () => {
|
||||
// given
|
||||
const options: NextAuthMiddlewareOptions = {
|
||||
secret: "secret"
|
||||
}
|
||||
it("should respect NextURL#basePath when redirecting", async () => {
|
||||
const options: NextAuthMiddlewareOptions = { secret: "secret" }
|
||||
const handleMiddleware = withAuth(options) as NextMiddleware
|
||||
|
||||
// when
|
||||
const res = await handleMiddleware({
|
||||
nextUrl: {
|
||||
pathname: "/protected/pathA",
|
||||
search: "",
|
||||
origin: "http://127.0.0.1",
|
||||
basePath: "/custom-base-path"
|
||||
}, headers: { authorization: "" }
|
||||
} as any, null as any)
|
||||
const response1 = await handleMiddleware(
|
||||
{
|
||||
nextUrl: {
|
||||
pathname: "/protected/pathA",
|
||||
search: "",
|
||||
origin: "http://127.0.0.1",
|
||||
basePath: "/custom-base-path",
|
||||
},
|
||||
} as unknown as NextRequest,
|
||||
null as any
|
||||
)
|
||||
expect(response1?.status).toEqual(307)
|
||||
expect(response1?.headers.get("location")).toBe(
|
||||
"http://127.0.0.1/custom-base-path/api/auth/signin?callbackUrl=%2Fcustom-base-path%2Fprotected%2FpathA"
|
||||
)
|
||||
|
||||
// then
|
||||
expect(res).toBeDefined()
|
||||
expect(res.status).toEqual(307)
|
||||
expect(res.headers.get("location")).toContain("http://127.0.0.1/custom-base-path/api/auth/signin?callbackUrl=%2Fcustom-base-path%2Fprotected%2FpathA")
|
||||
// Should not redirect when invoked on sign in page
|
||||
|
||||
// and when follow redirect
|
||||
const resFromRedirectedUrl = await handleMiddleware({
|
||||
nextUrl: {
|
||||
pathname: "/api/auth/signin",
|
||||
search: "callbackUrl=%2Fcustom-base-path%2Fprotected%2FpathA",
|
||||
origin: "http://127.0.0.1",
|
||||
basePath: "/custom-base-path"
|
||||
}, headers: { authorization: "" }
|
||||
} as any, null as any)
|
||||
const response2 = await handleMiddleware(
|
||||
{
|
||||
nextUrl: {
|
||||
pathname: "/api/auth/signin",
|
||||
searchParams: new URLSearchParams({
|
||||
callbackUrl: "/custom-base-path/protected/pathA",
|
||||
}),
|
||||
origin: "http://127.0.0.1",
|
||||
basePath: "/custom-base-path",
|
||||
},
|
||||
} as unknown as NextRequest,
|
||||
null as any
|
||||
)
|
||||
|
||||
// then return sign in page
|
||||
expect(resFromRedirectedUrl).toBeUndefined()
|
||||
expect(response2).toBeUndefined()
|
||||
})
|
||||
|
||||
142
packages/next-auth/tests/next.test.ts
Normal file
142
packages/next-auth/tests/next.test.ts
Normal file
@@ -0,0 +1,142 @@
|
||||
import { nodeHandler } from "./utils"
|
||||
|
||||
it("Missing req.url throws in dev", async () => {
|
||||
await expect(nodeHandler).rejects.toThrow(new Error("Missing url"))
|
||||
})
|
||||
|
||||
const configErrorMessage =
|
||||
"There is a problem with the server configuration. Check the server logs for more information."
|
||||
|
||||
it("Missing req.url returns config error in prod", async () => {
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "production"
|
||||
const { res, logger } = await nodeHandler()
|
||||
|
||||
expect(logger.error).toBeCalledTimes(1)
|
||||
const error = new Error("Missing url")
|
||||
expect(logger.error).toBeCalledWith("INVALID_URL", error)
|
||||
|
||||
expect(res.status).toBeCalledWith(400)
|
||||
expect(res.json).toBeCalledWith({ message: configErrorMessage })
|
||||
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "test"
|
||||
})
|
||||
|
||||
it("Missing host throws in dev", async () => {
|
||||
await expect(
|
||||
async () =>
|
||||
await nodeHandler({
|
||||
req: { query: { nextauth: ["session"] } },
|
||||
})
|
||||
).rejects.toThrow(Error)
|
||||
})
|
||||
|
||||
it("Missing host config error in prod", async () => {
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "production"
|
||||
const { res, logger } = await nodeHandler({
|
||||
req: { query: { nextauth: ["session"] } },
|
||||
})
|
||||
expect(res.status).toBeCalledWith(400)
|
||||
expect(res.json).toBeCalledWith({ message: configErrorMessage })
|
||||
|
||||
expect(logger.error).toBeCalledWith("INVALID_URL", new Error("Missing url"))
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "test"
|
||||
})
|
||||
|
||||
it("Defined host throws 400 in production if not trusted", async () => {
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "production"
|
||||
const { res } = await nodeHandler({
|
||||
req: { headers: { host: "http://localhost" } },
|
||||
})
|
||||
expect(res.status).toBeCalledWith(400)
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "test"
|
||||
})
|
||||
|
||||
it("Defined host throws 400 in production if trusted but invalid URL", async () => {
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "production"
|
||||
const { res } = await nodeHandler({
|
||||
req: { headers: { host: "localhost" } },
|
||||
options: { trustHost: true },
|
||||
})
|
||||
expect(res.status).toBeCalledWith(400)
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "test"
|
||||
})
|
||||
|
||||
it("Defined host does not throw in production if trusted and valid URL", async () => {
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "production"
|
||||
const { res } = await nodeHandler({
|
||||
req: {
|
||||
url: "/api/auth/session",
|
||||
headers: { host: "http://localhost" },
|
||||
},
|
||||
options: { trustHost: true },
|
||||
})
|
||||
expect(res.status).toBeCalledWith(200)
|
||||
expect(JSON.parse(res.send.mock.calls[0][0])).toEqual({})
|
||||
// @ts-expect-error
|
||||
process.env.NODE_ENV = "test"
|
||||
})
|
||||
|
||||
it("Use process.env.NEXTAUTH_URL for host if present", async () => {
|
||||
process.env.NEXTAUTH_URL = "http://localhost"
|
||||
const { res } = await nodeHandler({
|
||||
req: { url: "/api/auth/session" },
|
||||
})
|
||||
expect(res.status).toBeCalledWith(200)
|
||||
expect(JSON.parse(res.send.mock.calls[0][0])).toEqual({})
|
||||
})
|
||||
|
||||
it("Redirects if necessary", async () => {
|
||||
process.env.NEXTAUTH_URL = "http://localhost"
|
||||
const { res } = await nodeHandler({
|
||||
req: {
|
||||
method: "post",
|
||||
url: "/api/auth/signin/github",
|
||||
},
|
||||
})
|
||||
expect(res.status).toBeCalledWith(302)
|
||||
expect(res.setHeader).toBeCalledWith("set-cookie", [
|
||||
expect.stringMatching(
|
||||
/next-auth.csrf-token=.*; Path=\/; HttpOnly; SameSite=Lax/
|
||||
),
|
||||
`next-auth.callback-url=${encodeURIComponent(
|
||||
process.env.NEXTAUTH_URL
|
||||
)}; Path=/; HttpOnly; SameSite=Lax`,
|
||||
])
|
||||
expect(res.setHeader).toBeCalledTimes(2)
|
||||
expect(res.send).toBeCalledWith("")
|
||||
})
|
||||
|
||||
it("Returns redirect if `X-Auth-Return-Redirect` header is present", async () => {
|
||||
process.env.NEXTAUTH_URL = "http://localhost"
|
||||
const { res } = await nodeHandler({
|
||||
req: {
|
||||
method: "post",
|
||||
url: "/api/auth/signin/github",
|
||||
headers: { "X-Auth-Return-Redirect": "1" },
|
||||
},
|
||||
})
|
||||
|
||||
expect(res.status).toBeCalledWith(200)
|
||||
expect(res.setHeader).toBeCalledWith("content-type", "application/json")
|
||||
expect(res.setHeader).toBeCalledWith("set-cookie", [
|
||||
expect.stringMatching(
|
||||
/next-auth.csrf-token=.*; Path=\/; HttpOnly; SameSite=Lax/
|
||||
),
|
||||
`next-auth.callback-url=${encodeURIComponent(
|
||||
process.env.NEXTAUTH_URL
|
||||
)}; Path=/; HttpOnly; SameSite=Lax`,
|
||||
])
|
||||
expect(res.setHeader).toBeCalledTimes(2)
|
||||
expect(res.send).toBeCalledWith(
|
||||
JSON.stringify({ url: "http://localhost/api/auth/signin?csrf=true" })
|
||||
)
|
||||
})
|
||||
169
packages/next-auth/tests/pkce-handler.test.ts
Normal file
169
packages/next-auth/tests/pkce-handler.test.ts
Normal file
@@ -0,0 +1,169 @@
|
||||
import { mockLogger } from "./utils"
|
||||
import type {
|
||||
InternalOptions,
|
||||
LoggerInstance,
|
||||
InternalProvider,
|
||||
CallbacksOptions,
|
||||
Account,
|
||||
Awaitable,
|
||||
Profile,
|
||||
Session,
|
||||
User,
|
||||
CookiesOptions,
|
||||
} from "../src"
|
||||
import { createPKCE } from "../src/core/lib/oauth/pkce-handler"
|
||||
import { InternalUrl } from "../src/utils/parse-url"
|
||||
import { JWT, JWTDecodeParams, JWTEncodeParams, JWTOptions } from "../src/jwt"
|
||||
import { CredentialInput } from "../src/providers"
|
||||
|
||||
let logger: LoggerInstance
|
||||
let url: InternalUrl
|
||||
let provider: InternalProvider<"oauth">
|
||||
let jwt: JWTOptions
|
||||
let callbacks: CallbacksOptions
|
||||
let cookies: CookiesOptions
|
||||
let options: InternalOptions<"oauth">
|
||||
|
||||
beforeEach(() => {
|
||||
logger = mockLogger()
|
||||
|
||||
url = {
|
||||
origin: "http://localhost:3000",
|
||||
host: "localhost:3000",
|
||||
path: "/api/auth",
|
||||
base: "http://localhost:3000/api/auth",
|
||||
toString: () => "http://localhost:3000/api/auth",
|
||||
}
|
||||
|
||||
provider = {
|
||||
type: "oauth",
|
||||
id: "testId",
|
||||
name: "testName",
|
||||
signinUrl: "/",
|
||||
callbackUrl: "/",
|
||||
checks: ["pkce", "state"],
|
||||
}
|
||||
|
||||
jwt = {
|
||||
secret: "secret",
|
||||
maxAge: 0,
|
||||
encode: function (params: JWTEncodeParams): Awaitable<string> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
decode: function (params: JWTDecodeParams): Awaitable<JWT | null> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
}
|
||||
|
||||
callbacks = {
|
||||
signIn: function (params: {
|
||||
user: User
|
||||
account: Account
|
||||
profile: Profile & Record<string, unknown>
|
||||
email: { verificationRequest?: boolean | undefined }
|
||||
credentials?: Record<string, CredentialInput> | undefined
|
||||
}): Awaitable<string | boolean> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
redirect: function (params: {
|
||||
url: string
|
||||
baseUrl: string
|
||||
}): Awaitable<string> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
session: function (params: {
|
||||
session: Session
|
||||
user: User
|
||||
token: JWT
|
||||
}): Awaitable<Session> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
jwt: function (params: {
|
||||
token: JWT
|
||||
user?: User | undefined
|
||||
account?: Account | undefined
|
||||
profile?: Profile | undefined
|
||||
isNewUser?: boolean | undefined
|
||||
}): Awaitable<JWT> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
}
|
||||
|
||||
cookies = {
|
||||
sessionToken: { name: "", options: undefined },
|
||||
callbackUrl: { name: "", options: undefined },
|
||||
csrfToken: { name: "", options: undefined },
|
||||
pkceCodeVerifier: { name: "", options: {} },
|
||||
state: { name: "", options: undefined },
|
||||
nonce: { name: "", options: undefined },
|
||||
}
|
||||
|
||||
options = {
|
||||
url,
|
||||
action: "session",
|
||||
provider,
|
||||
secret: "",
|
||||
debug: false,
|
||||
logger,
|
||||
session: { strategy: "jwt", maxAge: 0, updateAge: 0 },
|
||||
pages: {},
|
||||
jwt,
|
||||
events: {},
|
||||
callbacks,
|
||||
cookies,
|
||||
callbackUrl: "",
|
||||
providers: [],
|
||||
theme: {},
|
||||
}
|
||||
})
|
||||
|
||||
describe("createPKCE", () => {
|
||||
it("returns a code challenge, code challenge method, and cookie", async () => {
|
||||
const pkce = await createPKCE(options)
|
||||
|
||||
expect(pkce?.code_challenge).not.toBeNull()
|
||||
expect(pkce?.code_challenge_method).toEqual("S256")
|
||||
expect(pkce?.cookie).not.toBeNull()
|
||||
})
|
||||
it("does not return a pkce when the provider does not support pkce", async () => {
|
||||
options.provider.checks = ["state"]
|
||||
|
||||
const pkce = await createPKCE(options)
|
||||
|
||||
expect(pkce).toBeUndefined()
|
||||
})
|
||||
it("sets the cookie expiration to a default of 15 minutes when the max age option is not provided", async () => {
|
||||
const pkce = await createPKCE(options)
|
||||
|
||||
const defaultMaxAge = 60 * 15 // 15 minutes in seconds
|
||||
const expires = new Date()
|
||||
expires.setTime(expires.getTime() + defaultMaxAge * 1000)
|
||||
|
||||
validateCookieExpiration({ pkce, expires })
|
||||
expect(pkce?.cookie.options.maxAge).toBeUndefined()
|
||||
})
|
||||
|
||||
it("sets the cookie expiration and max age to the provided max age from the options", async () => {
|
||||
const maxAge = 60 * 20 // 20 minutes
|
||||
cookies.pkceCodeVerifier.options.maxAge = maxAge
|
||||
|
||||
const pkce = await createPKCE(options)
|
||||
|
||||
const expires = new Date()
|
||||
expires.setTime(expires.getTime() + maxAge * 1000)
|
||||
|
||||
validateCookieExpiration({ pkce, expires })
|
||||
expect(pkce?.cookie.options.maxAge).toEqual(maxAge)
|
||||
})
|
||||
})
|
||||
|
||||
// comparing the parts instead of getTime() because the milliseconds
|
||||
// will not match since the two Date objects are created milliseconds apart
|
||||
const validateCookieExpiration = ({ pkce, expires }) => {
|
||||
const cookieExpires = pkce?.cookie.options.expires
|
||||
expect(cookieExpires.getFullYear()).toEqual(expires.getFullYear())
|
||||
expect(cookieExpires.getMonth()).toEqual(expires.getMonth())
|
||||
expect(cookieExpires.getFullYear()).toEqual(expires.getFullYear())
|
||||
expect(cookieExpires.getHours()).toEqual(expires.getHours())
|
||||
expect(cookieExpires.getMinutes()).toEqual(expires.getMinutes())
|
||||
}
|
||||
164
packages/next-auth/tests/state-handler.test.ts
Normal file
164
packages/next-auth/tests/state-handler.test.ts
Normal file
@@ -0,0 +1,164 @@
|
||||
import { mockLogger } from "./utils"
|
||||
import type {
|
||||
InternalOptions,
|
||||
LoggerInstance,
|
||||
InternalProvider,
|
||||
CallbacksOptions,
|
||||
Account,
|
||||
Awaitable,
|
||||
Profile,
|
||||
Session,
|
||||
User,
|
||||
CookiesOptions,
|
||||
} from "../src"
|
||||
import { createState } from "../src/core/lib/oauth/state-handler"
|
||||
import { InternalUrl } from "../src/utils/parse-url"
|
||||
import { JWT, JWTOptions, encode, decode } from "../src/jwt"
|
||||
import { CredentialInput } from "../src/providers"
|
||||
|
||||
let logger: LoggerInstance
|
||||
let url: InternalUrl
|
||||
let provider: InternalProvider<"oauth">
|
||||
let jwt: JWTOptions
|
||||
let callbacks: CallbacksOptions
|
||||
let cookies: CookiesOptions
|
||||
let options: InternalOptions<"oauth">
|
||||
|
||||
beforeEach(() => {
|
||||
logger = mockLogger()
|
||||
|
||||
url = {
|
||||
origin: "http://localhost:3000",
|
||||
host: "localhost:3000",
|
||||
path: "/api/auth",
|
||||
base: "http://localhost:3000/api/auth",
|
||||
toString: () => "http://localhost:3000/api/auth",
|
||||
}
|
||||
|
||||
provider = {
|
||||
type: "oauth",
|
||||
id: "testId",
|
||||
name: "testName",
|
||||
signinUrl: "/",
|
||||
callbackUrl: "/",
|
||||
checks: ["pkce", "state"],
|
||||
}
|
||||
|
||||
jwt = {
|
||||
secret: "secret",
|
||||
maxAge: 0,
|
||||
encode,
|
||||
decode,
|
||||
}
|
||||
|
||||
callbacks = {
|
||||
signIn: function (params: {
|
||||
user: User
|
||||
account: Account
|
||||
profile: Profile & Record<string, unknown>
|
||||
email: { verificationRequest?: boolean | undefined }
|
||||
credentials?: Record<string, CredentialInput> | undefined
|
||||
}): Awaitable<string | boolean> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
redirect: function (params: {
|
||||
url: string
|
||||
baseUrl: string
|
||||
}): Awaitable<string> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
session: function (params: {
|
||||
session: Session
|
||||
user: User
|
||||
token: JWT
|
||||
}): Awaitable<Session> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
jwt: function (params: {
|
||||
token: JWT
|
||||
user?: User | undefined
|
||||
account?: Account | undefined
|
||||
profile?: Profile | undefined
|
||||
isNewUser?: boolean | undefined
|
||||
}): Awaitable<JWT> {
|
||||
throw new Error("Function not implemented.")
|
||||
},
|
||||
}
|
||||
|
||||
cookies = {
|
||||
sessionToken: { name: "", options: undefined },
|
||||
callbackUrl: { name: "", options: undefined },
|
||||
csrfToken: { name: "", options: undefined },
|
||||
pkceCodeVerifier: { name: "", options: undefined },
|
||||
state: { name: "", options: {} },
|
||||
nonce: { name: "", options: undefined },
|
||||
}
|
||||
|
||||
options = {
|
||||
url,
|
||||
action: "session",
|
||||
provider,
|
||||
secret: "",
|
||||
debug: false,
|
||||
logger,
|
||||
session: { strategy: "jwt", maxAge: 0, updateAge: 0 },
|
||||
pages: {},
|
||||
jwt,
|
||||
events: {},
|
||||
callbacks,
|
||||
cookies,
|
||||
callbackUrl: "",
|
||||
providers: [],
|
||||
theme: {},
|
||||
}
|
||||
})
|
||||
|
||||
describe("createState", () => {
|
||||
it("returns a state, and cookie", async () => {
|
||||
const state = await createState(options)
|
||||
|
||||
expect(state?.value).not.toBeNull()
|
||||
expect(state?.cookie).not.toBeNull()
|
||||
})
|
||||
it("does not return a state when the provider does not support state", async () => {
|
||||
options.provider.checks = ["pkce"]
|
||||
|
||||
const state = await createState(options)
|
||||
|
||||
expect(state).toBeUndefined()
|
||||
})
|
||||
it("sets the cookie expiration to a default of 15 minutes when the max age option is not provided", async () => {
|
||||
const state = await createState(options)
|
||||
|
||||
const defaultMaxAge = 60 * 15 // 15 minutes in seconds
|
||||
const expires = new Date()
|
||||
expires.setTime(expires.getTime() + defaultMaxAge * 1000)
|
||||
|
||||
validateCookieExpiration({ state, expires })
|
||||
expect(state?.cookie.options.maxAge).toBeUndefined()
|
||||
})
|
||||
|
||||
it("sets the cookie expiration and max age to the provided max age from the options", async () => {
|
||||
const maxAge = 60 * 20 // 20 minutes
|
||||
cookies.state.options.maxAge = maxAge
|
||||
|
||||
const state = await createState(options)
|
||||
|
||||
const expires = new Date()
|
||||
expires.setTime(expires.getTime() + maxAge * 1000)
|
||||
|
||||
validateCookieExpiration({ state, expires })
|
||||
expect(state?.cookie.options.maxAge).toEqual(maxAge)
|
||||
})
|
||||
})
|
||||
|
||||
// comparing the parts instead of getTime() because the milliseconds
|
||||
// will not match since the two Date objects are created milliseconds apart
|
||||
const validateCookieExpiration = ({ state, expires }) => {
|
||||
const cookieExpires = state?.cookie.options.expires
|
||||
expect(cookieExpires.getFullYear()).toEqual(expires.getFullYear())
|
||||
expect(cookieExpires.getMonth()).toEqual(expires.getMonth())
|
||||
expect(cookieExpires.getFullYear()).toEqual(expires.getFullYear())
|
||||
expect(cookieExpires.getHours()).toEqual(expires.getHours())
|
||||
expect(cookieExpires.getMinutes()).toEqual(expires.getMinutes())
|
||||
}
|
||||
116
packages/next-auth/tests/utils.ts
Normal file
116
packages/next-auth/tests/utils.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import { createHash } from "crypto"
|
||||
import { AuthHandler } from "../src/core"
|
||||
import type { LoggerInstance, AuthOptions } from "../src"
|
||||
import type { Adapter } from "../src/adapters"
|
||||
|
||||
import NextAuth from "../src/next"
|
||||
|
||||
import type { NextApiRequest, NextApiResponse } from "next"
|
||||
|
||||
export function mockLogger(): Record<keyof LoggerInstance, jest.Mock> {
|
||||
return {
|
||||
error: jest.fn(() => {}),
|
||||
warn: jest.fn(() => {}),
|
||||
debug: jest.fn(() => {}),
|
||||
}
|
||||
}
|
||||
|
||||
interface HandlerOptions {
|
||||
prod?: boolean
|
||||
path?: string
|
||||
params?: URLSearchParams | Record<string, string>
|
||||
requestInit?: RequestInit
|
||||
}
|
||||
|
||||
export async function handler(
|
||||
options: AuthOptions,
|
||||
{ prod, path, params, requestInit }: HandlerOptions
|
||||
) {
|
||||
// @ts-expect-error
|
||||
if (prod) process.env.NODE_ENV = "production"
|
||||
|
||||
const url = new URL(
|
||||
`http://localhost:3000/api/auth/${path ?? "signin"}?${new URLSearchParams(
|
||||
params ?? {}
|
||||
)}`
|
||||
)
|
||||
const req = new Request(url, { headers: { host: "" }, ...requestInit })
|
||||
const logger = mockLogger()
|
||||
const response = await AuthHandler(req, {
|
||||
secret: "secret",
|
||||
...options,
|
||||
logger,
|
||||
})
|
||||
// @ts-expect-error
|
||||
if (prod) process.env.NODE_ENV = "test"
|
||||
|
||||
return {
|
||||
res: {
|
||||
status: response.status,
|
||||
headers: response.headers,
|
||||
body: response.body,
|
||||
redirect: response.headers.get("location"),
|
||||
html:
|
||||
response.headers?.get("content-type") === "text/html"
|
||||
? await response.clone().text()
|
||||
: undefined,
|
||||
},
|
||||
log: logger,
|
||||
}
|
||||
}
|
||||
|
||||
export function createCSRF() {
|
||||
const secret = "secret"
|
||||
const value = "csrf"
|
||||
const token = createHash("sha256").update(`${value}${secret}`).digest("hex")
|
||||
|
||||
return {
|
||||
secret,
|
||||
csrf: { value, token, cookie: `next-auth.csrf-token=${value}|${token}` },
|
||||
}
|
||||
}
|
||||
|
||||
export function mockAdapter(): Adapter {
|
||||
const adapter: Adapter = {
|
||||
createVerificationToken: jest.fn(() => {}),
|
||||
useVerificationToken: jest.fn(() => {}),
|
||||
getUserByEmail: jest.fn(() => {}),
|
||||
} as unknown as Adapter
|
||||
return adapter
|
||||
}
|
||||
|
||||
export async function nodeHandler(
|
||||
params: {
|
||||
req?: Partial<NextApiRequest>
|
||||
res?: Partial<NextApiResponse>
|
||||
options?: Partial<AuthOptions>
|
||||
} = {}
|
||||
) {
|
||||
const req = {
|
||||
body: {},
|
||||
cookies: {},
|
||||
headers: {},
|
||||
method: "GET",
|
||||
...params.req,
|
||||
}
|
||||
|
||||
const res = {
|
||||
...params.res,
|
||||
end: jest.fn(),
|
||||
json: jest.fn(),
|
||||
status: jest.fn().mockReturnValue({ end: jest.fn() }),
|
||||
setHeader: jest.fn(),
|
||||
removeHeader: jest.fn(),
|
||||
send: jest.fn(),
|
||||
}
|
||||
|
||||
const logger = mockLogger()
|
||||
|
||||
await NextAuth(req as any, res as any, {
|
||||
providers: [],
|
||||
secret: "secret",
|
||||
logger,
|
||||
...params.options,
|
||||
})
|
||||
return { req, res, logger }
|
||||
}
|
||||
5052
pnpm-lock.yaml
generated
5052
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user