@ironcorelabs/ironweb 4.0.15 → 4.1.1

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.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Versions = exports.UserAndGroupTypes = exports.GroupPermissions = exports.Frame = exports.ErrorCodes = exports.CryptoConstants = exports.ALLOWED_ID_CHAR_REGEX = exports.HEADER_META_LENGTH_LENGTH = exports.VERSION_HEADER_LENGTH = exports.DOCUMENT_ENCRYPTION_DETAILS_VERSION_NUMBER = void 0;
3
4
  /**
4
5
  * Number which is prepended onto encrypted documents to denote which classification of encrypted data
5
6
  * the document represents. Used to have a place to denote header info, symmetric encryption details, etc
@@ -16,7 +17,7 @@ exports.CryptoConstants = {
16
17
  IV_LENGTH: 12,
17
18
  SALT_LENGTH: 32,
18
19
  AES_SYMMETRIC_KEY_LENGTH: 32,
19
- PBKDF2_ITERATIONS: function () { return 250000; },
20
+ PBKDF2_ITERATIONS: 250000,
20
21
  NATIVE_DECRYPT_FAILURE_ERROR: "OperationError",
21
22
  };
22
23
  var ErrorCodes;
@@ -45,6 +46,7 @@ var ErrorCodes;
45
46
  ErrorCodes[ErrorCodes["USER_DEVICE_DELETE_REQUEST_FAILURE"] = 210] = "USER_DEVICE_DELETE_REQUEST_FAILURE";
46
47
  ErrorCodes[ErrorCodes["USER_UPDATE_KEY_REQUEST_FAILURE"] = 211] = "USER_UPDATE_KEY_REQUEST_FAILURE";
47
48
  ErrorCodes[ErrorCodes["USER_PRIVATE_KEY_ROTATION_FAILURE"] = 212] = "USER_PRIVATE_KEY_ROTATION_FAILURE";
49
+ ErrorCodes[ErrorCodes["USER_DEVICE_LIST_REQUEST_FAILURE"] = 213] = "USER_DEVICE_LIST_REQUEST_FAILURE";
48
50
  ErrorCodes[ErrorCodes["DOCUMENT_LIST_REQUEST_FAILURE"] = 300] = "DOCUMENT_LIST_REQUEST_FAILURE";
49
51
  ErrorCodes[ErrorCodes["DOCUMENT_GET_REQUEST_FAILURE"] = 301] = "DOCUMENT_GET_REQUEST_FAILURE";
50
52
  ErrorCodes[ErrorCodes["DOCUMENT_CREATE_REQUEST_FAILURE"] = 302] = "DOCUMENT_CREATE_REQUEST_FAILURE";
@@ -110,5 +112,5 @@ exports.UserAndGroupTypes = {
110
112
  };
111
113
  exports.Versions = {
112
114
  //This define is replaced at runtime during development, and at build time in the build script with the proper version
113
- SDK_VERSION: "4.0.15",
115
+ SDK_VERSION: "4.1.1",
114
116
  };
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sliceArrayBuffer = exports.concatArrayBuffers = exports.transformKeyToBase64 = exports.publicKeyToBytes = exports.publicKeyToBase64 = exports.arrayBufferToUtf8String = exports.utf8StringToArrayBuffer = void 0;
3
4
  var UTF8 = require("@stablelib/utf8");
4
5
  var base64_js_1 = require("base64-js");
5
6
  /**
@@ -21,8 +22,8 @@ exports.arrayBufferToUtf8String = arrayBufferToUtf8String;
21
22
  */
22
23
  function publicKeyToBase64(publicKey) {
23
24
  return {
24
- x: base64_js_1.fromByteArray(publicKey.x),
25
- y: base64_js_1.fromByteArray(publicKey.y),
25
+ x: (0, base64_js_1.fromByteArray)(publicKey.x),
26
+ y: (0, base64_js_1.fromByteArray)(publicKey.y),
26
27
  };
27
28
  }
28
29
  exports.publicKeyToBase64 = publicKeyToBase64;
@@ -31,8 +32,8 @@ exports.publicKeyToBase64 = publicKeyToBase64;
31
32
  */
32
33
  function publicKeyToBytes(publicKey) {
33
34
  return {
34
- x: base64_js_1.toByteArray(publicKey.x),
35
- y: base64_js_1.toByteArray(publicKey.y),
35
+ x: (0, base64_js_1.toByteArray)(publicKey.x),
36
+ y: (0, base64_js_1.toByteArray)(publicKey.y),
36
37
  };
37
38
  }
38
39
  exports.publicKeyToBytes = publicKeyToBytes;
