Dan6erbond / sk-auth

Authentication library for use with SvelteKit featuring built-in OAuth providers and zero restriction customization!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaking change in sveltekit

HalfdanJ opened this issue · comments

An update has been made to sveltekit (not 100% sure which version it came with) that breaks the library. This is the breaking PR: sveltejs/kit#3384

The error message is event.headers has been replaced by event.request.headers. See https://github.com/sveltejs/kit/pull/3384 for details pointing to this chunk of code:

this.getSession = async ({ headers }) => {
      const token = await this.getToken(headers);
      if (token) {
        if (this.config?.callbacks?.session) {
          return await this.config.callbacks.session(token, { user: token.user });
        }
        return { user: token.user };
      }
      return {};
    };

I believe that instead of { headers } it should be { request }, and then request.headers.

I tried modifying the library to make a PR, but having issues building the library in a way that the app will accept it.

endpoints also need updating

looks like this commit from @landongn carries all the required fixes. can't wait for it to be merged.
landongn@dfcd607

#69 was now merged with main and I'll be creating a release soon to address these breaking changes. Thanks to the help by @landongn!