From 9f75831b19440d9ba73e6b7583f94e5a333386a6 Mon Sep 17 00:00:00 2001 From: sefatanam Date: Sat, 19 Nov 2022 23:58:25 +0600 Subject: [PATCH] implemented jsDoc support #1 --- README.md | 15 +- package-lock.json | 2 +- package.json | 5 +- projects/crypto-browser-storage/README.md | 15 +- .../crypto-browser-storage/package-lock.json | 151 +++++++++++++++++- projects/crypto-browser-storage/package.json | 5 +- .../src/lib/crypto-browser-storage.service.ts | 36 +++-- 7 files changed, 205 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 26d7c0c..180d509 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,20 @@ # Crypto Browser Storage -☢ A simple package for secure local storage data by encryption using Crypto.JS +☢ A simple package for secure local storage data by encryption using Crypto.JS. Project generated with angular version ```12.2.0```, sou must need an Angular Project ( ``version >= 12.2.x`` ) ## How to use -* Must need an Angular Project ( ``version >= 12.x.x`` ) * Use ``npm i crypto-browser-storage`` -* Inject your Component or Service as Dependency Injection -* Then you will be able to access `crypto-browser-storage`'s library function to set, retrieve & many more. +* Inject to your component or service as Dependency Injection +* Then you will be able to access `crypto-browser-storage`'s library functions, + - setCache + - getCache + - removeCacheByKey + - clearAllCache + +
## Sample Code Snippet +
+ ```` import { CryptoBrowserStorageService } from 'crypto-browser-storage'; diff --git a/package-lock.json b/package-lock.json index aa8faa8..17a2269 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "crypto-local-storage", + "name": "crypto-browser-storage", "version": "0.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index c7dab5c..a5d942f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crypto-browser-storage", - "version": "0.0.0", + "version": "1.0.6", "scripts": { "ng": "ng", "start": "ng serve", @@ -36,5 +36,6 @@ "karma-jasmine-html-reporter": "~1.7.0", "ng-packagr": "^12.1.1", "typescript": "~4.3.5" - } + }, + "license": "MIT" } diff --git a/projects/crypto-browser-storage/README.md b/projects/crypto-browser-storage/README.md index 26d7c0c..180d509 100644 --- a/projects/crypto-browser-storage/README.md +++ b/projects/crypto-browser-storage/README.md @@ -1,13 +1,20 @@ # Crypto Browser Storage -☢ A simple package for secure local storage data by encryption using Crypto.JS +☢ A simple package for secure local storage data by encryption using Crypto.JS. Project generated with angular version ```12.2.0```, sou must need an Angular Project ( ``version >= 12.2.x`` ) ## How to use -* Must need an Angular Project ( ``version >= 12.x.x`` ) * Use ``npm i crypto-browser-storage`` -* Inject your Component or Service as Dependency Injection -* Then you will be able to access `crypto-browser-storage`'s library function to set, retrieve & many more. +* Inject to your component or service as Dependency Injection +* Then you will be able to access `crypto-browser-storage`'s library functions, + - setCache + - getCache + - removeCacheByKey + - clearAllCache + +
## Sample Code Snippet +
+ ```` import { CryptoBrowserStorageService } from 'crypto-browser-storage'; diff --git a/projects/crypto-browser-storage/package-lock.json b/projects/crypto-browser-storage/package-lock.json index 07163f1..52f60b2 100644 --- a/projects/crypto-browser-storage/package-lock.json +++ b/projects/crypto-browser-storage/package-lock.json @@ -1,9 +1,133 @@ { - "name": "crypto-local-storage", + "name": "crypto-browser-storage", "version": "0.0.1", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "crypto-browser-storage", + "version": "0.0.1", + "dependencies": { + "crypto-js": "^3.1.8", + "secure-web-storage": "^1.0.2", + "tslib": "^2.3.0" + }, + "devDependencies": { + "@types/crypto-js": "^4.0.2", + "@types/node": "^16.11.6" + }, + "peerDependencies": { + "@angular/common": "^12.2.0", + "@angular/core": "^12.2.0", + "crypto-js": "^3.1.8", + "secure-web-storage": "^1.0.2" + } + }, + "node_modules/@angular/common": { + "version": "12.2.16", + "resolved": "https://registry.npmjs.org/@angular/common/-/common-12.2.16.tgz", + "integrity": "sha512-FEqTXTEsnbDInqV1yFlm97Tz1OFqZS5t0TUkm8gzXRgpIce/F/jLwAg0u1VQkgOsno6cNm0xTWPoZgu85NI4ug==", + "peer": true, + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": "^12.14.1 || >=14.0.0" + }, + "peerDependencies": { + "@angular/core": "12.2.16", + "rxjs": "^6.5.3 || ^7.0.0" + } + }, + "node_modules/@angular/core": { + "version": "12.2.16", + "resolved": "https://registry.npmjs.org/@angular/core/-/core-12.2.16.tgz", + "integrity": "sha512-jsmvaRdAfng99z2a9mAmkfcsCE1wm+tBYVDxnc5JquSXznwtncjzcoc2X0J0dzrkCDvzFfpTsZ9vehylytBc+A==", + "peer": true, + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": "^12.14.1 || >=14.0.0" + }, + "peerDependencies": { + "rxjs": "^6.5.3 || ^7.0.0", + "zone.js": "~0.11.4" + } + }, + "node_modules/@types/crypto-js": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.0.2.tgz", + "integrity": "sha512-sCVniU+h3GcGqxOmng11BRvf9TfN9yIs8KKjB8C8d75W69cpTfZG80gau9yTx5SxF3gvHGbJhdESzzvnjtf3Og==", + "dev": true + }, + "node_modules/@types/node": { + "version": "16.11.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz", + "integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==", + "dev": true + }, + "node_modules/crypto-js": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.8.tgz", + "integrity": "sha1-cV8HC/YBTyrpkqmLOSkli3E/CNU=" + }, + "node_modules/generate-js": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/generate-js/-/generate-js-3.1.2.tgz", + "integrity": "sha1-Jf+N1MOAkKk49kiIfVNrrUa0e2I=" + }, + "node_modules/rxjs": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz", + "integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==", + "peer": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/secure-web-storage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/secure-web-storage/-/secure-web-storage-1.0.2.tgz", + "integrity": "sha1-cwnDXDaF8KnmOoxJZMbs3A+Dg5w=", + "dependencies": { + "generate-js": "^3.1.2" + } + }, + "node_modules/tslib": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", + "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" + }, + "node_modules/zone.js": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.11.8.tgz", + "integrity": "sha512-82bctBg2hKcEJ21humWIkXRlLBBmrc3nN7DFh5LGGhcyycO2S7FN8NmdvlcKaGFDNVL4/9kFLmwmInTavdJERA==", + "peer": true, + "dependencies": { + "tslib": "^2.3.0" + } + } + }, "dependencies": { + "@angular/common": { + "version": "12.2.16", + "resolved": "https://registry.npmjs.org/@angular/common/-/common-12.2.16.tgz", + "integrity": "sha512-FEqTXTEsnbDInqV1yFlm97Tz1OFqZS5t0TUkm8gzXRgpIce/F/jLwAg0u1VQkgOsno6cNm0xTWPoZgu85NI4ug==", + "peer": true, + "requires": { + "tslib": "^2.2.0" + } + }, + "@angular/core": { + "version": "12.2.16", + "resolved": "https://registry.npmjs.org/@angular/core/-/core-12.2.16.tgz", + "integrity": "sha512-jsmvaRdAfng99z2a9mAmkfcsCE1wm+tBYVDxnc5JquSXznwtncjzcoc2X0J0dzrkCDvzFfpTsZ9vehylytBc+A==", + "peer": true, + "requires": { + "tslib": "^2.2.0" + } + }, "@types/crypto-js": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.0.2.tgz", @@ -26,6 +150,15 @@ "resolved": "https://registry.npmjs.org/generate-js/-/generate-js-3.1.2.tgz", "integrity": "sha1-Jf+N1MOAkKk49kiIfVNrrUa0e2I=" }, + "rxjs": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz", + "integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==", + "peer": true, + "requires": { + "tslib": "^2.1.0" + } + }, "secure-web-storage": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/secure-web-storage/-/secure-web-storage-1.0.2.tgz", @@ -33,6 +166,20 @@ "requires": { "generate-js": "^3.1.2" } + }, + "tslib": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", + "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" + }, + "zone.js": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.11.8.tgz", + "integrity": "sha512-82bctBg2hKcEJ21humWIkXRlLBBmrc3nN7DFh5LGGhcyycO2S7FN8NmdvlcKaGFDNVL4/9kFLmwmInTavdJERA==", + "peer": true, + "requires": { + "tslib": "^2.3.0" + } } } } diff --git a/projects/crypto-browser-storage/package.json b/projects/crypto-browser-storage/package.json index 46961a7..1cef48d 100644 --- a/projects/crypto-browser-storage/package.json +++ b/projects/crypto-browser-storage/package.json @@ -1,6 +1,6 @@ { "name": "crypto-browser-storage", - "version": "0.0.1", + "version": "1.0.6", "description": "☢ A simple package for secure local storage data by encryption using Crypto.JS", "author": { "url": "https://github.com/nixgram", @@ -23,5 +23,6 @@ "devDependencies": { "@types/crypto-js": "^4.0.2", "@types/node": "^16.11.6" - } + }, + "license": "MIT" } diff --git a/projects/crypto-browser-storage/src/lib/crypto-browser-storage.service.ts b/projects/crypto-browser-storage/src/lib/crypto-browser-storage.service.ts index 2d29a56..69ed9d9 100644 --- a/projects/crypto-browser-storage/src/lib/crypto-browser-storage.service.ts +++ b/projects/crypto-browser-storage/src/lib/crypto-browser-storage.service.ts @@ -1,6 +1,6 @@ -import {Injectable} from '@angular/core'; +import { Injectable } from '@angular/core'; import * as CryptoJS from "crypto-js"; -import {KEY} from "./KEY"; +import { KEY } from "./KEY"; const SecureStorage = require("secure-web-storage"); @@ -30,9 +30,13 @@ export class CryptoBrowserStorageService { }); - // Set local storage data via key + /** + * Set data to localstorage via key + * @param {any} key:string + * @param {any} data: any + * @returns {void} void + */ public setCache(key: string, data: any): void { - try { if (data) { this.secureStorage.setItem(key, data); @@ -44,26 +48,40 @@ export class CryptoBrowserStorageService { } } - // Get local storage data via key + + /** + * Get localstorage data via key + * @param {any} key:string + * @returns {any} any: number | string | object | array + */ public getCache(key: string) { try { return this.secureStorage.getItem(key); } catch (error) { - console.log(`Error To Get ${key} Cache Data:`, error); + console.log('Key not found in localstorage or maybe wrong key.'); } } - // Remove stored local storage data via key + /** + * It will remove stored local storage data via key + * @param {any} key:string + * @returns {void} void + */ + public removeCacheByKey(key: string) { try { this.secureStorage.removeItem(key); } catch (error) { - console.log(`Error To Remove ${key} Cache Data:`, error); + console.error('Key not found in localstorage or maybe wrong key.'); } } - // It remove all local storage stored data + + /** + * It behave like native localstorage clear() function. It will clear all cache including pre-existing localstorage data. + * @returns {void} void + */ public clearAllCache() { localStorage.clear(); }