updates to camp and things
This commit is contained in:
parent
16e1340a7c
commit
7724a42e73
442 changed files with 97335 additions and 8 deletions
60
static/js/cljs-runtime/goog.html.safescript.js
Normal file
60
static/js/cljs-runtime/goog.html.safescript.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
goog.loadModule(function(exports) {
|
||||
"use strict";
|
||||
goog.module("goog.html.SafeScript");
|
||||
goog.module.declareLegacyNamespace();
|
||||
const Const = goog.require("goog.string.Const");
|
||||
const TypedString = goog.require("goog.string.TypedString");
|
||||
const trustedtypes = goog.require("goog.html.trustedtypes");
|
||||
const {fail} = goog.require("goog.asserts");
|
||||
const CONSTRUCTOR_TOKEN_PRIVATE = {};
|
||||
class SafeScript {
|
||||
constructor(value, token) {
|
||||
this.privateDoNotAccessOrElseSafeScriptWrappedValue_ = token === CONSTRUCTOR_TOKEN_PRIVATE ? value : "";
|
||||
this.implementsGoogStringTypedString = true;
|
||||
}
|
||||
toString() {
|
||||
return this.privateDoNotAccessOrElseSafeScriptWrappedValue_.toString();
|
||||
}
|
||||
static fromConstant(script) {
|
||||
const scriptString = Const.unwrap(script);
|
||||
if (scriptString.length === 0) {
|
||||
return SafeScript.EMPTY;
|
||||
}
|
||||
return SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse(scriptString);
|
||||
}
|
||||
static fromJson(val) {
|
||||
return SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse(SafeScript.stringify_(val));
|
||||
}
|
||||
getTypedStringValue() {
|
||||
return this.privateDoNotAccessOrElseSafeScriptWrappedValue_.toString();
|
||||
}
|
||||
static unwrap(safeScript) {
|
||||
return SafeScript.unwrapTrustedScript(safeScript).toString();
|
||||
}
|
||||
static unwrapTrustedScript(safeScript) {
|
||||
if (safeScript instanceof SafeScript && safeScript.constructor === SafeScript) {
|
||||
return safeScript.privateDoNotAccessOrElseSafeScriptWrappedValue_;
|
||||
} else {
|
||||
fail("expected object of type SafeScript, got '" + safeScript + "' of type " + goog.typeOf(safeScript));
|
||||
return "type_error:SafeScript";
|
||||
}
|
||||
}
|
||||
static stringify_(val) {
|
||||
const json = JSON.stringify(val);
|
||||
return json.replace(/</g, "\\x3c");
|
||||
}
|
||||
static createSafeScriptSecurityPrivateDoNotAccessOrElse(script) {
|
||||
const noinlineScript = script;
|
||||
const policy = trustedtypes.getPolicyPrivateDoNotAccessOrElse();
|
||||
const trustedScript = policy ? policy.createScript(noinlineScript) : noinlineScript;
|
||||
return new SafeScript(trustedScript, CONSTRUCTOR_TOKEN_PRIVATE);
|
||||
}
|
||||
}
|
||||
SafeScript.EMPTY = {valueOf:function() {
|
||||
return SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse("");
|
||||
},}.valueOf();
|
||||
exports = SafeScript;
|
||||
return exports;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=goog.html.safescript.js.map
|
Loading…
Add table
Add a link
Reference in a new issue