@upandgo/react-scorm-container
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -9,3 +9,5 @@ import * as React from "react"; | ||
initialState: LMSState; | ||
commitCallback: (state: LMSState, eventList: SCORMEvent[]) => void; | ||
commitCallback: (state: LMSState, eventList: SCORMEvent & { | ||
sessionId: string; | ||
}[]) => void; | ||
}; | ||
@@ -15,2 +17,3 @@ declare type State = { | ||
moduleUrl?: string; | ||
sessionId: string; | ||
}; | ||
@@ -17,0 +20,0 @@ export default class ExampleComponent extends React.Component<Props, State> { |
@@ -32,2 +32,13 @@ import { createRef, createElement, Component } from 'react'; | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
@@ -106,2 +117,57 @@ return new (P || (P = Promise))(function (resolve, reject) { | ||
// This file replaces `index.js` in bundlers like webpack or Rollup, | ||
// according to `browser` config in `package.json`. | ||
if (process.env.NODE_ENV !== 'production') { | ||
// All bundlers will remove this block in production bundle | ||
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { | ||
throw new Error( | ||
'React Native does not have a built-in secure random generator. ' + | ||
'If you don’t need unpredictable IDs, you can use `nanoid/non-secure`. ' + | ||
'For secure ID install `expo-random` locally and use `nanoid/async`.' | ||
) | ||
} | ||
if (typeof self === 'undefined' || (!self.crypto && !self.msCrypto)) { | ||
throw new Error( | ||
'Your browser does not have secure random generator. ' + | ||
'If you don’t need unpredictable IDs, you can use nanoid/non-secure.' | ||
) | ||
} | ||
} | ||
var crypto = self.crypto || self.msCrypto; | ||
// This alphabet uses a-z A-Z 0-9 _- symbols. | ||
// Symbols are generated for smaller size. | ||
// -_zyxwvutsrqponmlkjihgfedcba9876543210ZYXWVUTSRQPONMLKJIHGFEDCBA | ||
var url = '-_'; | ||
// Loop from 36 to 0 (from z to a and 9 to 0 in Base36). | ||
var i = 36; | ||
while (i--) { | ||
// 36 is radix. Number.prototype.toString(36) returns number | ||
// in Base36 representation. Base36 is like hex, but it uses 0–9 and a-z. | ||
url += i.toString(36); | ||
} | ||
// Loop from 36 to 10 (from Z to A in Base36). | ||
i = 36; | ||
while (i-- - 10) { | ||
url += i.toString(36).toUpperCase(); | ||
} | ||
var index_browser = function (size) { | ||
var id = ''; | ||
var bytes = crypto.getRandomValues(new Uint8Array(size || 21)); | ||
i = size || 21; | ||
// Compact alternative for `for (var i = 0; i < size; i++)` | ||
while (i--) { | ||
// We can’t use bytes bigger than the alphabet. 63 is 00111111 bitmask. | ||
// This mask reduces random byte 0-255 to 0-63 values. | ||
// There is no need in `|| ''` and `* 1.6` hacks in here, | ||
// because bitmask trim bytes exact to alphabet size. | ||
id += url[bytes[i] & 63]; | ||
} | ||
return id | ||
}; | ||
var ExampleComponent = /** @class */ (function (_super) { | ||
@@ -131,3 +197,3 @@ __extends(ExampleComponent, _super); | ||
if (ev.data.type === "commit") { | ||
_this.props.commitCallback(ev.data.data, ev.data.eventList); | ||
_this.props.commitCallback(ev.data.data, ev.data.eventList.map(function (event) { return (__assign(__assign({}, event), { sessionId: _this.state.sessionId })); })); | ||
} | ||
@@ -151,6 +217,9 @@ }; | ||
_this.scormIFrame = createRef(); | ||
_this.state = {}; | ||
_this.state = { | ||
sessionId: "" | ||
}; | ||
return _this; | ||
} | ||
ExampleComponent.prototype.componentDidMount = function () { | ||
this.setState({ sessionId: index_browser() }); | ||
this.fetchManifest(); | ||
@@ -157,0 +226,0 @@ this.initSCORMListener(); |
@@ -36,2 +36,13 @@ 'use strict'; | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
@@ -110,2 +121,57 @@ return new (P || (P = Promise))(function (resolve, reject) { | ||
// This file replaces `index.js` in bundlers like webpack or Rollup, | ||
// according to `browser` config in `package.json`. | ||
if (process.env.NODE_ENV !== 'production') { | ||
// All bundlers will remove this block in production bundle | ||
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { | ||
throw new Error( | ||
'React Native does not have a built-in secure random generator. ' + | ||
'If you don’t need unpredictable IDs, you can use `nanoid/non-secure`. ' + | ||
'For secure ID install `expo-random` locally and use `nanoid/async`.' | ||
) | ||
} | ||
if (typeof self === 'undefined' || (!self.crypto && !self.msCrypto)) { | ||
throw new Error( | ||
'Your browser does not have secure random generator. ' + | ||
'If you don’t need unpredictable IDs, you can use nanoid/non-secure.' | ||
) | ||
} | ||
} | ||
var crypto = self.crypto || self.msCrypto; | ||
// This alphabet uses a-z A-Z 0-9 _- symbols. | ||
// Symbols are generated for smaller size. | ||
// -_zyxwvutsrqponmlkjihgfedcba9876543210ZYXWVUTSRQPONMLKJIHGFEDCBA | ||
var url = '-_'; | ||
// Loop from 36 to 0 (from z to a and 9 to 0 in Base36). | ||
var i = 36; | ||
while (i--) { | ||
// 36 is radix. Number.prototype.toString(36) returns number | ||
// in Base36 representation. Base36 is like hex, but it uses 0–9 and a-z. | ||
url += i.toString(36); | ||
} | ||
// Loop from 36 to 10 (from Z to A in Base36). | ||
i = 36; | ||
while (i-- - 10) { | ||
url += i.toString(36).toUpperCase(); | ||
} | ||
var index_browser = function (size) { | ||
var id = ''; | ||
var bytes = crypto.getRandomValues(new Uint8Array(size || 21)); | ||
i = size || 21; | ||
// Compact alternative for `for (var i = 0; i < size; i++)` | ||
while (i--) { | ||
// We can’t use bytes bigger than the alphabet. 63 is 00111111 bitmask. | ||
// This mask reduces random byte 0-255 to 0-63 values. | ||
// There is no need in `|| ''` and `* 1.6` hacks in here, | ||
// because bitmask trim bytes exact to alphabet size. | ||
id += url[bytes[i] & 63]; | ||
} | ||
return id | ||
}; | ||
var ExampleComponent = /** @class */ (function (_super) { | ||
@@ -135,3 +201,3 @@ __extends(ExampleComponent, _super); | ||
if (ev.data.type === "commit") { | ||
_this.props.commitCallback(ev.data.data, ev.data.eventList); | ||
_this.props.commitCallback(ev.data.data, ev.data.eventList.map(function (event) { return (__assign(__assign({}, event), { sessionId: _this.state.sessionId })); })); | ||
} | ||
@@ -155,6 +221,9 @@ }; | ||
_this.scormIFrame = React.createRef(); | ||
_this.state = {}; | ||
_this.state = { | ||
sessionId: "" | ||
}; | ||
return _this; | ||
} | ||
ExampleComponent.prototype.componentDidMount = function () { | ||
this.setState({ sessionId: index_browser() }); | ||
this.fetchManifest(); | ||
@@ -161,0 +230,0 @@ this.initSCORMListener(); |
{ | ||
"name": "@upandgo/react-scorm-container", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A React component acting as a LMS, listening to SCORM API events and reacting to SCORM API call.", | ||
@@ -25,2 +25,3 @@ "author": "Sangrene", | ||
"dependencies": { | ||
"nanoid": "^2.1.11", | ||
"xml2js": "^0.4.23" | ||
@@ -33,4 +34,6 @@ }, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@svgr/rollup": "^2.4.1", | ||
"@types/jest": "^23.1.5", | ||
"@types/nanoid": "^2.1.0", | ||
"@types/react": "^16.3.13", | ||
@@ -37,0 +40,0 @@ "@types/react-dom": "^16.0.5", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
82322
543
4
27
3
+ Addednanoid@^2.1.11
+ Addednanoid@2.1.11(transitive)