@peopleplus/auth
Advanced tools
Comparing version
import type { RequestEvent } from '@sveltejs/kit'; | ||
import { MicrosoftEntraId as Base, OAuth2Tokens } from 'arctic'; | ||
export type MicrosoftEntraIdProviderOptions = { | ||
clientId: string; | ||
clientID: string; | ||
clientSecret: string; | ||
tenant: string; | ||
redirectUri: string; | ||
redirectUri?: string; | ||
additionalScopes?: string[]; | ||
@@ -16,2 +16,3 @@ logoutHint?: string; | ||
constructor(opts: MicrosoftEntraIdProviderOptions, baseURL: URL | string); | ||
createAuthorizationURL(state: string, codeVerifier: string, scopes: string[]): URL; | ||
oauthLogoutURL(idToken: string, redirectURL: URL | string): URL; | ||
@@ -18,0 +19,0 @@ handleAuthCallback(event: RequestEvent, cookie: { |
@@ -6,5 +6,15 @@ import { MicrosoftEntraId as Base, OAuth2Tokens } from 'arctic'; | ||
constructor(opts, baseURL) { | ||
super(opts.tenant, opts.clientId, opts.clientSecret, new URL(opts.redirectUri ?? MicrosoftEntraId.DEFAULT_AUTH_REDIRECT_URL, baseURL).toString()); | ||
super(opts.tenant, opts.clientID, opts.clientSecret, new URL(opts.redirectUri ?? MicrosoftEntraId.DEFAULT_AUTH_REDIRECT_URL, baseURL).toString()); | ||
this.opts = opts; | ||
} | ||
createAuthorizationURL(state, codeVerifier, scopes) { | ||
const url = super.createAuthorizationURL(state, codeVerifier, [ | ||
'openid', | ||
'profile', | ||
'email', | ||
...(this.opts.additionalScopes ?? []), | ||
...(scopes ?? []), | ||
]); | ||
return url; | ||
} | ||
oauthLogoutURL(idToken, redirectURL) { | ||
@@ -11,0 +21,0 @@ const url = new URL('/oauth2/logout', this.opts.baseOAuthURL ?? 'https://login.microsoftonline.com/common/'); |
{ | ||
"name": "@peopleplus/auth", | ||
"version": "0.0.0-snapshot-20250116162232", | ||
"version": "0.0.0-snapshot-20250116163309", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "vite dev", |
44793
0.91%954
1.17%