Comments (4)
Hello @fernandofas , I hope you are well.
Unless you assign the encrypt-storage
instance to the window it will never exist in the global context, and I don't advise doing that in production.
in any <filename>.d.ts
file declare this module:
import { EncryptStorage } from 'encrypt-storage';
declare global {
export interface Window {
encryptStorage?: EncryptStorage;
}
}
After that, where to declare your encrypt-storage
instance use this code:
const encryptStorage = new EncryptStorage('@secretkey', { prefix: '@instance1' });
window.encryptStorage = encryptStorage;
Hope this helps.
Thanks.
from encrypt-storage.
from encrypt-storage.
from encrypt-storage.
No problem @fernandofas,
it would be more or less like this:
using import from node_modules
:
import { EncryptStorage } from 'encrypt-storage';
const prefix = '@application-name';
const secret = '@secret-key'; // greater than 10 characters
export const encryptStorage = new EncryptStorage(secret, {
prefix,
});
// add to global scope
window.encryptStorage = encryptStorage;
using CDNs
<body>
<!-- ...after other codes -->
<script src="https://unpkg.com/encrypt-storage@latest/dist/index.js"></script>
<!-- or <script src="https://cdn.jsdelivr.net/npm/encrypt-storage@latest/dist/index.js"></script> -->
<script>
const encryptStorage = new EncryptStorage('secret-key-value', {
prefix: '@application-name',
});
// add to global scope
window.encryptStorage = encryptStorage;
</script>
</body>
I hope I helped and understood your problem @fernandofas .
Thank you very much for using the library.
from encrypt-storage.
Related Issues (17)
- redux-persist: Cannot read properties of undefined (reading 'then') HOT 6
- Not working with NextJs(SSR) HOT 4
- Error: Can't resolve 'crypto' HOT 13
- get length(): Promise<number>;
- self is not defined HOT 4
- [question] BADENGINE HOT 7
- Uncaught ReferenceError: globalThis is not defined HOT 3
- Native crypto module could not be used to get secure random number. HOT 11
- Type 'EncryptStorage' is not assignable to type 'Storage'. HOT 5
- decryptValue get method return null for plain data HOT 2
- Name and logo of the package HOT 1
- ReferenceError: self is not defined HOT 4
- Invalid left-hand side in assignment (Angular) HOT 6
- Mocking localStorage when Unit Testing Modules using Pinia/Encrypt-Storage HOT 2
- Add example for `pinia-plugin-persistedstate` HOT 1
- API inconsistency HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from encrypt-storage.