npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@maspav/browser-storage

v1.1.1

Published

### Overview `@maspav/browser-storage` is an Angular utility package designed to work seamlessly with Angular versions 14.2.0 and above. It provides browser storage functionalities with additional encryption and decryption capabilities using `crypto-js`.

Readme

@maspav/browser-storage

Overview

@maspav/browser-storage is an Angular utility package designed to work seamlessly with Angular versions 14.2.0 and above. It provides browser storage functionalities with additional encryption and decryption capabilities using crypto-js.

Note: To fully leverage the capabilities of the maspav/browser-storage library, we highly recommend installing crypto-js.
This provides robust encryption and decryption, adding an essential layer of security to your stored data.

Installation

Installing the library using npm:

npm install @maspav/browser-storage

Methods

| Name | Description | |-------|-------------| | set | Stores the encrypted version of a key-value pair in localStorage. Requires key, data and secret as parameters. | | get | Retrieves and decrypts data from localStorage using the specified key and secret. | | clear | Clears data from localStorage. If a key is passed, the data stored against the key is cleared. If no key is passed, all data in the local storage are cleared. | | clearExcept | Clears all data except for the specified keys. Accepts an array of keys to retain. | | encrypt| Encrypts data using a specified secret. This method is utilised internally by set and get but can be used independently as well. | | decrypt | Decrypts data using the secret provided during encryption. This method is used internally by set and get but can also be used independently. |

Usage

Import the Package into Your Angular Module

After installation, import the utilities provided by the library into your Angular module as follows:

import { AppComponent } from "./app.component";
import { BrowserStorageModule } from '@maspav/browser-storage';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserStorageModule],
  bootstrap: [AppComponent]
})

export class AppModule {}

Note: You have the option to import BrowserStorageModule directly as shown above, or configure it with a secret key using the forRoot method, as demonstrated below:

import { AppComponent } from "./app.component";
import { BrowserStorageModule } from '@maspav/browser-storage';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserStorageModule.forRoot({ secret: 'mySecretKey' })],
  bootstrap: [AppComponent]
})

export class AppModule {}

Accessing the Package within Your Component

The example below demonstrates how to store and retrieve the details of a currently logged-in user. It also includes ways to encrypt and decrypt data for added security among other relevant methods.

test.component.ts

import { BehaviorSubject } from 'rxjs';
import { Component } from '@angular/core';
import { BrowserStorageService } from '@maspav/browser-storage';

@Component({
  selector: 'app-test',
  templateUrl: './test.component.html'
})

export class TestComponent {
  text = "Hello World";
  secretKey = "mySecretKey";
  currentUser: any;

  constructor (public storageService: BrowserStorageService) {

    // `set` method example
    this.storageService.set('currentUser', { id: 1, name: 'John Doe' }, secretKey);

    // `get` method example
    this.currentUser = this.storageService.get('currentUser');

    // `clearExcept` method example
    this.storageService.clearExcept(['firstKey', 'secondKey']);
        
    // `clear with key` method example
    this.storageService.clear('firstKey');

    // `clear all` method example
    this.storageService.clear();

    // encrypt method example
    const encryptedText = this.storageService.encrypt(this.text, secretKey);

    // decrypt method example
    const decryptedText = this.storageService.decrypt(encryptedText, secretKey);
  }
}