flexsearch icon indicating copy to clipboard operation
flexsearch copied to clipboard

Subresource integrity error

Open niksauer opened this issue 7 months ago • 5 comments

We've been using this library for a while but are having problems with the v0.8+ releases. In addition to not exporting most of the types (see https://github.com/nextapps-de/flexsearch/issues/342#issuecomment-2772370334), it appears that Vite is using a different version of this package when building for production vs. local development. This results in the following error when using a content security policy to whitelist the various script-src:

localhost/:1 Failed to find a valid digest in the 'integrity' attribute for resource 'https://localhost:4173/assets/index-F5PzREtn.js' with computed SHA-256 integrity 'mAt2XXcJ08sos08Ul/Wi7XhLDYG/F2SRpvgwa+brcN0='. The resource has been blocked.

I believe this has to do with the build system overhaul explained in https://github.com/nextapps-de/flexsearch?tab=readme-ov-file#load-library-nodejs-esm-legacy-browser, though as Typescript users we don't have a choice other than import { Document } from 'flexsearch';.

niksauer avatar May 07 '25 13:05 niksauer

Hey @niksauer the latest update export every type. Is it solving your issue?

ts-thomas avatar May 09 '25 05:05 ts-thomas

There don't seem to be any new releases. How can I test a beta build?

niksauer avatar May 09 '25 09:05 niksauer

@niksauer there is a new release on NPM

ts-thomas avatar May 10 '25 13:05 ts-thomas

It somewhat helps with the types but things like Id or Tokenizer are still not exported. Regardless, exporting types won't fix this subresource integrity error. That's related to the bundle(s) being distributed. Merely importing flexsearch in our apps makes it break.

niksauer avatar May 15 '25 09:05 niksauer

@niksauer The index.d.ts now exports everything. There is a testfile for Typescript located here: https://github.com/nextapps-de/flexsearch/blob/master/test/types.ts Compiling those file works fine by tsc ./types.ts.

ts-thomas avatar May 23 '25 18:05 ts-thomas