@@ -43,10 +44,10 @@ function transformKeyToBase64(transformKey) {
43
44
  return {
44
45
  ephemeralPublicKey: publicKeyToBase64(transformKey.ephemeralPublicKey),
45
46
  toPublicKey: publicKeyToBase64(transformKey.toPublicKey),
46
- encryptedTempKey: base64_js_1.fromByteArray(transformKey.encryptedTempKey),
47
- hashedTempKey: base64_js_1.fromByteArray(transformKey.hashedTempKey),
48
- publicSigningKey: base64_js_1.fromByteArray(transformKey.publicSigningKey),
49
- signature: base64_js_1.fromByteArray(transformKey.signature),
47
+ encryptedTempKey: (0, base64_js_1.fromByteArray)(transformKey.encryptedTempKey),
48
+ hashedTempKey: (0, base64_js_1.fromByteArray)(transformKey.hashedTempKey),
49
+ publicSigningKey: (0, base64_js_1.fromByteArray)(transformKey.publicSigningKey),
50
+ signature: (0, base64_js_1.fromByteArray)(transformKey.signature),
50
51
  };
51
52
  }
52
53
  exports.transformKeyToBase64 = transformKeyToBase64;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendMessage = exports.messenger = exports.ShimMessenger = void 0;
3
4
  var futurejs_1 = require("futurejs");
4
5
  var Constants_1 = require("../Constants");
5
6
  var SDKError_1 = require("../lib/SDKError");
@@ -86,7 +87,7 @@ frame.style.display = "none";
86
87
  frame.style.position = "absolute";
87
88
  frame.style.top = "-999px";
88
89
  frame.style.left = "-999px";
89
- frame.src = "" + Constants_1.Frame.FRAME_DOMAIN + Constants_1.Frame.FRAME_PATH + "?version=" + Constants_1.Versions.SDK_VERSION;
90
+ frame.src = "".concat(Constants_1.Frame.FRAME_DOMAIN).concat(Constants_1.Frame.FRAME_PATH, "?version=").concat(Constants_1.Versions.SDK_VERSION);
90
91
  window.document.body.appendChild(frame);
91
92
  /**
92
93
  * Return a simple Future wrapper around existing frame load Promise so that we wait until the iFrame has loaded before we post any messages to it. We
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initialize = exports.createUserDeviceKeys = exports.createNewUser = void 0;
3
4
  var futurejs_1 = require("futurejs");
4
5
  var Constants_1 = require("../Constants");
5
6
  var SDKError_1 = require("../lib/SDKError");
@@ -22,7 +23,7 @@ function getJWT(jwtCallback) {
22
23
  if (typeof jwt === "string" && jwt.length > 0) {
23
24
  return futurejs_1.default.of(jwt);
24
25
  }
25
- return futurejs_1.default.reject(new SDKError_1.default(new Error("JWT should be a non-zero length string, but instead got '" + jwt + "'"), Constants_1.ErrorCodes.JWT_RETRIEVAL_FAILURE));
26
+ return futurejs_1.default.reject(new SDKError_1.default(new Error("JWT should be a non-zero length string, but instead got '".concat(jwt, "'")), Constants_1.ErrorCodes.JWT_RETRIEVAL_FAILURE));
26
27
  });
27
28
  }
28
29
  /**
@@ -42,7 +43,7 @@ function invokePasscodeCallback(passcodeCallback, doesUserExist) {
42
43
  if (typeof passcode === "string" && passcode.length > 0) {
43
44
  return futurejs_1.default.of(passcode);
44
45
  }
45
- return futurejs_1.default.reject(new SDKError_1.default(new Error("User provided passcode should be a non-zero length string, but instead got '" + passcode + "'"), Constants_1.ErrorCodes.PASSCODE_RETRIEVAL_FAILURE));
46
+ return futurejs_1.default.reject(new SDKError_1.default(new Error("User provided passcode should be a non-zero length string, but instead got '".concat(passcode, "'")), Constants_1.ErrorCodes.PASSCODE_RETRIEVAL_FAILURE));
46
47
  });
47
48
  }
48
49
  /**
@@ -60,15 +61,15 @@ function setUserPasscode(doesUserExist, passcode) {
60
61
  return FrameMediator.sendMessage(payload);
61
62
  })
62
63
  .map(function (sdkResponse) {
63
- ShimUtils_1.storeParentWindowSymmetricKey(sdkResponse.message.symmetricKey);
64
- ShimUtils_1.setSDKInitialized();
64
+ (0, ShimUtils_1.storeParentWindowSymmetricKey)(sdkResponse.message.symmetricKey);
65
+ (0, ShimUtils_1.setSDKInitialized)();
65
66
  return { user: sdkResponse.message.user, groupsNeedingRotation: sdkResponse.message.groupsNeedingRotation };
66
67
  });
67
68
  }
68
69
  /**
69
70
  * Create a new user using a JWT callback. Returns the created user's info if successful.
70
71
  */
