perarnborg / vuex-oidc

Vuejs (with vuex) wrapper for open id authentication
MIT License
232 stars 64 forks source link

Both `clientId` and `client_id` are required for VuexOidcClientSettings #204

Open Santobert opened 1 year ago

Santobert commented 1 year ago

With version 4.0.1 clientId and client_id are expected attributes of VuexOidcClientSettings as well as redirect_uri and redirectUri.

const clientSettings = {
  authority: [...],
  clientId: [...],
  redirectUri: [...],
  responseType: "code",
  scope: "openid email profile",
  automaticSilentRenew: true,
  automaticSilentSignin: false,
  accessTokenExpiringNotificationTimeInSeconds: 10,
  extraQueryParams: { nonce: nanoid() },
} as VuexOidcClientSettings;

export default vuexOidcCreateStoreModule(
  clientSettings,
  {
    namespaced: true,
    routeBase: [...],
  },
);

This leads to the following error:

Conversion of type '{ authority: string; clientId: string; redirectUri: string; responseType: string; scope: string; automaticSilentRenew: true; automaticSilentSignin: false; accessTokenExpiringNotificationTimeInSeconds: number; extraQueryParams: { ...; }; }' to type 'VuexOidcClientSettings' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type '{ authority: string; clientId: string; redirectUri: string; responseType: string; scope: string; automaticSilentRenew: true; automaticSilentSignin: false; accessTokenExpiringNotificationTimeInSeconds: number; extraQueryParams: { ...; }; }' is missing the following properties from type 'VuexOidcClientSettings': client_id, redirect_urits(2352)

In addition, the accessTokenExpiringNotificationTimeInSeconds attribute also seems to be an issue, although it works as expected.

perarnborg commented 1 year ago

I see, I had missed this difference between oidc-client and oidc-client-ts – in the type definition (that vuex-oidc extends) in oidc-client client_id and redirect_uri are not required.

I think the easiest fix is to set clientId and redirectUri as optional in the vuex-oidc interface VuexOidcClientSettings. This will force typescript users to set client_id and redirect_uri rather than clientId and redirectUri - so it will introduce a braking change for typescript. But still better than now that both syntaxes are required.

I will fix this within short!

dr-waterstorm commented 1 year ago

Thanks @perarnborg for all your efforts! It's awesome to see that this lib is migrating to the new TS version.

Is there an ETA for this fix? I've ran into the same issue.

My "workaround" currently is using the TS naming scheme from oidc-client and a

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
vuexOidcProcessSilentSignInCallback(oidcSettings)

for the linter to still accept the code :)

perarnborg commented 1 year ago

Previous ETA was within short from jan 11. I seem to have failed with that. 😉

I will probably find the time to fix this let’s say this month. Hopefully sooner than the end of this month. But a bit stressed for time at the moment.

perarnborg commented 1 year ago

This is fixed in v4.0.2. TS users should now set client_id and redirect_uri (snake_cased), as they are specified in oidc-client-ts