Skip to content

Instantly share code, notes, and snippets.

@anudit
Last active January 5, 2024 10:28
Show Gist options
  • Save anudit/5d0524da5a6e3dde2381bcd76a05de1e to your computer and use it in GitHub Desktop.
Save anudit/5d0524da5a6e3dde2381bcd76a05de1e to your computer and use it in GitHub Desktop.
TLSN error
/*! For license information please see index.js.LICENSE.txt */ ! function(e, t) {
if ("object" == typeof exports && "object" == typeof module) module.exports = t();
else if ("function" == typeof define && define.amd) define([], t);
else {
var n = t();
for (var r in n)("object" == typeof exports ? exports : e)[r] = n[r]
}
}(this, (() => (() => {
"use strict";
var e = {
m: {},
d: (t, n) => {
for (var r in n) e.o(n, r) && !e.o(t, r) && Object.defineProperty(t, r, {
enumerable: !0,
get: n[r]
})
},
u: e => e + ".js",
o: (e, t) => Object.prototype.hasOwnProperty.call(e, t),
r: e => {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
value: "Module"
}), Object.defineProperty(e, "__esModule", {
value: !0
})
},
p: ""
};
e.b = document.baseURI || self.location.href;
var t = {};
e.r(t), e.d(t, {
prove: () => T,
verify: () => R
});
const n = Symbol("Comlink.proxy"),
r = Symbol("Comlink.endpoint"),
o = Symbol("Comlink.releaseProxy"),
a = Symbol("Comlink.finalizer"),
i = Symbol("Comlink.thrown"),
s = e => "object" == typeof e && null !== e || "function" == typeof e,
c = new Map([
["proxy", {
canHandle: e => s(e) && e[n],
serialize(e) {
const {
port1: t,
port2: n
} = new MessageChannel;
return u(e, t), [n, [n]]
},
deserialize: e => (e.start(), f(e))
}],
["throw", {
canHandle: e => s(e) && i in e,
serialize({
value: e
}) {
let t;
return t = e instanceof Error ? {
isError: !0,
value: {
message: e.message,
name: e.name,
stack: e.stack
}
} : {
isError: !1,
value: e
}, [t, []]
},
deserialize(e) {
if (e.isError) throw Object.assign(new Error(e.value.message), e.value);
throw e.value
}
}]
]);
function u(e, t = globalThis, r = ["*"]) {
t.addEventListener("message", (function o(s) {
if (!s || !s.data) return;
if (! function(e, t) {
for (const n of e) {
if (t === n || "*" === n) return !0;
if (n instanceof RegExp && n.test(t)) return !0
}
return !1
}(r, s.origin)) return void console.warn(`Invalid origin '${s.origin}' for comlink proxy`);
const {
id: c,
type: f,
path: p
} = Object.assign({
path: []
}, s.data), y = (s.data.argumentList || []).map(w);
let d;
try {
const t = p.slice(0, -1).reduce(((e, t) => e[t]), e),
r = p.reduce(((e, t) => e[t]), e);
switch (f) {
case "GET":
d = r;
break;
case "SET":
t[p.slice(-1)[0]] = w(s.data.value), d = !0;
break;
case "APPLY":
d = r.apply(t, y);
break;
case "CONSTRUCT":
d = function(e) {
return Object.assign(e, {
[n]: !0
})
}(new r(...y));
break;
case "ENDPOINT": {
const {
port1: t,
port2: n
} = new MessageChannel;
u(e, n), d = function(e, t) {
return v.set(e, t), e
}(t, [t])
}
break;
case "RELEASE":
d = void 0;
break;
default:
return
}
} catch (e) {
d = {
value: e,
[i]: 0
}
}
Promise.resolve(d).catch((e => ({
value: e,
[i]: 0
}))).then((n => {
const [r, i] = g(n);
t.postMessage(Object.assign(Object.assign({}, r), {
id: c
}), i), "RELEASE" === f && (t.removeEventListener("message", o), l(t), a in e && "function" == typeof e[a] && e[a]())
})).catch((e => {
const [n, r] = g({
value: new TypeError("Unserializable return value"),
[i]: 0
});
t.postMessage(Object.assign(Object.assign({}, n), {
id: c
}), r)
}))
})), t.start && t.start()
}
function l(e) {
(function(e) {
return "MessagePort" === e.constructor.name
})(e) && e.close()
}
function f(e, t) {
return b(e, [], t)
}
function p(e) {
if (e) throw new Error("Proxy has been released and is not useable")
}
function y(e) {
return E(e, {
type: "RELEASE"
}).then((() => {
l(e)
}))
}
const d = new WeakMap,
h = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e => {
const t = (d.get(e) || 0) - 1;
d.set(e, t), 0 === t && y(e)
}));
function b(e, t = [], n = function() {}) {
let a = !1;
const i = new Proxy(n, {
get(n, r) {
if (p(a), r === o) return () => {
! function(e) {
h && h.unregister(e)
}(i), y(e), a = !0
};
if ("then" === r) {
if (0 === t.length) return {
then: () => i
};
const n = E(e, {
type: "GET",
path: t.map((e => e.toString()))
}).then(w);
return n.then.bind(n)
}
return b(e, [...t, r])
},
set(n, r, o) {
p(a);
const [i, s] = g(o);
return E(e, {
type: "SET",
path: [...t, r].map((e => e.toString())),
value: i
}, s).then(w)
},
apply(n, o, i) {
p(a);
const s = t[t.length - 1];
if (s === r) return E(e, {
type: "ENDPOINT"
}).then(w);
if ("bind" === s) return b(e, t.slice(0, -1));
const [c, u] = m(i);
return E(e, {
type: "APPLY",
path: t.map((e => e.toString())),
argumentList: c
}, u).then(w)
},
construct(n, r) {
p(a);
const [o, i] = m(r);
return E(e, {
type: "CONSTRUCT",
path: t.map((e => e.toString())),
argumentList: o
}, i).then(w)
}
});
return function(e, t) {
const n = (d.get(t) || 0) + 1;
d.set(t, n), h && h.register(e, t, e)
}(i, e), i
}
function m(e) {
const t = e.map(g);
return [t.map((e => e[0])), (n = t.map((e => e[1])), Array.prototype.concat.apply([], n))];
var n
}
const v = new WeakMap;
function g(e) {
for (const [t, n] of c)
if (n.canHandle(e)) {
const [r, o] = n.serialize(e);
return [{
type: "HANDLER",
name: t,
value: r
}, o]
} return [{
type: "RAW",
value: e
}, v.get(e) || []]
}
function w(e) {
switch (e.type) {
case "HANDLER":
return c.get(e.name).deserialize(e.value);
case "RAW":
return e.value
}
}
function E(e, t, n) {
return new Promise((r => {
const o = new Array(4).fill(0).map((() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16))).join("-");
e.addEventListener("message", (function t(n) {
n.data && n.data.id && n.data.id === o && (e.removeEventListener("message", t), r(n.data))
})), e.start && e.start(), e.postMessage(Object.assign({
id: o
}, t), n)
}))
}
var S, k = function() {
return k = Object.assign || function(e) {
for (var t, n = 1, r = arguments.length; n < r; n++)
for (var o in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
return e
}, k.apply(this, arguments)
},
P = function(e, t, n, r) {
return new(n || (n = Promise))((function(o, a) {
function i(e) {
try {
c(r.next(e))
} catch (e) {
a(e)
}
}
function s(e) {
try {
c(r.throw(e))
} catch (e) {
a(e)
}
}
function c(e) {
var t;
e.done ? o(e.value) : (t = e.value, t instanceof n ? t : new n((function(e) {
e(t)
}))).then(i, s)
}
c((r = r.apply(e, t || [])).next())
}))
},
j = function(e, t) {
var n, r, o, a, i = {
label: 0,
sent: function() {
if (1 & o[0]) throw o[1];
return o[1]
},
trys: [],
ops: []
};
return a = {
next: s(0),
throw: s(1),
return: s(2)
}, "function" == typeof Symbol && (a[Symbol.iterator] = function() {
return this
}), a;
function s(s) {
return function(c) {
return function(s) {
if (n) throw new TypeError("Generator is already executing.");
for (; a && (a = 0, s[0] && (i = 0)), i;) try {
if (n = 1, r && (o = 2 & s[0] ? r.return : s[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, s[1])).done) return o;
switch (r = 0, o && (s = [2 & s[0], o.value]), s[0]) {
case 0:
case 1:
o = s;
break;
case 4:
return i.label++, {
value: s[1],
done: !1
};
case 5:
i.label++, r = s[1], s = [0];
continue;
case 7:
s = i.ops.pop(), i.trys.pop();
continue;
default:
if (!((o = (o = i.trys).length > 0 && o[o.length - 1]) || 6 !== s[0] && 2 !== s[0])) {
i = 0;
continue
}
if (3 === s[0] && (!o || s[1] > o[0] && s[1] < o[3])) {
i.label = s[1];
break
}
if (6 === s[0] && i.label < o[1]) {
i.label = o[1], o = s;
break
}
if (o && i.label < o[2]) {
i.label = o[2], i.ops.push(s);
break
}
o[2] && i.ops.pop(), i.trys.pop();
continue
}
s = t.call(e, i)
} catch (e) {
s = [6, e], r = 0
} finally {
n = o = 0
}
if (5 & s[0]) throw s[1];
return {
value: s[0] ? s[1] : void 0,
done: !0
}
}([s, c])
}
}
},
x = f(new Worker(new URL(e.p + e.u(995), e.b)));
function O() {
return P(this, void 0, Promise, (function() {
return j(this, (function(e) {
switch (e.label) {
case 0:
return S ? [2, S] : [4, new x];
case 1:
return [2, S = e.sent()]
}
}))
}))
}
var T = function(e, t) {
return P(void 0, void 0, Promise, (function() {
var n, r, o, a, i, s, c, u, l, f, p, y, d;
return j(this, (function(h) {
switch (h.label) {
case 0:
return n = t.method, r = t.headers, o = void 0 === r ? {} : r, a = t.body, i = void 0 === a ? "" : a, s = t.maxTranscriptSize, c = void 0 === s ? 16384 : s, u = t.notaryUrl, l = t.websocketProxyUrl, f = t.secretHeaders, p = t.secretResps, [4, O()];
case 1:
return y = h.sent(), o.Host = new URL(e).host, o.Connection = "close", [4, y.prove(e, {
method: n,
headers: o,
body: i,
maxTranscriptSize: c,
notaryUrl: u,
websocketProxyUrl: l,
secretHeaders: f,
secretResps: p
})];
case 2:
return d = h.sent(), [2, k(k({}, d), {
notaryUrl: u
})]
}
}))
}))
},
R = function(e) {
return P(void 0, void 0, Promise, (function() {
var t, n, r;
return j(this, (function(o) {
switch (o.label) {
case 0:
return [4, fetch(e.notaryUrl + "/info")];
case 1:
return [4, o.sent().json()];
case 2:
return t = o.sent(), n = t.publicKey, [4, O()];
case 3:
return [4, o.sent().verify(e, n)];
case 4:
return r = o.sent(), [2, k(k({}, r), {
notaryUrl: e.notaryUrl
})]
}
}))
}))
};
return t
})()));
//# sourceMappingURL=index.js.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment