Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
ng7-storage
Advanced tools
Share Data among multiple components in angular using browser session storage
see Stackblitz Demo here More on Github
Angular compatibility
Angular Version | package version |
---|---|
angular 8 and below | 1.1.4 and below |
angular 9 and above(ivy version) | 1.1.5 and above |
angular 10 and above | 1.1.8 and above |
angular 14 and above | 1.1.9 and above |
Run npm i ng7-storage --save
Add to providers array in app module
providers: [
NgStorageService
],
Then import NgStorageService service import { NgStorageService } from 'ng7-storage';
in the components that you would like to use
Then Initialize NgStorageService
in the component constructor
constructor(private ngStorage: NgStorageService) {
}
follow below methods to set and retrieve data to storage
this.ngStorage.setData({ key: "key", value: "data", encrypt: boolean });
Pass key value pairs to store data , and key should be valid string
NB: data format that accepted by setData
method is
export interface IsetData {
key: string;
value?: any;
encrypt?: Boolean;
decrypt?: Boolean;
}
NB:encrypt
is a development onprogress feature and may have issues when setting data that has special characters
eg:
this.ngStorage.getData({ key: "key", decrypt?: boolean });
Use
getData
method to retrieve data, passkey
of the item. passdecrypt
astrue
if you have encrypted the data
For removing data, we can either remove by a single key or we can remove all data at once
removeData
method is used remove single item based on keyremoveAll
method remove all data storedExamples :
removeData : this.ngStorage.removeData('key')
removeAll : this.ngStorage.removeAll()
setData();
getData();
removeData();
removeAll();
Edison Augusthy 💻 |
FAQs
An Angular service for browser session storage management with optional base64 encryption/decryption.
The npm package ng7-storage receives a total of 7 weekly downloads. As such, ng7-storage popularity was classified as not popular.
We found that ng7-storage demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.