krillplayer-plugin 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/cli.js +391 -86
- package/dist/crypto.js +135 -4
- package/kernel/Sources/Kernel/Network/PublicSuffixList.dat +16978 -0
- package/kernel/Sources/Kernel/PluginPrelude.js +1 -0
- package/package.json +2 -2
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-backup-line.json +38 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live-selected-line-gone.json +38 -0
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/cases/play-live.json +13 -1
- package/skill/krillplayer-plugin/assets/samples/live-video-platform/plugin.ts +21 -3
- package/skill/krillplayer-plugin/references/cases.md +2 -2
- package/skill/krillplayer-plugin/references/contract.d.ts +24 -4
package/dist/crypto.js
CHANGED
|
@@ -385,7 +385,8 @@ var PlayableStream = object("PlayableStream", {
|
|
|
385
385
|
});
|
|
386
386
|
var PlayableLine = object("PlayableLine", {
|
|
387
387
|
name: string,
|
|
388
|
-
streams: array(PlayableStream)
|
|
388
|
+
streams: array(PlayableStream),
|
|
389
|
+
qualities: optional(array(string))
|
|
389
390
|
});
|
|
390
391
|
var Playable = object("Playable", {
|
|
391
392
|
timing: enumeration("PlayableTiming", ["live", "onDemand"]),
|
|
@@ -804,6 +805,121 @@ var SLOT_RETURNS = {
|
|
|
804
805
|
resolve: { "": { schema: Resolved, nullable: true } }
|
|
805
806
|
};
|
|
806
807
|
|
|
808
|
+
// host/interop-crypto.ts
|
|
809
|
+
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
810
|
+
function padded(data, littleEndian) {
|
|
811
|
+
const length = (data.length + 8 >> 6) + 1 << 6;
|
|
812
|
+
const block = new Uint8Array(length);
|
|
813
|
+
block.set(data);
|
|
814
|
+
block[data.length] = 128;
|
|
815
|
+
const view = new DataView(block.buffer);
|
|
816
|
+
const bits = data.length * 8;
|
|
817
|
+
const high = Math.floor(bits / 4294967296);
|
|
818
|
+
const low = bits >>> 0;
|
|
819
|
+
if (littleEndian) {
|
|
820
|
+
view.setUint32(length - 8, low, true);
|
|
821
|
+
view.setUint32(length - 4, high, true);
|
|
822
|
+
} else {
|
|
823
|
+
view.setUint32(length - 8, high);
|
|
824
|
+
view.setUint32(length - 4, low);
|
|
825
|
+
}
|
|
826
|
+
return view;
|
|
827
|
+
}
|
|
828
|
+
var MD5_K = Array.from({ length: 64 }, (_, i) => Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296) >>> 0);
|
|
829
|
+
var MD5_S = [7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21];
|
|
830
|
+
function md5(data) {
|
|
831
|
+
const view = padded(data, true);
|
|
832
|
+
let a0 = 1732584193, b0 = 4023233417, c0 = 2562383102, d0 = 271733878;
|
|
833
|
+
const m = new Array(16);
|
|
834
|
+
for (let offset = 0; offset < view.byteLength; offset += 64) {
|
|
835
|
+
for (let i = 0; i < 16; i++) m[i] = view.getUint32(offset + i * 4, true);
|
|
836
|
+
let a = a0, b = b0, c = c0, d = d0;
|
|
837
|
+
for (let i = 0; i < 64; i++) {
|
|
838
|
+
const round = i >> 4;
|
|
839
|
+
let f, g;
|
|
840
|
+
if (round === 0) {
|
|
841
|
+
f = b & c | ~b & d;
|
|
842
|
+
g = i;
|
|
843
|
+
} else if (round === 1) {
|
|
844
|
+
f = d & b | ~d & c;
|
|
845
|
+
g = 5 * i + 1 & 15;
|
|
846
|
+
} else if (round === 2) {
|
|
847
|
+
f = b ^ c ^ d;
|
|
848
|
+
g = 3 * i + 5 & 15;
|
|
849
|
+
} else {
|
|
850
|
+
f = c ^ (b | ~d);
|
|
851
|
+
g = 7 * i & 15;
|
|
852
|
+
}
|
|
853
|
+
const next = d;
|
|
854
|
+
d = c;
|
|
855
|
+
c = b;
|
|
856
|
+
b = b + rotl(a + f + MD5_K[i] + m[g] | 0, MD5_S[round << 2 | i & 3]) | 0;
|
|
857
|
+
a = next;
|
|
858
|
+
}
|
|
859
|
+
a0 = a0 + a | 0;
|
|
860
|
+
b0 = b0 + b | 0;
|
|
861
|
+
c0 = c0 + c | 0;
|
|
862
|
+
d0 = d0 + d | 0;
|
|
863
|
+
}
|
|
864
|
+
const out = new DataView(new ArrayBuffer(16));
|
|
865
|
+
[a0, b0, c0, d0].forEach((word, i) => out.setUint32(i * 4, word >>> 0, true));
|
|
866
|
+
return new Uint8Array(out.buffer);
|
|
867
|
+
}
|
|
868
|
+
var SM3_IV = [1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214];
|
|
869
|
+
var p0 = (x) => x ^ rotl(x, 9) ^ rotl(x, 17);
|
|
870
|
+
var p1 = (x) => x ^ rotl(x, 15) ^ rotl(x, 23);
|
|
871
|
+
function sm3(data) {
|
|
872
|
+
const view = padded(data, false);
|
|
873
|
+
const v = [...SM3_IV];
|
|
874
|
+
const w = new Array(68);
|
|
875
|
+
const w1 = new Array(64);
|
|
876
|
+
for (let offset = 0; offset < view.byteLength; offset += 64) {
|
|
877
|
+
for (let j = 0; j < 16; j++) w[j] = view.getUint32(offset + j * 4) | 0;
|
|
878
|
+
for (let j = 16; j < 68; j++) w[j] = p1(w[j - 16] ^ w[j - 9] ^ rotl(w[j - 3], 15)) ^ rotl(w[j - 13], 7) ^ w[j - 6];
|
|
879
|
+
for (let j = 0; j < 64; j++) w1[j] = w[j] ^ w[j + 4];
|
|
880
|
+
let [a, b, c, d, e, f, g, h] = v;
|
|
881
|
+
for (let j = 0; j < 64; j++) {
|
|
882
|
+
const t = j < 16 ? 2043430169 : 2055708042;
|
|
883
|
+
const ss1 = rotl(rotl(a, 12) + e + rotl(t, j % 32) | 0, 7);
|
|
884
|
+
const ss2 = ss1 ^ rotl(a, 12);
|
|
885
|
+
const ff = j < 16 ? a ^ b ^ c : a & b | a & c | b & c;
|
|
886
|
+
const gg = j < 16 ? e ^ f ^ g : e & f | ~e & g;
|
|
887
|
+
const tt1 = ff + d + ss2 + w1[j] | 0;
|
|
888
|
+
const tt2 = gg + h + ss1 + w[j] | 0;
|
|
889
|
+
d = c;
|
|
890
|
+
c = rotl(b, 9);
|
|
891
|
+
b = a;
|
|
892
|
+
a = tt1;
|
|
893
|
+
h = g;
|
|
894
|
+
g = rotl(f, 19);
|
|
895
|
+
f = e;
|
|
896
|
+
e = p0(tt2);
|
|
897
|
+
}
|
|
898
|
+
[a, b, c, d, e, f, g, h].forEach((word, i) => {
|
|
899
|
+
v[i] ^= word;
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
const out = new DataView(new ArrayBuffer(32));
|
|
903
|
+
v.forEach((word, i) => out.setUint32(i * 4, word >>> 0));
|
|
904
|
+
return new Uint8Array(out.buffer);
|
|
905
|
+
}
|
|
906
|
+
function rc4(key, data) {
|
|
907
|
+
const s = new Uint8Array(256);
|
|
908
|
+
for (let i = 0; i < 256; i++) s[i] = i;
|
|
909
|
+
for (let i = 0, j = 0; i < 256; i++) {
|
|
910
|
+
j = j + s[i] + key[i % key.length] & 255;
|
|
911
|
+
[s[i], s[j]] = [s[j], s[i]];
|
|
912
|
+
}
|
|
913
|
+
const out = new Uint8Array(data.length);
|
|
914
|
+
for (let n = 0, i = 0, j = 0; n < data.length; n++) {
|
|
915
|
+
i = i + 1 & 255;
|
|
916
|
+
j = j + s[i] & 255;
|
|
917
|
+
[s[i], s[j]] = [s[j], s[i]];
|
|
918
|
+
out[n] = data[n] ^ s[s[i] + s[j] & 255];
|
|
919
|
+
}
|
|
920
|
+
return out;
|
|
921
|
+
}
|
|
922
|
+
|
|
807
923
|
// host/json-depth.ts
|
|
808
924
|
function pluginJSONText(bytes2) {
|
|
809
925
|
if (bytes2[0] === 239 && bytes2[1] === 187 && bytes2[2] === 191) return void 0;
|
|
@@ -1592,15 +1708,30 @@ function createSubtle() {
|
|
|
1592
1708
|
};
|
|
1593
1709
|
}
|
|
1594
1710
|
var DIGESTS = /* @__PURE__ */ new Map([["sha-1", "SHA-1"], ["sha-256", "SHA-256"], ["sha-384", "SHA-384"], ["sha-512", "SHA-512"]]);
|
|
1711
|
+
var INTEROP_DIGESTS = /* @__PURE__ */ new Map([["md5", md5], ["sm3", sm3]]);
|
|
1712
|
+
function plainBytes(value) {
|
|
1713
|
+
if (typeof value === "string") return new TextEncoder().encode(value);
|
|
1714
|
+
if (ArrayBuffer.isView(value) && Object.prototype.toString.call(value) === "[object Uint8Array]") return new Uint8Array(value);
|
|
1715
|
+
throw new TypeError("expected a Uint8Array or a string");
|
|
1716
|
+
}
|
|
1595
1717
|
async function plainDigest(algorithm, data) {
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1598
|
-
|
|
1718
|
+
const lowered = String(algorithm).toLowerCase();
|
|
1719
|
+
const interop = INTEROP_DIGESTS.get(lowered);
|
|
1720
|
+
const name = DIGESTS.get(lowered);
|
|
1721
|
+
if (interop === void 0 && name === void 0) throw new TypeError(`unsupported digest ${algorithm}`);
|
|
1722
|
+
const bytes2 = plainBytes(data);
|
|
1723
|
+
return interop !== void 0 ? interop(bytes2) : new Uint8Array(await subtle().digest(name, bytes2));
|
|
1724
|
+
}
|
|
1725
|
+
async function plainRC4(key, data) {
|
|
1726
|
+
const keyBytes = plainBytes(key);
|
|
1727
|
+
if (keyBytes.length < 1 || keyBytes.length > 256) throw new TypeError("krillplayer.crypto.rc4 needs a key of 1 to 256 bytes");
|
|
1728
|
+
return rc4(keyBytes, plainBytes(data));
|
|
1599
1729
|
}
|
|
1600
1730
|
function createCrypto() {
|
|
1601
1731
|
return {
|
|
1602
1732
|
randomBytes: (length) => globalThis.crypto.getRandomValues(new Uint8Array(length)),
|
|
1603
1733
|
digest: plainDigest,
|
|
1734
|
+
rc4: plainRC4,
|
|
1604
1735
|
subtle: createSubtle()
|
|
1605
1736
|
};
|
|
1606
1737
|
}
|