UNPKG

4.71 kBTypeScriptView Raw
1import { ICookieStorageData, ICognitoStorage } from 'amazon-cognito-identity-js';
2/**
3 * Parameters for user sign up
4 */
5export interface SignUpParams {
6 username: string;
7 password: string;
8 attributes?: object;
9 validationData?: {
10 [key: string]: any;
11 };
12 clientMetadata?: {
13 [key: string]: string;
14 };
15 autoSignIn?: AutoSignInOptions;
16}
17export interface AuthCache {
18 setItem(): any;
19 getItem(): any;
20 removeItem(): any;
21}
22/**
23 * Auth instance options
24 */
25export interface AuthOptions {
26 userPoolId?: string;
27 userPoolWebClientId?: string;
28 identityPoolId?: string;
29 region?: string;
30 mandatorySignIn?: boolean;
31 cookieStorage?: ICookieStorageData;
32 oauth?: OAuthOpts;
33 refreshHandlers?: object;
34 storage?: ICognitoStorage;
35 authenticationFlowType?: string;
36 identityPoolRegion?: string;
37 clientMetadata?: any;
38 endpoint?: string;
39 signUpVerificationMethod?: 'code' | 'link';
40}
41export declare enum CognitoHostedUIIdentityProvider {
42 Cognito = "COGNITO",
43 Google = "Google",
44 Facebook = "Facebook",
45 Amazon = "LoginWithAmazon",
46 Apple = "SignInWithApple"
47}
48export declare type LegacyProvider = 'google' | 'facebook' | 'amazon' | 'developer' | string;
49export declare type FederatedSignInOptions = {
50 provider: CognitoHostedUIIdentityProvider;
51 customState?: string;
52};
53export declare type FederatedSignInOptionsCustom = {
54 customProvider: string;
55 customState?: string;
56};
57export declare function isFederatedSignInOptions(obj: any): obj is FederatedSignInOptions;
58export declare function isFederatedSignInOptionsCustom(obj: any): obj is FederatedSignInOptionsCustom;
59export declare function hasCustomState(obj: any): boolean;
60/**
61 * Details for multi-factor authentication
62 */
63export interface MfaRequiredDetails {
64 challengeName: any;
65 challengeParameters: any;
66}
67/**
68 * interface for federatedResponse
69 */
70export interface FederatedResponse {
71 token: string;
72 identity_id?: string;
73 expires_at: number;
74}
75/**
76 * interface for federatedUser
77 */
78export interface FederatedUser {
79 name: string;
80 email?: string;
81 picture?: string;
82}
83export interface AwsCognitoOAuthOpts {
84 domain: string;
85 scope: Array<string>;
86 redirectSignIn: string;
87 redirectSignOut: string;
88 responseType: string;
89 options?: object;
90 urlOpener?: (url: string, redirectUrl: string) => Promise<any>;
91}
92export declare function isCognitoHostedOpts(oauth: OAuthOpts): oauth is AwsCognitoOAuthOpts;
93export interface Auth0OAuthOpts {
94 domain: string;
95 clientID: string;
96 scope: string;
97 redirectUri: string;
98 audience: string;
99 responseType: string;
100 returnTo: string;
101 urlOpener?: (url: string, redirectUrl: string) => Promise<any>;
102}
103export declare type OAuthOpts = AwsCognitoOAuthOpts | Auth0OAuthOpts;
104export interface ConfirmSignUpOptions {
105 forceAliasCreation?: boolean;
106 clientMetadata?: ClientMetaData;
107}
108export interface SignOutOpts {
109 global?: boolean;
110}
111export interface CurrentUserOpts {
112 bypassCache: boolean;
113}
114export interface GetPreferredMFAOpts {
115 bypassCache: boolean;
116}
117export declare type UsernamePasswordOpts = {
118 username: string;
119 password: string;
120 validationData?: {
121 [key: string]: any;
122 };
123};
124export declare enum AuthErrorTypes {
125 NoConfig = "noConfig",
126 MissingAuthConfig = "missingAuthConfig",
127 EmptyUsername = "emptyUsername",
128 InvalidUsername = "invalidUsername",
129 EmptyPassword = "emptyPassword",
130 EmptyCode = "emptyCode",
131 SignUpError = "signUpError",
132 NoMFA = "noMFA",
133 InvalidMFA = "invalidMFA",
134 EmptyChallengeResponse = "emptyChallengeResponse",
135 NoUserSession = "noUserSession",
136 Default = "default",
137 DeviceConfig = "deviceConfig",
138 NetworkError = "networkError",
139 AutoSignInError = "autoSignInError"
140}
141export declare type AuthErrorMessages = {
142 [key in AuthErrorTypes]: AuthErrorMessage;
143};
144export interface AuthErrorMessage {
145 message: string;
146 log?: string;
147}
148export declare type SignInOpts = UsernamePasswordOpts;
149export declare type ClientMetaData = {
150 [key: string]: string;
151} | undefined;
152export declare function isUsernamePasswordOpts(obj: any): obj is UsernamePasswordOpts;
153export interface IAuthDevice {
154 id: string;
155 name: string;
156}
157export interface AutoSignInOptions {
158 enabled: boolean;
159 clientMetaData?: ClientMetaData;
160 validationData?: {
161 [key: string]: any;
162 };
163}
164export declare enum GRAPHQL_AUTH_MODE {
165 API_KEY = "API_KEY",
166 AWS_IAM = "AWS_IAM",
167 OPENID_CONNECT = "OPENID_CONNECT",
168 AMAZON_COGNITO_USER_POOLS = "AMAZON_COGNITO_USER_POOLS",
169 AWS_LAMBDA = "AWS_LAMBDA"
170}