UNPKG

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