jimeng-free-api/temp/lib-uploader.3.js
2025-05-30 18:37:00 +08:00

480 lines
13 KiB
JavaScript

(function (e, t) {
if (
("undefined" != typeof window &&
window.crypto &&
(r = window.crypto),
"undefined" != typeof self &&
self.crypto &&
(r = self.crypto),
"undefined" != typeof globalThis &&
globalThis.crypto &&
(r = globalThis.crypto),
!r &&
"undefined" != typeof window &&
window.msCrypto &&
(r = window.msCrypto),
!r && void 0 !== o && o.crypto && (r = o.crypto),
!r)
)
try {
r = n.default;
} catch (e) {}
var r,
i = function () {
if (r) {
if ("function" == typeof r.getRandomValues)
try {
return r.getRandomValues(
new Uint32Array(1)
)[0];
} catch (e) {}
if ("function" == typeof r.randomBytes)
try {
return r.randomBytes(4).readInt32LE();
} catch (e) {}
}
throw Error(
"Native crypto module could not be used to get secure random number."
);
},
s =
Object.create ||
(function () {
function e() {}
return function (t) {
var r;
return (
(e.prototype = t),
(r = new e()),
(e.prototype = null),
r
);
};
})(),
a = {},
c = (a.lib = {}),
u = (c.Base = {
extend: function (e) {
var t = s(this);
return (
e && t.mixIn(e),
(t.hasOwnProperty("init") &&
this.init !== t.init) ||
(t.init = function () {
t.$super.init.apply(this, arguments);
}),
(t.init.prototype = t),
(t.$super = this),
t
);
},
create: function () {
var e = this.extend();
return e.init.apply(e, arguments), e;
},
init: function () {},
mixIn: function (e) {
for (var t in e)
e.hasOwnProperty(t) && (this[t] = e[t]);
e.hasOwnProperty("toString") &&
(this.toString = e.toString);
},
clone: function () {
return this.init.prototype.extend(this);
},
}),
l = (c.WordArray = u.extend({
init: function (e, t) {
(e = this.words = e || []),
(this.sigBytes =
null != t ? t : 4 * e.length);
},
toString: function (e) {
return (e || p).stringify(this);
},
concat: function (e) {
var t = this.words,
r = e.words,
n = this.sigBytes,
i = e.sigBytes;
if ((this.clamp(), n % 4))
for (var o = 0; o < i; o++) {
var s =
(r[o >>> 2] >>> (24 - (o % 4) * 8)) & 255;
t[(n + o) >>> 2] |=
s << (24 - ((n + o) % 4) * 8);
}
else
for (var a = 0; a < i; a += 4)
t[(n + a) >>> 2] = r[a >>> 2];
return (this.sigBytes += i), this;
},
clamp: function () {
var t = this.words,
r = this.sigBytes;
(t[r >>> 2] &=
0xffffffff << (32 - (r % 4) * 8)),
(t.length = e.ceil(r / 4));
},
clone: function () {
var e = u.clone.call(this);
return (e.words = this.words.slice(0)), e;
},
random: function (e) {
for (var t = [], r = 0; r < e; r += 4)
t.push(i());
return new l.init(t, e);
},
})),
f = (a.enc = {}),
p = (f.Hex = {
stringify: function (e) {
for (
var t = e.words,
r = e.sigBytes,
n = [],
i = 0;
i < r;
i++
) {
var o =
(t[i >>> 2] >>> (24 - (i % 4) * 8)) & 255;
n.push((o >>> 4).toString(16)),
n.push((15 & o).toString(16));
}
return n.join("");
},
parse: function (e) {
for (
var t = e.length, r = [], n = 0;
n < t;
n += 2
)
r[n >>> 3] |=
parseInt(e.substr(n, 2), 16) <<
(24 - (n % 8) * 4);
return new l.init(r, t / 2);
},
}),
h = (f.Latin1 = {
stringify: function (e) {
for (
var t = e.words,
r = e.sigBytes,
n = [],
i = 0;
i < r;
i++
) {
var o =
(t[i >>> 2] >>> (24 - (i % 4) * 8)) & 255;
n.push(String.fromCharCode(o));
}
return n.join("");
},
parse: function (e) {
for (
var t = e.length, r = [], n = 0;
n < t;
n++
)
r[n >>> 2] |=
(255 & e.charCodeAt(n)) <<
(24 - (n % 4) * 8);
return new l.init(r, t);
},
}),
d = (f.Utf8 = {
stringify: function (e) {
try {
return decodeURIComponent(
escape(h.stringify(e))
);
} catch (e) {
throw Error("Malformed UTF-8 data");
}
},
parse: function (e) {
return h.parse(unescape(encodeURIComponent(e)));
},
}),
g = (c.BufferedBlockAlgorithm = u.extend({
reset: function () {
(this._data = new l.init()),
(this._nDataBytes = 0);
},
_append: function (e) {
"string" == typeof e && (e = d.parse(e)),
this._data.concat(e),
(this._nDataBytes += e.sigBytes);
},
_process: function (t) {
var r,
n = this._data,
i = n.words,
o = n.sigBytes,
s = this.blockSize,
a = o / (4 * s),
c =
(a = t
? e.ceil(a)
: e.max(
(0 | a) - this._minBufferSize,
0
)) * s,
u = e.min(4 * c, o);
if (c) {
for (var f = 0; f < c; f += s)
this._doProcessBlock(i, f);
(r = i.splice(0, c)), (n.sigBytes -= u);
}
return new l.init(r, u);
},
clone: function () {
var e = u.clone.call(this);
return (e._data = this._data.clone()), e;
},
_minBufferSize: 0,
}));
c.Hasher = g.extend({
cfg: u.extend(),
init: function (e) {
(this.cfg = this.cfg.extend(e)), this.reset();
},
reset: function () {
g.reset.call(this), this._doReset();
},
update: function (e) {
return this._append(e), this._process(), this;
},
finalize: function (e) {
return e && this._append(e), this._doFinalize();
},
blockSize: 16,
_createHelper: function (e) {
return function (t, r) {
return new e.init(r).finalize(t);
};
},
_createHmacHelper: function (e) {
return function (t, r) {
return new y.HMAC.init(e, r).finalize(t);
};
},
});
var y = (a.algo = {});
return a;
})(Math);
var u = function (e, t) {
var r, n;
e.exports =
((r = a.lib.Base),
(n = a.enc.Utf8),
void (a.algo.HMAC = r.extend({
init: function (e, t) {
(e = this._hasher = new e.init()),
"string" == typeof t && (t = n.parse(t));
var r = e.blockSize,
i = 4 * r;
t.sigBytes > i && (t = e.finalize(t)), t.clamp();
for (
var o = (this._oKey = t.clone()),
s = (this._iKey = t.clone()),
a = o.words,
c = s.words,
u = 0;
u < r;
u++
)
(a[u] ^= 0x5c5c5c5c), (c[u] ^= 0x36363636);
(o.sigBytes = s.sigBytes = i), this.reset();
},
reset: function () {
var e = this._hasher;
e.reset(), e.update(this._iKey);
},
update: function (e) {
return this._hasher.update(e), this;
},
finalize: function (e) {
var t = this._hasher,
r = t.finalize(e);
return (
t.reset(),
t.finalize(this._oKey.clone().concat(r))
);
},
})));
}
var c = s(function (e, t) {
var r, n, i, o, s, c, u, l, f;
e.exports =
((r = Math),
(i = (n = a.lib).WordArray),
(o = n.Hasher),
(s = a.algo),
(c = []),
(u = []),
(function () {
function e(e) {
return (0x100000000 * (e - (0 | e))) | 0;
}
for (var t = 2, n = 0; n < 64; )
(function (e) {
for (var t = r.sqrt(e), n = 2; n <= t; n++)
if (!(e % n)) return !1;
return !0;
})(t) &&
(n < 8 && (c[n] = e(r.pow(t, 0.5))),
(u[n] = e(r.pow(t, 1 / 3))),
n++),
t++;
})(),
(l = []),
(f = s.SHA256 =
o.extend({
_doReset: function () {
this._hash = new i.init(c.slice(0));
},
_doProcessBlock: function (e, t) {
for (
var r = this._hash.words,
n = r[0],
i = r[1],
o = r[2],
s = r[3],
a = r[4],
c = r[5],
f = r[6],
p = r[7],
h = 0;
h < 64;
h++
) {
if (h < 16) l[h] = 0 | e[t + h];
else {
var d = l[h - 15],
g =
((d << 25) | (d >>> 7)) ^
((d << 14) | (d >>> 18)) ^
(d >>> 3),
y = l[h - 2],
m =
((y << 15) | (y >>> 17)) ^
((y << 13) | (y >>> 19)) ^
(y >>> 10);
l[h] = g + l[h - 7] + m + l[h - 16];
}
var v = (n & i) ^ (n & o) ^ (i & o),
b =
((n << 30) | (n >>> 2)) ^
((n << 19) | (n >>> 13)) ^
((n << 10) | (n >>> 22)),
_ =
p +
(((a << 26) | (a >>> 6)) ^
((a << 21) | (a >>> 11)) ^
((a << 7) | (a >>> 25))) +
((a & c) ^ (~a & f)) +
u[h] +
l[h];
(p = f),
(f = c),
(c = a),
(a = (s + _) | 0),
(s = o),
(o = i),
(i = n),
(n = (_ + (b + v)) | 0);
}
(r[0] = (r[0] + n) | 0),
(r[1] = (r[1] + i) | 0),
(r[2] = (r[2] + o) | 0),
(r[3] = (r[3] + s) | 0),
(r[4] = (r[4] + a) | 0),
(r[5] = (r[5] + c) | 0),
(r[6] = (r[6] + f) | 0),
(r[7] = (r[7] + p) | 0);
},
_doFinalize: function () {
var e = this._data,
t = e.words,
n = 8 * this._nDataBytes,
i = 8 * e.sigBytes;
return (
(t[i >>> 5] |= 128 << (24 - (i % 32))),
(t[14 + (((i + 64) >>> 9) << 4)] = r.floor(
n / 0x100000000
)),
(t[15 + (((i + 64) >>> 9) << 4)] = n),
(e.sigBytes = 4 * t.length),
this._process(),
this._hash
);
},
clone: function () {
var e = o.clone.call(this);
return (e._hash = this._hash.clone()), e;
},
})),
(a.SHA256 = o._createHelper(f)),
(a.HmacSHA256 = o._createHmacHelper(f)),
a.SHA256);
}),
u =
(s()),
l = {
hmac: function (e, t) {
return u(t, e);
},
sha256: function (e) {
return c(e);
},
},
f = [
"authorization",
"content-type",
"content-length",
"user-agent",
"presigned-expires",
"expect",
"x-amzn-trace-id",
],
p = function (e) {
try {
return encodeURIComponent(e)
.replace(/[^A-Za-z0-9_.~\-%]+/g, escape)
.replace(/[*]/g, function (e) {
return "%".concat(
e.charCodeAt(0).toString(16).toUpperCase()
);
});
} catch (e) {
return "";
}
},
h = function (e) {
return Object.keys(e)
.sort()
.map(function (t) {
var r = e[t];
if (null != r) {
var n = p(t);
if (n)
return Array.isArray(r)
? ""
.concat(n, "=")
.concat(
r.map(p).sort().join("&".concat(n, "="))
)
: "".concat(n, "=").concat(p(r));
}
})
.filter(function (e) {
return e;
})
.join("&");
};