OAuth integration for Amazon Cognito’s hosted UI. Refer to the Cognito docs:
Provider id is cognito
.
import { cognito } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";
const cognitoAuth = cognito(auth, configs);
cognito()
#
const cognito: (
auth: Auth,
config: {
clientId: string;
clientSecret: string;
redirectUri: string;
scope?: string[];
userPoolDomain: string;
}
) => CognitoProvider;
Parameters#
name | type | description | optional |
---|
auth | Auth | Lucia instance | |
config.clientId | string | Cognito app client id | |
config.clientSecret | string | Cognito app client secret | |
config.redirectUri | string | an authorized redirect URI | |
config.scope | string[] | an array of scopes - openid is always included | ✓ |
config.userPoolDomain | string | Amazon Cognito’s user pool domain | |
Returns#
Interfaces#
CognitoAuth
#
See OAuth2ProviderAuth
.
// implements OAuth2ProviderAuth<CognitoAuth<_Auth>>
interface CognitoAuth<_Auth extends Auth> {
getAuthorizationUrl: () => Promise<readonly [url: URL, state: string]>;
validateCallback: (code: string) => Promise<CognitoAuth<_Auth>>;
}
Generics#
name | extends | default |
---|
_Auth | Auth | Auth |
CognitoTokens
#
type CognitoTokens = {
accessToken: string;
refreshToken: string;
idToken: string;
accessTokenExpiresIn: number;
tokenType: string;
};
CognitoUser
#
type CognitoUser = {
sub: string;
"cognito:username": string;
"cognito:groups": string[];
address?: {
formatted?: string;
};
birthdate?: string;
email?: string;
email_verified?: boolean;
family_name?: string;
gender?: string;
given_name?: string;
locale?: string;
middle_name?: string;
name?: string;
nickname?: string;
phone_number?: string;
phone_number_verified?: boolean;
picture?: string;
preferred_username?: string;
profile?: string;
website?: string;
zoneinfo?: string;
updated_at?: number;
};
CognitoUserAuth
#
Extends ProviderUserAuth
.
interface CognitoUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
cognitoUser: CognitoUser;
cognitoTokens: CognitoTokens;
}
Generics#