@ada-support/web-storage 0.11.0 → 0.13.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.
@@ -191,6 +191,12 @@ border: 1px solid;
191
191
  <td>Persistent</td>
192
192
  </tr>
193
193
  <tr>
194
+ <td>testBotPhoneNumber</td>
195
+ <td>Used for voice chat functionality in the bot builder dashboard</td>
196
+ <td>Web Storage (functional)</td>
197
+ <td>Persistent</td>
198
+ </tr>
199
+ <tr>
194
200
  <td>vuid</td>
195
201
  <td>Used by Vimeo to store the user’s usage history (loaded only if a video has been included).</td>
196
202
  <td>Cookie (functional)</td>
@@ -1,6 +1,6 @@
1
1
  import type { AdaFunctionalStorageValue } from "./functional-storage";
2
2
  import type { StorageValueByKey } from "./storage-keys";
3
- export declare const createStorage: (storageProvider: Storage) => {
3
+ export declare const createStorage: (storageType: "local" | "session") => {
4
4
  readonly setItem: <K extends keyof StorageValueByKey>(key: K, value: StorageValueByKey[K]) => void;
5
5
  readonly getItem: <K_1 extends keyof StorageValueByKey>(key: K_1) => StorageValueByKey[K_1] | null;
6
6
  readonly removeItem: <K_2 extends keyof StorageValueByKey>(key: K_2) => void;
@@ -13,7 +13,15 @@ var __assign = (this && this.__assign) || function () {
13
13
  exports.__esModule = true;
14
14
  exports.createStorage = void 0;
15
15
  var WEB_STORAGE_ACCESS_ERROR_MESSAGE = "Cannot access Web Storage API";
16
- var createStorage = function (storageProvider) {
16
+ var createStorage = function (storageType) {
17
+ var storageProvider;
18
+ // To handle incognito mode. Calling localStorage throws an error when in incognito
19
+ try {
20
+ storageProvider = storageType === "local" ? localStorage : sessionStorage;
21
+ }
22
+ catch (e) {
23
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
24
+ }
17
25
  var storage = {
18
26
  setItem: function (key, value) {
19
27
  try {
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  exports.__esModule = true;
3
3
  exports.isWebStorageSupported = exports.adaSessionStorage = exports.adaLocalStorage = void 0;
4
4
  var create_storage_1 = require("./create-storage");
5
- exports.adaLocalStorage = (0, create_storage_1.createStorage)(localStorage);
6
- exports.adaSessionStorage = (0, create_storage_1.createStorage)(sessionStorage);
5
+ exports.adaLocalStorage = (0, create_storage_1.createStorage)("local");
6
+ exports.adaSessionStorage = (0, create_storage_1.createStorage)("session");
7
7
  /** Checks if Web Storage API is supported */
8
8
  var isWebStorageSupported = function () {
9
9
  try {
@@ -54,6 +54,8 @@ export interface StorageValueByKey {
54
54
  "secretButton": string;
55
55
  /** Used for chatter authentication. This is stored on Ada domain. */
56
56
  "sessionToken": string;
57
+ /** Used for voice chat functionality in the bot builder dashboard */
58
+ "testBotPhoneNumber": string;
57
59
  /** Used for Zendesk authentication functionality. */
58
60
  "zdAuthChatPending": boolean;
59
61
  /** Used for Zendesk SDK functionality. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/web-storage",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "A package to provide access to Web Storage API",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {
@@ -3,7 +3,16 @@ import type { StorageKey, StorageValueByKey } from "./storage-keys";
3
3
 
4
4
  const WEB_STORAGE_ACCESS_ERROR_MESSAGE = "Cannot access Web Storage API";
5
5
 
6
- export const createStorage = (storageProvider: Storage) => {
6
+ export const createStorage = (storageType: "local" | "session") => {
7
+ let storageProvider: Storage;
8
+
9
+ // To handle incognito mode. Calling localStorage throws an error when in incognito
10
+ try {
11
+ storageProvider = storageType === "local" ? localStorage : sessionStorage;
12
+ } catch (e) {
13
+ console.warn(WEB_STORAGE_ACCESS_ERROR_MESSAGE);
14
+ }
15
+
7
16
  const storage = {
8
17
  setItem: <K extends StorageKey>(key: K, value: StorageValueByKey[K]): void => {
9
18
  try {
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createStorage } from "./create-storage";
2
2
  import type { StorageKey, StorageValueByKey } from "./storage-keys";
3
3
 
4
- export const adaLocalStorage = createStorage(localStorage);
5
- export const adaSessionStorage = createStorage(sessionStorage);
4
+ export const adaLocalStorage = createStorage("local");
5
+ export const adaSessionStorage = createStorage("session");
6
6
  export type AdaStorageKey = StorageKey;
7
7
  export type AdaStorageValueByKey = StorageValueByKey;
8
8
 
@@ -79,6 +79,9 @@ export interface StorageValueByKey {
79
79
  /** Used for chatter authentication. This is stored on Ada domain. */
80
80
  "sessionToken": string;
81
81
 
82
+ /** Used for voice chat functionality in the bot builder dashboard */
83
+ "testBotPhoneNumber": string;
84
+
82
85
  /** Used for Zendesk authentication functionality. */
83
86
  "zdAuthChatPending": boolean;
84
87