okta / okta-auth-js

The official js wrapper around Okta's auth API
Other
447 stars 261 forks source link

`issuer` type can be undefined but it results in a runtime error #1475

Closed amir-ziaei closed 8 months ago

amir-ziaei commented 10 months ago

Describe the bug

I believe this bug is at the type level. The issuer prop to the constructor of OktaAuth is marked as string | undefined. However, undefined results in a runtime error as you can see in the following screenshot:

image

Reproduction Steps?

  1. Import OktaAuth and instantiate it with just passing an empty object
    import { OktaAuth } from "@okta/okta-auth-js";
    new OktaAuth({});
  2. Observe there are no type errors
  3. Run the code
  4. Observe the runtime error
    Uncaught AuthSdkError: No issuer passed to constructor. Required usage: new OktaAuth({issuer: "https://{yourOktaDomain}.com/oauth2/{authServerId}"})
    at <anonymous>:2:270564
    at new g (<anonymous>:2:271060)
    at l.f (<anonymous>:2:51190)
    at new l (<anonymous>:2:51316)
    at l.f (<anonymous>:2:119912)
    at new l (<anonymous>:2:120038)
    at new t (<anonymous>:2:9188)
    at s.l (<anonymous>:2:303846)
    at new p (<anonymous>:2:304042)
    at s.d (<anonymous>:2:69354)

SDK Versions

System: OS: macOS 14.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 23.51 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v18.15.0/bin/yarn npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm pnpm: 7.29.3 - /usr/local/bin/pnpm bun: 1.0.9 - ~/.bun/bin/bun Browsers: Brave Browser: 119.1.60.114 Chrome: 119.0.6045.123 Safari: 17.1 npmPackages: @okta/okta-auth-js: ^7.4.3 => 7.4.3

Additional Information?

No response

jaredperreault-okta commented 8 months ago

Fixed in 7.5.1 https://github.com/okta/okta-auth-js/releases/tag/okta-auth-js-7.5.1