diff --git a/dist/autofill-debug.js b/dist/autofill-debug.js index 6cad1f558..4d7388a9c 100644 --- a/dist/autofill-debug.js +++ b/dist/autofill-debug.js @@ -55,796 +55,437 @@ function processConfig(data, userList, preferences) { Object.defineProperty(exports, "__esModule", { value: true }); -var _messaging = require("./messaging.js"); -Object.keys(_messaging).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _messaging[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _messaging[key]; +exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0; +const util_1 = require("./helpers/util"); +exports.ZodIssueCode = util_1.util.arrayToEnum(["invalid_type", "invalid_literal", "custom", "invalid_union", "invalid_union_discriminator", "invalid_enum_value", "unrecognized_keys", "invalid_arguments", "invalid_return_type", "invalid_date", "invalid_string", "too_small", "too_big", "invalid_intersection_types", "not_multiple_of", "not_finite"]); +const quotelessJson = obj => { + const json = JSON.stringify(obj, null, 2); + return json.replace(/"([^"]+)":/g, "$1:"); +}; +exports.quotelessJson = quotelessJson; +class ZodError extends Error { + constructor(issues) { + var _this; + super(); + _this = this; + this.issues = []; + this.addIssue = sub => { + this.issues = [...this.issues, sub]; + }; + this.addIssues = function () { + let subs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + _this.issues = [..._this.issues, ...subs]; + }; + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } else { + this.__proto__ = actualProto; } - }); -}); - -},{"./messaging.js":3}],3:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.MissingHandler = exports.MessagingTransport = exports.Messaging = void 0; -Object.defineProperty(exports, "WebkitMessagingConfig", { - enumerable: true, - get: function () { - return _webkit.WebkitMessagingConfig; - } -}); -Object.defineProperty(exports, "WindowsMessagingConfig", { - enumerable: true, - get: function () { - return _windows.WindowsMessagingConfig; - } -}); -var _windows = require("./messaging/windows.js"); -var _webkit = require("./messaging/webkit.js"); -/** - * @module Messaging - * - * @description - * - * An abstraction for communications between JavaScript and host platforms. - * - * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) - * 2) Then use that to get an instance of the Messaging utility which allows - * you to send and receive data in a unified way - * 3) Each platform implements {@link MessagingTransport} along with its own Configuration - * - For example, to learn what configuration is required for Webkit, see: {@link "Webkit Messaging".WebkitMessagingConfig} - * - Or, to learn about how messages are sent and received in Webkit, see {@link "Webkit Messaging".WebkitMessagingTransport} - * - * @example Webkit Messaging - * - * ```js - * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // This config would be injected into the UserScript - * const injectedConfig = { - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }; - * - * // Then use that config to construct platform-specific configuration - * const config = new WebkitMessagingConfig(injectedConfig); - * - * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 - * const messaging = new Messaging(config); - * messaging.notify("hello world!", {foo: "bar"}) - * - * ``` - * - * @example Windows Messaging - * - * ```js - * import { Messaging, WindowsMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // Messaging on Windows is namespaced, so you can create multiple messaging instances - * const autofillConfig = new WindowsMessagingConfig({ featureName: "Autofill" }); - * const debugConfig = new WindowsMessagingConfig({ featureName: "Debugging" }); - * - * const autofillMessaging = new Messaging(autofillConfig); - * const debugMessaging = new Messaging(debugConfig); - * - * // Now send messages to both features as needed 🚀 - * autofillMessaging.notify("storeFormData", { "username": "dax" }) - * debugMessaging.notify("pageLoad", { time: window.performance.now() }) - * ``` - */ - -/** - * @implements {MessagingTransport} - */ -class Messaging { - /** - * @param {WebkitMessagingConfig | WindowsMessagingConfig} config - */ - constructor(config) { - this.transport = getTransport(config); + this.name = "ZodError"; + this.issues = issues; } - /** - * Send a 'fire-and-forget' message. - * @throws - * {@link MissingHandler} - * - * @example - * - * ``` - * const messaging = new Messaging(config) - * messaging.notify("foo", {bar: "baz"}) - * ``` - * @param {string} name - * @param {Record} [data] - */ - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - this.transport.notify(name, data); + get errors() { + return this.issues; } - /** - * Send a request, and wait for a response - * @throws - * {@link MissingHandler} - * - * @example - * ``` - * const messaging = new Messaging(config) - * const response = await messaging.request("foo", {bar: "baz"}) - * ``` - * - * @param {string} name - * @param {Record} [data] - * @return {Promise} - */ - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - return this.transport.request(name, data); + format(_mapper) { + const mapper = _mapper || function (issue) { + return issue.message; + }; + const fieldErrors = { + _errors: [] + }; + const processError = error => { + for (const issue of error.issues) { + if (issue.code === "invalid_union") { + issue.unionErrors.map(processError); + } else if (issue.code === "invalid_return_type") { + processError(issue.returnTypeError); + } else if (issue.code === "invalid_arguments") { + processError(issue.argumentsError); + } else if (issue.path.length === 0) { + fieldErrors._errors.push(mapper(issue)); + } else { + let curr = fieldErrors; + let i = 0; + while (i < issue.path.length) { + const el = issue.path[i]; + const terminal = i === issue.path.length - 1; + if (!terminal) { + curr[el] = curr[el] || { + _errors: [] + }; + } else { + curr[el] = curr[el] || { + _errors: [] + }; + curr[el]._errors.push(mapper(issue)); + } + curr = curr[el]; + i++; + } + } + } + }; + processError(this); + return fieldErrors; } -} - -/** - * @interface - */ -exports.Messaging = Messaging; -class MessagingTransport { - /** - * @param {string} name - * @param {Record} [data] - * @returns {void} - */ - // @ts-ignore - ignoring a no-unused ts error, this is only an interface. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error("must implement 'notify'"); + toString() { + return this.message; } - /** - * @param {string} name - * @param {Record} [data] - * @return {Promise} - */ - // @ts-ignore - ignoring a no-unused ts error, this is only an interface. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error('must implement'); + get message() { + return JSON.stringify(this.issues, util_1.util.jsonStringifyReplacer, 2); } -} - -/** - * @param {WebkitMessagingConfig | WindowsMessagingConfig} config - * @returns {MessagingTransport} - */ -exports.MessagingTransport = MessagingTransport; -function getTransport(config) { - if (config instanceof _webkit.WebkitMessagingConfig) { - return new _webkit.WebkitMessagingTransport(config); + get isEmpty() { + return this.issues.length === 0; } - if (config instanceof _windows.WindowsMessagingConfig) { - return new _windows.WindowsMessagingTransport(config); + flatten() { + let mapper = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : issue => issue.message; + const fieldErrors = {}; + const formErrors = []; + for (const sub of this.issues) { + if (sub.path.length > 0) { + fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; + fieldErrors[sub.path[0]].push(mapper(sub)); + } else { + formErrors.push(mapper(sub)); + } + } + return { + formErrors, + fieldErrors + }; } - throw new Error('unreachable'); -} - -/** - * Thrown when a handler cannot be found - */ -class MissingHandler extends Error { - /** - * @param {string} message - * @param {string} handlerName - */ - constructor(message, handlerName) { - super(message); - this.handlerName = handlerName; + get formErrors() { + return this.flatten(); } } +exports.ZodError = ZodError; +ZodError.create = issues => { + const error = new ZodError(issues); + return error; +}; -/** - * Some re-exports for convenience - */ -exports.MissingHandler = MissingHandler; - -},{"./messaging/webkit.js":4,"./messaging/windows.js":5}],4:[function(require,module,exports){ +},{"./helpers/util":8}],3:[function(require,module,exports){ "use strict"; -Object.defineProperty(exports, "__esModule", { +var __importDefault = void 0 && (void 0).__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebkitMessagingTransport = exports.WebkitMessagingConfig = exports.SecureMessagingParams = void 0; -var _messaging = require("../messaging.js"); -/** - * @module Webkit Messaging - * - * @description - * - * A wrapper for messaging on WebKit platforms. It supports modern WebKit messageHandlers - * along with encryption for older versions (like macOS Catalina) - * - * Note: If you wish to support Catalina then you'll need to implement the native - * part of the message handling, see {@link WebkitMessagingTransport} for details. - * - * ```js - * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // This config would be injected into the UserScript - * const injectedConfig = { - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }; - * - * // Then use that config to construct platform-specific configuration - * const config = new WebkitMessagingConfig(injectedConfig); - * - * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 - * const messaging = new Messaging(config); - * messaging.notify("hello world!", {foo: "bar"}) - * - * ``` - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars +exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = void 0; +const en_1 = __importDefault(require("./locales/en")); +exports.defaultErrorMap = en_1.default; +let overrideErrorMap = en_1.default; +function setErrorMap(map) { + overrideErrorMap = map; +} +exports.setErrorMap = setErrorMap; +function getErrorMap() { + return overrideErrorMap; +} +exports.getErrorMap = getErrorMap; -/** - * @example - * On macOS 11+, this will just call through to `window.webkit.messageHandlers.x.postMessage` - * - * Eg: for a `foo` message defined in Swift that accepted the payload `{"bar": "baz"}`, the following - * would occur: - * - * ```js - * const json = await window.webkit.messageHandlers.foo.postMessage({ bar: "baz" }); - * const response = JSON.parse(json) - * ``` - * - * @example - * On macOS 10 however, the process is a little more involved. A method will be appended to `window` - * that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow - * as being something along the lines of: - * - * ```js - * // add the window method - * window["_0123456"] = (response) => { - * // decrypt `response` and deliver the result to the caller here - * // then remove the temporary method - * delete window["_0123456"] - * }; - * - * // send the data + `messageHanding` values - * window.webkit.messageHandlers.foo.postMessage({ - * bar: "baz", - * messagingHandling: { - * methodName: "_0123456", - * secret: "super-secret", - * key: [1, 2, 45, 2], - * iv: [34, 4, 43], - * } - * }); - * - * // later in swift, the following JavaScript snippet will be executed - * (() => { - * window["_0123456"]({ - * ciphertext: [12, 13, 4], - * tag: [3, 5, 67, 56] - * }) - * })() - * ``` - * @implements {MessagingTransport} - */ -class WebkitMessagingTransport { - /** @type {WebkitMessagingConfig} */ - config; - globals; - /** - * @param {WebkitMessagingConfig} config - */ - constructor(config) { - this.config = config; - this.globals = captureGlobals(); - if (!this.config.hasModernWebkitAPI) { - this.captureWebkitHandlers(this.config.webkitMessageHandlerNames); +},{"./locales/en":10}],4:[function(require,module,exports){ +"use strict"; + +var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { + enumerable: true, + get: function () { + return m[k]; } + }); +} : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); +var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { + value: true +}); +__exportStar(require("./errors"), exports); +__exportStar(require("./helpers/parseUtil"), exports); +__exportStar(require("./helpers/typeAliases"), exports); +__exportStar(require("./helpers/util"), exports); +__exportStar(require("./types"), exports); +__exportStar(require("./ZodError"), exports); + +},{"./ZodError":2,"./errors":3,"./helpers/parseUtil":6,"./helpers/typeAliases":7,"./helpers/util":8,"./types":11}],5:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.errorUtil = void 0; +var errorUtil; +(function (errorUtil) { + errorUtil.errToObj = message => typeof message === "string" ? { + message + } : message || {}; + errorUtil.toString = message => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; +})(errorUtil = exports.errorUtil || (exports.errorUtil = {})); + +},{}],6:[function(require,module,exports){ +"use strict"; + +var __importDefault = void 0 && (void 0).__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0; +const errors_1 = require("../errors"); +const en_1 = __importDefault(require("../locales/en")); +const makeIssue = params => { + const { + data, + path, + errorMaps, + issueData + } = params; + const fullPath = [...path, ...(issueData.path || [])]; + const fullIssue = { + ...issueData, + path: fullPath + }; + let errorMessage = ""; + const maps = errorMaps.filter(m => !!m).slice().reverse(); + for (const map of maps) { + errorMessage = map(fullIssue, { + data, + defaultError: errorMessage + }).message; } - /** - * Sends message to the webkit layer (fire and forget) - * @param {String} handler - * @param {*} data - * @internal - */ - wkSend(handler) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (!(handler in this.globals.window.webkit.messageHandlers)) { - throw new _messaging.MissingHandler(`Missing webkit handler: '${handler}'`, handler); + return { + ...issueData, + path: fullPath, + message: issueData.message || errorMessage + }; +}; +exports.makeIssue = makeIssue; +exports.EMPTY_PATH = []; +function addIssueToContext(ctx, issueData) { + const issue = (0, exports.makeIssue)({ + issueData: issueData, + data: ctx.data, + path: ctx.path, + errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, (0, errors_1.getErrorMap)(), en_1.default].filter(x => !!x) + }); + ctx.common.issues.push(issue); +} +exports.addIssueToContext = addIssueToContext; +class ParseStatus { + constructor() { + this.value = "valid"; + } + dirty() { + if (this.value === "valid") this.value = "dirty"; + } + abort() { + if (this.value !== "aborted") this.value = "aborted"; + } + static mergeArray(status, results) { + const arrayValue = []; + for (const s of results) { + if (s.status === "aborted") return exports.INVALID; + if (s.status === "dirty") status.dirty(); + arrayValue.push(s.value); } - const outgoing = { - ...data, - messageHandling: { - ...data.messageHandling, - secret: this.config.secret - } + return { + status: status.value, + value: arrayValue }; - if (!this.config.hasModernWebkitAPI) { - if (!(handler in this.globals.capturedWebkitHandlers)) { - throw new _messaging.MissingHandler(`cannot continue, method ${handler} not captured on macos < 11`, handler); - } else { - return this.globals.capturedWebkitHandlers[handler](outgoing); - } - } - return this.globals.window.webkit.messageHandlers[handler].postMessage?.(outgoing); } - - /** - * Sends message to the webkit layer and waits for the specified response - * @param {String} handler - * @param {*} data - * @returns {Promise<*>} - * @internal - */ - async wkSendAndWait(handler) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (this.config.hasModernWebkitAPI) { - const response = await this.wkSend(handler, data); - return this.globals.JSONparse(response || '{}'); + static async mergeObjectAsync(status, pairs) { + const syncPairs = []; + for (const pair of pairs) { + syncPairs.push({ + key: await pair.key, + value: await pair.value + }); } - try { - const randMethodName = this.createRandMethodName(); - const key = await this.createRandKey(); - const iv = this.createRandIv(); - const { - ciphertext, - tag - } = await new this.globals.Promise(( /** @type {any} */resolve) => { - this.generateRandomMethod(randMethodName, resolve); - data.messageHandling = new SecureMessagingParams({ - methodName: randMethodName, - secret: this.config.secret, - key: this.globals.Arrayfrom(key), - iv: this.globals.Arrayfrom(iv) - }); - this.wkSend(handler, data); - }); - const cipher = new this.globals.Uint8Array([...ciphertext, ...tag]); - const decrypted = await this.decrypt(cipher, key, iv); - return this.globals.JSONparse(decrypted || '{}'); - } catch (e) { - // re-throw when the error is just a 'MissingHandler' - if (e instanceof _messaging.MissingHandler) { - throw e; - } else { - console.error('decryption failed', e); - console.error(e); - return { - error: e - }; - } - } - } - /** - * @param {string} name - * @param {Record} [data] - */ - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - this.wkSend(name, data); - } - /** - * @param {string} name - * @param {Record} [data] - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - return this.wkSendAndWait(name, data); - } - /** - * Generate a random method name and adds it to the global scope - * The native layer will use this method to send the response - * @param {string | number} randomMethodName - * @param {Function} callback - */ - generateRandomMethod(randomMethodName, callback) { - var _this = this; - this.globals.ObjectDefineProperty(this.globals.window, randomMethodName, { - enumerable: false, - // configurable, To allow for deletion later - configurable: true, - writable: false, - /** - * @param {any[]} args - */ - value: function () { - callback(...arguments); - // @ts-ignore - we want this to throw if it fails as it would indicate a fatal error. - delete _this.globals.window[randomMethodName]; - } - }); - } - randomString() { - return '' + this.globals.getRandomValues(new this.globals.Uint32Array(1))[0]; - } - createRandMethodName() { - return '_' + this.randomString(); - } - - /** - * @type {{name: string, length: number}} - */ - algoObj = { - name: 'AES-GCM', - length: 256 - }; - - /** - * @returns {Promise} - */ - async createRandKey() { - const key = await this.globals.generateKey(this.algoObj, true, ['encrypt', 'decrypt']); - const exportedKey = await this.globals.exportKey('raw', key); - return new this.globals.Uint8Array(exportedKey); - } - - /** - * @returns {Uint8Array} - */ - createRandIv() { - return this.globals.getRandomValues(new this.globals.Uint8Array(12)); - } - - /** - * @param {BufferSource} ciphertext - * @param {BufferSource} key - * @param {Uint8Array} iv - * @returns {Promise} - */ - async decrypt(ciphertext, key, iv) { - const cryptoKey = await this.globals.importKey('raw', key, 'AES-GCM', false, ['decrypt']); - const algo = { - name: 'AES-GCM', - iv - }; - let decrypted = await this.globals.decrypt(algo, cryptoKey, ciphertext); - let dec = new this.globals.TextDecoder(); - return dec.decode(decrypted); + return ParseStatus.mergeObjectSync(status, syncPairs); } - - /** - * When required (such as on macos 10.x), capture the `postMessage` method on - * each webkit messageHandler - * - * @param {string[]} handlerNames - */ - captureWebkitHandlers(handlerNames) { - const handlers = window.webkit.messageHandlers; - if (!handlers) throw new _messaging.MissingHandler('window.webkit.messageHandlers was absent', 'all'); - for (let webkitMessageHandlerName of handlerNames) { - if (typeof handlers[webkitMessageHandlerName]?.postMessage === 'function') { - /** - * `bind` is used here to ensure future calls to the captured - * `postMessage` have the correct `this` context - */ - const original = handlers[webkitMessageHandlerName]; - const bound = handlers[webkitMessageHandlerName].postMessage?.bind(original); - this.globals.capturedWebkitHandlers[webkitMessageHandlerName] = bound; - delete handlers[webkitMessageHandlerName].postMessage; + static mergeObjectSync(status, pairs) { + const finalObject = {}; + for (const pair of pairs) { + const { + key, + value + } = pair; + if (key.status === "aborted") return exports.INVALID; + if (value.status === "aborted") return exports.INVALID; + if (key.status === "dirty") status.dirty(); + if (value.status === "dirty") status.dirty(); + if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) { + finalObject[key.value] = value.value; } } + return { + status: status.value, + value: finalObject + }; } } +exports.ParseStatus = ParseStatus; +exports.INVALID = Object.freeze({ + status: "aborted" +}); +const DIRTY = value => ({ + status: "dirty", + value +}); +exports.DIRTY = DIRTY; +const OK = value => ({ + status: "valid", + value +}); +exports.OK = OK; +const isAborted = x => x.status === "aborted"; +exports.isAborted = isAborted; +const isDirty = x => x.status === "dirty"; +exports.isDirty = isDirty; +const isValid = x => x.status === "valid"; +exports.isValid = isValid; +const isAsync = x => typeof Promise !== "undefined" && x instanceof Promise; +exports.isAsync = isAsync; -/** - * Use this configuration to create an instance of {@link Messaging} for WebKit - * - * ```js - * import { fromConfig, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * const config = new WebkitMessagingConfig({ - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }); - * - * const messaging = new Messaging(config) - * const resp = await messaging.request("debugConfig") - * ``` - */ -exports.WebkitMessagingTransport = WebkitMessagingTransport; -class WebkitMessagingConfig { - /** - * @param {object} params - * @param {boolean} params.hasModernWebkitAPI - * @param {string[]} params.webkitMessageHandlerNames - * @param {string} params.secret - */ - constructor(params) { - /** - * Whether or not the current WebKit Platform supports secure messaging - * by default (eg: macOS 11+) - */ - this.hasModernWebkitAPI = params.hasModernWebkitAPI; - /** - * A list of WebKit message handler names that a user script can send - */ - this.webkitMessageHandlerNames = params.webkitMessageHandlerNames; - /** - * A string provided by native platforms to be sent with future outgoing - * messages - */ - this.secret = params.secret; - } -} - -/** - * This is the additional payload that gets appended to outgoing messages. - * It's used in the Swift side to encrypt the response that comes back - */ -exports.WebkitMessagingConfig = WebkitMessagingConfig; -class SecureMessagingParams { - /** - * @param {object} params - * @param {string} params.methodName - * @param {string} params.secret - * @param {number[]} params.key - * @param {number[]} params.iv - */ - constructor(params) { - /** - * The method that's been appended to `window` to be called later - */ - this.methodName = params.methodName; - /** - * The secret used to ensure message sender validity - */ - this.secret = params.secret; - /** - * The CipherKey as number[] - */ - this.key = params.key; - /** - * The Initial Vector as number[] - */ - this.iv = params.iv; - } -} +},{"../errors":3,"../locales/en":10}],7:[function(require,module,exports){ +"use strict"; -/** - * Capture some globals used for messaging handling to prevent page - * scripts from tampering with this - */ -exports.SecureMessagingParams = SecureMessagingParams; -function captureGlobals() { - // Creat base with null prototype - return { - window, - // Methods must be bound to their interface, otherwise they throw Illegal invocation - encrypt: window.crypto.subtle.encrypt.bind(window.crypto.subtle), - decrypt: window.crypto.subtle.decrypt.bind(window.crypto.subtle), - generateKey: window.crypto.subtle.generateKey.bind(window.crypto.subtle), - exportKey: window.crypto.subtle.exportKey.bind(window.crypto.subtle), - importKey: window.crypto.subtle.importKey.bind(window.crypto.subtle), - getRandomValues: window.crypto.getRandomValues.bind(window.crypto), - TextEncoder, - TextDecoder, - Uint8Array, - Uint16Array, - Uint32Array, - JSONstringify: window.JSON.stringify, - JSONparse: window.JSON.parse, - Arrayfrom: window.Array.from, - Promise: window.Promise, - ObjectDefineProperty: window.Object.defineProperty, - addEventListener: window.addEventListener.bind(window), - /** @type {Record} */ - capturedWebkitHandlers: {} - }; -} +Object.defineProperty(exports, "__esModule", { + value: true +}); -},{"../messaging.js":3}],5:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.WindowsMessagingTransport = exports.WindowsMessagingConfig = void 0; -var _messaging = require("../messaging.js"); -// eslint-disable-next-line @typescript-eslint/no-unused-vars - -/** - * @implements {MessagingTransport} - */ -class WindowsMessagingTransport { - config; - /** - * @param {WindowsMessagingConfig} config - */ - constructor(config) { - this.config = config; - } - /** - * @param {string} name - * @param {Record} [data] - */ - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error('todo: implement notify for windows'); - } - /** - * @param {string} name - * @param {Record} [data] - * @param {{signal?: AbortSignal}} opts - * @return {Promise} - */ - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - throw new Error('todo: implement request for windows'); - } -} -exports.WindowsMessagingTransport = WindowsMessagingTransport; -class WindowsMessagingConfig { - /** - * @param {object} params - * @param {string} params.featureName - */ - constructor(params) { - this.featureName = params.featureName; +exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0; +var util; +(function (util) { + util.assertEqual = val => val; + function assertIs(_arg) {} + util.assertIs = assertIs; + function assertNever(_x) { + throw new Error(); } -} -exports.WindowsMessagingConfig = WindowsMessagingConfig; - -},{"../messaging.js":3}],6:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0; -const util_1 = require("./helpers/util"); -exports.ZodIssueCode = util_1.util.arrayToEnum(["invalid_type", "invalid_literal", "custom", "invalid_union", "invalid_union_discriminator", "invalid_enum_value", "unrecognized_keys", "invalid_arguments", "invalid_return_type", "invalid_date", "invalid_string", "too_small", "too_big", "invalid_intersection_types", "not_multiple_of", "not_finite"]); -const quotelessJson = obj => { - const json = JSON.stringify(obj, null, 2); - return json.replace(/"([^"]+)":/g, "$1:"); -}; -exports.quotelessJson = quotelessJson; -class ZodError extends Error { - constructor(issues) { - var _this; - super(); - _this = this; - this.issues = []; - this.addIssue = sub => { - this.issues = [...this.issues, sub]; - }; - this.addIssues = function () { - let subs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - _this.issues = [..._this.issues, ...subs]; - }; - const actualProto = new.target.prototype; - if (Object.setPrototypeOf) { - Object.setPrototypeOf(this, actualProto); - } else { - this.__proto__ = actualProto; + util.assertNever = assertNever; + util.arrayToEnum = items => { + const obj = {}; + for (const item of items) { + obj[item] = item; } - this.name = "ZodError"; - this.issues = issues; - } - get errors() { - return this.issues; - } - format(_mapper) { - const mapper = _mapper || function (issue) { - return issue.message; - }; - const fieldErrors = { - _errors: [] - }; - const processError = error => { - for (const issue of error.issues) { - if (issue.code === "invalid_union") { - issue.unionErrors.map(processError); - } else if (issue.code === "invalid_return_type") { - processError(issue.returnTypeError); - } else if (issue.code === "invalid_arguments") { - processError(issue.argumentsError); - } else if (issue.path.length === 0) { - fieldErrors._errors.push(mapper(issue)); - } else { - let curr = fieldErrors; - let i = 0; - while (i < issue.path.length) { - const el = issue.path[i]; - const terminal = i === issue.path.length - 1; - if (!terminal) { - curr[el] = curr[el] || { - _errors: [] - }; - } else { - curr[el] = curr[el] || { - _errors: [] - }; - curr[el]._errors.push(mapper(issue)); - } - curr = curr[el]; - i++; - } - } + return obj; + }; + util.getValidEnumValues = obj => { + const validKeys = util.objectKeys(obj).filter(k => typeof obj[obj[k]] !== "number"); + const filtered = {}; + for (const k of validKeys) { + filtered[k] = obj[k]; + } + return util.objectValues(filtered); + }; + util.objectValues = obj => { + return util.objectKeys(obj).map(function (e) { + return obj[e]; + }); + }; + util.objectKeys = typeof Object.keys === "function" ? obj => Object.keys(obj) : object => { + const keys = []; + for (const key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + keys.push(key); } - }; - processError(this); - return fieldErrors; - } - toString() { - return this.message; - } - get message() { - return JSON.stringify(this.issues, util_1.util.jsonStringifyReplacer, 2); - } - get isEmpty() { - return this.issues.length === 0; + } + return keys; + }; + util.find = (arr, checker) => { + for (const item of arr) { + if (checker(item)) return item; + } + return undefined; + }; + util.isInteger = typeof Number.isInteger === "function" ? val => Number.isInteger(val) : val => typeof val === "number" && isFinite(val) && Math.floor(val) === val; + function joinValues(array) { + let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : " | "; + return array.map(val => typeof val === "string" ? `'${val}'` : val).join(separator); } - flatten() { - let mapper = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : issue => issue.message; - const fieldErrors = {}; - const formErrors = []; - for (const sub of this.issues) { - if (sub.path.length > 0) { - fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; - fieldErrors[sub.path[0]].push(mapper(sub)); - } else { - formErrors.push(mapper(sub)); - } + util.joinValues = joinValues; + util.jsonStringifyReplacer = (_, value) => { + if (typeof value === "bigint") { + return value.toString(); } + return value; + }; +})(util = exports.util || (exports.util = {})); +var objectUtil; +(function (objectUtil) { + objectUtil.mergeShapes = (first, second) => { return { - formErrors, - fieldErrors + ...first, + ...second }; - } - get formErrors() { - return this.flatten(); - } -} -exports.ZodError = ZodError; -ZodError.create = issues => { - const error = new ZodError(issues); - return error; -}; - -},{"./helpers/util":12}],7:[function(require,module,exports){ -"use strict"; - -var __importDefault = void 0 && (void 0).__importDefault || function (mod) { - return mod && mod.__esModule ? mod : { - "default": mod }; +})(objectUtil = exports.objectUtil || (exports.objectUtil = {})); +exports.ZodParsedType = util.arrayToEnum(["string", "nan", "number", "integer", "float", "boolean", "date", "bigint", "symbol", "function", "undefined", "null", "array", "object", "unknown", "promise", "void", "never", "map", "set"]); +const getParsedType = data => { + const t = typeof data; + switch (t) { + case "undefined": + return exports.ZodParsedType.undefined; + case "string": + return exports.ZodParsedType.string; + case "number": + return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number; + case "boolean": + return exports.ZodParsedType.boolean; + case "function": + return exports.ZodParsedType.function; + case "bigint": + return exports.ZodParsedType.bigint; + case "symbol": + return exports.ZodParsedType.symbol; + case "object": + if (Array.isArray(data)) { + return exports.ZodParsedType.array; + } + if (data === null) { + return exports.ZodParsedType.null; + } + if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { + return exports.ZodParsedType.promise; + } + if (typeof Map !== "undefined" && data instanceof Map) { + return exports.ZodParsedType.map; + } + if (typeof Set !== "undefined" && data instanceof Set) { + return exports.ZodParsedType.set; + } + if (typeof Date !== "undefined" && data instanceof Date) { + return exports.ZodParsedType.date; + } + return exports.ZodParsedType.object; + default: + return exports.ZodParsedType.unknown; + } }; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = void 0; -const en_1 = __importDefault(require("./locales/en")); -exports.defaultErrorMap = en_1.default; -let overrideErrorMap = en_1.default; -function setErrorMap(map) { - overrideErrorMap = map; -} -exports.setErrorMap = setErrorMap; -function getErrorMap() { - return overrideErrorMap; -} -exports.getErrorMap = getErrorMap; +exports.getParsedType = getParsedType; -},{"./locales/en":14}],8:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ "use strict"; var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { @@ -859,566 +500,271 @@ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? fun if (k2 === undefined) k2 = k; o[k2] = m[k]; }); +var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) { + Object.defineProperty(o, "default", { + enumerable: true, + value: v + }); +} : function (o, v) { + o["default"] = v; +}); +var __importStar = void 0 && (void 0).__importStar || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("./errors"), exports); -__exportStar(require("./helpers/parseUtil"), exports); -__exportStar(require("./helpers/typeAliases"), exports); -__exportStar(require("./helpers/util"), exports); -__exportStar(require("./types"), exports); -__exportStar(require("./ZodError"), exports); +exports.z = void 0; +const z = __importStar(require("./external")); +exports.z = z; +__exportStar(require("./external"), exports); +exports.default = z; -},{"./ZodError":6,"./errors":7,"./helpers/parseUtil":10,"./helpers/typeAliases":11,"./helpers/util":12,"./types":15}],9:[function(require,module,exports){ +},{"./external":4}],10:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.errorUtil = void 0; -var errorUtil; -(function (errorUtil) { - errorUtil.errToObj = message => typeof message === "string" ? { +const util_1 = require("../helpers/util"); +const ZodError_1 = require("../ZodError"); +const errorMap = (issue, _ctx) => { + let message; + switch (issue.code) { + case ZodError_1.ZodIssueCode.invalid_type: + if (issue.received === util_1.ZodParsedType.undefined) { + message = "Required"; + } else { + message = `Expected ${issue.expected}, received ${issue.received}`; + } + break; + case ZodError_1.ZodIssueCode.invalid_literal: + message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_1.util.jsonStringifyReplacer)}`; + break; + case ZodError_1.ZodIssueCode.unrecognized_keys: + message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`; + break; + case ZodError_1.ZodIssueCode.invalid_union: + message = `Invalid input`; + break; + case ZodError_1.ZodIssueCode.invalid_union_discriminator: + message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`; + break; + case ZodError_1.ZodIssueCode.invalid_enum_value: + message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`; + break; + case ZodError_1.ZodIssueCode.invalid_arguments: + message = `Invalid function arguments`; + break; + case ZodError_1.ZodIssueCode.invalid_return_type: + message = `Invalid function return type`; + break; + case ZodError_1.ZodIssueCode.invalid_date: + message = `Invalid date`; + break; + case ZodError_1.ZodIssueCode.invalid_string: + if (typeof issue.validation === "object") { + if ("includes" in issue.validation) { + message = `Invalid input: must include "${issue.validation.includes}"`; + if (typeof issue.validation.position === "number") { + message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; + } + } else if ("startsWith" in issue.validation) { + message = `Invalid input: must start with "${issue.validation.startsWith}"`; + } else if ("endsWith" in issue.validation) { + message = `Invalid input: must end with "${issue.validation.endsWith}"`; + } else { + util_1.util.assertNever(issue.validation); + } + } else if (issue.validation !== "regex") { + message = `Invalid ${issue.validation}`; + } else { + message = "Invalid"; + } + break; + case ZodError_1.ZodIssueCode.too_small: + if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;else message = "Invalid input"; + break; + case ZodError_1.ZodIssueCode.too_big: + if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;else message = "Invalid input"; + break; + case ZodError_1.ZodIssueCode.custom: + message = `Invalid input`; + break; + case ZodError_1.ZodIssueCode.invalid_intersection_types: + message = `Intersection results could not be merged`; + break; + case ZodError_1.ZodIssueCode.not_multiple_of: + message = `Number must be a multiple of ${issue.multipleOf}`; + break; + case ZodError_1.ZodIssueCode.not_finite: + message = "Number must be finite"; + break; + default: + message = _ctx.defaultError; + util_1.util.assertNever(issue); + } + return { message - } : message || {}; - errorUtil.toString = message => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; -})(errorUtil = exports.errorUtil || (exports.errorUtil = {})); + }; +}; +exports.default = errorMap; -},{}],10:[function(require,module,exports){ +},{"../ZodError":2,"../helpers/util":8}],11:[function(require,module,exports){ "use strict"; -var __importDefault = void 0 && (void 0).__importDefault || function (mod) { - return mod && mod.__esModule ? mod : { - "default": mod - }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0; -const errors_1 = require("../errors"); -const en_1 = __importDefault(require("../locales/en")); -const makeIssue = params => { - const { - data, - path, - errorMaps, - issueData - } = params; - const fullPath = [...path, ...(issueData.path || [])]; - const fullIssue = { - ...issueData, - path: fullPath - }; - let errorMessage = ""; - const maps = errorMaps.filter(m => !!m).slice().reverse(); - for (const map of maps) { - errorMessage = map(fullIssue, { - data, - defaultError: errorMessage - }).message; - } - return { - ...issueData, - path: fullPath, - message: issueData.message || errorMessage - }; -}; -exports.makeIssue = makeIssue; -exports.EMPTY_PATH = []; -function addIssueToContext(ctx, issueData) { - const issue = (0, exports.makeIssue)({ - issueData: issueData, - data: ctx.data, - path: ctx.path, - errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, (0, errors_1.getErrorMap)(), en_1.default].filter(x => !!x) - }); - ctx.common.issues.push(issue); -} -exports.addIssueToContext = addIssueToContext; -class ParseStatus { - constructor() { - this.value = "valid"; - } - dirty() { - if (this.value === "valid") this.value = "dirty"; - } - abort() { - if (this.value !== "aborted") this.value = "aborted"; +exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0; +exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = exports.discriminatedUnion = void 0; +const errors_1 = require("./errors"); +const errorUtil_1 = require("./helpers/errorUtil"); +const parseUtil_1 = require("./helpers/parseUtil"); +const util_1 = require("./helpers/util"); +const ZodError_1 = require("./ZodError"); +class ParseInputLazyPath { + constructor(parent, value, path, key) { + this._cachedPath = []; + this.parent = parent; + this.data = value; + this._path = path; + this._key = key; } - static mergeArray(status, results) { - const arrayValue = []; - for (const s of results) { - if (s.status === "aborted") return exports.INVALID; - if (s.status === "dirty") status.dirty(); - arrayValue.push(s.value); + get path() { + if (!this._cachedPath.length) { + if (this._key instanceof Array) { + this._cachedPath.push(...this._path, ...this._key); + } else { + this._cachedPath.push(...this._path, this._key); + } } + return this._cachedPath; + } +} +const handleResult = (ctx, result) => { + if ((0, parseUtil_1.isValid)(result)) { return { - status: status.value, - value: arrayValue + success: true, + data: result.value }; - } - static async mergeObjectAsync(status, pairs) { - const syncPairs = []; - for (const pair of pairs) { - syncPairs.push({ - key: await pair.key, - value: await pair.value - }); - } - return ParseStatus.mergeObjectSync(status, syncPairs); - } - static mergeObjectSync(status, pairs) { - const finalObject = {}; - for (const pair of pairs) { - const { - key, - value - } = pair; - if (key.status === "aborted") return exports.INVALID; - if (value.status === "aborted") return exports.INVALID; - if (key.status === "dirty") status.dirty(); - if (value.status === "dirty") status.dirty(); - if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) { - finalObject[key.value] = value.value; - } + } else { + if (!ctx.common.issues.length) { + throw new Error("Validation failed but no issues detected."); } return { - status: status.value, - value: finalObject + success: false, + get error() { + if (this._error) return this._error; + const error = new ZodError_1.ZodError(ctx.common.issues); + this._error = error; + return this._error; + } }; } -} -exports.ParseStatus = ParseStatus; -exports.INVALID = Object.freeze({ - status: "aborted" -}); -const DIRTY = value => ({ - status: "dirty", - value -}); -exports.DIRTY = DIRTY; -const OK = value => ({ - status: "valid", - value -}); -exports.OK = OK; -const isAborted = x => x.status === "aborted"; -exports.isAborted = isAborted; -const isDirty = x => x.status === "dirty"; -exports.isDirty = isDirty; -const isValid = x => x.status === "valid"; -exports.isValid = isValid; -const isAsync = x => typeof Promise !== "undefined" && x instanceof Promise; -exports.isAsync = isAsync; - -},{"../errors":7,"../locales/en":14}],11:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -},{}],12:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0; -var util; -(function (util) { - util.assertEqual = val => val; - function assertIs(_arg) {} - util.assertIs = assertIs; - function assertNever(_x) { - throw new Error(); +}; +function processCreateParams(params) { + if (!params) return {}; + const { + errorMap, + invalid_type_error, + required_error, + description + } = params; + if (errorMap && (invalid_type_error || required_error)) { + throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); } - util.assertNever = assertNever; - util.arrayToEnum = items => { - const obj = {}; - for (const item of items) { - obj[item] = item; - } - return obj; - }; - util.getValidEnumValues = obj => { - const validKeys = util.objectKeys(obj).filter(k => typeof obj[obj[k]] !== "number"); - const filtered = {}; - for (const k of validKeys) { - filtered[k] = obj[k]; - } - return util.objectValues(filtered); - }; - util.objectValues = obj => { - return util.objectKeys(obj).map(function (e) { - return obj[e]; - }); + if (errorMap) return { + errorMap: errorMap, + description }; - util.objectKeys = typeof Object.keys === "function" ? obj => Object.keys(obj) : object => { - const keys = []; - for (const key in object) { - if (Object.prototype.hasOwnProperty.call(object, key)) { - keys.push(key); - } + const customMap = (iss, ctx) => { + if (iss.code !== "invalid_type") return { + message: ctx.defaultError + }; + if (typeof ctx.data === "undefined") { + return { + message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError + }; } - return keys; + return { + message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError + }; }; - util.find = (arr, checker) => { - for (const item of arr) { - if (checker(item)) return item; - } - return undefined; + return { + errorMap: customMap, + description }; - util.isInteger = typeof Number.isInteger === "function" ? val => Number.isInteger(val) : val => typeof val === "number" && isFinite(val) && Math.floor(val) === val; - function joinValues(array) { - let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : " | "; - return array.map(val => typeof val === "string" ? `'${val}'` : val).join(separator); +} +class ZodType { + constructor(def) { + this.spa = this.safeParseAsync; + this._def = def; + this.parse = this.parse.bind(this); + this.safeParse = this.safeParse.bind(this); + this.parseAsync = this.parseAsync.bind(this); + this.safeParseAsync = this.safeParseAsync.bind(this); + this.spa = this.spa.bind(this); + this.refine = this.refine.bind(this); + this.refinement = this.refinement.bind(this); + this.superRefine = this.superRefine.bind(this); + this.optional = this.optional.bind(this); + this.nullable = this.nullable.bind(this); + this.nullish = this.nullish.bind(this); + this.array = this.array.bind(this); + this.promise = this.promise.bind(this); + this.or = this.or.bind(this); + this.and = this.and.bind(this); + this.transform = this.transform.bind(this); + this.brand = this.brand.bind(this); + this.default = this.default.bind(this); + this.catch = this.catch.bind(this); + this.describe = this.describe.bind(this); + this.pipe = this.pipe.bind(this); + this.readonly = this.readonly.bind(this); + this.isNullable = this.isNullable.bind(this); + this.isOptional = this.isOptional.bind(this); } - util.joinValues = joinValues; - util.jsonStringifyReplacer = (_, value) => { - if (typeof value === "bigint") { - return value.toString(); - } - return value; - }; -})(util = exports.util || (exports.util = {})); -var objectUtil; -(function (objectUtil) { - objectUtil.mergeShapes = (first, second) => { - return { - ...first, - ...second + get description() { + return this._def.description; + } + _getType(input) { + return (0, util_1.getParsedType)(input.data); + } + _getOrReturnCtx(input, ctx) { + return ctx || { + common: input.parent.common, + data: input.data, + parsedType: (0, util_1.getParsedType)(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent }; - }; -})(objectUtil = exports.objectUtil || (exports.objectUtil = {})); -exports.ZodParsedType = util.arrayToEnum(["string", "nan", "number", "integer", "float", "boolean", "date", "bigint", "symbol", "function", "undefined", "null", "array", "object", "unknown", "promise", "void", "never", "map", "set"]); -const getParsedType = data => { - const t = typeof data; - switch (t) { - case "undefined": - return exports.ZodParsedType.undefined; - case "string": - return exports.ZodParsedType.string; - case "number": - return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number; - case "boolean": - return exports.ZodParsedType.boolean; - case "function": - return exports.ZodParsedType.function; - case "bigint": - return exports.ZodParsedType.bigint; - case "symbol": - return exports.ZodParsedType.symbol; - case "object": - if (Array.isArray(data)) { - return exports.ZodParsedType.array; - } - if (data === null) { - return exports.ZodParsedType.null; - } - if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { - return exports.ZodParsedType.promise; - } - if (typeof Map !== "undefined" && data instanceof Map) { - return exports.ZodParsedType.map; - } - if (typeof Set !== "undefined" && data instanceof Set) { - return exports.ZodParsedType.set; - } - if (typeof Date !== "undefined" && data instanceof Date) { - return exports.ZodParsedType.date; + } + _processInputParams(input) { + return { + status: new parseUtil_1.ParseStatus(), + ctx: { + common: input.parent.common, + data: input.data, + parsedType: (0, util_1.getParsedType)(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent } - return exports.ZodParsedType.object; - default: - return exports.ZodParsedType.unknown; + }; } -}; -exports.getParsedType = getParsedType; - -},{}],13:[function(require,module,exports){ -"use strict"; - -var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { - enumerable: true, - get: function () { - return m[k]; - } - }); -} : function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -}); -var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) { - Object.defineProperty(o, "default", { - enumerable: true, - value: v - }); -} : function (o, v) { - o["default"] = v; -}); -var __importStar = void 0 && (void 0).__importStar || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.z = void 0; -const z = __importStar(require("./external")); -exports.z = z; -__exportStar(require("./external"), exports); -exports.default = z; - -},{"./external":8}],14:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -const util_1 = require("../helpers/util"); -const ZodError_1 = require("../ZodError"); -const errorMap = (issue, _ctx) => { - let message; - switch (issue.code) { - case ZodError_1.ZodIssueCode.invalid_type: - if (issue.received === util_1.ZodParsedType.undefined) { - message = "Required"; - } else { - message = `Expected ${issue.expected}, received ${issue.received}`; - } - break; - case ZodError_1.ZodIssueCode.invalid_literal: - message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_1.util.jsonStringifyReplacer)}`; - break; - case ZodError_1.ZodIssueCode.unrecognized_keys: - message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`; - break; - case ZodError_1.ZodIssueCode.invalid_union: - message = `Invalid input`; - break; - case ZodError_1.ZodIssueCode.invalid_union_discriminator: - message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`; - break; - case ZodError_1.ZodIssueCode.invalid_enum_value: - message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`; - break; - case ZodError_1.ZodIssueCode.invalid_arguments: - message = `Invalid function arguments`; - break; - case ZodError_1.ZodIssueCode.invalid_return_type: - message = `Invalid function return type`; - break; - case ZodError_1.ZodIssueCode.invalid_date: - message = `Invalid date`; - break; - case ZodError_1.ZodIssueCode.invalid_string: - if (typeof issue.validation === "object") { - if ("includes" in issue.validation) { - message = `Invalid input: must include "${issue.validation.includes}"`; - if (typeof issue.validation.position === "number") { - message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; - } - } else if ("startsWith" in issue.validation) { - message = `Invalid input: must start with "${issue.validation.startsWith}"`; - } else if ("endsWith" in issue.validation) { - message = `Invalid input: must end with "${issue.validation.endsWith}"`; - } else { - util_1.util.assertNever(issue.validation); - } - } else if (issue.validation !== "regex") { - message = `Invalid ${issue.validation}`; - } else { - message = "Invalid"; - } - break; - case ZodError_1.ZodIssueCode.too_small: - if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;else message = "Invalid input"; - break; - case ZodError_1.ZodIssueCode.too_big: - if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;else message = "Invalid input"; - break; - case ZodError_1.ZodIssueCode.custom: - message = `Invalid input`; - break; - case ZodError_1.ZodIssueCode.invalid_intersection_types: - message = `Intersection results could not be merged`; - break; - case ZodError_1.ZodIssueCode.not_multiple_of: - message = `Number must be a multiple of ${issue.multipleOf}`; - break; - case ZodError_1.ZodIssueCode.not_finite: - message = "Number must be finite"; - break; - default: - message = _ctx.defaultError; - util_1.util.assertNever(issue); - } - return { - message - }; -}; -exports.default = errorMap; - -},{"../ZodError":6,"../helpers/util":12}],15:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0; -exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = exports.discriminatedUnion = void 0; -const errors_1 = require("./errors"); -const errorUtil_1 = require("./helpers/errorUtil"); -const parseUtil_1 = require("./helpers/parseUtil"); -const util_1 = require("./helpers/util"); -const ZodError_1 = require("./ZodError"); -class ParseInputLazyPath { - constructor(parent, value, path, key) { - this._cachedPath = []; - this.parent = parent; - this.data = value; - this._path = path; - this._key = key; - } - get path() { - if (!this._cachedPath.length) { - if (this._key instanceof Array) { - this._cachedPath.push(...this._path, ...this._key); - } else { - this._cachedPath.push(...this._path, this._key); - } - } - return this._cachedPath; - } -} -const handleResult = (ctx, result) => { - if ((0, parseUtil_1.isValid)(result)) { - return { - success: true, - data: result.value - }; - } else { - if (!ctx.common.issues.length) { - throw new Error("Validation failed but no issues detected."); - } - return { - success: false, - get error() { - if (this._error) return this._error; - const error = new ZodError_1.ZodError(ctx.common.issues); - this._error = error; - return this._error; - } - }; - } -}; -function processCreateParams(params) { - if (!params) return {}; - const { - errorMap, - invalid_type_error, - required_error, - description - } = params; - if (errorMap && (invalid_type_error || required_error)) { - throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); - } - if (errorMap) return { - errorMap: errorMap, - description - }; - const customMap = (iss, ctx) => { - if (iss.code !== "invalid_type") return { - message: ctx.defaultError - }; - if (typeof ctx.data === "undefined") { - return { - message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError - }; - } - return { - message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError - }; - }; - return { - errorMap: customMap, - description - }; -} -class ZodType { - constructor(def) { - this.spa = this.safeParseAsync; - this._def = def; - this.parse = this.parse.bind(this); - this.safeParse = this.safeParse.bind(this); - this.parseAsync = this.parseAsync.bind(this); - this.safeParseAsync = this.safeParseAsync.bind(this); - this.spa = this.spa.bind(this); - this.refine = this.refine.bind(this); - this.refinement = this.refinement.bind(this); - this.superRefine = this.superRefine.bind(this); - this.optional = this.optional.bind(this); - this.nullable = this.nullable.bind(this); - this.nullish = this.nullish.bind(this); - this.array = this.array.bind(this); - this.promise = this.promise.bind(this); - this.or = this.or.bind(this); - this.and = this.and.bind(this); - this.transform = this.transform.bind(this); - this.brand = this.brand.bind(this); - this.default = this.default.bind(this); - this.catch = this.catch.bind(this); - this.describe = this.describe.bind(this); - this.pipe = this.pipe.bind(this); - this.readonly = this.readonly.bind(this); - this.isNullable = this.isNullable.bind(this); - this.isOptional = this.isOptional.bind(this); - } - get description() { - return this._def.description; - } - _getType(input) { - return (0, util_1.getParsedType)(input.data); - } - _getOrReturnCtx(input, ctx) { - return ctx || { - common: input.parent.common, - data: input.data, - parsedType: (0, util_1.getParsedType)(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - }; - } - _processInputParams(input) { - return { - status: new parseUtil_1.ParseStatus(), - ctx: { - common: input.parent.common, - data: input.data, - parsedType: (0, util_1.getParsedType)(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - } - }; - } - _parseSync(input) { - const result = this._parse(input); - if ((0, parseUtil_1.isAsync)(result)) { - throw new Error("Synchronous parse encountered promise."); + _parseSync(input) { + const result = this._parse(input); + if ((0, parseUtil_1.isAsync)(result)) { + throw new Error("Synchronous parse encountered promise."); } return result; } @@ -4648,380 +3994,949 @@ exports.coerce = { }; exports.NEVER = parseUtil_1.INVALID; -},{"./ZodError":6,"./errors":7,"./helpers/errorUtil":9,"./helpers/parseUtil":10,"./helpers/util":12}],16:[function(require,module,exports){ +},{"./ZodError":2,"./errors":3,"./helpers/errorUtil":5,"./helpers/parseUtil":6,"./helpers/util":8}],12:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "DeviceApi", { + enumerable: true, + get: function () { + return _deviceApi.DeviceApi; + } +}); +Object.defineProperty(exports, "DeviceApiCall", { + enumerable: true, + get: function () { + return _deviceApiCall.DeviceApiCall; + } +}); +Object.defineProperty(exports, "DeviceApiTransport", { + enumerable: true, + get: function () { + return _deviceApi.DeviceApiTransport; + } +}); +Object.defineProperty(exports, "createNotification", { + enumerable: true, + get: function () { + return _deviceApiCall.createNotification; + } +}); +Object.defineProperty(exports, "createRequest", { + enumerable: true, + get: function () { + return _deviceApiCall.createRequest; + } +}); +Object.defineProperty(exports, "validate", { + enumerable: true, + get: function () { + return _deviceApiCall.validate; + } +}); +var _deviceApiCall = require("./lib/device-api-call.js"); +var _deviceApi = require("./lib/device-api.js"); + +},{"./lib/device-api-call.js":13,"./lib/device-api.js":14}],13:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.SchemaValidationError = exports.DeviceApiCallError = exports.DeviceApiCall = void 0; +exports.createDeviceApiCall = createDeviceApiCall; +exports.createNotification = void 0; +exports.createRequest = createRequest; +exports.validate = validate; +/** + * This roughly follows https://www.jsonrpc.org/specification + * @template {import("zod").ZodType} Params=import("zod").ZodType + * @template {import("zod").ZodType} Result=import("zod").ZodType + */ +class DeviceApiCall { + /** @type {string} */ + method = 'unknown'; + /** + * An optional 'id' - used to indicate if a request requires a response. + * @type {string|null} + */ + id = null; + /** @type {Params | null | undefined} */ + paramsValidator = null; + /** @type {Result | null | undefined} */ + resultValidator = null; + /** @type {import("zod").infer} */ + params; + /** + * This is a carve-out for legacy messages that are not typed yet. + * If you set this to 'true', then the response will not be checked to conform + * to any shape + * @deprecated this is here to aid migration, should be removed ASAP + * @type {boolean} + */ + throwOnResultKeysMissing = true; + /** + * New messages should be in a particular format, eg: { success: T }, + * but you can set this to false if you want to access the result as-is, + * without any unwrapping logic + * @deprecated this is here to aid migration, should be removed ASAP + * @type {boolean} + */ + unwrapResult = true; + /** + * @param {import("zod").infer} data + */ + constructor(data) { + this.params = data; + } + + /** + * @returns {import("zod").infer|undefined} + */ + validateParams() { + if (this.params === undefined) { + return undefined; + } + this._validate(this.params, this.paramsValidator); + return this.params; + } + + /** + * @param {any|null} incoming + * @returns {import("zod").infer} + */ + validateResult(incoming) { + this._validate(incoming, this.resultValidator); + if (!incoming) { + return incoming; + } + if (!this.unwrapResult) { + return incoming; + } + if ('data' in incoming) { + console.warn('response had `data` property. Please migrate to `success`'); + return incoming.data; + } + if ('success' in incoming) { + return incoming.success; + } + if ('error' in incoming) { + if (typeof incoming.error.message === 'string') { + throw new DeviceApiCallError(`${this.method}: ${incoming.error.message}`); + } + } + if (this.throwOnResultKeysMissing) { + throw new Error('unreachable. Response did not contain `success` or `data`'); + } + return incoming; + } + + /** + * @param {any} data + * @param {import("zod").ZodType|undefined|null} [validator] + * @private + */ + _validate(data, validator) { + if (!validator) return data; + if (validator) { + const result = validator?.safeParse(data); + if (!result) { + throw new Error('unreachable, data failure', data); + } + if (!result.success) { + if ('error' in result) { + this.throwError(result.error.issues); + } else { + console.error('unknown error from validate'); + } + } + } + } + + /** + * @param {import('zod').ZodIssue[]} errors + */ + throwError(errors) { + const error = SchemaValidationError.fromZodErrors(errors, this.constructor.name); + throw error; + } + + /** + * Use this helper for creating stand-in response messages that are typed correctly. + * + * @examples + * + * ```js + * const msg = new Message(); + * const response = msg.response({}) // <-- This argument will be typed correctly + * ``` + * + * @param {import("zod").infer} response + * @returns {import("zod").infer} + */ + result(response) { + return response; + } + /** + * @returns {import("zod").infer} + */ + preResultValidation(response) { + return response; + } +} +exports.DeviceApiCall = DeviceApiCall; +class DeviceApiCallError extends Error {} + +/** + * Check for this error if you'd like to + */ +exports.DeviceApiCallError = DeviceApiCallError; +class SchemaValidationError extends Error { + /** @type {import("zod").ZodIssue[]} */ + validationErrors = []; + + /** + * @param {import("zod").ZodIssue[]} errors + * @param {string} name + * @returns {SchemaValidationError} + */ + static fromZodErrors(errors, name) { + const heading = `${errors.length} SchemaValidationError(s) errors for ` + name; + function log(issue) { + switch (issue.code) { + case 'invalid_literal': + case 'invalid_type': + { + console.log(`${name}. Path: '${issue.path.join('.')}', Error: '${issue.message}'`); + break; + } + case 'invalid_union': + { + for (let unionError of issue.unionErrors) { + for (let issue1 of unionError.issues) { + log(issue1); + } + } + break; + } + default: + { + console.log(name, 'other issue:', issue); + } + } + } + for (let error of errors) { + log(error); + } + const message = [heading, 'please see the details above'].join('\n '); + const error = new SchemaValidationError(message); + error.validationErrors = errors; + return error; + } +} + +/** + * Creates an instance of `DeviceApiCall` from only a name and 'params' + * and optional validators. Use this to help migrate existing messages. + * + * @template {import("zod").ZodType} Params + * @template {import("zod").ZodType} Result + * @param {string} method + * @param {import("zod").infer} [params] + * @param {Params|null} [paramsValidator] + * @param {Result|null} [resultValidator] + * @returns {DeviceApiCall} + */ +exports.SchemaValidationError = SchemaValidationError; +function createDeviceApiCall(method, params) { + let paramsValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + let resultValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + /** @type {DeviceApiCall} */ + const deviceApiCall = new DeviceApiCall(params); + deviceApiCall.paramsValidator = paramsValidator; + deviceApiCall.resultValidator = resultValidator; + deviceApiCall.method = method; + deviceApiCall.throwOnResultKeysMissing = false; + deviceApiCall.unwrapResult = false; + return deviceApiCall; +} + +/** + * Creates an instance of `DeviceApiCall` from only a name and 'params' + * and optional validators. Use this to help migrate existing messages. + * + * Note: This creates a regular DeviceApiCall, but adds the 'id' as a string + * so that transports know that it expects a response. + * + * @template {import("zod").ZodType} Params + * @template {import("zod").ZodType} Result + * @param {string} method + * @param {import("zod").infer} [params] + * @param {string} [id] + * @param {Params|null} [paramsValidator] + * @param {Result|null} [resultValidator] + * @returns {DeviceApiCall} + */ +function createRequest(method, params) { + let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n/a'; + let paramsValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + let resultValidator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; + const call = createDeviceApiCall(method, params, paramsValidator, resultValidator); + call.id = id; + return call; +} +const createNotification = exports.createNotification = createDeviceApiCall; + +/** + * Validate any arbitrary data with any Zod validator + * + * @template {import("zod").ZodType} Validator + * @param {any} data + * @param {Validator | null} [validator] + * @returns {import("zod").infer} + */ +function validate(data) { + let validator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + if (validator) { + return validator.parse(data); + } + return data; +} + +},{}],14:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -Object.defineProperty(exports, "DeviceApi", { - enumerable: true, - get: function () { - return _deviceApi.DeviceApi; +exports.DeviceApiTransport = exports.DeviceApi = void 0; +/** + * Platforms should only need to implement this `send` method + */ +class DeviceApiTransport { + /** + * @param {import("./device-api-call.js").DeviceApiCall} _deviceApiCall + * @param {CallOptions} [_options] + * @returns {Promise} + */ + async send(_deviceApiCall, _options) { + return undefined; } -}); -Object.defineProperty(exports, "DeviceApiCall", { - enumerable: true, - get: function () { - return _deviceApiCall.DeviceApiCall; +} + +/** + * This is the base Sender class that platforms can will implement. + * + * Note: The 'handle' method must be implemented, unless you also implement 'send' + * + * @typedef CallOptions + * @property {AbortSignal} [signal] + */ +exports.DeviceApiTransport = DeviceApiTransport; +class DeviceApi { + /** @type {DeviceApiTransport} */ + transport; + /** @param {DeviceApiTransport} transport */ + constructor(transport) { + this.transport = transport; } -}); -Object.defineProperty(exports, "DeviceApiTransport", { - enumerable: true, - get: function () { - return _deviceApi.DeviceApiTransport; + /** + * @template {import("./device-api-call").DeviceApiCall} D + * @param {D} deviceApiCall + * @param {CallOptions} [options] + * @returns {Promise['success']>>} + */ + async request(deviceApiCall, options) { + deviceApiCall.validateParams(); + let result = await this.transport.send(deviceApiCall, options); + let processed = deviceApiCall.preResultValidation(result); + return deviceApiCall.validateResult(processed); } -}); -Object.defineProperty(exports, "createNotification", { - enumerable: true, - get: function () { - return _deviceApiCall.createNotification; + /** + * @template {import("./device-api-call").DeviceApiCall} P + * @param {P} deviceApiCall + * @param {CallOptions} [options] + * @returns {Promise} + */ + async notify(deviceApiCall, options) { + deviceApiCall.validateParams(); + return this.transport.send(deviceApiCall, options); } +} +exports.DeviceApi = DeviceApi; + +},{}],15:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true }); -Object.defineProperty(exports, "createRequest", { +exports.MissingHandler = exports.MessagingTransport = exports.Messaging = void 0; +Object.defineProperty(exports, "WebkitMessagingConfig", { enumerable: true, get: function () { - return _deviceApiCall.createRequest; + return _webkit.WebkitMessagingConfig; } }); -Object.defineProperty(exports, "validate", { - enumerable: true, - get: function () { - return _deviceApiCall.validate; +var _webkit = require("./webkit.js"); +/** + * @module Messaging + * + * @description + * + * An abstraction for communications between JavaScript and host platforms. + * + * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) + * 2) Then use that to get an instance of the Messaging utility which allows + * you to send and receive data in a unified way + * 3) Each platform implements {@link MessagingTransport} along with its own Configuration + * - For example, to learn what configuration is required for Webkit, see: {@link "Webkit Messaging".WebkitMessagingConfig} + * - Or, to learn about how messages are sent and received in Webkit, see {@link "Webkit Messaging".WebkitMessagingTransport} + * + * @example Webkit Messaging + * + * ```js + * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" + * + * // This config would be injected into the UserScript + * const injectedConfig = { + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }; + * + * // Then use that config to construct platform-specific configuration + * const config = new WebkitMessagingConfig(injectedConfig); + * + * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 + * const messaging = new Messaging(config); + * messaging.notify("hello world!", {foo: "bar"}) + * + * ``` + * + * @example Windows Messaging + * + * ```js + * import { Messaging, WindowsMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" + * + * // Messaging on Windows is namespaced, so you can create multiple messaging instances + * const autofillConfig = new WindowsMessagingConfig({ featureName: "Autofill" }); + * const debugConfig = new WindowsMessagingConfig({ featureName: "Debugging" }); + * + * const autofillMessaging = new Messaging(autofillConfig); + * const debugMessaging = new Messaging(debugConfig); + * + * // Now send messages to both features as needed 🚀 + * autofillMessaging.notify("storeFormData", { "username": "dax" }) + * debugMessaging.notify("pageLoad", { time: window.performance.now() }) + * ``` + */ + +/** + * @implements {MessagingTransport} + */ +class Messaging { + /** + * @param {WebkitMessagingConfig} config + */ + constructor(config) { + this.transport = getTransport(config); } -}); -var _deviceApiCall = require("./lib/device-api-call.js"); -var _deviceApi = require("./lib/device-api.js"); + /** + * Send a 'fire-and-forget' message. + * @throws {Error} + * {@link MissingHandler} + * + * @example + * + * ``` + * const messaging = new Messaging(config) + * messaging.notify("foo", {bar: "baz"}) + * ``` + * @param {string} name + * @param {Record} [data] + */ + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + this.transport.notify(name, data); + } + /** + * Send a request, and wait for a response + * @throws {Error} + * {@link MissingHandler} + * + * @example + * ``` + * const messaging = new Messaging(config) + * const response = await messaging.request("foo", {bar: "baz"}) + * ``` + * + * @param {string} name + * @param {Record} [data] + * @return {Promise} + */ + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return this.transport.request(name, data); + } +} + +/** + * @interface + */ +exports.Messaging = Messaging; +class MessagingTransport { + /** + * @param {string} name + * @param {Record} [data] + * @returns {void} + */ + // @ts-ignore - ignoring a no-unused ts error, this is only an interface. + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + throw new Error("must implement 'notify'"); + } + /** + * @param {string} name + * @param {Record} [data] + * @return {Promise} + */ + // @ts-ignore - ignoring a no-unused ts error, this is only an interface. + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + throw new Error('must implement'); + } +} + +/** + * @param {WebkitMessagingConfig} config + * @returns {MessagingTransport} + */ +exports.MessagingTransport = MessagingTransport; +function getTransport(config) { + if (config instanceof _webkit.WebkitMessagingConfig) { + return new _webkit.WebkitMessagingTransport(config); + } + throw new Error('unreachable'); +} + +/** + * Thrown when a handler cannot be found + */ +class MissingHandler extends Error { + /** + * @param {string} message + * @param {string} handlerName + */ + constructor(message, handlerName) { + super(message); + this.handlerName = handlerName; + } +} + +/** + * Some re-exports for convenience + */ +exports.MissingHandler = MissingHandler; -},{"./lib/device-api-call.js":17,"./lib/device-api.js":18}],17:[function(require,module,exports){ +},{"./webkit.js":16}],16:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.SchemaValidationError = exports.DeviceApiCallError = exports.DeviceApiCall = void 0; -exports.createDeviceApiCall = createDeviceApiCall; -exports.createNotification = void 0; -exports.createRequest = createRequest; -exports.validate = validate; +exports.WebkitMessagingTransport = exports.WebkitMessagingConfig = exports.SecureMessagingParams = void 0; +var _messaging = require("./messaging.js"); /** - * This roughly follows https://www.jsonrpc.org/specification - * @template {import("zod").ZodType} Params=import("zod").ZodType - * @template {import("zod").ZodType} Result=import("zod").ZodType + * @module Webkit Messaging + * + * @description + * + * A wrapper for messaging on WebKit platforms. It supports modern WebKit messageHandlers + * along with encryption for older versions (like macOS Catalina) + * + * Note: If you wish to support Catalina then you'll need to implement the native + * part of the message handling, see {@link WebkitMessagingTransport} for details. + * + * ```js + * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" + * + * // This config would be injected into the UserScript + * const injectedConfig = { + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }; + * + * // Then use that config to construct platform-specific configuration + * const config = new WebkitMessagingConfig(injectedConfig); + * + * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 + * const messaging = new Messaging(config); + * messaging.notify("hello world!", {foo: "bar"}) + * + * ``` + */ + +/** + * @typedef {import("./messaging").MessagingTransport} MessagingTransport + */ + +/** + * @example + * On macOS 11+, this will just call through to `window.webkit.messageHandlers.x.postMessage` + * + * Eg: for a `foo` message defined in Swift that accepted the payload `{"bar": "baz"}`, the following + * would occur: + * + * ```js + * const json = await window.webkit.messageHandlers.foo.postMessage({ bar: "baz" }); + * const response = JSON.parse(json) + * ``` + * + * @example + * On macOS 10 however, the process is a little more involved. A method will be appended to `window` + * that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow + * as being something along the lines of: + * + * ```js + * // add the window method + * window["_0123456"] = (response) => { + * // decrypt `response` and deliver the result to the caller here + * // then remove the temporary method + * delete window["_0123456"] + * }; + * + * // send the data + `messageHanding` values + * window.webkit.messageHandlers.foo.postMessage({ + * bar: "baz", + * messagingHandling: { + * methodName: "_0123456", + * secret: "super-secret", + * key: [1, 2, 45, 2], + * iv: [34, 4, 43], + * } + * }); + * + * // later in swift, the following JavaScript snippet will be executed + * (() => { + * window["_0123456"]({ + * ciphertext: [12, 13, 4], + * tag: [3, 5, 67, 56] + * }) + * })() + * ``` + * @implements {MessagingTransport} */ -class DeviceApiCall { - /** @type {string} */ - method = 'unknown'; - /** - * An optional 'id' - used to indicate if a request requires a response. - * @type {string|null} - */ - id = null; - /** @type {Params | null | undefined} */ - paramsValidator = null; - /** @type {Result | null | undefined} */ - resultValidator = null; - /** @type {import("zod").infer} */ - params; - /** - * This is a carve-out for legacy messages that are not typed yet. - * If you set this to 'true', then the response will not be checked to conform - * to any shape - * @deprecated this is here to aid migration, should be removed ASAP - * @type {boolean} - */ - throwOnResultKeysMissing = true; - /** - * New messages should be in a particular format, eg: { success: T }, - * but you can set this to false if you want to access the result as-is, - * without any unwrapping logic - * @deprecated this is here to aid migration, should be removed ASAP - * @type {boolean} - */ - unwrapResult = true; +class WebkitMessagingTransport { + /** @type {WebkitMessagingConfig} */ + config; + globals; /** - * @param {import("zod").infer} data - */ - constructor(data) { - this.params = data; + * @param {WebkitMessagingConfig} config + */ + constructor(config) { + this.config = config; + this.globals = captureGlobals(); + if (!this.config.hasModernWebkitAPI) { + this.captureWebkitHandlers(this.config.webkitMessageHandlerNames); + } } - /** - * @returns {import("zod").infer|undefined} - */ - validateParams() { - if (this.params === undefined) { - return undefined; + * Sends message to the webkit layer (fire and forget) + * @param {String} handler + * @param {*} data + * @internal + */ + wkSend(handler) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + if (!(handler in this.globals.window.webkit.messageHandlers)) { + throw new _messaging.MissingHandler(`Missing webkit handler: '${handler}'`, handler); } - this._validate(this.params, this.paramsValidator); - return this.params; + const outgoing = { + ...data, + messageHandling: { + ...data.messageHandling, + secret: this.config.secret + } + }; + if (!this.config.hasModernWebkitAPI) { + if (!(handler in this.globals.capturedWebkitHandlers)) { + throw new _messaging.MissingHandler(`cannot continue, method ${handler} not captured on macos < 11`, handler); + } else { + return this.globals.capturedWebkitHandlers[handler](outgoing); + } + } + return this.globals.window.webkit.messageHandlers[handler].postMessage?.(outgoing); } /** - * @param {any|null} incoming - * @returns {import("zod").infer} - */ - validateResult(incoming) { - this._validate(incoming, this.resultValidator); - if (!incoming) { - return incoming; - } - if (!this.unwrapResult) { - return incoming; - } - if ('data' in incoming) { - console.warn('response had `data` property. Please migrate to `success`'); - return incoming.data; - } - if ('success' in incoming) { - return incoming.success; + * Sends message to the webkit layer and waits for the specified response + * @param {String} handler + * @param {*} data + * @returns {Promise<*>} + * @internal + */ + async wkSendAndWait(handler) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + if (this.config.hasModernWebkitAPI) { + const response = await this.wkSend(handler, data); + return this.globals.JSONparse(response || '{}'); } - if ('error' in incoming) { - if (typeof incoming.error.message === 'string') { - throw new DeviceApiCallError(`${this.method}: ${incoming.error.message}`); + try { + const randMethodName = this.createRandMethodName(); + const key = await this.createRandKey(); + const iv = this.createRandIv(); + const { + ciphertext, + tag + } = await new this.globals.Promise(( /** @type {any} */resolve) => { + this.generateRandomMethod(randMethodName, resolve); + data.messageHandling = new SecureMessagingParams({ + methodName: randMethodName, + secret: this.config.secret, + key: this.globals.Arrayfrom(key), + iv: this.globals.Arrayfrom(iv) + }); + this.wkSend(handler, data); + }); + const cipher = new this.globals.Uint8Array([...ciphertext, ...tag]); + const decrypted = await this.decrypt(cipher, key, iv); + return this.globals.JSONparse(decrypted || '{}'); + } catch (e) { + // re-throw when the error is just a 'MissingHandler' + if (e instanceof _messaging.MissingHandler) { + throw e; + } else { + console.error('decryption failed', e); + console.error(e); + return { + error: e + }; } } - if (this.throwOnResultKeysMissing) { - throw new Error('unreachable. Response did not contain `success` or `data`'); - } - return incoming; } - /** - * @param {any} data - * @param {import("zod").ZodType|undefined|null} [validator] - * @private - */ - _validate(data, validator) { - if (!validator) return data; - if (validator) { - const result = validator?.safeParse(data); - if (!result) { - throw new Error('unreachable, data failure', data); - } - if (!result.success) { - if ('error' in result) { - this.throwError(result.error.issues); - } else { - console.error('unknown error from validate'); - } + * @param {string} name + * @param {Record} [data] + */ + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + this.wkSend(name, data); + } + /** + * @param {string} name + * @param {Record} [data] + */ + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return this.wkSendAndWait(name, data); + } + /** + * Generate a random method name and adds it to the global scope + * The native layer will use this method to send the response + * @param {string | number} randomMethodName + * @param {Function} callback + */ + generateRandomMethod(randomMethodName, callback) { + var _this = this; + this.globals.ObjectDefineProperty(this.globals.window, randomMethodName, { + enumerable: false, + // configurable, To allow for deletion later + configurable: true, + writable: false, + /** + * @param {any[]} args + */ + value: function () { + callback(...arguments); + // @ts-ignore - we want this to throw if it fails as it would indicate a fatal error. + delete _this.globals.window[randomMethodName]; } - } + }); + } + randomString() { + return '' + this.globals.getRandomValues(new this.globals.Uint32Array(1))[0]; + } + createRandMethodName() { + return '_' + this.randomString(); } /** - * @param {import('zod').ZodIssue[]} errors - */ - throwError(errors) { - const error = SchemaValidationError.fromZodErrors(errors, this.constructor.name); - throw error; - } + * @type {{name: string, length: number}} + */ + algoObj = { + name: 'AES-GCM', + length: 256 + }; /** - * Use this helper for creating stand-in response messages that are typed correctly. - * - * @examples - * - * ```js - * const msg = new Message(); - * const response = msg.response({}) // <-- This argument will be typed correctly - * ``` - * - * @param {import("zod").infer} response - * @returns {import("zod").infer} - */ - result(response) { - return response; + * @returns {Promise} + */ + async createRandKey() { + const key = await this.globals.generateKey(this.algoObj, true, ['encrypt', 'decrypt']); + const exportedKey = await this.globals.exportKey('raw', key); + return new this.globals.Uint8Array(exportedKey); } - /** - * @returns {import("zod").infer} - */ - preResultValidation(response) { - return response; + + /** + * @returns {Uint8Array} + */ + createRandIv() { + return this.globals.getRandomValues(new this.globals.Uint8Array(12)); } -} -exports.DeviceApiCall = DeviceApiCall; -class DeviceApiCallError extends Error {} -/** - * Check for this error if you'd like to - */ -exports.DeviceApiCallError = DeviceApiCallError; -class SchemaValidationError extends Error { - /** @type {import("zod").ZodIssue[]} */ - validationErrors = []; + /** + * @param {BufferSource} ciphertext + * @param {BufferSource} key + * @param {Uint8Array} iv + * @returns {Promise} + */ + async decrypt(ciphertext, key, iv) { + const cryptoKey = await this.globals.importKey('raw', key, 'AES-GCM', false, ['decrypt']); + const algo = { + name: 'AES-GCM', + iv + }; + let decrypted = await this.globals.decrypt(algo, cryptoKey, ciphertext); + let dec = new this.globals.TextDecoder(); + return dec.decode(decrypted); + } /** - * @param {import("zod").ZodIssue[]} errors - * @param {string} name - * @returns {SchemaValidationError} - */ - static fromZodErrors(errors, name) { - const heading = `${errors.length} SchemaValidationError(s) errors for ` + name; - function log(issue) { - switch (issue.code) { - case 'invalid_literal': - case 'invalid_type': - { - console.log(`${name}. Path: '${issue.path.join('.')}', Error: '${issue.message}'`); - break; - } - case 'invalid_union': - { - for (let unionError of issue.unionErrors) { - for (let issue1 of unionError.issues) { - log(issue1); - } - } - break; - } - default: - { - console.log(name, 'other issue:', issue); - } + * When required (such as on macos 10.x), capture the `postMessage` method on + * each webkit messageHandler + * + * @param {string[]} handlerNames + */ + captureWebkitHandlers(handlerNames) { + const handlers = window.webkit.messageHandlers; + if (!handlers) throw new _messaging.MissingHandler('window.webkit.messageHandlers was absent', 'all'); + for (let webkitMessageHandlerName of handlerNames) { + if (typeof handlers[webkitMessageHandlerName]?.postMessage === 'function') { + /** + * `bind` is used here to ensure future calls to the captured + * `postMessage` have the correct `this` context + */ + const original = handlers[webkitMessageHandlerName]; + const bound = handlers[webkitMessageHandlerName].postMessage?.bind(original); + this.globals.capturedWebkitHandlers[webkitMessageHandlerName] = bound; + delete handlers[webkitMessageHandlerName].postMessage; } } - for (let error of errors) { - log(error); - } - const message = [heading, 'please see the details above'].join('\n '); - const error = new SchemaValidationError(message); - error.validationErrors = errors; - return error; } } /** - * Creates an instance of `DeviceApiCall` from only a name and 'params' - * and optional validators. Use this to help migrate existing messages. - * - * @template {import("zod").ZodType} Params - * @template {import("zod").ZodType} Result - * @param {string} method - * @param {import("zod").infer} [params] - * @param {Params|null} [paramsValidator] - * @param {Result|null} [resultValidator] - * @returns {DeviceApiCall} - */ -exports.SchemaValidationError = SchemaValidationError; -function createDeviceApiCall(method, params) { - let paramsValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - let resultValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - /** @type {DeviceApiCall} */ - const deviceApiCall = new DeviceApiCall(params); - deviceApiCall.paramsValidator = paramsValidator; - deviceApiCall.resultValidator = resultValidator; - deviceApiCall.method = method; - deviceApiCall.throwOnResultKeysMissing = false; - deviceApiCall.unwrapResult = false; - return deviceApiCall; -} - -/** - * Creates an instance of `DeviceApiCall` from only a name and 'params' - * and optional validators. Use this to help migrate existing messages. + * Use this configuration to create an instance of {@link Messaging} for WebKit * - * Note: This creates a regular DeviceApiCall, but adds the 'id' as a string - * so that transports know that it expects a response. + * ```js + * import { fromConfig, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" * - * @template {import("zod").ZodType} Params - * @template {import("zod").ZodType} Result - * @param {string} method - * @param {import("zod").infer} [params] - * @param {string} [id] - * @param {Params|null} [paramsValidator] - * @param {Result|null} [resultValidator] - * @returns {DeviceApiCall} - */ -function createRequest(method, params) { - let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n/a'; - let paramsValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - let resultValidator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; - const call = createDeviceApiCall(method, params, paramsValidator, resultValidator); - call.id = id; - return call; -} -const createNotification = exports.createNotification = createDeviceApiCall; - -/** - * Validate any arbitrary data with any Zod validator + * const config = new WebkitMessagingConfig({ + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }); * - * @template {import("zod").ZodType} Validator - * @param {any} data - * @param {Validator | null} [validator] - * @returns {import("zod").infer} + * const messaging = new Messaging(config) + * const resp = await messaging.request("debugConfig") + * ``` */ -function validate(data) { - let validator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - if (validator) { - return validator.parse(data); +exports.WebkitMessagingTransport = WebkitMessagingTransport; +class WebkitMessagingConfig { + /** + * @param {object} params + * @param {boolean} params.hasModernWebkitAPI + * @param {string[]} params.webkitMessageHandlerNames + * @param {string} params.secret + */ + constructor(params) { + /** + * Whether or not the current WebKit Platform supports secure messaging + * by default (eg: macOS 11+) + */ + this.hasModernWebkitAPI = params.hasModernWebkitAPI; + /** + * A list of WebKit message handler names that a user script can send + */ + this.webkitMessageHandlerNames = params.webkitMessageHandlerNames; + /** + * A string provided by native platforms to be sent with future outgoing + * messages + */ + this.secret = params.secret; } - return data; } -},{}],18:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DeviceApiTransport = exports.DeviceApi = void 0; /** - * Platforms should only need to implement this `send` method + * This is the additional payload that gets appended to outgoing messages. + * It's used in the Swift side to encrypt the response that comes back */ -class DeviceApiTransport { +exports.WebkitMessagingConfig = WebkitMessagingConfig; +class SecureMessagingParams { /** - * @param {import("./device-api-call.js").DeviceApiCall} _deviceApiCall - * @param {CallOptions} [_options] - * @returns {Promise} - */ - async send(_deviceApiCall, _options) { - return undefined; + * @param {object} params + * @param {string} params.methodName + * @param {string} params.secret + * @param {number[]} params.key + * @param {number[]} params.iv + */ + constructor(params) { + /** + * The method that's been appended to `window` to be called later + */ + this.methodName = params.methodName; + /** + * The secret used to ensure message sender validity + */ + this.secret = params.secret; + /** + * The CipherKey as number[] + */ + this.key = params.key; + /** + * The Initial Vector as number[] + */ + this.iv = params.iv; } } /** - * This is the base Sender class that platforms can will implement. - * - * Note: The 'handle' method must be implemented, unless you also implement 'send' - * - * @typedef CallOptions - * @property {AbortSignal} [signal] + * Capture some globals used for messaging handling to prevent page + * scripts from tampering with this */ -exports.DeviceApiTransport = DeviceApiTransport; -class DeviceApi { - /** @type {DeviceApiTransport} */ - transport; - /** @param {DeviceApiTransport} transport */ - constructor(transport) { - this.transport = transport; - } - /** - * @template {import("./device-api-call").DeviceApiCall} D - * @param {D} deviceApiCall - * @param {CallOptions} [options] - * @returns {Promise['success']>>} - */ - async request(deviceApiCall, options) { - deviceApiCall.validateParams(); - let result = await this.transport.send(deviceApiCall, options); - let processed = deviceApiCall.preResultValidation(result); - return deviceApiCall.validateResult(processed); - } - /** - * @template {import("./device-api-call").DeviceApiCall} P - * @param {P} deviceApiCall - * @param {CallOptions} [options] - * @returns {Promise} - */ - async notify(deviceApiCall, options) { - deviceApiCall.validateParams(); - return this.transport.send(deviceApiCall, options); - } +exports.SecureMessagingParams = SecureMessagingParams; +function captureGlobals() { + // Creat base with null prototype + return { + window, + // Methods must be bound to their interface, otherwise they throw Illegal invocation + encrypt: window.crypto.subtle.encrypt.bind(window.crypto.subtle), + decrypt: window.crypto.subtle.decrypt.bind(window.crypto.subtle), + generateKey: window.crypto.subtle.generateKey.bind(window.crypto.subtle), + exportKey: window.crypto.subtle.exportKey.bind(window.crypto.subtle), + importKey: window.crypto.subtle.importKey.bind(window.crypto.subtle), + getRandomValues: window.crypto.getRandomValues.bind(window.crypto), + TextEncoder, + TextDecoder, + Uint8Array, + Uint16Array, + Uint32Array, + JSONstringify: window.JSON.stringify, + JSONparse: window.JSON.parse, + Arrayfrom: window.Array.from, + Promise: window.Promise, + ObjectDefineProperty: window.Object.defineProperty, + addEventListener: window.addEventListener.bind(window), + /** @type {Record} */ + capturedWebkitHandlers: {} + }; } -exports.DeviceApi = DeviceApi; -},{}],19:[function(require,module,exports){ +},{"./messaging.js":15}],17:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5152,7 +5067,7 @@ function _safeHostname(inputHostname) { } } -},{"./lib/apple.password.js":20,"./lib/constants.js":21,"./lib/rules-parser.js":22}],20:[function(require,module,exports){ +},{"./lib/apple.password.js":18,"./lib/constants.js":19,"./lib/rules-parser.js":20}],18:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5681,7 +5596,7 @@ class Password { } exports.Password = Password; -},{"./constants.js":21,"./rules-parser.js":22}],21:[function(require,module,exports){ +},{"./constants.js":19,"./rules-parser.js":20}],19:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5701,7 +5616,7 @@ const constants = exports.constants = { DEFAULT_UNAMBIGUOUS_CHARS }; -},{}],22:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6297,7 +6212,7 @@ function parsePasswordRules(input, formatRulesForMinifiedVersion) { return newPasswordRules; } -},{}],23:[function(require,module,exports){ +},{}],21:[function(require,module,exports){ module.exports={ "163.com": { "password-rules": "minlength: 6; maxlength: 16;" @@ -7128,7 +7043,7 @@ module.exports={ "password-rules": "minlength: 8; maxlength: 32; max-consecutive: 6; required: lower; required: upper; required: digit;" } } -},{}],24:[function(require,module,exports){ +},{}],22:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7184,7 +7099,7 @@ function createDevice() { return new _ExtensionInterface.ExtensionInterface(globalConfig, deviceApi, settings); } -},{"../packages/device-api/index.js":16,"./DeviceInterface/AndroidInterface.js":25,"./DeviceInterface/AppleDeviceInterface.js":26,"./DeviceInterface/AppleOverlayDeviceInterface.js":27,"./DeviceInterface/ExtensionInterface.js":28,"./DeviceInterface/WindowsInterface.js":30,"./DeviceInterface/WindowsOverlayDeviceInterface.js":31,"./Settings.js":52,"./config.js":65,"./deviceApiCalls/transports/transports.js":73}],25:[function(require,module,exports){ +},{"../packages/device-api/index.js":12,"./DeviceInterface/AndroidInterface.js":23,"./DeviceInterface/AppleDeviceInterface.js":24,"./DeviceInterface/AppleOverlayDeviceInterface.js":25,"./DeviceInterface/ExtensionInterface.js":26,"./DeviceInterface/WindowsInterface.js":28,"./DeviceInterface/WindowsOverlayDeviceInterface.js":29,"./Settings.js":50,"./config.js":63,"./deviceApiCalls/transports/transports.js":71}],23:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7310,7 +7225,7 @@ class AndroidInterface extends _InterfacePrototype.default { } exports.AndroidInterface = AndroidInterface; -},{"../UI/controllers/NativeUIController.js":58,"../autofill-utils.js":63,"./InterfacePrototype.js":29,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],26:[function(require,module,exports){ +},{"../UI/controllers/NativeUIController.js":56,"../autofill-utils.js":61,"./InterfacePrototype.js":27,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],24:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7696,7 +7611,7 @@ class AppleDeviceInterface extends _InterfacePrototype.default { } exports.AppleDeviceInterface = AppleDeviceInterface; -},{"../../packages/device-api/index.js":16,"../Form/matching.js":45,"../InContextSignup.js":46,"../UI/HTMLTooltip.js":56,"../UI/controllers/HTMLTooltipUIController.js":57,"../UI/controllers/NativeUIController.js":58,"../UI/controllers/OverlayUIController.js":59,"../autofill-utils.js":63,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"../deviceApiCalls/additionalDeviceApiCalls.js":69,"./InterfacePrototype.js":29,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],27:[function(require,module,exports){ +},{"../../packages/device-api/index.js":12,"../Form/matching.js":43,"../InContextSignup.js":44,"../UI/HTMLTooltip.js":54,"../UI/controllers/HTMLTooltipUIController.js":55,"../UI/controllers/NativeUIController.js":56,"../UI/controllers/OverlayUIController.js":57,"../autofill-utils.js":61,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"../deviceApiCalls/additionalDeviceApiCalls.js":67,"./InterfacePrototype.js":27,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],25:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7830,7 +7745,7 @@ class AppleOverlayDeviceInterface extends _AppleDeviceInterface.AppleDeviceInter } exports.AppleOverlayDeviceInterface = AppleOverlayDeviceInterface; -},{"../../packages/device-api/index.js":16,"../UI/controllers/HTMLTooltipUIController.js":57,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"../deviceApiCalls/__generated__/validators.zod.js":68,"./AppleDeviceInterface.js":26,"./overlayApi.js":33}],28:[function(require,module,exports){ +},{"../../packages/device-api/index.js":12,"../UI/controllers/HTMLTooltipUIController.js":55,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"../deviceApiCalls/__generated__/validators.zod.js":66,"./AppleDeviceInterface.js":24,"./overlayApi.js":31}],26:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8061,7 +7976,7 @@ class ExtensionInterface extends _InterfacePrototype.default { } exports.ExtensionInterface = ExtensionInterface; -},{"../Form/matching.js":45,"../InContextSignup.js":46,"../UI/HTMLTooltip.js":56,"../UI/controllers/HTMLTooltipUIController.js":57,"../autofill-utils.js":63,"./InterfacePrototype.js":29}],29:[function(require,module,exports){ +},{"../Form/matching.js":43,"../InContextSignup.js":44,"../UI/HTMLTooltip.js":54,"../UI/controllers/HTMLTooltipUIController.js":55,"../autofill-utils.js":61,"./InterfacePrototype.js":27}],27:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8942,7 +8857,7 @@ class InterfacePrototype { } var _default = exports.default = InterfacePrototype; -},{"../../packages/device-api/index.js":16,"../EmailProtection.js":34,"../Form/formatters.js":38,"../Form/matching.js":45,"../InputTypes/Credentials.js":47,"../PasswordGenerator.js":50,"../Scanner.js":51,"../Settings.js":52,"../UI/controllers/NativeUIController.js":58,"../autofill-utils.js":63,"../config.js":65,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"../deviceApiCalls/__generated__/validators.zod.js":68,"../deviceApiCalls/transports/transports.js":73,"./initFormSubmissionsApi.js":32}],30:[function(require,module,exports){ +},{"../../packages/device-api/index.js":12,"../EmailProtection.js":32,"../Form/formatters.js":36,"../Form/matching.js":43,"../InputTypes/Credentials.js":45,"../PasswordGenerator.js":48,"../Scanner.js":49,"../Settings.js":50,"../UI/controllers/NativeUIController.js":56,"../autofill-utils.js":61,"../config.js":63,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"../deviceApiCalls/__generated__/validators.zod.js":66,"../deviceApiCalls/transports/transports.js":71,"./initFormSubmissionsApi.js":30}],28:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9114,7 +9029,7 @@ class WindowsInterface extends _InterfacePrototype.default { } exports.WindowsInterface = WindowsInterface; -},{"../UI/controllers/OverlayUIController.js":59,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"./InterfacePrototype.js":29}],31:[function(require,module,exports){ +},{"../UI/controllers/OverlayUIController.js":57,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"./InterfacePrototype.js":27}],29:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9293,7 +9208,7 @@ class WindowsOverlayDeviceInterface extends _InterfacePrototype.default { } exports.WindowsOverlayDeviceInterface = WindowsOverlayDeviceInterface; -},{"../UI/controllers/HTMLTooltipUIController.js":57,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"./InterfacePrototype.js":29,"./overlayApi.js":33}],32:[function(require,module,exports){ +},{"../UI/controllers/HTMLTooltipUIController.js":55,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"./InterfacePrototype.js":27,"./overlayApi.js":31}],30:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9385,7 +9300,7 @@ function initFormSubmissionsApi(forms, matching) { }); } -},{"../Form/label-util.js":41,"../autofill-utils.js":63}],33:[function(require,module,exports){ +},{"../Form/label-util.js":39,"../autofill-utils.js":61}],31:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9443,7 +9358,7 @@ function overlayApi(device) { }; } -},{"../deviceApiCalls/__generated__/deviceApiCalls.js":67}],34:[function(require,module,exports){ +},{"../deviceApiCalls/__generated__/deviceApiCalls.js":65}],32:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9478,7 +9393,7 @@ class EmailProtection { } exports.EmailProtection = EmailProtection; -},{}],35:[function(require,module,exports){ +},{}],33:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10280,7 +10195,7 @@ class Form { } exports.Form = Form; -},{"../autofill-utils.js":63,"../constants.js":66,"./FormAnalyzer.js":36,"./formatters.js":38,"./inputStyles.js":39,"./inputTypeConfig.js":40,"./matching.js":45}],36:[function(require,module,exports){ +},{"../autofill-utils.js":61,"../constants.js":64,"./FormAnalyzer.js":34,"./formatters.js":36,"./inputStyles.js":37,"./inputTypeConfig.js":38,"./matching.js":43}],34:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10627,7 +10542,7 @@ class FormAnalyzer { } var _default = exports.default = FormAnalyzer; -},{"../autofill-utils.js":63,"../constants.js":66,"./matching-config/__generated__/compiled-matching-config.js":43,"./matching.js":45}],37:[function(require,module,exports){ +},{"../autofill-utils.js":61,"../constants.js":64,"./matching-config/__generated__/compiled-matching-config.js":41,"./matching.js":43}],35:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11192,7 +11107,7 @@ const COUNTRY_NAMES_TO_CODES = exports.COUNTRY_NAMES_TO_CODES = { 'Unknown Region': 'ZZ' }; -},{}],38:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11497,7 +11412,7 @@ const prepareFormValuesForStorage = formValues => { }; exports.prepareFormValuesForStorage = prepareFormValuesForStorage; -},{"./countryNames.js":37,"./matching.js":45}],39:[function(require,module,exports){ +},{"./countryNames.js":35,"./matching.js":43}],37:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11588,7 +11503,7 @@ const getIconStylesAutofilled = (input, form) => { }; exports.getIconStylesAutofilled = getIconStylesAutofilled; -},{"./inputTypeConfig.js":40}],40:[function(require,module,exports){ +},{"./inputTypeConfig.js":38}],38:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11831,7 +11746,7 @@ const isFieldDecorated = input => { }; exports.isFieldDecorated = isFieldDecorated; -},{"../InputTypes/Credentials.js":47,"../InputTypes/CreditCard.js":48,"../InputTypes/Identity.js":49,"../UI/img/ddgPasswordIcon.js":61,"../constants.js":66,"./logo-svg.js":42,"./matching.js":45}],41:[function(require,module,exports){ +},{"../InputTypes/Credentials.js":45,"../InputTypes/CreditCard.js":46,"../InputTypes/Identity.js":47,"../UI/img/ddgPasswordIcon.js":59,"../constants.js":64,"./logo-svg.js":40,"./matching.js":43}],39:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11879,7 +11794,7 @@ const extractElementStrings = element => { }; exports.extractElementStrings = extractElementStrings; -},{"./matching.js":45}],42:[function(require,module,exports){ +},{"./matching.js":43}],40:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11912,7 +11827,7 @@ const daxGrayscaleSvg = ` `.trim(); const daxGrayscaleBase64 = exports.daxGrayscaleBase64 = `data:image/svg+xml;base64,${window.btoa(daxGrayscaleSvg)}`; -},{}],43:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12358,7 +12273,7 @@ const matchingConfiguration = exports.matchingConfiguration = { } }; -},{}],44:[function(require,module,exports){ +},{}],42:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12433,7 +12348,7 @@ function logUnmatched(el, allStrings) { console.groupEnd(); } -},{"../autofill-utils.js":63,"./matching.js":45}],45:[function(require,module,exports){ +},{"../autofill-utils.js":61,"./matching.js":43}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12689,8 +12604,8 @@ class Matching { this.setActiveElementStrings(input, formEl); if (this.subtypeFromMatchers('unknown', input)) return 'unknown'; - // // For CC forms we run aggressive matches, so we want to make sure we only - // // run them on actual CC forms to avoid false positives and expensive loops + // For CC forms we run aggressive matches, so we want to make sure we only + // run them on actual CC forms to avoid false positives and expensive loops if (opts.isCCForm) { const subtype = this.subtypeFromMatchers('cc', input); if (subtype && isValidCreditCardSubtype(subtype)) { @@ -13339,7 +13254,7 @@ function createMatching() { return new Matching(_compiledMatchingConfig.matchingConfiguration); } -},{"../autofill-utils.js":63,"../constants.js":66,"./label-util.js":41,"./matching-config/__generated__/compiled-matching-config.js":43,"./matching-utils.js":44}],46:[function(require,module,exports){ +},{"../autofill-utils.js":61,"../constants.js":64,"./label-util.js":39,"./matching-config/__generated__/compiled-matching-config.js":41,"./matching-utils.js":42}],44:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13471,7 +13386,7 @@ class InContextSignup { } exports.InContextSignup = InContextSignup; -},{"./autofill-utils.js":63,"./deviceApiCalls/__generated__/deviceApiCalls.js":67}],47:[function(require,module,exports){ +},{"./autofill-utils.js":61,"./deviceApiCalls/__generated__/deviceApiCalls.js":65}],45:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13618,7 +13533,7 @@ function createCredentialsTooltipItem(data) { return new CredentialsTooltipItem(data); } -},{"../autofill-utils.js":63}],48:[function(require,module,exports){ +},{"../autofill-utils.js":61}],46:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13641,7 +13556,7 @@ class CreditCardTooltipItem { } exports.CreditCardTooltipItem = CreditCardTooltipItem; -},{}],49:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13681,7 +13596,7 @@ class IdentityTooltipItem { } exports.IdentityTooltipItem = IdentityTooltipItem; -},{"../Form/formatters.js":38}],50:[function(require,module,exports){ +},{"../Form/formatters.js":36}],48:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13723,7 +13638,7 @@ class PasswordGenerator { } exports.PasswordGenerator = PasswordGenerator; -},{"../packages/password/index.js":19,"../packages/password/rules.json":23}],51:[function(require,module,exports){ +},{"../packages/password/index.js":17,"../packages/password/rules.json":21}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14086,7 +14001,7 @@ function createScanner(device, scannerOptions) { }); } -},{"./Form/Form.js":35,"./Form/matching.js":45,"./autofill-utils.js":63,"./constants.js":66,"./deviceApiCalls/__generated__/deviceApiCalls.js":67}],52:[function(require,module,exports){ +},{"./Form/Form.js":33,"./Form/matching.js":43,"./autofill-utils.js":61,"./constants.js":64,"./deviceApiCalls/__generated__/deviceApiCalls.js":65}],50:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14431,7 +14346,7 @@ class Settings { } exports.Settings = Settings; -},{"../packages/device-api/index.js":16,"./autofill-utils.js":63,"./deviceApiCalls/__generated__/deviceApiCalls.js":67,"./deviceApiCalls/__generated__/validators.zod.js":68,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],53:[function(require,module,exports){ +},{"../packages/device-api/index.js":12,"./autofill-utils.js":61,"./deviceApiCalls/__generated__/deviceApiCalls.js":65,"./deviceApiCalls/__generated__/validators.zod.js":66,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],51:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14559,7 +14474,7 @@ ${css} } var _default = exports.default = DataHTMLTooltip; -},{"../InputTypes/Credentials.js":47,"../autofill-utils.js":63,"./HTMLTooltip.js":56}],54:[function(require,module,exports){ +},{"../InputTypes/Credentials.js":45,"../autofill-utils.js":61,"./HTMLTooltip.js":54}],52:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14637,7 +14552,7 @@ ${this.options.css} } var _default = exports.default = EmailHTMLTooltip; -},{"../autofill-utils.js":63,"./HTMLTooltip.js":56}],55:[function(require,module,exports){ +},{"../autofill-utils.js":61,"./HTMLTooltip.js":54}],53:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14693,7 +14608,7 @@ ${this.options.css} } var _default = exports.default = EmailSignupHTMLTooltip; -},{"./HTMLTooltip.js":56}],56:[function(require,module,exports){ +},{"./HTMLTooltip.js":54}],54:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15080,7 +14995,7 @@ class HTMLTooltip { exports.HTMLTooltip = HTMLTooltip; var _default = exports.default = HTMLTooltip; -},{"../Form/matching.js":45,"../autofill-utils.js":63,"./styles/styles.js":62}],57:[function(require,module,exports){ +},{"../Form/matching.js":43,"../autofill-utils.js":61,"./styles/styles.js":60}],55:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15431,7 +15346,7 @@ class HTMLTooltipUIController extends _UIController.UIController { } exports.HTMLTooltipUIController = HTMLTooltipUIController; -},{"../../Form/inputTypeConfig.js":40,"../../Form/matching.js":45,"../../autofill-utils.js":63,"../DataHTMLTooltip.js":53,"../EmailHTMLTooltip.js":54,"../EmailSignupHTMLTooltip.js":55,"../HTMLTooltip.js":56,"./UIController.js":60}],58:[function(require,module,exports){ +},{"../../Form/inputTypeConfig.js":38,"../../Form/matching.js":43,"../../autofill-utils.js":61,"../DataHTMLTooltip.js":51,"../EmailHTMLTooltip.js":52,"../EmailSignupHTMLTooltip.js":53,"../HTMLTooltip.js":54,"./UIController.js":58}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15593,7 +15508,7 @@ class NativeUIController extends _UIController.UIController { } exports.NativeUIController = NativeUIController; -},{"../../Form/matching.js":45,"../../InputTypes/Credentials.js":47,"../../deviceApiCalls/__generated__/deviceApiCalls.js":67,"./UIController.js":60}],59:[function(require,module,exports){ +},{"../../Form/matching.js":43,"../../InputTypes/Credentials.js":45,"../../deviceApiCalls/__generated__/deviceApiCalls.js":65,"./UIController.js":58}],57:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15830,7 +15745,7 @@ class OverlayUIController extends _UIController.UIController { } exports.OverlayUIController = OverlayUIController; -},{"../../Form/matching.js":45,"./UIController.js":60}],60:[function(require,module,exports){ +},{"../../Form/matching.js":43,"./UIController.js":58}],58:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15914,7 +15829,7 @@ class UIController { } exports.UIController = UIController; -},{}],61:[function(require,module,exports){ +},{}],59:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15929,7 +15844,7 @@ const ddgCcIconBase = exports.ddgCcIconBase = 'data:image/svg+xml;base64,PD94bWw const ddgCcIconFilled = exports.ddgCcIconFilled = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyN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NCAyLjgxNi0uODMgNC4yODMtLjgxMSAxLjQ2Ny4wMTggMi45MTYuMzMgNC4yNi45MTZ6TTEyIDIzYzYuMDc1IDAgMTEtNC45MjUgMTEtMTFTMTguMDc1IDEgMTIgMSAxIDUuOTI1IDEgMTJzNC45MjUgMTEgMTEgMTF6bTMtMTNjMCAxLjY1Ny0xLjM0MyAzLTMgM3MtMy0xLjM0My0zLTMgMS4zNDMtMyAzLTMgMyAxLjM0MyAzIDN6bTIgMGMwIDIuNzYxLTIuMjM5IDUtNSA1cy01LTIuMjM5LTUtNSAyLjIzOS01IDUtNSA1IDIuMjM5IDUgNXoiIGZpbGw9IiMwMDAiLz4KPC9zdmc+Cg==`; -},{}],62:[function(require,module,exports){ +},{}],60:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15938,7 +15853,7 @@ Object.defineProperty(exports, "__esModule", { exports.CSS_STYLES = void 0; const CSS_STYLES = exports.CSS_STYLES = ":root {\n color-scheme: light dark;\n}\n\n.wrapper *, .wrapper *::before, .wrapper *::after {\n box-sizing: border-box;\n}\n.wrapper {\n position: fixed;\n top: 0;\n left: 0;\n padding: 0;\n font-family: 'DDG_ProximaNova', 'Proxima Nova', system-ui, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n z-index: 2147483647;\n}\n.wrapper--data {\n font-family: 'SF Pro Text', system-ui, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n}\n:not(.top-autofill) .tooltip {\n position: absolute;\n width: 300px;\n max-width: calc(100vw - 25px);\n transform: translate(-1000px, -1000px);\n z-index: 2147483647;\n}\n.tooltip--data, #topAutofill {\n background-color: rgba(242, 240, 240, 1);\n -webkit-backdrop-filter: blur(40px);\n backdrop-filter: blur(40px);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip--data, #topAutofill {\n background: rgb(100, 98, 102, .9);\n }\n}\n.tooltip--data {\n padding: 6px;\n font-size: 13px;\n line-height: 14px;\n width: 315px;\n max-height: 290px;\n overflow-y: auto;\n}\n.top-autofill .tooltip--data {\n min-height: 100vh;\n}\n.tooltip--data.tooltip--incontext-signup {\n width: 360px;\n}\n:not(.top-autofill) .tooltip--data {\n top: 100%;\n left: 100%;\n border: 0.5px solid rgba(255, 255, 255, 0.2);\n border-radius: 6px;\n box-shadow: 0 10px 20px rgba(0, 0, 0, 0.32);\n}\n@media (prefers-color-scheme: dark) {\n :not(.top-autofill) .tooltip--data {\n border: 1px solid rgba(255, 255, 255, 0.2);\n }\n}\n:not(.top-autofill) .tooltip--email {\n top: calc(100% + 6px);\n right: calc(100% - 48px);\n padding: 8px;\n border: 1px solid #D0D0D0;\n border-radius: 10px;\n background-color: #FFFFFF;\n font-size: 14px;\n line-height: 1.3;\n color: #333333;\n box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);\n}\n.tooltip--email__caret {\n position: absolute;\n transform: translate(-1000px, -1000px);\n z-index: 2147483647;\n}\n.tooltip--email__caret::before,\n.tooltip--email__caret::after {\n content: \"\";\n width: 0;\n height: 0;\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n display: block;\n border-bottom: 8px solid #D0D0D0;\n position: absolute;\n right: -28px;\n}\n.tooltip--email__caret::before {\n border-bottom-color: #D0D0D0;\n top: -1px;\n}\n.tooltip--email__caret::after {\n border-bottom-color: #FFFFFF;\n top: 0px;\n}\n\n/* Buttons */\n.tooltip__button {\n display: flex;\n width: 100%;\n padding: 8px 8px 8px 0px;\n font-family: inherit;\n color: inherit;\n background: transparent;\n border: none;\n border-radius: 6px;\n}\n.tooltip__button.currentFocus,\n.wrapper:not(.top-autofill) .tooltip__button:hover {\n background-color: #3969EF;\n color: #FFFFFF;\n}\n\n/* Data autofill tooltip specific */\n.tooltip__button--data {\n position: relative;\n min-height: 48px;\n flex-direction: row;\n justify-content: flex-start;\n font-size: inherit;\n font-weight: 500;\n line-height: 16px;\n text-align: left;\n border-radius: 3px;\n}\n.tooltip--data__item-container {\n max-height: 220px;\n overflow: auto;\n}\n.tooltip__button--data:first-child {\n margin-top: 0;\n}\n.tooltip__button--data:last-child {\n margin-bottom: 0;\n}\n.tooltip__button--data::before {\n content: '';\n flex-shrink: 0;\n display: block;\n width: 32px;\n height: 32px;\n margin: 0 8px;\n background-size: 20px 20px;\n background-repeat: no-repeat;\n background-position: center 6px;\n}\n#provider_locked::after {\n position: absolute;\n content: '';\n flex-shrink: 0;\n display: block;\n width: 32px;\n height: 32px;\n margin: 0 8px;\n background-size: 11px 13px;\n background-repeat: no-repeat;\n background-position: right bottom;\n}\n.tooltip__button--data.currentFocus:not(.tooltip__button--data--bitwarden)::before,\n.wrapper:not(.top-autofill) .tooltip__button--data:not(.tooltip__button--data--bitwarden):hover::before {\n filter: invert(100%);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip__button--data:not(.tooltip__button--data--bitwarden)::before,\n .tooltip__button--data:not(.tooltip__button--data--bitwarden)::before {\n filter: invert(100%);\n opacity: .9;\n }\n}\n.tooltip__button__text-container {\n margin: auto 0;\n}\n.label {\n display: block;\n font-weight: 400;\n letter-spacing: -0.25px;\n color: rgba(0,0,0,.8);\n font-size: 13px;\n line-height: 1;\n}\n.label + .label {\n margin-top: 2px;\n}\n.label.label--medium {\n font-weight: 500;\n letter-spacing: -0.25px;\n color: rgba(0,0,0,.9);\n}\n.label.label--small {\n font-size: 11px;\n font-weight: 400;\n letter-spacing: 0.06px;\n color: rgba(0,0,0,0.6);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip--data .label {\n color: #ffffff;\n }\n .tooltip--data .label--medium {\n color: #ffffff;\n }\n .tooltip--data .label--small {\n color: #cdcdcd;\n }\n}\n.tooltip__button.currentFocus .label,\n.wrapper:not(.top-autofill) .tooltip__button:hover .label {\n color: #FFFFFF;\n}\n\n.tooltip__button--manage {\n font-size: 13px;\n padding: 5px 9px;\n border-radius: 3px;\n margin: 0;\n}\n\n/* Icons */\n.tooltip__button--data--credentials::before {\n background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjYzNiA4LjY4MkM5LjYzNiA1LjU0NCAxMi4xOCAzIDE1LjMxOCAzIDE4LjQ1NiAzIDIxIDUuNTQ0IDIxIDguNjgyYzAgMy4xMzgtMi41NDQgNS42ODItNS42ODIgNS42ODItLjY5MiAwLTEuMzUzLS4xMjQtMS45NjQtLjM0OS0uMzcyLS4xMzctLjc5LS4wNDEtMS4wNjYuMjQ1bC0uNzEzLjc0SDEwYy0uNTUyIDAtMSAuNDQ4LTEgMXYySDdjLS41NTIgMC0xIC40NDgtMSAxdjJIM3YtMi44ODFsNi42NjgtNi42NjhjLjI2NS0uMjY2LjM2LS42NTguMjQ0LTEuMDE1LS4xNzktLjU1MS0uMjc2LTEuMTQtLjI3Ni0xLjc1NHpNMTUuMzE4IDFjLTQuMjQyIDAtNy42ODIgMy40NC03LjY4MiA3LjY4MiAwIC42MDcuMDcxIDEuMi4yMDUgMS43NjdsLTYuNTQ4IDYuNTQ4Yy0uMTg4LjE4OC0uMjkzLjQ0Mi0uMjkzLjcwOFYyMmMwIC4yNjUuMTA1LjUyLjI5My43MDcuMTg3LjE4OC40NDIuMjkzLjcwNy4yOTNoNGMxLjEwNSAwIDItLjg5NSAyLTJ2LTFoMWMxLjEwNSAwIDItLjg5NSAyLTJ2LTFoMWMuMjcyIDAgLjUzMi0uMTEuNzItLjMwNmwuNTc3LS42Yy42NDUuMTc2IDEuMzIzLjI3IDIuMDIxLjI3IDQuMjQzIDAgNy42ODItMy40NCA3LjY4Mi03LjY4MkMyMyA0LjQzOSAxOS41NiAxIDE1LjMxOCAxek0xNSA4YzAtLjU1Mi40NDgtMSAxLTFzMSAuNDQ4IDEgMS0uNDQ4IDEtMSAxLTEtLjQ0OC0xLTF6bTEtM2MtMS42NTcgMC0zIDEuMzQzLTMgM3MxLjM0MyAzIDMgMyAzLTEuMzQzIDMtMy0xLjM0My0zLTMtM3oiIGZpbGw9IiMwMDAiIGZpbGwtb3BhY2l0eT0iLjkiLz4KPC9zdmc+');\n}\n.tooltip__button--data--creditCards::before {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+CiAgICA8cGF0aCBkPSJNNSA5Yy0uNTUyIDAtMSAuNDQ4LTEgMXYyYzAgLjU1Mi40NDggMSAxIDFoM2MuNTUyIDAgMS0uNDQ4IDEtMXYtMmMwLS41NTItLjQ0OC0xLTEtMUg1eiIgZmlsbD0iIzAwMCIvPgogICAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xIDZjMC0yLjIxIDEuNzktNCA0LTRoMTRjMi4yMSAwIDQgMS43OSA0IDR2MTJjMCAyLjIxLTEuNzkgNC00IDRINWMtMi4yMSAwLTQtMS43OS00LTRWNnptNC0yYy0xLjEwNSAwLTIgLjg5NS0yIDJ2OWgxOFY2YzAtMS4xMDUtLjg5NS0yLTItMkg1em0wIDE2Yy0xLjEwNSAwLTItLjg5NS0yLTJoMThjMCAxLjEwNS0uODk1IDItMiAySDV6IiBmaWxsPSIjMDAwIi8+Cjwvc3ZnPgo=');\n}\n.tooltip__button--data--identities::before {\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+CiAgICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEyIDIxYzIuMTQzIDAgNC4xMTEtLjc1IDUuNjU3LTItLjYyNi0uNTA2LTEuMzE4LS45MjctMi4wNi0xLjI1LTEuMS0uNDgtMi4yODUtLjczNS0zLjQ4Ni0uNzUtMS4yLS4wMTQtMi4zOTIuMjExLTMuNTA0LjY2NC0uODE3LjMzMy0xLjU4Ljc4My0yLjI2NCAxLjMzNiAxLjU0NiAxLjI1IDMuNTE0IDIgNS42NTcgMnptNC4zOTctNS4wODNjLjk2Ny40MjIgMS44NjYuOTggMi42NzIgMS42NTVDMjAuMjc5IDE2LjAzOSAyMSAxNC4xMDQgMjEgMTJjMC00Ljk3LTQuMDMtOS05LTlzLTkgNC4wMy05IDljMCAyLjEwNC43MjIgNC4wNCAxLjkzMiA1LjU3Mi44NzQtLjczNCAxLjg2LTEuMzI4IDIuOTIxLTEuNzYgMS4zNi0uNTU0IDIuODE2LS44MyA0LjI4My0uODExIDEuNDY3LjAxOCAyLjkxNi4zMyA0LjI2LjkxNnpNMTIgMjNjNi4wNzUgMCAxMS00LjkyNSAxMS0xMVMxOC4wNzUgMSAxMiAxIDEgNS45MjUgMSAxMnM0LjkyNSAxMSAxMSAxMXptMy0xM2MwIDEuNjU3LTEuMzQzIDMtMyAzcy0zLTEuMzQzLTMtMyAxLjM0My0zIDMtMyAzIDEuMzQzIDMgM3ptMiAwYzAgMi43NjEtMi4yMzkgNS01IDVzLTUtMi4yMzktNS01IDIuMjM5LTUgNS01IDUgMi4yMzkgNSA1eiIgZmlsbD0iIzAwMCIvPgo8L3N2Zz4=');\n}\n.tooltip__button--data--credentials.tooltip__button--data--bitwarden::before {\n background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIH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c2OTkgNS4zNDgwNiA0LjkxMDQ3IDUuNDA2MyA0Ljk2ODdDNS40NjU0MiA1LjAyNzgzIDUuNDk5MDQgNS4xMDc3NCA1LjUgNS4xOTEzVjUuNUg0Ljg3NVY1LjE5MTNDNC44NzU5NiA1LjEwNzc0IDQuOTA5NTggNS4wMjc4MyA0Ljk2ODcgNC45Njg3WiIgZmlsbD0iIzIyMjIyMiIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIi8+Cjwvc3ZnPgo=');\n}\n\nhr {\n display: block;\n margin: 5px 9px;\n border: none; /* reset the border */\n border-top: 1px solid rgba(0,0,0,.1);\n}\n\nhr:first-child {\n display: none;\n}\n\n@media (prefers-color-scheme: dark) {\n hr {\n border-top: 1px solid rgba(255,255,255,.2);\n }\n}\n\n#privateAddress {\n align-items: flex-start;\n}\n#personalAddress::before,\n#privateAddress::before,\n#incontextSignup::before,\n#personalAddress.currentFocus::before,\n#personalAddress:hover::before,\n#privateAddress.currentFocus::before,\n#privateAddress:hover::before {\n filter: none;\n /* This is the same icon as `daxBase64` in `src/Form/logo-svg.js` */\n background-image: url('data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiB2aWV3Qm94PSIwIDAgMTI4IDEyOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0ibTY0IDEyOGMzNS4zNDYgMCA2NC0yOC42NTQgNjQtNjRzLTI4LjY1NC02NC02NC02NC02NCAyOC42NTQtNjQgNjQgMjguNjU0IDY0IDY0IDY0eiIgZmlsbD0iI2RlNTgzMyIgZmlsbC1ydWxlPSJldmVub2RkIi8+CiAgICA8cGF0aCBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Im03MyAxMTEuNzVjMC0uNS4xMjMtLjYxNC0xLjQ2Ni0zLjc4Mi00LjIyNC04LjQ1OS04LjQ3LTIwLjM4NC02Lj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LTMuNDc1IDMuNDYyem0yLjQ0Ny00LjYwOGEuODk5Ljg5OSAwIDAgMCAtMS43OTkgMGMwIC40OTQuNDA1Ljg5NS45Ljg5NS40OTkgMCAuOS0uNC45LS44OTV6bS0yNS40NjQgMy41NDJhNC4wNDIgNC4wNDIgMCAwIDEgLTQuMDQ5IDQuMDM3IDQuMDQ1IDQuMDQ1IDAgMCAxIC00LjA1LTQuMDM3IDQuMDQ1IDQuMDQ1IDAgMCAxIDQuMDUtNC4wMzcgNC4wNDUgNC4wNDUgMCAwIDEgNC4wNSA0LjAzN3ptLTEuMTkzLTEuMzM4YTEuMDUgMS4wNSAwIDAgMCAtMi4wOTcgMCAxLjA0OCAxLjA0OCAwIDAgMCAyLjA5NyAweiIgZmlsbC1ydWxlPSJldmVub2RkIi8+CiAgICA8L2c+CiAgICA8cGF0aCBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Im02NCAxMTcuNzVjMjkuNjg1IDAgNTMuNzUtMjQuMDY1IDUzLjc1LTUzLjc1cy0yNC4wNjUtNTMuNzUtNTMuNzUtNTMuNzUtNTMuNzUgMjQuMDY1LTUzLjc1IDUzLjc1IDI0LjA2NSA1My43NSA1My43NSA1My43NXptMCA1YzMyLjQ0NyAwIDU4Ljc1LTI2LjMwMyA1OC43NS01OC43NXMtMjYuMzAzLTU4Ljc1LTU4Ljc1LTU4Ljc1LTU4Ljc1IDI2LjMwMy01OC43NSA1OC43NSAyNi4zMDMgNTguNzUgNTguNzUgNTguNzV6IiBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz4KPC9zdmc+');\n}\n\n/* Email tooltip specific */\n.tooltip__button--email {\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n font-size: 14px;\n padding: 4px 8px;\n}\n.tooltip__button--email__primary-text {\n font-weight: bold;\n}\n.tooltip__button--email__secondary-text {\n font-size: 12px;\n}\n\n/* Email Protection signup notice */\n:not(.top-autofill) .tooltip--email-signup {\n text-align: left;\n color: #222222;\n padding: 16px 20px;\n width: 380px;\n}\n\n.tooltip--email-signup h1 {\n font-weight: 700;\n font-size: 16px;\n line-height: 1.5;\n margin: 0;\n}\n\n.tooltip--email-signup p {\n font-weight: 400;\n font-size: 14px;\n line-height: 1.4;\n}\n\n.notice-controls {\n display: flex;\n}\n\n.tooltip--email-signup .notice-controls > * {\n border-radius: 8px;\n border: 0;\n cursor: pointer;\n display: inline-block;\n font-family: inherit;\n font-style: normal;\n font-weight: bold;\n padding: 8px 12px;\n text-decoration: none;\n}\n\n.notice-controls .ghost {\n margin-left: 1rem;\n}\n\n.tooltip--email-signup a.primary {\n background: #3969EF;\n color: #fff;\n}\n\n.tooltip--email-signup a.primary:hover,\n.tooltip--email-signup a.primary:focus {\n background: #2b55ca;\n}\n\n.tooltip--email-signup a.primary:active {\n background: #1e42a4;\n}\n\n.tooltip--email-signup button.ghost {\n background: transparent;\n color: #3969EF;\n}\n\n.tooltip--email-signup button.ghost:hover,\n.tooltip--email-signup button.ghost:focus {\n background-color: rgba(0, 0, 0, 0.06);\n color: #2b55ca;\n}\n\n.tooltip--email-signup button.ghost:active {\n background-color: rgba(0, 0, 0, 0.12);\n color: #1e42a4;\n}\n\n.tooltip--email-signup button.close-tooltip {\n background-color: transparent;\n background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMiAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0wLjI5Mjg5NCAwLjY1NjkwN0MwLjY4MzQxOCAwLjI2NjM4MyAxLjMxNjU4IDAuMjY2MzgzIDEuNzA3MTEgMC42NTY5MDdMNiA0Ljk0OThMMTAuMjkyOSAwLjY1NjkwN0MxMC42ODM0IDAuMjY2MzgzIDExLjMxNjYgMC4yNjYzODMgMTEuNzA3MSAwLjY1NjkwN0MxMi4wOTc2IDEuMDQ3NDMgMTIuMDk3NiAxLjY4MDYgMTEuNzA3MSAyLjA3MTEyTDcuNDE0MjEgNi4zNjQwMUwxMS43MDcxIDEwLjY1NjlDMTIuMDk3NiAxMS4wNDc0IDEyLjA5NzYgMTEuNjgwNiAxMS43MDcxIDEyLjA3MTFDMTEuMzE2NiAxMi40NjE2IDEwLjY4MzQgMTIuNDYxNiAxMC4yOTI5IDEyLjA3MTFMNiA3Ljc3ODIzTDEuNzA3MTEgMTIuMDcxMUMxLjMxNjU4IDEyLjQ2MTYgMC42ODM0MTcgMTIuNDYxNiAwLjI5Mjg5MyAxMi4wNzExQy0wLjA5NzYzMTEgMTEuNjgwNiAtMC4wOTc2MzExIDExLjA0NzQgMC4yOTI4OTMgMTAuNjU2OUw0LjU4NTc5IDYuMzY0MDFMMC4yOTI4OTQgMi4wNzExMkMtMC4wOTc2MzA2IDEuNjgwNiAtMC4wOTc2MzA2IDEuMDQ3NDMgMC4yOTI4OTQgMC42NTY5MDdaIiBmaWxsPSJibGFjayIgZmlsbC1vcGFjaXR5PSIwLjg0Ii8+Cjwvc3ZnPgo=);\n background-position: center center;\n background-repeat: no-repeat;\n border: 0;\n cursor: pointer;\n padding: 16px;\n position: absolute;\n right: 12px;\n top: 12px;\n}\n"; -},{}],63:[function(require,module,exports){ +},{}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -16494,7 +16409,7 @@ function isFormLikelyToBeUsedAsPageWrapper(form) { return formChildrenPercentage > 50; } -},{"./Form/matching.js":45}],64:[function(require,module,exports){ +},{"./Form/matching.js":43}],62:[function(require,module,exports){ "use strict"; require("./requestIdleCallback.js"); @@ -16525,7 +16440,7 @@ var _autofillUtils = require("./autofill-utils.js"); } })(); -},{"./DeviceInterface.js":24,"./autofill-utils.js":63,"./requestIdleCallback.js":75}],65:[function(require,module,exports){ +},{"./DeviceInterface.js":22,"./autofill-utils.js":61,"./requestIdleCallback.js":73}],63:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -16614,7 +16529,7 @@ function createGlobalConfig(overrides) { return config; } -},{}],66:[function(require,module,exports){ +},{}],64:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -16631,7 +16546,7 @@ const constants = exports.constants = { MAX_FORM_MUT_OBS_COUNT: 50 }; -},{}],67:[function(require,module,exports){ +},{}],65:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -16868,7 +16783,7 @@ class CloseEmailProtectionTabCall extends _deviceApi.DeviceApiCall { } exports.CloseEmailProtectionTabCall = CloseEmailProtectionTabCall; -},{"../../../packages/device-api":16,"./validators.zod.js":68}],68:[function(require,module,exports){ +},{"../../../packages/device-api":12,"./validators.zod.js":66}],66:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17260,7 +17175,7 @@ const apiSchema = exports.apiSchema = _zod.z.object({ closeEmailProtectionTab: _zod.z.record(_zod.z.unknown()).optional() }); -},{"zod":13}],69:[function(require,module,exports){ +},{"zod":9}],67:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17286,7 +17201,7 @@ class GetAlias extends _index.DeviceApiCall { } exports.GetAlias = GetAlias; -},{"../../packages/device-api/index.js":16,"./__generated__/validators.zod.js":68}],70:[function(require,module,exports){ +},{"../../packages/device-api/index.js":12,"./__generated__/validators.zod.js":66}],68:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17412,14 +17327,14 @@ function androidSpecificAvailableInputTypes(globalConfig) { }; } -},{"../../../packages/device-api/index.js":16,"../__generated__/deviceApiCalls.js":67}],71:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":12,"../__generated__/deviceApiCalls.js":65}],69:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppleTransport = void 0; -var _contentScopeUtils = require("@duckduckgo/content-scope-utils"); +var _messaging = require("../../../packages/messaging/messaging.js"); var _index = require("../../../packages/device-api/index.js"); var _deviceApiCalls = require("../__generated__/deviceApiCalls.js"); class AppleTransport extends _index.DeviceApiTransport { @@ -17427,12 +17342,12 @@ class AppleTransport extends _index.DeviceApiTransport { constructor(globalConfig) { super(); this.config = globalConfig; - const webkitConfig = new _contentScopeUtils.WebkitMessagingConfig({ + const webkitConfig = new _messaging.WebkitMessagingConfig({ hasModernWebkitAPI: this.config.hasModernWebkitAPI, webkitMessageHandlerNames: this.config.webkitMessageHandlerNames, secret: this.config.secret }); - this.messaging = new _contentScopeUtils.Messaging(webkitConfig); + this.messaging = new _messaging.Messaging(webkitConfig); } async send(deviceApiCall) { try { @@ -17443,7 +17358,7 @@ class AppleTransport extends _index.DeviceApiTransport { return this.messaging.notify(deviceApiCall.method, deviceApiCall.params || undefined); } } catch (e) { - if (e instanceof _contentScopeUtils.MissingHandler) { + if (e instanceof _messaging.MissingHandler) { if (this.config.isDDGTestMode) { console.log('MissingWebkitHandler error for:', deviceApiCall.method); } @@ -17478,7 +17393,7 @@ function appleSpecificRuntimeConfiguration(globalConfig) { }; } -},{"../../../packages/device-api/index.js":16,"../__generated__/deviceApiCalls.js":67,"@duckduckgo/content-scope-utils":2}],72:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":12,"../../../packages/messaging/messaging.js":15,"../__generated__/deviceApiCalls.js":65}],70:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17630,7 +17545,7 @@ async function extensionSpecificSetIncontextSignupPermanentlyDismissedAtCall(par }); } -},{"../../../packages/device-api/index.js":16,"../../Settings.js":52,"../../autofill-utils.js":63,"../__generated__/deviceApiCalls.js":67}],73:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":12,"../../Settings.js":50,"../../autofill-utils.js":61,"../__generated__/deviceApiCalls.js":65}],71:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17674,7 +17589,7 @@ function createTransport(globalConfig) { return new _extensionTransport.ExtensionTransport(globalConfig); } -},{"./android.transport.js":70,"./apple.transport.js":71,"./extension.transport.js":72,"./windows.transport.js":74}],74:[function(require,module,exports){ +},{"./android.transport.js":68,"./apple.transport.js":69,"./extension.transport.js":70,"./windows.transport.js":72}],72:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17759,7 +17674,7 @@ function waitForWindowsResponse(responseId, options) { }); } -},{"../../../packages/device-api/index.js":16}],75:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":12}],73:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17802,4 +17717,4 @@ window.cancelIdleCallback = window.cancelIdleCallback || function (id) { }; var _default = exports.default = {}; -},{}]},{},[64]); +},{}]},{},[62]); diff --git a/dist/autofill.js b/dist/autofill.js index 5eeb00d03..2371f2b2b 100644 --- a/dist/autofill.js +++ b/dist/autofill.js @@ -55,222 +55,402 @@ function processConfig(data, userList, preferences) { Object.defineProperty(exports, "__esModule", { value: true }); -var _messaging = require("./messaging.js"); -Object.keys(_messaging).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _messaging[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _messaging[key]; - } - }); +Object.defineProperty(exports, "DeviceApi", { + enumerable: true, + get: function () { + return _deviceApi.DeviceApi; + } }); - -},{"./messaging.js":3}],3:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true +Object.defineProperty(exports, "DeviceApiCall", { + enumerable: true, + get: function () { + return _deviceApiCall.DeviceApiCall; + } }); -exports.MissingHandler = exports.MessagingTransport = exports.Messaging = void 0; -Object.defineProperty(exports, "WebkitMessagingConfig", { +Object.defineProperty(exports, "DeviceApiTransport", { enumerable: true, get: function () { - return _webkit.WebkitMessagingConfig; + return _deviceApi.DeviceApiTransport; } }); -Object.defineProperty(exports, "WindowsMessagingConfig", { +Object.defineProperty(exports, "createNotification", { enumerable: true, get: function () { - return _windows.WindowsMessagingConfig; + return _deviceApiCall.createNotification; } }); -var _windows = require("./messaging/windows.js"); -var _webkit = require("./messaging/webkit.js"); -/** - * @module Messaging - * - * @description - * - * An abstraction for communications between JavaScript and host platforms. - * - * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) - * 2) Then use that to get an instance of the Messaging utility which allows - * you to send and receive data in a unified way - * 3) Each platform implements {@link MessagingTransport} along with its own Configuration - * - For example, to learn what configuration is required for Webkit, see: {@link "Webkit Messaging".WebkitMessagingConfig} - * - Or, to learn about how messages are sent and received in Webkit, see {@link "Webkit Messaging".WebkitMessagingTransport} - * - * @example Webkit Messaging - * - * ```js - * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // This config would be injected into the UserScript - * const injectedConfig = { - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }; - * - * // Then use that config to construct platform-specific configuration - * const config = new WebkitMessagingConfig(injectedConfig); - * - * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 - * const messaging = new Messaging(config); - * messaging.notify("hello world!", {foo: "bar"}) - * - * ``` - * - * @example Windows Messaging - * - * ```js - * import { Messaging, WindowsMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // Messaging on Windows is namespaced, so you can create multiple messaging instances - * const autofillConfig = new WindowsMessagingConfig({ featureName: "Autofill" }); - * const debugConfig = new WindowsMessagingConfig({ featureName: "Debugging" }); - * - * const autofillMessaging = new Messaging(autofillConfig); - * const debugMessaging = new Messaging(debugConfig); - * - * // Now send messages to both features as needed 🚀 - * autofillMessaging.notify("storeFormData", { "username": "dax" }) - * debugMessaging.notify("pageLoad", { time: window.performance.now() }) - * ``` - */ +Object.defineProperty(exports, "createRequest", { + enumerable: true, + get: function () { + return _deviceApiCall.createRequest; + } +}); +Object.defineProperty(exports, "validate", { + enumerable: true, + get: function () { + return _deviceApiCall.validate; + } +}); +var _deviceApiCall = require("./lib/device-api-call.js"); +var _deviceApi = require("./lib/device-api.js"); + +},{"./lib/device-api-call.js":3,"./lib/device-api.js":4}],3:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.SchemaValidationError = exports.DeviceApiCallError = exports.DeviceApiCall = void 0; +exports.createDeviceApiCall = createDeviceApiCall; +exports.createNotification = void 0; +exports.createRequest = createRequest; +exports.validate = validate; /** - * @implements {MessagingTransport} + * This roughly follows https://www.jsonrpc.org/specification + * @template {import("zod").ZodType} Params=import("zod").ZodType + * @template {import("zod").ZodType} Result=import("zod").ZodType */ -class Messaging { +class DeviceApiCall { + /** @type {string} */ + method = 'unknown'; /** - * @param {WebkitMessagingConfig | WindowsMessagingConfig} config + * An optional 'id' - used to indicate if a request requires a response. + * @type {string|null} */ - constructor(config) { - this.transport = getTransport(config); - } + id = null; + /** @type {Params | null | undefined} */ + paramsValidator = null; + /** @type {Result | null | undefined} */ + resultValidator = null; + /** @type {import("zod").infer} */ + params; /** - * Send a 'fire-and-forget' message. - * @throws - * {@link MissingHandler} - * - * @example - * - * ``` - * const messaging = new Messaging(config) - * messaging.notify("foo", {bar: "baz"}) - * ``` - * @param {string} name - * @param {Record} [data] + * This is a carve-out for legacy messages that are not typed yet. + * If you set this to 'true', then the response will not be checked to conform + * to any shape + * @deprecated this is here to aid migration, should be removed ASAP + * @type {boolean} */ - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - this.transport.notify(name, data); - } + throwOnResultKeysMissing = true; /** - * Send a request, and wait for a response - * @throws - * {@link MissingHandler} - * - * @example - * ``` - * const messaging = new Messaging(config) - * const response = await messaging.request("foo", {bar: "baz"}) - * ``` - * - * @param {string} name - * @param {Record} [data] - * @return {Promise} + * New messages should be in a particular format, eg: { success: T }, + * but you can set this to false if you want to access the result as-is, + * without any unwrapping logic + * @deprecated this is here to aid migration, should be removed ASAP + * @type {boolean} */ - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - return this.transport.request(name, data); + unwrapResult = true; + /** + * @param {import("zod").infer} data + */ + constructor(data) { + this.params = data; } -} -/** - * @interface - */ -exports.Messaging = Messaging; -class MessagingTransport { /** - * @param {string} name - * @param {Record} [data] - * @returns {void} + * @returns {import("zod").infer|undefined} */ - // @ts-ignore - ignoring a no-unused ts error, this is only an interface. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error("must implement 'notify'"); + validateParams() { + if (this.params === undefined) { + return undefined; + } + this._validate(this.params, this.paramsValidator); + return this.params; } + /** - * @param {string} name - * @param {Record} [data] - * @return {Promise} + * @param {any|null} incoming + * @returns {import("zod").infer} */ - // @ts-ignore - ignoring a no-unused ts error, this is only an interface. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error('must implement'); + validateResult(incoming) { + this._validate(incoming, this.resultValidator); + if (!incoming) { + return incoming; + } + if (!this.unwrapResult) { + return incoming; + } + if ('data' in incoming) { + console.warn('response had `data` property. Please migrate to `success`'); + return incoming.data; + } + if ('success' in incoming) { + return incoming.success; + } + if ('error' in incoming) { + if (typeof incoming.error.message === 'string') { + throw new DeviceApiCallError(`${this.method}: ${incoming.error.message}`); + } + } + if (this.throwOnResultKeysMissing) { + throw new Error('unreachable. Response did not contain `success` or `data`'); + } + return incoming; } -} -/** - * @param {WebkitMessagingConfig | WindowsMessagingConfig} config - * @returns {MessagingTransport} - */ -exports.MessagingTransport = MessagingTransport; -function getTransport(config) { - if (config instanceof _webkit.WebkitMessagingConfig) { - return new _webkit.WebkitMessagingTransport(config); - } - if (config instanceof _windows.WindowsMessagingConfig) { - return new _windows.WindowsMessagingTransport(config); + /** + * @param {any} data + * @param {import("zod").ZodType|undefined|null} [validator] + * @private + */ + _validate(data, validator) { + if (!validator) return data; + if (validator) { + const result = validator?.safeParse(data); + if (!result) { + throw new Error('unreachable, data failure', data); + } + if (!result.success) { + if ('error' in result) { + this.throwError(result.error.issues); + } else { + console.error('unknown error from validate'); + } + } + } } - throw new Error('unreachable'); -} -/** - * Thrown when a handler cannot be found - */ -class MissingHandler extends Error { /** - * @param {string} message - * @param {string} handlerName + * @param {import('zod').ZodIssue[]} errors */ - constructor(message, handlerName) { - super(message); - this.handlerName = handlerName; + throwError(errors) { + const error = SchemaValidationError.fromZodErrors(errors, this.constructor.name); + throw error; } -} -/** - * Some re-exports for convenience - */ -exports.MissingHandler = MissingHandler; + /** + * Use this helper for creating stand-in response messages that are typed correctly. + * + * @examples + * + * ```js + * const msg = new Message(); + * const response = msg.response({}) // <-- This argument will be typed correctly + * ``` + * + * @param {import("zod").infer} response + * @returns {import("zod").infer} + */ + result(response) { + return response; + } + /** + * @returns {import("zod").infer} + */ + preResultValidation(response) { + return response; + } +} +exports.DeviceApiCall = DeviceApiCall; +class DeviceApiCallError extends Error {} + +/** + * Check for this error if you'd like to + */ +exports.DeviceApiCallError = DeviceApiCallError; +class SchemaValidationError extends Error { + /** @type {import("zod").ZodIssue[]} */ + validationErrors = []; + + /** + * @param {import("zod").ZodIssue[]} errors + * @param {string} name + * @returns {SchemaValidationError} + */ + static fromZodErrors(errors, name) { + const heading = `${errors.length} SchemaValidationError(s) errors for ` + name; + function log(issue) { + switch (issue.code) { + case 'invalid_literal': + case 'invalid_type': + { + console.log(`${name}. Path: '${issue.path.join('.')}', Error: '${issue.message}'`); + break; + } + case 'invalid_union': + { + for (let unionError of issue.unionErrors) { + for (let issue1 of unionError.issues) { + log(issue1); + } + } + break; + } + default: + { + console.log(name, 'other issue:', issue); + } + } + } + for (let error of errors) { + log(error); + } + const message = [heading, 'please see the details above'].join('\n '); + const error = new SchemaValidationError(message); + error.validationErrors = errors; + return error; + } +} + +/** + * Creates an instance of `DeviceApiCall` from only a name and 'params' + * and optional validators. Use this to help migrate existing messages. + * + * @template {import("zod").ZodType} Params + * @template {import("zod").ZodType} Result + * @param {string} method + * @param {import("zod").infer} [params] + * @param {Params|null} [paramsValidator] + * @param {Result|null} [resultValidator] + * @returns {DeviceApiCall} + */ +exports.SchemaValidationError = SchemaValidationError; +function createDeviceApiCall(method, params) { + let paramsValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + let resultValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + /** @type {DeviceApiCall} */ + const deviceApiCall = new DeviceApiCall(params); + deviceApiCall.paramsValidator = paramsValidator; + deviceApiCall.resultValidator = resultValidator; + deviceApiCall.method = method; + deviceApiCall.throwOnResultKeysMissing = false; + deviceApiCall.unwrapResult = false; + return deviceApiCall; +} + +/** + * Creates an instance of `DeviceApiCall` from only a name and 'params' + * and optional validators. Use this to help migrate existing messages. + * + * Note: This creates a regular DeviceApiCall, but adds the 'id' as a string + * so that transports know that it expects a response. + * + * @template {import("zod").ZodType} Params + * @template {import("zod").ZodType} Result + * @param {string} method + * @param {import("zod").infer} [params] + * @param {string} [id] + * @param {Params|null} [paramsValidator] + * @param {Result|null} [resultValidator] + * @returns {DeviceApiCall} + */ +function createRequest(method, params) { + let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n/a'; + let paramsValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + let resultValidator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; + const call = createDeviceApiCall(method, params, paramsValidator, resultValidator); + call.id = id; + return call; +} +const createNotification = exports.createNotification = createDeviceApiCall; + +/** + * Validate any arbitrary data with any Zod validator + * + * @template {import("zod").ZodType} Validator + * @param {any} data + * @param {Validator | null} [validator] + * @returns {import("zod").infer} + */ +function validate(data) { + let validator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + if (validator) { + return validator.parse(data); + } + return data; +} -},{"./messaging/webkit.js":4,"./messaging/windows.js":5}],4:[function(require,module,exports){ +},{}],4:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebkitMessagingTransport = exports.WebkitMessagingConfig = exports.SecureMessagingParams = void 0; -var _messaging = require("../messaging.js"); +exports.DeviceApiTransport = exports.DeviceApi = void 0; /** - * @module Webkit Messaging + * Platforms should only need to implement this `send` method + */ +class DeviceApiTransport { + /** + * @param {import("./device-api-call.js").DeviceApiCall} _deviceApiCall + * @param {CallOptions} [_options] + * @returns {Promise} + */ + async send(_deviceApiCall, _options) { + return undefined; + } +} + +/** + * This is the base Sender class that platforms can will implement. + * + * Note: The 'handle' method must be implemented, unless you also implement 'send' + * + * @typedef CallOptions + * @property {AbortSignal} [signal] + */ +exports.DeviceApiTransport = DeviceApiTransport; +class DeviceApi { + /** @type {DeviceApiTransport} */ + transport; + /** @param {DeviceApiTransport} transport */ + constructor(transport) { + this.transport = transport; + } + /** + * @template {import("./device-api-call").DeviceApiCall} D + * @param {D} deviceApiCall + * @param {CallOptions} [options] + * @returns {Promise['success']>>} + */ + async request(deviceApiCall, options) { + deviceApiCall.validateParams(); + let result = await this.transport.send(deviceApiCall, options); + let processed = deviceApiCall.preResultValidation(result); + return deviceApiCall.validateResult(processed); + } + /** + * @template {import("./device-api-call").DeviceApiCall} P + * @param {P} deviceApiCall + * @param {CallOptions} [options] + * @returns {Promise} + */ + async notify(deviceApiCall, options) { + deviceApiCall.validateParams(); + return this.transport.send(deviceApiCall, options); + } +} +exports.DeviceApi = DeviceApi; + +},{}],5:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.MissingHandler = exports.MessagingTransport = exports.Messaging = void 0; +Object.defineProperty(exports, "WebkitMessagingConfig", { + enumerable: true, + get: function () { + return _webkit.WebkitMessagingConfig; + } +}); +var _webkit = require("./webkit.js"); +/** + * @module Messaging * * @description * - * A wrapper for messaging on WebKit platforms. It supports modern WebKit messageHandlers - * along with encryption for older versions (like macOS Catalina) + * An abstraction for communications between JavaScript and host platforms. * - * Note: If you wish to support Catalina then you'll need to implement the native - * part of the message handling, see {@link WebkitMessagingTransport} for details. + * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) + * 2) Then use that to get an instance of the Messaging utility which allows + * you to send and receive data in a unified way + * 3) Each platform implements {@link MessagingTransport} along with its own Configuration + * - For example, to learn what configuration is required for Webkit, see: {@link "Webkit Messaging".WebkitMessagingConfig} + * - Or, to learn about how messages are sent and received in Webkit, see {@link "Webkit Messaging".WebkitMessagingTransport} + * + * @example Webkit Messaging * * ```js * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" @@ -290,36 +470,202 @@ var _messaging = require("../messaging.js"); * messaging.notify("hello world!", {foo: "bar"}) * * ``` - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars - -/** - * @example - * On macOS 11+, this will just call through to `window.webkit.messageHandlers.x.postMessage` * - * Eg: for a `foo` message defined in Swift that accepted the payload `{"bar": "baz"}`, the following - * would occur: + * @example Windows Messaging * * ```js - * const json = await window.webkit.messageHandlers.foo.postMessage({ bar: "baz" }); - * const response = JSON.parse(json) - * ``` + * import { Messaging, WindowsMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" * - * @example - * On macOS 10 however, the process is a little more involved. A method will be appended to `window` - * that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow - * as being something along the lines of: + * // Messaging on Windows is namespaced, so you can create multiple messaging instances + * const autofillConfig = new WindowsMessagingConfig({ featureName: "Autofill" }); + * const debugConfig = new WindowsMessagingConfig({ featureName: "Debugging" }); * - * ```js - * // add the window method - * window["_0123456"] = (response) => { - * // decrypt `response` and deliver the result to the caller here - * // then remove the temporary method - * delete window["_0123456"] - * }; + * const autofillMessaging = new Messaging(autofillConfig); + * const debugMessaging = new Messaging(debugConfig); * - * // send the data + `messageHanding` values - * window.webkit.messageHandlers.foo.postMessage({ + * // Now send messages to both features as needed 🚀 + * autofillMessaging.notify("storeFormData", { "username": "dax" }) + * debugMessaging.notify("pageLoad", { time: window.performance.now() }) + * ``` + */ + +/** + * @implements {MessagingTransport} + */ +class Messaging { + /** + * @param {WebkitMessagingConfig} config + */ + constructor(config) { + this.transport = getTransport(config); + } + /** + * Send a 'fire-and-forget' message. + * @throws {Error} + * {@link MissingHandler} + * + * @example + * + * ``` + * const messaging = new Messaging(config) + * messaging.notify("foo", {bar: "baz"}) + * ``` + * @param {string} name + * @param {Record} [data] + */ + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + this.transport.notify(name, data); + } + /** + * Send a request, and wait for a response + * @throws {Error} + * {@link MissingHandler} + * + * @example + * ``` + * const messaging = new Messaging(config) + * const response = await messaging.request("foo", {bar: "baz"}) + * ``` + * + * @param {string} name + * @param {Record} [data] + * @return {Promise} + */ + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return this.transport.request(name, data); + } +} + +/** + * @interface + */ +exports.Messaging = Messaging; +class MessagingTransport { + /** + * @param {string} name + * @param {Record} [data] + * @returns {void} + */ + // @ts-ignore - ignoring a no-unused ts error, this is only an interface. + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + throw new Error("must implement 'notify'"); + } + /** + * @param {string} name + * @param {Record} [data] + * @return {Promise} + */ + // @ts-ignore - ignoring a no-unused ts error, this is only an interface. + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + throw new Error('must implement'); + } +} + +/** + * @param {WebkitMessagingConfig} config + * @returns {MessagingTransport} + */ +exports.MessagingTransport = MessagingTransport; +function getTransport(config) { + if (config instanceof _webkit.WebkitMessagingConfig) { + return new _webkit.WebkitMessagingTransport(config); + } + throw new Error('unreachable'); +} + +/** + * Thrown when a handler cannot be found + */ +class MissingHandler extends Error { + /** + * @param {string} message + * @param {string} handlerName + */ + constructor(message, handlerName) { + super(message); + this.handlerName = handlerName; + } +} + +/** + * Some re-exports for convenience + */ +exports.MissingHandler = MissingHandler; + +},{"./webkit.js":6}],6:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.WebkitMessagingTransport = exports.WebkitMessagingConfig = exports.SecureMessagingParams = void 0; +var _messaging = require("./messaging.js"); +/** + * @module Webkit Messaging + * + * @description + * + * A wrapper for messaging on WebKit platforms. It supports modern WebKit messageHandlers + * along with encryption for older versions (like macOS Catalina) + * + * Note: If you wish to support Catalina then you'll need to implement the native + * part of the message handling, see {@link WebkitMessagingTransport} for details. + * + * ```js + * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" + * + * // This config would be injected into the UserScript + * const injectedConfig = { + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }; + * + * // Then use that config to construct platform-specific configuration + * const config = new WebkitMessagingConfig(injectedConfig); + * + * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 + * const messaging = new Messaging(config); + * messaging.notify("hello world!", {foo: "bar"}) + * + * ``` + */ + +/** + * @typedef {import("./messaging").MessagingTransport} MessagingTransport + */ + +/** + * @example + * On macOS 11+, this will just call through to `window.webkit.messageHandlers.x.postMessage` + * + * Eg: for a `foo` message defined in Swift that accepted the payload `{"bar": "baz"}`, the following + * would occur: + * + * ```js + * const json = await window.webkit.messageHandlers.foo.postMessage({ bar: "baz" }); + * const response = JSON.parse(json) + * ``` + * + * @example + * On macOS 10 however, the process is a little more involved. A method will be appended to `window` + * that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow + * as being something along the lines of: + * + * ```js + * // add the window method + * window["_0123456"] = (response) => { + * // decrypt `response` and deliver the result to the caller here + * // then remove the temporary method + * delete window["_0123456"] + * }; + * + * // send the data + `messageHanding` values + * window.webkit.messageHandlers.foo.postMessage({ * bar: "baz", * messagingHandling: { * methodName: "_0123456", @@ -344,8 +690,8 @@ class WebkitMessagingTransport { config; globals; /** - * @param {WebkitMessagingConfig} config - */ + * @param {WebkitMessagingConfig} config + */ constructor(config) { this.config = config; this.globals = captureGlobals(); @@ -354,11 +700,11 @@ class WebkitMessagingTransport { } } /** - * Sends message to the webkit layer (fire and forget) - * @param {String} handler - * @param {*} data - * @internal - */ + * Sends message to the webkit layer (fire and forget) + * @param {String} handler + * @param {*} data + * @internal + */ wkSend(handler) { let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (!(handler in this.globals.window.webkit.messageHandlers)) { @@ -382,12 +728,12 @@ class WebkitMessagingTransport { } /** - * Sends message to the webkit layer and waits for the specified response - * @param {String} handler - * @param {*} data - * @returns {Promise<*>} - * @internal - */ + * Sends message to the webkit layer and waits for the specified response + * @param {String} handler + * @param {*} data + * @returns {Promise<*>} + * @internal + */ async wkSendAndWait(handler) { let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (this.config.hasModernWebkitAPI) { @@ -428,28 +774,27 @@ class WebkitMessagingTransport { } } /** - * @param {string} name - * @param {Record} [data] - */ + * @param {string} name + * @param {Record} [data] + */ notify(name) { let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; this.wkSend(name, data); } /** - * @param {string} name - * @param {Record} [data] - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars + * @param {string} name + * @param {Record} [data] + */ request(name) { let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return this.wkSendAndWait(name, data); } /** - * Generate a random method name and adds it to the global scope - * The native layer will use this method to send the response - * @param {string | number} randomMethodName - * @param {Function} callback - */ + * Generate a random method name and adds it to the global scope + * The native layer will use this method to send the response + * @param {string | number} randomMethodName + * @param {Function} callback + */ generateRandomMethod(randomMethodName, callback) { var _this = this; this.globals.ObjectDefineProperty(this.globals.window, randomMethodName, { @@ -458,8 +803,8 @@ class WebkitMessagingTransport { configurable: true, writable: false, /** - * @param {any[]} args - */ + * @param {any[]} args + */ value: function () { callback(...arguments); // @ts-ignore - we want this to throw if it fails as it would indicate a fatal error. @@ -475,16 +820,16 @@ class WebkitMessagingTransport { } /** - * @type {{name: string, length: number}} - */ + * @type {{name: string, length: number}} + */ algoObj = { name: 'AES-GCM', length: 256 }; /** - * @returns {Promise} - */ + * @returns {Promise} + */ async createRandKey() { const key = await this.globals.generateKey(this.algoObj, true, ['encrypt', 'decrypt']); const exportedKey = await this.globals.exportKey('raw', key); @@ -492,591 +837,161 @@ class WebkitMessagingTransport { } /** - * @returns {Uint8Array} - */ + * @returns {Uint8Array} + */ createRandIv() { - return this.globals.getRandomValues(new this.globals.Uint8Array(12)); - } - - /** - * @param {BufferSource} ciphertext - * @param {BufferSource} key - * @param {Uint8Array} iv - * @returns {Promise} - */ - async decrypt(ciphertext, key, iv) { - const cryptoKey = await this.globals.importKey('raw', key, 'AES-GCM', false, ['decrypt']); - const algo = { - name: 'AES-GCM', - iv - }; - let decrypted = await this.globals.decrypt(algo, cryptoKey, ciphertext); - let dec = new this.globals.TextDecoder(); - return dec.decode(decrypted); - } - - /** - * When required (such as on macos 10.x), capture the `postMessage` method on - * each webkit messageHandler - * - * @param {string[]} handlerNames - */ - captureWebkitHandlers(handlerNames) { - const handlers = window.webkit.messageHandlers; - if (!handlers) throw new _messaging.MissingHandler('window.webkit.messageHandlers was absent', 'all'); - for (let webkitMessageHandlerName of handlerNames) { - if (typeof handlers[webkitMessageHandlerName]?.postMessage === 'function') { - /** - * `bind` is used here to ensure future calls to the captured - * `postMessage` have the correct `this` context - */ - const original = handlers[webkitMessageHandlerName]; - const bound = handlers[webkitMessageHandlerName].postMessage?.bind(original); - this.globals.capturedWebkitHandlers[webkitMessageHandlerName] = bound; - delete handlers[webkitMessageHandlerName].postMessage; - } - } - } -} - -/** - * Use this configuration to create an instance of {@link Messaging} for WebKit - * - * ```js - * import { fromConfig, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * const config = new WebkitMessagingConfig({ - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }); - * - * const messaging = new Messaging(config) - * const resp = await messaging.request("debugConfig") - * ``` - */ -exports.WebkitMessagingTransport = WebkitMessagingTransport; -class WebkitMessagingConfig { - /** - * @param {object} params - * @param {boolean} params.hasModernWebkitAPI - * @param {string[]} params.webkitMessageHandlerNames - * @param {string} params.secret - */ - constructor(params) { - /** - * Whether or not the current WebKit Platform supports secure messaging - * by default (eg: macOS 11+) - */ - this.hasModernWebkitAPI = params.hasModernWebkitAPI; - /** - * A list of WebKit message handler names that a user script can send - */ - this.webkitMessageHandlerNames = params.webkitMessageHandlerNames; - /** - * A string provided by native platforms to be sent with future outgoing - * messages - */ - this.secret = params.secret; - } -} - -/** - * This is the additional payload that gets appended to outgoing messages. - * It's used in the Swift side to encrypt the response that comes back - */ -exports.WebkitMessagingConfig = WebkitMessagingConfig; -class SecureMessagingParams { - /** - * @param {object} params - * @param {string} params.methodName - * @param {string} params.secret - * @param {number[]} params.key - * @param {number[]} params.iv - */ - constructor(params) { - /** - * The method that's been appended to `window` to be called later - */ - this.methodName = params.methodName; - /** - * The secret used to ensure message sender validity - */ - this.secret = params.secret; - /** - * The CipherKey as number[] - */ - this.key = params.key; - /** - * The Initial Vector as number[] - */ - this.iv = params.iv; - } -} - -/** - * Capture some globals used for messaging handling to prevent page - * scripts from tampering with this - */ -exports.SecureMessagingParams = SecureMessagingParams; -function captureGlobals() { - // Creat base with null prototype - return { - window, - // Methods must be bound to their interface, otherwise they throw Illegal invocation - encrypt: window.crypto.subtle.encrypt.bind(window.crypto.subtle), - decrypt: window.crypto.subtle.decrypt.bind(window.crypto.subtle), - generateKey: window.crypto.subtle.generateKey.bind(window.crypto.subtle), - exportKey: window.crypto.subtle.exportKey.bind(window.crypto.subtle), - importKey: window.crypto.subtle.importKey.bind(window.crypto.subtle), - getRandomValues: window.crypto.getRandomValues.bind(window.crypto), - TextEncoder, - TextDecoder, - Uint8Array, - Uint16Array, - Uint32Array, - JSONstringify: window.JSON.stringify, - JSONparse: window.JSON.parse, - Arrayfrom: window.Array.from, - Promise: window.Promise, - ObjectDefineProperty: window.Object.defineProperty, - addEventListener: window.addEventListener.bind(window), - /** @type {Record} */ - capturedWebkitHandlers: {} - }; -} - -},{"../messaging.js":3}],5:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.WindowsMessagingTransport = exports.WindowsMessagingConfig = void 0; -var _messaging = require("../messaging.js"); -// eslint-disable-next-line @typescript-eslint/no-unused-vars - -/** - * @implements {MessagingTransport} - */ -class WindowsMessagingTransport { - config; - /** - * @param {WindowsMessagingConfig} config - */ - constructor(config) { - this.config = config; - } - /** - * @param {string} name - * @param {Record} [data] - */ - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error('todo: implement notify for windows'); - } - /** - * @param {string} name - * @param {Record} [data] - * @param {{signal?: AbortSignal}} opts - * @return {Promise} - */ - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - throw new Error('todo: implement request for windows'); - } -} -exports.WindowsMessagingTransport = WindowsMessagingTransport; -class WindowsMessagingConfig { - /** - * @param {object} params - * @param {string} params.featureName - */ - constructor(params) { - this.featureName = params.featureName; - } -} -exports.WindowsMessagingConfig = WindowsMessagingConfig; - -},{"../messaging.js":3}],6:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "DeviceApi", { - enumerable: true, - get: function () { - return _deviceApi.DeviceApi; - } -}); -Object.defineProperty(exports, "DeviceApiCall", { - enumerable: true, - get: function () { - return _deviceApiCall.DeviceApiCall; - } -}); -Object.defineProperty(exports, "DeviceApiTransport", { - enumerable: true, - get: function () { - return _deviceApi.DeviceApiTransport; - } -}); -Object.defineProperty(exports, "createNotification", { - enumerable: true, - get: function () { - return _deviceApiCall.createNotification; - } -}); -Object.defineProperty(exports, "createRequest", { - enumerable: true, - get: function () { - return _deviceApiCall.createRequest; - } -}); -Object.defineProperty(exports, "validate", { - enumerable: true, - get: function () { - return _deviceApiCall.validate; - } -}); -var _deviceApiCall = require("./lib/device-api-call.js"); -var _deviceApi = require("./lib/device-api.js"); - -},{"./lib/device-api-call.js":7,"./lib/device-api.js":8}],7:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.SchemaValidationError = exports.DeviceApiCallError = exports.DeviceApiCall = void 0; -exports.createDeviceApiCall = createDeviceApiCall; -exports.createNotification = void 0; -exports.createRequest = createRequest; -exports.validate = validate; -/** - * This roughly follows https://www.jsonrpc.org/specification - * @template {import("zod").ZodType} Params=import("zod").ZodType - * @template {import("zod").ZodType} Result=import("zod").ZodType - */ -class DeviceApiCall { - /** @type {string} */ - method = 'unknown'; - /** - * An optional 'id' - used to indicate if a request requires a response. - * @type {string|null} - */ - id = null; - /** @type {Params | null | undefined} */ - paramsValidator = null; - /** @type {Result | null | undefined} */ - resultValidator = null; - /** @type {import("zod").infer} */ - params; - /** - * This is a carve-out for legacy messages that are not typed yet. - * If you set this to 'true', then the response will not be checked to conform - * to any shape - * @deprecated this is here to aid migration, should be removed ASAP - * @type {boolean} - */ - throwOnResultKeysMissing = true; - /** - * New messages should be in a particular format, eg: { success: T }, - * but you can set this to false if you want to access the result as-is, - * without any unwrapping logic - * @deprecated this is here to aid migration, should be removed ASAP - * @type {boolean} - */ - unwrapResult = true; - /** - * @param {import("zod").infer} data - */ - constructor(data) { - this.params = data; - } - - /** - * @returns {import("zod").infer|undefined} - */ - validateParams() { - if (this.params === undefined) { - return undefined; - } - this._validate(this.params, this.paramsValidator); - return this.params; - } - - /** - * @param {any|null} incoming - * @returns {import("zod").infer} - */ - validateResult(incoming) { - this._validate(incoming, this.resultValidator); - if (!incoming) { - return incoming; - } - if (!this.unwrapResult) { - return incoming; - } - if ('data' in incoming) { - console.warn('response had `data` property. Please migrate to `success`'); - return incoming.data; - } - if ('success' in incoming) { - return incoming.success; - } - if ('error' in incoming) { - if (typeof incoming.error.message === 'string') { - throw new DeviceApiCallError(`${this.method}: ${incoming.error.message}`); - } - } - if (this.throwOnResultKeysMissing) { - throw new Error('unreachable. Response did not contain `success` or `data`'); - } - return incoming; - } - - /** - * @param {any} data - * @param {import("zod").ZodType|undefined|null} [validator] - * @private - */ - _validate(data, validator) { - if (!validator) return data; - if (validator) { - const result = validator?.safeParse(data); - if (!result) { - throw new Error('unreachable, data failure', data); - } - if (!result.success) { - if ('error' in result) { - this.throwError(result.error.issues); - } else { - console.error('unknown error from validate'); - } - } - } - } - - /** - * @param {import('zod').ZodIssue[]} errors - */ - throwError(errors) { - const error = SchemaValidationError.fromZodErrors(errors, this.constructor.name); - throw error; - } - - /** - * Use this helper for creating stand-in response messages that are typed correctly. - * - * @examples - * - * ```js - * const msg = new Message(); - * const response = msg.response({}) // <-- This argument will be typed correctly - * ``` - * - * @param {import("zod").infer} response - * @returns {import("zod").infer} - */ - result(response) { - return response; - } - /** - * @returns {import("zod").infer} - */ - preResultValidation(response) { - return response; + return this.globals.getRandomValues(new this.globals.Uint8Array(12)); } -} -exports.DeviceApiCall = DeviceApiCall; -class DeviceApiCallError extends Error {} -/** - * Check for this error if you'd like to - */ -exports.DeviceApiCallError = DeviceApiCallError; -class SchemaValidationError extends Error { - /** @type {import("zod").ZodIssue[]} */ - validationErrors = []; + /** + * @param {BufferSource} ciphertext + * @param {BufferSource} key + * @param {Uint8Array} iv + * @returns {Promise} + */ + async decrypt(ciphertext, key, iv) { + const cryptoKey = await this.globals.importKey('raw', key, 'AES-GCM', false, ['decrypt']); + const algo = { + name: 'AES-GCM', + iv + }; + let decrypted = await this.globals.decrypt(algo, cryptoKey, ciphertext); + let dec = new this.globals.TextDecoder(); + return dec.decode(decrypted); + } /** - * @param {import("zod").ZodIssue[]} errors - * @param {string} name - * @returns {SchemaValidationError} - */ - static fromZodErrors(errors, name) { - const heading = `${errors.length} SchemaValidationError(s) errors for ` + name; - function log(issue) { - switch (issue.code) { - case 'invalid_literal': - case 'invalid_type': - { - console.log(`${name}. Path: '${issue.path.join('.')}', Error: '${issue.message}'`); - break; - } - case 'invalid_union': - { - for (let unionError of issue.unionErrors) { - for (let issue1 of unionError.issues) { - log(issue1); - } - } - break; - } - default: - { - console.log(name, 'other issue:', issue); - } + * When required (such as on macos 10.x), capture the `postMessage` method on + * each webkit messageHandler + * + * @param {string[]} handlerNames + */ + captureWebkitHandlers(handlerNames) { + const handlers = window.webkit.messageHandlers; + if (!handlers) throw new _messaging.MissingHandler('window.webkit.messageHandlers was absent', 'all'); + for (let webkitMessageHandlerName of handlerNames) { + if (typeof handlers[webkitMessageHandlerName]?.postMessage === 'function') { + /** + * `bind` is used here to ensure future calls to the captured + * `postMessage` have the correct `this` context + */ + const original = handlers[webkitMessageHandlerName]; + const bound = handlers[webkitMessageHandlerName].postMessage?.bind(original); + this.globals.capturedWebkitHandlers[webkitMessageHandlerName] = bound; + delete handlers[webkitMessageHandlerName].postMessage; } } - for (let error of errors) { - log(error); - } - const message = [heading, 'please see the details above'].join('\n '); - const error = new SchemaValidationError(message); - error.validationErrors = errors; - return error; } } /** - * Creates an instance of `DeviceApiCall` from only a name and 'params' - * and optional validators. Use this to help migrate existing messages. - * - * @template {import("zod").ZodType} Params - * @template {import("zod").ZodType} Result - * @param {string} method - * @param {import("zod").infer} [params] - * @param {Params|null} [paramsValidator] - * @param {Result|null} [resultValidator] - * @returns {DeviceApiCall} - */ -exports.SchemaValidationError = SchemaValidationError; -function createDeviceApiCall(method, params) { - let paramsValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - let resultValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - /** @type {DeviceApiCall} */ - const deviceApiCall = new DeviceApiCall(params); - deviceApiCall.paramsValidator = paramsValidator; - deviceApiCall.resultValidator = resultValidator; - deviceApiCall.method = method; - deviceApiCall.throwOnResultKeysMissing = false; - deviceApiCall.unwrapResult = false; - return deviceApiCall; -} - -/** - * Creates an instance of `DeviceApiCall` from only a name and 'params' - * and optional validators. Use this to help migrate existing messages. + * Use this configuration to create an instance of {@link Messaging} for WebKit * - * Note: This creates a regular DeviceApiCall, but adds the 'id' as a string - * so that transports know that it expects a response. + * ```js + * import { fromConfig, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" * - * @template {import("zod").ZodType} Params - * @template {import("zod").ZodType} Result - * @param {string} method - * @param {import("zod").infer} [params] - * @param {string} [id] - * @param {Params|null} [paramsValidator] - * @param {Result|null} [resultValidator] - * @returns {DeviceApiCall} - */ -function createRequest(method, params) { - let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n/a'; - let paramsValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - let resultValidator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; - const call = createDeviceApiCall(method, params, paramsValidator, resultValidator); - call.id = id; - return call; -} -const createNotification = exports.createNotification = createDeviceApiCall; - -/** - * Validate any arbitrary data with any Zod validator + * const config = new WebkitMessagingConfig({ + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }); * - * @template {import("zod").ZodType} Validator - * @param {any} data - * @param {Validator | null} [validator] - * @returns {import("zod").infer} + * const messaging = new Messaging(config) + * const resp = await messaging.request("debugConfig") + * ``` */ -function validate(data) { - let validator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - if (validator) { - return validator.parse(data); +exports.WebkitMessagingTransport = WebkitMessagingTransport; +class WebkitMessagingConfig { + /** + * @param {object} params + * @param {boolean} params.hasModernWebkitAPI + * @param {string[]} params.webkitMessageHandlerNames + * @param {string} params.secret + */ + constructor(params) { + /** + * Whether or not the current WebKit Platform supports secure messaging + * by default (eg: macOS 11+) + */ + this.hasModernWebkitAPI = params.hasModernWebkitAPI; + /** + * A list of WebKit message handler names that a user script can send + */ + this.webkitMessageHandlerNames = params.webkitMessageHandlerNames; + /** + * A string provided by native platforms to be sent with future outgoing + * messages + */ + this.secret = params.secret; } - return data; } -},{}],8:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DeviceApiTransport = exports.DeviceApi = void 0; /** - * Platforms should only need to implement this `send` method + * This is the additional payload that gets appended to outgoing messages. + * It's used in the Swift side to encrypt the response that comes back */ -class DeviceApiTransport { +exports.WebkitMessagingConfig = WebkitMessagingConfig; +class SecureMessagingParams { /** - * @param {import("./device-api-call.js").DeviceApiCall} _deviceApiCall - * @param {CallOptions} [_options] - * @returns {Promise} - */ - async send(_deviceApiCall, _options) { - return undefined; + * @param {object} params + * @param {string} params.methodName + * @param {string} params.secret + * @param {number[]} params.key + * @param {number[]} params.iv + */ + constructor(params) { + /** + * The method that's been appended to `window` to be called later + */ + this.methodName = params.methodName; + /** + * The secret used to ensure message sender validity + */ + this.secret = params.secret; + /** + * The CipherKey as number[] + */ + this.key = params.key; + /** + * The Initial Vector as number[] + */ + this.iv = params.iv; } } /** - * This is the base Sender class that platforms can will implement. - * - * Note: The 'handle' method must be implemented, unless you also implement 'send' - * - * @typedef CallOptions - * @property {AbortSignal} [signal] + * Capture some globals used for messaging handling to prevent page + * scripts from tampering with this */ -exports.DeviceApiTransport = DeviceApiTransport; -class DeviceApi { - /** @type {DeviceApiTransport} */ - transport; - /** @param {DeviceApiTransport} transport */ - constructor(transport) { - this.transport = transport; - } - /** - * @template {import("./device-api-call").DeviceApiCall} D - * @param {D} deviceApiCall - * @param {CallOptions} [options] - * @returns {Promise['success']>>} - */ - async request(deviceApiCall, options) { - deviceApiCall.validateParams(); - let result = await this.transport.send(deviceApiCall, options); - let processed = deviceApiCall.preResultValidation(result); - return deviceApiCall.validateResult(processed); - } - /** - * @template {import("./device-api-call").DeviceApiCall} P - * @param {P} deviceApiCall - * @param {CallOptions} [options] - * @returns {Promise} - */ - async notify(deviceApiCall, options) { - deviceApiCall.validateParams(); - return this.transport.send(deviceApiCall, options); - } +exports.SecureMessagingParams = SecureMessagingParams; +function captureGlobals() { + // Creat base with null prototype + return { + window, + // Methods must be bound to their interface, otherwise they throw Illegal invocation + encrypt: window.crypto.subtle.encrypt.bind(window.crypto.subtle), + decrypt: window.crypto.subtle.decrypt.bind(window.crypto.subtle), + generateKey: window.crypto.subtle.generateKey.bind(window.crypto.subtle), + exportKey: window.crypto.subtle.exportKey.bind(window.crypto.subtle), + importKey: window.crypto.subtle.importKey.bind(window.crypto.subtle), + getRandomValues: window.crypto.getRandomValues.bind(window.crypto), + TextEncoder, + TextDecoder, + Uint8Array, + Uint16Array, + Uint32Array, + JSONstringify: window.JSON.stringify, + JSONparse: window.JSON.parse, + Arrayfrom: window.Array.from, + Promise: window.Promise, + ObjectDefineProperty: window.Object.defineProperty, + addEventListener: window.addEventListener.bind(window), + /** @type {Record} */ + capturedWebkitHandlers: {} + }; } -exports.DeviceApi = DeviceApi; -},{}],9:[function(require,module,exports){ +},{"./messaging.js":5}],7:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1207,7 +1122,7 @@ function _safeHostname(inputHostname) { } } -},{"./lib/apple.password.js":10,"./lib/constants.js":11,"./lib/rules-parser.js":12}],10:[function(require,module,exports){ +},{"./lib/apple.password.js":8,"./lib/constants.js":9,"./lib/rules-parser.js":10}],8:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1736,7 +1651,7 @@ class Password { } exports.Password = Password; -},{"./constants.js":11,"./rules-parser.js":12}],11:[function(require,module,exports){ +},{"./constants.js":9,"./rules-parser.js":10}],9:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1756,7 +1671,7 @@ const constants = exports.constants = { DEFAULT_UNAMBIGUOUS_CHARS }; -},{}],12:[function(require,module,exports){ +},{}],10:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -2352,7 +2267,7 @@ function parsePasswordRules(input, formatRulesForMinifiedVersion) { return newPasswordRules; } -},{}],13:[function(require,module,exports){ +},{}],11:[function(require,module,exports){ module.exports={ "163.com": { "password-rules": "minlength: 6; maxlength: 16;" @@ -3183,7 +3098,7 @@ module.exports={ "password-rules": "minlength: 8; maxlength: 32; max-consecutive: 6; required: lower; required: upper; required: digit;" } } -},{}],14:[function(require,module,exports){ +},{}],12:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3239,7 +3154,7 @@ function createDevice() { return new _ExtensionInterface.ExtensionInterface(globalConfig, deviceApi, settings); } -},{"../packages/device-api/index.js":6,"./DeviceInterface/AndroidInterface.js":15,"./DeviceInterface/AppleDeviceInterface.js":16,"./DeviceInterface/AppleOverlayDeviceInterface.js":17,"./DeviceInterface/ExtensionInterface.js":18,"./DeviceInterface/WindowsInterface.js":20,"./DeviceInterface/WindowsOverlayDeviceInterface.js":21,"./Settings.js":42,"./config.js":55,"./deviceApiCalls/transports/transports.js":63}],15:[function(require,module,exports){ +},{"../packages/device-api/index.js":2,"./DeviceInterface/AndroidInterface.js":13,"./DeviceInterface/AppleDeviceInterface.js":14,"./DeviceInterface/AppleOverlayDeviceInterface.js":15,"./DeviceInterface/ExtensionInterface.js":16,"./DeviceInterface/WindowsInterface.js":18,"./DeviceInterface/WindowsOverlayDeviceInterface.js":19,"./Settings.js":40,"./config.js":53,"./deviceApiCalls/transports/transports.js":61}],13:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3365,7 +3280,7 @@ class AndroidInterface extends _InterfacePrototype.default { } exports.AndroidInterface = AndroidInterface; -},{"../UI/controllers/NativeUIController.js":48,"../autofill-utils.js":53,"./InterfacePrototype.js":19,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],16:[function(require,module,exports){ +},{"../UI/controllers/NativeUIController.js":46,"../autofill-utils.js":51,"./InterfacePrototype.js":17,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],14:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3751,7 +3666,7 @@ class AppleDeviceInterface extends _InterfacePrototype.default { } exports.AppleDeviceInterface = AppleDeviceInterface; -},{"../../packages/device-api/index.js":6,"../Form/matching.js":35,"../InContextSignup.js":36,"../UI/HTMLTooltip.js":46,"../UI/controllers/HTMLTooltipUIController.js":47,"../UI/controllers/NativeUIController.js":48,"../UI/controllers/OverlayUIController.js":49,"../autofill-utils.js":53,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"../deviceApiCalls/additionalDeviceApiCalls.js":59,"./InterfacePrototype.js":19,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],17:[function(require,module,exports){ +},{"../../packages/device-api/index.js":2,"../Form/matching.js":33,"../InContextSignup.js":34,"../UI/HTMLTooltip.js":44,"../UI/controllers/HTMLTooltipUIController.js":45,"../UI/controllers/NativeUIController.js":46,"../UI/controllers/OverlayUIController.js":47,"../autofill-utils.js":51,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"../deviceApiCalls/additionalDeviceApiCalls.js":57,"./InterfacePrototype.js":17,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],15:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3885,7 +3800,7 @@ class AppleOverlayDeviceInterface extends _AppleDeviceInterface.AppleDeviceInter } exports.AppleOverlayDeviceInterface = AppleOverlayDeviceInterface; -},{"../../packages/device-api/index.js":6,"../UI/controllers/HTMLTooltipUIController.js":47,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"../deviceApiCalls/__generated__/validators.zod.js":58,"./AppleDeviceInterface.js":16,"./overlayApi.js":23}],18:[function(require,module,exports){ +},{"../../packages/device-api/index.js":2,"../UI/controllers/HTMLTooltipUIController.js":45,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"../deviceApiCalls/__generated__/validators.zod.js":56,"./AppleDeviceInterface.js":14,"./overlayApi.js":21}],16:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -4116,7 +4031,7 @@ class ExtensionInterface extends _InterfacePrototype.default { } exports.ExtensionInterface = ExtensionInterface; -},{"../Form/matching.js":35,"../InContextSignup.js":36,"../UI/HTMLTooltip.js":46,"../UI/controllers/HTMLTooltipUIController.js":47,"../autofill-utils.js":53,"./InterfacePrototype.js":19}],19:[function(require,module,exports){ +},{"../Form/matching.js":33,"../InContextSignup.js":34,"../UI/HTMLTooltip.js":44,"../UI/controllers/HTMLTooltipUIController.js":45,"../autofill-utils.js":51,"./InterfacePrototype.js":17}],17:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -4997,7 +4912,7 @@ class InterfacePrototype { } var _default = exports.default = InterfacePrototype; -},{"../../packages/device-api/index.js":6,"../EmailProtection.js":24,"../Form/formatters.js":28,"../Form/matching.js":35,"../InputTypes/Credentials.js":37,"../PasswordGenerator.js":40,"../Scanner.js":41,"../Settings.js":42,"../UI/controllers/NativeUIController.js":48,"../autofill-utils.js":53,"../config.js":55,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"../deviceApiCalls/__generated__/validators.zod.js":58,"../deviceApiCalls/transports/transports.js":63,"./initFormSubmissionsApi.js":22}],20:[function(require,module,exports){ +},{"../../packages/device-api/index.js":2,"../EmailProtection.js":22,"../Form/formatters.js":26,"../Form/matching.js":33,"../InputTypes/Credentials.js":35,"../PasswordGenerator.js":38,"../Scanner.js":39,"../Settings.js":40,"../UI/controllers/NativeUIController.js":46,"../autofill-utils.js":51,"../config.js":53,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"../deviceApiCalls/__generated__/validators.zod.js":56,"../deviceApiCalls/transports/transports.js":61,"./initFormSubmissionsApi.js":20}],18:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5169,7 +5084,7 @@ class WindowsInterface extends _InterfacePrototype.default { } exports.WindowsInterface = WindowsInterface; -},{"../UI/controllers/OverlayUIController.js":49,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"./InterfacePrototype.js":19}],21:[function(require,module,exports){ +},{"../UI/controllers/OverlayUIController.js":47,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"./InterfacePrototype.js":17}],19:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5348,7 +5263,7 @@ class WindowsOverlayDeviceInterface extends _InterfacePrototype.default { } exports.WindowsOverlayDeviceInterface = WindowsOverlayDeviceInterface; -},{"../UI/controllers/HTMLTooltipUIController.js":47,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"./InterfacePrototype.js":19,"./overlayApi.js":23}],22:[function(require,module,exports){ +},{"../UI/controllers/HTMLTooltipUIController.js":45,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"./InterfacePrototype.js":17,"./overlayApi.js":21}],20:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5440,7 +5355,7 @@ function initFormSubmissionsApi(forms, matching) { }); } -},{"../Form/label-util.js":31,"../autofill-utils.js":53}],23:[function(require,module,exports){ +},{"../Form/label-util.js":29,"../autofill-utils.js":51}],21:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5498,7 +5413,7 @@ function overlayApi(device) { }; } -},{"../deviceApiCalls/__generated__/deviceApiCalls.js":57}],24:[function(require,module,exports){ +},{"../deviceApiCalls/__generated__/deviceApiCalls.js":55}],22:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5533,7 +5448,7 @@ class EmailProtection { } exports.EmailProtection = EmailProtection; -},{}],25:[function(require,module,exports){ +},{}],23:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6335,7 +6250,7 @@ class Form { } exports.Form = Form; -},{"../autofill-utils.js":53,"../constants.js":56,"./FormAnalyzer.js":26,"./formatters.js":28,"./inputStyles.js":29,"./inputTypeConfig.js":30,"./matching.js":35}],26:[function(require,module,exports){ +},{"../autofill-utils.js":51,"../constants.js":54,"./FormAnalyzer.js":24,"./formatters.js":26,"./inputStyles.js":27,"./inputTypeConfig.js":28,"./matching.js":33}],24:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6682,7 +6597,7 @@ class FormAnalyzer { } var _default = exports.default = FormAnalyzer; -},{"../autofill-utils.js":53,"../constants.js":56,"./matching-config/__generated__/compiled-matching-config.js":33,"./matching.js":35}],27:[function(require,module,exports){ +},{"../autofill-utils.js":51,"../constants.js":54,"./matching-config/__generated__/compiled-matching-config.js":31,"./matching.js":33}],25:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7247,7 +7162,7 @@ const COUNTRY_NAMES_TO_CODES = exports.COUNTRY_NAMES_TO_CODES = { 'Unknown Region': 'ZZ' }; -},{}],28:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7552,7 +7467,7 @@ const prepareFormValuesForStorage = formValues => { }; exports.prepareFormValuesForStorage = prepareFormValuesForStorage; -},{"./countryNames.js":27,"./matching.js":35}],29:[function(require,module,exports){ +},{"./countryNames.js":25,"./matching.js":33}],27:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7643,7 +7558,7 @@ const getIconStylesAutofilled = (input, form) => { }; exports.getIconStylesAutofilled = getIconStylesAutofilled; -},{"./inputTypeConfig.js":30}],30:[function(require,module,exports){ +},{"./inputTypeConfig.js":28}],28:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7886,7 +7801,7 @@ const isFieldDecorated = input => { }; exports.isFieldDecorated = isFieldDecorated; -},{"../InputTypes/Credentials.js":37,"../InputTypes/CreditCard.js":38,"../InputTypes/Identity.js":39,"../UI/img/ddgPasswordIcon.js":51,"../constants.js":56,"./logo-svg.js":32,"./matching.js":35}],31:[function(require,module,exports){ +},{"../InputTypes/Credentials.js":35,"../InputTypes/CreditCard.js":36,"../InputTypes/Identity.js":37,"../UI/img/ddgPasswordIcon.js":49,"../constants.js":54,"./logo-svg.js":30,"./matching.js":33}],29:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7934,7 +7849,7 @@ const extractElementStrings = element => { }; exports.extractElementStrings = extractElementStrings; -},{"./matching.js":35}],32:[function(require,module,exports){ +},{"./matching.js":33}],30:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7967,7 +7882,7 @@ const daxGrayscaleSvg = ` `.trim(); const daxGrayscaleBase64 = exports.daxGrayscaleBase64 = `data:image/svg+xml;base64,${window.btoa(daxGrayscaleSvg)}`; -},{}],33:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8413,7 +8328,7 @@ const matchingConfiguration = exports.matchingConfiguration = { } }; -},{}],34:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8488,7 +8403,7 @@ function logUnmatched(el, allStrings) { console.groupEnd(); } -},{"../autofill-utils.js":53,"./matching.js":35}],35:[function(require,module,exports){ +},{"../autofill-utils.js":51,"./matching.js":33}],33:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8744,8 +8659,8 @@ class Matching { this.setActiveElementStrings(input, formEl); if (this.subtypeFromMatchers('unknown', input)) return 'unknown'; - // // For CC forms we run aggressive matches, so we want to make sure we only - // // run them on actual CC forms to avoid false positives and expensive loops + // For CC forms we run aggressive matches, so we want to make sure we only + // run them on actual CC forms to avoid false positives and expensive loops if (opts.isCCForm) { const subtype = this.subtypeFromMatchers('cc', input); if (subtype && isValidCreditCardSubtype(subtype)) { @@ -9394,7 +9309,7 @@ function createMatching() { return new Matching(_compiledMatchingConfig.matchingConfiguration); } -},{"../autofill-utils.js":53,"../constants.js":56,"./label-util.js":31,"./matching-config/__generated__/compiled-matching-config.js":33,"./matching-utils.js":34}],36:[function(require,module,exports){ +},{"../autofill-utils.js":51,"../constants.js":54,"./label-util.js":29,"./matching-config/__generated__/compiled-matching-config.js":31,"./matching-utils.js":32}],34:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9526,7 +9441,7 @@ class InContextSignup { } exports.InContextSignup = InContextSignup; -},{"./autofill-utils.js":53,"./deviceApiCalls/__generated__/deviceApiCalls.js":57}],37:[function(require,module,exports){ +},{"./autofill-utils.js":51,"./deviceApiCalls/__generated__/deviceApiCalls.js":55}],35:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9673,7 +9588,7 @@ function createCredentialsTooltipItem(data) { return new CredentialsTooltipItem(data); } -},{"../autofill-utils.js":53}],38:[function(require,module,exports){ +},{"../autofill-utils.js":51}],36:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9696,7 +9611,7 @@ class CreditCardTooltipItem { } exports.CreditCardTooltipItem = CreditCardTooltipItem; -},{}],39:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9736,7 +9651,7 @@ class IdentityTooltipItem { } exports.IdentityTooltipItem = IdentityTooltipItem; -},{"../Form/formatters.js":28}],40:[function(require,module,exports){ +},{"../Form/formatters.js":26}],38:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9778,7 +9693,7 @@ class PasswordGenerator { } exports.PasswordGenerator = PasswordGenerator; -},{"../packages/password/index.js":9,"../packages/password/rules.json":13}],41:[function(require,module,exports){ +},{"../packages/password/index.js":7,"../packages/password/rules.json":11}],39:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10141,7 +10056,7 @@ function createScanner(device, scannerOptions) { }); } -},{"./Form/Form.js":25,"./Form/matching.js":35,"./autofill-utils.js":53,"./constants.js":56,"./deviceApiCalls/__generated__/deviceApiCalls.js":57}],42:[function(require,module,exports){ +},{"./Form/Form.js":23,"./Form/matching.js":33,"./autofill-utils.js":51,"./constants.js":54,"./deviceApiCalls/__generated__/deviceApiCalls.js":55}],40:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10486,7 +10401,7 @@ class Settings { } exports.Settings = Settings; -},{"../packages/device-api/index.js":6,"./autofill-utils.js":53,"./deviceApiCalls/__generated__/deviceApiCalls.js":57,"./deviceApiCalls/__generated__/validators.zod.js":58,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],43:[function(require,module,exports){ +},{"../packages/device-api/index.js":2,"./autofill-utils.js":51,"./deviceApiCalls/__generated__/deviceApiCalls.js":55,"./deviceApiCalls/__generated__/validators.zod.js":56,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],41:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10614,7 +10529,7 @@ ${css} } var _default = exports.default = DataHTMLTooltip; -},{"../InputTypes/Credentials.js":37,"../autofill-utils.js":53,"./HTMLTooltip.js":46}],44:[function(require,module,exports){ +},{"../InputTypes/Credentials.js":35,"../autofill-utils.js":51,"./HTMLTooltip.js":44}],42:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10692,7 +10607,7 @@ ${this.options.css} } var _default = exports.default = EmailHTMLTooltip; -},{"../autofill-utils.js":53,"./HTMLTooltip.js":46}],45:[function(require,module,exports){ +},{"../autofill-utils.js":51,"./HTMLTooltip.js":44}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10748,7 +10663,7 @@ ${this.options.css} } var _default = exports.default = EmailSignupHTMLTooltip; -},{"./HTMLTooltip.js":46}],46:[function(require,module,exports){ +},{"./HTMLTooltip.js":44}],44:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11135,7 +11050,7 @@ class HTMLTooltip { exports.HTMLTooltip = HTMLTooltip; var _default = exports.default = HTMLTooltip; -},{"../Form/matching.js":35,"../autofill-utils.js":53,"./styles/styles.js":52}],47:[function(require,module,exports){ +},{"../Form/matching.js":33,"../autofill-utils.js":51,"./styles/styles.js":50}],45:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11486,7 +11401,7 @@ class HTMLTooltipUIController extends _UIController.UIController { } exports.HTMLTooltipUIController = HTMLTooltipUIController; -},{"../../Form/inputTypeConfig.js":30,"../../Form/matching.js":35,"../../autofill-utils.js":53,"../DataHTMLTooltip.js":43,"../EmailHTMLTooltip.js":44,"../EmailSignupHTMLTooltip.js":45,"../HTMLTooltip.js":46,"./UIController.js":50}],48:[function(require,module,exports){ +},{"../../Form/inputTypeConfig.js":28,"../../Form/matching.js":33,"../../autofill-utils.js":51,"../DataHTMLTooltip.js":41,"../EmailHTMLTooltip.js":42,"../EmailSignupHTMLTooltip.js":43,"../HTMLTooltip.js":44,"./UIController.js":48}],46:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11648,7 +11563,7 @@ class NativeUIController extends _UIController.UIController { } exports.NativeUIController = NativeUIController; -},{"../../Form/matching.js":35,"../../InputTypes/Credentials.js":37,"../../deviceApiCalls/__generated__/deviceApiCalls.js":57,"./UIController.js":50}],49:[function(require,module,exports){ +},{"../../Form/matching.js":33,"../../InputTypes/Credentials.js":35,"../../deviceApiCalls/__generated__/deviceApiCalls.js":55,"./UIController.js":48}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11885,7 +11800,7 @@ class OverlayUIController extends _UIController.UIController { } exports.OverlayUIController = OverlayUIController; -},{"../../Form/matching.js":35,"./UIController.js":50}],50:[function(require,module,exports){ +},{"../../Form/matching.js":33,"./UIController.js":48}],48:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11969,7 +11884,7 @@ class UIController { } exports.UIController = UIController; -},{}],51:[function(require,module,exports){ +},{}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11984,7 +11899,7 @@ const ddgCcIconBase = exports.ddgCcIconBase = 'data:image/svg+xml;base64,PD94bWw const ddgCcIconFilled = exports.ddgCcIconFilled = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2Zy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NzIuODc0LS43MzQgMS44Ni0xLjMyOCAyLjkyMS0xLjc2IDEuMzYtLjU1NCAyLjgxNi0uODMgNC4yODMtLjgxMSAxLjQ2Ny4wMTggMi45MTYuMzMgNC4yNi45MTZ6TTEyIDIzYzYuMDc1IDAgMTEtNC45MjUgMTEtMTFTMTguMDc1IDEgMTIgMSAxIDUuOTI1IDEgMTJzNC45MjUgMTEgMTEgMTF6bTMtMTNjMCAxLjY1Ny0xLjM0MyAzLTMgM3MtMy0xLjM0My0zLTMgMS4zNDMtMyAzLTMgMyAxLjM0MyAzIDN6bTIgMGMwIDIuNzYxLTIuMjM5IDUtNSA1cy01LTIuMjM5LTUtNSAyLjIzOS01IDUtNSA1IDIuMjM5IDUgNXoiIGZpbGw9IiMwMDAiLz4KPC9zdmc+Cg==`; -},{}],52:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11993,7 +11908,7 @@ Object.defineProperty(exports, "__esModule", { exports.CSS_STYLES = void 0; const CSS_STYLES = exports.CSS_STYLES = ":root {\n color-scheme: light dark;\n}\n\n.wrapper *, .wrapper *::before, .wrapper *::after {\n box-sizing: border-box;\n}\n.wrapper {\n position: fixed;\n top: 0;\n left: 0;\n padding: 0;\n font-family: 'DDG_ProximaNova', 'Proxima Nova', system-ui, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n z-index: 2147483647;\n}\n.wrapper--data {\n font-family: 'SF Pro Text', system-ui, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n}\n:not(.top-autofill) .tooltip {\n position: absolute;\n width: 300px;\n max-width: calc(100vw - 25px);\n transform: translate(-1000px, -1000px);\n z-index: 2147483647;\n}\n.tooltip--data, #topAutofill {\n background-color: rgba(242, 240, 240, 1);\n -webkit-backdrop-filter: blur(40px);\n backdrop-filter: blur(40px);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip--data, #topAutofill {\n background: rgb(100, 98, 102, .9);\n }\n}\n.tooltip--data {\n padding: 6px;\n font-size: 13px;\n line-height: 14px;\n width: 315px;\n max-height: 290px;\n overflow-y: auto;\n}\n.top-autofill .tooltip--data {\n min-height: 100vh;\n}\n.tooltip--data.tooltip--incontext-signup {\n width: 360px;\n}\n:not(.top-autofill) .tooltip--data {\n top: 100%;\n left: 100%;\n border: 0.5px solid rgba(255, 255, 255, 0.2);\n border-radius: 6px;\n box-shadow: 0 10px 20px rgba(0, 0, 0, 0.32);\n}\n@media (prefers-color-scheme: dark) {\n :not(.top-autofill) .tooltip--data {\n border: 1px solid rgba(255, 255, 255, 0.2);\n }\n}\n:not(.top-autofill) .tooltip--email {\n top: calc(100% + 6px);\n right: calc(100% - 48px);\n padding: 8px;\n border: 1px solid #D0D0D0;\n border-radius: 10px;\n background-color: #FFFFFF;\n font-size: 14px;\n line-height: 1.3;\n color: #333333;\n box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);\n}\n.tooltip--email__caret {\n position: absolute;\n transform: translate(-1000px, -1000px);\n z-index: 2147483647;\n}\n.tooltip--email__caret::before,\n.tooltip--email__caret::after {\n content: \"\";\n width: 0;\n height: 0;\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n display: block;\n border-bottom: 8px solid #D0D0D0;\n position: absolute;\n right: -28px;\n}\n.tooltip--email__caret::before {\n border-bottom-color: #D0D0D0;\n top: -1px;\n}\n.tooltip--email__caret::after {\n border-bottom-color: #FFFFFF;\n top: 0px;\n}\n\n/* Buttons */\n.tooltip__button {\n display: flex;\n width: 100%;\n padding: 8px 8px 8px 0px;\n font-family: inherit;\n color: inherit;\n background: transparent;\n border: none;\n border-radius: 6px;\n}\n.tooltip__button.currentFocus,\n.wrapper:not(.top-autofill) .tooltip__button:hover {\n background-color: #3969EF;\n color: #FFFFFF;\n}\n\n/* Data autofill tooltip specific */\n.tooltip__button--data {\n position: relative;\n min-height: 48px;\n flex-direction: row;\n justify-content: flex-start;\n font-size: inherit;\n font-weight: 500;\n line-height: 16px;\n text-align: left;\n border-radius: 3px;\n}\n.tooltip--data__item-container {\n max-height: 220px;\n overflow: auto;\n}\n.tooltip__button--data:first-child {\n margin-top: 0;\n}\n.tooltip__button--data:last-child {\n margin-bottom: 0;\n}\n.tooltip__button--data::before {\n content: '';\n flex-shrink: 0;\n display: block;\n width: 32px;\n height: 32px;\n margin: 0 8px;\n background-size: 20px 20px;\n background-repeat: no-repeat;\n background-position: center 6px;\n}\n#provider_locked::after {\n position: absolute;\n content: '';\n flex-shrink: 0;\n display: block;\n width: 32px;\n height: 32px;\n margin: 0 8px;\n background-size: 11px 13px;\n background-repeat: no-repeat;\n background-position: right bottom;\n}\n.tooltip__button--data.currentFocus:not(.tooltip__button--data--bitwarden)::before,\n.wrapper:not(.top-autofill) .tooltip__button--data:not(.tooltip__button--data--bitwarden):hover::before {\n filter: invert(100%);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip__button--data:not(.tooltip__button--data--bitwarden)::before,\n .tooltip__button--data:not(.tooltip__button--data--bitwarden)::before {\n filter: invert(100%);\n opacity: .9;\n }\n}\n.tooltip__button__text-container {\n margin: auto 0;\n}\n.label {\n display: block;\n font-weight: 400;\n letter-spacing: -0.25px;\n color: rgba(0,0,0,.8);\n font-size: 13px;\n line-height: 1;\n}\n.label + .label {\n margin-top: 2px;\n}\n.label.label--medium {\n font-weight: 500;\n letter-spacing: -0.25px;\n color: rgba(0,0,0,.9);\n}\n.label.label--small {\n font-size: 11px;\n font-weight: 400;\n letter-spacing: 0.06px;\n color: rgba(0,0,0,0.6);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip--data .label {\n color: #ffffff;\n }\n .tooltip--data .label--medium {\n color: #ffffff;\n }\n .tooltip--data .label--small {\n color: #cdcdcd;\n }\n}\n.tooltip__button.currentFocus .label,\n.wrapper:not(.top-autofill) .tooltip__button:hover .label {\n color: #FFFFFF;\n}\n\n.tooltip__button--manage {\n font-size: 13px;\n padding: 5px 9px;\n border-radius: 3px;\n margin: 0;\n}\n\n/* Icons */\n.tooltip__button--data--credentials::before {\n background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjYzNiA4LjY4MkM5LjYzNiA1LjU0NCAxMi4xOCAzIDE1LjMxOCAzIDE4LjQ1NiAzIDIxIDUuNTQ0IDIxIDguNjgyYzAgMy4xMzgtMi41NDQgNS42ODItNS42ODIgNS42ODItLjY5MiAwLTEuMzUzLS4xMjQtMS45NjQtLjM0OS0uMzcyLS4xMzctLjc5LS4wNDEtMS4wNjYuMjQ1bC0uNzEzLjc0SDEwYy0uNTUyIDAtMSAuNDQ4LTEgMXYySDdjLS41NTIgMC0xIC40NDgtMSAxdjJIM3YtMi44ODFsNi42NjgtNi42NjhjLjI2NS0uMjY2LjM2LS42NTguMjQ0LTEuMDE1LS4xNzktLjU1MS0uMjc2LTEuMTQtLjI3Ni0xLjc1NHpNMTUuMzE4IDFjLTQuMjQyIDAtNy42ODIgMy40NC03LjY4MiA3LjY4MiAwIC42MDcuMDcxIDEuMi4yMDUgMS43NjdsLTYuNTQ4IDYuNTQ4Yy0uMTg4LjE4OC0uMjkzLjQ0Mi0uMjkzLjcwOFYyMmMwIC4yNjUuMTA1LjUyLjI5My43MDcuMTg3LjE4OC40NDIuMjkzLjcwNy4yOTNoNGMxLjEwNSAwIDItLjg5NSAyLTJ2LTFoMWMxLjEwNSAwIDItLjg5NSAyLTJ2LTFoMWMuMjcyIDAgLjUzMi0uMTEuNzItLjMwNmwuNTc3LS42Yy42NDUuMTc2IDEuMzIzLjI3IDIuMDIxLjI3IDQuMjQzIDAgNy42ODItMy40NCA3LjY4Mi03LjY4MkMyMyA0LjQzOSAxOS41NiAxIDE1LjMxOCAxek0xNSA4YzAtLjU1Mi40NDgtMSAxLTFzMSAuNDQ4IDEgMS0uNDQ4IDEtMSAxLTEtLjQ0OC0xLTF6bTEtM2MtMS42NTcgMC0zIDEuMzQzLTMgM3MxLjM0MyAzIDMgMyAzLTEuMzQzIDMtMy0xLjM0My0zLTMtM3oiIGZpbGw9IiMwMDAiIGZpbGwtb3BhY2l0eT0iLjkiLz4KPC9zdmc+');\n}\n.tooltip__button--data--creditCards::before {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+CiAgICA8cGF0aCBkPSJNNSA5Yy0uNTUyIDAtMSAuNDQ4LTEgMXYyYzAgLjU1Mi40NDggMSAxIDFoM2MuNTUyIDAgMS0uNDQ4IDEtMXYtMmMwLS41NTItLjQ0OC0xLTEtMUg1eiIgZmlsbD0iIzAwMCIvPgogICAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xIDZjMC0yLjIxIDEuNzktNCA0LTRoMTRjMi4yMSAwIDQgMS43OSA0IDR2MTJjMCAyLjIxLTEuNzkgNC00IDRINWMtMi4yMSAwLTQtMS43OS00LTRWNnptNC0yYy0xLjEwNSAwLTIgLjg5NS0yIDJ2OWgxOFY2YzAtMS4xMDUtLjg5NS0yLTItMkg1em0wIDE2Yy0xLjEwNSAwLTItLjg5NS0yLTJoMThjMCAxLjEwNS0uODk1IDItMiAySDV6IiBmaWxsPSIjMDAwIi8+Cjwvc3ZnPgo=');\n}\n.tooltip__button--data--identities::before {\n background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+CiAgICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEyIDIxYzIuMTQzIDAgNC4xMTEtLjc1IDUuNjU3LTItLjYyNi0uNTA2LTEuMzE4LS45MjctMi4wNi0xLjI1LTEuMS0uNDgtMi4yODUtLjczNS0zLjQ4Ni0uNzUtMS4yLS4wMTQtMi4zOTIuMjExLTMuNTA0LjY2NC0uODE3LjMzMy0xLjU4Ljc4My0yLjI2NCAxLjMzNiAxLjU0NiAxLjI1IDMuNTE0IDIgNS42NTcgMnptNC4zOTctNS4wODNjLjk2Ny40MjIgMS44NjYuOTggMi42NzIgMS42NTVDMjAuMjc5IDE2LjAzOSAyMSAxNC4xMDQgMjEgMTJjMC00Ljk3LTQuMDMtOS05LTlzLTkgNC4wMy05IDljMCAyLjEwNC43MjIgNC4wNCAxLjkzMiA1LjU3Mi44NzQtLjczNCAxLjg2LTEuMzI4IDIuOTIxLTEuNzYgMS4zNi0uNTU0IDIuODE2LS44MyA0LjI4My0uODExIDEuNDY3LjAxOCAyLjkxNi4zMyA0LjI2LjkxNnpNMTIgMjNjNi4wNzUgMCAxMS00LjkyNSAxMS0xMVMxOC4wNzUgMSAxMiAxIDEgNS45MjUgMSAxMnM0LjkyNSAxMSAxMSAxMXptMy0xM2MwIDEuNjU3LTEuMzQzIDMtMyAzcy0zLTEuMzQzLTMtMyAxLjM0My0zIDMtMyAzIDEuMzQzIDMgM3ptMiAwYzAgMi43NjEtMi4yMzkgNS01IDVzLTUtMi4yMzktNS01IDIuMjM5LTUgNS01IDUgMi4yMzkgNSA1eiIgZmlsbD0iIzAwMCIvPgo8L3N2Zz4=');\n}\n.tooltip__button--data--credentials.tooltip__button--data--bitwarden::before {\n background-image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DUuMTA1MzIgNC44NzY5OSA1LjE4NzUgNC44NzUwN0M1LjI2OTY4IDQuODc2OTkgNS4zNDgwNiA0LjkxMDQ3IDUuNDA2MyA0Ljk2ODdDNS40NjU0MiA1LjAyNzgzIDUuNDk5MDQgNS4xMDc3NCA1LjUgNS4xOTEzVjUuNUg0Ljg3NVY1LjE5MTNDNC44NzU5NiA1LjEwNzc0IDQuOTA5NTggNS4wMjc4MyA0Ljk2ODcgNC45Njg3WiIgZmlsbD0iIzIyMjIyMiIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIi8+Cjwvc3ZnPgo=');\n}\n\nhr {\n display: block;\n margin: 5px 9px;\n border: none; /* reset the border */\n border-top: 1px solid rgba(0,0,0,.1);\n}\n\nhr:first-child {\n display: none;\n}\n\n@media (prefers-color-scheme: dark) {\n hr {\n border-top: 1px solid rgba(255,255,255,.2);\n }\n}\n\n#privateAddress {\n align-items: flex-start;\n}\n#personalAddress::before,\n#privateAddress::before,\n#incontextSignup::before,\n#personalAddress.currentFocus::before,\n#personalAddress:hover::before,\n#privateAddress.currentFocus::before,\n#privateAddress:hover::before {\n filter: none;\n /* This is the same icon as `daxBase64` in `src/Form/logo-svg.js` */\n background-image: url('data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiB2aWV3Qm94PSIwIDAgMTI4IDEyOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0ibTY0IDEyOGMzNS4zNDYgMCA2NC0yOC42NTQgNjQtNjRzLTI4LjY1NC02NC02NC02NC02NCAyOC42NTQtNjQgNjQgMjguNjU0IDY0IDY0IDY0eiIgZmlsbD0iI2RlNTgzMyIgZmlsbC1ydWxlPSJldmVub2RkIi8+CiAgICA8cGF0aCBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Im03MyAxMTEuNzVjMC0uNS4xMjMtLjYxN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Q3IDMuNDcgMCAwIDEgMy40NzQgMy40NiAzLjQ3IDMuNDcgMCAwIDEgLTMuNDc1IDMuNDYyem0yLjQ0Ny00LjYwOGEuODk5Ljg5OSAwIDAgMCAtMS43OTkgMGMwIC40OTQuNDA1Ljg5NS45Ljg5NS40OTkgMCAuOS0uNC45LS44OTV6bS0yNS40NjQgMy41NDJhNC4wNDIgNC4wNDIgMCAwIDEgLTQuMDQ5IDQuMDM3IDQuMDQ1IDQuMDQ1IDAgMCAxIC00LjA1LTQuMDM3IDQuMDQ1IDQuMDQ1IDAgMCAxIDQuMDUtNC4wMzcgNC4wNDUgNC4wNDUgMCAwIDEgNC4wNSA0LjAzN3ptLTEuMTkzLTEuMzM4YTEuMDUgMS4wNSAwIDAgMCAtMi4wOTcgMCAxLjA0OCAxLjA0OCAwIDAgMCAyLjA5NyAweiIgZmlsbC1ydWxlPSJldmVub2RkIi8+CiAgICA8L2c+CiAgICA8cGF0aCBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Im02NCAxMTcuNzVjMjkuNjg1IDAgNTMuNzUtMjQuMDY1IDUzLjc1LTUzLjc1cy0yNC4wNjUtNTMuNzUtNTMuNzUtNTMuNzUtNTMuNzUgMjQuMDY1LTUzLjc1IDUzLjc1IDI0LjA2NSA1My43NSA1My43NSA1My43NXptMCA1YzMyLjQ0NyAwIDU4Ljc1LTI2LjMwMyA1OC43NS01OC43NXMtMjYuMzAzLTU4Ljc1LTU4Ljc1LTU4Ljc1LTU4Ljc1IDI2LjMwMy01OC43NSA1OC43NSAyNi4zMDMgNTguNzUgNTguNzUgNTguNzV6IiBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz4KPC9zdmc+');\n}\n\n/* Email tooltip specific */\n.tooltip__button--email {\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n font-size: 14px;\n padding: 4px 8px;\n}\n.tooltip__button--email__primary-text {\n font-weight: bold;\n}\n.tooltip__button--email__secondary-text {\n font-size: 12px;\n}\n\n/* Email Protection signup notice */\n:not(.top-autofill) .tooltip--email-signup {\n text-align: left;\n color: #222222;\n padding: 16px 20px;\n width: 380px;\n}\n\n.tooltip--email-signup h1 {\n font-weight: 700;\n font-size: 16px;\n line-height: 1.5;\n margin: 0;\n}\n\n.tooltip--email-signup p {\n font-weight: 400;\n font-size: 14px;\n line-height: 1.4;\n}\n\n.notice-controls {\n display: flex;\n}\n\n.tooltip--email-signup .notice-controls > * {\n border-radius: 8px;\n border: 0;\n cursor: pointer;\n display: inline-block;\n font-family: inherit;\n font-style: normal;\n font-weight: bold;\n padding: 8px 12px;\n text-decoration: none;\n}\n\n.notice-controls .ghost {\n margin-left: 1rem;\n}\n\n.tooltip--email-signup a.primary {\n background: #3969EF;\n color: #fff;\n}\n\n.tooltip--email-signup a.primary:hover,\n.tooltip--email-signup a.primary:focus {\n background: #2b55ca;\n}\n\n.tooltip--email-signup a.primary:active {\n background: #1e42a4;\n}\n\n.tooltip--email-signup button.ghost {\n background: transparent;\n color: #3969EF;\n}\n\n.tooltip--email-signup button.ghost:hover,\n.tooltip--email-signup button.ghost:focus {\n background-color: rgba(0, 0, 0, 0.06);\n color: #2b55ca;\n}\n\n.tooltip--email-signup button.ghost:active {\n background-color: rgba(0, 0, 0, 0.12);\n color: #1e42a4;\n}\n\n.tooltip--email-signup button.close-tooltip {\n background-color: transparent;\n background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMiAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0wLjI5Mjg5NCAwLjY1NjkwN0MwLjY4MzQxOCAwLjI2NjM4MyAxLjMxNjU4IDAuMjY2MzgzIDEuNzA3MTEgMC42NTY5MDdMNiA0Ljk0OThMMTAuMjkyOSAwLjY1NjkwN0MxMC42ODM0IDAuMjY2MzgzIDExLjMxNjYgMC4yNjYzODMgMTEuNzA3MSAwLjY1NjkwN0MxMi4wOTc2IDEuMDQ3NDMgMTIuMDk3NiAxLjY4MDYgMTEuNzA3MSAyLjA3MTEyTDcuNDE0MjEgNi4zNjQwMUwxMS43MDcxIDEwLjY1NjlDMTIuMDk3NiAxMS4wNDc0IDEyLjA5NzYgMTEuNjgwNiAxMS43MDcxIDEyLjA3MTFDMTEuMzE2NiAxMi40NjE2IDEwLjY4MzQgMTIuNDYxNiAxMC4yOTI5IDEyLjA3MTFMNiA3Ljc3ODIzTDEuNzA3MTEgMTIuMDcxMUMxLjMxNjU4IDEyLjQ2MTYgMC42ODM0MTcgMTIuNDYxNiAwLjI5Mjg5MyAxMi4wNzExQy0wLjA5NzYzMTEgMTEuNjgwNiAtMC4wOTc2MzExIDExLjA0NzQgMC4yOTI4OTMgMTAuNjU2OUw0LjU4NTc5IDYuMzY0MDFMMC4yOTI4OTQgMi4wNzExMkMtMC4wOTc2MzA2IDEuNjgwNiAtMC4wOTc2MzA2IDEuMDQ3NDMgMC4yOTI4OTQgMC42NTY5MDdaIiBmaWxsPSJibGFjayIgZmlsbC1vcGFjaXR5PSIwLjg0Ii8+Cjwvc3ZnPgo=);\n background-position: center center;\n background-repeat: no-repeat;\n border: 0;\n cursor: pointer;\n padding: 16px;\n position: absolute;\n right: 12px;\n top: 12px;\n}\n"; -},{}],53:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12549,7 +12464,7 @@ function isFormLikelyToBeUsedAsPageWrapper(form) { return formChildrenPercentage > 50; } -},{"./Form/matching.js":35}],54:[function(require,module,exports){ +},{"./Form/matching.js":33}],52:[function(require,module,exports){ "use strict"; require("./requestIdleCallback.js"); @@ -12580,7 +12495,7 @@ var _autofillUtils = require("./autofill-utils.js"); } })(); -},{"./DeviceInterface.js":14,"./autofill-utils.js":53,"./requestIdleCallback.js":65}],55:[function(require,module,exports){ +},{"./DeviceInterface.js":12,"./autofill-utils.js":51,"./requestIdleCallback.js":63}],53:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12669,7 +12584,7 @@ function createGlobalConfig(overrides) { return config; } -},{}],56:[function(require,module,exports){ +},{}],54:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12686,7 +12601,7 @@ const constants = exports.constants = { MAX_FORM_MUT_OBS_COUNT: 50 }; -},{}],57:[function(require,module,exports){ +},{}],55:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12923,7 +12838,7 @@ class CloseEmailProtectionTabCall extends _deviceApi.DeviceApiCall { } exports.CloseEmailProtectionTabCall = CloseEmailProtectionTabCall; -},{"../../../packages/device-api":6,"./validators.zod.js":58}],58:[function(require,module,exports){ +},{"../../../packages/device-api":2,"./validators.zod.js":56}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12969,7 +12884,7 @@ const askToUnlockProviderResultSchema = exports.askToUnlockProviderResultSchema const checkCredentialsProviderStatusResultSchema = exports.checkCredentialsProviderStatusResultSchema = null; const apiSchema = exports.apiSchema = null; -},{}],59:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12995,7 +12910,7 @@ class GetAlias extends _index.DeviceApiCall { } exports.GetAlias = GetAlias; -},{"../../packages/device-api/index.js":6,"./__generated__/validators.zod.js":58}],60:[function(require,module,exports){ +},{"../../packages/device-api/index.js":2,"./__generated__/validators.zod.js":56}],58:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13121,14 +13036,14 @@ function androidSpecificAvailableInputTypes(globalConfig) { }; } -},{"../../../packages/device-api/index.js":6,"../__generated__/deviceApiCalls.js":57}],61:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":2,"../__generated__/deviceApiCalls.js":55}],59:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppleTransport = void 0; -var _contentScopeUtils = require("@duckduckgo/content-scope-utils"); +var _messaging = require("../../../packages/messaging/messaging.js"); var _index = require("../../../packages/device-api/index.js"); var _deviceApiCalls = require("../__generated__/deviceApiCalls.js"); class AppleTransport extends _index.DeviceApiTransport { @@ -13136,12 +13051,12 @@ class AppleTransport extends _index.DeviceApiTransport { constructor(globalConfig) { super(); this.config = globalConfig; - const webkitConfig = new _contentScopeUtils.WebkitMessagingConfig({ + const webkitConfig = new _messaging.WebkitMessagingConfig({ hasModernWebkitAPI: this.config.hasModernWebkitAPI, webkitMessageHandlerNames: this.config.webkitMessageHandlerNames, secret: this.config.secret }); - this.messaging = new _contentScopeUtils.Messaging(webkitConfig); + this.messaging = new _messaging.Messaging(webkitConfig); } async send(deviceApiCall) { try { @@ -13152,7 +13067,7 @@ class AppleTransport extends _index.DeviceApiTransport { return this.messaging.notify(deviceApiCall.method, deviceApiCall.params || undefined); } } catch (e) { - if (e instanceof _contentScopeUtils.MissingHandler) { + if (e instanceof _messaging.MissingHandler) { if (this.config.isDDGTestMode) { console.log('MissingWebkitHandler error for:', deviceApiCall.method); } @@ -13187,7 +13102,7 @@ function appleSpecificRuntimeConfiguration(globalConfig) { }; } -},{"../../../packages/device-api/index.js":6,"../__generated__/deviceApiCalls.js":57,"@duckduckgo/content-scope-utils":2}],62:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":2,"../../../packages/messaging/messaging.js":5,"../__generated__/deviceApiCalls.js":55}],60:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13339,7 +13254,7 @@ async function extensionSpecificSetIncontextSignupPermanentlyDismissedAtCall(par }); } -},{"../../../packages/device-api/index.js":6,"../../Settings.js":42,"../../autofill-utils.js":53,"../__generated__/deviceApiCalls.js":57}],63:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":2,"../../Settings.js":40,"../../autofill-utils.js":51,"../__generated__/deviceApiCalls.js":55}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13383,7 +13298,7 @@ function createTransport(globalConfig) { return new _extensionTransport.ExtensionTransport(globalConfig); } -},{"./android.transport.js":60,"./apple.transport.js":61,"./extension.transport.js":62,"./windows.transport.js":64}],64:[function(require,module,exports){ +},{"./android.transport.js":58,"./apple.transport.js":59,"./extension.transport.js":60,"./windows.transport.js":62}],62:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13468,7 +13383,7 @@ function waitForWindowsResponse(responseId, options) { }); } -},{"../../../packages/device-api/index.js":6}],65:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":2}],63:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13511,4 +13426,4 @@ window.cancelIdleCallback = window.cancelIdleCallback || function (id) { }; var _default = exports.default = {}; -},{}]},{},[54]); +},{}]},{},[52]); diff --git a/package-lock.json b/package-lock.json index 323c1ec4b..54b9a3427 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "@babel/eslint-parser": "^7.22.15", "@babel/preset-env": "^7.22.20", "@duckduckgo/content-scope-scripts": "github:duckduckgo/content-scope-scripts#1.3.0", - "@duckduckgo/content-scope-utils": "github:duckduckgo/content-scope-utils#1.0.2", "@playwright/test": "^1.38.1", "@types/jest": "^29.5.5", "@types/node": "^18.17.19", @@ -1857,12 +1856,6 @@ "sjcl": "^1.0.8" } }, - "node_modules/@duckduckgo/content-scope-utils": { - "version": "1.0.0", - "resolved": "git+ssh://git@github.com/duckduckgo/content-scope-utils.git#97b233e9b257c0b11d4aebb74656ed15a63660ae", - "dev": true, - "license": "ISC" - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -15721,11 +15714,6 @@ "sjcl": "^1.0.8" } }, - "@duckduckgo/content-scope-utils": { - "version": "git+ssh://git@github.com/duckduckgo/content-scope-utils.git#97b233e9b257c0b11d4aebb74656ed15a63660ae", - "dev": true, - "from": "@duckduckgo/content-scope-utils@github:duckduckgo/content-scope-utils#1.0.2" - }, "@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", diff --git a/swift-package/Resources/assets/autofill-debug.js b/swift-package/Resources/assets/autofill-debug.js index 6cad1f558..4d7388a9c 100644 --- a/swift-package/Resources/assets/autofill-debug.js +++ b/swift-package/Resources/assets/autofill-debug.js @@ -55,796 +55,437 @@ function processConfig(data, userList, preferences) { Object.defineProperty(exports, "__esModule", { value: true }); -var _messaging = require("./messaging.js"); -Object.keys(_messaging).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _messaging[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _messaging[key]; +exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0; +const util_1 = require("./helpers/util"); +exports.ZodIssueCode = util_1.util.arrayToEnum(["invalid_type", "invalid_literal", "custom", "invalid_union", "invalid_union_discriminator", "invalid_enum_value", "unrecognized_keys", "invalid_arguments", "invalid_return_type", "invalid_date", "invalid_string", "too_small", "too_big", "invalid_intersection_types", "not_multiple_of", "not_finite"]); +const quotelessJson = obj => { + const json = JSON.stringify(obj, null, 2); + return json.replace(/"([^"]+)":/g, "$1:"); +}; +exports.quotelessJson = quotelessJson; +class ZodError extends Error { + constructor(issues) { + var _this; + super(); + _this = this; + this.issues = []; + this.addIssue = sub => { + this.issues = [...this.issues, sub]; + }; + this.addIssues = function () { + let subs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + _this.issues = [..._this.issues, ...subs]; + }; + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } else { + this.__proto__ = actualProto; } - }); -}); - -},{"./messaging.js":3}],3:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.MissingHandler = exports.MessagingTransport = exports.Messaging = void 0; -Object.defineProperty(exports, "WebkitMessagingConfig", { - enumerable: true, - get: function () { - return _webkit.WebkitMessagingConfig; - } -}); -Object.defineProperty(exports, "WindowsMessagingConfig", { - enumerable: true, - get: function () { - return _windows.WindowsMessagingConfig; - } -}); -var _windows = require("./messaging/windows.js"); -var _webkit = require("./messaging/webkit.js"); -/** - * @module Messaging - * - * @description - * - * An abstraction for communications between JavaScript and host platforms. - * - * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) - * 2) Then use that to get an instance of the Messaging utility which allows - * you to send and receive data in a unified way - * 3) Each platform implements {@link MessagingTransport} along with its own Configuration - * - For example, to learn what configuration is required for Webkit, see: {@link "Webkit Messaging".WebkitMessagingConfig} - * - Or, to learn about how messages are sent and received in Webkit, see {@link "Webkit Messaging".WebkitMessagingTransport} - * - * @example Webkit Messaging - * - * ```js - * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // This config would be injected into the UserScript - * const injectedConfig = { - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }; - * - * // Then use that config to construct platform-specific configuration - * const config = new WebkitMessagingConfig(injectedConfig); - * - * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 - * const messaging = new Messaging(config); - * messaging.notify("hello world!", {foo: "bar"}) - * - * ``` - * - * @example Windows Messaging - * - * ```js - * import { Messaging, WindowsMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // Messaging on Windows is namespaced, so you can create multiple messaging instances - * const autofillConfig = new WindowsMessagingConfig({ featureName: "Autofill" }); - * const debugConfig = new WindowsMessagingConfig({ featureName: "Debugging" }); - * - * const autofillMessaging = new Messaging(autofillConfig); - * const debugMessaging = new Messaging(debugConfig); - * - * // Now send messages to both features as needed 🚀 - * autofillMessaging.notify("storeFormData", { "username": "dax" }) - * debugMessaging.notify("pageLoad", { time: window.performance.now() }) - * ``` - */ - -/** - * @implements {MessagingTransport} - */ -class Messaging { - /** - * @param {WebkitMessagingConfig | WindowsMessagingConfig} config - */ - constructor(config) { - this.transport = getTransport(config); + this.name = "ZodError"; + this.issues = issues; } - /** - * Send a 'fire-and-forget' message. - * @throws - * {@link MissingHandler} - * - * @example - * - * ``` - * const messaging = new Messaging(config) - * messaging.notify("foo", {bar: "baz"}) - * ``` - * @param {string} name - * @param {Record} [data] - */ - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - this.transport.notify(name, data); + get errors() { + return this.issues; } - /** - * Send a request, and wait for a response - * @throws - * {@link MissingHandler} - * - * @example - * ``` - * const messaging = new Messaging(config) - * const response = await messaging.request("foo", {bar: "baz"}) - * ``` - * - * @param {string} name - * @param {Record} [data] - * @return {Promise} - */ - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - return this.transport.request(name, data); + format(_mapper) { + const mapper = _mapper || function (issue) { + return issue.message; + }; + const fieldErrors = { + _errors: [] + }; + const processError = error => { + for (const issue of error.issues) { + if (issue.code === "invalid_union") { + issue.unionErrors.map(processError); + } else if (issue.code === "invalid_return_type") { + processError(issue.returnTypeError); + } else if (issue.code === "invalid_arguments") { + processError(issue.argumentsError); + } else if (issue.path.length === 0) { + fieldErrors._errors.push(mapper(issue)); + } else { + let curr = fieldErrors; + let i = 0; + while (i < issue.path.length) { + const el = issue.path[i]; + const terminal = i === issue.path.length - 1; + if (!terminal) { + curr[el] = curr[el] || { + _errors: [] + }; + } else { + curr[el] = curr[el] || { + _errors: [] + }; + curr[el]._errors.push(mapper(issue)); + } + curr = curr[el]; + i++; + } + } + } + }; + processError(this); + return fieldErrors; } -} - -/** - * @interface - */ -exports.Messaging = Messaging; -class MessagingTransport { - /** - * @param {string} name - * @param {Record} [data] - * @returns {void} - */ - // @ts-ignore - ignoring a no-unused ts error, this is only an interface. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error("must implement 'notify'"); + toString() { + return this.message; } - /** - * @param {string} name - * @param {Record} [data] - * @return {Promise} - */ - // @ts-ignore - ignoring a no-unused ts error, this is only an interface. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error('must implement'); + get message() { + return JSON.stringify(this.issues, util_1.util.jsonStringifyReplacer, 2); } -} - -/** - * @param {WebkitMessagingConfig | WindowsMessagingConfig} config - * @returns {MessagingTransport} - */ -exports.MessagingTransport = MessagingTransport; -function getTransport(config) { - if (config instanceof _webkit.WebkitMessagingConfig) { - return new _webkit.WebkitMessagingTransport(config); + get isEmpty() { + return this.issues.length === 0; } - if (config instanceof _windows.WindowsMessagingConfig) { - return new _windows.WindowsMessagingTransport(config); + flatten() { + let mapper = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : issue => issue.message; + const fieldErrors = {}; + const formErrors = []; + for (const sub of this.issues) { + if (sub.path.length > 0) { + fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; + fieldErrors[sub.path[0]].push(mapper(sub)); + } else { + formErrors.push(mapper(sub)); + } + } + return { + formErrors, + fieldErrors + }; } - throw new Error('unreachable'); -} - -/** - * Thrown when a handler cannot be found - */ -class MissingHandler extends Error { - /** - * @param {string} message - * @param {string} handlerName - */ - constructor(message, handlerName) { - super(message); - this.handlerName = handlerName; + get formErrors() { + return this.flatten(); } } +exports.ZodError = ZodError; +ZodError.create = issues => { + const error = new ZodError(issues); + return error; +}; -/** - * Some re-exports for convenience - */ -exports.MissingHandler = MissingHandler; - -},{"./messaging/webkit.js":4,"./messaging/windows.js":5}],4:[function(require,module,exports){ +},{"./helpers/util":8}],3:[function(require,module,exports){ "use strict"; -Object.defineProperty(exports, "__esModule", { +var __importDefault = void 0 && (void 0).__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebkitMessagingTransport = exports.WebkitMessagingConfig = exports.SecureMessagingParams = void 0; -var _messaging = require("../messaging.js"); -/** - * @module Webkit Messaging - * - * @description - * - * A wrapper for messaging on WebKit platforms. It supports modern WebKit messageHandlers - * along with encryption for older versions (like macOS Catalina) - * - * Note: If you wish to support Catalina then you'll need to implement the native - * part of the message handling, see {@link WebkitMessagingTransport} for details. - * - * ```js - * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // This config would be injected into the UserScript - * const injectedConfig = { - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }; - * - * // Then use that config to construct platform-specific configuration - * const config = new WebkitMessagingConfig(injectedConfig); - * - * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 - * const messaging = new Messaging(config); - * messaging.notify("hello world!", {foo: "bar"}) - * - * ``` - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars +exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = void 0; +const en_1 = __importDefault(require("./locales/en")); +exports.defaultErrorMap = en_1.default; +let overrideErrorMap = en_1.default; +function setErrorMap(map) { + overrideErrorMap = map; +} +exports.setErrorMap = setErrorMap; +function getErrorMap() { + return overrideErrorMap; +} +exports.getErrorMap = getErrorMap; -/** - * @example - * On macOS 11+, this will just call through to `window.webkit.messageHandlers.x.postMessage` - * - * Eg: for a `foo` message defined in Swift that accepted the payload `{"bar": "baz"}`, the following - * would occur: - * - * ```js - * const json = await window.webkit.messageHandlers.foo.postMessage({ bar: "baz" }); - * const response = JSON.parse(json) - * ``` - * - * @example - * On macOS 10 however, the process is a little more involved. A method will be appended to `window` - * that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow - * as being something along the lines of: - * - * ```js - * // add the window method - * window["_0123456"] = (response) => { - * // decrypt `response` and deliver the result to the caller here - * // then remove the temporary method - * delete window["_0123456"] - * }; - * - * // send the data + `messageHanding` values - * window.webkit.messageHandlers.foo.postMessage({ - * bar: "baz", - * messagingHandling: { - * methodName: "_0123456", - * secret: "super-secret", - * key: [1, 2, 45, 2], - * iv: [34, 4, 43], - * } - * }); - * - * // later in swift, the following JavaScript snippet will be executed - * (() => { - * window["_0123456"]({ - * ciphertext: [12, 13, 4], - * tag: [3, 5, 67, 56] - * }) - * })() - * ``` - * @implements {MessagingTransport} - */ -class WebkitMessagingTransport { - /** @type {WebkitMessagingConfig} */ - config; - globals; - /** - * @param {WebkitMessagingConfig} config - */ - constructor(config) { - this.config = config; - this.globals = captureGlobals(); - if (!this.config.hasModernWebkitAPI) { - this.captureWebkitHandlers(this.config.webkitMessageHandlerNames); +},{"./locales/en":10}],4:[function(require,module,exports){ +"use strict"; + +var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { + enumerable: true, + get: function () { + return m[k]; } + }); +} : function (o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); +var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { + value: true +}); +__exportStar(require("./errors"), exports); +__exportStar(require("./helpers/parseUtil"), exports); +__exportStar(require("./helpers/typeAliases"), exports); +__exportStar(require("./helpers/util"), exports); +__exportStar(require("./types"), exports); +__exportStar(require("./ZodError"), exports); + +},{"./ZodError":2,"./errors":3,"./helpers/parseUtil":6,"./helpers/typeAliases":7,"./helpers/util":8,"./types":11}],5:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.errorUtil = void 0; +var errorUtil; +(function (errorUtil) { + errorUtil.errToObj = message => typeof message === "string" ? { + message + } : message || {}; + errorUtil.toString = message => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; +})(errorUtil = exports.errorUtil || (exports.errorUtil = {})); + +},{}],6:[function(require,module,exports){ +"use strict"; + +var __importDefault = void 0 && (void 0).__importDefault || function (mod) { + return mod && mod.__esModule ? mod : { + "default": mod + }; +}; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0; +const errors_1 = require("../errors"); +const en_1 = __importDefault(require("../locales/en")); +const makeIssue = params => { + const { + data, + path, + errorMaps, + issueData + } = params; + const fullPath = [...path, ...(issueData.path || [])]; + const fullIssue = { + ...issueData, + path: fullPath + }; + let errorMessage = ""; + const maps = errorMaps.filter(m => !!m).slice().reverse(); + for (const map of maps) { + errorMessage = map(fullIssue, { + data, + defaultError: errorMessage + }).message; } - /** - * Sends message to the webkit layer (fire and forget) - * @param {String} handler - * @param {*} data - * @internal - */ - wkSend(handler) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (!(handler in this.globals.window.webkit.messageHandlers)) { - throw new _messaging.MissingHandler(`Missing webkit handler: '${handler}'`, handler); + return { + ...issueData, + path: fullPath, + message: issueData.message || errorMessage + }; +}; +exports.makeIssue = makeIssue; +exports.EMPTY_PATH = []; +function addIssueToContext(ctx, issueData) { + const issue = (0, exports.makeIssue)({ + issueData: issueData, + data: ctx.data, + path: ctx.path, + errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, (0, errors_1.getErrorMap)(), en_1.default].filter(x => !!x) + }); + ctx.common.issues.push(issue); +} +exports.addIssueToContext = addIssueToContext; +class ParseStatus { + constructor() { + this.value = "valid"; + } + dirty() { + if (this.value === "valid") this.value = "dirty"; + } + abort() { + if (this.value !== "aborted") this.value = "aborted"; + } + static mergeArray(status, results) { + const arrayValue = []; + for (const s of results) { + if (s.status === "aborted") return exports.INVALID; + if (s.status === "dirty") status.dirty(); + arrayValue.push(s.value); } - const outgoing = { - ...data, - messageHandling: { - ...data.messageHandling, - secret: this.config.secret - } + return { + status: status.value, + value: arrayValue }; - if (!this.config.hasModernWebkitAPI) { - if (!(handler in this.globals.capturedWebkitHandlers)) { - throw new _messaging.MissingHandler(`cannot continue, method ${handler} not captured on macos < 11`, handler); - } else { - return this.globals.capturedWebkitHandlers[handler](outgoing); - } - } - return this.globals.window.webkit.messageHandlers[handler].postMessage?.(outgoing); } - - /** - * Sends message to the webkit layer and waits for the specified response - * @param {String} handler - * @param {*} data - * @returns {Promise<*>} - * @internal - */ - async wkSendAndWait(handler) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - if (this.config.hasModernWebkitAPI) { - const response = await this.wkSend(handler, data); - return this.globals.JSONparse(response || '{}'); + static async mergeObjectAsync(status, pairs) { + const syncPairs = []; + for (const pair of pairs) { + syncPairs.push({ + key: await pair.key, + value: await pair.value + }); } - try { - const randMethodName = this.createRandMethodName(); - const key = await this.createRandKey(); - const iv = this.createRandIv(); - const { - ciphertext, - tag - } = await new this.globals.Promise(( /** @type {any} */resolve) => { - this.generateRandomMethod(randMethodName, resolve); - data.messageHandling = new SecureMessagingParams({ - methodName: randMethodName, - secret: this.config.secret, - key: this.globals.Arrayfrom(key), - iv: this.globals.Arrayfrom(iv) - }); - this.wkSend(handler, data); - }); - const cipher = new this.globals.Uint8Array([...ciphertext, ...tag]); - const decrypted = await this.decrypt(cipher, key, iv); - return this.globals.JSONparse(decrypted || '{}'); - } catch (e) { - // re-throw when the error is just a 'MissingHandler' - if (e instanceof _messaging.MissingHandler) { - throw e; - } else { - console.error('decryption failed', e); - console.error(e); - return { - error: e - }; - } - } - } - /** - * @param {string} name - * @param {Record} [data] - */ - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - this.wkSend(name, data); - } - /** - * @param {string} name - * @param {Record} [data] - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - return this.wkSendAndWait(name, data); - } - /** - * Generate a random method name and adds it to the global scope - * The native layer will use this method to send the response - * @param {string | number} randomMethodName - * @param {Function} callback - */ - generateRandomMethod(randomMethodName, callback) { - var _this = this; - this.globals.ObjectDefineProperty(this.globals.window, randomMethodName, { - enumerable: false, - // configurable, To allow for deletion later - configurable: true, - writable: false, - /** - * @param {any[]} args - */ - value: function () { - callback(...arguments); - // @ts-ignore - we want this to throw if it fails as it would indicate a fatal error. - delete _this.globals.window[randomMethodName]; - } - }); - } - randomString() { - return '' + this.globals.getRandomValues(new this.globals.Uint32Array(1))[0]; - } - createRandMethodName() { - return '_' + this.randomString(); - } - - /** - * @type {{name: string, length: number}} - */ - algoObj = { - name: 'AES-GCM', - length: 256 - }; - - /** - * @returns {Promise} - */ - async createRandKey() { - const key = await this.globals.generateKey(this.algoObj, true, ['encrypt', 'decrypt']); - const exportedKey = await this.globals.exportKey('raw', key); - return new this.globals.Uint8Array(exportedKey); - } - - /** - * @returns {Uint8Array} - */ - createRandIv() { - return this.globals.getRandomValues(new this.globals.Uint8Array(12)); - } - - /** - * @param {BufferSource} ciphertext - * @param {BufferSource} key - * @param {Uint8Array} iv - * @returns {Promise} - */ - async decrypt(ciphertext, key, iv) { - const cryptoKey = await this.globals.importKey('raw', key, 'AES-GCM', false, ['decrypt']); - const algo = { - name: 'AES-GCM', - iv - }; - let decrypted = await this.globals.decrypt(algo, cryptoKey, ciphertext); - let dec = new this.globals.TextDecoder(); - return dec.decode(decrypted); + return ParseStatus.mergeObjectSync(status, syncPairs); } - - /** - * When required (such as on macos 10.x), capture the `postMessage` method on - * each webkit messageHandler - * - * @param {string[]} handlerNames - */ - captureWebkitHandlers(handlerNames) { - const handlers = window.webkit.messageHandlers; - if (!handlers) throw new _messaging.MissingHandler('window.webkit.messageHandlers was absent', 'all'); - for (let webkitMessageHandlerName of handlerNames) { - if (typeof handlers[webkitMessageHandlerName]?.postMessage === 'function') { - /** - * `bind` is used here to ensure future calls to the captured - * `postMessage` have the correct `this` context - */ - const original = handlers[webkitMessageHandlerName]; - const bound = handlers[webkitMessageHandlerName].postMessage?.bind(original); - this.globals.capturedWebkitHandlers[webkitMessageHandlerName] = bound; - delete handlers[webkitMessageHandlerName].postMessage; + static mergeObjectSync(status, pairs) { + const finalObject = {}; + for (const pair of pairs) { + const { + key, + value + } = pair; + if (key.status === "aborted") return exports.INVALID; + if (value.status === "aborted") return exports.INVALID; + if (key.status === "dirty") status.dirty(); + if (value.status === "dirty") status.dirty(); + if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) { + finalObject[key.value] = value.value; } } + return { + status: status.value, + value: finalObject + }; } } +exports.ParseStatus = ParseStatus; +exports.INVALID = Object.freeze({ + status: "aborted" +}); +const DIRTY = value => ({ + status: "dirty", + value +}); +exports.DIRTY = DIRTY; +const OK = value => ({ + status: "valid", + value +}); +exports.OK = OK; +const isAborted = x => x.status === "aborted"; +exports.isAborted = isAborted; +const isDirty = x => x.status === "dirty"; +exports.isDirty = isDirty; +const isValid = x => x.status === "valid"; +exports.isValid = isValid; +const isAsync = x => typeof Promise !== "undefined" && x instanceof Promise; +exports.isAsync = isAsync; -/** - * Use this configuration to create an instance of {@link Messaging} for WebKit - * - * ```js - * import { fromConfig, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * const config = new WebkitMessagingConfig({ - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }); - * - * const messaging = new Messaging(config) - * const resp = await messaging.request("debugConfig") - * ``` - */ -exports.WebkitMessagingTransport = WebkitMessagingTransport; -class WebkitMessagingConfig { - /** - * @param {object} params - * @param {boolean} params.hasModernWebkitAPI - * @param {string[]} params.webkitMessageHandlerNames - * @param {string} params.secret - */ - constructor(params) { - /** - * Whether or not the current WebKit Platform supports secure messaging - * by default (eg: macOS 11+) - */ - this.hasModernWebkitAPI = params.hasModernWebkitAPI; - /** - * A list of WebKit message handler names that a user script can send - */ - this.webkitMessageHandlerNames = params.webkitMessageHandlerNames; - /** - * A string provided by native platforms to be sent with future outgoing - * messages - */ - this.secret = params.secret; - } -} - -/** - * This is the additional payload that gets appended to outgoing messages. - * It's used in the Swift side to encrypt the response that comes back - */ -exports.WebkitMessagingConfig = WebkitMessagingConfig; -class SecureMessagingParams { - /** - * @param {object} params - * @param {string} params.methodName - * @param {string} params.secret - * @param {number[]} params.key - * @param {number[]} params.iv - */ - constructor(params) { - /** - * The method that's been appended to `window` to be called later - */ - this.methodName = params.methodName; - /** - * The secret used to ensure message sender validity - */ - this.secret = params.secret; - /** - * The CipherKey as number[] - */ - this.key = params.key; - /** - * The Initial Vector as number[] - */ - this.iv = params.iv; - } -} +},{"../errors":3,"../locales/en":10}],7:[function(require,module,exports){ +"use strict"; -/** - * Capture some globals used for messaging handling to prevent page - * scripts from tampering with this - */ -exports.SecureMessagingParams = SecureMessagingParams; -function captureGlobals() { - // Creat base with null prototype - return { - window, - // Methods must be bound to their interface, otherwise they throw Illegal invocation - encrypt: window.crypto.subtle.encrypt.bind(window.crypto.subtle), - decrypt: window.crypto.subtle.decrypt.bind(window.crypto.subtle), - generateKey: window.crypto.subtle.generateKey.bind(window.crypto.subtle), - exportKey: window.crypto.subtle.exportKey.bind(window.crypto.subtle), - importKey: window.crypto.subtle.importKey.bind(window.crypto.subtle), - getRandomValues: window.crypto.getRandomValues.bind(window.crypto), - TextEncoder, - TextDecoder, - Uint8Array, - Uint16Array, - Uint32Array, - JSONstringify: window.JSON.stringify, - JSONparse: window.JSON.parse, - Arrayfrom: window.Array.from, - Promise: window.Promise, - ObjectDefineProperty: window.Object.defineProperty, - addEventListener: window.addEventListener.bind(window), - /** @type {Record} */ - capturedWebkitHandlers: {} - }; -} +Object.defineProperty(exports, "__esModule", { + value: true +}); -},{"../messaging.js":3}],5:[function(require,module,exports){ +},{}],8:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.WindowsMessagingTransport = exports.WindowsMessagingConfig = void 0; -var _messaging = require("../messaging.js"); -// eslint-disable-next-line @typescript-eslint/no-unused-vars - -/** - * @implements {MessagingTransport} - */ -class WindowsMessagingTransport { - config; - /** - * @param {WindowsMessagingConfig} config - */ - constructor(config) { - this.config = config; - } - /** - * @param {string} name - * @param {Record} [data] - */ - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error('todo: implement notify for windows'); - } - /** - * @param {string} name - * @param {Record} [data] - * @param {{signal?: AbortSignal}} opts - * @return {Promise} - */ - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - throw new Error('todo: implement request for windows'); - } -} -exports.WindowsMessagingTransport = WindowsMessagingTransport; -class WindowsMessagingConfig { - /** - * @param {object} params - * @param {string} params.featureName - */ - constructor(params) { - this.featureName = params.featureName; +exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0; +var util; +(function (util) { + util.assertEqual = val => val; + function assertIs(_arg) {} + util.assertIs = assertIs; + function assertNever(_x) { + throw new Error(); } -} -exports.WindowsMessagingConfig = WindowsMessagingConfig; - -},{"../messaging.js":3}],6:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0; -const util_1 = require("./helpers/util"); -exports.ZodIssueCode = util_1.util.arrayToEnum(["invalid_type", "invalid_literal", "custom", "invalid_union", "invalid_union_discriminator", "invalid_enum_value", "unrecognized_keys", "invalid_arguments", "invalid_return_type", "invalid_date", "invalid_string", "too_small", "too_big", "invalid_intersection_types", "not_multiple_of", "not_finite"]); -const quotelessJson = obj => { - const json = JSON.stringify(obj, null, 2); - return json.replace(/"([^"]+)":/g, "$1:"); -}; -exports.quotelessJson = quotelessJson; -class ZodError extends Error { - constructor(issues) { - var _this; - super(); - _this = this; - this.issues = []; - this.addIssue = sub => { - this.issues = [...this.issues, sub]; - }; - this.addIssues = function () { - let subs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - _this.issues = [..._this.issues, ...subs]; - }; - const actualProto = new.target.prototype; - if (Object.setPrototypeOf) { - Object.setPrototypeOf(this, actualProto); - } else { - this.__proto__ = actualProto; + util.assertNever = assertNever; + util.arrayToEnum = items => { + const obj = {}; + for (const item of items) { + obj[item] = item; } - this.name = "ZodError"; - this.issues = issues; - } - get errors() { - return this.issues; - } - format(_mapper) { - const mapper = _mapper || function (issue) { - return issue.message; - }; - const fieldErrors = { - _errors: [] - }; - const processError = error => { - for (const issue of error.issues) { - if (issue.code === "invalid_union") { - issue.unionErrors.map(processError); - } else if (issue.code === "invalid_return_type") { - processError(issue.returnTypeError); - } else if (issue.code === "invalid_arguments") { - processError(issue.argumentsError); - } else if (issue.path.length === 0) { - fieldErrors._errors.push(mapper(issue)); - } else { - let curr = fieldErrors; - let i = 0; - while (i < issue.path.length) { - const el = issue.path[i]; - const terminal = i === issue.path.length - 1; - if (!terminal) { - curr[el] = curr[el] || { - _errors: [] - }; - } else { - curr[el] = curr[el] || { - _errors: [] - }; - curr[el]._errors.push(mapper(issue)); - } - curr = curr[el]; - i++; - } - } + return obj; + }; + util.getValidEnumValues = obj => { + const validKeys = util.objectKeys(obj).filter(k => typeof obj[obj[k]] !== "number"); + const filtered = {}; + for (const k of validKeys) { + filtered[k] = obj[k]; + } + return util.objectValues(filtered); + }; + util.objectValues = obj => { + return util.objectKeys(obj).map(function (e) { + return obj[e]; + }); + }; + util.objectKeys = typeof Object.keys === "function" ? obj => Object.keys(obj) : object => { + const keys = []; + for (const key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + keys.push(key); } - }; - processError(this); - return fieldErrors; - } - toString() { - return this.message; - } - get message() { - return JSON.stringify(this.issues, util_1.util.jsonStringifyReplacer, 2); - } - get isEmpty() { - return this.issues.length === 0; + } + return keys; + }; + util.find = (arr, checker) => { + for (const item of arr) { + if (checker(item)) return item; + } + return undefined; + }; + util.isInteger = typeof Number.isInteger === "function" ? val => Number.isInteger(val) : val => typeof val === "number" && isFinite(val) && Math.floor(val) === val; + function joinValues(array) { + let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : " | "; + return array.map(val => typeof val === "string" ? `'${val}'` : val).join(separator); } - flatten() { - let mapper = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : issue => issue.message; - const fieldErrors = {}; - const formErrors = []; - for (const sub of this.issues) { - if (sub.path.length > 0) { - fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; - fieldErrors[sub.path[0]].push(mapper(sub)); - } else { - formErrors.push(mapper(sub)); - } + util.joinValues = joinValues; + util.jsonStringifyReplacer = (_, value) => { + if (typeof value === "bigint") { + return value.toString(); } + return value; + }; +})(util = exports.util || (exports.util = {})); +var objectUtil; +(function (objectUtil) { + objectUtil.mergeShapes = (first, second) => { return { - formErrors, - fieldErrors + ...first, + ...second }; - } - get formErrors() { - return this.flatten(); - } -} -exports.ZodError = ZodError; -ZodError.create = issues => { - const error = new ZodError(issues); - return error; -}; - -},{"./helpers/util":12}],7:[function(require,module,exports){ -"use strict"; - -var __importDefault = void 0 && (void 0).__importDefault || function (mod) { - return mod && mod.__esModule ? mod : { - "default": mod }; +})(objectUtil = exports.objectUtil || (exports.objectUtil = {})); +exports.ZodParsedType = util.arrayToEnum(["string", "nan", "number", "integer", "float", "boolean", "date", "bigint", "symbol", "function", "undefined", "null", "array", "object", "unknown", "promise", "void", "never", "map", "set"]); +const getParsedType = data => { + const t = typeof data; + switch (t) { + case "undefined": + return exports.ZodParsedType.undefined; + case "string": + return exports.ZodParsedType.string; + case "number": + return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number; + case "boolean": + return exports.ZodParsedType.boolean; + case "function": + return exports.ZodParsedType.function; + case "bigint": + return exports.ZodParsedType.bigint; + case "symbol": + return exports.ZodParsedType.symbol; + case "object": + if (Array.isArray(data)) { + return exports.ZodParsedType.array; + } + if (data === null) { + return exports.ZodParsedType.null; + } + if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { + return exports.ZodParsedType.promise; + } + if (typeof Map !== "undefined" && data instanceof Map) { + return exports.ZodParsedType.map; + } + if (typeof Set !== "undefined" && data instanceof Set) { + return exports.ZodParsedType.set; + } + if (typeof Date !== "undefined" && data instanceof Date) { + return exports.ZodParsedType.date; + } + return exports.ZodParsedType.object; + default: + return exports.ZodParsedType.unknown; + } }; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = void 0; -const en_1 = __importDefault(require("./locales/en")); -exports.defaultErrorMap = en_1.default; -let overrideErrorMap = en_1.default; -function setErrorMap(map) { - overrideErrorMap = map; -} -exports.setErrorMap = setErrorMap; -function getErrorMap() { - return overrideErrorMap; -} -exports.getErrorMap = getErrorMap; +exports.getParsedType = getParsedType; -},{"./locales/en":14}],8:[function(require,module,exports){ +},{}],9:[function(require,module,exports){ "use strict"; var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { @@ -859,566 +500,271 @@ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? fun if (k2 === undefined) k2 = k; o[k2] = m[k]; }); +var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) { + Object.defineProperty(o, "default", { + enumerable: true, + value: v + }); +} : function (o, v) { + o["default"] = v; +}); +var __importStar = void 0 && (void 0).__importStar || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("./errors"), exports); -__exportStar(require("./helpers/parseUtil"), exports); -__exportStar(require("./helpers/typeAliases"), exports); -__exportStar(require("./helpers/util"), exports); -__exportStar(require("./types"), exports); -__exportStar(require("./ZodError"), exports); +exports.z = void 0; +const z = __importStar(require("./external")); +exports.z = z; +__exportStar(require("./external"), exports); +exports.default = z; -},{"./ZodError":6,"./errors":7,"./helpers/parseUtil":10,"./helpers/typeAliases":11,"./helpers/util":12,"./types":15}],9:[function(require,module,exports){ +},{"./external":4}],10:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.errorUtil = void 0; -var errorUtil; -(function (errorUtil) { - errorUtil.errToObj = message => typeof message === "string" ? { +const util_1 = require("../helpers/util"); +const ZodError_1 = require("../ZodError"); +const errorMap = (issue, _ctx) => { + let message; + switch (issue.code) { + case ZodError_1.ZodIssueCode.invalid_type: + if (issue.received === util_1.ZodParsedType.undefined) { + message = "Required"; + } else { + message = `Expected ${issue.expected}, received ${issue.received}`; + } + break; + case ZodError_1.ZodIssueCode.invalid_literal: + message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_1.util.jsonStringifyReplacer)}`; + break; + case ZodError_1.ZodIssueCode.unrecognized_keys: + message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`; + break; + case ZodError_1.ZodIssueCode.invalid_union: + message = `Invalid input`; + break; + case ZodError_1.ZodIssueCode.invalid_union_discriminator: + message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`; + break; + case ZodError_1.ZodIssueCode.invalid_enum_value: + message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`; + break; + case ZodError_1.ZodIssueCode.invalid_arguments: + message = `Invalid function arguments`; + break; + case ZodError_1.ZodIssueCode.invalid_return_type: + message = `Invalid function return type`; + break; + case ZodError_1.ZodIssueCode.invalid_date: + message = `Invalid date`; + break; + case ZodError_1.ZodIssueCode.invalid_string: + if (typeof issue.validation === "object") { + if ("includes" in issue.validation) { + message = `Invalid input: must include "${issue.validation.includes}"`; + if (typeof issue.validation.position === "number") { + message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; + } + } else if ("startsWith" in issue.validation) { + message = `Invalid input: must start with "${issue.validation.startsWith}"`; + } else if ("endsWith" in issue.validation) { + message = `Invalid input: must end with "${issue.validation.endsWith}"`; + } else { + util_1.util.assertNever(issue.validation); + } + } else if (issue.validation !== "regex") { + message = `Invalid ${issue.validation}`; + } else { + message = "Invalid"; + } + break; + case ZodError_1.ZodIssueCode.too_small: + if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;else message = "Invalid input"; + break; + case ZodError_1.ZodIssueCode.too_big: + if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;else message = "Invalid input"; + break; + case ZodError_1.ZodIssueCode.custom: + message = `Invalid input`; + break; + case ZodError_1.ZodIssueCode.invalid_intersection_types: + message = `Intersection results could not be merged`; + break; + case ZodError_1.ZodIssueCode.not_multiple_of: + message = `Number must be a multiple of ${issue.multipleOf}`; + break; + case ZodError_1.ZodIssueCode.not_finite: + message = "Number must be finite"; + break; + default: + message = _ctx.defaultError; + util_1.util.assertNever(issue); + } + return { message - } : message || {}; - errorUtil.toString = message => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; -})(errorUtil = exports.errorUtil || (exports.errorUtil = {})); + }; +}; +exports.default = errorMap; -},{}],10:[function(require,module,exports){ +},{"../ZodError":2,"../helpers/util":8}],11:[function(require,module,exports){ "use strict"; -var __importDefault = void 0 && (void 0).__importDefault || function (mod) { - return mod && mod.__esModule ? mod : { - "default": mod - }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0; -const errors_1 = require("../errors"); -const en_1 = __importDefault(require("../locales/en")); -const makeIssue = params => { - const { - data, - path, - errorMaps, - issueData - } = params; - const fullPath = [...path, ...(issueData.path || [])]; - const fullIssue = { - ...issueData, - path: fullPath - }; - let errorMessage = ""; - const maps = errorMaps.filter(m => !!m).slice().reverse(); - for (const map of maps) { - errorMessage = map(fullIssue, { - data, - defaultError: errorMessage - }).message; - } - return { - ...issueData, - path: fullPath, - message: issueData.message || errorMessage - }; -}; -exports.makeIssue = makeIssue; -exports.EMPTY_PATH = []; -function addIssueToContext(ctx, issueData) { - const issue = (0, exports.makeIssue)({ - issueData: issueData, - data: ctx.data, - path: ctx.path, - errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, (0, errors_1.getErrorMap)(), en_1.default].filter(x => !!x) - }); - ctx.common.issues.push(issue); -} -exports.addIssueToContext = addIssueToContext; -class ParseStatus { - constructor() { - this.value = "valid"; - } - dirty() { - if (this.value === "valid") this.value = "dirty"; - } - abort() { - if (this.value !== "aborted") this.value = "aborted"; +exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0; +exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = exports.discriminatedUnion = void 0; +const errors_1 = require("./errors"); +const errorUtil_1 = require("./helpers/errorUtil"); +const parseUtil_1 = require("./helpers/parseUtil"); +const util_1 = require("./helpers/util"); +const ZodError_1 = require("./ZodError"); +class ParseInputLazyPath { + constructor(parent, value, path, key) { + this._cachedPath = []; + this.parent = parent; + this.data = value; + this._path = path; + this._key = key; } - static mergeArray(status, results) { - const arrayValue = []; - for (const s of results) { - if (s.status === "aborted") return exports.INVALID; - if (s.status === "dirty") status.dirty(); - arrayValue.push(s.value); + get path() { + if (!this._cachedPath.length) { + if (this._key instanceof Array) { + this._cachedPath.push(...this._path, ...this._key); + } else { + this._cachedPath.push(...this._path, this._key); + } } + return this._cachedPath; + } +} +const handleResult = (ctx, result) => { + if ((0, parseUtil_1.isValid)(result)) { return { - status: status.value, - value: arrayValue + success: true, + data: result.value }; - } - static async mergeObjectAsync(status, pairs) { - const syncPairs = []; - for (const pair of pairs) { - syncPairs.push({ - key: await pair.key, - value: await pair.value - }); - } - return ParseStatus.mergeObjectSync(status, syncPairs); - } - static mergeObjectSync(status, pairs) { - const finalObject = {}; - for (const pair of pairs) { - const { - key, - value - } = pair; - if (key.status === "aborted") return exports.INVALID; - if (value.status === "aborted") return exports.INVALID; - if (key.status === "dirty") status.dirty(); - if (value.status === "dirty") status.dirty(); - if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) { - finalObject[key.value] = value.value; - } + } else { + if (!ctx.common.issues.length) { + throw new Error("Validation failed but no issues detected."); } return { - status: status.value, - value: finalObject + success: false, + get error() { + if (this._error) return this._error; + const error = new ZodError_1.ZodError(ctx.common.issues); + this._error = error; + return this._error; + } }; } -} -exports.ParseStatus = ParseStatus; -exports.INVALID = Object.freeze({ - status: "aborted" -}); -const DIRTY = value => ({ - status: "dirty", - value -}); -exports.DIRTY = DIRTY; -const OK = value => ({ - status: "valid", - value -}); -exports.OK = OK; -const isAborted = x => x.status === "aborted"; -exports.isAborted = isAborted; -const isDirty = x => x.status === "dirty"; -exports.isDirty = isDirty; -const isValid = x => x.status === "valid"; -exports.isValid = isValid; -const isAsync = x => typeof Promise !== "undefined" && x instanceof Promise; -exports.isAsync = isAsync; - -},{"../errors":7,"../locales/en":14}],11:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -},{}],12:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0; -var util; -(function (util) { - util.assertEqual = val => val; - function assertIs(_arg) {} - util.assertIs = assertIs; - function assertNever(_x) { - throw new Error(); +}; +function processCreateParams(params) { + if (!params) return {}; + const { + errorMap, + invalid_type_error, + required_error, + description + } = params; + if (errorMap && (invalid_type_error || required_error)) { + throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); } - util.assertNever = assertNever; - util.arrayToEnum = items => { - const obj = {}; - for (const item of items) { - obj[item] = item; - } - return obj; - }; - util.getValidEnumValues = obj => { - const validKeys = util.objectKeys(obj).filter(k => typeof obj[obj[k]] !== "number"); - const filtered = {}; - for (const k of validKeys) { - filtered[k] = obj[k]; - } - return util.objectValues(filtered); - }; - util.objectValues = obj => { - return util.objectKeys(obj).map(function (e) { - return obj[e]; - }); + if (errorMap) return { + errorMap: errorMap, + description }; - util.objectKeys = typeof Object.keys === "function" ? obj => Object.keys(obj) : object => { - const keys = []; - for (const key in object) { - if (Object.prototype.hasOwnProperty.call(object, key)) { - keys.push(key); - } + const customMap = (iss, ctx) => { + if (iss.code !== "invalid_type") return { + message: ctx.defaultError + }; + if (typeof ctx.data === "undefined") { + return { + message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError + }; } - return keys; + return { + message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError + }; }; - util.find = (arr, checker) => { - for (const item of arr) { - if (checker(item)) return item; - } - return undefined; + return { + errorMap: customMap, + description }; - util.isInteger = typeof Number.isInteger === "function" ? val => Number.isInteger(val) : val => typeof val === "number" && isFinite(val) && Math.floor(val) === val; - function joinValues(array) { - let separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : " | "; - return array.map(val => typeof val === "string" ? `'${val}'` : val).join(separator); +} +class ZodType { + constructor(def) { + this.spa = this.safeParseAsync; + this._def = def; + this.parse = this.parse.bind(this); + this.safeParse = this.safeParse.bind(this); + this.parseAsync = this.parseAsync.bind(this); + this.safeParseAsync = this.safeParseAsync.bind(this); + this.spa = this.spa.bind(this); + this.refine = this.refine.bind(this); + this.refinement = this.refinement.bind(this); + this.superRefine = this.superRefine.bind(this); + this.optional = this.optional.bind(this); + this.nullable = this.nullable.bind(this); + this.nullish = this.nullish.bind(this); + this.array = this.array.bind(this); + this.promise = this.promise.bind(this); + this.or = this.or.bind(this); + this.and = this.and.bind(this); + this.transform = this.transform.bind(this); + this.brand = this.brand.bind(this); + this.default = this.default.bind(this); + this.catch = this.catch.bind(this); + this.describe = this.describe.bind(this); + this.pipe = this.pipe.bind(this); + this.readonly = this.readonly.bind(this); + this.isNullable = this.isNullable.bind(this); + this.isOptional = this.isOptional.bind(this); } - util.joinValues = joinValues; - util.jsonStringifyReplacer = (_, value) => { - if (typeof value === "bigint") { - return value.toString(); - } - return value; - }; -})(util = exports.util || (exports.util = {})); -var objectUtil; -(function (objectUtil) { - objectUtil.mergeShapes = (first, second) => { - return { - ...first, - ...second + get description() { + return this._def.description; + } + _getType(input) { + return (0, util_1.getParsedType)(input.data); + } + _getOrReturnCtx(input, ctx) { + return ctx || { + common: input.parent.common, + data: input.data, + parsedType: (0, util_1.getParsedType)(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent }; - }; -})(objectUtil = exports.objectUtil || (exports.objectUtil = {})); -exports.ZodParsedType = util.arrayToEnum(["string", "nan", "number", "integer", "float", "boolean", "date", "bigint", "symbol", "function", "undefined", "null", "array", "object", "unknown", "promise", "void", "never", "map", "set"]); -const getParsedType = data => { - const t = typeof data; - switch (t) { - case "undefined": - return exports.ZodParsedType.undefined; - case "string": - return exports.ZodParsedType.string; - case "number": - return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number; - case "boolean": - return exports.ZodParsedType.boolean; - case "function": - return exports.ZodParsedType.function; - case "bigint": - return exports.ZodParsedType.bigint; - case "symbol": - return exports.ZodParsedType.symbol; - case "object": - if (Array.isArray(data)) { - return exports.ZodParsedType.array; - } - if (data === null) { - return exports.ZodParsedType.null; - } - if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { - return exports.ZodParsedType.promise; - } - if (typeof Map !== "undefined" && data instanceof Map) { - return exports.ZodParsedType.map; - } - if (typeof Set !== "undefined" && data instanceof Set) { - return exports.ZodParsedType.set; - } - if (typeof Date !== "undefined" && data instanceof Date) { - return exports.ZodParsedType.date; + } + _processInputParams(input) { + return { + status: new parseUtil_1.ParseStatus(), + ctx: { + common: input.parent.common, + data: input.data, + parsedType: (0, util_1.getParsedType)(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent } - return exports.ZodParsedType.object; - default: - return exports.ZodParsedType.unknown; + }; } -}; -exports.getParsedType = getParsedType; - -},{}],13:[function(require,module,exports){ -"use strict"; - -var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { - enumerable: true, - get: function () { - return m[k]; - } - }); -} : function (o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -}); -var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) { - Object.defineProperty(o, "default", { - enumerable: true, - value: v - }); -} : function (o, v) { - o["default"] = v; -}); -var __importStar = void 0 && (void 0).__importStar || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.z = void 0; -const z = __importStar(require("./external")); -exports.z = z; -__exportStar(require("./external"), exports); -exports.default = z; - -},{"./external":8}],14:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -const util_1 = require("../helpers/util"); -const ZodError_1 = require("../ZodError"); -const errorMap = (issue, _ctx) => { - let message; - switch (issue.code) { - case ZodError_1.ZodIssueCode.invalid_type: - if (issue.received === util_1.ZodParsedType.undefined) { - message = "Required"; - } else { - message = `Expected ${issue.expected}, received ${issue.received}`; - } - break; - case ZodError_1.ZodIssueCode.invalid_literal: - message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_1.util.jsonStringifyReplacer)}`; - break; - case ZodError_1.ZodIssueCode.unrecognized_keys: - message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`; - break; - case ZodError_1.ZodIssueCode.invalid_union: - message = `Invalid input`; - break; - case ZodError_1.ZodIssueCode.invalid_union_discriminator: - message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`; - break; - case ZodError_1.ZodIssueCode.invalid_enum_value: - message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`; - break; - case ZodError_1.ZodIssueCode.invalid_arguments: - message = `Invalid function arguments`; - break; - case ZodError_1.ZodIssueCode.invalid_return_type: - message = `Invalid function return type`; - break; - case ZodError_1.ZodIssueCode.invalid_date: - message = `Invalid date`; - break; - case ZodError_1.ZodIssueCode.invalid_string: - if (typeof issue.validation === "object") { - if ("includes" in issue.validation) { - message = `Invalid input: must include "${issue.validation.includes}"`; - if (typeof issue.validation.position === "number") { - message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; - } - } else if ("startsWith" in issue.validation) { - message = `Invalid input: must start with "${issue.validation.startsWith}"`; - } else if ("endsWith" in issue.validation) { - message = `Invalid input: must end with "${issue.validation.endsWith}"`; - } else { - util_1.util.assertNever(issue.validation); - } - } else if (issue.validation !== "regex") { - message = `Invalid ${issue.validation}`; - } else { - message = "Invalid"; - } - break; - case ZodError_1.ZodIssueCode.too_small: - if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;else message = "Invalid input"; - break; - case ZodError_1.ZodIssueCode.too_big: - if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;else message = "Invalid input"; - break; - case ZodError_1.ZodIssueCode.custom: - message = `Invalid input`; - break; - case ZodError_1.ZodIssueCode.invalid_intersection_types: - message = `Intersection results could not be merged`; - break; - case ZodError_1.ZodIssueCode.not_multiple_of: - message = `Number must be a multiple of ${issue.multipleOf}`; - break; - case ZodError_1.ZodIssueCode.not_finite: - message = "Number must be finite"; - break; - default: - message = _ctx.defaultError; - util_1.util.assertNever(issue); - } - return { - message - }; -}; -exports.default = errorMap; - -},{"../ZodError":6,"../helpers/util":12}],15:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0; -exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = exports.discriminatedUnion = void 0; -const errors_1 = require("./errors"); -const errorUtil_1 = require("./helpers/errorUtil"); -const parseUtil_1 = require("./helpers/parseUtil"); -const util_1 = require("./helpers/util"); -const ZodError_1 = require("./ZodError"); -class ParseInputLazyPath { - constructor(parent, value, path, key) { - this._cachedPath = []; - this.parent = parent; - this.data = value; - this._path = path; - this._key = key; - } - get path() { - if (!this._cachedPath.length) { - if (this._key instanceof Array) { - this._cachedPath.push(...this._path, ...this._key); - } else { - this._cachedPath.push(...this._path, this._key); - } - } - return this._cachedPath; - } -} -const handleResult = (ctx, result) => { - if ((0, parseUtil_1.isValid)(result)) { - return { - success: true, - data: result.value - }; - } else { - if (!ctx.common.issues.length) { - throw new Error("Validation failed but no issues detected."); - } - return { - success: false, - get error() { - if (this._error) return this._error; - const error = new ZodError_1.ZodError(ctx.common.issues); - this._error = error; - return this._error; - } - }; - } -}; -function processCreateParams(params) { - if (!params) return {}; - const { - errorMap, - invalid_type_error, - required_error, - description - } = params; - if (errorMap && (invalid_type_error || required_error)) { - throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); - } - if (errorMap) return { - errorMap: errorMap, - description - }; - const customMap = (iss, ctx) => { - if (iss.code !== "invalid_type") return { - message: ctx.defaultError - }; - if (typeof ctx.data === "undefined") { - return { - message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError - }; - } - return { - message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError - }; - }; - return { - errorMap: customMap, - description - }; -} -class ZodType { - constructor(def) { - this.spa = this.safeParseAsync; - this._def = def; - this.parse = this.parse.bind(this); - this.safeParse = this.safeParse.bind(this); - this.parseAsync = this.parseAsync.bind(this); - this.safeParseAsync = this.safeParseAsync.bind(this); - this.spa = this.spa.bind(this); - this.refine = this.refine.bind(this); - this.refinement = this.refinement.bind(this); - this.superRefine = this.superRefine.bind(this); - this.optional = this.optional.bind(this); - this.nullable = this.nullable.bind(this); - this.nullish = this.nullish.bind(this); - this.array = this.array.bind(this); - this.promise = this.promise.bind(this); - this.or = this.or.bind(this); - this.and = this.and.bind(this); - this.transform = this.transform.bind(this); - this.brand = this.brand.bind(this); - this.default = this.default.bind(this); - this.catch = this.catch.bind(this); - this.describe = this.describe.bind(this); - this.pipe = this.pipe.bind(this); - this.readonly = this.readonly.bind(this); - this.isNullable = this.isNullable.bind(this); - this.isOptional = this.isOptional.bind(this); - } - get description() { - return this._def.description; - } - _getType(input) { - return (0, util_1.getParsedType)(input.data); - } - _getOrReturnCtx(input, ctx) { - return ctx || { - common: input.parent.common, - data: input.data, - parsedType: (0, util_1.getParsedType)(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - }; - } - _processInputParams(input) { - return { - status: new parseUtil_1.ParseStatus(), - ctx: { - common: input.parent.common, - data: input.data, - parsedType: (0, util_1.getParsedType)(input.data), - schemaErrorMap: this._def.errorMap, - path: input.path, - parent: input.parent - } - }; - } - _parseSync(input) { - const result = this._parse(input); - if ((0, parseUtil_1.isAsync)(result)) { - throw new Error("Synchronous parse encountered promise."); + _parseSync(input) { + const result = this._parse(input); + if ((0, parseUtil_1.isAsync)(result)) { + throw new Error("Synchronous parse encountered promise."); } return result; } @@ -4648,380 +3994,949 @@ exports.coerce = { }; exports.NEVER = parseUtil_1.INVALID; -},{"./ZodError":6,"./errors":7,"./helpers/errorUtil":9,"./helpers/parseUtil":10,"./helpers/util":12}],16:[function(require,module,exports){ +},{"./ZodError":2,"./errors":3,"./helpers/errorUtil":5,"./helpers/parseUtil":6,"./helpers/util":8}],12:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "DeviceApi", { + enumerable: true, + get: function () { + return _deviceApi.DeviceApi; + } +}); +Object.defineProperty(exports, "DeviceApiCall", { + enumerable: true, + get: function () { + return _deviceApiCall.DeviceApiCall; + } +}); +Object.defineProperty(exports, "DeviceApiTransport", { + enumerable: true, + get: function () { + return _deviceApi.DeviceApiTransport; + } +}); +Object.defineProperty(exports, "createNotification", { + enumerable: true, + get: function () { + return _deviceApiCall.createNotification; + } +}); +Object.defineProperty(exports, "createRequest", { + enumerable: true, + get: function () { + return _deviceApiCall.createRequest; + } +}); +Object.defineProperty(exports, "validate", { + enumerable: true, + get: function () { + return _deviceApiCall.validate; + } +}); +var _deviceApiCall = require("./lib/device-api-call.js"); +var _deviceApi = require("./lib/device-api.js"); + +},{"./lib/device-api-call.js":13,"./lib/device-api.js":14}],13:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.SchemaValidationError = exports.DeviceApiCallError = exports.DeviceApiCall = void 0; +exports.createDeviceApiCall = createDeviceApiCall; +exports.createNotification = void 0; +exports.createRequest = createRequest; +exports.validate = validate; +/** + * This roughly follows https://www.jsonrpc.org/specification + * @template {import("zod").ZodType} Params=import("zod").ZodType + * @template {import("zod").ZodType} Result=import("zod").ZodType + */ +class DeviceApiCall { + /** @type {string} */ + method = 'unknown'; + /** + * An optional 'id' - used to indicate if a request requires a response. + * @type {string|null} + */ + id = null; + /** @type {Params | null | undefined} */ + paramsValidator = null; + /** @type {Result | null | undefined} */ + resultValidator = null; + /** @type {import("zod").infer} */ + params; + /** + * This is a carve-out for legacy messages that are not typed yet. + * If you set this to 'true', then the response will not be checked to conform + * to any shape + * @deprecated this is here to aid migration, should be removed ASAP + * @type {boolean} + */ + throwOnResultKeysMissing = true; + /** + * New messages should be in a particular format, eg: { success: T }, + * but you can set this to false if you want to access the result as-is, + * without any unwrapping logic + * @deprecated this is here to aid migration, should be removed ASAP + * @type {boolean} + */ + unwrapResult = true; + /** + * @param {import("zod").infer} data + */ + constructor(data) { + this.params = data; + } + + /** + * @returns {import("zod").infer|undefined} + */ + validateParams() { + if (this.params === undefined) { + return undefined; + } + this._validate(this.params, this.paramsValidator); + return this.params; + } + + /** + * @param {any|null} incoming + * @returns {import("zod").infer} + */ + validateResult(incoming) { + this._validate(incoming, this.resultValidator); + if (!incoming) { + return incoming; + } + if (!this.unwrapResult) { + return incoming; + } + if ('data' in incoming) { + console.warn('response had `data` property. Please migrate to `success`'); + return incoming.data; + } + if ('success' in incoming) { + return incoming.success; + } + if ('error' in incoming) { + if (typeof incoming.error.message === 'string') { + throw new DeviceApiCallError(`${this.method}: ${incoming.error.message}`); + } + } + if (this.throwOnResultKeysMissing) { + throw new Error('unreachable. Response did not contain `success` or `data`'); + } + return incoming; + } + + /** + * @param {any} data + * @param {import("zod").ZodType|undefined|null} [validator] + * @private + */ + _validate(data, validator) { + if (!validator) return data; + if (validator) { + const result = validator?.safeParse(data); + if (!result) { + throw new Error('unreachable, data failure', data); + } + if (!result.success) { + if ('error' in result) { + this.throwError(result.error.issues); + } else { + console.error('unknown error from validate'); + } + } + } + } + + /** + * @param {import('zod').ZodIssue[]} errors + */ + throwError(errors) { + const error = SchemaValidationError.fromZodErrors(errors, this.constructor.name); + throw error; + } + + /** + * Use this helper for creating stand-in response messages that are typed correctly. + * + * @examples + * + * ```js + * const msg = new Message(); + * const response = msg.response({}) // <-- This argument will be typed correctly + * ``` + * + * @param {import("zod").infer} response + * @returns {import("zod").infer} + */ + result(response) { + return response; + } + /** + * @returns {import("zod").infer} + */ + preResultValidation(response) { + return response; + } +} +exports.DeviceApiCall = DeviceApiCall; +class DeviceApiCallError extends Error {} + +/** + * Check for this error if you'd like to + */ +exports.DeviceApiCallError = DeviceApiCallError; +class SchemaValidationError extends Error { + /** @type {import("zod").ZodIssue[]} */ + validationErrors = []; + + /** + * @param {import("zod").ZodIssue[]} errors + * @param {string} name + * @returns {SchemaValidationError} + */ + static fromZodErrors(errors, name) { + const heading = `${errors.length} SchemaValidationError(s) errors for ` + name; + function log(issue) { + switch (issue.code) { + case 'invalid_literal': + case 'invalid_type': + { + console.log(`${name}. Path: '${issue.path.join('.')}', Error: '${issue.message}'`); + break; + } + case 'invalid_union': + { + for (let unionError of issue.unionErrors) { + for (let issue1 of unionError.issues) { + log(issue1); + } + } + break; + } + default: + { + console.log(name, 'other issue:', issue); + } + } + } + for (let error of errors) { + log(error); + } + const message = [heading, 'please see the details above'].join('\n '); + const error = new SchemaValidationError(message); + error.validationErrors = errors; + return error; + } +} + +/** + * Creates an instance of `DeviceApiCall` from only a name and 'params' + * and optional validators. Use this to help migrate existing messages. + * + * @template {import("zod").ZodType} Params + * @template {import("zod").ZodType} Result + * @param {string} method + * @param {import("zod").infer} [params] + * @param {Params|null} [paramsValidator] + * @param {Result|null} [resultValidator] + * @returns {DeviceApiCall} + */ +exports.SchemaValidationError = SchemaValidationError; +function createDeviceApiCall(method, params) { + let paramsValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + let resultValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + /** @type {DeviceApiCall} */ + const deviceApiCall = new DeviceApiCall(params); + deviceApiCall.paramsValidator = paramsValidator; + deviceApiCall.resultValidator = resultValidator; + deviceApiCall.method = method; + deviceApiCall.throwOnResultKeysMissing = false; + deviceApiCall.unwrapResult = false; + return deviceApiCall; +} + +/** + * Creates an instance of `DeviceApiCall` from only a name and 'params' + * and optional validators. Use this to help migrate existing messages. + * + * Note: This creates a regular DeviceApiCall, but adds the 'id' as a string + * so that transports know that it expects a response. + * + * @template {import("zod").ZodType} Params + * @template {import("zod").ZodType} Result + * @param {string} method + * @param {import("zod").infer} [params] + * @param {string} [id] + * @param {Params|null} [paramsValidator] + * @param {Result|null} [resultValidator] + * @returns {DeviceApiCall} + */ +function createRequest(method, params) { + let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n/a'; + let paramsValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + let resultValidator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; + const call = createDeviceApiCall(method, params, paramsValidator, resultValidator); + call.id = id; + return call; +} +const createNotification = exports.createNotification = createDeviceApiCall; + +/** + * Validate any arbitrary data with any Zod validator + * + * @template {import("zod").ZodType} Validator + * @param {any} data + * @param {Validator | null} [validator] + * @returns {import("zod").infer} + */ +function validate(data) { + let validator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + if (validator) { + return validator.parse(data); + } + return data; +} + +},{}],14:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -Object.defineProperty(exports, "DeviceApi", { - enumerable: true, - get: function () { - return _deviceApi.DeviceApi; +exports.DeviceApiTransport = exports.DeviceApi = void 0; +/** + * Platforms should only need to implement this `send` method + */ +class DeviceApiTransport { + /** + * @param {import("./device-api-call.js").DeviceApiCall} _deviceApiCall + * @param {CallOptions} [_options] + * @returns {Promise} + */ + async send(_deviceApiCall, _options) { + return undefined; } -}); -Object.defineProperty(exports, "DeviceApiCall", { - enumerable: true, - get: function () { - return _deviceApiCall.DeviceApiCall; +} + +/** + * This is the base Sender class that platforms can will implement. + * + * Note: The 'handle' method must be implemented, unless you also implement 'send' + * + * @typedef CallOptions + * @property {AbortSignal} [signal] + */ +exports.DeviceApiTransport = DeviceApiTransport; +class DeviceApi { + /** @type {DeviceApiTransport} */ + transport; + /** @param {DeviceApiTransport} transport */ + constructor(transport) { + this.transport = transport; } -}); -Object.defineProperty(exports, "DeviceApiTransport", { - enumerable: true, - get: function () { - return _deviceApi.DeviceApiTransport; + /** + * @template {import("./device-api-call").DeviceApiCall} D + * @param {D} deviceApiCall + * @param {CallOptions} [options] + * @returns {Promise['success']>>} + */ + async request(deviceApiCall, options) { + deviceApiCall.validateParams(); + let result = await this.transport.send(deviceApiCall, options); + let processed = deviceApiCall.preResultValidation(result); + return deviceApiCall.validateResult(processed); } -}); -Object.defineProperty(exports, "createNotification", { - enumerable: true, - get: function () { - return _deviceApiCall.createNotification; + /** + * @template {import("./device-api-call").DeviceApiCall} P + * @param {P} deviceApiCall + * @param {CallOptions} [options] + * @returns {Promise} + */ + async notify(deviceApiCall, options) { + deviceApiCall.validateParams(); + return this.transport.send(deviceApiCall, options); } +} +exports.DeviceApi = DeviceApi; + +},{}],15:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true }); -Object.defineProperty(exports, "createRequest", { +exports.MissingHandler = exports.MessagingTransport = exports.Messaging = void 0; +Object.defineProperty(exports, "WebkitMessagingConfig", { enumerable: true, get: function () { - return _deviceApiCall.createRequest; + return _webkit.WebkitMessagingConfig; } }); -Object.defineProperty(exports, "validate", { - enumerable: true, - get: function () { - return _deviceApiCall.validate; +var _webkit = require("./webkit.js"); +/** + * @module Messaging + * + * @description + * + * An abstraction for communications between JavaScript and host platforms. + * + * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) + * 2) Then use that to get an instance of the Messaging utility which allows + * you to send and receive data in a unified way + * 3) Each platform implements {@link MessagingTransport} along with its own Configuration + * - For example, to learn what configuration is required for Webkit, see: {@link "Webkit Messaging".WebkitMessagingConfig} + * - Or, to learn about how messages are sent and received in Webkit, see {@link "Webkit Messaging".WebkitMessagingTransport} + * + * @example Webkit Messaging + * + * ```js + * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" + * + * // This config would be injected into the UserScript + * const injectedConfig = { + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }; + * + * // Then use that config to construct platform-specific configuration + * const config = new WebkitMessagingConfig(injectedConfig); + * + * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 + * const messaging = new Messaging(config); + * messaging.notify("hello world!", {foo: "bar"}) + * + * ``` + * + * @example Windows Messaging + * + * ```js + * import { Messaging, WindowsMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" + * + * // Messaging on Windows is namespaced, so you can create multiple messaging instances + * const autofillConfig = new WindowsMessagingConfig({ featureName: "Autofill" }); + * const debugConfig = new WindowsMessagingConfig({ featureName: "Debugging" }); + * + * const autofillMessaging = new Messaging(autofillConfig); + * const debugMessaging = new Messaging(debugConfig); + * + * // Now send messages to both features as needed 🚀 + * autofillMessaging.notify("storeFormData", { "username": "dax" }) + * debugMessaging.notify("pageLoad", { time: window.performance.now() }) + * ``` + */ + +/** + * @implements {MessagingTransport} + */ +class Messaging { + /** + * @param {WebkitMessagingConfig} config + */ + constructor(config) { + this.transport = getTransport(config); } -}); -var _deviceApiCall = require("./lib/device-api-call.js"); -var _deviceApi = require("./lib/device-api.js"); + /** + * Send a 'fire-and-forget' message. + * @throws {Error} + * {@link MissingHandler} + * + * @example + * + * ``` + * const messaging = new Messaging(config) + * messaging.notify("foo", {bar: "baz"}) + * ``` + * @param {string} name + * @param {Record} [data] + */ + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + this.transport.notify(name, data); + } + /** + * Send a request, and wait for a response + * @throws {Error} + * {@link MissingHandler} + * + * @example + * ``` + * const messaging = new Messaging(config) + * const response = await messaging.request("foo", {bar: "baz"}) + * ``` + * + * @param {string} name + * @param {Record} [data] + * @return {Promise} + */ + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return this.transport.request(name, data); + } +} + +/** + * @interface + */ +exports.Messaging = Messaging; +class MessagingTransport { + /** + * @param {string} name + * @param {Record} [data] + * @returns {void} + */ + // @ts-ignore - ignoring a no-unused ts error, this is only an interface. + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + throw new Error("must implement 'notify'"); + } + /** + * @param {string} name + * @param {Record} [data] + * @return {Promise} + */ + // @ts-ignore - ignoring a no-unused ts error, this is only an interface. + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + throw new Error('must implement'); + } +} + +/** + * @param {WebkitMessagingConfig} config + * @returns {MessagingTransport} + */ +exports.MessagingTransport = MessagingTransport; +function getTransport(config) { + if (config instanceof _webkit.WebkitMessagingConfig) { + return new _webkit.WebkitMessagingTransport(config); + } + throw new Error('unreachable'); +} + +/** + * Thrown when a handler cannot be found + */ +class MissingHandler extends Error { + /** + * @param {string} message + * @param {string} handlerName + */ + constructor(message, handlerName) { + super(message); + this.handlerName = handlerName; + } +} + +/** + * Some re-exports for convenience + */ +exports.MissingHandler = MissingHandler; -},{"./lib/device-api-call.js":17,"./lib/device-api.js":18}],17:[function(require,module,exports){ +},{"./webkit.js":16}],16:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.SchemaValidationError = exports.DeviceApiCallError = exports.DeviceApiCall = void 0; -exports.createDeviceApiCall = createDeviceApiCall; -exports.createNotification = void 0; -exports.createRequest = createRequest; -exports.validate = validate; +exports.WebkitMessagingTransport = exports.WebkitMessagingConfig = exports.SecureMessagingParams = void 0; +var _messaging = require("./messaging.js"); /** - * This roughly follows https://www.jsonrpc.org/specification - * @template {import("zod").ZodType} Params=import("zod").ZodType - * @template {import("zod").ZodType} Result=import("zod").ZodType + * @module Webkit Messaging + * + * @description + * + * A wrapper for messaging on WebKit platforms. It supports modern WebKit messageHandlers + * along with encryption for older versions (like macOS Catalina) + * + * Note: If you wish to support Catalina then you'll need to implement the native + * part of the message handling, see {@link WebkitMessagingTransport} for details. + * + * ```js + * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" + * + * // This config would be injected into the UserScript + * const injectedConfig = { + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }; + * + * // Then use that config to construct platform-specific configuration + * const config = new WebkitMessagingConfig(injectedConfig); + * + * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 + * const messaging = new Messaging(config); + * messaging.notify("hello world!", {foo: "bar"}) + * + * ``` + */ + +/** + * @typedef {import("./messaging").MessagingTransport} MessagingTransport + */ + +/** + * @example + * On macOS 11+, this will just call through to `window.webkit.messageHandlers.x.postMessage` + * + * Eg: for a `foo` message defined in Swift that accepted the payload `{"bar": "baz"}`, the following + * would occur: + * + * ```js + * const json = await window.webkit.messageHandlers.foo.postMessage({ bar: "baz" }); + * const response = JSON.parse(json) + * ``` + * + * @example + * On macOS 10 however, the process is a little more involved. A method will be appended to `window` + * that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow + * as being something along the lines of: + * + * ```js + * // add the window method + * window["_0123456"] = (response) => { + * // decrypt `response` and deliver the result to the caller here + * // then remove the temporary method + * delete window["_0123456"] + * }; + * + * // send the data + `messageHanding` values + * window.webkit.messageHandlers.foo.postMessage({ + * bar: "baz", + * messagingHandling: { + * methodName: "_0123456", + * secret: "super-secret", + * key: [1, 2, 45, 2], + * iv: [34, 4, 43], + * } + * }); + * + * // later in swift, the following JavaScript snippet will be executed + * (() => { + * window["_0123456"]({ + * ciphertext: [12, 13, 4], + * tag: [3, 5, 67, 56] + * }) + * })() + * ``` + * @implements {MessagingTransport} */ -class DeviceApiCall { - /** @type {string} */ - method = 'unknown'; - /** - * An optional 'id' - used to indicate if a request requires a response. - * @type {string|null} - */ - id = null; - /** @type {Params | null | undefined} */ - paramsValidator = null; - /** @type {Result | null | undefined} */ - resultValidator = null; - /** @type {import("zod").infer} */ - params; - /** - * This is a carve-out for legacy messages that are not typed yet. - * If you set this to 'true', then the response will not be checked to conform - * to any shape - * @deprecated this is here to aid migration, should be removed ASAP - * @type {boolean} - */ - throwOnResultKeysMissing = true; - /** - * New messages should be in a particular format, eg: { success: T }, - * but you can set this to false if you want to access the result as-is, - * without any unwrapping logic - * @deprecated this is here to aid migration, should be removed ASAP - * @type {boolean} - */ - unwrapResult = true; +class WebkitMessagingTransport { + /** @type {WebkitMessagingConfig} */ + config; + globals; /** - * @param {import("zod").infer} data - */ - constructor(data) { - this.params = data; + * @param {WebkitMessagingConfig} config + */ + constructor(config) { + this.config = config; + this.globals = captureGlobals(); + if (!this.config.hasModernWebkitAPI) { + this.captureWebkitHandlers(this.config.webkitMessageHandlerNames); + } } - /** - * @returns {import("zod").infer|undefined} - */ - validateParams() { - if (this.params === undefined) { - return undefined; + * Sends message to the webkit layer (fire and forget) + * @param {String} handler + * @param {*} data + * @internal + */ + wkSend(handler) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + if (!(handler in this.globals.window.webkit.messageHandlers)) { + throw new _messaging.MissingHandler(`Missing webkit handler: '${handler}'`, handler); } - this._validate(this.params, this.paramsValidator); - return this.params; + const outgoing = { + ...data, + messageHandling: { + ...data.messageHandling, + secret: this.config.secret + } + }; + if (!this.config.hasModernWebkitAPI) { + if (!(handler in this.globals.capturedWebkitHandlers)) { + throw new _messaging.MissingHandler(`cannot continue, method ${handler} not captured on macos < 11`, handler); + } else { + return this.globals.capturedWebkitHandlers[handler](outgoing); + } + } + return this.globals.window.webkit.messageHandlers[handler].postMessage?.(outgoing); } /** - * @param {any|null} incoming - * @returns {import("zod").infer} - */ - validateResult(incoming) { - this._validate(incoming, this.resultValidator); - if (!incoming) { - return incoming; - } - if (!this.unwrapResult) { - return incoming; - } - if ('data' in incoming) { - console.warn('response had `data` property. Please migrate to `success`'); - return incoming.data; - } - if ('success' in incoming) { - return incoming.success; + * Sends message to the webkit layer and waits for the specified response + * @param {String} handler + * @param {*} data + * @returns {Promise<*>} + * @internal + */ + async wkSendAndWait(handler) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + if (this.config.hasModernWebkitAPI) { + const response = await this.wkSend(handler, data); + return this.globals.JSONparse(response || '{}'); } - if ('error' in incoming) { - if (typeof incoming.error.message === 'string') { - throw new DeviceApiCallError(`${this.method}: ${incoming.error.message}`); + try { + const randMethodName = this.createRandMethodName(); + const key = await this.createRandKey(); + const iv = this.createRandIv(); + const { + ciphertext, + tag + } = await new this.globals.Promise(( /** @type {any} */resolve) => { + this.generateRandomMethod(randMethodName, resolve); + data.messageHandling = new SecureMessagingParams({ + methodName: randMethodName, + secret: this.config.secret, + key: this.globals.Arrayfrom(key), + iv: this.globals.Arrayfrom(iv) + }); + this.wkSend(handler, data); + }); + const cipher = new this.globals.Uint8Array([...ciphertext, ...tag]); + const decrypted = await this.decrypt(cipher, key, iv); + return this.globals.JSONparse(decrypted || '{}'); + } catch (e) { + // re-throw when the error is just a 'MissingHandler' + if (e instanceof _messaging.MissingHandler) { + throw e; + } else { + console.error('decryption failed', e); + console.error(e); + return { + error: e + }; } } - if (this.throwOnResultKeysMissing) { - throw new Error('unreachable. Response did not contain `success` or `data`'); - } - return incoming; } - /** - * @param {any} data - * @param {import("zod").ZodType|undefined|null} [validator] - * @private - */ - _validate(data, validator) { - if (!validator) return data; - if (validator) { - const result = validator?.safeParse(data); - if (!result) { - throw new Error('unreachable, data failure', data); - } - if (!result.success) { - if ('error' in result) { - this.throwError(result.error.issues); - } else { - console.error('unknown error from validate'); - } + * @param {string} name + * @param {Record} [data] + */ + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + this.wkSend(name, data); + } + /** + * @param {string} name + * @param {Record} [data] + */ + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return this.wkSendAndWait(name, data); + } + /** + * Generate a random method name and adds it to the global scope + * The native layer will use this method to send the response + * @param {string | number} randomMethodName + * @param {Function} callback + */ + generateRandomMethod(randomMethodName, callback) { + var _this = this; + this.globals.ObjectDefineProperty(this.globals.window, randomMethodName, { + enumerable: false, + // configurable, To allow for deletion later + configurable: true, + writable: false, + /** + * @param {any[]} args + */ + value: function () { + callback(...arguments); + // @ts-ignore - we want this to throw if it fails as it would indicate a fatal error. + delete _this.globals.window[randomMethodName]; } - } + }); + } + randomString() { + return '' + this.globals.getRandomValues(new this.globals.Uint32Array(1))[0]; + } + createRandMethodName() { + return '_' + this.randomString(); } /** - * @param {import('zod').ZodIssue[]} errors - */ - throwError(errors) { - const error = SchemaValidationError.fromZodErrors(errors, this.constructor.name); - throw error; - } + * @type {{name: string, length: number}} + */ + algoObj = { + name: 'AES-GCM', + length: 256 + }; /** - * Use this helper for creating stand-in response messages that are typed correctly. - * - * @examples - * - * ```js - * const msg = new Message(); - * const response = msg.response({}) // <-- This argument will be typed correctly - * ``` - * - * @param {import("zod").infer} response - * @returns {import("zod").infer} - */ - result(response) { - return response; + * @returns {Promise} + */ + async createRandKey() { + const key = await this.globals.generateKey(this.algoObj, true, ['encrypt', 'decrypt']); + const exportedKey = await this.globals.exportKey('raw', key); + return new this.globals.Uint8Array(exportedKey); } - /** - * @returns {import("zod").infer} - */ - preResultValidation(response) { - return response; + + /** + * @returns {Uint8Array} + */ + createRandIv() { + return this.globals.getRandomValues(new this.globals.Uint8Array(12)); } -} -exports.DeviceApiCall = DeviceApiCall; -class DeviceApiCallError extends Error {} -/** - * Check for this error if you'd like to - */ -exports.DeviceApiCallError = DeviceApiCallError; -class SchemaValidationError extends Error { - /** @type {import("zod").ZodIssue[]} */ - validationErrors = []; + /** + * @param {BufferSource} ciphertext + * @param {BufferSource} key + * @param {Uint8Array} iv + * @returns {Promise} + */ + async decrypt(ciphertext, key, iv) { + const cryptoKey = await this.globals.importKey('raw', key, 'AES-GCM', false, ['decrypt']); + const algo = { + name: 'AES-GCM', + iv + }; + let decrypted = await this.globals.decrypt(algo, cryptoKey, ciphertext); + let dec = new this.globals.TextDecoder(); + return dec.decode(decrypted); + } /** - * @param {import("zod").ZodIssue[]} errors - * @param {string} name - * @returns {SchemaValidationError} - */ - static fromZodErrors(errors, name) { - const heading = `${errors.length} SchemaValidationError(s) errors for ` + name; - function log(issue) { - switch (issue.code) { - case 'invalid_literal': - case 'invalid_type': - { - console.log(`${name}. Path: '${issue.path.join('.')}', Error: '${issue.message}'`); - break; - } - case 'invalid_union': - { - for (let unionError of issue.unionErrors) { - for (let issue1 of unionError.issues) { - log(issue1); - } - } - break; - } - default: - { - console.log(name, 'other issue:', issue); - } + * When required (such as on macos 10.x), capture the `postMessage` method on + * each webkit messageHandler + * + * @param {string[]} handlerNames + */ + captureWebkitHandlers(handlerNames) { + const handlers = window.webkit.messageHandlers; + if (!handlers) throw new _messaging.MissingHandler('window.webkit.messageHandlers was absent', 'all'); + for (let webkitMessageHandlerName of handlerNames) { + if (typeof handlers[webkitMessageHandlerName]?.postMessage === 'function') { + /** + * `bind` is used here to ensure future calls to the captured + * `postMessage` have the correct `this` context + */ + const original = handlers[webkitMessageHandlerName]; + const bound = handlers[webkitMessageHandlerName].postMessage?.bind(original); + this.globals.capturedWebkitHandlers[webkitMessageHandlerName] = bound; + delete handlers[webkitMessageHandlerName].postMessage; } } - for (let error of errors) { - log(error); - } - const message = [heading, 'please see the details above'].join('\n '); - const error = new SchemaValidationError(message); - error.validationErrors = errors; - return error; } } /** - * Creates an instance of `DeviceApiCall` from only a name and 'params' - * and optional validators. Use this to help migrate existing messages. - * - * @template {import("zod").ZodType} Params - * @template {import("zod").ZodType} Result - * @param {string} method - * @param {import("zod").infer} [params] - * @param {Params|null} [paramsValidator] - * @param {Result|null} [resultValidator] - * @returns {DeviceApiCall} - */ -exports.SchemaValidationError = SchemaValidationError; -function createDeviceApiCall(method, params) { - let paramsValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - let resultValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - /** @type {DeviceApiCall} */ - const deviceApiCall = new DeviceApiCall(params); - deviceApiCall.paramsValidator = paramsValidator; - deviceApiCall.resultValidator = resultValidator; - deviceApiCall.method = method; - deviceApiCall.throwOnResultKeysMissing = false; - deviceApiCall.unwrapResult = false; - return deviceApiCall; -} - -/** - * Creates an instance of `DeviceApiCall` from only a name and 'params' - * and optional validators. Use this to help migrate existing messages. + * Use this configuration to create an instance of {@link Messaging} for WebKit * - * Note: This creates a regular DeviceApiCall, but adds the 'id' as a string - * so that transports know that it expects a response. + * ```js + * import { fromConfig, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" * - * @template {import("zod").ZodType} Params - * @template {import("zod").ZodType} Result - * @param {string} method - * @param {import("zod").infer} [params] - * @param {string} [id] - * @param {Params|null} [paramsValidator] - * @param {Result|null} [resultValidator] - * @returns {DeviceApiCall} - */ -function createRequest(method, params) { - let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n/a'; - let paramsValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - let resultValidator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; - const call = createDeviceApiCall(method, params, paramsValidator, resultValidator); - call.id = id; - return call; -} -const createNotification = exports.createNotification = createDeviceApiCall; - -/** - * Validate any arbitrary data with any Zod validator + * const config = new WebkitMessagingConfig({ + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }); * - * @template {import("zod").ZodType} Validator - * @param {any} data - * @param {Validator | null} [validator] - * @returns {import("zod").infer} + * const messaging = new Messaging(config) + * const resp = await messaging.request("debugConfig") + * ``` */ -function validate(data) { - let validator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - if (validator) { - return validator.parse(data); +exports.WebkitMessagingTransport = WebkitMessagingTransport; +class WebkitMessagingConfig { + /** + * @param {object} params + * @param {boolean} params.hasModernWebkitAPI + * @param {string[]} params.webkitMessageHandlerNames + * @param {string} params.secret + */ + constructor(params) { + /** + * Whether or not the current WebKit Platform supports secure messaging + * by default (eg: macOS 11+) + */ + this.hasModernWebkitAPI = params.hasModernWebkitAPI; + /** + * A list of WebKit message handler names that a user script can send + */ + this.webkitMessageHandlerNames = params.webkitMessageHandlerNames; + /** + * A string provided by native platforms to be sent with future outgoing + * messages + */ + this.secret = params.secret; } - return data; } -},{}],18:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DeviceApiTransport = exports.DeviceApi = void 0; /** - * Platforms should only need to implement this `send` method + * This is the additional payload that gets appended to outgoing messages. + * It's used in the Swift side to encrypt the response that comes back */ -class DeviceApiTransport { +exports.WebkitMessagingConfig = WebkitMessagingConfig; +class SecureMessagingParams { /** - * @param {import("./device-api-call.js").DeviceApiCall} _deviceApiCall - * @param {CallOptions} [_options] - * @returns {Promise} - */ - async send(_deviceApiCall, _options) { - return undefined; + * @param {object} params + * @param {string} params.methodName + * @param {string} params.secret + * @param {number[]} params.key + * @param {number[]} params.iv + */ + constructor(params) { + /** + * The method that's been appended to `window` to be called later + */ + this.methodName = params.methodName; + /** + * The secret used to ensure message sender validity + */ + this.secret = params.secret; + /** + * The CipherKey as number[] + */ + this.key = params.key; + /** + * The Initial Vector as number[] + */ + this.iv = params.iv; } } /** - * This is the base Sender class that platforms can will implement. - * - * Note: The 'handle' method must be implemented, unless you also implement 'send' - * - * @typedef CallOptions - * @property {AbortSignal} [signal] + * Capture some globals used for messaging handling to prevent page + * scripts from tampering with this */ -exports.DeviceApiTransport = DeviceApiTransport; -class DeviceApi { - /** @type {DeviceApiTransport} */ - transport; - /** @param {DeviceApiTransport} transport */ - constructor(transport) { - this.transport = transport; - } - /** - * @template {import("./device-api-call").DeviceApiCall} D - * @param {D} deviceApiCall - * @param {CallOptions} [options] - * @returns {Promise['success']>>} - */ - async request(deviceApiCall, options) { - deviceApiCall.validateParams(); - let result = await this.transport.send(deviceApiCall, options); - let processed = deviceApiCall.preResultValidation(result); - return deviceApiCall.validateResult(processed); - } - /** - * @template {import("./device-api-call").DeviceApiCall} P - * @param {P} deviceApiCall - * @param {CallOptions} [options] - * @returns {Promise} - */ - async notify(deviceApiCall, options) { - deviceApiCall.validateParams(); - return this.transport.send(deviceApiCall, options); - } +exports.SecureMessagingParams = SecureMessagingParams; +function captureGlobals() { + // Creat base with null prototype + return { + window, + // Methods must be bound to their interface, otherwise they throw Illegal invocation + encrypt: window.crypto.subtle.encrypt.bind(window.crypto.subtle), + decrypt: window.crypto.subtle.decrypt.bind(window.crypto.subtle), + generateKey: window.crypto.subtle.generateKey.bind(window.crypto.subtle), + exportKey: window.crypto.subtle.exportKey.bind(window.crypto.subtle), + importKey: window.crypto.subtle.importKey.bind(window.crypto.subtle), + getRandomValues: window.crypto.getRandomValues.bind(window.crypto), + TextEncoder, + TextDecoder, + Uint8Array, + Uint16Array, + Uint32Array, + JSONstringify: window.JSON.stringify, + JSONparse: window.JSON.parse, + Arrayfrom: window.Array.from, + Promise: window.Promise, + ObjectDefineProperty: window.Object.defineProperty, + addEventListener: window.addEventListener.bind(window), + /** @type {Record} */ + capturedWebkitHandlers: {} + }; } -exports.DeviceApi = DeviceApi; -},{}],19:[function(require,module,exports){ +},{"./messaging.js":15}],17:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5152,7 +5067,7 @@ function _safeHostname(inputHostname) { } } -},{"./lib/apple.password.js":20,"./lib/constants.js":21,"./lib/rules-parser.js":22}],20:[function(require,module,exports){ +},{"./lib/apple.password.js":18,"./lib/constants.js":19,"./lib/rules-parser.js":20}],18:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5681,7 +5596,7 @@ class Password { } exports.Password = Password; -},{"./constants.js":21,"./rules-parser.js":22}],21:[function(require,module,exports){ +},{"./constants.js":19,"./rules-parser.js":20}],19:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5701,7 +5616,7 @@ const constants = exports.constants = { DEFAULT_UNAMBIGUOUS_CHARS }; -},{}],22:[function(require,module,exports){ +},{}],20:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6297,7 +6212,7 @@ function parsePasswordRules(input, formatRulesForMinifiedVersion) { return newPasswordRules; } -},{}],23:[function(require,module,exports){ +},{}],21:[function(require,module,exports){ module.exports={ "163.com": { "password-rules": "minlength: 6; maxlength: 16;" @@ -7128,7 +7043,7 @@ module.exports={ "password-rules": "minlength: 8; maxlength: 32; max-consecutive: 6; required: lower; required: upper; required: digit;" } } -},{}],24:[function(require,module,exports){ +},{}],22:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7184,7 +7099,7 @@ function createDevice() { return new _ExtensionInterface.ExtensionInterface(globalConfig, deviceApi, settings); } -},{"../packages/device-api/index.js":16,"./DeviceInterface/AndroidInterface.js":25,"./DeviceInterface/AppleDeviceInterface.js":26,"./DeviceInterface/AppleOverlayDeviceInterface.js":27,"./DeviceInterface/ExtensionInterface.js":28,"./DeviceInterface/WindowsInterface.js":30,"./DeviceInterface/WindowsOverlayDeviceInterface.js":31,"./Settings.js":52,"./config.js":65,"./deviceApiCalls/transports/transports.js":73}],25:[function(require,module,exports){ +},{"../packages/device-api/index.js":12,"./DeviceInterface/AndroidInterface.js":23,"./DeviceInterface/AppleDeviceInterface.js":24,"./DeviceInterface/AppleOverlayDeviceInterface.js":25,"./DeviceInterface/ExtensionInterface.js":26,"./DeviceInterface/WindowsInterface.js":28,"./DeviceInterface/WindowsOverlayDeviceInterface.js":29,"./Settings.js":50,"./config.js":63,"./deviceApiCalls/transports/transports.js":71}],23:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7310,7 +7225,7 @@ class AndroidInterface extends _InterfacePrototype.default { } exports.AndroidInterface = AndroidInterface; -},{"../UI/controllers/NativeUIController.js":58,"../autofill-utils.js":63,"./InterfacePrototype.js":29,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],26:[function(require,module,exports){ +},{"../UI/controllers/NativeUIController.js":56,"../autofill-utils.js":61,"./InterfacePrototype.js":27,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],24:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7696,7 +7611,7 @@ class AppleDeviceInterface extends _InterfacePrototype.default { } exports.AppleDeviceInterface = AppleDeviceInterface; -},{"../../packages/device-api/index.js":16,"../Form/matching.js":45,"../InContextSignup.js":46,"../UI/HTMLTooltip.js":56,"../UI/controllers/HTMLTooltipUIController.js":57,"../UI/controllers/NativeUIController.js":58,"../UI/controllers/OverlayUIController.js":59,"../autofill-utils.js":63,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"../deviceApiCalls/additionalDeviceApiCalls.js":69,"./InterfacePrototype.js":29,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],27:[function(require,module,exports){ +},{"../../packages/device-api/index.js":12,"../Form/matching.js":43,"../InContextSignup.js":44,"../UI/HTMLTooltip.js":54,"../UI/controllers/HTMLTooltipUIController.js":55,"../UI/controllers/NativeUIController.js":56,"../UI/controllers/OverlayUIController.js":57,"../autofill-utils.js":61,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"../deviceApiCalls/additionalDeviceApiCalls.js":67,"./InterfacePrototype.js":27,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],25:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7830,7 +7745,7 @@ class AppleOverlayDeviceInterface extends _AppleDeviceInterface.AppleDeviceInter } exports.AppleOverlayDeviceInterface = AppleOverlayDeviceInterface; -},{"../../packages/device-api/index.js":16,"../UI/controllers/HTMLTooltipUIController.js":57,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"../deviceApiCalls/__generated__/validators.zod.js":68,"./AppleDeviceInterface.js":26,"./overlayApi.js":33}],28:[function(require,module,exports){ +},{"../../packages/device-api/index.js":12,"../UI/controllers/HTMLTooltipUIController.js":55,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"../deviceApiCalls/__generated__/validators.zod.js":66,"./AppleDeviceInterface.js":24,"./overlayApi.js":31}],26:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8061,7 +7976,7 @@ class ExtensionInterface extends _InterfacePrototype.default { } exports.ExtensionInterface = ExtensionInterface; -},{"../Form/matching.js":45,"../InContextSignup.js":46,"../UI/HTMLTooltip.js":56,"../UI/controllers/HTMLTooltipUIController.js":57,"../autofill-utils.js":63,"./InterfacePrototype.js":29}],29:[function(require,module,exports){ +},{"../Form/matching.js":43,"../InContextSignup.js":44,"../UI/HTMLTooltip.js":54,"../UI/controllers/HTMLTooltipUIController.js":55,"../autofill-utils.js":61,"./InterfacePrototype.js":27}],27:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8942,7 +8857,7 @@ class InterfacePrototype { } var _default = exports.default = InterfacePrototype; -},{"../../packages/device-api/index.js":16,"../EmailProtection.js":34,"../Form/formatters.js":38,"../Form/matching.js":45,"../InputTypes/Credentials.js":47,"../PasswordGenerator.js":50,"../Scanner.js":51,"../Settings.js":52,"../UI/controllers/NativeUIController.js":58,"../autofill-utils.js":63,"../config.js":65,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"../deviceApiCalls/__generated__/validators.zod.js":68,"../deviceApiCalls/transports/transports.js":73,"./initFormSubmissionsApi.js":32}],30:[function(require,module,exports){ +},{"../../packages/device-api/index.js":12,"../EmailProtection.js":32,"../Form/formatters.js":36,"../Form/matching.js":43,"../InputTypes/Credentials.js":45,"../PasswordGenerator.js":48,"../Scanner.js":49,"../Settings.js":50,"../UI/controllers/NativeUIController.js":56,"../autofill-utils.js":61,"../config.js":63,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"../deviceApiCalls/__generated__/validators.zod.js":66,"../deviceApiCalls/transports/transports.js":71,"./initFormSubmissionsApi.js":30}],28:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9114,7 +9029,7 @@ class WindowsInterface extends _InterfacePrototype.default { } exports.WindowsInterface = WindowsInterface; -},{"../UI/controllers/OverlayUIController.js":59,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"./InterfacePrototype.js":29}],31:[function(require,module,exports){ +},{"../UI/controllers/OverlayUIController.js":57,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"./InterfacePrototype.js":27}],29:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9293,7 +9208,7 @@ class WindowsOverlayDeviceInterface extends _InterfacePrototype.default { } exports.WindowsOverlayDeviceInterface = WindowsOverlayDeviceInterface; -},{"../UI/controllers/HTMLTooltipUIController.js":57,"../deviceApiCalls/__generated__/deviceApiCalls.js":67,"./InterfacePrototype.js":29,"./overlayApi.js":33}],32:[function(require,module,exports){ +},{"../UI/controllers/HTMLTooltipUIController.js":55,"../deviceApiCalls/__generated__/deviceApiCalls.js":65,"./InterfacePrototype.js":27,"./overlayApi.js":31}],30:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9385,7 +9300,7 @@ function initFormSubmissionsApi(forms, matching) { }); } -},{"../Form/label-util.js":41,"../autofill-utils.js":63}],33:[function(require,module,exports){ +},{"../Form/label-util.js":39,"../autofill-utils.js":61}],31:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9443,7 +9358,7 @@ function overlayApi(device) { }; } -},{"../deviceApiCalls/__generated__/deviceApiCalls.js":67}],34:[function(require,module,exports){ +},{"../deviceApiCalls/__generated__/deviceApiCalls.js":65}],32:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9478,7 +9393,7 @@ class EmailProtection { } exports.EmailProtection = EmailProtection; -},{}],35:[function(require,module,exports){ +},{}],33:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10280,7 +10195,7 @@ class Form { } exports.Form = Form; -},{"../autofill-utils.js":63,"../constants.js":66,"./FormAnalyzer.js":36,"./formatters.js":38,"./inputStyles.js":39,"./inputTypeConfig.js":40,"./matching.js":45}],36:[function(require,module,exports){ +},{"../autofill-utils.js":61,"../constants.js":64,"./FormAnalyzer.js":34,"./formatters.js":36,"./inputStyles.js":37,"./inputTypeConfig.js":38,"./matching.js":43}],34:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10627,7 +10542,7 @@ class FormAnalyzer { } var _default = exports.default = FormAnalyzer; -},{"../autofill-utils.js":63,"../constants.js":66,"./matching-config/__generated__/compiled-matching-config.js":43,"./matching.js":45}],37:[function(require,module,exports){ +},{"../autofill-utils.js":61,"../constants.js":64,"./matching-config/__generated__/compiled-matching-config.js":41,"./matching.js":43}],35:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11192,7 +11107,7 @@ const COUNTRY_NAMES_TO_CODES = exports.COUNTRY_NAMES_TO_CODES = { 'Unknown Region': 'ZZ' }; -},{}],38:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11497,7 +11412,7 @@ const prepareFormValuesForStorage = formValues => { }; exports.prepareFormValuesForStorage = prepareFormValuesForStorage; -},{"./countryNames.js":37,"./matching.js":45}],39:[function(require,module,exports){ +},{"./countryNames.js":35,"./matching.js":43}],37:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11588,7 +11503,7 @@ const getIconStylesAutofilled = (input, form) => { }; exports.getIconStylesAutofilled = getIconStylesAutofilled; -},{"./inputTypeConfig.js":40}],40:[function(require,module,exports){ +},{"./inputTypeConfig.js":38}],38:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11831,7 +11746,7 @@ const isFieldDecorated = input => { }; exports.isFieldDecorated = isFieldDecorated; -},{"../InputTypes/Credentials.js":47,"../InputTypes/CreditCard.js":48,"../InputTypes/Identity.js":49,"../UI/img/ddgPasswordIcon.js":61,"../constants.js":66,"./logo-svg.js":42,"./matching.js":45}],41:[function(require,module,exports){ +},{"../InputTypes/Credentials.js":45,"../InputTypes/CreditCard.js":46,"../InputTypes/Identity.js":47,"../UI/img/ddgPasswordIcon.js":59,"../constants.js":64,"./logo-svg.js":40,"./matching.js":43}],39:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11879,7 +11794,7 @@ const extractElementStrings = element => { }; exports.extractElementStrings = extractElementStrings; -},{"./matching.js":45}],42:[function(require,module,exports){ +},{"./matching.js":43}],40:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11912,7 +11827,7 @@ const daxGrayscaleSvg = ` `.trim(); const daxGrayscaleBase64 = exports.daxGrayscaleBase64 = `data:image/svg+xml;base64,${window.btoa(daxGrayscaleSvg)}`; -},{}],43:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12358,7 +12273,7 @@ const matchingConfiguration = exports.matchingConfiguration = { } }; -},{}],44:[function(require,module,exports){ +},{}],42:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12433,7 +12348,7 @@ function logUnmatched(el, allStrings) { console.groupEnd(); } -},{"../autofill-utils.js":63,"./matching.js":45}],45:[function(require,module,exports){ +},{"../autofill-utils.js":61,"./matching.js":43}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12689,8 +12604,8 @@ class Matching { this.setActiveElementStrings(input, formEl); if (this.subtypeFromMatchers('unknown', input)) return 'unknown'; - // // For CC forms we run aggressive matches, so we want to make sure we only - // // run them on actual CC forms to avoid false positives and expensive loops + // For CC forms we run aggressive matches, so we want to make sure we only + // run them on actual CC forms to avoid false positives and expensive loops if (opts.isCCForm) { const subtype = this.subtypeFromMatchers('cc', input); if (subtype && isValidCreditCardSubtype(subtype)) { @@ -13339,7 +13254,7 @@ function createMatching() { return new Matching(_compiledMatchingConfig.matchingConfiguration); } -},{"../autofill-utils.js":63,"../constants.js":66,"./label-util.js":41,"./matching-config/__generated__/compiled-matching-config.js":43,"./matching-utils.js":44}],46:[function(require,module,exports){ +},{"../autofill-utils.js":61,"../constants.js":64,"./label-util.js":39,"./matching-config/__generated__/compiled-matching-config.js":41,"./matching-utils.js":42}],44:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13471,7 +13386,7 @@ class InContextSignup { } exports.InContextSignup = InContextSignup; -},{"./autofill-utils.js":63,"./deviceApiCalls/__generated__/deviceApiCalls.js":67}],47:[function(require,module,exports){ +},{"./autofill-utils.js":61,"./deviceApiCalls/__generated__/deviceApiCalls.js":65}],45:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13618,7 +13533,7 @@ function createCredentialsTooltipItem(data) { return new CredentialsTooltipItem(data); } -},{"../autofill-utils.js":63}],48:[function(require,module,exports){ +},{"../autofill-utils.js":61}],46:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13641,7 +13556,7 @@ class CreditCardTooltipItem { } exports.CreditCardTooltipItem = CreditCardTooltipItem; -},{}],49:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13681,7 +13596,7 @@ class IdentityTooltipItem { } exports.IdentityTooltipItem = IdentityTooltipItem; -},{"../Form/formatters.js":38}],50:[function(require,module,exports){ +},{"../Form/formatters.js":36}],48:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13723,7 +13638,7 @@ class PasswordGenerator { } exports.PasswordGenerator = PasswordGenerator; -},{"../packages/password/index.js":19,"../packages/password/rules.json":23}],51:[function(require,module,exports){ +},{"../packages/password/index.js":17,"../packages/password/rules.json":21}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14086,7 +14001,7 @@ function createScanner(device, scannerOptions) { }); } -},{"./Form/Form.js":35,"./Form/matching.js":45,"./autofill-utils.js":63,"./constants.js":66,"./deviceApiCalls/__generated__/deviceApiCalls.js":67}],52:[function(require,module,exports){ +},{"./Form/Form.js":33,"./Form/matching.js":43,"./autofill-utils.js":61,"./constants.js":64,"./deviceApiCalls/__generated__/deviceApiCalls.js":65}],50:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14431,7 +14346,7 @@ class Settings { } exports.Settings = Settings; -},{"../packages/device-api/index.js":16,"./autofill-utils.js":63,"./deviceApiCalls/__generated__/deviceApiCalls.js":67,"./deviceApiCalls/__generated__/validators.zod.js":68,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],53:[function(require,module,exports){ +},{"../packages/device-api/index.js":12,"./autofill-utils.js":61,"./deviceApiCalls/__generated__/deviceApiCalls.js":65,"./deviceApiCalls/__generated__/validators.zod.js":66,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],51:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14559,7 +14474,7 @@ ${css} } var _default = exports.default = DataHTMLTooltip; -},{"../InputTypes/Credentials.js":47,"../autofill-utils.js":63,"./HTMLTooltip.js":56}],54:[function(require,module,exports){ +},{"../InputTypes/Credentials.js":45,"../autofill-utils.js":61,"./HTMLTooltip.js":54}],52:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14637,7 +14552,7 @@ ${this.options.css} } var _default = exports.default = EmailHTMLTooltip; -},{"../autofill-utils.js":63,"./HTMLTooltip.js":56}],55:[function(require,module,exports){ +},{"../autofill-utils.js":61,"./HTMLTooltip.js":54}],53:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -14693,7 +14608,7 @@ ${this.options.css} } var _default = exports.default = EmailSignupHTMLTooltip; -},{"./HTMLTooltip.js":56}],56:[function(require,module,exports){ +},{"./HTMLTooltip.js":54}],54:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15080,7 +14995,7 @@ class HTMLTooltip { exports.HTMLTooltip = HTMLTooltip; var _default = exports.default = HTMLTooltip; -},{"../Form/matching.js":45,"../autofill-utils.js":63,"./styles/styles.js":62}],57:[function(require,module,exports){ +},{"../Form/matching.js":43,"../autofill-utils.js":61,"./styles/styles.js":60}],55:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15431,7 +15346,7 @@ class HTMLTooltipUIController extends _UIController.UIController { } exports.HTMLTooltipUIController = HTMLTooltipUIController; -},{"../../Form/inputTypeConfig.js":40,"../../Form/matching.js":45,"../../autofill-utils.js":63,"../DataHTMLTooltip.js":53,"../EmailHTMLTooltip.js":54,"../EmailSignupHTMLTooltip.js":55,"../HTMLTooltip.js":56,"./UIController.js":60}],58:[function(require,module,exports){ +},{"../../Form/inputTypeConfig.js":38,"../../Form/matching.js":43,"../../autofill-utils.js":61,"../DataHTMLTooltip.js":51,"../EmailHTMLTooltip.js":52,"../EmailSignupHTMLTooltip.js":53,"../HTMLTooltip.js":54,"./UIController.js":58}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15593,7 +15508,7 @@ class NativeUIController extends _UIController.UIController { } exports.NativeUIController = NativeUIController; -},{"../../Form/matching.js":45,"../../InputTypes/Credentials.js":47,"../../deviceApiCalls/__generated__/deviceApiCalls.js":67,"./UIController.js":60}],59:[function(require,module,exports){ +},{"../../Form/matching.js":43,"../../InputTypes/Credentials.js":45,"../../deviceApiCalls/__generated__/deviceApiCalls.js":65,"./UIController.js":58}],57:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15830,7 +15745,7 @@ class OverlayUIController extends _UIController.UIController { } exports.OverlayUIController = OverlayUIController; -},{"../../Form/matching.js":45,"./UIController.js":60}],60:[function(require,module,exports){ +},{"../../Form/matching.js":43,"./UIController.js":58}],58:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15914,7 +15829,7 @@ class UIController { } exports.UIController = UIController; -},{}],61:[function(require,module,exports){ +},{}],59:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15929,7 +15844,7 @@ const ddgCcIconBase = exports.ddgCcIconBase = 'data:image/svg+xml;base64,PD94bWw const ddgCcIconFilled = exports.ddgCcIconFilled = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+CiAgICA8cGF0aCBkPSJNNSA5Yy0uNTUyIDAtMSAuNDQ4LTEgMXYyYzAgLjU1Mi40NDggMSAxIDFoM2MuNTUyIDAgMS0uNDQ4IDEtMXYtMmMwLS41NTItLjQ0OC0xLTEtMUg1eiIgZmlsbD0iIzc2NDMxMCIvPgogICAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xIDZjMC0yLjIxIDEuNzktNCA0LTRoMTRjMi4yMSAwIDQgMS43OSA0IDR2MTJjMCAyLjIxLTEuNzkgNC00IDRINWMtMi4yMSAwLTQtMS43OS00LTRWNnptNC0yYy0xLjEwNSAwLTIgLjg5NS0yIDJ2OWgxOFY2YzAtMS4xMDUtLjg5NS0yLTItMkg1em0wIDE2Yy0xLjEwNSAwLTItLjg5NS0yLTJoMThjMCAxLjEwNS0uODk1IDItMiAySDV6IiBmaWxsPSIjNzY0MzEwIi8+Cjwvc3ZnPgo='; const ddgIdentityIconBase = exports.ddgIdentityIconBase = `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+CiAgICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEyIDIxYzIuMTQzIDAgNC4xMTEtLjc1IDUuNjU3LTItLjYyNi0u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Mzk3LTUuMDgzYy45NjcuNDIyIDEuODY2Ljk4IDIuNjcyIDEuNjU1QzIwLjI3OSAxNi4wMzkgMjEgMTQuMTA0IDIxIDEyYzAtNC45Ny00LjAzLTktOS05cy05IDQuMDMtOSA5YzAgMi4xMDQuNzIyIDQuMDQgMS45MzIgNS41NzIuODc0LS43MzQgMS44Ni0xLjMyOCAyLjkyMS0xLjc2IDEuMzYtLjU1NCAyLjgxNi0uODMgNC4yODMtLjgxMSAxLjQ2Ny4wMTggMi45MTYuMzMgNC4yNi45MTZ6TTEyIDIzYzYuMDc1IDAgMTEtNC45MjUgMTEtMTFTMTguMDc1IDEgMTIgMSAxIDUuOTI1IDEgMTJzNC45MjUgMTEgMTEgMTF6bTMtMTNjMCAxLjY1Ny0xLjM0MyAzLTMgM3MtMy0xLjM0My0zLTMgMS4zNDMtMyAzLTMgMyAxLjM0MyAzIDN6bTIgMGMwIDIuNzYxLTIuMjM5IDUtNSA1cy01LTIuMjM5LTUtNSAyLjIzOS01IDUtNSA1IDIuMjM5IDUgNXoiIGZpbGw9IiMwMDAiLz4KPC9zdmc+Cg==`; -},{}],62:[function(require,module,exports){ +},{}],60:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -15938,7 +15853,7 @@ Object.defineProperty(exports, "__esModule", { exports.CSS_STYLES = void 0; const CSS_STYLES = exports.CSS_STYLES = ":root {\n color-scheme: light dark;\n}\n\n.wrapper *, .wrapper *::before, .wrapper *::after {\n box-sizing: border-box;\n}\n.wrapper {\n position: fixed;\n top: 0;\n left: 0;\n padding: 0;\n font-family: 'DDG_ProximaNova', 'Proxima Nova', system-ui, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n z-index: 2147483647;\n}\n.wrapper--data {\n font-family: 'SF Pro Text', system-ui, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n}\n:not(.top-autofill) .tooltip {\n position: absolute;\n width: 300px;\n max-width: calc(100vw - 25px);\n transform: translate(-1000px, -1000px);\n z-index: 2147483647;\n}\n.tooltip--data, #topAutofill {\n background-color: rgba(242, 240, 240, 1);\n -webkit-backdrop-filter: blur(40px);\n backdrop-filter: blur(40px);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip--data, #topAutofill {\n background: rgb(100, 98, 102, .9);\n }\n}\n.tooltip--data {\n padding: 6px;\n font-size: 13px;\n line-height: 14px;\n width: 315px;\n max-height: 290px;\n overflow-y: auto;\n}\n.top-autofill .tooltip--data {\n min-height: 100vh;\n}\n.tooltip--data.tooltip--incontext-signup {\n width: 360px;\n}\n:not(.top-autofill) .tooltip--data {\n top: 100%;\n left: 100%;\n border: 0.5px solid rgba(255, 255, 255, 0.2);\n border-radius: 6px;\n box-shadow: 0 10px 20px rgba(0, 0, 0, 0.32);\n}\n@media (prefers-color-scheme: dark) {\n :not(.top-autofill) .tooltip--data {\n border: 1px solid rgba(255, 255, 255, 0.2);\n }\n}\n:not(.top-autofill) .tooltip--email {\n top: calc(100% + 6px);\n right: calc(100% - 48px);\n padding: 8px;\n border: 1px solid #D0D0D0;\n border-radius: 10px;\n background-color: #FFFFFF;\n font-size: 14px;\n line-height: 1.3;\n color: #333333;\n box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);\n}\n.tooltip--email__caret {\n position: absolute;\n transform: translate(-1000px, -1000px);\n z-index: 2147483647;\n}\n.tooltip--email__caret::before,\n.tooltip--email__caret::after {\n content: \"\";\n width: 0;\n height: 0;\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n display: block;\n border-bottom: 8px solid #D0D0D0;\n position: absolute;\n right: -28px;\n}\n.tooltip--email__caret::before {\n border-bottom-color: #D0D0D0;\n top: -1px;\n}\n.tooltip--email__caret::after {\n border-bottom-color: #FFFFFF;\n top: 0px;\n}\n\n/* Buttons */\n.tooltip__button {\n display: flex;\n width: 100%;\n padding: 8px 8px 8px 0px;\n font-family: inherit;\n color: inherit;\n background: transparent;\n border: none;\n border-radius: 6px;\n}\n.tooltip__button.currentFocus,\n.wrapper:not(.top-autofill) .tooltip__button:hover {\n background-color: #3969EF;\n color: #FFFFFF;\n}\n\n/* Data autofill tooltip specific */\n.tooltip__button--data {\n position: relative;\n min-height: 48px;\n flex-direction: row;\n justify-content: flex-start;\n font-size: inherit;\n font-weight: 500;\n line-height: 16px;\n text-align: left;\n border-radius: 3px;\n}\n.tooltip--data__item-container {\n max-height: 220px;\n overflow: auto;\n}\n.tooltip__button--data:first-child {\n margin-top: 0;\n}\n.tooltip__button--data:last-child {\n margin-bottom: 0;\n}\n.tooltip__button--data::before {\n content: '';\n flex-shrink: 0;\n display: block;\n width: 32px;\n height: 32px;\n margin: 0 8px;\n background-size: 20px 20px;\n background-repeat: no-repeat;\n background-position: center 6px;\n}\n#provider_locked::after {\n position: absolute;\n content: '';\n flex-shrink: 0;\n display: block;\n width: 32px;\n height: 32px;\n margin: 0 8px;\n background-size: 11px 13px;\n background-repeat: no-repeat;\n background-position: right bottom;\n}\n.tooltip__button--data.currentFocus:not(.tooltip__button--data--bitwarden)::before,\n.wrapper:not(.top-autofill) .tooltip__button--data:not(.tooltip__button--data--bitwarden):hover::before {\n filter: invert(100%);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip__button--data:not(.tooltip__button--data--bitwarden)::before,\n .tooltip__button--data:not(.tooltip__button--data--bitwarden)::before {\n filter: invert(100%);\n opacity: .9;\n }\n}\n.tooltip__button__text-container {\n margin: auto 0;\n}\n.label {\n display: block;\n font-weight: 400;\n letter-spacing: -0.25px;\n color: rgba(0,0,0,.8);\n font-size: 13px;\n line-height: 1;\n}\n.label + .label {\n margin-top: 2px;\n}\n.label.label--medium {\n font-weight: 500;\n letter-spacing: -0.25px;\n color: rgba(0,0,0,.9);\n}\n.label.label--small {\n font-size: 11px;\n font-weight: 400;\n letter-spacing: 0.06px;\n color: rgba(0,0,0,0.6);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip--data .label {\n color: #ffffff;\n }\n .tooltip--data .label--medium {\n color: #ffffff;\n }\n .tooltip--data .label--small {\n color: #cdcdcd;\n }\n}\n.tooltip__button.currentFocus .label,\n.wrapper:not(.top-autofill) .tooltip__button:hover .label {\n color: #FFFFFF;\n}\n\n.tooltip__button--manage {\n font-size: 13px;\n padding: 5px 9px;\n border-radius: 3px;\n margin: 0;\n}\n\n/* Icons */\n.tooltip__button--data--credentials::before {\n background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjYzNiA4LjY4MkM5LjYzNiA1LjU0NCAxMi4xOCAzIDE1LjMxOCAzIDE4LjQ1NiAzIDIxIDUuNTQ0IDIxIDguNjgyYzAgMy4xMzgtMi41NDQgNS42ODItNS42ODIgNS42ODItLjY5MiAwLTEuMzUzLS4xMjQtMS45NjQtLjM0OS0uMzcyLS4xMzctLjc5LS4wNDEtMS4wNjYuMjQ1bC0uNzEzLjc0SDEwYy0uNTUyIDAtMSAuNDQ4LTEgMXYySDdjLS41NTIgMC0xIC40NDgtMSAxdjJIM3YtMi44ODFsNi42NjgtNi42NjhjLjI2NS0uMjY2LjM2LS42NTguMjQ0LTEuMDE1LS4xNzktLjU1MS0uMjc2LTEuMTQtLjI3Ni0xLjc1NHpNMTUuMzE4IDFjLTQuMjQyIDAtNy42ODIgMy40NC03LjY4MiA3LjY4MiAwIC42MDcuMDcxIDEuMi4yMDUgMS43NjdsLTYuNTQ4IDYuNTQ4Yy0uMTg4LjE4OC0uMjkzLjQ0Mi0uMjkzLjcwOFYyMmMwIC4yNjUuMTA1LjUyL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DMS42MTczMiA2LjEwNjM3IDEuNDk4MTcgNi4yMzQ0NiAxLjM5NTc4IDYuMzc2NzhDMS4xMzkyNiA2LjczMzM1IDEuMDAwODUgNy4xNjEzMSAxIDcuNjAwNTdaTTQuOTY4NyA0Ljk2ODdDNS4wMjY5NCA0LjkxMDQ3IDUuMTA1MzIgNC44NzY5OSA1LjE4NzUgNC44NzUwN0M1LjI2OTY4IDQuODc2OTkgNS4zNDgwNiA0LjkxMDQ3IDUuNDA2MyA0Ljk2ODdDNS40NjU0MiA1LjAyNzgzIDUuNDk5MDQgNS4xMDc3NCA1LjUgNS4xOTEzVjUuNUg0Ljg3NVY1LjE5MTNDNC44NzU5NiA1LjEwNzc0IDQuOTA5NTggNS4wMjc4MyA0Ljk2ODcgNC45Njg3WiIgZmlsbD0iIzIyMjIyMiIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIi8+Cjwvc3ZnPgo=');\n}\n\nhr {\n display: block;\n margin: 5px 9px;\n border: none; /* reset the border */\n border-top: 1px solid rgba(0,0,0,.1);\n}\n\nhr:first-child {\n display: none;\n}\n\n@media (prefers-color-scheme: dark) {\n hr {\n border-top: 1px solid rgba(255,255,255,.2);\n }\n}\n\n#privateAddress {\n align-items: flex-start;\n}\n#personalAddress::before,\n#privateAddress::before,\n#incontextSignup::before,\n#personalAddress.currentFocus::before,\n#personalAddress:hover::before,\n#privateAddress.currentFocus::before,\n#privateAddress:hover::before {\n filter: none;\n /* This is the same icon as `daxBase64` in `src/Form/logo-svg.js` */\n background-image: url('data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiB2aWV3Qm94PSIwIDAgMTI4IDEyOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0ibTY0IDEyOGMzNS4zNDYgMCA2NC0yOC42NTQgNjQtNjRzLTI4LjY1NC02NC02NC02NC02NCAyO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2ZW5vZGQiLz4KPC9zdmc+');\n}\n\n/* Email tooltip specific */\n.tooltip__button--email {\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n font-size: 14px;\n padding: 4px 8px;\n}\n.tooltip__button--email__primary-text {\n font-weight: bold;\n}\n.tooltip__button--email__secondary-text {\n font-size: 12px;\n}\n\n/* Email Protection signup notice */\n:not(.top-autofill) .tooltip--email-signup {\n text-align: left;\n color: #222222;\n padding: 16px 20px;\n width: 380px;\n}\n\n.tooltip--email-signup h1 {\n font-weight: 700;\n font-size: 16px;\n line-height: 1.5;\n margin: 0;\n}\n\n.tooltip--email-signup p {\n font-weight: 400;\n font-size: 14px;\n line-height: 1.4;\n}\n\n.notice-controls {\n display: flex;\n}\n\n.tooltip--email-signup .notice-controls > * {\n border-radius: 8px;\n border: 0;\n cursor: pointer;\n display: inline-block;\n font-family: inherit;\n font-style: normal;\n font-weight: bold;\n padding: 8px 12px;\n text-decoration: none;\n}\n\n.notice-controls .ghost {\n margin-left: 1rem;\n}\n\n.tooltip--email-signup a.primary {\n background: #3969EF;\n color: #fff;\n}\n\n.tooltip--email-signup a.primary:hover,\n.tooltip--email-signup a.primary:focus {\n background: #2b55ca;\n}\n\n.tooltip--email-signup a.primary:active {\n background: #1e42a4;\n}\n\n.tooltip--email-signup button.ghost {\n background: transparent;\n color: #3969EF;\n}\n\n.tooltip--email-signup button.ghost:hover,\n.tooltip--email-signup button.ghost:focus {\n background-color: rgba(0, 0, 0, 0.06);\n color: #2b55ca;\n}\n\n.tooltip--email-signup button.ghost:active {\n background-color: rgba(0, 0, 0, 0.12);\n color: #1e42a4;\n}\n\n.tooltip--email-signup button.close-tooltip {\n background-color: transparent;\n background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMiAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0wLjI5Mjg5NCAwLjY1NjkwN0MwLjY4MzQxOCAwLjI2NjM4MyAxLjMxNjU4IDAuMjY2MzgzIDEuNzA3MTEgMC42NTY5MDdMNiA0Ljk0OThMMTAuMjkyOSAwLjY1NjkwN0MxMC42ODM0IDAuMjY2MzgzIDExLjMxNjYgMC4yNjYzODMgMTEuNzA3MSAwLjY1NjkwN0MxMi4wOTc2IDEuMDQ3NDMgMTIuMDk3NiAxLjY4MDYgMTEuNzA3MSAyLjA3MTEyTDcuNDE0MjEgNi4zNjQwMUwxMS43MDcxIDEwLjY1NjlDMTIuMDk3NiAxMS4wNDc0IDEyLjA5NzYgMTEuNjgwNiAxMS43MDcxIDEyLjA3MTFDMTEuMzE2NiAxMi40NjE2IDEwLjY4MzQgMTIuNDYxNiAxMC4yOTI5IDEyLjA3MTFMNiA3Ljc3ODIzTDEuNzA3MTEgMTIuMDcxMUMxLjMxNjU4IDEyLjQ2MTYgMC42ODM0MTcgMTIuNDYxNiAwLjI5Mjg5MyAxMi4wNzExQy0wLjA5NzYzMTEgMTEuNjgwNiAtMC4wOTc2MzExIDExLjA0NzQgMC4yOTI4OTMgMTAuNjU2OUw0LjU4NTc5IDYuMzY0MDFMMC4yOTI4OTQgMi4wNzExMkMtMC4wOTc2MzA2IDEuNjgwNiAtMC4wOTc2MzA2IDEuMDQ3NDMgMC4yOTI4OTQgMC42NTY5MDdaIiBmaWxsPSJibGFjayIgZmlsbC1vcGFjaXR5PSIwLjg0Ii8+Cjwvc3ZnPgo=);\n background-position: center center;\n background-repeat: no-repeat;\n border: 0;\n cursor: pointer;\n padding: 16px;\n position: absolute;\n right: 12px;\n top: 12px;\n}\n"; -},{}],63:[function(require,module,exports){ +},{}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -16494,7 +16409,7 @@ function isFormLikelyToBeUsedAsPageWrapper(form) { return formChildrenPercentage > 50; } -},{"./Form/matching.js":45}],64:[function(require,module,exports){ +},{"./Form/matching.js":43}],62:[function(require,module,exports){ "use strict"; require("./requestIdleCallback.js"); @@ -16525,7 +16440,7 @@ var _autofillUtils = require("./autofill-utils.js"); } })(); -},{"./DeviceInterface.js":24,"./autofill-utils.js":63,"./requestIdleCallback.js":75}],65:[function(require,module,exports){ +},{"./DeviceInterface.js":22,"./autofill-utils.js":61,"./requestIdleCallback.js":73}],63:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -16614,7 +16529,7 @@ function createGlobalConfig(overrides) { return config; } -},{}],66:[function(require,module,exports){ +},{}],64:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -16631,7 +16546,7 @@ const constants = exports.constants = { MAX_FORM_MUT_OBS_COUNT: 50 }; -},{}],67:[function(require,module,exports){ +},{}],65:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -16868,7 +16783,7 @@ class CloseEmailProtectionTabCall extends _deviceApi.DeviceApiCall { } exports.CloseEmailProtectionTabCall = CloseEmailProtectionTabCall; -},{"../../../packages/device-api":16,"./validators.zod.js":68}],68:[function(require,module,exports){ +},{"../../../packages/device-api":12,"./validators.zod.js":66}],66:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17260,7 +17175,7 @@ const apiSchema = exports.apiSchema = _zod.z.object({ closeEmailProtectionTab: _zod.z.record(_zod.z.unknown()).optional() }); -},{"zod":13}],69:[function(require,module,exports){ +},{"zod":9}],67:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17286,7 +17201,7 @@ class GetAlias extends _index.DeviceApiCall { } exports.GetAlias = GetAlias; -},{"../../packages/device-api/index.js":16,"./__generated__/validators.zod.js":68}],70:[function(require,module,exports){ +},{"../../packages/device-api/index.js":12,"./__generated__/validators.zod.js":66}],68:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17412,14 +17327,14 @@ function androidSpecificAvailableInputTypes(globalConfig) { }; } -},{"../../../packages/device-api/index.js":16,"../__generated__/deviceApiCalls.js":67}],71:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":12,"../__generated__/deviceApiCalls.js":65}],69:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppleTransport = void 0; -var _contentScopeUtils = require("@duckduckgo/content-scope-utils"); +var _messaging = require("../../../packages/messaging/messaging.js"); var _index = require("../../../packages/device-api/index.js"); var _deviceApiCalls = require("../__generated__/deviceApiCalls.js"); class AppleTransport extends _index.DeviceApiTransport { @@ -17427,12 +17342,12 @@ class AppleTransport extends _index.DeviceApiTransport { constructor(globalConfig) { super(); this.config = globalConfig; - const webkitConfig = new _contentScopeUtils.WebkitMessagingConfig({ + const webkitConfig = new _messaging.WebkitMessagingConfig({ hasModernWebkitAPI: this.config.hasModernWebkitAPI, webkitMessageHandlerNames: this.config.webkitMessageHandlerNames, secret: this.config.secret }); - this.messaging = new _contentScopeUtils.Messaging(webkitConfig); + this.messaging = new _messaging.Messaging(webkitConfig); } async send(deviceApiCall) { try { @@ -17443,7 +17358,7 @@ class AppleTransport extends _index.DeviceApiTransport { return this.messaging.notify(deviceApiCall.method, deviceApiCall.params || undefined); } } catch (e) { - if (e instanceof _contentScopeUtils.MissingHandler) { + if (e instanceof _messaging.MissingHandler) { if (this.config.isDDGTestMode) { console.log('MissingWebkitHandler error for:', deviceApiCall.method); } @@ -17478,7 +17393,7 @@ function appleSpecificRuntimeConfiguration(globalConfig) { }; } -},{"../../../packages/device-api/index.js":16,"../__generated__/deviceApiCalls.js":67,"@duckduckgo/content-scope-utils":2}],72:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":12,"../../../packages/messaging/messaging.js":15,"../__generated__/deviceApiCalls.js":65}],70:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17630,7 +17545,7 @@ async function extensionSpecificSetIncontextSignupPermanentlyDismissedAtCall(par }); } -},{"../../../packages/device-api/index.js":16,"../../Settings.js":52,"../../autofill-utils.js":63,"../__generated__/deviceApiCalls.js":67}],73:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":12,"../../Settings.js":50,"../../autofill-utils.js":61,"../__generated__/deviceApiCalls.js":65}],71:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17674,7 +17589,7 @@ function createTransport(globalConfig) { return new _extensionTransport.ExtensionTransport(globalConfig); } -},{"./android.transport.js":70,"./apple.transport.js":71,"./extension.transport.js":72,"./windows.transport.js":74}],74:[function(require,module,exports){ +},{"./android.transport.js":68,"./apple.transport.js":69,"./extension.transport.js":70,"./windows.transport.js":72}],72:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17759,7 +17674,7 @@ function waitForWindowsResponse(responseId, options) { }); } -},{"../../../packages/device-api/index.js":16}],75:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":12}],73:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -17802,4 +17717,4 @@ window.cancelIdleCallback = window.cancelIdleCallback || function (id) { }; var _default = exports.default = {}; -},{}]},{},[64]); +},{}]},{},[62]); diff --git a/swift-package/Resources/assets/autofill.js b/swift-package/Resources/assets/autofill.js index 5eeb00d03..2371f2b2b 100644 --- a/swift-package/Resources/assets/autofill.js +++ b/swift-package/Resources/assets/autofill.js @@ -55,222 +55,402 @@ function processConfig(data, userList, preferences) { Object.defineProperty(exports, "__esModule", { value: true }); -var _messaging = require("./messaging.js"); -Object.keys(_messaging).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (key in exports && exports[key] === _messaging[key]) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _messaging[key]; - } - }); +Object.defineProperty(exports, "DeviceApi", { + enumerable: true, + get: function () { + return _deviceApi.DeviceApi; + } }); - -},{"./messaging.js":3}],3:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true +Object.defineProperty(exports, "DeviceApiCall", { + enumerable: true, + get: function () { + return _deviceApiCall.DeviceApiCall; + } }); -exports.MissingHandler = exports.MessagingTransport = exports.Messaging = void 0; -Object.defineProperty(exports, "WebkitMessagingConfig", { +Object.defineProperty(exports, "DeviceApiTransport", { enumerable: true, get: function () { - return _webkit.WebkitMessagingConfig; + return _deviceApi.DeviceApiTransport; } }); -Object.defineProperty(exports, "WindowsMessagingConfig", { +Object.defineProperty(exports, "createNotification", { enumerable: true, get: function () { - return _windows.WindowsMessagingConfig; + return _deviceApiCall.createNotification; } }); -var _windows = require("./messaging/windows.js"); -var _webkit = require("./messaging/webkit.js"); -/** - * @module Messaging - * - * @description - * - * An abstraction for communications between JavaScript and host platforms. - * - * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) - * 2) Then use that to get an instance of the Messaging utility which allows - * you to send and receive data in a unified way - * 3) Each platform implements {@link MessagingTransport} along with its own Configuration - * - For example, to learn what configuration is required for Webkit, see: {@link "Webkit Messaging".WebkitMessagingConfig} - * - Or, to learn about how messages are sent and received in Webkit, see {@link "Webkit Messaging".WebkitMessagingTransport} - * - * @example Webkit Messaging - * - * ```js - * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // This config would be injected into the UserScript - * const injectedConfig = { - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }; - * - * // Then use that config to construct platform-specific configuration - * const config = new WebkitMessagingConfig(injectedConfig); - * - * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 - * const messaging = new Messaging(config); - * messaging.notify("hello world!", {foo: "bar"}) - * - * ``` - * - * @example Windows Messaging - * - * ```js - * import { Messaging, WindowsMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * // Messaging on Windows is namespaced, so you can create multiple messaging instances - * const autofillConfig = new WindowsMessagingConfig({ featureName: "Autofill" }); - * const debugConfig = new WindowsMessagingConfig({ featureName: "Debugging" }); - * - * const autofillMessaging = new Messaging(autofillConfig); - * const debugMessaging = new Messaging(debugConfig); - * - * // Now send messages to both features as needed 🚀 - * autofillMessaging.notify("storeFormData", { "username": "dax" }) - * debugMessaging.notify("pageLoad", { time: window.performance.now() }) - * ``` - */ +Object.defineProperty(exports, "createRequest", { + enumerable: true, + get: function () { + return _deviceApiCall.createRequest; + } +}); +Object.defineProperty(exports, "validate", { + enumerable: true, + get: function () { + return _deviceApiCall.validate; + } +}); +var _deviceApiCall = require("./lib/device-api-call.js"); +var _deviceApi = require("./lib/device-api.js"); + +},{"./lib/device-api-call.js":3,"./lib/device-api.js":4}],3:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.SchemaValidationError = exports.DeviceApiCallError = exports.DeviceApiCall = void 0; +exports.createDeviceApiCall = createDeviceApiCall; +exports.createNotification = void 0; +exports.createRequest = createRequest; +exports.validate = validate; /** - * @implements {MessagingTransport} + * This roughly follows https://www.jsonrpc.org/specification + * @template {import("zod").ZodType} Params=import("zod").ZodType + * @template {import("zod").ZodType} Result=import("zod").ZodType */ -class Messaging { +class DeviceApiCall { + /** @type {string} */ + method = 'unknown'; /** - * @param {WebkitMessagingConfig | WindowsMessagingConfig} config + * An optional 'id' - used to indicate if a request requires a response. + * @type {string|null} */ - constructor(config) { - this.transport = getTransport(config); - } + id = null; + /** @type {Params | null | undefined} */ + paramsValidator = null; + /** @type {Result | null | undefined} */ + resultValidator = null; + /** @type {import("zod").infer} */ + params; /** - * Send a 'fire-and-forget' message. - * @throws - * {@link MissingHandler} - * - * @example - * - * ``` - * const messaging = new Messaging(config) - * messaging.notify("foo", {bar: "baz"}) - * ``` - * @param {string} name - * @param {Record} [data] + * This is a carve-out for legacy messages that are not typed yet. + * If you set this to 'true', then the response will not be checked to conform + * to any shape + * @deprecated this is here to aid migration, should be removed ASAP + * @type {boolean} */ - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - this.transport.notify(name, data); - } + throwOnResultKeysMissing = true; /** - * Send a request, and wait for a response - * @throws - * {@link MissingHandler} - * - * @example - * ``` - * const messaging = new Messaging(config) - * const response = await messaging.request("foo", {bar: "baz"}) - * ``` - * - * @param {string} name - * @param {Record} [data] - * @return {Promise} + * New messages should be in a particular format, eg: { success: T }, + * but you can set this to false if you want to access the result as-is, + * without any unwrapping logic + * @deprecated this is here to aid migration, should be removed ASAP + * @type {boolean} */ - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - return this.transport.request(name, data); + unwrapResult = true; + /** + * @param {import("zod").infer} data + */ + constructor(data) { + this.params = data; } -} -/** - * @interface - */ -exports.Messaging = Messaging; -class MessagingTransport { /** - * @param {string} name - * @param {Record} [data] - * @returns {void} + * @returns {import("zod").infer|undefined} */ - // @ts-ignore - ignoring a no-unused ts error, this is only an interface. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error("must implement 'notify'"); + validateParams() { + if (this.params === undefined) { + return undefined; + } + this._validate(this.params, this.paramsValidator); + return this.params; } + /** - * @param {string} name - * @param {Record} [data] - * @return {Promise} + * @param {any|null} incoming + * @returns {import("zod").infer} */ - // @ts-ignore - ignoring a no-unused ts error, this is only an interface. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error('must implement'); + validateResult(incoming) { + this._validate(incoming, this.resultValidator); + if (!incoming) { + return incoming; + } + if (!this.unwrapResult) { + return incoming; + } + if ('data' in incoming) { + console.warn('response had `data` property. Please migrate to `success`'); + return incoming.data; + } + if ('success' in incoming) { + return incoming.success; + } + if ('error' in incoming) { + if (typeof incoming.error.message === 'string') { + throw new DeviceApiCallError(`${this.method}: ${incoming.error.message}`); + } + } + if (this.throwOnResultKeysMissing) { + throw new Error('unreachable. Response did not contain `success` or `data`'); + } + return incoming; } -} -/** - * @param {WebkitMessagingConfig | WindowsMessagingConfig} config - * @returns {MessagingTransport} - */ -exports.MessagingTransport = MessagingTransport; -function getTransport(config) { - if (config instanceof _webkit.WebkitMessagingConfig) { - return new _webkit.WebkitMessagingTransport(config); - } - if (config instanceof _windows.WindowsMessagingConfig) { - return new _windows.WindowsMessagingTransport(config); + /** + * @param {any} data + * @param {import("zod").ZodType|undefined|null} [validator] + * @private + */ + _validate(data, validator) { + if (!validator) return data; + if (validator) { + const result = validator?.safeParse(data); + if (!result) { + throw new Error('unreachable, data failure', data); + } + if (!result.success) { + if ('error' in result) { + this.throwError(result.error.issues); + } else { + console.error('unknown error from validate'); + } + } + } } - throw new Error('unreachable'); -} -/** - * Thrown when a handler cannot be found - */ -class MissingHandler extends Error { /** - * @param {string} message - * @param {string} handlerName + * @param {import('zod').ZodIssue[]} errors */ - constructor(message, handlerName) { - super(message); - this.handlerName = handlerName; + throwError(errors) { + const error = SchemaValidationError.fromZodErrors(errors, this.constructor.name); + throw error; } -} -/** - * Some re-exports for convenience - */ -exports.MissingHandler = MissingHandler; + /** + * Use this helper for creating stand-in response messages that are typed correctly. + * + * @examples + * + * ```js + * const msg = new Message(); + * const response = msg.response({}) // <-- This argument will be typed correctly + * ``` + * + * @param {import("zod").infer} response + * @returns {import("zod").infer} + */ + result(response) { + return response; + } + /** + * @returns {import("zod").infer} + */ + preResultValidation(response) { + return response; + } +} +exports.DeviceApiCall = DeviceApiCall; +class DeviceApiCallError extends Error {} + +/** + * Check for this error if you'd like to + */ +exports.DeviceApiCallError = DeviceApiCallError; +class SchemaValidationError extends Error { + /** @type {import("zod").ZodIssue[]} */ + validationErrors = []; + + /** + * @param {import("zod").ZodIssue[]} errors + * @param {string} name + * @returns {SchemaValidationError} + */ + static fromZodErrors(errors, name) { + const heading = `${errors.length} SchemaValidationError(s) errors for ` + name; + function log(issue) { + switch (issue.code) { + case 'invalid_literal': + case 'invalid_type': + { + console.log(`${name}. Path: '${issue.path.join('.')}', Error: '${issue.message}'`); + break; + } + case 'invalid_union': + { + for (let unionError of issue.unionErrors) { + for (let issue1 of unionError.issues) { + log(issue1); + } + } + break; + } + default: + { + console.log(name, 'other issue:', issue); + } + } + } + for (let error of errors) { + log(error); + } + const message = [heading, 'please see the details above'].join('\n '); + const error = new SchemaValidationError(message); + error.validationErrors = errors; + return error; + } +} + +/** + * Creates an instance of `DeviceApiCall` from only a name and 'params' + * and optional validators. Use this to help migrate existing messages. + * + * @template {import("zod").ZodType} Params + * @template {import("zod").ZodType} Result + * @param {string} method + * @param {import("zod").infer} [params] + * @param {Params|null} [paramsValidator] + * @param {Result|null} [resultValidator] + * @returns {DeviceApiCall} + */ +exports.SchemaValidationError = SchemaValidationError; +function createDeviceApiCall(method, params) { + let paramsValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + let resultValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + /** @type {DeviceApiCall} */ + const deviceApiCall = new DeviceApiCall(params); + deviceApiCall.paramsValidator = paramsValidator; + deviceApiCall.resultValidator = resultValidator; + deviceApiCall.method = method; + deviceApiCall.throwOnResultKeysMissing = false; + deviceApiCall.unwrapResult = false; + return deviceApiCall; +} + +/** + * Creates an instance of `DeviceApiCall` from only a name and 'params' + * and optional validators. Use this to help migrate existing messages. + * + * Note: This creates a regular DeviceApiCall, but adds the 'id' as a string + * so that transports know that it expects a response. + * + * @template {import("zod").ZodType} Params + * @template {import("zod").ZodType} Result + * @param {string} method + * @param {import("zod").infer} [params] + * @param {string} [id] + * @param {Params|null} [paramsValidator] + * @param {Result|null} [resultValidator] + * @returns {DeviceApiCall} + */ +function createRequest(method, params) { + let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n/a'; + let paramsValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + let resultValidator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; + const call = createDeviceApiCall(method, params, paramsValidator, resultValidator); + call.id = id; + return call; +} +const createNotification = exports.createNotification = createDeviceApiCall; + +/** + * Validate any arbitrary data with any Zod validator + * + * @template {import("zod").ZodType} Validator + * @param {any} data + * @param {Validator | null} [validator] + * @returns {import("zod").infer} + */ +function validate(data) { + let validator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + if (validator) { + return validator.parse(data); + } + return data; +} -},{"./messaging/webkit.js":4,"./messaging/windows.js":5}],4:[function(require,module,exports){ +},{}],4:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.WebkitMessagingTransport = exports.WebkitMessagingConfig = exports.SecureMessagingParams = void 0; -var _messaging = require("../messaging.js"); +exports.DeviceApiTransport = exports.DeviceApi = void 0; /** - * @module Webkit Messaging + * Platforms should only need to implement this `send` method + */ +class DeviceApiTransport { + /** + * @param {import("./device-api-call.js").DeviceApiCall} _deviceApiCall + * @param {CallOptions} [_options] + * @returns {Promise} + */ + async send(_deviceApiCall, _options) { + return undefined; + } +} + +/** + * This is the base Sender class that platforms can will implement. + * + * Note: The 'handle' method must be implemented, unless you also implement 'send' + * + * @typedef CallOptions + * @property {AbortSignal} [signal] + */ +exports.DeviceApiTransport = DeviceApiTransport; +class DeviceApi { + /** @type {DeviceApiTransport} */ + transport; + /** @param {DeviceApiTransport} transport */ + constructor(transport) { + this.transport = transport; + } + /** + * @template {import("./device-api-call").DeviceApiCall} D + * @param {D} deviceApiCall + * @param {CallOptions} [options] + * @returns {Promise['success']>>} + */ + async request(deviceApiCall, options) { + deviceApiCall.validateParams(); + let result = await this.transport.send(deviceApiCall, options); + let processed = deviceApiCall.preResultValidation(result); + return deviceApiCall.validateResult(processed); + } + /** + * @template {import("./device-api-call").DeviceApiCall} P + * @param {P} deviceApiCall + * @param {CallOptions} [options] + * @returns {Promise} + */ + async notify(deviceApiCall, options) { + deviceApiCall.validateParams(); + return this.transport.send(deviceApiCall, options); + } +} +exports.DeviceApi = DeviceApi; + +},{}],5:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.MissingHandler = exports.MessagingTransport = exports.Messaging = void 0; +Object.defineProperty(exports, "WebkitMessagingConfig", { + enumerable: true, + get: function () { + return _webkit.WebkitMessagingConfig; + } +}); +var _webkit = require("./webkit.js"); +/** + * @module Messaging * * @description * - * A wrapper for messaging on WebKit platforms. It supports modern WebKit messageHandlers - * along with encryption for older versions (like macOS Catalina) + * An abstraction for communications between JavaScript and host platforms. * - * Note: If you wish to support Catalina then you'll need to implement the native - * part of the message handling, see {@link WebkitMessagingTransport} for details. + * 1) First you construct your platform-specific configuration (eg: {@link WebkitMessagingConfig}) + * 2) Then use that to get an instance of the Messaging utility which allows + * you to send and receive data in a unified way + * 3) Each platform implements {@link MessagingTransport} along with its own Configuration + * - For example, to learn what configuration is required for Webkit, see: {@link "Webkit Messaging".WebkitMessagingConfig} + * - Or, to learn about how messages are sent and received in Webkit, see {@link "Webkit Messaging".WebkitMessagingTransport} + * + * @example Webkit Messaging * * ```js * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" @@ -290,36 +470,202 @@ var _messaging = require("../messaging.js"); * messaging.notify("hello world!", {foo: "bar"}) * * ``` - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars - -/** - * @example - * On macOS 11+, this will just call through to `window.webkit.messageHandlers.x.postMessage` * - * Eg: for a `foo` message defined in Swift that accepted the payload `{"bar": "baz"}`, the following - * would occur: + * @example Windows Messaging * * ```js - * const json = await window.webkit.messageHandlers.foo.postMessage({ bar: "baz" }); - * const response = JSON.parse(json) - * ``` + * import { Messaging, WindowsMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" * - * @example - * On macOS 10 however, the process is a little more involved. A method will be appended to `window` - * that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow - * as being something along the lines of: + * // Messaging on Windows is namespaced, so you can create multiple messaging instances + * const autofillConfig = new WindowsMessagingConfig({ featureName: "Autofill" }); + * const debugConfig = new WindowsMessagingConfig({ featureName: "Debugging" }); * - * ```js - * // add the window method - * window["_0123456"] = (response) => { - * // decrypt `response` and deliver the result to the caller here - * // then remove the temporary method - * delete window["_0123456"] - * }; + * const autofillMessaging = new Messaging(autofillConfig); + * const debugMessaging = new Messaging(debugConfig); * - * // send the data + `messageHanding` values - * window.webkit.messageHandlers.foo.postMessage({ + * // Now send messages to both features as needed 🚀 + * autofillMessaging.notify("storeFormData", { "username": "dax" }) + * debugMessaging.notify("pageLoad", { time: window.performance.now() }) + * ``` + */ + +/** + * @implements {MessagingTransport} + */ +class Messaging { + /** + * @param {WebkitMessagingConfig} config + */ + constructor(config) { + this.transport = getTransport(config); + } + /** + * Send a 'fire-and-forget' message. + * @throws {Error} + * {@link MissingHandler} + * + * @example + * + * ``` + * const messaging = new Messaging(config) + * messaging.notify("foo", {bar: "baz"}) + * ``` + * @param {string} name + * @param {Record} [data] + */ + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + this.transport.notify(name, data); + } + /** + * Send a request, and wait for a response + * @throws {Error} + * {@link MissingHandler} + * + * @example + * ``` + * const messaging = new Messaging(config) + * const response = await messaging.request("foo", {bar: "baz"}) + * ``` + * + * @param {string} name + * @param {Record} [data] + * @return {Promise} + */ + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return this.transport.request(name, data); + } +} + +/** + * @interface + */ +exports.Messaging = Messaging; +class MessagingTransport { + /** + * @param {string} name + * @param {Record} [data] + * @returns {void} + */ + // @ts-ignore - ignoring a no-unused ts error, this is only an interface. + notify(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + throw new Error("must implement 'notify'"); + } + /** + * @param {string} name + * @param {Record} [data] + * @return {Promise} + */ + // @ts-ignore - ignoring a no-unused ts error, this is only an interface. + request(name) { + let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + throw new Error('must implement'); + } +} + +/** + * @param {WebkitMessagingConfig} config + * @returns {MessagingTransport} + */ +exports.MessagingTransport = MessagingTransport; +function getTransport(config) { + if (config instanceof _webkit.WebkitMessagingConfig) { + return new _webkit.WebkitMessagingTransport(config); + } + throw new Error('unreachable'); +} + +/** + * Thrown when a handler cannot be found + */ +class MissingHandler extends Error { + /** + * @param {string} message + * @param {string} handlerName + */ + constructor(message, handlerName) { + super(message); + this.handlerName = handlerName; + } +} + +/** + * Some re-exports for convenience + */ +exports.MissingHandler = MissingHandler; + +},{"./webkit.js":6}],6:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.WebkitMessagingTransport = exports.WebkitMessagingConfig = exports.SecureMessagingParams = void 0; +var _messaging = require("./messaging.js"); +/** + * @module Webkit Messaging + * + * @description + * + * A wrapper for messaging on WebKit platforms. It supports modern WebKit messageHandlers + * along with encryption for older versions (like macOS Catalina) + * + * Note: If you wish to support Catalina then you'll need to implement the native + * part of the message handling, see {@link WebkitMessagingTransport} for details. + * + * ```js + * import { Messaging, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" + * + * // This config would be injected into the UserScript + * const injectedConfig = { + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }; + * + * // Then use that config to construct platform-specific configuration + * const config = new WebkitMessagingConfig(injectedConfig); + * + * // finally, get an instance of Messaging and start sending messages in a unified way 🚀 + * const messaging = new Messaging(config); + * messaging.notify("hello world!", {foo: "bar"}) + * + * ``` + */ + +/** + * @typedef {import("./messaging").MessagingTransport} MessagingTransport + */ + +/** + * @example + * On macOS 11+, this will just call through to `window.webkit.messageHandlers.x.postMessage` + * + * Eg: for a `foo` message defined in Swift that accepted the payload `{"bar": "baz"}`, the following + * would occur: + * + * ```js + * const json = await window.webkit.messageHandlers.foo.postMessage({ bar: "baz" }); + * const response = JSON.parse(json) + * ``` + * + * @example + * On macOS 10 however, the process is a little more involved. A method will be appended to `window` + * that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow + * as being something along the lines of: + * + * ```js + * // add the window method + * window["_0123456"] = (response) => { + * // decrypt `response` and deliver the result to the caller here + * // then remove the temporary method + * delete window["_0123456"] + * }; + * + * // send the data + `messageHanding` values + * window.webkit.messageHandlers.foo.postMessage({ * bar: "baz", * messagingHandling: { * methodName: "_0123456", @@ -344,8 +690,8 @@ class WebkitMessagingTransport { config; globals; /** - * @param {WebkitMessagingConfig} config - */ + * @param {WebkitMessagingConfig} config + */ constructor(config) { this.config = config; this.globals = captureGlobals(); @@ -354,11 +700,11 @@ class WebkitMessagingTransport { } } /** - * Sends message to the webkit layer (fire and forget) - * @param {String} handler - * @param {*} data - * @internal - */ + * Sends message to the webkit layer (fire and forget) + * @param {String} handler + * @param {*} data + * @internal + */ wkSend(handler) { let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (!(handler in this.globals.window.webkit.messageHandlers)) { @@ -382,12 +728,12 @@ class WebkitMessagingTransport { } /** - * Sends message to the webkit layer and waits for the specified response - * @param {String} handler - * @param {*} data - * @returns {Promise<*>} - * @internal - */ + * Sends message to the webkit layer and waits for the specified response + * @param {String} handler + * @param {*} data + * @returns {Promise<*>} + * @internal + */ async wkSendAndWait(handler) { let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (this.config.hasModernWebkitAPI) { @@ -428,28 +774,27 @@ class WebkitMessagingTransport { } } /** - * @param {string} name - * @param {Record} [data] - */ + * @param {string} name + * @param {Record} [data] + */ notify(name) { let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; this.wkSend(name, data); } /** - * @param {string} name - * @param {Record} [data] - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars + * @param {string} name + * @param {Record} [data] + */ request(name) { let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; return this.wkSendAndWait(name, data); } /** - * Generate a random method name and adds it to the global scope - * The native layer will use this method to send the response - * @param {string | number} randomMethodName - * @param {Function} callback - */ + * Generate a random method name and adds it to the global scope + * The native layer will use this method to send the response + * @param {string | number} randomMethodName + * @param {Function} callback + */ generateRandomMethod(randomMethodName, callback) { var _this = this; this.globals.ObjectDefineProperty(this.globals.window, randomMethodName, { @@ -458,8 +803,8 @@ class WebkitMessagingTransport { configurable: true, writable: false, /** - * @param {any[]} args - */ + * @param {any[]} args + */ value: function () { callback(...arguments); // @ts-ignore - we want this to throw if it fails as it would indicate a fatal error. @@ -475,16 +820,16 @@ class WebkitMessagingTransport { } /** - * @type {{name: string, length: number}} - */ + * @type {{name: string, length: number}} + */ algoObj = { name: 'AES-GCM', length: 256 }; /** - * @returns {Promise} - */ + * @returns {Promise} + */ async createRandKey() { const key = await this.globals.generateKey(this.algoObj, true, ['encrypt', 'decrypt']); const exportedKey = await this.globals.exportKey('raw', key); @@ -492,591 +837,161 @@ class WebkitMessagingTransport { } /** - * @returns {Uint8Array} - */ + * @returns {Uint8Array} + */ createRandIv() { - return this.globals.getRandomValues(new this.globals.Uint8Array(12)); - } - - /** - * @param {BufferSource} ciphertext - * @param {BufferSource} key - * @param {Uint8Array} iv - * @returns {Promise} - */ - async decrypt(ciphertext, key, iv) { - const cryptoKey = await this.globals.importKey('raw', key, 'AES-GCM', false, ['decrypt']); - const algo = { - name: 'AES-GCM', - iv - }; - let decrypted = await this.globals.decrypt(algo, cryptoKey, ciphertext); - let dec = new this.globals.TextDecoder(); - return dec.decode(decrypted); - } - - /** - * When required (such as on macos 10.x), capture the `postMessage` method on - * each webkit messageHandler - * - * @param {string[]} handlerNames - */ - captureWebkitHandlers(handlerNames) { - const handlers = window.webkit.messageHandlers; - if (!handlers) throw new _messaging.MissingHandler('window.webkit.messageHandlers was absent', 'all'); - for (let webkitMessageHandlerName of handlerNames) { - if (typeof handlers[webkitMessageHandlerName]?.postMessage === 'function') { - /** - * `bind` is used here to ensure future calls to the captured - * `postMessage` have the correct `this` context - */ - const original = handlers[webkitMessageHandlerName]; - const bound = handlers[webkitMessageHandlerName].postMessage?.bind(original); - this.globals.capturedWebkitHandlers[webkitMessageHandlerName] = bound; - delete handlers[webkitMessageHandlerName].postMessage; - } - } - } -} - -/** - * Use this configuration to create an instance of {@link Messaging} for WebKit - * - * ```js - * import { fromConfig, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" - * - * const config = new WebkitMessagingConfig({ - * hasModernWebkitAPI: true, - * webkitMessageHandlerNames: ["foo", "bar", "baz"], - * secret: "dax", - * }); - * - * const messaging = new Messaging(config) - * const resp = await messaging.request("debugConfig") - * ``` - */ -exports.WebkitMessagingTransport = WebkitMessagingTransport; -class WebkitMessagingConfig { - /** - * @param {object} params - * @param {boolean} params.hasModernWebkitAPI - * @param {string[]} params.webkitMessageHandlerNames - * @param {string} params.secret - */ - constructor(params) { - /** - * Whether or not the current WebKit Platform supports secure messaging - * by default (eg: macOS 11+) - */ - this.hasModernWebkitAPI = params.hasModernWebkitAPI; - /** - * A list of WebKit message handler names that a user script can send - */ - this.webkitMessageHandlerNames = params.webkitMessageHandlerNames; - /** - * A string provided by native platforms to be sent with future outgoing - * messages - */ - this.secret = params.secret; - } -} - -/** - * This is the additional payload that gets appended to outgoing messages. - * It's used in the Swift side to encrypt the response that comes back - */ -exports.WebkitMessagingConfig = WebkitMessagingConfig; -class SecureMessagingParams { - /** - * @param {object} params - * @param {string} params.methodName - * @param {string} params.secret - * @param {number[]} params.key - * @param {number[]} params.iv - */ - constructor(params) { - /** - * The method that's been appended to `window` to be called later - */ - this.methodName = params.methodName; - /** - * The secret used to ensure message sender validity - */ - this.secret = params.secret; - /** - * The CipherKey as number[] - */ - this.key = params.key; - /** - * The Initial Vector as number[] - */ - this.iv = params.iv; - } -} - -/** - * Capture some globals used for messaging handling to prevent page - * scripts from tampering with this - */ -exports.SecureMessagingParams = SecureMessagingParams; -function captureGlobals() { - // Creat base with null prototype - return { - window, - // Methods must be bound to their interface, otherwise they throw Illegal invocation - encrypt: window.crypto.subtle.encrypt.bind(window.crypto.subtle), - decrypt: window.crypto.subtle.decrypt.bind(window.crypto.subtle), - generateKey: window.crypto.subtle.generateKey.bind(window.crypto.subtle), - exportKey: window.crypto.subtle.exportKey.bind(window.crypto.subtle), - importKey: window.crypto.subtle.importKey.bind(window.crypto.subtle), - getRandomValues: window.crypto.getRandomValues.bind(window.crypto), - TextEncoder, - TextDecoder, - Uint8Array, - Uint16Array, - Uint32Array, - JSONstringify: window.JSON.stringify, - JSONparse: window.JSON.parse, - Arrayfrom: window.Array.from, - Promise: window.Promise, - ObjectDefineProperty: window.Object.defineProperty, - addEventListener: window.addEventListener.bind(window), - /** @type {Record} */ - capturedWebkitHandlers: {} - }; -} - -},{"../messaging.js":3}],5:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.WindowsMessagingTransport = exports.WindowsMessagingConfig = void 0; -var _messaging = require("../messaging.js"); -// eslint-disable-next-line @typescript-eslint/no-unused-vars - -/** - * @implements {MessagingTransport} - */ -class WindowsMessagingTransport { - config; - /** - * @param {WindowsMessagingConfig} config - */ - constructor(config) { - this.config = config; - } - /** - * @param {string} name - * @param {Record} [data] - */ - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars - notify(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - throw new Error('todo: implement notify for windows'); - } - /** - * @param {string} name - * @param {Record} [data] - * @param {{signal?: AbortSignal}} opts - * @return {Promise} - */ - // @ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unused-vars - request(name) { - let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - throw new Error('todo: implement request for windows'); - } -} -exports.WindowsMessagingTransport = WindowsMessagingTransport; -class WindowsMessagingConfig { - /** - * @param {object} params - * @param {string} params.featureName - */ - constructor(params) { - this.featureName = params.featureName; - } -} -exports.WindowsMessagingConfig = WindowsMessagingConfig; - -},{"../messaging.js":3}],6:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "DeviceApi", { - enumerable: true, - get: function () { - return _deviceApi.DeviceApi; - } -}); -Object.defineProperty(exports, "DeviceApiCall", { - enumerable: true, - get: function () { - return _deviceApiCall.DeviceApiCall; - } -}); -Object.defineProperty(exports, "DeviceApiTransport", { - enumerable: true, - get: function () { - return _deviceApi.DeviceApiTransport; - } -}); -Object.defineProperty(exports, "createNotification", { - enumerable: true, - get: function () { - return _deviceApiCall.createNotification; - } -}); -Object.defineProperty(exports, "createRequest", { - enumerable: true, - get: function () { - return _deviceApiCall.createRequest; - } -}); -Object.defineProperty(exports, "validate", { - enumerable: true, - get: function () { - return _deviceApiCall.validate; - } -}); -var _deviceApiCall = require("./lib/device-api-call.js"); -var _deviceApi = require("./lib/device-api.js"); - -},{"./lib/device-api-call.js":7,"./lib/device-api.js":8}],7:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.SchemaValidationError = exports.DeviceApiCallError = exports.DeviceApiCall = void 0; -exports.createDeviceApiCall = createDeviceApiCall; -exports.createNotification = void 0; -exports.createRequest = createRequest; -exports.validate = validate; -/** - * This roughly follows https://www.jsonrpc.org/specification - * @template {import("zod").ZodType} Params=import("zod").ZodType - * @template {import("zod").ZodType} Result=import("zod").ZodType - */ -class DeviceApiCall { - /** @type {string} */ - method = 'unknown'; - /** - * An optional 'id' - used to indicate if a request requires a response. - * @type {string|null} - */ - id = null; - /** @type {Params | null | undefined} */ - paramsValidator = null; - /** @type {Result | null | undefined} */ - resultValidator = null; - /** @type {import("zod").infer} */ - params; - /** - * This is a carve-out for legacy messages that are not typed yet. - * If you set this to 'true', then the response will not be checked to conform - * to any shape - * @deprecated this is here to aid migration, should be removed ASAP - * @type {boolean} - */ - throwOnResultKeysMissing = true; - /** - * New messages should be in a particular format, eg: { success: T }, - * but you can set this to false if you want to access the result as-is, - * without any unwrapping logic - * @deprecated this is here to aid migration, should be removed ASAP - * @type {boolean} - */ - unwrapResult = true; - /** - * @param {import("zod").infer} data - */ - constructor(data) { - this.params = data; - } - - /** - * @returns {import("zod").infer|undefined} - */ - validateParams() { - if (this.params === undefined) { - return undefined; - } - this._validate(this.params, this.paramsValidator); - return this.params; - } - - /** - * @param {any|null} incoming - * @returns {import("zod").infer} - */ - validateResult(incoming) { - this._validate(incoming, this.resultValidator); - if (!incoming) { - return incoming; - } - if (!this.unwrapResult) { - return incoming; - } - if ('data' in incoming) { - console.warn('response had `data` property. Please migrate to `success`'); - return incoming.data; - } - if ('success' in incoming) { - return incoming.success; - } - if ('error' in incoming) { - if (typeof incoming.error.message === 'string') { - throw new DeviceApiCallError(`${this.method}: ${incoming.error.message}`); - } - } - if (this.throwOnResultKeysMissing) { - throw new Error('unreachable. Response did not contain `success` or `data`'); - } - return incoming; - } - - /** - * @param {any} data - * @param {import("zod").ZodType|undefined|null} [validator] - * @private - */ - _validate(data, validator) { - if (!validator) return data; - if (validator) { - const result = validator?.safeParse(data); - if (!result) { - throw new Error('unreachable, data failure', data); - } - if (!result.success) { - if ('error' in result) { - this.throwError(result.error.issues); - } else { - console.error('unknown error from validate'); - } - } - } - } - - /** - * @param {import('zod').ZodIssue[]} errors - */ - throwError(errors) { - const error = SchemaValidationError.fromZodErrors(errors, this.constructor.name); - throw error; - } - - /** - * Use this helper for creating stand-in response messages that are typed correctly. - * - * @examples - * - * ```js - * const msg = new Message(); - * const response = msg.response({}) // <-- This argument will be typed correctly - * ``` - * - * @param {import("zod").infer} response - * @returns {import("zod").infer} - */ - result(response) { - return response; - } - /** - * @returns {import("zod").infer} - */ - preResultValidation(response) { - return response; + return this.globals.getRandomValues(new this.globals.Uint8Array(12)); } -} -exports.DeviceApiCall = DeviceApiCall; -class DeviceApiCallError extends Error {} -/** - * Check for this error if you'd like to - */ -exports.DeviceApiCallError = DeviceApiCallError; -class SchemaValidationError extends Error { - /** @type {import("zod").ZodIssue[]} */ - validationErrors = []; + /** + * @param {BufferSource} ciphertext + * @param {BufferSource} key + * @param {Uint8Array} iv + * @returns {Promise} + */ + async decrypt(ciphertext, key, iv) { + const cryptoKey = await this.globals.importKey('raw', key, 'AES-GCM', false, ['decrypt']); + const algo = { + name: 'AES-GCM', + iv + }; + let decrypted = await this.globals.decrypt(algo, cryptoKey, ciphertext); + let dec = new this.globals.TextDecoder(); + return dec.decode(decrypted); + } /** - * @param {import("zod").ZodIssue[]} errors - * @param {string} name - * @returns {SchemaValidationError} - */ - static fromZodErrors(errors, name) { - const heading = `${errors.length} SchemaValidationError(s) errors for ` + name; - function log(issue) { - switch (issue.code) { - case 'invalid_literal': - case 'invalid_type': - { - console.log(`${name}. Path: '${issue.path.join('.')}', Error: '${issue.message}'`); - break; - } - case 'invalid_union': - { - for (let unionError of issue.unionErrors) { - for (let issue1 of unionError.issues) { - log(issue1); - } - } - break; - } - default: - { - console.log(name, 'other issue:', issue); - } + * When required (such as on macos 10.x), capture the `postMessage` method on + * each webkit messageHandler + * + * @param {string[]} handlerNames + */ + captureWebkitHandlers(handlerNames) { + const handlers = window.webkit.messageHandlers; + if (!handlers) throw new _messaging.MissingHandler('window.webkit.messageHandlers was absent', 'all'); + for (let webkitMessageHandlerName of handlerNames) { + if (typeof handlers[webkitMessageHandlerName]?.postMessage === 'function') { + /** + * `bind` is used here to ensure future calls to the captured + * `postMessage` have the correct `this` context + */ + const original = handlers[webkitMessageHandlerName]; + const bound = handlers[webkitMessageHandlerName].postMessage?.bind(original); + this.globals.capturedWebkitHandlers[webkitMessageHandlerName] = bound; + delete handlers[webkitMessageHandlerName].postMessage; } } - for (let error of errors) { - log(error); - } - const message = [heading, 'please see the details above'].join('\n '); - const error = new SchemaValidationError(message); - error.validationErrors = errors; - return error; } } /** - * Creates an instance of `DeviceApiCall` from only a name and 'params' - * and optional validators. Use this to help migrate existing messages. - * - * @template {import("zod").ZodType} Params - * @template {import("zod").ZodType} Result - * @param {string} method - * @param {import("zod").infer} [params] - * @param {Params|null} [paramsValidator] - * @param {Result|null} [resultValidator] - * @returns {DeviceApiCall} - */ -exports.SchemaValidationError = SchemaValidationError; -function createDeviceApiCall(method, params) { - let paramsValidator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; - let resultValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - /** @type {DeviceApiCall} */ - const deviceApiCall = new DeviceApiCall(params); - deviceApiCall.paramsValidator = paramsValidator; - deviceApiCall.resultValidator = resultValidator; - deviceApiCall.method = method; - deviceApiCall.throwOnResultKeysMissing = false; - deviceApiCall.unwrapResult = false; - return deviceApiCall; -} - -/** - * Creates an instance of `DeviceApiCall` from only a name and 'params' - * and optional validators. Use this to help migrate existing messages. + * Use this configuration to create an instance of {@link Messaging} for WebKit * - * Note: This creates a regular DeviceApiCall, but adds the 'id' as a string - * so that transports know that it expects a response. + * ```js + * import { fromConfig, WebkitMessagingConfig } from "@duckduckgo/content-scope-scripts/lib/messaging.js" * - * @template {import("zod").ZodType} Params - * @template {import("zod").ZodType} Result - * @param {string} method - * @param {import("zod").infer} [params] - * @param {string} [id] - * @param {Params|null} [paramsValidator] - * @param {Result|null} [resultValidator] - * @returns {DeviceApiCall} - */ -function createRequest(method, params) { - let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'n/a'; - let paramsValidator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - let resultValidator = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; - const call = createDeviceApiCall(method, params, paramsValidator, resultValidator); - call.id = id; - return call; -} -const createNotification = exports.createNotification = createDeviceApiCall; - -/** - * Validate any arbitrary data with any Zod validator + * const config = new WebkitMessagingConfig({ + * hasModernWebkitAPI: true, + * webkitMessageHandlerNames: ["foo", "bar", "baz"], + * secret: "dax", + * }); * - * @template {import("zod").ZodType} Validator - * @param {any} data - * @param {Validator | null} [validator] - * @returns {import("zod").infer} + * const messaging = new Messaging(config) + * const resp = await messaging.request("debugConfig") + * ``` */ -function validate(data) { - let validator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - if (validator) { - return validator.parse(data); +exports.WebkitMessagingTransport = WebkitMessagingTransport; +class WebkitMessagingConfig { + /** + * @param {object} params + * @param {boolean} params.hasModernWebkitAPI + * @param {string[]} params.webkitMessageHandlerNames + * @param {string} params.secret + */ + constructor(params) { + /** + * Whether or not the current WebKit Platform supports secure messaging + * by default (eg: macOS 11+) + */ + this.hasModernWebkitAPI = params.hasModernWebkitAPI; + /** + * A list of WebKit message handler names that a user script can send + */ + this.webkitMessageHandlerNames = params.webkitMessageHandlerNames; + /** + * A string provided by native platforms to be sent with future outgoing + * messages + */ + this.secret = params.secret; } - return data; } -},{}],8:[function(require,module,exports){ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.DeviceApiTransport = exports.DeviceApi = void 0; /** - * Platforms should only need to implement this `send` method + * This is the additional payload that gets appended to outgoing messages. + * It's used in the Swift side to encrypt the response that comes back */ -class DeviceApiTransport { +exports.WebkitMessagingConfig = WebkitMessagingConfig; +class SecureMessagingParams { /** - * @param {import("./device-api-call.js").DeviceApiCall} _deviceApiCall - * @param {CallOptions} [_options] - * @returns {Promise} - */ - async send(_deviceApiCall, _options) { - return undefined; + * @param {object} params + * @param {string} params.methodName + * @param {string} params.secret + * @param {number[]} params.key + * @param {number[]} params.iv + */ + constructor(params) { + /** + * The method that's been appended to `window` to be called later + */ + this.methodName = params.methodName; + /** + * The secret used to ensure message sender validity + */ + this.secret = params.secret; + /** + * The CipherKey as number[] + */ + this.key = params.key; + /** + * The Initial Vector as number[] + */ + this.iv = params.iv; } } /** - * This is the base Sender class that platforms can will implement. - * - * Note: The 'handle' method must be implemented, unless you also implement 'send' - * - * @typedef CallOptions - * @property {AbortSignal} [signal] + * Capture some globals used for messaging handling to prevent page + * scripts from tampering with this */ -exports.DeviceApiTransport = DeviceApiTransport; -class DeviceApi { - /** @type {DeviceApiTransport} */ - transport; - /** @param {DeviceApiTransport} transport */ - constructor(transport) { - this.transport = transport; - } - /** - * @template {import("./device-api-call").DeviceApiCall} D - * @param {D} deviceApiCall - * @param {CallOptions} [options] - * @returns {Promise['success']>>} - */ - async request(deviceApiCall, options) { - deviceApiCall.validateParams(); - let result = await this.transport.send(deviceApiCall, options); - let processed = deviceApiCall.preResultValidation(result); - return deviceApiCall.validateResult(processed); - } - /** - * @template {import("./device-api-call").DeviceApiCall} P - * @param {P} deviceApiCall - * @param {CallOptions} [options] - * @returns {Promise} - */ - async notify(deviceApiCall, options) { - deviceApiCall.validateParams(); - return this.transport.send(deviceApiCall, options); - } +exports.SecureMessagingParams = SecureMessagingParams; +function captureGlobals() { + // Creat base with null prototype + return { + window, + // Methods must be bound to their interface, otherwise they throw Illegal invocation + encrypt: window.crypto.subtle.encrypt.bind(window.crypto.subtle), + decrypt: window.crypto.subtle.decrypt.bind(window.crypto.subtle), + generateKey: window.crypto.subtle.generateKey.bind(window.crypto.subtle), + exportKey: window.crypto.subtle.exportKey.bind(window.crypto.subtle), + importKey: window.crypto.subtle.importKey.bind(window.crypto.subtle), + getRandomValues: window.crypto.getRandomValues.bind(window.crypto), + TextEncoder, + TextDecoder, + Uint8Array, + Uint16Array, + Uint32Array, + JSONstringify: window.JSON.stringify, + JSONparse: window.JSON.parse, + Arrayfrom: window.Array.from, + Promise: window.Promise, + ObjectDefineProperty: window.Object.defineProperty, + addEventListener: window.addEventListener.bind(window), + /** @type {Record} */ + capturedWebkitHandlers: {} + }; } -exports.DeviceApi = DeviceApi; -},{}],9:[function(require,module,exports){ +},{"./messaging.js":5}],7:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1207,7 +1122,7 @@ function _safeHostname(inputHostname) { } } -},{"./lib/apple.password.js":10,"./lib/constants.js":11,"./lib/rules-parser.js":12}],10:[function(require,module,exports){ +},{"./lib/apple.password.js":8,"./lib/constants.js":9,"./lib/rules-parser.js":10}],8:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1736,7 +1651,7 @@ class Password { } exports.Password = Password; -},{"./constants.js":11,"./rules-parser.js":12}],11:[function(require,module,exports){ +},{"./constants.js":9,"./rules-parser.js":10}],9:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -1756,7 +1671,7 @@ const constants = exports.constants = { DEFAULT_UNAMBIGUOUS_CHARS }; -},{}],12:[function(require,module,exports){ +},{}],10:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -2352,7 +2267,7 @@ function parsePasswordRules(input, formatRulesForMinifiedVersion) { return newPasswordRules; } -},{}],13:[function(require,module,exports){ +},{}],11:[function(require,module,exports){ module.exports={ "163.com": { "password-rules": "minlength: 6; maxlength: 16;" @@ -3183,7 +3098,7 @@ module.exports={ "password-rules": "minlength: 8; maxlength: 32; max-consecutive: 6; required: lower; required: upper; required: digit;" } } -},{}],14:[function(require,module,exports){ +},{}],12:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3239,7 +3154,7 @@ function createDevice() { return new _ExtensionInterface.ExtensionInterface(globalConfig, deviceApi, settings); } -},{"../packages/device-api/index.js":6,"./DeviceInterface/AndroidInterface.js":15,"./DeviceInterface/AppleDeviceInterface.js":16,"./DeviceInterface/AppleOverlayDeviceInterface.js":17,"./DeviceInterface/ExtensionInterface.js":18,"./DeviceInterface/WindowsInterface.js":20,"./DeviceInterface/WindowsOverlayDeviceInterface.js":21,"./Settings.js":42,"./config.js":55,"./deviceApiCalls/transports/transports.js":63}],15:[function(require,module,exports){ +},{"../packages/device-api/index.js":2,"./DeviceInterface/AndroidInterface.js":13,"./DeviceInterface/AppleDeviceInterface.js":14,"./DeviceInterface/AppleOverlayDeviceInterface.js":15,"./DeviceInterface/ExtensionInterface.js":16,"./DeviceInterface/WindowsInterface.js":18,"./DeviceInterface/WindowsOverlayDeviceInterface.js":19,"./Settings.js":40,"./config.js":53,"./deviceApiCalls/transports/transports.js":61}],13:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3365,7 +3280,7 @@ class AndroidInterface extends _InterfacePrototype.default { } exports.AndroidInterface = AndroidInterface; -},{"../UI/controllers/NativeUIController.js":48,"../autofill-utils.js":53,"./InterfacePrototype.js":19,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],16:[function(require,module,exports){ +},{"../UI/controllers/NativeUIController.js":46,"../autofill-utils.js":51,"./InterfacePrototype.js":17,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],14:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3751,7 +3666,7 @@ class AppleDeviceInterface extends _InterfacePrototype.default { } exports.AppleDeviceInterface = AppleDeviceInterface; -},{"../../packages/device-api/index.js":6,"../Form/matching.js":35,"../InContextSignup.js":36,"../UI/HTMLTooltip.js":46,"../UI/controllers/HTMLTooltipUIController.js":47,"../UI/controllers/NativeUIController.js":48,"../UI/controllers/OverlayUIController.js":49,"../autofill-utils.js":53,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"../deviceApiCalls/additionalDeviceApiCalls.js":59,"./InterfacePrototype.js":19,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],17:[function(require,module,exports){ +},{"../../packages/device-api/index.js":2,"../Form/matching.js":33,"../InContextSignup.js":34,"../UI/HTMLTooltip.js":44,"../UI/controllers/HTMLTooltipUIController.js":45,"../UI/controllers/NativeUIController.js":46,"../UI/controllers/OverlayUIController.js":47,"../autofill-utils.js":51,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"../deviceApiCalls/additionalDeviceApiCalls.js":57,"./InterfacePrototype.js":17,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],15:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3885,7 +3800,7 @@ class AppleOverlayDeviceInterface extends _AppleDeviceInterface.AppleDeviceInter } exports.AppleOverlayDeviceInterface = AppleOverlayDeviceInterface; -},{"../../packages/device-api/index.js":6,"../UI/controllers/HTMLTooltipUIController.js":47,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"../deviceApiCalls/__generated__/validators.zod.js":58,"./AppleDeviceInterface.js":16,"./overlayApi.js":23}],18:[function(require,module,exports){ +},{"../../packages/device-api/index.js":2,"../UI/controllers/HTMLTooltipUIController.js":45,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"../deviceApiCalls/__generated__/validators.zod.js":56,"./AppleDeviceInterface.js":14,"./overlayApi.js":21}],16:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -4116,7 +4031,7 @@ class ExtensionInterface extends _InterfacePrototype.default { } exports.ExtensionInterface = ExtensionInterface; -},{"../Form/matching.js":35,"../InContextSignup.js":36,"../UI/HTMLTooltip.js":46,"../UI/controllers/HTMLTooltipUIController.js":47,"../autofill-utils.js":53,"./InterfacePrototype.js":19}],19:[function(require,module,exports){ +},{"../Form/matching.js":33,"../InContextSignup.js":34,"../UI/HTMLTooltip.js":44,"../UI/controllers/HTMLTooltipUIController.js":45,"../autofill-utils.js":51,"./InterfacePrototype.js":17}],17:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -4997,7 +4912,7 @@ class InterfacePrototype { } var _default = exports.default = InterfacePrototype; -},{"../../packages/device-api/index.js":6,"../EmailProtection.js":24,"../Form/formatters.js":28,"../Form/matching.js":35,"../InputTypes/Credentials.js":37,"../PasswordGenerator.js":40,"../Scanner.js":41,"../Settings.js":42,"../UI/controllers/NativeUIController.js":48,"../autofill-utils.js":53,"../config.js":55,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"../deviceApiCalls/__generated__/validators.zod.js":58,"../deviceApiCalls/transports/transports.js":63,"./initFormSubmissionsApi.js":22}],20:[function(require,module,exports){ +},{"../../packages/device-api/index.js":2,"../EmailProtection.js":22,"../Form/formatters.js":26,"../Form/matching.js":33,"../InputTypes/Credentials.js":35,"../PasswordGenerator.js":38,"../Scanner.js":39,"../Settings.js":40,"../UI/controllers/NativeUIController.js":46,"../autofill-utils.js":51,"../config.js":53,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"../deviceApiCalls/__generated__/validators.zod.js":56,"../deviceApiCalls/transports/transports.js":61,"./initFormSubmissionsApi.js":20}],18:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5169,7 +5084,7 @@ class WindowsInterface extends _InterfacePrototype.default { } exports.WindowsInterface = WindowsInterface; -},{"../UI/controllers/OverlayUIController.js":49,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"./InterfacePrototype.js":19}],21:[function(require,module,exports){ +},{"../UI/controllers/OverlayUIController.js":47,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"./InterfacePrototype.js":17}],19:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5348,7 +5263,7 @@ class WindowsOverlayDeviceInterface extends _InterfacePrototype.default { } exports.WindowsOverlayDeviceInterface = WindowsOverlayDeviceInterface; -},{"../UI/controllers/HTMLTooltipUIController.js":47,"../deviceApiCalls/__generated__/deviceApiCalls.js":57,"./InterfacePrototype.js":19,"./overlayApi.js":23}],22:[function(require,module,exports){ +},{"../UI/controllers/HTMLTooltipUIController.js":45,"../deviceApiCalls/__generated__/deviceApiCalls.js":55,"./InterfacePrototype.js":17,"./overlayApi.js":21}],20:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5440,7 +5355,7 @@ function initFormSubmissionsApi(forms, matching) { }); } -},{"../Form/label-util.js":31,"../autofill-utils.js":53}],23:[function(require,module,exports){ +},{"../Form/label-util.js":29,"../autofill-utils.js":51}],21:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5498,7 +5413,7 @@ function overlayApi(device) { }; } -},{"../deviceApiCalls/__generated__/deviceApiCalls.js":57}],24:[function(require,module,exports){ +},{"../deviceApiCalls/__generated__/deviceApiCalls.js":55}],22:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -5533,7 +5448,7 @@ class EmailProtection { } exports.EmailProtection = EmailProtection; -},{}],25:[function(require,module,exports){ +},{}],23:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6335,7 +6250,7 @@ class Form { } exports.Form = Form; -},{"../autofill-utils.js":53,"../constants.js":56,"./FormAnalyzer.js":26,"./formatters.js":28,"./inputStyles.js":29,"./inputTypeConfig.js":30,"./matching.js":35}],26:[function(require,module,exports){ +},{"../autofill-utils.js":51,"../constants.js":54,"./FormAnalyzer.js":24,"./formatters.js":26,"./inputStyles.js":27,"./inputTypeConfig.js":28,"./matching.js":33}],24:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6682,7 +6597,7 @@ class FormAnalyzer { } var _default = exports.default = FormAnalyzer; -},{"../autofill-utils.js":53,"../constants.js":56,"./matching-config/__generated__/compiled-matching-config.js":33,"./matching.js":35}],27:[function(require,module,exports){ +},{"../autofill-utils.js":51,"../constants.js":54,"./matching-config/__generated__/compiled-matching-config.js":31,"./matching.js":33}],25:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7247,7 +7162,7 @@ const COUNTRY_NAMES_TO_CODES = exports.COUNTRY_NAMES_TO_CODES = { 'Unknown Region': 'ZZ' }; -},{}],28:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7552,7 +7467,7 @@ const prepareFormValuesForStorage = formValues => { }; exports.prepareFormValuesForStorage = prepareFormValuesForStorage; -},{"./countryNames.js":27,"./matching.js":35}],29:[function(require,module,exports){ +},{"./countryNames.js":25,"./matching.js":33}],27:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7643,7 +7558,7 @@ const getIconStylesAutofilled = (input, form) => { }; exports.getIconStylesAutofilled = getIconStylesAutofilled; -},{"./inputTypeConfig.js":30}],30:[function(require,module,exports){ +},{"./inputTypeConfig.js":28}],28:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7886,7 +7801,7 @@ const isFieldDecorated = input => { }; exports.isFieldDecorated = isFieldDecorated; -},{"../InputTypes/Credentials.js":37,"../InputTypes/CreditCard.js":38,"../InputTypes/Identity.js":39,"../UI/img/ddgPasswordIcon.js":51,"../constants.js":56,"./logo-svg.js":32,"./matching.js":35}],31:[function(require,module,exports){ +},{"../InputTypes/Credentials.js":35,"../InputTypes/CreditCard.js":36,"../InputTypes/Identity.js":37,"../UI/img/ddgPasswordIcon.js":49,"../constants.js":54,"./logo-svg.js":30,"./matching.js":33}],29:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7934,7 +7849,7 @@ const extractElementStrings = element => { }; exports.extractElementStrings = extractElementStrings; -},{"./matching.js":35}],32:[function(require,module,exports){ +},{"./matching.js":33}],30:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7967,7 +7882,7 @@ const daxGrayscaleSvg = ` `.trim(); const daxGrayscaleBase64 = exports.daxGrayscaleBase64 = `data:image/svg+xml;base64,${window.btoa(daxGrayscaleSvg)}`; -},{}],33:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8413,7 +8328,7 @@ const matchingConfiguration = exports.matchingConfiguration = { } }; -},{}],34:[function(require,module,exports){ +},{}],32:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8488,7 +8403,7 @@ function logUnmatched(el, allStrings) { console.groupEnd(); } -},{"../autofill-utils.js":53,"./matching.js":35}],35:[function(require,module,exports){ +},{"../autofill-utils.js":51,"./matching.js":33}],33:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8744,8 +8659,8 @@ class Matching { this.setActiveElementStrings(input, formEl); if (this.subtypeFromMatchers('unknown', input)) return 'unknown'; - // // For CC forms we run aggressive matches, so we want to make sure we only - // // run them on actual CC forms to avoid false positives and expensive loops + // For CC forms we run aggressive matches, so we want to make sure we only + // run them on actual CC forms to avoid false positives and expensive loops if (opts.isCCForm) { const subtype = this.subtypeFromMatchers('cc', input); if (subtype && isValidCreditCardSubtype(subtype)) { @@ -9394,7 +9309,7 @@ function createMatching() { return new Matching(_compiledMatchingConfig.matchingConfiguration); } -},{"../autofill-utils.js":53,"../constants.js":56,"./label-util.js":31,"./matching-config/__generated__/compiled-matching-config.js":33,"./matching-utils.js":34}],36:[function(require,module,exports){ +},{"../autofill-utils.js":51,"../constants.js":54,"./label-util.js":29,"./matching-config/__generated__/compiled-matching-config.js":31,"./matching-utils.js":32}],34:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9526,7 +9441,7 @@ class InContextSignup { } exports.InContextSignup = InContextSignup; -},{"./autofill-utils.js":53,"./deviceApiCalls/__generated__/deviceApiCalls.js":57}],37:[function(require,module,exports){ +},{"./autofill-utils.js":51,"./deviceApiCalls/__generated__/deviceApiCalls.js":55}],35:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9673,7 +9588,7 @@ function createCredentialsTooltipItem(data) { return new CredentialsTooltipItem(data); } -},{"../autofill-utils.js":53}],38:[function(require,module,exports){ +},{"../autofill-utils.js":51}],36:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9696,7 +9611,7 @@ class CreditCardTooltipItem { } exports.CreditCardTooltipItem = CreditCardTooltipItem; -},{}],39:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9736,7 +9651,7 @@ class IdentityTooltipItem { } exports.IdentityTooltipItem = IdentityTooltipItem; -},{"../Form/formatters.js":28}],40:[function(require,module,exports){ +},{"../Form/formatters.js":26}],38:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9778,7 +9693,7 @@ class PasswordGenerator { } exports.PasswordGenerator = PasswordGenerator; -},{"../packages/password/index.js":9,"../packages/password/rules.json":13}],41:[function(require,module,exports){ +},{"../packages/password/index.js":7,"../packages/password/rules.json":11}],39:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10141,7 +10056,7 @@ function createScanner(device, scannerOptions) { }); } -},{"./Form/Form.js":25,"./Form/matching.js":35,"./autofill-utils.js":53,"./constants.js":56,"./deviceApiCalls/__generated__/deviceApiCalls.js":57}],42:[function(require,module,exports){ +},{"./Form/Form.js":23,"./Form/matching.js":33,"./autofill-utils.js":51,"./constants.js":54,"./deviceApiCalls/__generated__/deviceApiCalls.js":55}],40:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10486,7 +10401,7 @@ class Settings { } exports.Settings = Settings; -},{"../packages/device-api/index.js":6,"./autofill-utils.js":53,"./deviceApiCalls/__generated__/deviceApiCalls.js":57,"./deviceApiCalls/__generated__/validators.zod.js":58,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],43:[function(require,module,exports){ +},{"../packages/device-api/index.js":2,"./autofill-utils.js":51,"./deviceApiCalls/__generated__/deviceApiCalls.js":55,"./deviceApiCalls/__generated__/validators.zod.js":56,"@duckduckgo/content-scope-scripts/src/apple-utils":1}],41:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10614,7 +10529,7 @@ ${css} } var _default = exports.default = DataHTMLTooltip; -},{"../InputTypes/Credentials.js":37,"../autofill-utils.js":53,"./HTMLTooltip.js":46}],44:[function(require,module,exports){ +},{"../InputTypes/Credentials.js":35,"../autofill-utils.js":51,"./HTMLTooltip.js":44}],42:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10692,7 +10607,7 @@ ${this.options.css} } var _default = exports.default = EmailHTMLTooltip; -},{"../autofill-utils.js":53,"./HTMLTooltip.js":46}],45:[function(require,module,exports){ +},{"../autofill-utils.js":51,"./HTMLTooltip.js":44}],43:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10748,7 +10663,7 @@ ${this.options.css} } var _default = exports.default = EmailSignupHTMLTooltip; -},{"./HTMLTooltip.js":46}],46:[function(require,module,exports){ +},{"./HTMLTooltip.js":44}],44:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11135,7 +11050,7 @@ class HTMLTooltip { exports.HTMLTooltip = HTMLTooltip; var _default = exports.default = HTMLTooltip; -},{"../Form/matching.js":35,"../autofill-utils.js":53,"./styles/styles.js":52}],47:[function(require,module,exports){ +},{"../Form/matching.js":33,"../autofill-utils.js":51,"./styles/styles.js":50}],45:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11486,7 +11401,7 @@ class HTMLTooltipUIController extends _UIController.UIController { } exports.HTMLTooltipUIController = HTMLTooltipUIController; -},{"../../Form/inputTypeConfig.js":30,"../../Form/matching.js":35,"../../autofill-utils.js":53,"../DataHTMLTooltip.js":43,"../EmailHTMLTooltip.js":44,"../EmailSignupHTMLTooltip.js":45,"../HTMLTooltip.js":46,"./UIController.js":50}],48:[function(require,module,exports){ +},{"../../Form/inputTypeConfig.js":28,"../../Form/matching.js":33,"../../autofill-utils.js":51,"../DataHTMLTooltip.js":41,"../EmailHTMLTooltip.js":42,"../EmailSignupHTMLTooltip.js":43,"../HTMLTooltip.js":44,"./UIController.js":48}],46:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11648,7 +11563,7 @@ class NativeUIController extends _UIController.UIController { } exports.NativeUIController = NativeUIController; -},{"../../Form/matching.js":35,"../../InputTypes/Credentials.js":37,"../../deviceApiCalls/__generated__/deviceApiCalls.js":57,"./UIController.js":50}],49:[function(require,module,exports){ +},{"../../Form/matching.js":33,"../../InputTypes/Credentials.js":35,"../../deviceApiCalls/__generated__/deviceApiCalls.js":55,"./UIController.js":48}],47:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11885,7 +11800,7 @@ class OverlayUIController extends _UIController.UIController { } exports.OverlayUIController = OverlayUIController; -},{"../../Form/matching.js":35,"./UIController.js":50}],50:[function(require,module,exports){ +},{"../../Form/matching.js":33,"./UIController.js":48}],48:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11969,7 +11884,7 @@ class UIController { } exports.UIController = UIController; -},{}],51:[function(require,module,exports){ +},{}],49:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11984,7 +11899,7 @@ const ddgCcIconBase = exports.ddgCcIconBase = 'data:image/svg+xml;base64,PD94bWw const ddgCcIconFilled = exports.ddgCcIconFilled = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+CiAgICA8cGF0aCBkPSJNNSA5Yy0uNTUyIDAtMSAuNDQ4LTEgMXYyYzAgLjU1Mi40NDggMSAxIDFoM2MuNTUyIDAgMS0uNDQ4IDEtMXYtMmMwLS41NTItLjQ0OC0xLTEtMUg1eiIgZmlsbD0iIzc2NDMxMCIvPgogICAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xIDZjMC0yLjIxIDEuNzktNCA0LTRoMTRjMi4yMSAwIDQgMS43OSA0IDR2MTJjMCAyLjIxLTEuNzkgNC00IDRINWMtMi4yMSAwLTQtMS43OS00LTRWNnptNC0yYy0xLjEwNSAwLTIgLjg5NS0yIDJ2OWgxOFY2YzAtMS4xMDUtLjg5NS0yLTItMkg1em0wIDE2Yy0xLjEwNSAwLTItLjg5NS0yLTJoMThjMCAxLjEwNS0uODk1IDItMiAySDV6IiBmaWxsPSIjNzY0MzEwIi8+Cjwvc3ZnPgo='; const ddgIdentityIconBase = exports.ddgIdentityIconBase = `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgZmlsbD0ibm9uZSI+CiAgICA8cGF0aCBmaWxsLXJ1bGU9ImV2Z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zLjUwNC42NjQtLjgxNy4zMzMtMS41OC43ODMtMi4yNjQgMS4zMzYgMS41NDYgMS4yNSAzLjUxNCAyIDUuNjU3IDJ6bTQuMzk3LTUuMDgzYy45NjcuNDIyIDEuODY2Ljk4IDIuNjcyIDEuNjU1QzIwLjI3OSAxNi4wMzkgMjEgMTQuMTA0IDIxIDEyYzAtNC45Ny00LjAzLTktOS05cy05IDQuMDMtOSA5YzAgMi4xMDQuNzIyIDQuMDQgMS45MzIgNS41NzIuODc0LS43MzQgMS44Ni0xLjMyOCAyLjkyMS0xLjc2IDEuMzYtLjU1NCAyLjgxNi0uODMgNC4yODMtLjgxMSAxLjQ2Ny4wMTggMi45MTYuMzMgNC4yNi45MTZ6TTEyIDIzYzYuMDc1IDAgMTEtNC45MjUgMTEtMTFTMTguMDc1IDEgMTIgMSAxIDUuOTI1IDEgMTJzNC45MjUgMTEgMTEgMTF6bTMtMTNjMCAxLjY1Ny0xLjM0MyAzLTMgM3MtMy0xLjM0My0zLTMgMS4zNDMtMyAzLTMgMyAxLjM0MyAzIDN6bTIgMGMwIDIuNzYxLTIuMjM5IDUtNSA1cy01LTIuMjM5LTUtNSAyLjIzOS01IDUtNSA1IDIuMjM5IDUgNXoiIGZpbGw9IiMwMDAiLz4KPC9zdmc+Cg==`; -},{}],52:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11993,7 +11908,7 @@ Object.defineProperty(exports, "__esModule", { exports.CSS_STYLES = void 0; const CSS_STYLES = exports.CSS_STYLES = ":root {\n color-scheme: light dark;\n}\n\n.wrapper *, .wrapper *::before, .wrapper *::after {\n box-sizing: border-box;\n}\n.wrapper {\n position: fixed;\n top: 0;\n left: 0;\n padding: 0;\n font-family: 'DDG_ProximaNova', 'Proxima Nova', system-ui, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n -webkit-font-smoothing: antialiased;\n z-index: 2147483647;\n}\n.wrapper--data {\n font-family: 'SF Pro Text', system-ui, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n}\n:not(.top-autofill) .tooltip {\n position: absolute;\n width: 300px;\n max-width: calc(100vw - 25px);\n transform: translate(-1000px, -1000px);\n z-index: 2147483647;\n}\n.tooltip--data, #topAutofill {\n background-color: rgba(242, 240, 240, 1);\n -webkit-backdrop-filter: blur(40px);\n backdrop-filter: blur(40px);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip--data, #topAutofill {\n background: rgb(100, 98, 102, .9);\n }\n}\n.tooltip--data {\n padding: 6px;\n font-size: 13px;\n line-height: 14px;\n width: 315px;\n max-height: 290px;\n overflow-y: auto;\n}\n.top-autofill .tooltip--data {\n min-height: 100vh;\n}\n.tooltip--data.tooltip--incontext-signup {\n width: 360px;\n}\n:not(.top-autofill) .tooltip--data {\n top: 100%;\n left: 100%;\n border: 0.5px solid rgba(255, 255, 255, 0.2);\n border-radius: 6px;\n box-shadow: 0 10px 20px rgba(0, 0, 0, 0.32);\n}\n@media (prefers-color-scheme: dark) {\n :not(.top-autofill) .tooltip--data {\n border: 1px solid rgba(255, 255, 255, 0.2);\n }\n}\n:not(.top-autofill) .tooltip--email {\n top: calc(100% + 6px);\n right: calc(100% - 48px);\n padding: 8px;\n border: 1px solid #D0D0D0;\n border-radius: 10px;\n background-color: #FFFFFF;\n font-size: 14px;\n line-height: 1.3;\n color: #333333;\n box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);\n}\n.tooltip--email__caret {\n position: absolute;\n transform: translate(-1000px, -1000px);\n z-index: 2147483647;\n}\n.tooltip--email__caret::before,\n.tooltip--email__caret::after {\n content: \"\";\n width: 0;\n height: 0;\n border-left: 10px solid transparent;\n border-right: 10px solid transparent;\n display: block;\n border-bottom: 8px solid #D0D0D0;\n position: absolute;\n right: -28px;\n}\n.tooltip--email__caret::before {\n border-bottom-color: #D0D0D0;\n top: -1px;\n}\n.tooltip--email__caret::after {\n border-bottom-color: #FFFFFF;\n top: 0px;\n}\n\n/* Buttons */\n.tooltip__button {\n display: flex;\n width: 100%;\n padding: 8px 8px 8px 0px;\n font-family: inherit;\n color: inherit;\n background: transparent;\n border: none;\n border-radius: 6px;\n}\n.tooltip__button.currentFocus,\n.wrapper:not(.top-autofill) .tooltip__button:hover {\n background-color: #3969EF;\n color: #FFFFFF;\n}\n\n/* Data autofill tooltip specific */\n.tooltip__button--data {\n position: relative;\n min-height: 48px;\n flex-direction: row;\n justify-content: flex-start;\n font-size: inherit;\n font-weight: 500;\n line-height: 16px;\n text-align: left;\n border-radius: 3px;\n}\n.tooltip--data__item-container {\n max-height: 220px;\n overflow: auto;\n}\n.tooltip__button--data:first-child {\n margin-top: 0;\n}\n.tooltip__button--data:last-child {\n margin-bottom: 0;\n}\n.tooltip__button--data::before {\n content: '';\n flex-shrink: 0;\n display: block;\n width: 32px;\n height: 32px;\n margin: 0 8px;\n background-size: 20px 20px;\n background-repeat: no-repeat;\n background-position: center 6px;\n}\n#provider_locked::after {\n position: absolute;\n content: '';\n flex-shrink: 0;\n display: block;\n width: 32px;\n height: 32px;\n margin: 0 8px;\n background-size: 11px 13px;\n background-repeat: no-repeat;\n background-position: right bottom;\n}\n.tooltip__button--data.currentFocus:not(.tooltip__button--data--bitwarden)::before,\n.wrapper:not(.top-autofill) .tooltip__button--data:not(.tooltip__button--data--bitwarden):hover::before {\n filter: invert(100%);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip__button--data:not(.tooltip__button--data--bitwarden)::before,\n .tooltip__button--data:not(.tooltip__button--data--bitwarden)::before {\n filter: invert(100%);\n opacity: .9;\n }\n}\n.tooltip__button__text-container {\n margin: auto 0;\n}\n.label {\n display: block;\n font-weight: 400;\n letter-spacing: -0.25px;\n color: rgba(0,0,0,.8);\n font-size: 13px;\n line-height: 1;\n}\n.label + .label {\n margin-top: 2px;\n}\n.label.label--medium {\n font-weight: 500;\n letter-spacing: -0.25px;\n color: rgba(0,0,0,.9);\n}\n.label.label--small {\n font-size: 11px;\n font-weight: 400;\n letter-spacing: 0.06px;\n color: rgba(0,0,0,0.6);\n}\n@media (prefers-color-scheme: dark) {\n .tooltip--data .label {\n color: #ffffff;\n }\n .tooltip--data .label--medium {\n color: #ffffff;\n }\n .tooltip--data .label--small {\n color: #cdcdcd;\n }\n}\n.tooltip__button.currentFocus .label,\n.wrapper:not(.top-autofill) .tooltip__button:hover .label {\n color: #FFFFFF;\n}\n\n.tooltip__button--manage {\n font-size: 13px;\n padding: 5px 9px;\n border-radius: 3px;\n margin: 0;\n}\n\n/* Icons */\n.tooltip__button--data--credentials::before {\n background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjYzNiA4LjY4MkM5LjYzNiA1LjU0NCAxMi4xOCAzIDE1LjMxOCAzIDE4LjQ1NiAzIDIxIDUuNTQ0IDIxIDguNjgyYzAgMy4xMzgtMi41NDQgNS42ODItNS42ODIgNS42ODItLjY5MiAwLTEuMzUzLS4xMjQtMS45NjQtLjM0OS0uMzcyLS4xMzctLjc5LS4wNDEtMS4wNjYuMjQ1bC0uNzEzLjc0SDEwYy0uNTUyIDAtMSAuNDQ4LTEgMXYySDdjLS41NTIgMC0xIC40NDgtMSAxdjJIM3YtMi44ODFsNi42NjgtNi42NjhjLjI2NS0uMjY2LjM2LS42NTguMjQ0LTEuMDE1LS4xNzktLjU1MS0uMjc2LTEuMTQtLjI3Ni0xLjc1NHpNMTUuMzE4IDFjLTQuMjQyIDAtNy42ODIgMy40NC03LjY4MiA3LjY4MiAwIC42MDcuMDcxIDEuMi4yMDU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yLjExMjE2IDIuNzU2ODIgMi43NTY4MkMyLjExMjE2IDMuNDAxNDggMS43NSA0LjI3NTgyIDEuNzUgNS4xODc1VjUuOTk0ODlDMS42MTczMiA2LjEwNjM3IDEuNDk4MTcgNi4yMzQ0NiAxLjM5NTc4IDYuMzc2NzhDMS4xMzkyNiA2LjczMzM1IDEuMDAwODUgNy4xNjEzMSAxIDcuNjAwNTdaTTQuOTY4NyA0Ljk2ODdDNS4wMjY5NCA0LjkxMDQ3IDUuMTA1MzIgNC44NzY5OSA1LjE4NzUgNC44NzUwN0M1LjI2OTY4IDQuODc2OTkgNS4zNDgwNiA0LjkxMDQ3IDUuNDA2MyA0Ljk2ODdDNS40NjU0MiA1LjAyNzgzIDUuNDk5MDQgNS4xMDc3NCA1LjUgNS4xOTEzVjUuNUg0Ljg3NVY1LjE5MTNDNC44NzU5NiA1LjEwNzc0IDQuOTA5NTggNS4wMjc4MyA0Ljk2ODcgNC45Njg3WiIgZmlsbD0iIzIyMjIyMiIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIi8+Cjwvc3ZnPgo=');\n}\n\nhr {\n display: block;\n margin: 5px 9px;\n border: none; /* reset the border */\n border-top: 1px solid rgba(0,0,0,.1);\n}\n\nhr:first-child {\n display: none;\n}\n\n@media (prefers-color-scheme: dark) {\n hr {\n border-top: 1px solid rgba(255,255,255,.2);\n }\n}\n\n#privateAddress {\n align-items: flex-start;\n}\n#personalAddress::before,\n#privateAddress::before,\n#incontextSignup::before,\n#personalAddress.currentFocus::before,\n#personalAddress:hover::before,\n#privateAddress.currentFocus::before,\n#privateAddress:hover::before {\n filter: none;\n /* This is the same icon as `daxBase64` in `src/Form/logo-svg.js` */\n background-image: url('data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiB2aWV3Qm94PSIwIDAgMTI4IDEyOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGNsaXAtcn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IDI2LjMwMy01OC43NSA1OC43NSAyNi4zMDMgNTguNzUgNTguNzUgNTguNzV6IiBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz4KPC9zdmc+');\n}\n\n/* Email tooltip specific */\n.tooltip__button--email {\n flex-direction: column;\n justify-content: center;\n align-items: flex-start;\n font-size: 14px;\n padding: 4px 8px;\n}\n.tooltip__button--email__primary-text {\n font-weight: bold;\n}\n.tooltip__button--email__secondary-text {\n font-size: 12px;\n}\n\n/* Email Protection signup notice */\n:not(.top-autofill) .tooltip--email-signup {\n text-align: left;\n color: #222222;\n padding: 16px 20px;\n width: 380px;\n}\n\n.tooltip--email-signup h1 {\n font-weight: 700;\n font-size: 16px;\n line-height: 1.5;\n margin: 0;\n}\n\n.tooltip--email-signup p {\n font-weight: 400;\n font-size: 14px;\n line-height: 1.4;\n}\n\n.notice-controls {\n display: flex;\n}\n\n.tooltip--email-signup .notice-controls > * {\n border-radius: 8px;\n border: 0;\n cursor: pointer;\n display: inline-block;\n font-family: inherit;\n font-style: normal;\n font-weight: bold;\n padding: 8px 12px;\n text-decoration: none;\n}\n\n.notice-controls .ghost {\n margin-left: 1rem;\n}\n\n.tooltip--email-signup a.primary {\n background: #3969EF;\n color: #fff;\n}\n\n.tooltip--email-signup a.primary:hover,\n.tooltip--email-signup a.primary:focus {\n background: #2b55ca;\n}\n\n.tooltip--email-signup a.primary:active {\n background: #1e42a4;\n}\n\n.tooltip--email-signup button.ghost {\n background: transparent;\n color: #3969EF;\n}\n\n.tooltip--email-signup button.ghost:hover,\n.tooltip--email-signup button.ghost:focus {\n background-color: rgba(0, 0, 0, 0.06);\n color: #2b55ca;\n}\n\n.tooltip--email-signup button.ghost:active {\n background-color: rgba(0, 0, 0, 0.12);\n color: #1e42a4;\n}\n\n.tooltip--email-signup button.close-tooltip {\n background-color: transparent;\n background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMiAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0wLjI5Mjg5NCAwLjY1NjkwN0MwLjY4MzQxOCAwLjI2NjM4MyAxLjMxNjU4IDAuMjY2MzgzIDEuNzA3MTEgMC42NTY5MDdMNiA0Ljk0OThMMTAuMjkyOSAwLjY1NjkwN0MxMC42ODM0IDAuMjY2MzgzIDExLjMxNjYgMC4yNjYzODMgMTEuNzA3MSAwLjY1NjkwN0MxMi4wOTc2IDEuMDQ3NDMgMTIuMDk3NiAxLjY4MDYgMTEuNzA3MSAyLjA3MTEyTDcuNDE0MjEgNi4zNjQwMUwxMS43MDcxIDEwLjY1NjlDMTIuMDk3NiAxMS4wNDc0IDEyLjA5NzYgMTEuNjgwNiAxMS43MDcxIDEyLjA3MTFDMTEuMzE2NiAxMi40NjE2IDEwLjY4MzQgMTIuNDYxNiAxMC4yOTI5IDEyLjA3MTFMNiA3Ljc3ODIzTDEuNzA3MTEgMTIuMDcxMUMxLjMxNjU4IDEyLjQ2MTYgMC42ODM0MTcgMTIuNDYxNiAwLjI5Mjg5MyAxMi4wNzExQy0wLjA5NzYzMTEgMTEuNjgwNiAtMC4wOTc2MzExIDExLjA0NzQgMC4yOTI4OTMgMTAuNjU2OUw0LjU4NTc5IDYuMzY0MDFMMC4yOTI4OTQgMi4wNzExMkMtMC4wOTc2MzA2IDEuNjgwNiAtMC4wOTc2MzA2IDEuMDQ3NDMgMC4yOTI4OTQgMC42NTY5MDdaIiBmaWxsPSJibGFjayIgZmlsbC1vcGFjaXR5PSIwLjg0Ii8+Cjwvc3ZnPgo=);\n background-position: center center;\n background-repeat: no-repeat;\n border: 0;\n cursor: pointer;\n padding: 16px;\n position: absolute;\n right: 12px;\n top: 12px;\n}\n"; -},{}],53:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12549,7 +12464,7 @@ function isFormLikelyToBeUsedAsPageWrapper(form) { return formChildrenPercentage > 50; } -},{"./Form/matching.js":35}],54:[function(require,module,exports){ +},{"./Form/matching.js":33}],52:[function(require,module,exports){ "use strict"; require("./requestIdleCallback.js"); @@ -12580,7 +12495,7 @@ var _autofillUtils = require("./autofill-utils.js"); } })(); -},{"./DeviceInterface.js":14,"./autofill-utils.js":53,"./requestIdleCallback.js":65}],55:[function(require,module,exports){ +},{"./DeviceInterface.js":12,"./autofill-utils.js":51,"./requestIdleCallback.js":63}],53:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12669,7 +12584,7 @@ function createGlobalConfig(overrides) { return config; } -},{}],56:[function(require,module,exports){ +},{}],54:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12686,7 +12601,7 @@ const constants = exports.constants = { MAX_FORM_MUT_OBS_COUNT: 50 }; -},{}],57:[function(require,module,exports){ +},{}],55:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12923,7 +12838,7 @@ class CloseEmailProtectionTabCall extends _deviceApi.DeviceApiCall { } exports.CloseEmailProtectionTabCall = CloseEmailProtectionTabCall; -},{"../../../packages/device-api":6,"./validators.zod.js":58}],58:[function(require,module,exports){ +},{"../../../packages/device-api":2,"./validators.zod.js":56}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12969,7 +12884,7 @@ const askToUnlockProviderResultSchema = exports.askToUnlockProviderResultSchema const checkCredentialsProviderStatusResultSchema = exports.checkCredentialsProviderStatusResultSchema = null; const apiSchema = exports.apiSchema = null; -},{}],59:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -12995,7 +12910,7 @@ class GetAlias extends _index.DeviceApiCall { } exports.GetAlias = GetAlias; -},{"../../packages/device-api/index.js":6,"./__generated__/validators.zod.js":58}],60:[function(require,module,exports){ +},{"../../packages/device-api/index.js":2,"./__generated__/validators.zod.js":56}],58:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13121,14 +13036,14 @@ function androidSpecificAvailableInputTypes(globalConfig) { }; } -},{"../../../packages/device-api/index.js":6,"../__generated__/deviceApiCalls.js":57}],61:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":2,"../__generated__/deviceApiCalls.js":55}],59:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppleTransport = void 0; -var _contentScopeUtils = require("@duckduckgo/content-scope-utils"); +var _messaging = require("../../../packages/messaging/messaging.js"); var _index = require("../../../packages/device-api/index.js"); var _deviceApiCalls = require("../__generated__/deviceApiCalls.js"); class AppleTransport extends _index.DeviceApiTransport { @@ -13136,12 +13051,12 @@ class AppleTransport extends _index.DeviceApiTransport { constructor(globalConfig) { super(); this.config = globalConfig; - const webkitConfig = new _contentScopeUtils.WebkitMessagingConfig({ + const webkitConfig = new _messaging.WebkitMessagingConfig({ hasModernWebkitAPI: this.config.hasModernWebkitAPI, webkitMessageHandlerNames: this.config.webkitMessageHandlerNames, secret: this.config.secret }); - this.messaging = new _contentScopeUtils.Messaging(webkitConfig); + this.messaging = new _messaging.Messaging(webkitConfig); } async send(deviceApiCall) { try { @@ -13152,7 +13067,7 @@ class AppleTransport extends _index.DeviceApiTransport { return this.messaging.notify(deviceApiCall.method, deviceApiCall.params || undefined); } } catch (e) { - if (e instanceof _contentScopeUtils.MissingHandler) { + if (e instanceof _messaging.MissingHandler) { if (this.config.isDDGTestMode) { console.log('MissingWebkitHandler error for:', deviceApiCall.method); } @@ -13187,7 +13102,7 @@ function appleSpecificRuntimeConfiguration(globalConfig) { }; } -},{"../../../packages/device-api/index.js":6,"../__generated__/deviceApiCalls.js":57,"@duckduckgo/content-scope-utils":2}],62:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":2,"../../../packages/messaging/messaging.js":5,"../__generated__/deviceApiCalls.js":55}],60:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13339,7 +13254,7 @@ async function extensionSpecificSetIncontextSignupPermanentlyDismissedAtCall(par }); } -},{"../../../packages/device-api/index.js":6,"../../Settings.js":42,"../../autofill-utils.js":53,"../__generated__/deviceApiCalls.js":57}],63:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":2,"../../Settings.js":40,"../../autofill-utils.js":51,"../__generated__/deviceApiCalls.js":55}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13383,7 +13298,7 @@ function createTransport(globalConfig) { return new _extensionTransport.ExtensionTransport(globalConfig); } -},{"./android.transport.js":60,"./apple.transport.js":61,"./extension.transport.js":62,"./windows.transport.js":64}],64:[function(require,module,exports){ +},{"./android.transport.js":58,"./apple.transport.js":59,"./extension.transport.js":60,"./windows.transport.js":62}],62:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13468,7 +13383,7 @@ function waitForWindowsResponse(responseId, options) { }); } -},{"../../../packages/device-api/index.js":6}],65:[function(require,module,exports){ +},{"../../../packages/device-api/index.js":2}],63:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -13511,4 +13426,4 @@ window.cancelIdleCallback = window.cancelIdleCallback || function (id) { }; var _default = exports.default = {}; -},{}]},{},[54]); +},{}]},{},[52]);