@ironcorelabs/ironweb 3.3.3 → 4.0.19

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;
@@ -80,6 +81,10 @@ var ErrorCodes;
80
81
  ErrorCodes[ErrorCodes["GROUP_ROTATE_PRIVATE_KEY_NOT_ADMIN_FAILURE"] = 418] = "GROUP_ROTATE_PRIVATE_KEY_NOT_ADMIN_FAILURE";
81
82
  ErrorCodes[ErrorCodes["REQUEST_RATE_LIMITED"] = 500] = "REQUEST_RATE_LIMITED";
82
83
  ErrorCodes[ErrorCodes["POLICY_APPLY_REQUEST_FAILURE"] = 600] = "POLICY_APPLY_REQUEST_FAILURE";
84
+ ErrorCodes[ErrorCodes["SEARCH_CREATE_INDEX_FAILURE"] = 700] = "SEARCH_CREATE_INDEX_FAILURE";
85
+ ErrorCodes[ErrorCodes["SEARCH_INIT_INDEX_FAILURE"] = 701] = "SEARCH_INIT_INDEX_FAILURE";
86
+ ErrorCodes[ErrorCodes["SEARCH_TOKENIZE_DATA_FAILURE"] = 702] = "SEARCH_TOKENIZE_DATA_FAILURE";
87
+ ErrorCodes[ErrorCodes["SEARCH_TOKENIZE_QUERY_FAILURE"] = 703] = "SEARCH_TOKENIZE_QUERY_FAILURE";
83
88
  })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
84
89
  /*
85
90
  * Constants around frame communication
@@ -106,5 +111,5 @@ exports.UserAndGroupTypes = {
106
111
  };
107
112
  exports.Versions = {
108
113
  //This define is replaced at runtime during development, and at build time in the build script with the proper version
109
- SDK_VERSION: "3.3.3",
114
+ SDK_VERSION: "4.0.19",
110
115
  };
@@ -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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var es6_promise_1 = require("es6-promise");
3
+ exports.sendMessage = exports.messenger = exports.ShimMessenger = void 0;
4
4
  var futurejs_1 = require("futurejs");
5
5
  var Constants_1 = require("../Constants");
6
6
  var SDKError_1 = require("../lib/SDKError");
@@ -67,7 +67,7 @@ exports.ShimMessenger = ShimMessenger;
67
67
  */
68
68
  var frame = window.document.createElement("iframe");
69
69
  exports.messenger = new ShimMessenger(frame);
