Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #15 and #22 #24

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,16 @@ encoding method is choosen.
`encryptionNamespace` is used to make multiple instances with different `encryptionSecret`
and/or different `encryptionSecret` possible.

var ls1 = new SecureLS({encodingType: 'des', encryptionSecret: 'my-secret-key-1'});
var ls2 = new SecureLS({encodingType: 'aes', encryptionSecret: 'my-secret-key-2'});
var ls1 = new SecureLS({
encodingType: 'des',
encryptionSecret: 'my-secret-key-1',
encryptionNamespace: 'user-1'
});
var ls2 = new SecureLS({
encodingType: 'aes',
encryptionSecret: 'my-secret-key-2',
encryptionNamespace: 'user-2'
});

**Examples:**

Expand Down
22 changes: 19 additions & 3 deletions dist/secure-ls.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import * as LZString from 'lz-string';
import {CipherHelper, Encoder} from 'crypto-js';

declare class SecureLS {
constructor(config?: { isCompression?: boolean, encodingType?: string, encryptionSecret?: string , encryptionNamespace?: string });
constructor(config?: {
isCompression?: boolean,
encodingType?: string,
encryptionSecret?: string,
encryptionNamespace?: string,
storage?: SecureLS.Storage
});
getEncryptionSecret(): string;
get(key: string, isAllKeysData?: boolean): any;
getDataFromLocalStorage(key: string): string | null;
Expand All @@ -14,7 +20,7 @@ declare class SecureLS {
remove(key: string): void;
removeAll(): void;
clear(): void;
resetAllKeys(): [];
resetAllKeys(): string[];
processData(data: any | string, isAllKeysData: boolean): string;
setMetaData(): void;
getMetaData(): { keys: string[] };
Expand All @@ -26,6 +32,7 @@ declare class SecureLS {
DES: CipherHelper;
RABBIT: CipherHelper;
RC4: CipherHelper;
ls: SecureLS.Storage;
enc: {
Latin1: Encoder;
_Utf8: Encoder;
Expand All @@ -38,4 +45,13 @@ declare namespace SecureLS{
encode(e: string): string;
decode(e: string): string;
}
}
interface Storage {
readonly length: number;
clear(): void;
getItem(key: string): string | null;
key(index: number): string | null;
removeItem(key: string): void;
setItem(key: string, value: string): void;
[name: string]: any;
}
}
Loading