Skip to content

Commit

Permalink
Merge branch 'release-3.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
olga-kulish committed Aug 13, 2024
2 parents 1ac09a7 + 12beb21 commit b04cdc1
Show file tree
Hide file tree
Showing 12 changed files with 975 additions and 1,768 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ dist/
node_modules/
.nyc_ouput/
coverage/
lib/
environment/
7 changes: 1 addition & 6 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,13 @@ export default inputs.map(input => {
'i18n',
'jquery',
'jquery.fileDownload',
'lib/uuid',
'lodash',
'module',
'moment'
],
plugins: [
resolve({ mainFields: ['main'] }),
commonJS({
namedExports: {
fastestsmallesttextencoderdecoder: ['TextEncoder']
}
}),
commonJS(),
alias({
resolve: ['.js', '.json'],
core: path.resolve(srcDir, 'core'),
Expand Down
15 changes: 9 additions & 6 deletions environment/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2019 (original work) Open Assessment Technologies SA ;
* Copyright (c) 2019-2024 (original work) Open Assessment Technologies SA ;
*/

define(['/node_modules/@oat-sa/tao-core-libs/dist/pathdefinition.js'], function(libPathDefinition) {
define(function() {
requirejs.config({
baseUrl: '/',
paths: Object.assign(
Expand All @@ -35,12 +35,15 @@ define(['/node_modules/@oat-sa/tao-core-libs/dist/pathdefinition.js'], function(
util: '/dist/util',

'jquery.mockjax': '/node_modules/jquery-mockjax/dist/jquery.mockjax',
'webcrypto-shim': '/node_modules/webcrypto-shim/webcrypto-shim',
'idb-wrapper': '/node_modules/idb-wrapper/idbstore',
'fetch-mock': '/node_modules/fetch-mock/es5/client-bundle',
'xhr-mock': '/node_modules/xhr-mock/dist/xhr-mock'
},
libPathDefinition
'xhr-mock': '/node_modules/xhr-mock/dist/xhr-mock',

jquery: '/node_modules/jquery/jquery',
lodash: '/node_modules/lodash/lodash',
moment: '/node_modules/moment/min/moment-with-locales',
handlebars: '/node_modules/handlebars/dist/handlebars.amd'
}
),
shim: {
'jquery.simulate': {
Expand Down
2,592 changes: 866 additions & 1,726 deletions package-lock.json

Large diffs are not rendered by default.

25 changes: 6 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-core-sdk",
"version": "3.1.1",
"version": "3.2.1",
"displayName": "TAO Core SDK",
"description": "Core libraries of TAO",
"homepage": "https://github.com/oat-sa/tao-core-sdk-fe#readme",
Expand Down Expand Up @@ -41,37 +41,25 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/core": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"@oat-sa/browserslist-config-tao": "^1.0.1",
"@oat-sa/eslint-config-tao": "^2.0.0",
"@oat-sa/prettier-config": "^0.1.1",
"@oat-sa/tao-core-libs": "^1.0.0",
"@oat-sa/tao-qunit-testrunner": "^2.0.0",
"async": "^0.2.10",
"dompurify": "^2.4.0",
"eslint": "^8.39.0",
"fetch-mock": "^9.11.0",
"gamp": "0.2.1",
"glob": "^8.1.0",
"handlebars": "1.3.0",
"interactjs": "1.3.4",
"jquery": "1.9.1",
"jquery-mockjax": "^2.6.0",
"jquery-simulate": "^1.0.2",
"lodash": "^4.17.21",
"mime": "^2.4.2",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"node-qunit-puppeteer": "^1.0.13",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"open-cli": "^7.2.0",
"popper.js": "1.16.1",
"prettier": "^2.8.8",
"promise-limit": "^2.7.0",
"qunit": "^2.19.1",
"raphael": "2.3.0",
"require-css": "^0.1.10",
"requirejs-plugins": "^1.0.2",
"rollup": "^1.32.1",
Expand All @@ -81,14 +69,13 @@
"rollup-plugin-istanbul": "^2.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"select2": "3.5.1",
"tooltip.js": "1.3.3",
"xhr-mock": "^2.5.1"
},
"dependencies": {
"fastestsmallesttextencoderdecoder": "1.0.14",
"idb-wrapper": "1.7.2",
"webcrypto-shim": "0.1.7"
"jquery": "1.9.1",
"lodash": "^4.17.21",
"moment": "^2.29.4"
},
"browserslist": [
"extends @oat-sa/browserslist-config-tao"
Expand Down
8 changes: 3 additions & 5 deletions src/core/digest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2018-2020 (original work) Open Assessment Technologies SA
* Copyright (c) 2018-2024 (original work) Open Assessment Technologies SA
*
*/

Expand All @@ -24,11 +24,9 @@
*
* @author Bertrand Chevrier <bertrand@taotesting.com>
*/
import 'webcrypto-shim';
import { TextEncoder } from 'fastestsmallesttextencoderdecoder';

//get the native implementation of the CryptoSubtle
const subtle = window.crypto.subtle || window.crypto.webkitSubtle;
const subtle = window.crypto.subtle;
const supportedAlgorithms = [
'SHA-1', //considered as not safe anymore
'SHA-256',
Expand Down Expand Up @@ -72,7 +70,7 @@ export default function digest(data, selectedAlgorithm = 'SHA-256') {
reader.readAsArrayBuffer(data);
});
} else if (typeof data === 'string') {
dataPromise = Promise.resolve(new TextEncoder('utf-8').encode(data));
dataPromise = Promise.resolve(new TextEncoder().encode(data));
} else {
throw new TypeError(`Unsupported data type to digest with ${algorithm}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/eventifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
*/
import _ from 'lodash';
import Promise from 'core/promise';
import uuid from 'lib/uuid';
import uuid from 'core/uuid';
import loggerFactory from 'core/logger';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/promiseQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import _ from 'lodash';
import Promise from 'core/promise';
import eventifier from 'core/eventifier';
import uuid from 'lib/uuid';
import uuid from 'core/uuid';

/**
* Creates a new promise queue
Expand Down
2 changes: 1 addition & 1 deletion src/core/store/indexeddb.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import _ from 'lodash';
import Promise from 'core/promise';
import IDBStore from 'idb-wrapper';
import uuid from 'lib/uuid';
import uuid from 'core/uuid';

/**
* Prefix all databases
Expand Down
2 changes: 1 addition & 1 deletion src/core/store/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
import _ from 'lodash';
import Promise from 'core/promise';
import uuid from 'lib/uuid';
import uuid from 'core/uuid';

/**
* where data dwelves
Expand Down
2 changes: 1 addition & 1 deletion src/core/store/webstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import _ from 'lodash';
import promiseQueue from 'core/promiseQueue';
import uuid from 'lib/uuid';
import uuid from 'core/uuid';

/**
* Prefix all databases
Expand Down
85 changes: 85 additions & 0 deletions src/core/uuid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* UUID generator
*
* This is a modified version of Robert Kieffer's Math.uuid
* from http://www.broofa.com/2008/09/javascript-uuid-function/
*
* It differs in three ways from the original work:
* - uuid is no longer attached to the Math object
* - script is now written in require.js style
* - alternative implementations have been removed
*
* Additionally the usage examples have been adapted to reflect these changes.
*
* Original credits:
* Math.uuid.js (v1.4)
* http://www.broofa.com
* mailto:robert@broofa.com
*
* Copyright (c) 2010 Robert Kieffer
* Dual licensed under the MIT and GPL licenses.
*
*/

// Private array of chars to use
const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');

/**
* Generate a random uuid
*
* USAGE: uuid(length, radix)
* length - the desired number of characters
* radix - the number of allowable values for each character.
*
* EXAMPLES:
* // No arguments - returns RFC4122, version 4 ID
* >>> uuid()
* "92329D39-6F5C-4520-ABFC-AAB64544E172"
*
* // One argument - returns ID of the specified length
* >>> uuid(15) // 15 character ID (default base=62)
* "VcydxgltxrVZSTV"
*
* // Two arguments - returns ID of the specified length, and radix. (Radix must be <= 62)
* >>> uuid(8, 2) // 8 character ID (base=2)
* "01001010"
* >>> uuid(8, 10) // 8 character ID (base=10)
* "47473046"
* >>> uuid(8, 16) // 8 character ID (base=16)
* "098F4D35"
*
* @param {number} len
* @param {number} radix
* @returns {*}
* @private
*/
function uuid(len, radix) {
const chars = CHARS;
const id = [];
radix = radix || chars.length;

// Compact form
if (len) {
for (let i = 0; i < len; i++) {
id[i] = chars[0 | (Math.random() * radix)];
}
// rfc4122 form
} else {
// rfc4122 requires these characters
// eslint-disable-next-line
id[8] = id[13] = id[18] = id[23] = '-';
id[14] = '4';

// Fill in random data. At i === 19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (let i = 0; i < 36; i++) {
if (!id[i]) {
const r = 0 | (Math.random() * 16);
id[i] = chars[i === 19 ? (r & 0x3) | 0x8 : r];
}
}
}

return id.join('');
}
export default uuid;

0 comments on commit b04cdc1

Please sign in to comment.