diff --git a/package-lock.json b/package-lock.json index 42783f13..0820d31e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4673,6 +4673,7 @@ }, "node_modules/abbrev": { "version": "1.1.1", + "dev": true, "license": "ISC" }, "node_modules/acorn": { @@ -4811,6 +4812,7 @@ }, "node_modules/ansi-styles": { "version": "3.2.1", + "dev": true, "license": "MIT", "dependencies": { "color-convert": "^1.9.0" @@ -4862,6 +4864,7 @@ }, "node_modules/archy": { "version": "1.0.0", + "dev": true, "license": "MIT" }, "node_modules/are-we-there-yet": { @@ -5677,6 +5680,7 @@ }, "node_modules/balanced-match": { "version": "1.0.2", + "dev": true, "license": "MIT" }, "node_modules/bare-events": { @@ -5964,6 +5968,7 @@ }, "node_modules/chalk": { "version": "2.4.2", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^3.2.1", @@ -6023,6 +6028,7 @@ }, "node_modules/chownr": { "version": "2.0.0", + "dev": true, "license": "ISC", "engines": { "node": ">=10" @@ -6030,6 +6036,7 @@ }, "node_modules/ci-info": { "version": "3.9.0", + "dev": true, "funding": [ { "type": "github", @@ -6219,6 +6226,7 @@ }, "node_modules/color-convert": { "version": "1.9.3", + "dev": true, "license": "MIT", "dependencies": { "color-name": "1.1.3" @@ -6226,6 +6234,7 @@ }, "node_modules/color-name": { "version": "1.1.3", + "dev": true, "license": "MIT" }, "node_modules/color-support": { @@ -6278,6 +6287,7 @@ }, "node_modules/concat-map": { "version": "0.0.1", + "dev": true, "license": "MIT" }, "node_modules/concat-stream": { @@ -6686,6 +6696,14 @@ } } }, + "node_modules/deep-freeze-es6": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/deep-freeze-es6/-/deep-freeze-es6-3.0.2.tgz", + "integrity": "sha512-snvTmNKjkzR1ywDMWN+jJtjEwqTPF0Nq0g1/puSkkaxgL71gJ0rJpsPF+WOqMRaVLWogtwb73lHthfSaqP8nIQ==", + "engines": { + "node": ">=18.12.0" + } + }, "node_modules/deep-is": { "version": "0.1.4", "dev": true, @@ -7168,6 +7186,7 @@ }, "node_modules/escape-string-regexp": { "version": "1.0.5", + "dev": true, "license": "MIT", "engines": { "node": ">=0.8.0" @@ -8272,6 +8291,7 @@ }, "node_modules/fs-minipass": { "version": "2.1.0", + "dev": true, "license": "ISC", "dependencies": { "minipass": "^3.0.0" @@ -8282,6 +8302,7 @@ }, "node_modules/fs-minipass/node_modules/minipass": { "version": "3.3.6", + "dev": true, "license": "ISC", "dependencies": { "yallist": "^4.0.0" @@ -8326,6 +8347,7 @@ }, "node_modules/fs.realpath": { "version": "1.0.0", + "dev": true, "license": "ISC" }, "node_modules/fsevents": { @@ -8342,6 +8364,7 @@ }, "node_modules/function-bind": { "version": "1.1.2", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -8500,6 +8523,7 @@ }, "node_modules/glob": { "version": "7.2.3", + "dev": true, "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", @@ -8923,6 +8947,7 @@ }, "node_modules/graceful-fs": { "version": "4.2.11", + "dev": true, "license": "ISC" }, "node_modules/grapheme-splitter": { @@ -9329,6 +9354,7 @@ }, "node_modules/has-flag": { "version": "3.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -9446,6 +9472,7 @@ }, "node_modules/hasown": { "version": "2.0.2", + "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -9475,6 +9502,7 @@ }, "node_modules/hosted-git-info": { "version": "2.8.9", + "dev": true, "license": "ISC" }, "node_modules/html-encoding-sniffer": { @@ -9593,6 +9621,7 @@ }, "node_modules/imurmurhash": { "version": "0.1.4", + "dev": true, "license": "MIT", "engines": { "node": ">=0.8.19" @@ -9608,6 +9637,7 @@ }, "node_modules/inflight": { "version": "1.0.6", + "dev": true, "license": "ISC", "dependencies": { "once": "^1.3.0", @@ -9616,10 +9646,12 @@ }, "node_modules/inherits": { "version": "2.0.4", + "dev": true, "license": "ISC" }, "node_modules/ini": { "version": "1.3.8", + "dev": true, "license": "ISC" }, "node_modules/inquirer": { @@ -9850,6 +9882,7 @@ }, "node_modules/is-core-module": { "version": "2.13.1", + "dev": true, "license": "MIT", "dependencies": { "hasown": "^2.0.0" @@ -10228,6 +10261,7 @@ }, "node_modules/isexe": { "version": "2.0.0", + "dev": true, "license": "ISC" }, "node_modules/isobject": { @@ -12249,6 +12283,7 @@ }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", + "dev": true, "license": "MIT" }, "node_modules/json-schema-traverse": { @@ -12514,6 +12549,7 @@ }, "node_modules/lru-cache": { "version": "6.0.0", + "dev": true, "license": "ISC", "dependencies": { "yallist": "^4.0.0" @@ -12891,6 +12927,7 @@ }, "node_modules/minimatch": { "version": "3.1.2", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -12901,6 +12938,7 @@ }, "node_modules/minimatch/node_modules/brace-expansion": { "version": "1.1.11", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -12922,6 +12960,7 @@ }, "node_modules/minipass": { "version": "5.0.0", + "dev": true, "license": "ISC", "engines": { "node": ">=8" @@ -12929,6 +12968,7 @@ }, "node_modules/minizlib": { "version": "2.1.2", + "dev": true, "license": "MIT", "dependencies": { "minipass": "^3.0.0", @@ -12940,6 +12980,7 @@ }, "node_modules/minizlib/node_modules/minipass": { "version": "3.3.6", + "dev": true, "license": "ISC", "dependencies": { "yallist": "^4.0.0" @@ -12970,6 +13011,7 @@ }, "node_modules/mkdirp": { "version": "1.0.4", + "dev": true, "license": "MIT", "bin": { "mkdirp": "bin/cmd.js" @@ -12985,6 +13027,7 @@ }, "node_modules/ms": { "version": "2.1.2", + "dev": true, "license": "MIT" }, "node_modules/mute-stdout": { @@ -13093,6 +13136,7 @@ }, "node_modules/nopt": { "version": "5.0.0", + "dev": true, "license": "ISC", "dependencies": { "abbrev": "1" @@ -13106,6 +13150,7 @@ }, "node_modules/normalize-package-data": { "version": "2.5.0", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "hosted-git-info": "^2.1.4", @@ -13116,6 +13161,7 @@ }, "node_modules/normalize-package-data/node_modules/semver": { "version": "5.7.2", + "dev": true, "license": "ISC", "bin": { "semver": "bin/semver" @@ -15748,6 +15794,7 @@ }, "node_modules/once": { "version": "1.4.0", + "dev": true, "license": "ISC", "dependencies": { "wrappy": "1" @@ -15876,6 +15923,7 @@ }, "node_modules/p-map": { "version": "2.1.0", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -15980,6 +16028,7 @@ }, "node_modules/path-is-absolute": { "version": "1.0.1", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -15995,6 +16044,7 @@ }, "node_modules/path-parse": { "version": "1.0.7", + "dev": true, "license": "MIT" }, "node_modules/path-root": { @@ -16747,6 +16797,7 @@ }, "node_modules/resolve": { "version": "1.22.8", + "dev": true, "license": "MIT", "dependencies": { "is-core-module": "^2.13.0", @@ -17141,6 +17192,7 @@ }, "node_modules/semver": { "version": "7.6.0", + "dev": true, "license": "ISC", "dependencies": { "lru-cache": "^6.0.0" @@ -17299,6 +17351,7 @@ }, "node_modules/signal-exit": { "version": "3.0.7", + "dev": true, "license": "ISC" }, "node_modules/simple-concat": { @@ -17751,6 +17804,7 @@ }, "node_modules/spdx-correct": { "version": "3.2.0", + "dev": true, "license": "Apache-2.0", "dependencies": { "spdx-expression-parse": "^3.0.0", @@ -17759,10 +17813,12 @@ }, "node_modules/spdx-exceptions": { "version": "2.5.0", + "dev": true, "license": "CC-BY-3.0" }, "node_modules/spdx-expression-parse": { "version": "3.0.1", + "dev": true, "license": "MIT", "dependencies": { "spdx-exceptions": "^2.1.0", @@ -17771,6 +17827,7 @@ }, "node_modules/spdx-license-ids": { "version": "3.0.17", + "dev": true, "license": "CC0-1.0" }, "node_modules/split-string": { @@ -18055,6 +18112,7 @@ }, "node_modules/supports-color": { "version": "5.5.0", + "dev": true, "license": "MIT", "dependencies": { "has-flag": "^3.0.0" @@ -18065,6 +18123,7 @@ }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -18123,6 +18182,7 @@ }, "node_modules/tar": { "version": "6.2.1", + "dev": true, "license": "ISC", "dependencies": { "chownr": "^2.0.0", @@ -18223,6 +18283,7 @@ }, "node_modules/text-table": { "version": "0.2.0", + "dev": true, "license": "MIT" }, "node_modules/textextensions": { @@ -19010,6 +19071,7 @@ }, "node_modules/validate-npm-package-license": { "version": "3.0.4", + "dev": true, "license": "Apache-2.0", "dependencies": { "spdx-correct": "^3.0.0", @@ -19232,6 +19294,7 @@ }, "node_modules/which": { "version": "2.0.2", + "dev": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" @@ -19349,10 +19412,12 @@ }, "node_modules/wrappy": { "version": "1.0.2", + "dev": true, "license": "ISC" }, "node_modules/write-file-atomic": { "version": "4.0.2", + "dev": true, "license": "ISC", "dependencies": { "imurmurhash": "^0.1.4", @@ -19420,6 +19485,7 @@ }, "node_modules/yallist": { "version": "4.0.0", + "dev": true, "license": "ISC" }, "node_modules/yargs": { @@ -19483,7 +19549,8 @@ "version": "0.0.1", "license": "ISC", "dependencies": { - "@aws-sdk/client-s3": "3.556.0" + "@aws-sdk/client-s3": "3.556.0", + "deep-freeze-es6": "^3.0.2" }, "devDependencies": { "@jspsych/config": "^2.0.0", diff --git a/packages/data/package.json b/packages/data/package.json index 2034ac91..756009e1 100644 --- a/packages/data/package.json +++ b/packages/data/package.json @@ -21,7 +21,8 @@ "test": "jest --coverage" }, "dependencies": { - "@aws-sdk/client-s3": "3.556.0" + "@aws-sdk/client-s3": "3.556.0", + "deep-freeze-es6": "^3.0.2" }, "devDependencies": { "@jspsych/config": "^2.0.0", diff --git a/packages/data/src/index.ts b/packages/data/src/index.ts index 4e612ce7..723f81ef 100644 --- a/packages/data/src/index.ts +++ b/packages/data/src/index.ts @@ -1,3 +1,4 @@ +import deepFreeze from "deep-freeze-es6"; import { finish, retrieveChild, @@ -34,7 +35,6 @@ async function load(response_uuid: string) { deepFreeze(window.chs); await finish(); } - } export default { load, retrieveResponse, updateResponse, finish, s3 }; diff --git a/packages/data/src/utils.spec.ts b/packages/data/src/utils.spec.ts index 3474ca20..56240702 100644 --- a/packages/data/src/utils.spec.ts +++ b/packages/data/src/utils.spec.ts @@ -9,10 +9,9 @@ function setLocationHref(href: string) { * Helper function for this set of tests. This will update the current URL to the value * provided in argument href. */ - // delete global.window.location; - // global.window = Object.create(window); - // global.window.location = { href }; - return href; + delete global.window.location; + global.window = Object.create(window); + global.window.location = { href }; } test("Api get function", async () => { diff --git a/packages/surveys/src/utils.ts b/packages/surveys/src/utils.ts index 8b52ce6a..615db7ad 100644 --- a/packages/surveys/src/utils.ts +++ b/packages/surveys/src/utils.ts @@ -1,17 +1,8 @@ import Data from "@lookit/data"; -import { Study } from "@lookit/lookit-api/dist/types"; import DOMPurify from "dompurify"; import { marked } from "marked"; import { Model } from "survey-jquery"; -declare global { - interface Window { - lookit: { - study: Study; - }; - } -} - const CONFIG = { marked: { async: false }, dompurify: { USE_PROFILES: { html: true } },