@degreesign/storage 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 DegreeSign
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # DegreeSign - Web Storage System
2
+
3
+ [More Info](https://github.com/DegreeSign/ds_storage)
4
+
5
+ ## Node Integration
6
+ Install using `yarn add @degreesign/storage` or `npm install @degreesign/storage`
7
+
8
+ ```typescript
9
+ import {
10
+ configureStorage,
11
+ } from "@degreesign/storage";
12
+
13
+ // configure storage system
14
+ await configureStorage({
15
+ storageKey: 'newAppData',
16
+ dbName: 'myDatabase',
17
+ storeName: 'users',
18
+ encryptionKey: 'my-secret-key-123'
19
+ });
20
+
21
+ // quick save/read (unencrypted) only suitable for smaller data
22
+ const user: UserData = { id: `1`, name: 'Hasn', email: 'hasn@example.com' };
23
+ saveData({ key: `userData`, data: user });
24
+ const storedUser = readData<UserData>(`userData`);
25
+ console.log('Storage data:', storedUser);
26
+ saveData({ key: `userData` }); // Removes the key and data
27
+
28
+ // secure save/read (encrypted) useful for larger data
29
+ await saveSecure({ key: `userData`, data: user });
30
+ const dbUser = await readSecure<UserData>(`userData`);
31
+ console.log('Database data:', dbUser);
32
+ await saveSecure({ key: `userData` }); // Removes the key and data
33
+ ```
34
+
35
+ ## Browser Integration
36
+ Use in browsers through CDN
37
+ `<script src="https://cdn.jsdelivr.net/npm/@degreesign/storage@1.0.0/dist/browser/degreesign.min.js"></script>`
38
+
39
+ ```typescript
40
+ // configure storage system
41
+ await stored.configureStorage({
42
+ storageKey: 'newAppData',
43
+ dbName: 'myDatabase',
44
+ storeName: 'users',
45
+ encryptionKey: 'my-secret-key-123'
46
+ });
47
+
48
+ // quick save/read (unencrypted) only suitable for smaller data
49
+ const user: UserData = { id: `1`, name: 'Hasn', email: 'hasn@example.com' };
50
+ stored.saveData({ key: `userData`, data: user });
51
+ const storedUser = stored.readData<UserData>(`userData`);
52
+ console.log('Storage data:', storedUser);
53
+ stored.saveData({ key: `userData` }); // Removes the key
54
+
55
+ // secure save/read (encrypted) useful for larger data
56
+ await stored.saveSecure({ key: `userData`, data: user });
57
+ const dbUser = await stored.readSecure<UserData>(`userData`);
58
+ console.log('Database data:', dbUser);
59
+ await stored.saveSecure({ key: `userData` }); // Removes the key
60
+ ```
@@ -0,0 +1,2 @@
1
+ /*! For license information please see degreesign.min.js.LICENSE.txt */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.stored=t():e.stored=t()}(this,()=>(()=>{"use strict";var e={28:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.migrateSecure=t.configureStorage=t.initialiseConfig=t.ENCRYPTION_KEY=t.STORE_NAME=t.DB_NAME=t.STORAGE_KEY=void 0;const a=r(205),o=r(247);let n,c="appData",i="appDB",s="appStorage";t.STORAGE_KEY=c,t.DB_NAME=i,t.STORE_NAME=s;const d="appConfig",y=async()=>{try{const e=localStorage.getItem(d);if(e){const r=JSON.parse(e);t.STORAGE_KEY=c=r.storageKey,t.DB_NAME=i=r.dbName||i,t.STORE_NAME=s=r.storeName||s,t.ENCRYPTION_KEY=n=r.encryptionKey?await(0,a.cryptoKey)(r.encryptionKey):void 0}}catch(e){console.log("initialiseConfig failed",e)}};t.initialiseConfig=y,t.configureStorage=async({storageKey:e,dbName:r,storeName:o,encryptionKey:y})=>{try{const l=localStorage.getItem(d);let u;l&&(u=JSON.parse(l));const p={storageKey:e,dbName:r||i,storeName:o||s,encryptionKey:y};localStorage.setItem(d,JSON.stringify(p)),t.STORAGE_KEY=c=e,p.dbName&&(t.DB_NAME=i=p.dbName),p.storeName&&(t.STORE_NAME=s=p.storeName),t.ENCRYPTION_KEY=n=y?await(0,a.cryptoKey)(y):void 0}catch(e){console.log("Error in configureStorage:",e)}},t.migrateSecure=async({storedKeys:e,newEncryptionKey:r,newDbName:c,newStoreName:d})=>{console.log("Data migration started...");const y=n,l=i,u=s;t.ENCRYPTION_KEY=n=await(0,a.cryptoKey)(r)??n,t.DB_NAME=i=c??i,t.STORE_NAME=s=d??s;for(let t=0;t<e.length;t++){const r=e[t];try{const e=await(0,o.readDB)({key:r,dbName:l,storeName:u}),t=e?y?await(0,a.decryptData)(e,y):JSON.parse(e):void 0,c=t?n?await(0,a.encryptData)(t,n):JSON.stringify(t):void 0;c&&await(0,o.saveDB)({key:r,data:c,dbName:i,storeName:s})}catch(e){console.log("migrateSecure failed",r,e)}}console.log("Data migration finished!")},y()},205:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=t.decryptData=t.encryptData=t.cryptoKey=void 0;const a=r(28),o=async(e,t)=>{try{const r=crypto.getRandomValues(new Uint8Array(12)),a=(new TextEncoder).encode(JSON.stringify(e)),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},t,a),n=new Uint8Array(o),c=new Uint8Array(r.length+n.length);return c.set(r),c.set(n,r.length),btoa(String.fromCharCode(...c))}catch(t){console.log("encryptData failed",t);try{return JSON.stringify(e)}catch(e){}}},n=async(e,t)=>{try{const r=Uint8Array.from(atob(e),e=>e.charCodeAt(0)),a=r.slice(0,12),o=r.slice(12),n=await crypto.subtle.decrypt({name:"AES-GCM",iv:a},t,o);return JSON.parse((new TextDecoder).decode(n))}catch(e){return void console.log("decryptData failed",e)}};t.cryptoKey=async e=>{try{if(!e)return;const t=await crypto.subtle.importKey("raw",(new TextEncoder).encode(e),"PBKDF2",!1,["deriveKey"]);return await crypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode("salt"),iterations:1e5,hash:"SHA-256"},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}catch(e){console.log("processKey failed",e)}},t.encryptData=o,t.decryptData=n,t.encrypt=async e=>{try{return a.ENCRYPTION_KEY?await o(e,a.ENCRYPTION_KEY):JSON.stringify(e)}catch(t){console.log("encrypt failed",t);try{return JSON.stringify(e)}catch(e){}}},t.decrypt=async e=>{try{return a.ENCRYPTION_KEY?await n(e,a.ENCRYPTION_KEY):JSON.parse(e)}catch(e){return void console.log("decrypt failed",e)}}},247:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readSecure=t.saveSecure=t.readDB=t.saveDB=t.openDB=void 0;const a=r(28),o=r(205),n=({dbName:e,storeName:t,version:r=1}={})=>new Promise((o,n)=>{e=e||a.DB_NAME;const c=indexedDB.open(e,r);c.onupgradeneeded=()=>{t=t||a.STORE_NAME;const e=c.result;e.objectStoreNames.contains(t)||e.createObjectStore(t,{keyPath:"id"})},c.onsuccess=()=>o(c.result),c.onerror=()=>{console.log("openDB error",c.error),n(c.error)}}),c=async({key:e,data:t,dbName:r,storeName:a})=>{try{const o=await n({dbName:r,storeName:a});return new Promise(r=>{const n=o.transaction([a],"readwrite").objectStore(a),c=t?n.put({id:e,data:t}):n.delete(e);c.onsuccess=()=>r(!0),c.onerror=()=>{console.log("saveDB error",c.error),r(!1)},o.close()})}catch(e){return console.log("saveSecure failed",e),!1}},i=async({key:e,dbName:t,storeName:r})=>{try{const a=await n({dbName:t,storeName:r});return new Promise(t=>{const o=a.transaction([r],"readonly").objectStore(r).get(e);o.onsuccess=()=>t(o?.result?.data),o.onerror=()=>{console.log("readDB error",o.error),t(void 0)},a.close()})}catch(e){return void console.log("readDB failed",e)}};t.openDB=n,t.saveDB=c,t.readDB=i,t.saveSecure=async({key:e,data:t})=>await c({key:e,data:t?await(0,o.encrypt)(t):void 0,dbName:a.DB_NAME,storeName:a.STORE_NAME}),t.readSecure=async e=>{try{const t=await i({key:e,dbName:a.DB_NAME,storeName:a.STORE_NAME});return t?await(0,o.decrypt)(t):void 0}catch(e){return void console.log("readSecure failed",e)}}},421:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readData=t.saveData=void 0;t.saveData=({key:e,data:t})=>{try{void 0===t?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}catch(e){console.log("saveData failed",e)}},t.readData=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch(e){return void console.log("readData failed",e)}}}},t={};function r(a){var o=t[a];if(void 0!==o)return o.exports;var n=t[a]={exports:{}};return e[a](n,n.exports,r),n.exports}var a={};return(()=>{var e=a;Object.defineProperty(e,"__esModule",{value:!0}),e.decryptData=e.encryptData=e.saveData=e.readData=e.saveSecure=e.readSecure=e.migrateSecure=e.configureStorage=e.initialiseConfig=void 0;const t=r(421);Object.defineProperty(e,"readData",{enumerable:!0,get:function(){return t.readData}}),Object.defineProperty(e,"saveData",{enumerable:!0,get:function(){return t.saveData}});const o=r(28);Object.defineProperty(e,"configureStorage",{enumerable:!0,get:function(){return o.configureStorage}}),Object.defineProperty(e,"initialiseConfig",{enumerable:!0,get:function(){return o.initialiseConfig}}),Object.defineProperty(e,"migrateSecure",{enumerable:!0,get:function(){return o.migrateSecure}});const n=r(247);Object.defineProperty(e,"readSecure",{enumerable:!0,get:function(){return n.readSecure}}),Object.defineProperty(e,"saveSecure",{enumerable:!0,get:function(){return n.saveSecure}});const c=r(205);Object.defineProperty(e,"decryptData",{enumerable:!0,get:function(){return c.decryptData}}),Object.defineProperty(e,"encryptData",{enumerable:!0,get:function(){return c.encryptData}})})(),a})());
@@ -0,0 +1 @@
1
+ /*! MIT License. DegreeSign Storage System SDK */
@@ -0,0 +1,10 @@
1
+ import { ConfigParams, MigrationParams } from "./types";
2
+ declare let STORAGE_KEY: string, DB_NAME: string, STORE_NAME: string, ENCRYPTION_KEY: CryptoKey | undefined;
3
+ declare const
4
+ /** Initialize configurable variables from localStorage on start */
5
+ initialiseConfig: () => Promise<void>,
6
+ /** Configure Storage System */
7
+ configureStorage: ({ storageKey, dbName, storeName, encryptionKey }: ConfigParams) => Promise<void>,
8
+ /** Migrate Data */
9
+ migrateSecure: ({ storedKeys, newEncryptionKey, newDbName, newStoreName, }: MigrationParams) => Promise<void>;
10
+ export { STORAGE_KEY, DB_NAME, STORE_NAME, ENCRYPTION_KEY, initialiseConfig, configureStorage, migrateSecure, };
@@ -0,0 +1,12 @@
1
+ declare const
2
+ /** Crypto Key Processing */
3
+ cryptoKey: (enKey: string | undefined) => Promise<CryptoKey | undefined>,
4
+ /** AES-GCM data encryption using custom key */
5
+ encryptData: <T>(data: T, key: CryptoKey) => Promise<string | undefined>,
6
+ /** AES-GCM data decryption using custom key */
7
+ decryptData: <T>(encrypted: string, key: CryptoKey) => Promise<T | undefined>,
8
+ /** AES-GCM data encryption using set key */
9
+ encrypt: <T>(data: T) => Promise<string | undefined>,
10
+ /** AES-GCM data decryption using set key */
11
+ decrypt: <T>(encrypted: string) => Promise<T | undefined>;
12
+ export { cryptoKey, encryptData, decryptData, encrypt, decrypt, };
@@ -0,0 +1,6 @@
1
+ import { readData, saveData } from "./storage";
2
+ import { configureStorage, initialiseConfig, migrateSecure } from "./config";
3
+ import { readSecure, saveSecure } from "./secure";
4
+ import { StorageParams, ConfigParams } from "./types";
5
+ import { decryptData, encryptData } from "./encrypt";
6
+ export { StorageParams, ConfigParams, initialiseConfig, configureStorage, migrateSecure, readSecure, saveSecure, readData, saveData, encryptData, decryptData, };
@@ -0,0 +1,2 @@
1
+ /*! For license information please see degreesign.node.min.js.LICENSE.txt */
2
+ (()=>{"use strict";var e={28:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.migrateSecure=t.configureStorage=t.initialiseConfig=t.ENCRYPTION_KEY=t.STORE_NAME=t.DB_NAME=t.STORAGE_KEY=void 0;const a=r(205),o=r(247);let n,c="appData",i="appDB",s="appStorage";t.STORAGE_KEY=c,t.DB_NAME=i,t.STORE_NAME=s;const d="appConfig",y=async()=>{try{const e=localStorage.getItem(d);if(e){const r=JSON.parse(e);t.STORAGE_KEY=c=r.storageKey,t.DB_NAME=i=r.dbName||i,t.STORE_NAME=s=r.storeName||s,t.ENCRYPTION_KEY=n=r.encryptionKey?await(0,a.cryptoKey)(r.encryptionKey):void 0}}catch(e){console.log("initialiseConfig failed",e)}};t.initialiseConfig=y,t.configureStorage=async({storageKey:e,dbName:r,storeName:o,encryptionKey:y})=>{try{const l=localStorage.getItem(d);let u;l&&(u=JSON.parse(l));const g={storageKey:e,dbName:r||i,storeName:o||s,encryptionKey:y};localStorage.setItem(d,JSON.stringify(g)),t.STORAGE_KEY=c=e,g.dbName&&(t.DB_NAME=i=g.dbName),g.storeName&&(t.STORE_NAME=s=g.storeName),t.ENCRYPTION_KEY=n=y?await(0,a.cryptoKey)(y):void 0}catch(e){console.log("Error in configureStorage:",e)}},t.migrateSecure=async({storedKeys:e,newEncryptionKey:r,newDbName:c,newStoreName:d})=>{console.log("Data migration started...");const y=n,l=i,u=s;t.ENCRYPTION_KEY=n=await(0,a.cryptoKey)(r)??n,t.DB_NAME=i=c??i,t.STORE_NAME=s=d??s;for(let t=0;t<e.length;t++){const r=e[t];try{const e=await(0,o.readDB)({key:r,dbName:l,storeName:u}),t=e?y?await(0,a.decryptData)(e,y):JSON.parse(e):void 0,c=t?n?await(0,a.encryptData)(t,n):JSON.stringify(t):void 0;c&&await(0,o.saveDB)({key:r,data:c,dbName:i,storeName:s})}catch(e){console.log("migrateSecure failed",r,e)}}console.log("Data migration finished!")},y()},205:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decrypt=t.encrypt=t.decryptData=t.encryptData=t.cryptoKey=void 0;const a=r(28),o=async(e,t)=>{try{const r=crypto.getRandomValues(new Uint8Array(12)),a=(new TextEncoder).encode(JSON.stringify(e)),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},t,a),n=new Uint8Array(o),c=new Uint8Array(r.length+n.length);return c.set(r),c.set(n,r.length),btoa(String.fromCharCode(...c))}catch(t){console.log("encryptData failed",t);try{return JSON.stringify(e)}catch(e){}}},n=async(e,t)=>{try{const r=Uint8Array.from(atob(e),e=>e.charCodeAt(0)),a=r.slice(0,12),o=r.slice(12),n=await crypto.subtle.decrypt({name:"AES-GCM",iv:a},t,o);return JSON.parse((new TextDecoder).decode(n))}catch(e){return void console.log("decryptData failed",e)}};t.cryptoKey=async e=>{try{if(!e)return;const t=await crypto.subtle.importKey("raw",(new TextEncoder).encode(e),"PBKDF2",!1,["deriveKey"]);return await crypto.subtle.deriveKey({name:"PBKDF2",salt:(new TextEncoder).encode("salt"),iterations:1e5,hash:"SHA-256"},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}catch(e){console.log("processKey failed",e)}},t.encryptData=o,t.decryptData=n,t.encrypt=async e=>{try{return a.ENCRYPTION_KEY?await o(e,a.ENCRYPTION_KEY):JSON.stringify(e)}catch(t){console.log("encrypt failed",t);try{return JSON.stringify(e)}catch(e){}}},t.decrypt=async e=>{try{return a.ENCRYPTION_KEY?await n(e,a.ENCRYPTION_KEY):JSON.parse(e)}catch(e){return void console.log("decrypt failed",e)}}},247:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readSecure=t.saveSecure=t.readDB=t.saveDB=t.openDB=void 0;const a=r(28),o=r(205),n=({dbName:e,storeName:t,version:r=1}={})=>new Promise((o,n)=>{e=e||a.DB_NAME;const c=indexedDB.open(e,r);c.onupgradeneeded=()=>{t=t||a.STORE_NAME;const e=c.result;e.objectStoreNames.contains(t)||e.createObjectStore(t,{keyPath:"id"})},c.onsuccess=()=>o(c.result),c.onerror=()=>{console.log("openDB error",c.error),n(c.error)}}),c=async({key:e,data:t,dbName:r,storeName:a})=>{try{const o=await n({dbName:r,storeName:a});return new Promise(r=>{const n=o.transaction([a],"readwrite").objectStore(a),c=t?n.put({id:e,data:t}):n.delete(e);c.onsuccess=()=>r(!0),c.onerror=()=>{console.log("saveDB error",c.error),r(!1)},o.close()})}catch(e){return console.log("saveSecure failed",e),!1}},i=async({key:e,dbName:t,storeName:r})=>{try{const a=await n({dbName:t,storeName:r});return new Promise(t=>{const o=a.transaction([r],"readonly").objectStore(r).get(e);o.onsuccess=()=>t(o?.result?.data),o.onerror=()=>{console.log("readDB error",o.error),t(void 0)},a.close()})}catch(e){return void console.log("readDB failed",e)}};t.openDB=n,t.saveDB=c,t.readDB=i,t.saveSecure=async({key:e,data:t})=>await c({key:e,data:t?await(0,o.encrypt)(t):void 0,dbName:a.DB_NAME,storeName:a.STORE_NAME}),t.readSecure=async e=>{try{const t=await i({key:e,dbName:a.DB_NAME,storeName:a.STORE_NAME});return t?await(0,o.decrypt)(t):void 0}catch(e){return void console.log("readSecure failed",e)}}},421:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readData=t.saveData=void 0;t.saveData=({key:e,data:t})=>{try{void 0===t?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))}catch(e){console.log("saveData failed",e)}},t.readData=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch(e){return void console.log("readData failed",e)}}}},t={};function r(a){var o=t[a];if(void 0!==o)return o.exports;var n=t[a]={exports:{}};return e[a](n,n.exports,r),n.exports}var a={};(()=>{var e=a;Object.defineProperty(e,"__esModule",{value:!0}),e.decryptData=e.encryptData=e.saveData=e.readData=e.saveSecure=e.readSecure=e.migrateSecure=e.configureStorage=e.initialiseConfig=void 0;const t=r(421);Object.defineProperty(e,"readData",{enumerable:!0,get:function(){return t.readData}}),Object.defineProperty(e,"saveData",{enumerable:!0,get:function(){return t.saveData}});const o=r(28);Object.defineProperty(e,"configureStorage",{enumerable:!0,get:function(){return o.configureStorage}}),Object.defineProperty(e,"initialiseConfig",{enumerable:!0,get:function(){return o.initialiseConfig}}),Object.defineProperty(e,"migrateSecure",{enumerable:!0,get:function(){return o.migrateSecure}});const n=r(247);Object.defineProperty(e,"readSecure",{enumerable:!0,get:function(){return n.readSecure}}),Object.defineProperty(e,"saveSecure",{enumerable:!0,get:function(){return n.saveSecure}});const c=r(205);Object.defineProperty(e,"decryptData",{enumerable:!0,get:function(){return c.decryptData}}),Object.defineProperty(e,"encryptData",{enumerable:!0,get:function(){return c.encryptData}})})();var o=exports;for(var n in a)o[n]=a[n];a.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})();
@@ -0,0 +1 @@
1
+ /*! MIT License. DegreeSign Storage System SDK */
@@ -0,0 +1,13 @@
1
+ import { DBConfig, DBRead, DBSave, StorageParams } from "./types";
2
+ declare const
3
+ /** Database (IndexedDB) operations */
4
+ openDB: ({ dbName, storeName, version }?: DBConfig) => Promise<IDBDatabase>,
5
+ /** Save Database (uses IndexedDB)*/
6
+ saveDB: ({ key, data, dbName, storeName, }: DBSave) => Promise<boolean>,
7
+ /** Read Database (uses IndexedDB)*/
8
+ readDB: ({ key, dbName, storeName, }: DBRead) => Promise<string | undefined>,
9
+ /** Save Secure Data (uses IndexedDB)*/
10
+ saveSecure: <T>({ key, data }: StorageParams<T>) => Promise<boolean>,
11
+ /** Read Secure Data (uses IndexedDB)*/
12
+ readSecure: <T>(key: string) => Promise<T | undefined>;
13
+ export { openDB, saveDB, readDB, saveSecure, readSecure, };
@@ -0,0 +1,7 @@
1
+ import { StorageParams } from "./types";
2
+ declare const
3
+ /** Save Data (uses localStorage)*/
4
+ saveData: <T>({ key, data }: StorageParams<T>) => void,
5
+ /** Read Data (uses localStorage)*/
6
+ readData: <T>(key: string) => T | undefined;
7
+ export { saveData, readData, };
@@ -0,0 +1,30 @@
1
+ interface DBConfig {
2
+ dbName?: string;
3
+ storeName?: string;
4
+ version?: number;
5
+ }
6
+ interface DBRead {
7
+ key: string;
8
+ dbName: string;
9
+ storeName: string;
10
+ }
11
+ interface DBSave extends DBRead {
12
+ data: string | undefined;
13
+ }
14
+ interface MigrationParams {
15
+ storedKeys: string[];
16
+ newEncryptionKey?: string;
17
+ newDbName?: string;
18
+ newStoreName?: string;
19
+ }
20
+ interface StorageParams<T> {
21
+ key: string;
22
+ data?: T;
23
+ }
24
+ interface ConfigParams {
25
+ storageKey: string;
26
+ dbName?: string;
27
+ storeName?: string;
28
+ encryptionKey?: string;
29
+ }
30
+ export { DBConfig, DBRead, DBSave, MigrationParams, StorageParams, ConfigParams, };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@degreesign/storage",
3
+ "version": "1.0.0",
4
+ "description": "DegreeSign Storage System",
5
+ "main": "dist/node/degreesign.node.min.js",
6
+ "module": "dist/node/degreesign.node.min.js",
7
+ "browser": "dist/browser/degreesign.min.js",
8
+ "types": "dist/index.d.ts",
9
+ "scripts": {
10
+ "build": "webpack"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/DegreeSign/ds_storage.git"
15
+ },
16
+ "keywords": [
17
+ "DegreeSign",
18
+ "Web Storage System",
19
+ "Web App"
20
+ ],
21
+ "author": "DegreeSign",
22
+ "license": "MIT",
23
+ "bugs": {
24
+ "url": "https://github.com/DegreeSign/ds_storage/issues"
25
+ },
26
+ "homepage": "https://github.com/DegreeSign/ds_storage#readme",
27
+ "devDependencies": {
28
+ "@types/node": "^22.10.2",
29
+ "clean-webpack-plugin": "^4.0.0",
30
+ "esbuild": "^0.24.2",
31
+ "terser-webpack-plugin": "^5.3.11",
32
+ "ts-loader": "^9.5.1",
33
+ "ts-node": "^10.9.2",
34
+ "typescript": "^5.7.2",
35
+ "webpack": "^5.97.1",
36
+ "webpack-cli": "^6.0.1",
37
+ "webpack-dev-server": "^5.2.0"
38
+ },
39
+ "files": [
40
+ "dist/"
41
+ ],
42
+ "dependencies": {}
43
+ }