@limrun/ui 0.14.0-rc.2 → 0.14.0-rc.4
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/dist/app-store-relay/index.cjs +3 -3
- package/dist/app-store-relay/index.js +5 -5
- package/dist/app-store-relay/react.cjs +1 -1
- package/dist/app-store-relay/react.d.ts +1 -1
- package/dist/app-store-relay/react.js +34 -31
- package/dist/apple-credentials/index.cjs +1 -0
- package/dist/apple-credentials/index.d.ts +59 -0
- package/dist/apple-credentials/index.js +227 -0
- package/dist/browser-storage-BnO-Ma-e.mjs +219 -0
- package/dist/browser-storage-DLxIqZk5.js +1 -0
- package/dist/client-D1drDXxE.js +1 -0
- package/dist/{client-CBX-hLnL.mjs → client-DSuNtWDv.mjs} +2 -7
- package/dist/core/device-install/operations/operations.d.ts +1 -1
- package/dist/core/device-install/storage/browser-storage.d.ts +8 -0
- package/dist/core/device-install/storage/index.d.ts +1 -0
- package/dist/core/device-install/storage/secret-store.d.ts +101 -0
- package/dist/core/device-install/types.d.ts +6 -0
- package/dist/core/errors.d.ts +1 -0
- package/dist/core/play-publish/google.d.ts +13 -0
- package/dist/core/play-publish/publish.d.ts +34 -0
- package/dist/device-build/index.cjs +1 -1
- package/dist/device-build/index.js +25 -24
- package/dist/device-build/react.cjs +1 -1
- package/dist/device-build/react.js +42 -43
- package/dist/device-install/index.cjs +1 -1
- package/dist/device-install/index.js +164 -160
- package/dist/device-install/react.cjs +1 -1
- package/dist/device-install/react.js +61 -60
- package/dist/errors-BSkqS7U-.js +1 -0
- package/dist/errors-gy8yQJos.mjs +6 -0
- package/dist/gsa-srp-Bme3JLEi.mjs +266 -0
- package/dist/gsa-srp-CCIfUz7Y.js +1 -0
- package/dist/index-ChhtuQ7e.js +22 -0
- package/dist/index-YDu8K9a4.mjs +11279 -0
- package/dist/play-publish/index.cjs +1 -0
- package/dist/play-publish/index.d.ts +2 -0
- package/dist/play-publish/index.js +109 -0
- package/dist/play-publish/react.cjs +1 -0
- package/dist/play-publish/react.d.ts +31 -0
- package/dist/play-publish/react.js +91 -0
- package/dist/{provisioning-DKbkBO-p.mjs → provisioning-B_DefBEp.mjs} +9 -9
- package/dist/{provisioning-Va0PH4Kk.js → provisioning-BlQMccX_.js} +1 -1
- package/package.json +18 -2
- package/src/app-store-relay/index.test.ts +6 -6
- package/src/app-store-relay/react.ts +6 -5
- package/src/apple-credentials/index.test.ts +158 -0
- package/src/apple-credentials/index.ts +241 -0
- package/src/core/device-install/apple/client.ts +1 -6
- package/src/core/device-install/apple/relay.ts +1 -4
- package/src/core/device-install/operations/operations.ts +8 -5
- package/src/core/device-install/storage/browser-storage.test.ts +65 -0
- package/src/core/device-install/storage/browser-storage.ts +33 -0
- package/src/core/device-install/storage/index.ts +1 -0
- package/src/core/device-install/storage/secret-store.ts +298 -0
- package/src/core/device-install/types.ts +6 -0
- package/src/core/errors.ts +3 -0
- package/src/core/play-publish/google.ts +113 -0
- package/src/core/play-publish/publish.test.ts +68 -0
- package/src/core/play-publish/publish.ts +89 -0
- package/src/device-build/react.ts +1 -4
- package/src/device-install/demo/demo.tsx +2 -8
- package/src/device-install/react.ts +31 -31
- package/src/play-publish/README.md +66 -0
- package/src/play-publish/index.ts +12 -0
- package/src/play-publish/react.ts +208 -0
- package/vite.config.ts +3 -0
- package/dist/browser-storage-Cx9eW-bm.mjs +0 -205
- package/dist/browser-storage-jJaIht4K.js +0 -1
- package/dist/client-BtC4n_qf.js +0 -1
- package/dist/index-CMeQfhYy.js +0 -22
- package/dist/index-DFdCvi2_.mjs +0 -11543
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as y } from "../errors-gy8yQJos.mjs";
|
|
2
|
+
import { j as Ue, n as Se, k as ve } from "../browser-storage-BnO-Ma-e.mjs";
|
|
2
3
|
const v = 1, f = 16, s = {
|
|
3
4
|
DeviceHello: 1,
|
|
4
5
|
OpenStream: 2,
|
|
@@ -14,19 +15,19 @@ const v = 1, f = 16, s = {
|
|
|
14
15
|
PairRecordReady: 12
|
|
15
16
|
};
|
|
16
17
|
function V(e) {
|
|
17
|
-
const t = new Uint8Array(f + e.payload.byteLength),
|
|
18
|
-
return
|
|
18
|
+
const t = new Uint8Array(f + e.payload.byteLength), r = new DataView(t.buffer);
|
|
19
|
+
return r.setUint8(0, v), r.setUint8(1, e.type), r.setUint8(2, 0), r.setUint8(3, 0), r.setUint32(4, e.requestId), r.setUint32(8, e.streamId), r.setUint32(12, e.payload.byteLength), t.set(e.payload, f), t;
|
|
19
20
|
}
|
|
20
21
|
function A(e) {
|
|
21
22
|
if (e.byteLength < f)
|
|
22
23
|
throw new Error(`Relay frame too short: ${e.byteLength}`);
|
|
23
|
-
const t = new DataView(e.buffer, e.byteOffset, e.byteLength),
|
|
24
|
-
if (
|
|
25
|
-
throw new Error(`Unsupported relay protocol version ${
|
|
26
|
-
const
|
|
27
|
-
if (e.byteLength !== f +
|
|
24
|
+
const t = new DataView(e.buffer, e.byteOffset, e.byteLength), r = t.getUint8(0);
|
|
25
|
+
if (r !== v)
|
|
26
|
+
throw new Error(`Unsupported relay protocol version ${r}`);
|
|
27
|
+
const n = t.getUint32(12);
|
|
28
|
+
if (e.byteLength !== f + n)
|
|
28
29
|
throw new Error(
|
|
29
|
-
`Relay frame length mismatch: got ${e.byteLength}, expected ${f +
|
|
30
|
+
`Relay frame length mismatch: got ${e.byteLength}, expected ${f + n}`
|
|
30
31
|
);
|
|
31
32
|
return {
|
|
32
33
|
type: t.getUint8(1),
|
|
@@ -47,23 +48,23 @@ async function C() {
|
|
|
47
48
|
return navigator.usb.requestDevice({ filters: [{ vendorId: 1452 }] });
|
|
48
49
|
}
|
|
49
50
|
function L(e) {
|
|
50
|
-
const t = [],
|
|
51
|
-
(a) => a.configurationValue ===
|
|
51
|
+
const t = [], r = e.configuration?.configurationValue, n = e.configurations.find(
|
|
52
|
+
(a) => a.configurationValue === r
|
|
52
53
|
);
|
|
53
|
-
|
|
54
|
+
n && t.push(...U(n));
|
|
54
55
|
for (const a of e.configurations)
|
|
55
|
-
a.configurationValue !==
|
|
56
|
+
a.configurationValue !== r && t.push(...U(a));
|
|
56
57
|
return t;
|
|
57
58
|
}
|
|
58
59
|
function U(e) {
|
|
59
60
|
const t = [];
|
|
60
|
-
for (const
|
|
61
|
-
for (const
|
|
62
|
-
|
|
61
|
+
for (const r of e.interfaces)
|
|
62
|
+
for (const n of r.alternates)
|
|
63
|
+
n.interfaceClass === 255 && n.interfaceSubclass === 254 && n.interfaceProtocol === 2 && t.push({
|
|
63
64
|
configurationValue: e.configurationValue,
|
|
64
|
-
interfaceNumber:
|
|
65
|
-
alternateSetting:
|
|
66
|
-
endpoints:
|
|
65
|
+
interfaceNumber: r.interfaceNumber,
|
|
66
|
+
alternateSetting: n.alternateSetting,
|
|
67
|
+
endpoints: n.endpoints
|
|
67
68
|
});
|
|
68
69
|
return t;
|
|
69
70
|
}
|
|
@@ -72,35 +73,35 @@ async function T(e, t) {
|
|
|
72
73
|
}
|
|
73
74
|
function W(e) {
|
|
74
75
|
const t = e.endpoints.find(
|
|
75
|
-
(
|
|
76
|
-
),
|
|
77
|
-
(
|
|
76
|
+
(n) => n.direction === "out" && n.type === "bulk"
|
|
77
|
+
), r = e.endpoints.find(
|
|
78
|
+
(n) => n.direction === "in" && n.type === "bulk"
|
|
78
79
|
);
|
|
79
|
-
if (!t || !
|
|
80
|
+
if (!t || !r)
|
|
80
81
|
throw new Error("Could not find usbmux bulk endpoints.");
|
|
81
|
-
return { outEndpoint: t, inEndpoint:
|
|
82
|
+
return { outEndpoint: t, inEndpoint: r };
|
|
82
83
|
}
|
|
83
|
-
async function R(e, t,
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
throw new Error(`USB transferOut failed: ${
|
|
87
|
-
|
|
84
|
+
async function R(e, t, r) {
|
|
85
|
+
const n = await e.transferOut(t.endpointNumber, r);
|
|
86
|
+
if (n.status !== "ok")
|
|
87
|
+
throw new Error(`USB transferOut failed: ${n.status}`);
|
|
88
|
+
r.byteLength % t.packetSize === 0 && await e.transferOut(t.endpointNumber, new Uint8Array());
|
|
88
89
|
}
|
|
89
|
-
async function B(e, t,
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
throw new Error(`USB transferIn failed: ${
|
|
93
|
-
return new Uint8Array(
|
|
90
|
+
async function B(e, t, r = 16384) {
|
|
91
|
+
const n = await e.transferIn(t.endpointNumber, r);
|
|
92
|
+
if (n.status !== "ok" || !n.data)
|
|
93
|
+
throw new Error(`USB transferIn failed: ${n.status}`);
|
|
94
|
+
return new Uint8Array(n.data.buffer, n.data.byteOffset, n.data.byteLength);
|
|
94
95
|
}
|
|
95
|
-
const E = 0, F = 2, k = 6, _ = 4277009102,
|
|
96
|
+
const E = 0, F = 2, k = 6, _ = 4277009102, m = 2, M = 4, d = 16, j = 49152;
|
|
96
97
|
async function H(e, t) {
|
|
97
|
-
const { inEndpoint:
|
|
98
|
-
i.setUint32(0, 2), i.setUint32(4, 0), i.setUint32(8, 0), await R(e,
|
|
99
|
-
const o = await P(e,
|
|
98
|
+
const { inEndpoint: r, outEndpoint: n } = W(t), a = new Uint8Array(12), i = new DataView(a.buffer);
|
|
99
|
+
i.setUint32(0, 2), i.setUint32(4, 0), i.setUint32(8, 0), await R(e, n, O(E, a));
|
|
100
|
+
const o = await P(e, r, 1), c = new DataView(o.payload.buffer, o.payload.byteOffset).getUint32(0), u = {
|
|
100
101
|
device: e,
|
|
101
102
|
candidate: t,
|
|
102
|
-
inEndpoint:
|
|
103
|
-
outEndpoint:
|
|
103
|
+
inEndpoint: r,
|
|
104
|
+
outEndpoint: n,
|
|
104
105
|
muxVersion: c,
|
|
105
106
|
txSeq: 0,
|
|
106
107
|
rxSeq: 65535,
|
|
@@ -114,7 +115,7 @@ async function H(e, t) {
|
|
|
114
115
|
async function J(e, t) {
|
|
115
116
|
if (e.closed)
|
|
116
117
|
throw new Error("usbmux session is closed.");
|
|
117
|
-
let
|
|
118
|
+
let r, n;
|
|
118
119
|
const a = {
|
|
119
120
|
session: e,
|
|
120
121
|
sport: e.nextSport++,
|
|
@@ -124,12 +125,12 @@ async function J(e, t) {
|
|
|
124
125
|
queue: [],
|
|
125
126
|
waiters: [],
|
|
126
127
|
opened: new Promise((i, o) => {
|
|
127
|
-
|
|
128
|
+
r = i, n = o;
|
|
128
129
|
}),
|
|
129
|
-
resolveOpened:
|
|
130
|
-
rejectOpened:
|
|
130
|
+
resolveOpened: r,
|
|
131
|
+
rejectOpened: n
|
|
131
132
|
};
|
|
132
|
-
return e.streams.set(
|
|
133
|
+
return e.streams.set(g(t, a.sport), a), await w(a, m, new Uint8Array()), await a.opened, a;
|
|
133
134
|
}
|
|
134
135
|
async function G(e, t) {
|
|
135
136
|
if (e.session.closed)
|
|
@@ -152,17 +153,17 @@ function I(e) {
|
|
|
152
153
|
t.waiters.shift()(new Uint8Array());
|
|
153
154
|
e.streams.clear();
|
|
154
155
|
}
|
|
155
|
-
async function w(e, t,
|
|
156
|
-
const
|
|
157
|
-
a.setUint16(0, e.sport), a.setUint16(2, e.dport), a.setUint32(4, e.seq), a.setUint32(8, e.ack), a.setUint8(12, 80), a.setUint8(13, t), a.setUint16(14, 512),
|
|
156
|
+
async function w(e, t, r) {
|
|
157
|
+
const n = new Uint8Array(20 + r.byteLength), a = new DataView(n.buffer);
|
|
158
|
+
a.setUint16(0, e.sport), a.setUint16(2, e.dport), a.setUint32(4, e.seq), a.setUint32(8, e.ack), a.setUint8(12, 80), a.setUint8(13, t), a.setUint16(14, 512), n.set(r, 20), await x(e.session, k, n);
|
|
158
159
|
}
|
|
159
|
-
async function x(e, t,
|
|
160
|
+
async function x(e, t, r) {
|
|
160
161
|
if (e.closed)
|
|
161
162
|
throw new Error("usbmux session is closed.");
|
|
162
163
|
return e.writeChain = e.writeChain.then(async () => {
|
|
163
164
|
if (e.closed) return;
|
|
164
|
-
const
|
|
165
|
-
await R(e.device, e.outEndpoint,
|
|
165
|
+
const n = e.muxVersion >= 2 ? z(t, r, e.txSeq++, e.rxSeq) : O(t, r);
|
|
166
|
+
await R(e.device, e.outEndpoint, n);
|
|
166
167
|
}), e.writeChain;
|
|
167
168
|
}
|
|
168
169
|
async function Y(e) {
|
|
@@ -173,66 +174,66 @@ async function Y(e) {
|
|
|
173
174
|
if (e.closed) return;
|
|
174
175
|
if (t.rxSeq !== void 0 && (e.rxSeq = t.rxSeq), t.protocol !== k)
|
|
175
176
|
continue;
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
178
|
-
if (
|
|
179
|
-
for (
|
|
180
|
-
|
|
181
|
-
e.streams.delete(
|
|
177
|
+
const r = X(t.payload), n = e.streams.get(g(r.sport, r.dport));
|
|
178
|
+
if (n) {
|
|
179
|
+
if (r.flags & M) {
|
|
180
|
+
for (n.error = new Error(`Device reset stream ${n.dport}`), n.rejectOpened(n.error); n.waiters.length > 0; )
|
|
181
|
+
n.waiters.shift()(new Uint8Array());
|
|
182
|
+
e.streams.delete(g(n.dport, n.sport));
|
|
182
183
|
continue;
|
|
183
184
|
}
|
|
184
|
-
if ((
|
|
185
|
-
|
|
185
|
+
if ((r.flags & (m | d)) === (m | d)) {
|
|
186
|
+
n.seq += 1, n.ack = r.seq + 1, await w(n, d, new Uint8Array()), n.resolveOpened();
|
|
186
187
|
continue;
|
|
187
188
|
}
|
|
188
|
-
|
|
189
|
+
r.payload.byteLength !== 0 && (n.ack = r.seq + r.payload.byteLength, await w(n, d, new Uint8Array()), n.waiters.length > 0 ? n.waiters.shift()(r.payload) : n.queue.push(r.payload));
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
} catch {
|
|
192
193
|
e.closed || I(e);
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
|
-
async function P(e, t,
|
|
196
|
+
async function P(e, t, r) {
|
|
196
197
|
for (; ; ) {
|
|
197
|
-
const
|
|
198
|
-
if (!(
|
|
198
|
+
const n = await B(e, t), a = K(n, r);
|
|
199
|
+
if (!(r === 1 && a.protocol !== E))
|
|
199
200
|
return a;
|
|
200
201
|
}
|
|
201
202
|
}
|
|
202
203
|
function O(e, t) {
|
|
203
|
-
const
|
|
204
|
-
return
|
|
204
|
+
const r = new Uint8Array(8 + t.byteLength), n = new DataView(r.buffer);
|
|
205
|
+
return n.setUint32(0, e), n.setUint32(4, r.byteLength), r.set(t, 8), r;
|
|
205
206
|
}
|
|
206
|
-
function z(e, t,
|
|
207
|
+
function z(e, t, r, n) {
|
|
207
208
|
const a = new Uint8Array(16 + t.byteLength), i = new DataView(a.buffer);
|
|
208
|
-
return i.setUint32(0, e), i.setUint32(4, a.byteLength), i.setUint32(8, _), i.setUint16(12,
|
|
209
|
+
return i.setUint32(0, e), i.setUint32(4, a.byteLength), i.setUint32(8, _), i.setUint16(12, r), i.setUint16(14, n), a.set(t, 16), a;
|
|
209
210
|
}
|
|
210
211
|
function K(e, t) {
|
|
211
|
-
const
|
|
212
|
+
const r = new DataView(e.buffer, e.byteOffset, e.byteLength), n = r.getUint32(0), a = r.getUint32(4), i = t >= 2 ? 16 : 8;
|
|
212
213
|
return {
|
|
213
|
-
protocol:
|
|
214
|
+
protocol: n,
|
|
214
215
|
length: a,
|
|
215
|
-
rxSeq: t >= 2 ?
|
|
216
|
+
rxSeq: t >= 2 ? r.getUint16(14) : void 0,
|
|
216
217
|
payload: e.slice(i, a)
|
|
217
218
|
};
|
|
218
219
|
}
|
|
219
220
|
function X(e) {
|
|
220
|
-
const t = new DataView(e.buffer, e.byteOffset, e.byteLength),
|
|
221
|
+
const t = new DataView(e.buffer, e.byteOffset, e.byteLength), r = (t.getUint8(12) >> 4) * 4;
|
|
221
222
|
return {
|
|
222
223
|
sport: t.getUint16(0),
|
|
223
224
|
dport: t.getUint16(2),
|
|
224
225
|
seq: t.getUint32(4),
|
|
225
226
|
ack: t.getUint32(8),
|
|
226
227
|
flags: t.getUint8(13),
|
|
227
|
-
payload: e.slice(
|
|
228
|
+
payload: e.slice(r)
|
|
228
229
|
};
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
+
function g(e, t) {
|
|
231
232
|
return `${e}:${t}`;
|
|
232
233
|
}
|
|
233
234
|
class Z {
|
|
234
|
-
constructor(t,
|
|
235
|
-
this.webSocketUrl = t, this.session =
|
|
235
|
+
constructor(t, r, n, a) {
|
|
236
|
+
this.webSocketUrl = t, this.session = r, this.deviceHello = n, this.log = a;
|
|
236
237
|
}
|
|
237
238
|
socket;
|
|
238
239
|
streams = /* @__PURE__ */ new Map();
|
|
@@ -245,11 +246,11 @@ class Z {
|
|
|
245
246
|
this.closed = !0, this.log("Relay socket closed"), this.frameQueue.finally(() => {
|
|
246
247
|
this.pairRecordWaiter && (this.pairRecordWaiter.reject(new Error("Relay socket closed")), this.pairRecordWaiter = void 0);
|
|
247
248
|
});
|
|
248
|
-
}, await new Promise((
|
|
249
|
-
t.onopen = () =>
|
|
250
|
-
}), t.onmessage = (
|
|
251
|
-
const
|
|
252
|
-
this.enqueueFrame(
|
|
249
|
+
}, await new Promise((r, n) => {
|
|
250
|
+
t.onopen = () => r(), t.onerror = () => n(new Error("WebSocket connection failed"));
|
|
251
|
+
}), t.onmessage = (r) => {
|
|
252
|
+
const n = r.data instanceof ArrayBuffer ? new Uint8Array(r.data) : new Uint8Array();
|
|
253
|
+
this.enqueueFrame(n);
|
|
253
254
|
}, await this.send({
|
|
254
255
|
type: s.DeviceHello,
|
|
255
256
|
requestId: 0,
|
|
@@ -258,8 +259,8 @@ class Z {
|
|
|
258
259
|
}), this.log("Connected WebSocket relay");
|
|
259
260
|
}
|
|
260
261
|
async startPairing() {
|
|
261
|
-
const t = new Promise((
|
|
262
|
-
this.pairRecordWaiter = { resolve:
|
|
262
|
+
const t = new Promise((r, n) => {
|
|
263
|
+
this.pairRecordWaiter = { resolve: r, reject: n };
|
|
263
264
|
});
|
|
264
265
|
return await this.send({
|
|
265
266
|
type: s.StartPairing,
|
|
@@ -268,20 +269,20 @@ class Z {
|
|
|
268
269
|
payload: l({})
|
|
269
270
|
}), this.log("Pairing requested"), t;
|
|
270
271
|
}
|
|
271
|
-
async startInstall(t,
|
|
272
|
+
async startInstall(t, r) {
|
|
272
273
|
await this.send({
|
|
273
274
|
type: s.StartInstall,
|
|
274
275
|
requestId: 0,
|
|
275
276
|
streamId: 0,
|
|
276
|
-
payload: l({ ...t, ...
|
|
277
|
+
payload: l({ ...t, ...r })
|
|
277
278
|
}), this.log("Installation requested");
|
|
278
279
|
}
|
|
279
280
|
close() {
|
|
280
281
|
this.closed = !0, this.socket?.close();
|
|
281
282
|
}
|
|
282
283
|
enqueueFrame(t) {
|
|
283
|
-
this.frameQueue = this.frameQueue.then(() => this.handleFrame(A(t))).catch((
|
|
284
|
-
this.log("Relay frame handling failed",
|
|
284
|
+
this.frameQueue = this.frameQueue.then(() => this.handleFrame(A(t))).catch((r) => {
|
|
285
|
+
this.log("Relay frame handling failed", r instanceof Error ? r.message : String(r));
|
|
285
286
|
});
|
|
286
287
|
}
|
|
287
288
|
async handleFrame(t) {
|
|
@@ -294,9 +295,9 @@ class Z {
|
|
|
294
295
|
);
|
|
295
296
|
break;
|
|
296
297
|
case s.StreamData: {
|
|
297
|
-
const
|
|
298
|
-
if (!
|
|
299
|
-
await G(
|
|
298
|
+
const r = this.streams.get(t.streamId);
|
|
299
|
+
if (!r) throw new Error(`Unknown stream ${t.streamId}`);
|
|
300
|
+
await G(r, t.payload);
|
|
300
301
|
break;
|
|
301
302
|
}
|
|
302
303
|
case s.StreamClose:
|
|
@@ -322,29 +323,29 @@ class Z {
|
|
|
322
323
|
}
|
|
323
324
|
}
|
|
324
325
|
handleError(t) {
|
|
325
|
-
const
|
|
326
|
-
this.log("Server error",
|
|
326
|
+
const r = ee(t);
|
|
327
|
+
this.log("Server error", r), this.pairRecordWaiter && (this.pairRecordWaiter.reject(new Error(r)), this.pairRecordWaiter = void 0);
|
|
327
328
|
}
|
|
328
329
|
handlePairRecordReady(t) {
|
|
329
330
|
this.log("Pair record received", t.udid), this.pairRecordWaiter?.resolve(t), this.pairRecordWaiter = void 0;
|
|
330
331
|
}
|
|
331
|
-
async handleOpenStream(t,
|
|
332
|
+
async handleOpenStream(t, r, n) {
|
|
332
333
|
try {
|
|
333
|
-
const a = await J(this.session,
|
|
334
|
-
this.streams.set(
|
|
334
|
+
const a = await J(this.session, n);
|
|
335
|
+
this.streams.set(r, a), await this.send({
|
|
335
336
|
type: s.OpenResult,
|
|
336
337
|
requestId: t,
|
|
337
|
-
streamId:
|
|
338
|
+
streamId: r,
|
|
338
339
|
payload: l({ ok: !0 })
|
|
339
|
-
}), this.log(`Opened device stream ${
|
|
340
|
+
}), this.log(`Opened device stream ${r} to port ${n}`), this.pumpDeviceToServer(r, a);
|
|
340
341
|
} catch (a) {
|
|
341
342
|
this.log(
|
|
342
|
-
`Open device stream ${
|
|
343
|
+
`Open device stream ${r} failed`,
|
|
343
344
|
a instanceof Error ? a.message : String(a)
|
|
344
345
|
), await this.send({
|
|
345
346
|
type: s.OpenResult,
|
|
346
347
|
requestId: t,
|
|
347
|
-
streamId:
|
|
348
|
+
streamId: r,
|
|
348
349
|
payload: l({
|
|
349
350
|
ok: !1,
|
|
350
351
|
error: a instanceof Error ? a.message : String(a)
|
|
@@ -352,25 +353,25 @@ class Z {
|
|
|
352
353
|
});
|
|
353
354
|
}
|
|
354
355
|
}
|
|
355
|
-
async pumpDeviceToServer(t,
|
|
356
|
+
async pumpDeviceToServer(t, r) {
|
|
356
357
|
try {
|
|
357
358
|
for (; ; ) {
|
|
358
|
-
const
|
|
359
|
+
const n = await Q(r);
|
|
359
360
|
if (this.closed) return;
|
|
360
361
|
await this.send({
|
|
361
362
|
type: s.StreamData,
|
|
362
363
|
requestId: 0,
|
|
363
364
|
streamId: t,
|
|
364
|
-
payload:
|
|
365
|
+
payload: n
|
|
365
366
|
});
|
|
366
367
|
}
|
|
367
|
-
} catch (
|
|
368
|
-
this.log(`Device stream ${t} closed`,
|
|
368
|
+
} catch (n) {
|
|
369
|
+
this.log(`Device stream ${t} closed`, n instanceof Error ? n.message : String(n)), await this.send({
|
|
369
370
|
type: s.StreamClose,
|
|
370
371
|
requestId: 0,
|
|
371
372
|
streamId: t,
|
|
372
373
|
payload: l({
|
|
373
|
-
reason:
|
|
374
|
+
reason: n instanceof Error ? n.message : String(n)
|
|
374
375
|
})
|
|
375
376
|
});
|
|
376
377
|
}
|
|
@@ -388,8 +389,8 @@ class Z {
|
|
|
388
389
|
function ee(e) {
|
|
389
390
|
const t = new TextDecoder().decode(e);
|
|
390
391
|
try {
|
|
391
|
-
const
|
|
392
|
-
return S(
|
|
392
|
+
const r = JSON.parse(t);
|
|
393
|
+
return S(r.error ?? t);
|
|
393
394
|
} catch {
|
|
394
395
|
return S(t);
|
|
395
396
|
}
|
|
@@ -401,41 +402,47 @@ function te(e) {
|
|
|
401
402
|
const t = "install status: ";
|
|
402
403
|
if (!e.startsWith(t))
|
|
403
404
|
return e;
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
406
|
-
const o = p(
|
|
407
|
-
return `Install error: ${
|
|
405
|
+
const r = e.slice(t.length), n = p(r, "Error");
|
|
406
|
+
if (n) {
|
|
407
|
+
const o = p(r, "ErrorDescription");
|
|
408
|
+
return `Install error: ${n}${o ? ` — ${o}` : ""}`;
|
|
408
409
|
}
|
|
409
|
-
const a = p(
|
|
410
|
+
const a = p(r, "Status") ?? "Unknown", i = p(r, "PercentComplete");
|
|
410
411
|
return `Install progress: ${i ? `${i}% ` : ""}${a}`;
|
|
411
412
|
}
|
|
412
413
|
function p(e, t) {
|
|
413
|
-
const
|
|
414
|
-
`<key>\\s*${
|
|
414
|
+
const n = new RegExp(
|
|
415
|
+
`<key>\\s*${re(
|
|
415
416
|
t
|
|
416
417
|
)}\\s*</key>\\s*<(?:string|integer|real)>([\\s\\S]*?)</(?:string|integer|real)>`
|
|
417
418
|
).exec(e);
|
|
418
|
-
return
|
|
419
|
+
return n ? ne(n[1].trim()) : void 0;
|
|
419
420
|
}
|
|
420
|
-
function
|
|
421
|
+
function re(e) {
|
|
421
422
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
422
423
|
}
|
|
423
|
-
function
|
|
424
|
+
function ne(e) {
|
|
424
425
|
return e.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
425
426
|
}
|
|
426
427
|
async function ae({ log: e }) {
|
|
427
428
|
e("Selecting USB device");
|
|
428
|
-
const t = await C(),
|
|
429
|
+
const t = await C(), r = ue(t);
|
|
429
430
|
return e(
|
|
430
431
|
"Selected USB device",
|
|
431
432
|
`${t.manufacturerName ?? ""} ${t.productName ?? ""} ${t.serialNumber ?? ""}`.trim()
|
|
432
|
-
),
|
|
433
|
+
), r;
|
|
433
434
|
}
|
|
434
|
-
async function ie({
|
|
435
|
-
|
|
435
|
+
async function ie({
|
|
436
|
+
registryApiUrl: e,
|
|
437
|
+
token: t,
|
|
438
|
+
organizationId: r,
|
|
439
|
+
log: n,
|
|
440
|
+
target: a
|
|
441
|
+
}) {
|
|
442
|
+
const i = N(e, t, r);
|
|
436
443
|
let o;
|
|
437
444
|
try {
|
|
438
|
-
o = await $(i, a,
|
|
445
|
+
o = await $(i, a, n);
|
|
439
446
|
const c = await o.startPairing();
|
|
440
447
|
return { relay: o, pairRecord: c, target: a };
|
|
441
448
|
} catch (c) {
|
|
@@ -445,16 +452,16 @@ async function ie({ registryApiUrl: e, token: t, organizationId: n, log: r, targ
|
|
|
445
452
|
async function oe({
|
|
446
453
|
registryApiUrl: e,
|
|
447
454
|
token: t,
|
|
448
|
-
organizationId:
|
|
449
|
-
log:
|
|
455
|
+
organizationId: r,
|
|
456
|
+
log: n,
|
|
450
457
|
target: a,
|
|
451
458
|
pairRecord: i,
|
|
452
459
|
installSource: o
|
|
453
460
|
}) {
|
|
454
|
-
const c = N(e, t,
|
|
461
|
+
const c = N(e, t, r);
|
|
455
462
|
let u;
|
|
456
463
|
try {
|
|
457
|
-
return u = await $(c, a,
|
|
464
|
+
return u = await $(c, a, n), await u.startInstall(i, o), u;
|
|
458
465
|
} catch (D) {
|
|
459
466
|
throw u?.close(), D;
|
|
460
467
|
}
|
|
@@ -464,30 +471,30 @@ async function se(e, t) {
|
|
|
464
471
|
if (e.session && (I(e.session), e.session = void 0), e.claimedInterfaceNumber !== void 0)
|
|
465
472
|
try {
|
|
466
473
|
await e.device.releaseInterface(e.claimedInterfaceNumber), t?.("Released usbmux interface");
|
|
467
|
-
} catch (
|
|
468
|
-
t?.("USB interface release failed",
|
|
474
|
+
} catch (r) {
|
|
475
|
+
t?.("USB interface release failed", y(r));
|
|
469
476
|
} finally {
|
|
470
477
|
e.claimedInterfaceNumber = void 0;
|
|
471
478
|
}
|
|
472
479
|
if (e.device.opened)
|
|
473
480
|
try {
|
|
474
481
|
await e.device.close(), t?.("Closed USB device");
|
|
475
|
-
} catch (
|
|
476
|
-
t?.("USB device close failed",
|
|
482
|
+
} catch (r) {
|
|
483
|
+
t?.("USB device close failed", y(r));
|
|
477
484
|
}
|
|
478
485
|
}
|
|
479
486
|
}
|
|
480
|
-
async function $(e, t,
|
|
481
|
-
await ce(t,
|
|
482
|
-
const
|
|
483
|
-
return await
|
|
487
|
+
async function $(e, t, r) {
|
|
488
|
+
await ce(t, r);
|
|
489
|
+
const n = new Z(e, t.session, t.hello, r);
|
|
490
|
+
return await n.connect(), n;
|
|
484
491
|
}
|
|
485
492
|
async function ce(e, t) {
|
|
486
493
|
if (!e.session)
|
|
487
494
|
try {
|
|
488
495
|
e.candidate = await le(e, t), e.session = await H(e.device, e.candidate), t("Created usbmux session");
|
|
489
|
-
} catch (
|
|
490
|
-
throw await se(e, t),
|
|
496
|
+
} catch (r) {
|
|
497
|
+
throw await se(e, t), r;
|
|
491
498
|
}
|
|
492
499
|
}
|
|
493
500
|
function ue(e) {
|
|
@@ -504,10 +511,10 @@ function ue(e) {
|
|
|
504
511
|
};
|
|
505
512
|
}
|
|
506
513
|
async function le(e, t) {
|
|
507
|
-
const
|
|
508
|
-
if (
|
|
509
|
-
let
|
|
510
|
-
for (const a of
|
|
514
|
+
const r = q(e.device);
|
|
515
|
+
if (r.length === 0) throw new Error("No Apple usbmux interface found.");
|
|
516
|
+
let n;
|
|
517
|
+
for (const a of r)
|
|
511
518
|
for (const i of [1, 2])
|
|
512
519
|
try {
|
|
513
520
|
return e.device.opened || await e.device.open(), t(
|
|
@@ -518,12 +525,12 @@ async function le(e, t) {
|
|
|
518
525
|
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}`
|
|
519
526
|
), a;
|
|
520
527
|
} catch (o) {
|
|
521
|
-
|
|
528
|
+
n = o, t(
|
|
522
529
|
"USB interface claim failed",
|
|
523
|
-
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}: ${
|
|
530
|
+
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}: ${y(o)}`
|
|
524
531
|
), await de(e), await pe(250);
|
|
525
532
|
}
|
|
526
|
-
throw
|
|
533
|
+
throw n instanceof Error ? n : new Error("Unable to claim any Apple usbmux interface.");
|
|
527
534
|
}
|
|
528
535
|
function fe(e) {
|
|
529
536
|
const t = q(e)[0];
|
|
@@ -531,18 +538,15 @@ function fe(e) {
|
|
|
531
538
|
return t;
|
|
532
539
|
}
|
|
533
540
|
function q(e) {
|
|
534
|
-
const t = L(e),
|
|
541
|
+
const t = L(e), r = e.configuration?.configurationValue;
|
|
535
542
|
return [
|
|
536
|
-
...t.filter((
|
|
537
|
-
...t.filter((
|
|
543
|
+
...t.filter((n) => n.configurationValue === r),
|
|
544
|
+
...t.filter((n) => n.configurationValue !== r)
|
|
538
545
|
];
|
|
539
546
|
}
|
|
540
|
-
function N(e, t,
|
|
541
|
-
const
|
|
542
|
-
return
|
|
543
|
-
}
|
|
544
|
-
function g(e) {
|
|
545
|
-
return e instanceof Error ? e.message : String(e);
|
|
547
|
+
function N(e, t, r) {
|
|
548
|
+
const n = new URL(e);
|
|
549
|
+
return n.protocol = n.protocol === "https:" ? "wss:" : "ws:", n.pathname = `${n.pathname.replace(/\/$/, "")}/ios/device/ws`, t && n.searchParams.set("token", t), r && n.searchParams.set("organization", r), n.toString();
|
|
546
550
|
}
|
|
547
551
|
async function de(e) {
|
|
548
552
|
if (e.claimedInterfaceNumber !== void 0) {
|
|
@@ -561,13 +565,13 @@ async function de(e) {
|
|
|
561
565
|
function pe(e) {
|
|
562
566
|
return new Promise((t) => setTimeout(t, e));
|
|
563
567
|
}
|
|
564
|
-
async function
|
|
568
|
+
async function he(e = {}) {
|
|
565
569
|
return ae({ log: e.log ?? b });
|
|
566
570
|
}
|
|
567
|
-
async function
|
|
571
|
+
async function ye(e) {
|
|
568
572
|
return ie({ ...e, log: e.log ?? b });
|
|
569
573
|
}
|
|
570
|
-
async function
|
|
574
|
+
async function me(e) {
|
|
571
575
|
return oe({ ...e, log: e.log ?? b });
|
|
572
576
|
}
|
|
573
577
|
function b() {
|
|
@@ -576,12 +580,12 @@ export {
|
|
|
576
580
|
Z as RelayClient,
|
|
577
581
|
se as closeDeviceRelayTarget,
|
|
578
582
|
N as deviceRelayWebSocketUrl,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
583
|
+
Ue as getPairRecord,
|
|
584
|
+
Se as normalizeUDID,
|
|
585
|
+
ye as pairDevice,
|
|
586
|
+
ve as putPairRecord,
|
|
587
|
+
he as requestUSBAccess,
|
|
588
|
+
me as startDeviceInstall,
|
|
585
589
|
oe as startDeviceInstallRelay,
|
|
586
590
|
ie as startDevicePairingRelay
|
|
587
591
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),i=require("./index.cjs"),w=require("../errors-BSkqS7U-.js"),D=require("../browser-storage-DLxIqZk5.js");function C({apiUrl:o,token:d,organizationId:v,log:h=T}){const[e,b]=r.useState(),[l,g]=r.useState(),[R,u]=r.useState(),[S,n]=r.useState(),[P,f]=r.useState(!1),y=r.useRef(void 0),p=r.useRef(void 0),t=r.useRef(h);t.current=h;const c=r.useCallback(async()=>{y.current?.close(),y.current=void 0,await i.closeDeviceRelayTarget(p.current,t.current)},[]);r.useEffect(()=>{p.current=e},[e]),r.useEffect(()=>()=>{c()},[c]);const q=r.useCallback(async()=>{u("usb"),n(void 0),f(!1);let a;try{await c(),a=await i.requestUSBAccess({log:t.current});const s=await D.getPairRecord(a.hello.serialNumber);return b(a),g(s),t.current(s?"Pair record found":"No pair record found",a.hello.serialNumber),a}catch(s){await i.closeDeviceRelayTarget(a,t.current),b(void 0),g(void 0),n(w.errorMessage(s));return}finally{u(void 0)}},[c]),m=r.useCallback(async()=>{if(!o||!e)throw new Error("Select a USB device before pairing.");u("pair"),n(void 0),f(!1);try{await c();const a=await i.pairDevice({registryApiUrl:o,token:d,organizationId:v,log:t.current,target:e}),s=await D.putPairRecord(a.pairRecord,{productName:e.hello.productName});return a.relay.close(),await i.closeDeviceRelayTarget(e,t.current),g(s),f(!1),t.current("Device paired","The pair record was stored locally in this browser."),s}catch(a){await i.closeDeviceRelayTarget(e,t.current),f(!0),n(w.errorMessage(a));return}finally{u(void 0)}},[o,c,e,v,d]),A=r.useCallback(async a=>{if(!o||!e||!l)throw new Error("Select and pair a USB device before starting installation.");u("install"),n(void 0);try{return await c(),y.current=await i.startDeviceInstall({registryApiUrl:o,token:d,organizationId:v,log:t.current,target:e,pairRecord:l,installSource:a}),t.current("Device install started","Installation will continue through the connected iPhone."),y.current}catch(s){await i.closeDeviceRelayTarget(e,t.current),n(w.errorMessage(s));return}finally{u(void 0)}},[o,c,e,v,l,d]),B=r.useCallback(()=>{c(),t.current("Device relay stopped")},[c]);return{device:e,pairRecord:l,busyAction:R,error:S,pairConfirmationRequired:P,hasPairRecord:!!l,canPair:!!o&&!R&&!!e,canInstall:!!o&&!R&&!!e&&!!l,requestUSBAccess:q,pairBrowser:m,startInstallation:A,stopRelay:B,clearError:()=>n(void 0)}}function T(){}exports.useDeviceInstallRelay=C;
|