Closed jhuerta closed 1 year ago
This kind of declaration is allowing it to work/compile:
persist: { enabled: true, strategies: [{ storage: encryptStorage as Storage }], },
Unfortunatelly, I am not sure of the consequences or side effects.
Hello @jhuerta, I believe there are no consequences or side-effects, as it implements the same storage interface.
But I believe I can improve this by extending the class. I will do this in a next update.
Thanks for letting me know about this little mishap.
Thanks a lot for looking into this. I'll keep an eye out for the next update.
Cheers,
Juan Huerta
On Tue, 1 Nov 2022 at 21:37, Michelon Souza @.***> wrote:
Hello @jhuerta https://github.com/jhuerta, I believe there are no consequences or side-effects, as it implements the same storage interface.
But I believe I can improve this by extending the class. I will do this in a next update.
Thanks for letting me know about this little mishap.
— Reply to this email directly, view it on GitHub https://github.com/michelonsouza/encrypt-storage/issues/545#issuecomment-1299108373, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJUJJLTDRCO7N2SAEL3AMLWGF5QTANCNFSM6AAAAAARUHF7OM . You are receiving this because you were mentioned.Message ID: @.***>
Hello @jhuerta, how are you? I still haven't had time to update the interface part, but I'll do it as my first task after the end of the year.
I'm sorry for this. Happy New Year.
Hi Michel,
Thanks for looking into this and happy new year to you 👍
So far we are using it with the syntax I commented before, with no problems :)
Thanks,
Juan
Hi,
I'm trying to use this plugin (encrypt-storage@2.12.12) with 'pinia-plugin-persist' ( pinia-plugin-persist@1.0.0)
I get the following TypeScript error:
Type 'EncryptStorage' is not assignable to type 'Storage'. The types returned by 'getItem(...)' are incompatible between these types.
Any suggestion on how to make it work?
tsconfig.json
{ "$schema": "https://json.schemastore.org/tsconfig.json", "extends": "@vue/tsconfig/tsconfig.web.json", "compilerOptions": { "target": "esnext", (...) "types": ["vite/client", "vitest/globals", "vue", "pinia-plugin-persist"] }, "include": ["src//*.ts", "src/*/.d.ts", "src//*.tsx", "src/*/.vue"], "exclude": ["node_modules", "dist", "src/client/Api.ts"], "references": [{ "path": "./tsconfig.node.json" }] }
encryptStorage.ts
import { EncryptStorage } from 'encrypt-storage';
export const encryptStorage = new EncryptStorage( import.meta.env.SECRET_KEY, { storageType: 'localStorage', stateManagementUse: true, } );
SystemStore.ts
import { defineStore } from 'pinia'; import type { encryptStorage } from '@/utils/encryptStorage';
type SystemStoreState = {
};
export default defineStore('systemStore', { state: (): SystemStoreState => ({ persist: { enabled: true, strategies: [{ storage: encryptStorage }], }, });