71
- exports.createNewUser = function (jwtCallback, passcode, needsRotation) {
72
+ var createNewUser = function (jwtCallback, passcode, needsRotation) {
72
73
  if (needsRotation === void 0) { needsRotation = false; }
73
74
  return getJWT(jwtCallback)
74
75
  .flatMap(function (jwtToken) {
@@ -89,10 +90,11 @@ exports.createNewUser = function (jwtCallback, passcode, needsRotation) {
89
90
  })
90
91
  .toPromise();
91
92
  };
93
+ exports.createNewUser = createNewUser;
92
94
  /**
93
95
  * Create a set of device keys that aren't stored in the browser and are returned to the caller.
94
96
  */
95
- exports.createUserDeviceKeys = function (jwtCallback, passcode) {
97
+ var createUserDeviceKeys = function (jwtCallback, passcode) {
96
98
  return getJWT(jwtCallback)
97
99
  .flatMap(function (jwtToken) {
98
100
  var payload = { type: "CREATE_DETATCHED_USER_DEVICE", message: { passcode: passcode, jwtToken: jwtToken } };
@@ -104,6 +106,7 @@ exports.createUserDeviceKeys = function (jwtCallback, passcode) {
104
106
  })
105
107
  .toPromise();
106
108
  };
109
+ exports.createUserDeviceKeys = createUserDeviceKeys;
107
110
  /**
108
111
  * Initialize the API by getting a JWT and verifying the user. Returns either the SDK if the user has their set of
109
112
  * device keys, or returns asking for passcode if user needs to be created/updated.
@@ -118,7 +121,7 @@ function initialize(jwtCallback, passcodeCallback) {
118
121
  type: "INIT_SDK",
119
122
  message: {
120
123
  jwtToken: jwtToken,
121
- symmetricKey: ShimUtils_1.getParentWindowSymmetricKey(),
124
+ symmetricKey: (0, ShimUtils_1.getParentWindowSymmetricKey)(),
122
125
  },
123
126
  };
124
127
  return FrameMediator.sendMessage(payload);
@@ -129,8 +132,8 @@ function initialize(jwtCallback, passcodeCallback) {
129
132
  return setUserPasscode(responsePayload.message.doesUserExist, passcode);
130
133
  });
131
134
  }
132
- ShimUtils_1.storeParentWindowSymmetricKey(responsePayload.message.symmetricKey);
133
- ShimUtils_1.setSDKInitialized();
135
+ (0, ShimUtils_1.storeParentWindowSymmetricKey)(responsePayload.message.symmetricKey);
136
+ (0, ShimUtils_1.setSDKInitialized)();
134
137
  return futurejs_1.default.of({
135
138
  user: responsePayload.message.user,
136
139
  groupsNeedingRotation: responsePayload.message.groupsNeedingRotation,
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.codec = exports.search = exports.group = exports.user = exports.document = void 0;
3
4
  var CodecSDK = require("./sdk/CodecSDK");
4
5
  var DocumentSDK = require("./sdk/DocumentSDK");
5
6
  var GroupSDK = require("./sdk/GroupSDK");
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dedupeAccessLists = exports.validateIDList = exports.validateAccessList = exports.validateEncryptedDeks = exports.validateEncryptedDocument = exports.validateDocumentData = exports.validateID = exports.validateOwnership = exports.dedupeArray = exports.clearParentWindowSymmetricKey = exports.getParentWindowSymmetricKey = exports.storeParentWindowSymmetricKey = exports.checkSDKInitialized = exports.clearSDKInitialized = exports.setSDKInitialized = void 0;
3
4
  var Constants_1 = require("../Constants");
4
5
  var SECRET_KEY_LOCAL_STORAGE_VERSION = "1";
5
6
  var hasInitializedSDK = false;
@@ -7,7 +8,7 @@ var hasInitializedSDK = false;
7
8
  * Generate parent window storage key that we'll use to store/retrieve the users symmetric key to decrypt their device/signing keys
8
9
  */
9
10
  function generateParentStorageKey() {
10
- return SECRET_KEY_LOCAL_STORAGE_VERSION + "-icldassk";
11
+ return "".concat(SECRET_KEY_LOCAL_STORAGE_VERSION, "-icldassk");
11
12
  }
12
13
  /**
13
14
  * Mark SDK initialization as complete to allow SDK methods to be run
@@ -103,10 +104,10 @@ exports.validateOwnership = validateOwnership;
103
104
  */
104
105
  function validateID(id) {
105
106
  if (typeof id !== "string" || !id.length) {
106
- throw new Error("Invalid ID provided. Expected a non-zero length string but got " + id);
107
+ throw new Error("Invalid ID provided. Expected a non-zero length string but got ".concat(id));
107
108
  }
108
109
  if (!Constants_1.ALLOWED_ID_CHAR_REGEX.test(id)) {
109
- throw new Error("Invalid ID provided. Provided value includes invalid characters: '" + id + "'.");
110
+ throw new Error("Invalid ID provided. Provided value includes invalid characters: '".concat(id, "'."));
110
111
  }
111
112
  }
112
113
  exports.validateID = validateID;
@@ -1,8 +1,20 @@
1
1
  "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.SDKError = exports.ErrorCodes = exports.isInitialized = exports.initialize = exports.createNewDeviceKeys = exports.createNewUser = void 0;
6
18
  var Constants_1 = require("../Constants");
7
19
  var SDKError_1 = require("../lib/SDKError");
8
20
  var Init = require("./Initialize");
@@ -92,7 +104,7 @@ exports.initialize = initialize;
92
104
  */
93
105
  function isInitialized() {
94
106
  try {
95
- ShimUtils_1.checkSDKInitialized();
107
+ (0, ShimUtils_1.checkSDKInitialized)();
96
108
  return true;
97
109
  }
98
110
  catch (_) {
@@ -107,10 +119,10 @@ exports.isInitialized = isInitialized;
107
119
  * List of SDK Error Codes
108
120
  */
109
121
  var Constants_2 = require("../Constants");
110
- exports.ErrorCodes = Constants_2.ErrorCodes;
122
+ Object.defineProperty(exports, "ErrorCodes", { enumerable: true, get: function () { return Constants_2.ErrorCodes; } });
111
123
  /**
112
124
  * SDK Error which extends normal Error object but adds `code` property which will be one of the ErrorCodes from above
113
125
  */
114
126
  var SDKError_2 = require("../lib/SDKError");
115
- exports.SDKError = SDKError_2.default;
116
- __export(require("./SDK"));
127
+ Object.defineProperty(exports, "SDKError", { enumerable: true, get: function () { return SDKError_2.default; } });
128
+ __exportStar(require("./SDK"), exports);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.base64 = exports.utf8 = void 0;
3
4
  var utf8_1 = require("@stablelib/utf8");
4
5
  var base64_js_1 = require("base64-js");
5
6
  exports.utf8 = {
@@ -8,14 +9,14 @@ exports.utf8 = {
8
9
  * @param {Uint8Array} bytes Array of bytes to convert into UTF-8
9
10
  */
10
11
  fromBytes: function (bytes) {
11
- return utf8_1.decode(bytes);
12
+ return (0, utf8_1.decode)(bytes);
12
13
  },
13
14
  /**
14
15
  * Convert a valid UTF-8 string into an array of bytes. This operation will throw an exception if the string provided is not valid UTF-8.
15
16
  * @param {string} utf8String UTF-8 string to convert into bytes
16
17
  */
17
18
  toBytes: function (utf8String) {
18
- return utf8_1.encode(utf8String);
19
+ return (0, utf8_1.encode)(utf8String);
19
20
  },
20
21
  };
21
22
  exports.base64 = {
@@ -24,13 +25,13 @@ exports.base64 = {
24
25
  * @param {Uint8Array} bytes Array of bytes to convert into Base64
25
26
  */
26
27
  fromBytes: function (bytes) {
27
- return base64_js_1.fromByteArray(bytes);
28
+ return (0, base64_js_1.fromByteArray)(bytes);
28
29
  },
29
30
  /**
30
31
  * Convert a valid Base64 string into an array of bytes. This operation will throw an exception if the string provided is not valid Base64.
31
32
  * @param {string} base64String Base64 string to convert into bytes
32
33
  */
33
34
  toBytes: function (base64String) {
34
- return base64_js_1.toByteArray(base64String);
35
+ return (0, base64_js_1.toByteArray)(base64String);
35
36
  },
36
37
  };
@@ -16,6 +16,7 @@ var __read = (this && this.__read) || function (o, n) {
16
16
  return ar;
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.advanced = exports.revokeAccess = exports.grantAccess = exports.updateName = exports.updateEncryptedData = exports.updateEncryptedDataInStore = exports.encrypt = exports.encryptToStore = exports.decrypt = exports.decryptFromStore = exports.getDocumentIDFromBytes = exports.getMetadata = exports.list = void 0;
19
20
  var futurejs_1 = require("futurejs");
20
21
  var Constants_1 = require("../../Constants");
21
22
  var SDKError_1 = require("../../lib/SDKError");
@@ -31,7 +32,7 @@ var MAX_DOCUMENT_SIZE = 1024 * 2 * 1000; //2MB
31
32
  function calculateDocumentCreateOptionsDefault(options) {
32
33
  //Generate a random ID for the document if the user didn't provide one
33
34
  var randomBytes = window.crypto.getRandomValues(new Uint8Array(16));
34
- var hexID = Array.prototype.map.call(randomBytes, function (byte) { return ("00" + byte.toString(16)).slice(-2); }).join("");
35
+ var hexID = Array.prototype.map.call(randomBytes, function (byte) { return "00".concat(byte.toString(16)).slice(-2); }).join("");
35
36
  if (!options) {
36
37
  return { documentID: hexID, documentName: "", accessList: { users: [], groups: [], grantToAuthor: true } };
37
38
  }
@@ -107,10 +108,12 @@ function getDocumentIDFromBytes(documentData) {
107
108
  }
108
109
  exports.getDocumentIDFromBytes = getDocumentIDFromBytes;
109
110
  /**
111
+ * @deprecated Use `decrypt` instead.
110
112
  * Retrieve and decrypt a document from the document store. Returns a Promise which will be resolved once the document has been retrieved and decrypted.
111
113
  * @param {string} documentID ID of the document to retrieve
112
114
  */
113
115
  function decryptFromStore(documentID) {
116
+ console.warn("decryptFromStore is deprecated. Use decrypt instead.");
114
117
  ShimUtils.checkSDKInitialized();
115
118
  ShimUtils.validateID(documentID);
116
119
  var payload = {
@@ -152,6 +155,7 @@ function decrypt(documentID, documentData) {
152
155
  }
153
156
  exports.decrypt = decrypt;
154
157
  /**
158
+ * @deprecated Use `encrypt` instead and manage storage of the result yourself.
155
159
  * Creates a new encrypted document within the store. Returns a Promise which will be resolved once the data has been fully encrypted and saved.
156
160
  * @param {Uint8Array} documentData Data to save for document
157
161
  * @param {DocumentCreateOptions} options Document create options. Includes:
@@ -164,10 +168,11 @@ exports.decrypt = decrypt;
164
168
  * grantToAuthor: boolean - Should the create grant access to the logged in user. Defaults to true.
165
169
  */
166
170
  function encryptToStore(documentData, options) {
171
+ console.warn("encryptToStore is deprecated. Use encrypt instead and manage storage of the result yourself.");
167
172
  ShimUtils.checkSDKInitialized();
168
173
  ShimUtils.validateDocumentData(documentData);
169
174
  if (documentData.length > MAX_DOCUMENT_SIZE) {
170
- return Promise.reject(new SDKError_1.default(new Error("Document of length " + documentData.length + " exceeds maximum allowed byte size of " + MAX_DOCUMENT_SIZE), Constants_1.ErrorCodes.DOCUMENT_MAX_SIZE_EXCEEDED));
175
+ return Promise.reject(new SDKError_1.default(new Error("Document of length ".concat(documentData.length, " exceeds maximum allowed byte size of ").concat(MAX_DOCUMENT_SIZE)), Constants_1.ErrorCodes.DOCUMENT_MAX_SIZE_EXCEEDED));
171
176
  }
172
177
  var encryptOptions = calculateDocumentCreateOptionsDefault(options);
173
178
  if (encryptOptions.documentID) {
@@ -237,6 +242,7 @@ function encrypt(documentData, options) {
237
242
  exports.encrypt = encrypt;
238
243
  /**
239
244
  * Update an existing documents data in the store. Returns a Promise which will be resolved once the document has been successfully updated in the store.
245
+ * @deprecated Use `updateEncryptedData` instead and manage storage of the result yourself.
240
246
  * @param {string} documentID ID of document to update. Promise will reject if document does not exist
241
247
  * @param {Uint8Array} newDocumentData New content to encrypt and save for document
242
248
  */
@@ -245,7 +251,7 @@ function updateEncryptedDataInStore(documentID, newDocumentData) {
245
251
  ShimUtils.validateID(documentID);
246
252
  ShimUtils.validateDocumentData(newDocumentData);
247
253
  if (newDocumentData.length > MAX_DOCUMENT_SIZE) {
248
- return Promise.reject(new SDKError_1.default(new Error("Document of length " + newDocumentData.length + " exceeds maximum allowed byte size of " + MAX_DOCUMENT_SIZE), Constants_1.ErrorCodes.DOCUMENT_MAX_SIZE_EXCEEDED));
254
+ return Promise.reject(new SDKError_1.default(new Error("Document of length ".concat(newDocumentData.length, " exceeds maximum allowed byte size of ").concat(MAX_DOCUMENT_SIZE)), Constants_1.ErrorCodes.DOCUMENT_MAX_SIZE_EXCEEDED));
249
255
  }
250
256
  var payload = {
251
257
  type: "DOCUMENT_STORE_UPDATE_DATA",
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteGroup = exports.removeSelfAsMember = exports.removeMembers = exports.addMembers = exports.removeAdmins = exports.addAdmins = exports.update = exports.rotatePrivateKey = exports.create = exports.get = exports.list = void 0;
3
4
  var FrameMediator = require("../FrameMediator");
4
5
  var ShimUtils = require("../ShimUtils");
5
6
  /**
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.transliterateString = exports.initializeBlindSearchIndex = exports.createBlindSearchIndex = void 0;
14
15
  var FrameMediator = require("../FrameMediator");
15
16
  var ShimUtils = require("../ShimUtils");
16
17
  /**
@@ -57,7 +58,7 @@ var InitializedSearchIndex = /** @class */ (function () {
57
58
  * Create a new blind search index and allow it to be decryptable by the provided group members. Creates and encrypts a new unmanaged
58
59
  * document which is returned to the caller to store.
59
60
  */
60
- exports.createBlindSearchIndex = function (groupId) {
61
+ var createBlindSearchIndex = function (groupId) {
61
62
  ShimUtils.checkSDKInitialized();
62
63
  ShimUtils.validateID(groupId);
63
64
  return FrameMediator.sendMessage({ type: "BLIND_SEARCH_INDEX_CREATE", message: { groupId: groupId } })
@@ -67,11 +68,12 @@ exports.createBlindSearchIndex = function (groupId) {
67
68
  })
68
69
  .toPromise();
69
70
  };
71
+ exports.createBlindSearchIndex = createBlindSearchIndex;
70
72
  /**
71
73
  * Initialize a blind search index using the fields returned from the createBlindSearchIndex method. Resolves with an instance of the
72
74
  * InitializedSearchIndex class which
73
75
  */
74
- exports.initializeBlindSearchIndex = function (index) {
76
+ var initializeBlindSearchIndex = function (index) {
75
77
  ShimUtils.checkSDKInitialized();
76
78
  ShimUtils.validateDocumentData(index.searchIndexEncryptedSalt);
77
79
  ShimUtils.validateDocumentData(index.searchIndexEdeks);
@@ -82,10 +84,11 @@ exports.initializeBlindSearchIndex = function (index) {
82
84
  })
83
85
  .toPromise();
84
86
  };
87
+ exports.initializeBlindSearchIndex = initializeBlindSearchIndex;
85
88
  /**
86
89
  * Transliterate the provided string by latinizing each character and removing all special characters.
87
90
  */
88
- exports.transliterateString = function (string) {
91
+ var transliterateString = function (string) {
89
92
  return FrameMediator.sendMessage({ type: "SEARCH_TRANSLITERATE_STRING", message: string })
90
93
  .map(function (_a) {
91
94
  var message = _a.message;
@@ -93,3 +96,4 @@ exports.transliterateString = function (string) {
93
96
  })
94
97
  .toPromise();
95
98
  };
99
+ exports.transliterateString = transliterateString;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listDevices = exports.deleteDeviceByPublicSigningKey = exports.deleteDevice = exports.deauthorizeDevice = exports.rotateMasterKey = exports.changePasscode = void 0;
3
4
  var ShimUtils_1 = require("../ShimUtils");
4
5
  var FrameMediator = require("../FrameMediator");
5
6
  /**
@@ -9,7 +10,7 @@ var FrameMediator = require("../FrameMediator");
9
10
  * @param {string} newPasscode New passcode
10
11
  */
11
12
  function changePasscode(currentPasscode, newPasscode) {
12
- ShimUtils_1.checkSDKInitialized();
13
+ (0, ShimUtils_1.checkSDKInitialized)();
13
14
  var payload = {
14
15
  type: "CHANGE_USER_PASSCODE",
15
16
  message: { currentPasscode: currentPasscode, newPasscode: newPasscode },
@@ -24,7 +25,7 @@ exports.changePasscode = changePasscode;
24
25
  * @param {string} passcode The users current passcode
25
26
  */
26
27
  function rotateMasterKey(passcode) {
27
- ShimUtils_1.checkSDKInitialized();
28
+ (0, ShimUtils_1.checkSDKInitialized)();
28
29
  var payload = {
29
30
  type: "ROTATE_USER_PRIVATE_KEY",
30
31
  message: { passcode: passcode },
@@ -35,24 +36,72 @@ function rotateMasterKey(passcode) {
35
36
  }
36
37
  exports.rotateMasterKey = rotateMasterKey;
37
38
  /**
39
+ * @deprecated Use deleteDevice with no arguments to get the same behavior.
38
40
  * Clears local device keys from the current browser instance. This will require the user to enter their passcode the next time they want to use this browser on this machine.
39
41
  * This method should usually be called whenever the current user logs out of your application.
40
42
  */
41
- function deauthorizeDevice() {
42
- ShimUtils_1.checkSDKInitialized();
43
+ var deauthorizeDevice = function () { return (0, exports.deleteDevice)().then(function (deletedDevice) { return ({ transformKeyDeleted: deletedDevice > 0 }); }); };
44
+ exports.deauthorizeDevice = deauthorizeDevice;
45
+ /**
46
+ * Deletes a device. If deleting the current device, the user will have to enter their passcode the next time they want to use this browser on this machine.
47
+ * This method should usually be called whenever the current user logs out of your application or you're aware a device of their's shouldn't have access.
48
+ * @param {number | undefined} deviceId The device id to delete. If undefined, the current device will be deleted and local storage will be cleared.
49
+ */
50
+ var deleteDevice = function (deviceId) {
51
+ (0, ShimUtils_1.checkSDKInitialized)();
52
+ var deletingCurrentDevice = deviceId === undefined;
43
53
  var payload = {
44
- type: "DEAUTHORIZE_DEVICE",
45
- message: null,
54
+ type: "DELETE_DEVICE",
55
+ message: deviceId,
46
56
  };
47
- //Clear the local symmetric key from local storage, then send a request to clear the frames local storage. Once that's complete clear the SDK init flag
48
- //so that the user has to rerun init before the SDK methods will work again.
49
- ShimUtils_1.clearParentWindowSymmetricKey();
57
+ // If current device, clear the local symmetric key from local storage, then send a request to clear the frames local storage.
58
+ // Once that's complete clear the SDK init flag so that the user has to rerun init before the SDK methods will work again.
59
+ if (deletingCurrentDevice) {
60
+ (0, ShimUtils_1.clearParentWindowSymmetricKey)();
61
+ }
50
62
  return FrameMediator.sendMessage(payload)
51
63
  .map(function (_a) {
52
64
  var message = _a.message;
53
- ShimUtils_1.clearSDKInitialized();
54
- return { transformKeyDeleted: message };
65
+ if (deletingCurrentDevice) {
66
+ (0, ShimUtils_1.clearSDKInitialized)();
67
+ }
68
+ return message;
55
69
  })
56
70
  .toPromise();
57
- }
58
- exports.deauthorizeDevice = deauthorizeDevice;
71
+ };
72
+ exports.deleteDevice = deleteDevice;
73
+ /**
74
+ * Deletes a device by its public signing key.
75
+ * @param {Base64String} publicSigningKey The public signing key of the device to delete.
76
+ */
77
+ var deleteDeviceByPublicSigningKey = function (publicSigningKey) {
78
+ (0, ShimUtils_1.checkSDKInitialized)();
79
+ var payload = {
80
+ type: "DELETE_DEVICE_BY_SIGNING_KEY",
81
+ message: publicSigningKey,
82
+ };
83
+ return FrameMediator.sendMessage(payload)
84
+ .map(function (_a) {
85
+ var message = _a.message;
86
+ return message;
87
+ })
88
+ .toPromise();
89
+ };
90
+ exports.deleteDeviceByPublicSigningKey = deleteDeviceByPublicSigningKey;
91
+ /**
92
+ * Lists all the devices for the currently logged in user.
93
+ */
94
+ var listDevices = function () {
95
+ (0, ShimUtils_1.checkSDKInitialized)();
96
+ var payload = {
97
+ type: "LIST_DEVICES",
98
+ message: null,
99
+ };
100
+ return FrameMediator.sendMessage(payload)
101
+ .map(function (_a) {
102
+ var result = _a.message;
103
+ return result;
104
+ })
105
+ .toPromise();
106
+ };
107
+ exports.listDevices = listDevices;
package/es/Constants.js CHANGED
@@ -14,7 +14,7 @@ export var CryptoConstants = {
14
14
  IV_LENGTH: 12,
15
15
  SALT_LENGTH: 32,
16
16
  AES_SYMMETRIC_KEY_LENGTH: 32,
17
- PBKDF2_ITERATIONS: function () { return 250000; },
17
+ PBKDF2_ITERATIONS: 250000,
18
18
  NATIVE_DECRYPT_FAILURE_ERROR: "OperationError",
19
19
  };
20
20
  export var ErrorCodes;
@@ -43,6 +43,7 @@ export var ErrorCodes;
43
43
  ErrorCodes[ErrorCodes["USER_DEVICE_DELETE_REQUEST_FAILURE"] = 210] = "USER_DEVICE_DELETE_REQUEST_FAILURE";
44
44
  ErrorCodes[ErrorCodes["USER_UPDATE_KEY_REQUEST_FAILURE"] = 211] = "USER_UPDATE_KEY_REQUEST_FAILURE";
45
45
  ErrorCodes[ErrorCodes["USER_PRIVATE_KEY_ROTATION_FAILURE"] = 212] = "USER_PRIVATE_KEY_ROTATION_FAILURE";
46
+ ErrorCodes[ErrorCodes["USER_DEVICE_LIST_REQUEST_FAILURE"] = 213] = "USER_DEVICE_LIST_REQUEST_FAILURE";
46
47
  ErrorCodes[ErrorCodes["DOCUMENT_LIST_REQUEST_FAILURE"] = 300] = "DOCUMENT_LIST_REQUEST_FAILURE";
47
48
  ErrorCodes[ErrorCodes["DOCUMENT_GET_REQUEST_FAILURE"] = 301] = "DOCUMENT_GET_REQUEST_FAILURE";
48
49
  ErrorCodes[ErrorCodes["DOCUMENT_CREATE_REQUEST_FAILURE"] = 302] = "DOCUMENT_CREATE_REQUEST_FAILURE";
@@ -108,5 +109,5 @@ export var UserAndGroupTypes = {
108
109
  };
109
110
  export var Versions = {
110
111
  //This define is replaced at runtime during development, and at build time in the build script with the proper version
111
- SDK_VERSION: "4.0.15",
112
+ SDK_VERSION: "4.1.1",
112
113
  };
@@ -2,10 +2,12 @@ var __extends = (this && this.__extends) || (function () {
2
2
  var extendStatics = function (d, b) {
3
3
  extendStatics = Object.setPrototypeOf ||
4
4
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
6
  return extendStatics(d, b);
7
7
  };
8
8
  return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
9
11
  extendStatics(d, b);
10
12
  function __() { this.constructor = d; }
11
13
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -84,7 +84,7 @@ frame.style.display = "none";
84
84
  frame.style.position = "absolute";
85
85
  frame.style.top = "-999px";
86
86
  frame.style.left = "-999px";
87
- frame.src = "" + Frame.FRAME_DOMAIN + Frame.FRAME_PATH + "?version=" + Versions.SDK_VERSION;
87
+ frame.src = "".concat(Frame.FRAME_DOMAIN).concat(Frame.FRAME_PATH, "?version=").concat(Versions.SDK_VERSION);
88
88
  window.document.body.appendChild(frame);
89
89
  /**
90
90
  * Return a simple Future wrapper around existing frame load Promise so that we wait until the iFrame has loaded before we post any messages to it. We
@@ -20,7 +20,7 @@ function getJWT(jwtCallback) {
20
20
  if (typeof jwt === "string" && jwt.length > 0) {
21
21
  return Future.of(jwt);
22
22
  }
23
- return Future.reject(new SDKError(new Error("JWT should be a non-zero length string, but instead got '" + jwt + "'"), ErrorCodes.JWT_RETRIEVAL_FAILURE));
23
+ return Future.reject(new SDKError(new Error("JWT should be a non-zero length string, but instead got '".concat(jwt, "'")), ErrorCodes.JWT_RETRIEVAL_FAILURE));
24
24
  });
25
25
  }
26
26
  /**
@@ -40,7 +40,7 @@ function invokePasscodeCallback(passcodeCallback, doesUserExist) {
40
40
  if (typeof passcode === "string" && passcode.length > 0) {
41
41
  return Future.of(passcode);
42
42
  }
43
- return Future.reject(new SDKError(new Error("User provided passcode should be a non-zero length string, but instead got '" + passcode + "'"), ErrorCodes.PASSCODE_RETRIEVAL_FAILURE));
43
+ return Future.reject(new SDKError(new Error("User provided passcode should be a non-zero length string, but instead got '".concat(passcode, "'")), ErrorCodes.PASSCODE_RETRIEVAL_FAILURE));
44
44
  });
45
45
  }
46
46
  /**
@@ -5,7 +5,7 @@ var hasInitializedSDK = false;
5
5
  * Generate parent window storage key that we'll use to store/retrieve the users symmetric key to decrypt their device/signing keys
6
6
  */
7
7
  function generateParentStorageKey() {
8
- return SECRET_KEY_LOCAL_STORAGE_VERSION + "-icldassk";
8
+ return "".concat(SECRET_KEY_LOCAL_STORAGE_VERSION, "-icldassk");
9
9
  }
10
10
  /**
11
11
  * Mark SDK initialization as complete to allow SDK methods to be run
@@ -93,10 +93,10 @@ export function validateOwnership(addAsAdmin, maybeOwner) {
93
93
  */
94
94
  export function validateID(id) {
95
95
  if (typeof id !== "string" || !id.length) {
96
- throw new Error("Invalid ID provided. Expected a non-zero length string but got " + id);
96
+ throw new Error("Invalid ID provided. Expected a non-zero length string but got ".concat(id));
97
97
  }
98
98
  if (!ALLOWED_ID_CHAR_REGEX.test(id)) {
99
- throw new Error("Invalid ID provided. Provided value includes invalid characters: '" + id + "'.");
99
+ throw new Error("Invalid ID provided. Provided value includes invalid characters: '".concat(id, "'."));
100
100
  }
101
101
  }
102
102
  /**