@streamlayer/web-os 0.7.4 → 0.8.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/lib/cjs/index.js +4931 -9
- package/lib/cjs/polyfills.js +212 -0
- package/lib/cjs/style.css +1 -1
- package/lib/es/index-ByUNFvMk.js +3775 -0
- package/lib/es/index.js +10 -27884
- package/lib/es/index2.js +25413 -0
- package/lib/es/style.css +1 -0
- package/lib/index.d.ts +0 -1
- package/lib/source.css +1 -0
- package/package.json +38 -29
- package/lib/cjs/index-eShKGO10.js +0 -1
- package/lib/classic/cjs/index-eShKGO10.js +0 -1
- package/lib/classic/cjs/index.js +0 -9
- package/lib/classic/cjs/style.css +0 -1
- package/lib/classic/es/index-eShKGO10.js +0 -3757
- package/lib/classic/es/index.js +0 -27886
- package/lib/classic/index.d.ts +0 -31
- package/lib/classic/style.css +0 -1
- package/lib/es/index-eShKGO10.js +0 -3757
- package/lib/style.css +0 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
require('core-js/stable');
|
|
2
|
+
require('regenerator-runtime/runtime');
|
|
3
|
+
// TextEncoder/TextDecoder pure JS polyfill (Chrome 38)
|
|
4
|
+
// The package only exports classes; must assign globals for SDK compatibility
|
|
5
|
+
var _textEncoding = require('text-encoding-utf-8');
|
|
6
|
+
if (typeof window.TextEncoder === 'undefined') window.TextEncoder = _textEncoding.TextEncoder;
|
|
7
|
+
if (typeof window.TextDecoder === 'undefined') window.TextDecoder = _textEncoding.TextDecoder;
|
|
8
|
+
require('intersection-observer'); // IntersectionObserver polyfill (Chrome 51)
|
|
9
|
+
// Web Crypto SubtleCrypto polyfill (Chrome 37)
|
|
10
|
+
// Chrome 32 has crypto.getRandomValues but no crypto.subtle.
|
|
11
|
+
// webcrypto-liner provides a full SubtleCrypto implementation in pure JS.
|
|
12
|
+
// window.crypto is a read-only accessor on many browsers, so direct assignment
|
|
13
|
+
// silently fails. Instead, define/overwrite the property or patch subtle in-place.
|
|
14
|
+
if (!window.crypto || !window.crypto.subtle) {
|
|
15
|
+
var _liner = require('webcrypto-liner');
|
|
16
|
+
if (window.crypto && !window.crypto.subtle) {
|
|
17
|
+
// Native crypto exists (getRandomValues) but no subtle — patch subtle in
|
|
18
|
+
Object.defineProperty(window.crypto, 'subtle', {
|
|
19
|
+
value: _liner.crypto.subtle,
|
|
20
|
+
writable: true,
|
|
21
|
+
configurable: true
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
// No native crypto at all — replace entirely
|
|
25
|
+
Object.defineProperty(window, 'crypto', {
|
|
26
|
+
value: _liner.crypto,
|
|
27
|
+
writable: true,
|
|
28
|
+
configurable: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
// CryptoKey global (Chrome 37) — used by SDK's JOSE library for instanceof checks
|
|
32
|
+
if (typeof window.CryptoKey === 'undefined') window.CryptoKey = _liner.CryptoKey;
|
|
33
|
+
// webcrypto-liner leaves AES-KW onImportKey/onExportKey/onGenerateKey as
|
|
34
|
+
// "not implemented" stubs (it expects native SubtleCrypto for these).
|
|
35
|
+
// Chrome 32 has no native SubtleCrypto, so patch them from AES-CBC provider
|
|
36
|
+
// which shares the same AesCrypto key import/export/generate logic.
|
|
37
|
+
var _subtle = _liner.crypto.subtle;
|
|
38
|
+
var _aesKw = _subtle.providers && _subtle.providers.get('AES-KW');
|
|
39
|
+
var _aesCbc = _subtle.providers && _subtle.providers.get('AES-CBC');
|
|
40
|
+
if (_aesKw && _aesCbc) {
|
|
41
|
+
_aesKw.onImportKey = _aesCbc.onImportKey;
|
|
42
|
+
_aesKw.onExportKey = _aesCbc.onExportKey;
|
|
43
|
+
_aesKw.onGenerateKey = _aesCbc.onGenerateKey;
|
|
44
|
+
}
|
|
45
|
+
// AES-KW wrap/unwrap (RFC 3394) implementation using AES-ECB from asmcrypto.js.
|
|
46
|
+
// webcrypto-liner stubs onEncrypt/onDecrypt as "not implemented" because it
|
|
47
|
+
// expects a native SubtleCrypto fallback, which Chrome 32 doesn't have.
|
|
48
|
+
var _AES_ECB = require('asmcrypto.js/asmcrypto.all.js').AES_ECB;
|
|
49
|
+
if (_aesKw && _AES_ECB) {
|
|
50
|
+
// RFC 3394 §2.2.1 — Key Wrap
|
|
51
|
+
_aesKw.onEncrypt = function(_algorithm, key, data) {
|
|
52
|
+
return Promise.resolve().then(function() {
|
|
53
|
+
var keyData = new Uint8Array(key.raw);
|
|
54
|
+
var P = new Uint8Array(data);
|
|
55
|
+
var n = P.length / 8; // number of 64-bit blocks
|
|
56
|
+
if (P.length % 8 !== 0) throw new Error('AES-KW: data must be a multiple of 8 bytes');
|
|
57
|
+
// Initial value (IV) per RFC 3394
|
|
58
|
+
var A = new Uint8Array([0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6]);
|
|
59
|
+
// R[1..n] = plaintext blocks
|
|
60
|
+
var R = [];
|
|
61
|
+
for (var i = 0; i < n; i++) {
|
|
62
|
+
R[i] = P.slice(i * 8, i * 8 + 8);
|
|
63
|
+
}
|
|
64
|
+
var ecb = new _AES_ECB(keyData);
|
|
65
|
+
var B = new Uint8Array(16);
|
|
66
|
+
for (var j = 0; j < 6; j++) {
|
|
67
|
+
for (var i = 0; i < n; i++) {
|
|
68
|
+
// B = AES(K, A | R[i])
|
|
69
|
+
B.set(A, 0);
|
|
70
|
+
B.set(R[i], 8);
|
|
71
|
+
var encrypted = ecb.encrypt(B);
|
|
72
|
+
// t = n*j + i + 1 (MSB first XOR into A)
|
|
73
|
+
var t = n * j + i + 1;
|
|
74
|
+
// A = MSB(64, B) ^ t
|
|
75
|
+
A = new Uint8Array(encrypted.slice(0, 8));
|
|
76
|
+
A[7] ^= t & 0xff;
|
|
77
|
+
A[6] ^= (t >> 8) & 0xff;
|
|
78
|
+
A[5] ^= (t >> 16) & 0xff;
|
|
79
|
+
A[4] ^= (t >> 24) & 0xff;
|
|
80
|
+
// R[i] = LSB(64, B)
|
|
81
|
+
R[i] = new Uint8Array(encrypted.slice(8, 16));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Output: A | R[1] | R[2] | ... | R[n]
|
|
85
|
+
var C = new Uint8Array(8 + n * 8);
|
|
86
|
+
C.set(A, 0);
|
|
87
|
+
for (var i = 0; i < n; i++) {
|
|
88
|
+
C.set(R[i], 8 + i * 8);
|
|
89
|
+
}
|
|
90
|
+
return C.buffer;
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
// RFC 3394 §2.2.2 — Key Unwrap
|
|
94
|
+
_aesKw.onDecrypt = function(_algorithm, key, data) {
|
|
95
|
+
return Promise.resolve().then(function() {
|
|
96
|
+
var keyData = new Uint8Array(key.raw);
|
|
97
|
+
var C = new Uint8Array(data);
|
|
98
|
+
var n = C.length / 8 - 1; // number of 64-bit blocks (minus IV)
|
|
99
|
+
if (C.length % 8 !== 0) throw new Error('AES-KW: data must be a multiple of 8 bytes');
|
|
100
|
+
// A = C[0]
|
|
101
|
+
var A = C.slice(0, 8);
|
|
102
|
+
var R = [];
|
|
103
|
+
for (var i = 0; i < n; i++) {
|
|
104
|
+
R[i] = C.slice(8 + i * 8, 16 + i * 8);
|
|
105
|
+
}
|
|
106
|
+
var ecb = new _AES_ECB(keyData);
|
|
107
|
+
var B = new Uint8Array(16);
|
|
108
|
+
for (var j = 5; j >= 0; j--) {
|
|
109
|
+
for (var i = n - 1; i >= 0; i--) {
|
|
110
|
+
var t = n * j + i + 1;
|
|
111
|
+
// A ^ t
|
|
112
|
+
var Ax = new Uint8Array(A);
|
|
113
|
+
Ax[7] ^= t & 0xff;
|
|
114
|
+
Ax[6] ^= (t >> 8) & 0xff;
|
|
115
|
+
Ax[5] ^= (t >> 16) & 0xff;
|
|
116
|
+
Ax[4] ^= (t >> 24) & 0xff;
|
|
117
|
+
// B = AES-1(K, (A ^ t) | R[i])
|
|
118
|
+
B.set(Ax, 0);
|
|
119
|
+
B.set(R[i], 8);
|
|
120
|
+
var decrypted = ecb.decrypt(B);
|
|
121
|
+
A = new Uint8Array(decrypted.slice(0, 8));
|
|
122
|
+
R[i] = new Uint8Array(decrypted.slice(8, 16));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Verify IV
|
|
126
|
+
var IV = [0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6];
|
|
127
|
+
for (var i = 0; i < 8; i++) {
|
|
128
|
+
if (A[i] !== IV[i]) throw new Error('AES-KW: integrity check failed');
|
|
129
|
+
}
|
|
130
|
+
var P = new Uint8Array(n * 8);
|
|
131
|
+
for (var i = 0; i < n; i++) {
|
|
132
|
+
P.set(R[i], i * 8);
|
|
133
|
+
}
|
|
134
|
+
return P.buffer;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// crypto.randomUUID() polyfill (Chrome 92)
|
|
140
|
+
if (typeof window.crypto.randomUUID !== 'function') {
|
|
141
|
+
window.crypto.randomUUID = function() {
|
|
142
|
+
var b = new Uint8Array(16);
|
|
143
|
+
window.crypto.getRandomValues(b);
|
|
144
|
+
b[6] = (b[6] & 0x0f) | 0x40; // version 4
|
|
145
|
+
b[8] = (b[8] & 0x3f) | 0x80; // variant 10
|
|
146
|
+
var h = '';
|
|
147
|
+
for (var i = 0; i < 16; i++) {
|
|
148
|
+
if (i === 4 || i === 6 || i === 8 || i === 10) h += '-';
|
|
149
|
+
h += (b[i] < 16 ? '0' : '') + b[i].toString(16);
|
|
150
|
+
}
|
|
151
|
+
return h;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (typeof window.ResizeObserver === 'undefined') { // ResizeObserver polyfill (Chrome 64)
|
|
155
|
+
var _RO = require('resize-observer-polyfill');
|
|
156
|
+
window.ResizeObserver = _RO.default || _RO;
|
|
157
|
+
}
|
|
158
|
+
var _streams = require('web-streams-polyfill');
|
|
159
|
+
if (typeof window.ReadableStream === 'undefined') window.ReadableStream = _streams.ReadableStream;
|
|
160
|
+
if (typeof window.WritableStream === 'undefined') window.WritableStream = _streams.WritableStream;
|
|
161
|
+
if (typeof window.TransformStream === 'undefined') window.TransformStream = _streams.TransformStream;
|
|
162
|
+
require('whatwg-fetch'); // fetch/Response/Headers/Request polyfill (Chrome 42)
|
|
163
|
+
require('abortcontroller-polyfill/dist/polyfill-patch-fetch'); // AbortController + patched fetch (Chrome 66)
|
|
164
|
+
|
|
165
|
+
// whatwg-fetch does not implement Response.body (ReadableStream).
|
|
166
|
+
// ConnectRPC requires response.body to parse gRPC-Web frames.
|
|
167
|
+
// Wrap fetch to synthesize .body from .arrayBuffer().
|
|
168
|
+
(function() {
|
|
169
|
+
var origFetch = window.fetch;
|
|
170
|
+
window.fetch = function(input, init) {
|
|
171
|
+
return origFetch.apply(this, arguments).then(function(response) {
|
|
172
|
+
if (response.body) return response;
|
|
173
|
+
var _stream = null;
|
|
174
|
+
Object.defineProperty(response, 'body', {
|
|
175
|
+
get: function() {
|
|
176
|
+
if (!_stream) {
|
|
177
|
+
var clone = response.clone();
|
|
178
|
+
_stream = new ReadableStream({
|
|
179
|
+
start: function(controller) {
|
|
180
|
+
clone.arrayBuffer().then(function(buf) {
|
|
181
|
+
controller.enqueue(new Uint8Array(buf));
|
|
182
|
+
controller.close();
|
|
183
|
+
}, function(err) {
|
|
184
|
+
controller.error(err);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return _stream;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
return response;
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
})();
|
|
196
|
+
|
|
197
|
+
// MediaQueryList.addEventListener/removeEventListener polyfill (Chrome 50)
|
|
198
|
+
// Chrome 32 only has the legacy addListener/removeListener API.
|
|
199
|
+
// MediaQueryList is not exposed as a global constructor in Chrome 32,
|
|
200
|
+
// so we obtain the prototype from an actual instance via matchMedia.
|
|
201
|
+
if (typeof window.matchMedia === 'function') {
|
|
202
|
+
var _mql = window.matchMedia('(min-width:0)');
|
|
203
|
+
if (_mql && !_mql.addEventListener) {
|
|
204
|
+
var _mqlProto = Object.getPrototypeOf(_mql);
|
|
205
|
+
_mqlProto.addEventListener = function (type, listener) {
|
|
206
|
+
if (type === 'change') this.addListener(listener);
|
|
207
|
+
};
|
|
208
|
+
_mqlProto.removeEventListener = function (type, listener) {
|
|
209
|
+
if (type === 'change') this.removeListener(listener);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|