@ada-support/web-storage 0.4.0 → 0.6.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/dist/index.d.ts +2 -0
- package/dist/index.js +14 -1
- package/dist/storage-keys.d.ts +6 -0
- package/package.json +1 -1
- package/src/index.ts +13 -0
- package/src/storage-keys.ts +9 -0
package/dist/index.d.ts
CHANGED
|
@@ -15,3 +15,5 @@ export declare const adaSessionStorage: {
|
|
|
15
15
|
};
|
|
16
16
|
export declare type AdaStorageKey = StorageKey;
|
|
17
17
|
export declare type AdaStorageValueByKey = StorageValueByKey;
|
|
18
|
+
/** Checks if Web Storage API is supported */
|
|
19
|
+
export declare const isWebStorageSupported: () => boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.__esModule = true;
|
|
3
|
-
exports.adaSessionStorage = exports.adaLocalStorage = void 0;
|
|
3
|
+
exports.isWebStorageSupported = exports.adaSessionStorage = exports.adaLocalStorage = void 0;
|
|
4
4
|
var create_storage_1 = require("./create-storage");
|
|
5
5
|
exports.adaLocalStorage = (0, create_storage_1.createStorage)(localStorage);
|
|
6
6
|
exports.adaSessionStorage = (0, create_storage_1.createStorage)(sessionStorage);
|
|
7
|
+
/** Checks if Web Storage API is supported */
|
|
8
|
+
var isWebStorageSupported = function () {
|
|
9
|
+
try {
|
|
10
|
+
var key = "key_to_test_local_storage";
|
|
11
|
+
localStorage.setItem(key, key);
|
|
12
|
+
localStorage.removeItem(key);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.isWebStorageSupported = isWebStorageSupported;
|
package/dist/storage-keys.d.ts
CHANGED
|
@@ -20,11 +20,17 @@ export interface StorageValueByKey {
|
|
|
20
20
|
"ada-functional-storage": Partial<AdaFunctionalStorageValue>;
|
|
21
21
|
/** Used to identify the user within Ada. */
|
|
22
22
|
"chatter": string;
|
|
23
|
+
/** Used to determine whether chatter session is expired. This is stored on Ada domain. */
|
|
24
|
+
"created": string;
|
|
23
25
|
/** Indicates whether user is connected to a live agent. */
|
|
24
26
|
"inLiveChat": boolean;
|
|
25
27
|
/** Indicates whether user is waiting to connect to a live agent. */
|
|
26
28
|
"liveChatPending": boolean;
|
|
29
|
+
/** Stores Chat iFrame parent window origin. */
|
|
30
|
+
"parentOrigin": string;
|
|
27
31
|
/** Used for chatter authentication. */
|
|
28
32
|
"session_token": string;
|
|
33
|
+
/** Used for chatter authentication. This is stored on Ada domain. */
|
|
34
|
+
"sessionToken": string;
|
|
29
35
|
}
|
|
30
36
|
export declare type StorageKey = keyof StorageValueByKey;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,3 +5,16 @@ export const adaLocalStorage = createStorage(localStorage);
|
|
|
5
5
|
export const adaSessionStorage = createStorage(sessionStorage);
|
|
6
6
|
export type AdaStorageKey = StorageKey;
|
|
7
7
|
export type AdaStorageValueByKey = StorageValueByKey;
|
|
8
|
+
|
|
9
|
+
/** Checks if Web Storage API is supported */
|
|
10
|
+
export const isWebStorageSupported = (): boolean => {
|
|
11
|
+
try {
|
|
12
|
+
const key = "key_to_test_local_storage";
|
|
13
|
+
localStorage.setItem(key, key);
|
|
14
|
+
localStorage.removeItem(key);
|
|
15
|
+
|
|
16
|
+
return true;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
package/src/storage-keys.ts
CHANGED
|
@@ -31,14 +31,23 @@ export interface StorageValueByKey {
|
|
|
31
31
|
/** Used to identify the user within Ada. */
|
|
32
32
|
"chatter": string;
|
|
33
33
|
|
|
34
|
+
/** Used to determine whether chatter session is expired. This is stored on Ada domain. */
|
|
35
|
+
"created": string;
|
|
36
|
+
|
|
34
37
|
/** Indicates whether user is connected to a live agent. */
|
|
35
38
|
"inLiveChat": boolean;
|
|
36
39
|
|
|
37
40
|
/** Indicates whether user is waiting to connect to a live agent. */
|
|
38
41
|
"liveChatPending": boolean;
|
|
39
42
|
|
|
43
|
+
/** Stores Chat iFrame parent window origin. */
|
|
44
|
+
"parentOrigin": string;
|
|
45
|
+
|
|
40
46
|
/** Used for chatter authentication. */
|
|
41
47
|
"session_token": string;
|
|
48
|
+
|
|
49
|
+
/** Used for chatter authentication. This is stored on Ada domain. */
|
|
50
|
+
"sessionToken": string;
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
export type StorageKey = keyof StorageValueByKey;
|