70
- var frameLoadedPromise = new es6_promise_1.Promise(function (resolve, reject) {
70
+ var frameLoadedPromise = new Promise(function (resolve, reject) {
71
71
  //The frame "load" even fires even if the frame failed to load (e.g. 404). So once it loads, we want to verify that it is actually
72
72
  //responding to messages we pass it. So pass a test message and verify we get a response within a second. If it does, we resolve
73
73
  //this Promise for all future messages. If it fails we reject with the appropriate SDK error message.
@@ -87,7 +87,7 @@ frame.style.display = "none";
87
87
  frame.style.position = "absolute";
88
88
  frame.style.top = "-999px";
89
89
  frame.style.left = "-999px";
90
- 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);
91
91
  window.document.body.appendChild(frame);
92
92
  /**
93
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,12 +1,15 @@
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;
4
+ var CodecSDK = require("./sdk/CodecSDK");
3
5
  var DocumentSDK = require("./sdk/DocumentSDK");
4
6
  var GroupSDK = require("./sdk/GroupSDK");
7
+ var SearchSDK = require("./sdk/SearchSDK");
5
8
  var UserSDK = require("./sdk/UserSDK");
6
- var CodecSDK = require("./sdk/CodecSDK");
7
9
  // https://github.com/Microsoft/TypeScript/issues/420
8
10
  // whenever this lands in TS we can get stronger compiler checking of our API <-> API Interface definition.
9
11
  exports.document = DocumentSDK;
10
12
  exports.user = UserSDK;
11
13
  exports.group = GroupSDK;
14
+ exports.search = SearchSDK;
12
15
  exports.codec = CodecSDK;
@@ -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");
@@ -11,7 +23,7 @@ var ShimUtils_1 = require("./ShimUtils");
11
23
  * Checks bowser functionality to ensure random number generation is supported.
12
24
  */
13
25
  function supportsRandomNumGen() {
14
- var nativeCrypto = window.msCrypto || window.crypto;
26
+ var nativeCrypto = window.crypto;
15
27
  return typeof nativeCrypto === "object" && typeof nativeCrypto.getRandomValues === "function";
16
28
  }
17
29
  /**
@@ -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
  };
@@ -1,5 +1,22 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
2
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;
3
20
  var futurejs_1 = require("futurejs");
4
21
  var Constants_1 = require("../../Constants");
5
22
  var SDKError_1 = require("../../lib/SDKError");
@@ -14,8 +31,8 @@ var MAX_DOCUMENT_SIZE = 1024 * 2 * 1000; //2MB
14
31
  */
15
32
  function calculateDocumentCreateOptionsDefault(options) {
16
33
  //Generate a random ID for the document if the user didn't provide one
17
- var randomBytes = (window.msCrypto || window.crypto).getRandomValues(new Uint8Array(16));
18
- var hexID = Array.prototype.map.call(randomBytes, function (byte) { return ("00" + byte.toString(16)).slice(-2); }).join("");
34
+ var randomBytes = window.crypto.getRandomValues(new Uint8Array(16));
35
+ var hexID = Array.prototype.map.call(randomBytes, function (byte) { return "00".concat(byte.toString(16)).slice(-2); }).join("");
19
36
  if (!options) {
20
37
  return { documentID: hexID, documentName: "", accessList: { users: [], groups: [], grantToAuthor: true } };
21
38
  }
@@ -91,10 +108,12 @@ function getDocumentIDFromBytes(documentData) {
91
108
  }
92
109
  exports.getDocumentIDFromBytes = getDocumentIDFromBytes;
93
110
  /**
111
+ * @deprecated Use `decrypt` instead.
94
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.
95
113
  * @param {string} documentID ID of the document to retrieve
96
114
  */
97
115
  function decryptFromStore(documentID) {
116
+ console.warn("decryptFromStore is deprecated. Use decrypt instead.");
98
117
  ShimUtils.checkSDKInitialized();
99
118
  ShimUtils.validateID(documentID);
100
119
  var payload = {
@@ -136,6 +155,7 @@ function decrypt(documentID, documentData) {
136
155
  }
137
156
  exports.decrypt = decrypt;
138
157
  /**
158
+ * @deprecated Use `encrypt` instead and manage storage of the result yourself.
139
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.
140
160
  * @param {Uint8Array} documentData Data to save for document
141
161
  * @param {DocumentCreateOptions} options Document create options. Includes:
@@ -148,16 +168,17 @@ exports.decrypt = decrypt;
148
168
  * grantToAuthor: boolean - Should the create grant access to the logged in user. Defaults to true.
149
169
  */
150
170
  function encryptToStore(documentData, options) {
171
+ console.warn("encryptToStore is deprecated. Use encrypt instead and manage storage of the result yourself.");
151
172
  ShimUtils.checkSDKInitialized();
152
173
  ShimUtils.validateDocumentData(documentData);
153
174
  if (documentData.length > MAX_DOCUMENT_SIZE) {
154
- 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));
155
176
  }
156
177
  var encryptOptions = calculateDocumentCreateOptionsDefault(options);
157
178
  if (encryptOptions.documentID) {
158
179
  ShimUtils.validateID(encryptOptions.documentID);
159
180
  }
160
- var _a = ShimUtils.dedupeAccessLists(encryptOptions.accessList), userGrants = _a[0], groupGrants = _a[1];
181
+ var _a = __read(ShimUtils.dedupeAccessLists(encryptOptions.accessList), 2), userGrants = _a[0], groupGrants = _a[1];
161
182
  var payload = {
162
183
  type: "DOCUMENT_STORE_ENCRYPT",
163
184
  message: {
@@ -198,7 +219,7 @@ function encrypt(documentData, options) {
198
219
  if (encryptOptions.documentID) {
199
220
  ShimUtils.validateID(encryptOptions.documentID);
200
221
  }
201
- var _a = ShimUtils.dedupeAccessLists(encryptOptions.accessList), userGrants = _a[0], groupGrants = _a[1];
222
+ var _a = __read(ShimUtils.dedupeAccessLists(encryptOptions.accessList), 2), userGrants = _a[0], groupGrants = _a[1];
202
223
  var payload = {
203
224
  type: "DOCUMENT_ENCRYPT",
204
225
  message: {
@@ -229,7 +250,7 @@ function updateEncryptedDataInStore(documentID, newDocumentData) {
229
250
  ShimUtils.validateID(documentID);
230
251
  ShimUtils.validateDocumentData(newDocumentData);
231
252
  if (newDocumentData.length > MAX_DOCUMENT_SIZE) {
232
- 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));
253
+ 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));
233
254
  }
234
255
  var payload = {
235
256
  type: "DOCUMENT_STORE_UPDATE_DATA",
@@ -303,7 +324,7 @@ function grantAccess(documentID, grantList) {
303
324
  ShimUtils.checkSDKInitialized();
304
325
  ShimUtils.validateID(documentID);
305
326
  ShimUtils.validateAccessList(grantList);
306
- var _a = ShimUtils.dedupeAccessLists(grantList), userGrants = _a[0], groupGrants = _a[1];
327
+ var _a = __read(ShimUtils.dedupeAccessLists(grantList), 2), userGrants = _a[0], groupGrants = _a[1];
307
328
  var payload = {
308
329
  type: "DOCUMENT_GRANT",
309
330
  message: {
@@ -330,7 +351,7 @@ function revokeAccess(documentID, revokeList) {
330
351
  ShimUtils.checkSDKInitialized();
331
352
  ShimUtils.validateID(documentID);
332
353
  ShimUtils.validateAccessList(revokeList);
333
- var _a = ShimUtils.dedupeAccessLists(revokeList), userRevocations = _a[0], groupRevocations = _a[1];
354
+ var _a = __read(ShimUtils.dedupeAccessLists(revokeList), 2), userRevocations = _a[0], groupRevocations = _a[1];
334
355
  var payload = {
335
356
  type: "DOCUMENT_REVOKE",
336
357
  message: {
@@ -395,7 +416,7 @@ exports.advanced = {
395
416
  if (encryptOptions.documentID) {
396
417
  ShimUtils.validateID(encryptOptions.documentID);
397
418
  }
398
- var _a = ShimUtils.dedupeAccessLists(encryptOptions.accessList), userGrants = _a[0], groupGrants = _a[1];
419
+ var _a = __read(ShimUtils.dedupeAccessLists(encryptOptions.accessList), 2), userGrants = _a[0], groupGrants = _a[1];
399
420
  var payload = {
400
421
  type: "DOCUMENT_UNMANAGED_ENCRYPT",
401
422
  message: {
@@ -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
  /**
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.transliterateString = exports.initializeBlindSearchIndex = exports.createBlindSearchIndex = void 0;
15
+ var FrameMediator = require("../FrameMediator");
16
+ var ShimUtils = require("../ShimUtils");
17
+ /**
18
+ * Class that is used to represent an initialized search index. Holds the search index ID (which is just a random ID used in the
19
+ * frames decrypted salt in-memory cache) so it can pass that down to the frame when tokenizing data.
20
+ */
21
+ var InitializedSearchIndex = /** @class */ (function () {
22
+ function InitializedSearchIndex(searchIndexId) {
23
+ this.searchIndexId = searchIndexId;
24
+ }
25
+ InitializedSearchIndex.prototype.tokenizeData = function (data, partitionId) {
26
+ return FrameMediator.sendMessage({
27
+ type: "BLIND_SEARCH_INDEX_TOKENIZE_DATA",
28
+ message: {
29
+ data: data,
30
+ partitionId: partitionId,
31
+ searchIndexId: this.searchIndexId,
32
+ },
33
+ })
34
+ .map(function (_a) {
35
+ var message = _a.message;
36
+ return message;
37
+ })
38
+ .toPromise();
39
+ };
40
+ InitializedSearchIndex.prototype.tokenizeQuery = function (query, partitionId) {
41
+ return FrameMediator.sendMessage({
42
+ type: "BLIND_SEARCH_INDEX_TOKENIZE_QUERY",
43
+ message: {
44
+ query: query,
45
+ partitionId: partitionId,
46
+ searchIndexId: this.searchIndexId,
47
+ },
48
+ })
49
+ .map(function (_a) {
50
+ var message = _a.message;
51
+ return message;
52
+ })
53
+ .toPromise();
54
+ };
55
+ return InitializedSearchIndex;
56
+ }());
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
59
+ * document which is returned to the caller to store.
60
+ */
61
+ var createBlindSearchIndex = function (groupId) {
62
+ ShimUtils.checkSDKInitialized();
63
+ ShimUtils.validateID(groupId);
64
+ return FrameMediator.sendMessage({ type: "BLIND_SEARCH_INDEX_CREATE", message: { groupId: groupId } })
65
+ .map(function (_a) {
66
+ var message = _a.message;
67
+ return message;
68
+ })
69
+ .toPromise();
70
+ };
71
+ exports.createBlindSearchIndex = createBlindSearchIndex;
72
+ /**
73
+ * Initialize a blind search index using the fields returned from the createBlindSearchIndex method. Resolves with an instance of the
74
+ * InitializedSearchIndex class which
75
+ */
76
+ var initializeBlindSearchIndex = function (index) {
77
+ ShimUtils.checkSDKInitialized();
78
+ ShimUtils.validateDocumentData(index.searchIndexEncryptedSalt);
79
+ ShimUtils.validateDocumentData(index.searchIndexEdeks);
80
+ return FrameMediator.sendMessage({ type: "BLIND_SEARCH_INDEX_INIT", message: __assign({}, index) })
81
+ .map(function (_a) {
82
+ var message = _a.message;
83
+ return new InitializedSearchIndex(message.searchIndexId);
84
+ })
85
+ .toPromise();
86
+ };
87
+ exports.initializeBlindSearchIndex = initializeBlindSearchIndex;
88
+ /**
89
+ * Transliterate the provided string by latinizing each character and removing all special characters.
90
+ */
91
+ var transliterateString = function (string) {
92
+ return FrameMediator.sendMessage({ type: "SEARCH_TRANSLITERATE_STRING", message: string })
93
+ .map(function (_a) {
94
+ var message = _a.message;
95
+ return message;
96
+ })
97
+ .toPromise();
98
+ };
99
+ exports.transliterateString = transliterateString;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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 },
@@ -39,18 +40,18 @@ exports.rotateMasterKey = rotateMasterKey;
39
40
  * This method should usually be called whenever the current user logs out of your application.
40
41
  */
41
42
  function deauthorizeDevice() {
42
- ShimUtils_1.checkSDKInitialized();
43
+ (0, ShimUtils_1.checkSDKInitialized)();
43
44
  var payload = {
44
45
  type: "DEAUTHORIZE_DEVICE",
45
46
  message: null,
46
47
  };
47
48
  //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
49
  //so that the user has to rerun init before the SDK methods will work again.
49
- ShimUtils_1.clearParentWindowSymmetricKey();
50
+ (0, ShimUtils_1.clearParentWindowSymmetricKey)();
50
51
  return FrameMediator.sendMessage(payload)
51
52
  .map(function (_a) {
52
53
  var message = _a.message;
53
- ShimUtils_1.clearSDKInitialized();
54
+ (0, ShimUtils_1.clearSDKInitialized)();
54
55
  return { transformKeyDeleted: message };
55
56
  })
56
57
  .toPromise();
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;
@@ -78,6 +78,10 @@ export var ErrorCodes;
78
78
  ErrorCodes[ErrorCodes["GROUP_ROTATE_PRIVATE_KEY_NOT_ADMIN_FAILURE"] = 418] = "GROUP_ROTATE_PRIVATE_KEY_NOT_ADMIN_FAILURE";
79
79
  ErrorCodes[ErrorCodes["REQUEST_RATE_LIMITED"] = 500] = "REQUEST_RATE_LIMITED";
80
80
  ErrorCodes[ErrorCodes["POLICY_APPLY_REQUEST_FAILURE"] = 600] = "POLICY_APPLY_REQUEST_FAILURE";
81
+ ErrorCodes[ErrorCodes["SEARCH_CREATE_INDEX_FAILURE"] = 700] = "SEARCH_CREATE_INDEX_FAILURE";
82
+ ErrorCodes[ErrorCodes["SEARCH_INIT_INDEX_FAILURE"] = 701] = "SEARCH_INIT_INDEX_FAILURE";
83
+ ErrorCodes[ErrorCodes["SEARCH_TOKENIZE_DATA_FAILURE"] = 702] = "SEARCH_TOKENIZE_DATA_FAILURE";
84
+ ErrorCodes[ErrorCodes["SEARCH_TOKENIZE_QUERY_FAILURE"] = 703] = "SEARCH_TOKENIZE_QUERY_FAILURE";
81
85
  })(ErrorCodes || (ErrorCodes = {}));
82
86
  /*
83
87
  * Constants around frame communication
@@ -104,5 +108,5 @@ export var UserAndGroupTypes = {
104
108
  };
105
109
  export var Versions = {
106
110
  //This define is replaced at runtime during development, and at build time in the build script with the proper version
107
- SDK_VERSION: "3.3.3",
111
+ SDK_VERSION: "4.0.19",
108
112
  };