amplify-js icon indicating copy to clipboard operation
amplify-js copied to clipboard

CUSTOM_WITH_SRP Failing but AUTH_WITH_SRP working

Open itkumar2013 opened this issue 1 year ago • 1 comments

Before opening, please confirm:

JavaScript Framework

Next.js

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

None

Environment information

# Put output below this line
  System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-1245U
    Memory: 2.01 GB / 15.64 GB
  Binaries:
    Node: 20.0.0 - C:\nodejs\node.EXE
    Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.6.4 - C:\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (114.0.1823.43)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @ampproject/toolbox-optimizer:  undefined ()
    @aws-amplify/ui-react: ^6.1.14 => 6.1.14
    @aws-amplify/ui-react-internal:  undefined ()
    @aws-sdk/client-cognito-identity-provider: ^3.600.0 => 3.621.0
    @aws-sdk/client-ses: ^3.540.0 => 3.621.0
    @aws-sdk/credential-providers: ^3.609.0 => 3.621.0
    @babel/core:  undefined ()
    @babel/runtime:  7.15.4
    @builder.io/react: ^2.0.9 => 2.2.0 (2.1.0)
    @builder.io/widgets: ^1.2.24 => 1.2.24
    @dnd-kit/core: ^6.0.8 => 6.1.0
    @dnd-kit/sortable: ^7.0.2 => 7.0.2
    @edge-runtime/primitives:  2.0.0
    @emotion/babel-plugin: ^11.10.5 => 11.11.0
    @emotion/cache: latest => 11.11.0 (10.0.29)
    @emotion/css: latest => 11.11.2 (10.0.27)
    @emotion/eslint-plugin: ^11.7.0 => 11.11.0
    @emotion/react: latest => 11.11.4
    @emotion/server: latest => 11.11.0
    @emotion/styled: latest => 11.11.5
    @graphql-codegen/cli: ^2.3.0 => 2.16.5
    @graphql-codegen/typescript: ^2.4.1 => 2.8.8
    @graphql-codegen/typescript-operations: ^2.2.1 => 2.5.13
    @hapi/accept:  undefined ()
    @hookform/resolvers: ^2.8.8 => 2.9.11
    @hookform/resolvers/ajv:  1.0.0
    @hookform/resolvers/class-validator:  1.0.0
    @hookform/resolvers/computed-types:  1.0.0
    @hookform/resolvers/io-ts:  1.0.0
    @hookform/resolvers/joi:  1.0.0
    @hookform/resolvers/nope:  1.0.0
    @hookform/resolvers/superstruct:  1.0.0
    @hookform/resolvers/typanion:  1.0.0
    @hookform/resolvers/vest:  1.0.0
    @hookform/resolvers/yup:  1.0.0
    @hookform/resolvers/zod:  1.0.0
    @kibocommerce/graphql-client: 1.0.3-beta.10 => 1.0.3-beta.10
    @mui/icons-material: ^5.10.16 => 5.15.15
    @mui/lab: ^5.0.0-alpha.123 => 5.0.0-alpha.170
    @mui/material: ^5.10.16 => 5.15.15
    @mui/x-date-pickers: ^5.0.13 => 5.0.20
    @napi-rs/triples:  undefined ()
    @next/bundle-analyzer: ^13.2.4 => 13.5.6
    @next/react-dev-overlay:  undefined ()
    @segment/ajv-human-errors:  undefined ()
    @storybook/addon-a11y: ^6.4.20 => 6.5.16
    @storybook/addon-actions: ^6.4.17 => 6.5.16
    @storybook/addon-essentials: ^6.4.17 => 6.5.16
    @storybook/addon-links: ^6.4.17 => 6.5.16
    @storybook/react: ^6.5.13 => 6.5.16
    @storybook/testing-react: ^1.2.3 => 1.3.0
    @stripe/stripe-js: ^4.1.0 => 4.1.0
    @swc/core: ^1.3.3 => 1.4.14
    @swc/jest: ^0.2.22 => 0.2.36
    @tanstack/query-codemods:  4.24.3
    @tanstack/react-query: ^5.0.0-alpha.68 => 5.29.2
    @tanstack/react-query-devtools: ^5.0.0-alpha.68 => 5.29.2
    @testing-library/jest-dom: ^5.16.5 => 5.17.0
    @testing-library/react: ^14.0.0 => 14.3.1
    @testing-library/react-hooks: ^8.0.1 => 8.0.1
    @testing-library/user-event: ^14.4.3 => 14.5.2
    @types/css-mediaquery: ^0.1.1 => 0.1.4
    @types/jest: ^29.2.3 => 29.5.12
    @types/next: ^9.0.0 => 9.0.0
    @types/node: 18.11.9 => 18.11.9 (16.18.96, 10.12.18, 18.19.43)
    @types/nprogress: ^0.2.0 => 0.2.3
    @types/react: ^18.0.25 => 18.2.79
    @types/react-beautiful-dnd: ^13.1.4 => 13.1.8
    @types/react-dom: ^18.0.9 => 18.2.25
    @types/react-loading-overlay: ^1.0.4 => 1.0.4
    @types/react-slick: ^0.23.13 => 0.23.13
    @types/react-swipeable-views: ^0.13.5 => 0.13.5
    @types/react-swipeable-views-utils: ^0.13.7 => 0.13.7
    @typescript-eslint/eslint-plugin: ^5.5.0 => 5.62.0
    @typescript-eslint/parser: ^5.5.0 => 5.62.0
    @vercel/fetch: ^6.1.1 => 6.2.0
    @vercel/nft:  undefined ()
    acorn:  undefined ()
    amphtml-validator:  undefined ()
    anser:  undefined ()
    arg:  undefined ()
    assert:  undefined ()
    async-retry:  undefined ()
    async-sema:  undefined ()
    aws-amplify: ^6.4.3 => 6.4.3
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    aws-cognito-srp-client: ^1.0.0 => 1.0.0
    babel-packages:  undefined ()
    babel-plugin-direct-import: ^1.0.0 => 1.0.0
    browserify-zlib:  undefined ()
    browserslist:  undefined ()
    buffer:  undefined ()
    bytes:  undefined ()
    chalk:  undefined ()
    ci-info:  undefined ()
    cli-select:  undefined ()
    cognito-srp-helper: ^2.2.2 => 2.2.2
    comment-json:  undefined ()
    compression:  undefined ()
    conf:  undefined ()
    constants-browserify:  undefined ()
    content-disposition:  undefined ()
    content-type:  undefined ()
    cookie:  undefined ()
    cookies-next: ^2.1.1 => 2.1.2
    credit-card-type: ^9.1.0 => 9.1.0
    cross-env: ^7.0.3 => 7.0.3
    cross-spawn:  undefined ()
    crypto-browserify:  undefined ()
    css-mediaquery: ^0.1.2 => 0.1.2
    css.escape:  undefined ()
    cssnano-simple:  undefined ()
    data-uri-to-buffer:  undefined ()
    date-fns: ^2.28.0 => 2.30.0
    dayjs: ^1.11.7 => 1.11.10
    debug:  undefined ()
    devalue:  undefined ()
    dnd-kit-sortable-tree: ^0.1.73 => 0.1.73
    domain-browser:  undefined ()
    edge-runtime:  undefined ()
    eslint: ^8.7.0 => 8.57.0
    eslint-config-next: 13.0.5 => 13.0.5
    eslint-config-prettier: ^8.3.0 => 8.10.0
    eslint-plugin-jest-dom: ^4.0.3 => 4.0.3
    eslint-plugin-storybook: ^0.5.6 => 0.5.13
    eslint-plugin-testing-library: ^5.0.6 => 5.11.1
    events:  undefined ()
    find-cache-dir:  undefined ()
    find-up:  undefined ()
    fresh:  undefined ()
    get-orientation:  undefined ()
    glob:  undefined ()
    graphql-codegen: ^0.4.0 => 0.4.0
    graphql-request: ^4.2.0 => 4.3.0 (6.1.0)
    gzip-size:  undefined ()
    http-proxy:  undefined ()
    https-browserify:  undefined ()
    husky: ^7.0.4 => 7.0.4
    icss-utils:  undefined ()
    ignore-loader:  undefined ()
    image-size:  undefined ()
    is-animated:  undefined ()
    is-docker:  undefined ()
    is-wsl:  undefined ()
    isomorphic-unfetch: ^3.1.0 => 3.1.0
    jest: 29.3.1 => 29.3.1
    jest-environment-jsdom: 29.3.1 => 29.3.1
    jest-mock-extended: ^3.0.1 => 3.0.6
    jest-sonar-reporter: ^2.0.0 => 2.0.0
    jest-worker:  undefined ()
    json5:  undefined ()
    jsonwebtoken:  undefined ()
    loader-utils:  undefined ()
    lodash.curry:  undefined ()
    lru-cache:  undefined ()
    material-ui-popup-state: ^2.0.0 => 2.0.1
    micromatch:  undefined ()
    mini-css-extract-plugin:  undefined ()
    msw: ^0.49.3 => 0.49.3
    msw-storybook-addon: ^1.7.0 => 1.10.0
    nanoid:  undefined ()
    native-url:  undefined ()
    neo-async:  undefined ()
    net: ^1.0.2 => 1.0.2
    next: ~13.0.5 => 13.0.7
    next-i18next: ^10.2.0 => 10.5.0
    next-i18next-create-client:  undefined ()
    next-recaptcha-v3: 1.1.5 => 1.1.5
    next-router-mock: ^0.9.1 => 0.9.13
    next-sitemap: ^4.1.3 => 4.2.3
    node-cache: ^5.1.2 => 5.1.2
    node-fetch: ^2.6.11 => 2.7.0 (1.7.3, )
    node-html-parser:  undefined ()
    nprogress: ^0.2.0 => 0.2.0
    ora:  undefined ()
    os-browserify:  undefined ()
    p-limit:  undefined ()
    path-browserify:  undefined ()
    platform:  undefined ()
    postcss-flexbugs-fixes:  undefined ()
    postcss-modules-extract-imports:  undefined ()
    postcss-modules-local-by-default:  undefined ()
    postcss-modules-scope:  undefined ()
    postcss-modules-values:  undefined ()
    postcss-preset-env:  undefined ()
    postcss-safe-parser:  undefined ()
    postcss-scss:  undefined ()
    postcss-value-parser:  undefined ()
    prettier: ^2.5.0 => 2.8.8 (2.3.0)
    pretty-quick: ^3.1.3 => 3.3.1
    process:  undefined ()
    punycode:  undefined ()
    querystring-es3:  undefined ()
    raw-body:  undefined ()
    react: 18.2.0 => 18.2.0 (18.3.0-next-3ba7add60-20221201)
    react-dom: 18.2.0 => 18.2.0 (18.3.0-next-3ba7add60-20221201)
    react-hook-form: ^7.28.1 => 7.51.3
    react-is:  18.2.0
    react-loading-overlay: ^1.0.1 => 1.0.1
    react-material-ui-carousel: ^3.4.2 => 3.4.2
    react-player: ^2.14.1 => 2.16.0
    react-refresh:  0.12.0
    react-server-dom-webpack:  undefined ()
    react-slick: ^0.29.0 => 0.29.0 (0.28.1)
    react-spinners: ^0.13.8 => 0.13.8
    react-swipeable-views: ^0.14.0 => 0.14.0
    react-swipeable-views-utils: ^0.14.0 => 0.14.0
    react-to-print: ^2.14.13 => 2.15.1
    react-transition-group: ^4.4.5 => 4.4.5 (2.9.0)
    react-transition-group/CSSTransition:  undefined ()
    react-transition-group/ReplaceTransition:  undefined ()
    react-transition-group/SwitchTransition:  undefined ()
    react-transition-group/Transition:  undefined ()
    react-transition-group/TransitionGroup:  undefined ()
    react-transition-group/TransitionGroupContext:  undefined ()
    react-transition-group/config:  undefined ()
    react-zoom-pan-pinch: ^2.1.3 => 2.6.1
    regenerator-runtime:  0.13.4
    sass-loader:  undefined ()
    scheduler:  undefined ()
    schema-utils:  undefined ()
    semver:  undefined ()
    send:  undefined ()
    setimmediate:  undefined ()
    sharp: ^0.32.1 => 0.32.6
    shell-quote:  undefined ()
    slick-carousel: ^1.8.1 => 1.8.1
    source-map:  undefined ()
    stacktrace-parser:  undefined ()
    storybook-addon-material-ui5: ^1.0.0 => 1.0.0
    storybook-addon-next: ^1.3.1 => 1.8.0
    storybook-addon-next-router: ^4.0.0 => 4.0.2
    stream-browserify:  undefined ()
    stream-http:  undefined ()
    strict-event-emitter: ^0.4.6 => 0.4.6 (0.2.8)
    string-hash:  undefined ()
    string_decoder:  undefined ()
    strip-ansi:  undefined ()
    stripe: ^14.25.0 => 14.25.0
    tar:  undefined ()
    terser:  undefined ()
    text-table:  undefined ()
    timers-browserify:  undefined ()
    ts-jest: ^29.0.3 => 29.1.2
    tsconfig-paths-webpack-plugin: ^3.5.2 => 3.5.2 (4.1.0)
    tty-browserify:  undefined ()
    typedoc: ^0.23.21 => 0.23.28
    typedoc-plugin-markdown: ^3.13.6 => 3.17.1
    typescript: ^4.9.5 => 4.9.5
    ua-parser-js:  undefined ()
    undici:  undefined ()
    unistore:  undefined ()
    util:  undefined ()
    vm-browserify:  undefined ()
    watchpack:  undefined ()
    web-vitals:  undefined ()
    webpack:  undefined ()
    webpack-sources:  undefined ()
    ws:  undefined ()
    yup: ^0.32.11 => 0.32.11
  npmGlobalPackages:
    @builder.io/cli: 1.2.8
    @kibocommerce/kibo-sandbox-data-cli: 1.0.20
    azure-functions-core-tools: 3.0.4899
    generator-mozu-app: 1.3.1
    generator-mozu-theme: 2.0.13
    grunt-cli: 1.4.3
    node-gyp: 9.4.0
    nodemailer: 6.9.8
    react-player: 2.14.1
    vercel: 34.1.1
    yarn: 1.22.21
    yo: 5.0.0

