mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
6 Commits
@auth/neo4
...
feat/vipps
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab8da6c32a | ||
|
|
9ab999cd50 | ||
|
|
47d41a8af2 | ||
|
|
148fb1931b | ||
|
|
3f3a4ff5c7 | ||
|
|
60dc5d2cdd |
1
.github/ISSUE_TEMPLATE/2_bug_provider.yml
vendored
1
.github/ISSUE_TEMPLATE/2_bug_provider.yml
vendored
@@ -74,6 +74,7 @@ body:
|
||||
- "Trakt"
|
||||
- "Twitch"
|
||||
- "Twitter"
|
||||
- "Vipps"
|
||||
- "Vk"
|
||||
- "Wordpress"
|
||||
- "WorkOS"
|
||||
|
||||
3
docs/static/img/providers/vipps-dark.svg
vendored
Normal file
3
docs/static/img/providers/vipps-dark.svg
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.2103 9.19238C16.3543 9.19238 17.3348 8.33691 17.3348 7.10693C17.3348 5.87646 16.3543 5.021 15.2103 5.021C14.0667 5.021 13.0867 5.87646 13.0867 7.10693C13.0867 8.33691 14.0667 9.19238 15.2103 9.19238ZM17.9881 12.5625C16.5716 14.3804 15.074 15.6377 12.4324 15.6377C9.7376 15.6377 7.63994 14.0332 6.00615 11.6797C5.35235 10.7168 4.34502 10.5029 3.60967 11.0112C2.92901 11.4927 2.76592 12.5088 3.3919 13.3916C5.65166 16.7881 8.7835 18.7666 12.4324 18.7666C15.782 18.7666 18.3968 17.1621 20.4388 14.4878C21.201 13.4985 21.1736 12.4824 20.4388 11.9204C19.7576 11.3853 18.7503 11.5732 17.9881 12.5625Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 767 B |
3
docs/static/img/providers/vipps.svg
vendored
Normal file
3
docs/static/img/providers/vipps.svg
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.2103 9.19238C16.3543 9.19238 17.3348 8.33691 17.3348 7.10693C17.3348 5.87646 16.3543 5.021 15.2103 5.021C14.0667 5.021 13.0867 5.87646 13.0867 7.10693C13.0867 8.33691 14.0667 9.19238 15.2103 9.19238ZM17.9881 12.5625C16.5716 14.3804 15.074 15.6377 12.4324 15.6377C9.7376 15.6377 7.63994 14.0332 6.00615 11.6797C5.35235 10.7168 4.34502 10.5029 3.60967 11.0112C2.92901 11.4927 2.76592 12.5088 3.3919 13.3916C5.65166 16.7881 8.7835 18.7666 12.4324 18.7666C15.782 18.7666 18.3968 17.1621 20.4388 14.4878C21.201 13.4985 21.1736 12.4824 20.4388 11.9204C19.7576 11.3853 18.7503 11.5732 17.9881 12.5625Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 767 B |
90
packages/core/src/providers/vipps.ts
Normal file
90
packages/core/src/providers/vipps.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import type { OIDCConfig, OIDCUserConfig } from "./index.js"
|
||||
|
||||
/** @see [User Profile Structure](https://vippsas.github.io/vipps-developer-docs/docs/APIs/login-api/vipps-login-api#userinfo) */
|
||||
export interface VippsProfile extends Record<string, any> {
|
||||
sid: string
|
||||
birthdate: string
|
||||
email: string
|
||||
email_verified: boolean
|
||||
family_name: string
|
||||
given_name: string
|
||||
name: string
|
||||
phone_number: string
|
||||
sub: string
|
||||
}
|
||||
|
||||
interface AdditonalConfig {
|
||||
redirectUri?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @see [Vipps Login API](https://vippsas.github.io/vipps-developer-docs/docs/APIs/login-api/vipps-login-api)
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* ```ts
|
||||
* import Vipps from "@auth/core/providers/vipps"
|
||||
* ...
|
||||
* providers: [
|
||||
* Vipps({
|
||||
* clientId: process.env.VIPPS_CLIENT_ID,
|
||||
* clientSecret: process.env.VIPPS_CLIENT_SECRET,
|
||||
* })
|
||||
* ]
|
||||
* ...
|
||||
* ```
|
||||
* ::: note
|
||||
* If you're testing, make sure to override the issuer option with apitest.vipps.no
|
||||
* :::
|
||||
*/
|
||||
|
||||
export default function Vipps<P extends VippsProfile>(
|
||||
options: OIDCUserConfig<P> & AdditonalConfig
|
||||
): OIDCConfig<P> {
|
||||
options.issuer ??= "https://api.vipps.no/access-management-1.0/access"
|
||||
return {
|
||||
id: "vipps",
|
||||
name: "Vipps",
|
||||
type: "oidc",
|
||||
client: {
|
||||
token_endpoint_auth_method: "client_secret_post",
|
||||
},
|
||||
authorization: {
|
||||
params: {
|
||||
scope: "openid name email",
|
||||
client_id: options.clientId,
|
||||
response_type: "code",
|
||||
},
|
||||
},
|
||||
userinfo: {
|
||||
async request({ tokens }) {
|
||||
const response = await fetch(
|
||||
"https://apitest.vipps.no/vipps-userinfo-api/userinfo",
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokens.access_token}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
return await response.json()
|
||||
},
|
||||
},
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.sub,
|
||||
name: profile.name,
|
||||
email: profile.email,
|
||||
}
|
||||
},
|
||||
style: {
|
||||
bgDark: "#f05c18",
|
||||
bg: "#f05c18",
|
||||
text: "#fff",
|
||||
textDark: "#fff",
|
||||
logo: "/vipps.svg",
|
||||
logoDark: "/vipps-dark.svg",
|
||||
},
|
||||
options,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user