{
    "Amplify Auth Configuration": {
        "prefix": "Amplify.configure",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "import awsmobile from './aws-exports';",
            "let awsmobileMandatorySignIn = awsmobile.aws_mandatory_sign_in == \"enable\" ? true : false;\n\n",
            "Amplify.configure({",
            "\tAuth: {",
            "\t\t// REQUIRED - Amazon Cognito Identity Pool ID,",
            "\t\tidentityPoolId: $awsmobile.aws_cognito_identity_pool_id,",
            "\t\t// REQUIRED - Amazon Cognito Region",
            "\t\tregion: $awsmobile.aws_cognito_region,",
            "\t\t// OPTIONAL - Amazon Cognito User Pool ID",
            "\t\tuserPoolId: $awsmobile.aws_user_pools_id,",
            "\t\t// OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)",
            "\t\tuserPoolWebClientId: $awsmobile.aws_user_pools_web_client_id,",
            "\t\t// OPTIONAL - Enforce user authentication prior to accessing AWS resources or not",
            "\t\tmandatorySignIn: $awsmobileMandatorySignIn,",
            "\t\t// OPTIONAL - Configuration for cookie storage",
            "\t\tcookieStorage: {",
            "\t\t\t// REQUIRED - Cookie domain (only required if cookieStorage is provided)",
            "\t\t\tdomain: ${1:'.yourdomain.com'},",
            "\t\t\t// OPTIONAL - Cookie path",
            "\t\t\tpath: ${2:'/'},",
            "\t\t\t// OPTIONAL - Cookie expiration in days",
            "\t\t\texpires: ${3:365},",
            "\t\t\t// OPTIONAL - Cookie secure flag",
            "\t\t\tsecure: ${4:true}",
            "\t\t}",
            "\t}",
            "});"
        ]
    },
    "Auth.signIn": {
        "prefix": "Auth.signIn",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "Auth.signIn(username, password)",
            "\t.then(user => console.log(user))",
            "\t.catch(err => console.log(err));"
        ]
    },
    "Auth.confirmSignIn": {
        "prefix": "Auth.confirmSignIn",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "// If MFA enabled, sign-in should be confirmed with the confirmation code",
            "// `user` : Return object from Auth.signIn()",
            "// `code` : Confirmation code  ",
            "// `mfaType` : MFA Type e.g. SMS, TOTP.",
            "Auth.confirmSignIn(user, code, mfaType)",
            "\t.then(data => console.log(data))",
            "\t.catch(err => console.log(err));"
        ]
    },
    "Auth.signUp": {
        "prefix": "Auth.signUp",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "Auth.signUp({",
            "\tusername,",
            "\tpassword,",
            "\tattributes: {",
            "\t\temail,             // optional",
            "\t\tphone_number,      // optional - E.164 number convention",
            "\t\t// Other custom attributes...",
            "\t},",
            "\tvalidationData: [],  // optional",
            "\t})",
            "\t.then(data => console.log(data))",
            "\t.catch(err => console.log(err));"
        ]
    },
    "Auth.confirmSignUp": {
        "prefix": "Auth.confirmSignUp",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "// After retrieveing the confirmation code from the user",
            "Auth.confirmSignUp(username, code, {",
            "\t// Optional. Force user confirmation irrespective of existing alias. By default set to True.",
            "\tforceAliasCreation: true", 
            "}).then(data => console.log(data))",
            "  .catch(err => console.log(err));"
        ]
    },
    "Auth.signOut": {
        "prefix": "Auth.signOut",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "Auth.signOut()",
            "\t.then(data => console.log(data))",
            "\t.catch(err => console.log(err));"
        ]
    },
    "Auth Change Password": {
        "prefix": "Auth.currentAuthenticatedUser",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "Auth.currentAuthenticatedUser()",
            "\t.then(user => {",
            "\t\treturn Auth.changePassword(user, ${1:'oldPassword'}, ${2:'newPassword'});",
            "\t})",
            "\t.then(data => console.log(data))",
            "\t.catch(err => console.log(err));"
        ]
    },
    "Auth Forgot Password": {
        "prefix": "Auth.forgotPassword",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "Auth.forgotPassword(username)",
            "\t.then(data => console.log(data))",
            "\t.catch(err => console.log(err));"
        ]
    },
    "Auth Forgot Password Submit": {
        "prefix": "Auth.forgotPasswordSubmit",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "// Collect confirmation code and new password , then",
            "Auth.forgotPasswordSubmit(username, code, new_password)",
            "\t.then(data => console.log(data))",
            "\t.catch(err => console.log(err));"
        ]
    },
    "Auth oauth": {
        "prefix": "oauth",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "oauth = {",
            "\t// Domain name",
            "\tdomain : ${1:'your-domain-prefix.auth.us-east-1.amazoncognito.com'},",
            "\t// Authorized scopes",
            "\tscope: ${2:['phone', 'email', 'profile', 'openid','aws.cognito.signin.user.admin']},",
            "\t// Callback URL",
            "\tredirectSignIn : ${3:'http://www.example.com/signin'},",
            "\t// Sign out URL",
            "\tredirectSignOut : ${4:'http://www.example.com/signout'},",
            "\t// 'code' for Authorization code grant,",
            "\t// 'token' for Implicit grant",
            "\tresponseType: ${5:'code'},",
            "\t// optional, for Cognito hosted ui specified options",
            "\toptions: {",
            "\t\t// Indicates if the data collection is enabled to support Cognito advanced security features. By default, this flag is set to true.",
            "\t\tAdvancedSecurityDataCollectionFlag : ${6:true}",
            "\t}",
            "}"
        ]
    },
    "logInWithReadPermissionsAsync": {
        "prefix": "logInWithReadPermissionsAsync",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "logInWithReadPermissionsAsync"
        ]
    },
    "handleAuthStateChange": {
        "prefix": "handleAuthStateChange",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "handleAuthStateChange"
        ]
    },
    "userPoolWebClientId": {
        "prefix": "userPoolWebClientId",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "userPoolWebClientId"
        ]
    },
    "OAuthSignIn": {
        "prefix": "OAuthSignIn",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "OAuthSignIn"
        ]
    },
    "Auth.verifyTotpToken": {
        "prefix": "Auth.verifyTotpToken",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "// Then you will have your TOTP account in your TOTP-generating app (like Google Authenticator)",
            "// Use the generated one-time password to verify the setup",
            "Auth.verifyTotpToken(user, challengeAnswer).then(() => {\n",
                "\t// don't forget to set TOTP as the preferred MFA method",
                "\tAuth.setPreferredMFA(user, 'TOTP');",
                "\t// ...",
            "}).catch( e => {",
                "\t// Token is not verified",
            "});"
        ]
    },
    "setPreferredMFA": {
        "prefix": "setPreferredMFA",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "setPreferredMFA"
        ]
    },
    "publicChallengeParameters": {
        "prefix": "publicChallengeParameters",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "publicChallengeParameters"
        ]
    },
    "privateChallengeParameters": {
        "prefix": "privateChallengeParameters",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "privateChallengeParameters"
        ]
    },
    "challengeMetadata": {
        "prefix": "challengeMetadata",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "challengeMetadata"
        ]
    },
    "challengeName": {
        "prefix": "challengeName",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "challengeName"
        ]
    },
    "failAuthentication": {
        "prefix": "failAuthentication",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "failAuthentication"
        ]
    },
    "issueTokens": {
        "prefix": "issueTokens",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "issueTokens"
        ]
    },
    "length": {
        "prefix": "length",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "length"
        ]
    },
    "challengeResult": {
        "prefix": "challengeResult",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "challengeResult"
        ]
    },
    "challengeAnswer": {
        "prefix": "challengeAnswer",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "challengeAnswer"
        ]
    },
    "answerCorrect": {
        "prefix": "answerCorrect",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "answerCorrect"
        ]
    },
    "authScreenLabels": {
        "prefix": "authScreenLabels",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "authScreenLabels = {",
                "\ten: {",
                    "\t\t${1:'Sign Up': 'Create new account'},",
                    "\t\t${2:'Sign Up Account': 'Create a new account'}",
                "\t}",
            "};\n",
            "I18n.setLanguage('en');",
            "I18n.putVocabularies(authScreenLabels);"
        ]
    },
    "Auth.currentCredentials": {
        "prefix": "Auth.currentCredentials",
        "scope": "javascript,javascriptreact,typescript",
        "body": [
            "Auth.currentCredentials()",
            "\t.then(credentials => {",
                "\t\tconst route53 = new Route53({",
                    "\t\t\tapiVersion: ${1:'2013-04-01'},",
                    "\t\t\tcredentials: ${2:Auth.essentialCredentials(credentials)}",
                "\t\t});",
                "\t\t// more code working with route53 object",
                "\t\t// route53.changeResourceRecordSets();",
            "\t})"
        ]
    }
}