Describe the bug

When I sign using the Amplify API sign with default sign which USER_SRP_AUTH I am able to login successfully without any issues but when I login with CUSTOM_WITH_SRP I am always getting as password verification failed in the PASSWORD VERIFIER step. __

Expected behavior

Expecting the PASSWORD VERIFIER to be successful without issues to proceed with next set of validation

Reproduction steps

  1. Implemented Custom UI in Next JS
  2. Used AWS SDK for Sign up
  3. Used Amplify library for Sign In. Sign in with USER_SRP_AUTH it logs in successfully. Try login with same CUSTOM_WITH_SRP. It fails.

Code Snippet

// Put your code below this line.

const username = data?.emailAddress; // The username
const password = data?.password; // The password
const email=data?.emailAddress;
try{
Amplify.configure({
  Auth: {
        Cognito: {
    
    userPoolClientId:clientId,
    userPoolId:poolId,
    userAttributes:{
      email: username,
                
    },
    loginWith: {
      email,
      username,
    }

   }

  }

});
// Generate the secret hash
const { nextStep,isSignedIn } = await signIn({
  username,
  password,
  options: {
    authFlowType: 'CUSTOM_WITH_SRP',
  },
 
});

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

itkumar2013 avatar Aug 05 '24 07:08 itkumar2013

Hello, @itkumar2013 and thanks for opening this issue. Just to clarify, did you already set up the 3 corresponding lambda triggers (referenced here) when using an authentication flow with CUSTOM_WITH_SRP?

cwomack avatar Aug 07 '24 18:08 cwomack

Closing this issue as we have not heard back from you. We'll update the docs however (within PR #7947 in the amplify-docs repo) to include a callout and give better visibility to these lambdas being critical to the authentication flow.

cwomack avatar Sep 10 '24 20:09 cwomack