@limrun/ui 0.14.0-rc.3 → 0.14.0-rc.5

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.
Files changed (76) hide show
  1. package/dist/app-store-relay/index.cjs +3 -3
  2. package/dist/app-store-relay/index.d.ts +108 -4
  3. package/dist/app-store-relay/index.js +353 -160
  4. package/dist/app-store-relay/react.cjs +1 -1
  5. package/dist/app-store-relay/react.js +32 -33
  6. package/dist/apple-credentials/index.cjs +1 -0
  7. package/dist/apple-credentials/index.d.ts +110 -0
  8. package/dist/apple-credentials/index.js +291 -0
  9. package/dist/browser-storage-BnO-Ma-e.mjs +219 -0
  10. package/dist/browser-storage-DLxIqZk5.js +1 -0
  11. package/dist/client-C9z_sgOf.js +1 -0
  12. package/dist/{client-C8ZDEjtD.mjs → client-CFDB4mX5.mjs} +38 -31
  13. package/dist/components/remote-control.d.ts +156 -0
  14. package/dist/core/device-install/apple/provisioning.d.ts +25 -0
  15. package/dist/core/device-install/apple/relay.d.ts +13 -0
  16. package/dist/core/device-install/storage/browser-storage.d.ts +8 -0
  17. package/dist/core/device-install/storage/index.d.ts +1 -0
  18. package/dist/core/device-install/storage/secret-store.d.ts +124 -0
  19. package/dist/core/device-install/types.d.ts +6 -0
  20. package/dist/core/errors.d.ts +1 -0
  21. package/dist/core/play-publish/google.d.ts +1 -1
  22. package/dist/device-build/index.cjs +1 -1
  23. package/dist/device-build/index.js +21 -20
  24. package/dist/device-build/react.cjs +1 -1
  25. package/dist/device-build/react.js +42 -43
  26. package/dist/device-install/index.cjs +1 -1
  27. package/dist/device-install/index.js +64 -63
  28. package/dist/device-install/react.cjs +1 -1
  29. package/dist/device-install/react.js +47 -49
  30. package/dist/errors-BSkqS7U-.js +1 -0
  31. package/dist/errors-gy8yQJos.mjs +6 -0
  32. package/dist/gsa-srp-Bme3JLEi.mjs +266 -0
  33. package/dist/gsa-srp-CCIfUz7Y.js +1 -0
  34. package/dist/index-ChhtuQ7e.js +22 -0
  35. package/dist/index-YDu8K9a4.mjs +11279 -0
  36. package/dist/index.cjs +1 -1
  37. package/dist/index.css +1 -1
  38. package/dist/index.js +1405 -1125
  39. package/dist/play-publish/index.cjs +1 -1
  40. package/dist/play-publish/index.js +27 -24
  41. package/dist/play-publish/react.cjs +1 -1
  42. package/dist/play-publish/react.d.ts +12 -2
  43. package/dist/play-publish/react.js +70 -60
  44. package/dist/{provisioning-BmsEnF6X.mjs → provisioning-CDPvxd1h.mjs} +64 -33
  45. package/dist/provisioning-CbC4h--7.js +1 -0
  46. package/package.json +6 -1
  47. package/src/app-store-relay/index.ts +358 -23
  48. package/src/app-store-relay/react.ts +1 -4
  49. package/src/apple-credentials/index.test.ts +180 -0
  50. package/src/apple-credentials/index.ts +388 -0
  51. package/src/components/remote-control.css +32 -0
  52. package/src/components/remote-control.tsx +865 -5
  53. package/src/core/device-install/apple/client.ts +13 -6
  54. package/src/core/device-install/apple/provisioning.test.ts +30 -0
  55. package/src/core/device-install/apple/provisioning.ts +39 -0
  56. package/src/core/device-install/apple/relay.ts +20 -0
  57. package/src/core/device-install/operations/operations.ts +7 -5
  58. package/src/core/device-install/storage/browser-storage.test.ts +65 -0
  59. package/src/core/device-install/storage/browser-storage.ts +33 -0
  60. package/src/core/device-install/storage/index.ts +1 -0
  61. package/src/core/device-install/storage/secret-store.ts +332 -0
  62. package/src/core/device-install/types.ts +6 -0
  63. package/src/core/errors.ts +3 -0
  64. package/src/core/play-publish/google.ts +11 -2
  65. package/src/device-build/react.ts +1 -4
  66. package/src/device-install/demo/demo.tsx +1 -4
  67. package/src/device-install/react.ts +1 -4
  68. package/src/play-publish/README.md +5 -4
  69. package/src/play-publish/react.ts +72 -32
  70. package/vite.config.ts +1 -0
  71. package/dist/browser-storage-Cx9eW-bm.mjs +0 -205
  72. package/dist/browser-storage-jJaIht4K.js +0 -1
  73. package/dist/client-BtC4n_qf.js +0 -1
  74. package/dist/index-CMeQfhYy.js +0 -22
  75. package/dist/index-DFdCvi2_.mjs +0 -11543
  76. package/dist/provisioning-Va0PH4Kk.js +0 -1
@@ -0,0 +1,219 @@
1
+ import { f as D } from "./index-YDu8K9a4.mjs";
2
+ const P = "limbuild-device-pairing", x = 1, d = "pairRecords", y = "limbuild-device-signing", A = 1, c = "signingAssets";
3
+ function l(e) {
4
+ return (e ?? "").replace(/-/g, "").replace(/[^a-fA-F0-9]/g, "");
5
+ }
6
+ function f(e) {
7
+ return (e ?? "").trim();
8
+ }
9
+ async function j(e) {
10
+ const t = l(e);
11
+ if (!t) return;
12
+ const r = await p(P, x, d, "udid");
13
+ return g(
14
+ r.transaction(d, "readonly").objectStore(d).get(t)
15
+ );
16
+ }
17
+ async function G(e, t = {}) {
18
+ const r = l(e.udid);
19
+ if (!r) throw new Error("Cannot store pair record without a UDID.");
20
+ const n = {
21
+ ...e,
22
+ udid: r,
23
+ productName: t.productName,
24
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
25
+ }, i = await p(P, x, d, "udid");
26
+ return await g(
27
+ i.transaction(d, "readwrite").objectStore(d).put(n)
28
+ ), n;
29
+ }
30
+ async function M({
31
+ deviceUDID: e,
32
+ bundleID: t,
33
+ signingMode: r = "development"
34
+ }) {
35
+ const n = f(t);
36
+ if (!n) return;
37
+ const i = l(e), o = await h(I("bundle", n, r));
38
+ if (o) return o;
39
+ if (i) {
40
+ const s = await h(I(i, n, r));
41
+ if (s) return s;
42
+ }
43
+ return (await T(n, r))[0];
44
+ }
45
+ async function k(e = "development") {
46
+ return (await b()).filter((r) => (r.signingMode ?? "development") === e).sort((r, n) => new Date(n.updatedAt).getTime() - new Date(r.updatedAt).getTime())[0];
47
+ }
48
+ async function V(e, t = "development") {
49
+ return (await b()).filter((n) => !n.certificateID || !n.certificateP12Base64 || (n.signingMode ?? "development") !== t ? !1 : !e || !n.teamID || n.teamID === e).sort((n, i) => new Date(i.updatedAt).getTime() - new Date(n.updatedAt).getTime())[0];
50
+ }
51
+ async function F(e) {
52
+ const t = f(e.bundleID);
53
+ if (!t)
54
+ throw new Error("Cannot store signing assets without a bundle ID.");
55
+ const r = l(e.deviceUDID), n = e.signingMode ?? "development", i = I("bundle", t, n), o = {
56
+ ...e,
57
+ id: i,
58
+ deviceUDID: r || void 0,
59
+ signingMode: n,
60
+ bundleID: t,
61
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
62
+ }, a = await p(y, A, c, "id");
63
+ return await g(
64
+ a.transaction(c, "readwrite").objectStore(c).put(o)
65
+ ), o;
66
+ }
67
+ async function T(e, t = "development") {
68
+ const r = f(e);
69
+ return r ? (await b()).filter(
70
+ (i) => i.bundleID === r && (i.signingMode ?? "development") === t
71
+ ) : [];
72
+ }
73
+ function W(e, t) {
74
+ const r = l(t);
75
+ return !!r && e.provisionedDevices.some((n) => l(n) === r);
76
+ }
77
+ function $(e, t) {
78
+ const r = f(t), n = f(e.bundleID);
79
+ if (!r || !n) return !1;
80
+ if (n === r || n === "*") return !0;
81
+ if (!n.endsWith(".*")) return !1;
82
+ const i = n.slice(0, -1);
83
+ return r.startsWith(i);
84
+ }
85
+ async function q(e) {
86
+ return E(new Uint8Array(await e.arrayBuffer()));
87
+ }
88
+ function L(e) {
89
+ const t = atob(e), r = new Uint8Array(t.length);
90
+ for (let n = 0; n < t.length; n += 1)
91
+ r[n] = t.charCodeAt(n);
92
+ return E(r);
93
+ }
94
+ function E(e) {
95
+ const t = new TextDecoder("latin1").decode(e), r = t.indexOf("<?xml"), n = t.indexOf("</plist>");
96
+ if (r < 0 || n < r)
97
+ throw new Error("Provisioning profile plist not found.");
98
+ const i = t.slice(r, n + 8);
99
+ if (/<!ENTITY/i.test(i))
100
+ throw new Error("Provisioning profile plist contains a disallowed ENTITY declaration.");
101
+ const o = new DOMParser().parseFromString(i, "application/xml");
102
+ if (o.querySelector("parsererror"))
103
+ throw new Error("Provisioning profile plist could not be parsed.");
104
+ const a = o.querySelector("plist > dict");
105
+ if (!a)
106
+ throw new Error("Provisioning profile plist dictionary not found.");
107
+ const s = v(a);
108
+ if (!N(s))
109
+ throw new Error("Provisioning profile plist has an unexpected shape.");
110
+ const m = N(s.Entitlements) ? s.Entitlements : {}, S = u(m["application-identifier"]), B = _(S);
111
+ return {
112
+ name: u(s.Name),
113
+ uuid: u(s.UUID),
114
+ teamID: u(m["com.apple.developer.team-identifier"]) ?? w(s.TeamIdentifier)[0],
115
+ applicationIdentifier: S,
116
+ bundleID: B,
117
+ provisionedDevices: w(s.ProvisionedDevices),
118
+ certificateSerialNumbers: O(w(s.DeveloperCertificates)),
119
+ getTaskAllow: R(m["get-task-allow"]),
120
+ expirationDate: u(s.ExpirationDate)
121
+ };
122
+ }
123
+ function z(e) {
124
+ return (e ?? "").replace(/^0+/, "").toUpperCase() || void 0;
125
+ }
126
+ function O(e) {
127
+ const t = [];
128
+ for (const r of e)
129
+ try {
130
+ const n = atob(r.replace(/\s+/g, "")), i = D.pki.certificateFromAsn1(D.asn1.fromDer(D.util.createBuffer(n))), o = z(i.serialNumber);
131
+ o && !t.includes(o) && t.push(o);
132
+ } catch {
133
+ }
134
+ return t;
135
+ }
136
+ async function h(e) {
137
+ if (!e) return;
138
+ const t = await p(y, A, c, "id");
139
+ return g(
140
+ t.transaction(c, "readonly").objectStore(c).get(e)
141
+ );
142
+ }
143
+ async function b() {
144
+ const e = await p(y, A, c, "id");
145
+ return g(
146
+ e.transaction(c, "readonly").objectStore(c).getAll()
147
+ );
148
+ }
149
+ function I(e, t, r) {
150
+ return `${r}:${e}:${t}`;
151
+ }
152
+ function _(e) {
153
+ if (!e) return;
154
+ const t = e.indexOf(".");
155
+ return t >= 0 ? e.slice(t + 1) : void 0;
156
+ }
157
+ function v(e) {
158
+ switch (e.tagName) {
159
+ case "dict":
160
+ return C(e);
161
+ case "array":
162
+ return Array.from(e.children).map(v);
163
+ case "string":
164
+ case "date":
165
+ return e.textContent ?? "";
166
+ default:
167
+ return e.textContent ?? "";
168
+ }
169
+ }
170
+ function C(e) {
171
+ const t = {}, r = Array.from(e.children);
172
+ for (let n = 0; n < r.length; n += 2) {
173
+ const i = r[n], o = r[n + 1];
174
+ !i || i.tagName !== "key" || !o || (t[i.textContent ?? ""] = v(o));
175
+ }
176
+ return t;
177
+ }
178
+ function u(e) {
179
+ return typeof e == "string" && e ? e : void 0;
180
+ }
181
+ function w(e) {
182
+ return Array.isArray(e) ? e.filter((t) => typeof t == "string") : [];
183
+ }
184
+ function R(e) {
185
+ return typeof e == "boolean" ? e : void 0;
186
+ }
187
+ function N(e) {
188
+ return typeof e == "object" && e !== null && !Array.isArray(e);
189
+ }
190
+ function p(e, t, r, n) {
191
+ return new Promise((i, o) => {
192
+ const a = indexedDB.open(e, t);
193
+ a.onupgradeneeded = () => {
194
+ const s = a.result;
195
+ s.objectStoreNames.contains(r) || s.createObjectStore(r, { keyPath: n });
196
+ }, a.onsuccess = () => i(a.result), a.onerror = () => o(a.error ?? new Error("Open IndexedDB failed"));
197
+ });
198
+ }
199
+ function g(e) {
200
+ return new Promise((t, r) => {
201
+ e.onsuccess = () => t(e.result), e.onerror = () => r(e.error ?? new Error("IndexedDB request failed"));
202
+ });
203
+ }
204
+ export {
205
+ F as a,
206
+ $ as b,
207
+ W as c,
208
+ V as d,
209
+ M as e,
210
+ L as f,
211
+ k as g,
212
+ E as h,
213
+ f as i,
214
+ j,
215
+ G as k,
216
+ z as l,
217
+ l as n,
218
+ q as p
219
+ };
@@ -0,0 +1 @@
1
+ "use strict";const m=require("./index-ChhtuQ7e.js"),B="limbuild-device-pairing",x=1,l="pairRecords",A="limbuild-device-signing",y=1,c="signingAssets";function d(e){return(e??"").replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"")}function u(e){return(e??"").trim()}async function C(e){const t=d(e);if(!t)return;const r=await g(B,x,l,"udid");return p(r.transaction(l,"readonly").objectStore(l).get(t))}async function T(e,t={}){const r=d(e.udid);if(!r)throw new Error("Cannot store pair record without a UDID.");const n={...e,udid:r,productName:t.productName,updatedAt:new Date().toISOString()},i=await g(B,x,l,"udid");return await p(i.transaction(l,"readwrite").objectStore(l).put(n)),n}async function R({deviceUDID:e,bundleID:t,signingMode:r="development"}){const n=u(t);if(!n)return;const i=d(e),o=await h(I("bundle",n,r));if(o)return o;if(i){const s=await h(I(i,n,r));if(s)return s}return(await M(n,r))[0]}async function O(e="development"){return(await S()).filter(r=>(r.signingMode??"development")===e).sort((r,n)=>new Date(n.updatedAt).getTime()-new Date(r.updatedAt).getTime())[0]}async function U(e,t="development"){return(await S()).filter(n=>!n.certificateID||!n.certificateP12Base64||(n.signingMode??"development")!==t?!1:!e||!n.teamID||n.teamID===e).sort((n,i)=>new Date(i.updatedAt).getTime()-new Date(n.updatedAt).getTime())[0]}async function _(e){const t=u(e.bundleID);if(!t)throw new Error("Cannot store signing assets without a bundle ID.");const r=d(e.deviceUDID),n=e.signingMode??"development",i=I("bundle",t,n),o={...e,id:i,deviceUDID:r||void 0,signingMode:n,bundleID:t,updatedAt:new Date().toISOString()},a=await g(A,y,c,"id");return await p(a.transaction(c,"readwrite").objectStore(c).put(o)),o}async function M(e,t="development"){const r=u(e);return r?(await S()).filter(i=>i.bundleID===r&&(i.signingMode??"development")===t):[]}function G(e,t){const r=d(t);return!!r&&e.provisionedDevices.some(n=>d(n)===r)}function j(e,t){const r=u(t),n=u(e.bundleID);if(!r||!n)return!1;if(n===r||n==="*")return!0;if(!n.endsWith(".*"))return!1;const i=n.slice(0,-1);return r.startsWith(i)}async function V(e){return v(new Uint8Array(await e.arrayBuffer()))}function k(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n+=1)r[n]=t.charCodeAt(n);return v(r)}function v(e){const t=new TextDecoder("latin1").decode(e),r=t.indexOf("<?xml"),n=t.indexOf("</plist>");if(r<0||n<r)throw new Error("Provisioning profile plist not found.");const i=t.slice(r,n+8);if(/<!ENTITY/i.test(i))throw new Error("Provisioning profile plist contains a disallowed ENTITY declaration.");const o=new DOMParser().parseFromString(i,"application/xml");if(o.querySelector("parsererror"))throw new Error("Provisioning profile plist could not be parsed.");const a=o.querySelector("plist > dict");if(!a)throw new Error("Provisioning profile plist dictionary not found.");const s=b(a);if(!N(s))throw new Error("Provisioning profile plist has an unexpected shape.");const D=N(s.Entitlements)?s.Entitlements:{},P=f(D["application-identifier"]),z=L(P);return{name:f(s.Name),uuid:f(s.UUID),teamID:f(D["com.apple.developer.team-identifier"])??w(s.TeamIdentifier)[0],applicationIdentifier:P,bundleID:z,provisionedDevices:w(s.ProvisionedDevices),certificateSerialNumbers:F(w(s.DeveloperCertificates)),getTaskAllow:q(D["get-task-allow"]),expirationDate:f(s.ExpirationDate)}}function E(e){return(e??"").replace(/^0+/,"").toUpperCase()||void 0}function F(e){const t=[];for(const r of e)try{const n=atob(r.replace(/\s+/g,"")),i=m.forge.pki.certificateFromAsn1(m.forge.asn1.fromDer(m.forge.util.createBuffer(n))),o=E(i.serialNumber);o&&!t.includes(o)&&t.push(o)}catch{}return t}async function h(e){if(!e)return;const t=await g(A,y,c,"id");return p(t.transaction(c,"readonly").objectStore(c).get(e))}async function S(){const e=await g(A,y,c,"id");return p(e.transaction(c,"readonly").objectStore(c).getAll())}function I(e,t,r){return`${r}:${e}:${t}`}function L(e){if(!e)return;const t=e.indexOf(".");return t>=0?e.slice(t+1):void 0}function b(e){switch(e.tagName){case"dict":return W(e);case"array":return Array.from(e.children).map(b);case"string":case"date":return e.textContent??"";default:return e.textContent??""}}function W(e){const t={},r=Array.from(e.children);for(let n=0;n<r.length;n+=2){const i=r[n],o=r[n+1];!i||i.tagName!=="key"||!o||(t[i.textContent??""]=b(o))}return t}function f(e){return typeof e=="string"&&e?e:void 0}function w(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function q(e){return typeof e=="boolean"?e:void 0}function N(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function g(e,t,r,n){return new Promise((i,o)=>{const a=indexedDB.open(e,t);a.onupgradeneeded=()=>{const s=a.result;s.objectStoreNames.contains(r)||s.createObjectStore(r,{keyPath:n})},a.onsuccess=()=>i(a.result),a.onerror=()=>o(a.error??new Error("Open IndexedDB failed"))})}function p(e){return new Promise((t,r)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>r(e.error??new Error("IndexedDB request failed"))})}exports.getLatestSigningAssets=O;exports.getLatestSigningAssetsWithCertificate=U;exports.getPairRecord=C;exports.getSigningAssets=R;exports.normalizeBundleID=u;exports.normalizeCertificateSerial=E;exports.normalizeUDID=d;exports.parseProvisioningProfile=V;exports.parseProvisioningProfileBase64=k;exports.parseProvisioningProfileBytes=v;exports.profileContainsDevice=G;exports.profileMatchesBundleID=j;exports.putPairRecord=T;exports.putSigningAssets=_;
@@ -0,0 +1 @@
1
+ "use strict";const R=require("./gsa-srp-CCIfUz7Y.js");class g{constructor(t,r,o){this.apiUrl=t,this.token=r,this.organizationId=o}socket;nextId=1;pending=new Map;async connect(){if(this.socket&&this.socket.readyState===WebSocket.OPEN)return;const t=new WebSocket(E(this.apiUrl,this.token,this.organizationId));this.socket=t,t.onmessage=r=>this.handleMessage(r),t.onclose=()=>this.rejectPending(new Error("Apple relay WebSocket closed")),t.onerror=()=>this.rejectPending(new Error("Apple relay WebSocket failed")),await new Promise((r,o)=>{t.onopen=()=>r(),t.onerror=()=>o(new Error("Apple relay WebSocket connection failed"))})}request(t,r){const o=this.socket;if(!o||o.readyState!==WebSocket.OPEN)throw new Error("Apple relay WebSocket is not connected.");const a=String(this.nextId++),n=new Promise((p,i)=>{this.pending.set(a,{resolve:w=>p(x(w)),reject:i})});return o.send(JSON.stringify({id:a,type:t,...r===void 0?{}:{payload:r}})),n}close(){this.rejectPending(new Error("Apple relay WebSocket closed")),this.socket?.close(),this.socket=void 0}handleMessage(t){const r=JSON.parse(String(t.data)),o=this.pending.get(r.id);if(o){if(this.pending.delete(r.id),!r.ok){o.reject(new Error(r.error||"Apple relay request failed"));return}if(!r.response){o.reject(new Error("Apple relay response was empty."));return}o.resolve(r.response)}}rejectPending(t){for(const r of this.pending.values())r.reject(t);this.pending.clear()}}async function m(e,t,r){const o=new g(e,t,r);return await o.connect(),o}async function S(e,t){return e.request("srpInit",t)}async function A(e,t){return e.request("srpComplete",t)}async function P(e){return e.request("triggerTrustedDevice2FA")}async function b(e,t,r="sms"){return e.request("triggerPhone2FA",{phoneNumberId:t,mode:r})}async function k(e,t){return e.request("submitTrustedDevice2FA",{code:t})}async function T(e,t,r,o="sms"){return e.request("submitPhone2FA",{phoneNumberId:t,mode:o,code:r})}async function v(e){return e.request("finalize")}async function q(e,t){return e.request("provisioning",t)}async function F(e,t){return e.request("appstoreconnect",t)}function x(e){if(e.body!==void 0||!e.rawBody)return e;try{return{...e,body:JSON.parse(e.rawBody)}}catch{return e}}function E(e,t,r){const o=new URL(e);return o.protocol=o.protocol==="https:"?"wss:":"ws:",o.pathname=`${o.pathname.replace(/\/$/,"")}/ios/appstoreconnect/ws`,t&&o.searchParams.set("token",t),r&&o.searchParams.set("organization",r),o.toString()}async function N({registryApiUrl:e,accountName:t,password:r,token:o,organizationId:a}){const n=await m(e,o,a);try{const p=new R.AppleGsaSrpClient(t),i=await S(n,await p.init());if(i.status<200||i.status>=300)throw new Error(`Apple SRP init failed: HTTP ${i.status} ${i.rawBody??""}`.trim());if(!i.body)throw new Error("Apple SRP init response did not include a body.");const w=await p.complete(r,i.body),u=await A(n,{...w,rememberMe:!1,trustTokens:[]}),y=u.status===409;let s,d={type:"trustedDevice"};if(y){s=await P(n);const c=W(s.body);if(s.status===412||C(s.body)){if(!c)throw new Error("Apple requested phone verification but did not include a trusted phone number.");d={type:"phone",phoneNumberId:c.id,mode:c.pushMode??"sms"},s=await b(n,c.id,c.pushMode??"sms")}if(s.status<200||s.status>=300)throw new Error(`Apple two-factor challenge failed: HTTP ${s.status} ${s.rawBody??""}`.trim())}else if(u.status<200||u.status>=300)throw new Error(`Apple SRP complete failed: HTTP ${u.status} ${u.rawBody??""}`.trim());return{relay:n,completeResponse:u,twoFactorChallengeResponse:s,requiresTwoFactor:y,finishTwoFactor:async c=>{const l=d.type==="phone"?await T(n,d.phoneNumberId,c,d.mode):await k(n,c);if(l.status<200||l.status>=300)throw new Error(`Apple two-factor code failed: HTTP ${l.status} ${l.rawBody??""}`.trim());return l},finalize:async()=>v(n),close:async()=>n.close()}}catch(p){throw n.close(),p}}function C(e){return h(e)&&e.noTrustedDevices===!0}function W(e){if(!h(e))return;const t=h(e.phoneNumberVerification)?e.phoneNumberVerification:void 0,r=f(t?.trustedPhoneNumber)??f(e.trustedPhoneNumber)??f(e.phoneNumber);if(!r)return;const o=r.id;if(typeof o!="number")return;const a=typeof r.pushMode=="string"?r.pushMode:typeof e.mode=="string"?e.mode:void 0;return{id:o,pushMode:a}}function f(e){return h(e)?e:void 0}function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}exports.AppleRelayWebSocketClient=g;exports.fetchAppleAccountSession=v;exports.openAppleRelayWebSocket=m;exports.proxyAppStoreConnectRequest=F;exports.proxyPhoneTwoFactorCode=T;exports.proxyProvisioningRequest=q;exports.proxySrpComplete=A;exports.proxySrpInit=S;exports.proxyTwoFactorCode=k;exports.startBrowserOwnedAppleIDLogin=N;exports.triggerPhoneTwoFactor=b;exports.triggerTrustedDeviceTwoFactor=P;
@@ -1,4 +1,4 @@
1
- import { A as m } from "./index-DFdCvi2_.mjs";
1
+ import { A as m } from "./gsa-srp-Bme3JLEi.mjs";
2
2
  class g {
3
3
  constructor(t, r, o) {
4
4
  this.apiUrl = t, this.token = r, this.organizationId = o;
@@ -8,7 +8,7 @@ class g {
8
8
  pending = /* @__PURE__ */ new Map();
9
9
  async connect() {
10
10
  if (this.socket && this.socket.readyState === WebSocket.OPEN) return;
11
- const t = new WebSocket(R(this.apiUrl, this.token, this.organizationId));
11
+ const t = new WebSocket(N(this.apiUrl, this.token, this.organizationId));
12
12
  this.socket = t, t.onmessage = (r) => this.handleMessage(r), t.onclose = () => this.rejectPending(new Error("Apple relay WebSocket closed")), t.onerror = () => this.rejectPending(new Error("Apple relay WebSocket failed")), await new Promise((r, o) => {
13
13
  t.onopen = () => r(), t.onerror = () => o(new Error("Apple relay WebSocket connection failed"));
14
14
  });
@@ -19,7 +19,7 @@ class g {
19
19
  throw new Error("Apple relay WebSocket is not connected.");
20
20
  const c = String(this.nextId++), n = new Promise((p, i) => {
21
21
  this.pending.set(c, {
22
- resolve: (h) => p(N(h)),
22
+ resolve: (f) => p(E(f)),
23
23
  reject: i
24
24
  });
25
25
  });
@@ -48,11 +48,11 @@ class g {
48
48
  this.pending.clear();
49
49
  }
50
50
  }
51
- async function b(e, t, r) {
51
+ async function A(e, t, r) {
52
52
  const o = new g(e, t, r);
53
53
  return await o.connect(), o;
54
54
  }
55
- async function A(e, t) {
55
+ async function b(e, t) {
56
56
  return e.request("srpInit", t);
57
57
  }
58
58
  async function P(e, t) {
@@ -70,13 +70,16 @@ async function T(e, t) {
70
70
  async function v(e, t, r, o = "sms") {
71
71
  return e.request("submitPhone2FA", { phoneNumberId: t, mode: o, code: r });
72
72
  }
73
- async function E(e) {
73
+ async function q(e) {
74
74
  return e.request("finalize");
75
75
  }
76
- async function W(e, t) {
76
+ async function x(e, t) {
77
77
  return e.request("provisioning", t);
78
78
  }
79
- function N(e) {
79
+ async function M(e, t) {
80
+ return e.request("appstoreconnect", t);
81
+ }
82
+ function E(e) {
80
83
  if (e.body !== void 0 || !e.rawBody)
81
84
  return e;
82
85
  try {
@@ -88,36 +91,36 @@ function N(e) {
88
91
  return e;
89
92
  }
90
93
  }
91
- function R(e, t, r) {
94
+ function N(e, t, r) {
92
95
  const o = new URL(e);
93
96
  return o.protocol = o.protocol === "https:" ? "wss:" : "ws:", o.pathname = `${o.pathname.replace(/\/$/, "")}/ios/appstoreconnect/ws`, t && o.searchParams.set("token", t), r && o.searchParams.set("organization", r), o.toString();
94
97
  }
95
- async function M({
98
+ async function $({
96
99
  registryApiUrl: e,
97
100
  accountName: t,
98
101
  password: r,
99
102
  token: o,
100
103
  organizationId: c
101
104
  }) {
102
- const n = await b(e, o, c);
105
+ const n = await A(e, o, c);
103
106
  try {
104
- const p = new m(t), i = await A(n, await p.init());
107
+ const p = new m(t), i = await b(n, await p.init());
105
108
  if (i.status < 200 || i.status >= 300)
106
109
  throw new Error(
107
110
  `Apple SRP init failed: HTTP ${i.status} ${i.rawBody ?? ""}`.trim()
108
111
  );
109
112
  if (!i.body)
110
113
  throw new Error("Apple SRP init response did not include a body.");
111
- const h = await p.complete(r, i.body), u = await P(n, {
112
- ...h,
114
+ const f = await p.complete(r, i.body), u = await P(n, {
115
+ ...f,
113
116
  rememberMe: !1,
114
117
  trustTokens: []
115
118
  }), y = u.status === 409;
116
119
  let s, l = { type: "trustedDevice" };
117
120
  if (y) {
118
121
  s = await S(n);
119
- const a = q(s.body);
120
- if (s.status === 412) {
122
+ const a = F(s.body);
123
+ if (s.status === 412 || R(s.body)) {
121
124
  if (!a)
122
125
  throw new Error("Apple requested phone verification but did not include a trusted phone number.");
123
126
  l = {
@@ -147,16 +150,19 @@ async function M({
147
150
  );
148
151
  return d;
149
152
  },
150
- finalize: async () => E(n),
153
+ finalize: async () => q(n),
151
154
  close: async () => n.close()
152
155
  };
153
156
  } catch (p) {
154
157
  throw n.close(), p;
155
158
  }
156
159
  }
157
- function q(e) {
158
- if (!f(e)) return;
159
- const t = f(e.phoneNumberVerification) ? e.phoneNumberVerification : void 0, r = w(t?.trustedPhoneNumber) ?? w(e.trustedPhoneNumber) ?? w(e.phoneNumber);
160
+ function R(e) {
161
+ return h(e) && e.noTrustedDevices === !0;
162
+ }
163
+ function F(e) {
164
+ if (!h(e)) return;
165
+ const t = h(e.phoneNumberVerification) ? e.phoneNumberVerification : void 0, r = w(t?.trustedPhoneNumber) ?? w(e.trustedPhoneNumber) ?? w(e.phoneNumber);
160
166
  if (!r) return;
161
167
  const o = r.id;
162
168
  if (typeof o != "number") return;
@@ -164,21 +170,22 @@ function q(e) {
164
170
  return { id: o, pushMode: c };
165
171
  }
166
172
  function w(e) {
167
- return f(e) ? e : void 0;
173
+ return h(e) ? e : void 0;
168
174
  }
169
- function f(e) {
175
+ function h(e) {
170
176
  return typeof e == "object" && e !== null && !Array.isArray(e);
171
177
  }
172
178
  export {
173
179
  g as A,
174
- v as a,
175
- P as b,
176
- A as c,
177
- T as d,
178
- S as e,
179
- E as f,
180
- b as o,
181
- W as p,
182
- M as s,
180
+ M as a,
181
+ v as b,
182
+ P as c,
183
+ b as d,
184
+ T as e,
185
+ q as f,
186
+ S as g,
187
+ A as o,
188
+ x as p,
189
+ $ as s,
183
190
  k as t
184
191
  };
@@ -14,6 +14,18 @@ interface RemoteControlProps {
14
14
  openUrl?: string;
15
15
  showFrame?: boolean;
16
16
  autoReconnect?: boolean;
17
+ /**
18
+ * Fires once when the component concludes the instance is permanently
19
+ * gone rather than suffering a recoverable connection blip.
20
+ *
21
+ * After a drop, the component probes the instance endpoint over HTTP;
22
+ * a 404 means the instance no longer exists (terminated/deleted). When
23
+ * that happens the component stops reconnecting and renders a built-in
24
+ * "terminated" message in place of the "Retry" button, and invokes this
25
+ * callback so the host can react (navigate away, surface its own UI,
26
+ * etc.). It is not called for ordinary network drops.
27
+ */
28
+ onTerminated?: () => void;
17
29
  /**
18
30
  * Enable the inspect overlay. When set, the component starts polling the
19
31
  * accessibility tree and draws boxes over each element on top of the
@@ -93,6 +105,150 @@ interface RemoteControlProps {
93
105
  * @default 2000
94
106
  */
95
107
  axMaxBackoffMs?: number;
108
+ /**
109
+ * Fires whenever the iOS simulator's camera demand state changes —
110
+ * i.e. an app inside the sim called
111
+ * `[AVCaptureSession startRunning]` or `[stopRunning]`. The
112
+ * component handles the `navigator.mediaDevices.getUserMedia` prompt
113
+ * and SDP plumbing internally; this callback is purely so the host
114
+ * UI can render a status indicator ("simulator is using your
115
+ * camera", etc.).
116
+ *
117
+ * `active` reflects whether the sim is currently asking for
118
+ * frames. `granted` is set only on the call that follows a
119
+ * `getUserMedia` attempt: `true` when the user accepted the
120
+ * browser prompt, `false` when they denied or the call failed
121
+ * (in which case the limulator side switches to a black-frame
122
+ * fallback so the app keeps ticking).
123
+ *
124
+ * `camera` (optional, only meaningful when `granted === true`)
125
+ * carries what `MediaStreamTrack.getSettings()` reported for the
126
+ * active capture: resolution, framerate, device label, facing
127
+ * mode. Use it to render a richer status indicator (e.g.
128
+ * "Camera · 1920×1080 · 30 fps · FaceTime HD").
129
+ *
130
+ * Only iOS instances ever fire this callback; Android instances
131
+ * have no camera-injector path and stay silent.
132
+ */
133
+ onCameraDemandChange?: (active: boolean, granted?: boolean, camera?: CameraCaptureInfo) => void;
134
+ /**
135
+ * Periodically (~1Hz) fires with a snapshot of the outbound
136
+ * camera stream's live WebRTC stats — codec, encoder
137
+ * implementation, hardware acceleration, encoded fps, bitrate,
138
+ * round-trip-time, and the encoder's
139
+ * `qualityLimitationReason` (which is what Meet/Zoom use to
140
+ * decide whether to show "Bandwidth limited" or "CPU limited"
141
+ * banners).
142
+ *
143
+ * Only fires while the simulator is actively pulling the
144
+ * camera AND `getUserMedia` was granted. `null` is emitted
145
+ * once when the stream goes back to idle so consumers can
146
+ * clear their UI without having to maintain their own
147
+ * timeout. The host app does not need to poll `getStats()`
148
+ * itself — this is the canonical place.
149
+ */
150
+ onCameraStats?: (stats: CameraStreamStats | null) => void;
151
+ /**
152
+ * Optional resolution cap for outbound camera capture.
153
+ *
154
+ * - `'auto'` (default): no extra constraint. The browser captures
155
+ * at its webcam's native max; WebRTC's quality scaler may step
156
+ * down resolution on the encoder side under bandwidth pressure
157
+ * while still feeding the simulator at the pool's native size.
158
+ * - `'1080p'` / `'720p'` / `'480p'`: hard cap applied via
159
+ * `getUserMedia` constraints (for new captures) and
160
+ * `track.applyConstraints` (for the currently-active track),
161
+ * matching the way Meet/Zoom expose a "Send resolution" picker.
162
+ *
163
+ * Bumping or lowering the cap mid-stream is supported; the
164
+ * change takes effect within a frame or two as the webcam
165
+ * re-negotiates.
166
+ */
167
+ cameraResolutionCap?: CameraResolutionCap;
168
+ /**
169
+ * Aspect ratio the simulator's virtual camera should report to apps.
170
+ * Picking a value here triggers a `cameraAspect` WS message to the
171
+ * host, which rebuilds its IOSurface ring at the matching dimensions
172
+ * (16:9 → 1920×1080, 4:3 → 1440×1080, 1:1 → 1080×1080, 9:16 →
173
+ * 1080×1920) and signals the in-sim dylib to re-handshake. iOS apps
174
+ * see CMSampleBuffers at the new dimensions within a frame or two.
175
+ *
176
+ * The browser still captures whatever the webcam offers; the host
177
+ * aspect-fills (cover, center-crop) into the new pool. Switching
178
+ * aspect at runtime is intentionally cheap so users can A/B preview
179
+ * styles without restarting the simulator.
180
+ *
181
+ * `undefined` leaves the pool untouched (the host's boot default —
182
+ * 16:9 / 1920×1080 — applies).
183
+ */
184
+ cameraAspect?: CameraAspect;
185
+ }
186
+ /**
187
+ * Resolution caps a host app can request on the outbound camera.
188
+ * `'auto'` is "let the browser decide" (no constraints beyond the
189
+ * 30 fps ceiling); the other options clamp width/height to the
190
+ * named target. Aspect ratio is preserved.
191
+ */
192
+ export type CameraResolutionCap = 'auto' | '1080p' | '720p' | '480p';
193
+ /**
194
+ * Aspect ratios exposed to the operator for the simulated camera.
195
+ * The host maps each label to concrete IOSurface dimensions; values
196
+ * the host doesn't recognise are silently ignored.
197
+ */
198
+ export type CameraAspect = '16:9' | '4:3' | '1:1' | '9:16';
199
+ /**
200
+ * Snapshot of the browser's webcam capture, mirrored from
201
+ * `MediaStreamTrack.getSettings()`. Forwarded to the host alongside
202
+ * `cameraResult` and exposed to the host app via
203
+ * `onCameraDemandChange` so it can render a status indicator without
204
+ * having to call `getStats()` itself.
205
+ */
206
+ export interface CameraCaptureInfo {
207
+ width?: number;
208
+ height?: number;
209
+ frameRate?: number;
210
+ deviceId?: string;
211
+ label?: string;
212
+ facingMode?: string;
213
+ }
214
+ /**
215
+ * Live outbound-camera quality snapshot. Derived from
216
+ * `RTCPeerConnection.getStats()` and rate-derived deltas, sampled
217
+ * once per second while the camera is sending. All fields optional:
218
+ * some browsers omit fields (Safari rarely reports
219
+ * `encoderImplementation`), and the first sample after camera start
220
+ * has no delta-derived numbers yet.
221
+ */
222
+ export interface CameraStreamStats {
223
+ /** "H264", "HEVC"/"H265", "VP9", "VP8", "AV1", etc. (uppercased). */
224
+ codec?: string;
225
+ /** e.g. "VideoToolbox" (hw), "OpenH264" (sw), "ExternalEncoder". */
226
+ encoderImplementation?: string;
227
+ /**
228
+ * Browser-reported hardware-acceleration hint. Some Chromium
229
+ * versions expose this via `powerEfficientEncoder`; we mirror it
230
+ * here so consumers don't have to know the spec quirk.
231
+ */
232
+ hardwareAccelerated?: boolean;
233
+ /** Outbound encoded fps over the last sample window. */
234
+ framesPerSecond?: number;
235
+ /** Cumulative encoded frame count. */
236
+ framesEncoded?: number;
237
+ /** Outbound encoded bitrate (bits/s) over the last window. */
238
+ bitrateBps?: number;
239
+ /** Width/height the encoder is currently producing. */
240
+ width?: number;
241
+ height?: number;
242
+ /**
243
+ * One of `'none' | 'cpu' | 'bandwidth' | 'other'`. Mirrors
244
+ * Meet/Zoom's "limited by …" banners. Anything other than
245
+ * `'none'` means the encoder dropped resolution to keep up.
246
+ */
247
+ qualityLimitationReason?: string;
248
+ /** Round-trip time in milliseconds, from the matching RTCP. */
249
+ rttMs?: number;
250
+ /** Packet-loss percentage over the last sample window (0..100). */
251
+ packetsLostPct?: number;
96
252
  }
97
253
  interface ScreenshotData {
98
254
  dataUri: string;
@@ -94,6 +94,11 @@ export declare function findAdHocProfilesRequest({ bundleID, teamID, }: Pick<App
94
94
  path: string;
95
95
  payload: Record<string, unknown>;
96
96
  };
97
+ export declare function findAppStoreProfilesRequest({ bundleID, teamID, }: Pick<AppleProvisioningContext, 'bundleID' | 'teamID'>): {
98
+ method: "POST";
99
+ path: string;
100
+ payload: Record<string, unknown>;
101
+ };
97
102
  export declare function registerDeviceRequest({ deviceUDID, teamID, name, }: Pick<AppleProvisioningContext, 'deviceUDID' | 'teamID'> & {
98
103
  name?: string;
99
104
  }): {
@@ -197,6 +202,26 @@ export declare function createAdHocProfileRequest({ bundleID, teamID, appIDID, c
197
202
  subPlatform: string;
198
203
  };
199
204
  };
205
+ /**
206
+ * App Store distribution profiles bind no devices, and the name is required
207
+ * because implementors brand profiles themselves; there is no default.
208
+ */
209
+ export declare function createAppStoreProfileRequest({ teamID, appIDID, certificateID, name, }: Pick<AppleProvisioningContext, 'teamID'> & {
210
+ appIDID: string;
211
+ certificateID: string;
212
+ name: string;
213
+ }): {
214
+ method: "POST";
215
+ path: string;
216
+ payload: {
217
+ teamId: string;
218
+ provisioningProfileName: string;
219
+ certificateIds: string[];
220
+ appIdId: string;
221
+ distributionType: string;
222
+ subPlatform: string;
223
+ };
224
+ };
200
225
  export declare function downloadProfileRequest(profileID: string, teamID?: string): {
201
226
  method: "GET";
202
227
  path: string;
@@ -12,6 +12,18 @@ export type AppleProvisioningRequest = {
12
12
  path: string;
13
13
  payload?: unknown;
14
14
  };
15
+ /**
16
+ * A session-authenticated App Store Connect request proxied by the relay.
17
+ * Unlike provisioning requests, payloads pass through as JSON and GET
18
+ * parameters go into an explicit query map because the App Store Connect
19
+ * API uses bracketed JSON:API keys like fields[apiKeys].
20
+ */
21
+ export type AppStoreConnectRequest = {
22
+ method?: 'GET' | 'POST';
23
+ path: string;
24
+ query?: Record<string, string>;
25
+ payload?: unknown;
26
+ };
15
27
  export declare class AppleRelayWebSocketClient {
16
28
  private readonly apiUrl;
17
29
  private readonly token?;
@@ -38,3 +50,4 @@ export declare function proxyTwoFactorCode(relay: AppleRelayWebSocketClient, cod
38
50
  export declare function proxyPhoneTwoFactorCode(relay: AppleRelayWebSocketClient, phoneNumberId: number, code: string, mode?: string): Promise<AppleRelayResponse<unknown>>;
39
51
  export declare function fetchAppleAccountSession(relay: AppleRelayWebSocketClient): Promise<AppleRelayResponse<unknown>>;
40
52
  export declare function proxyProvisioningRequest<T = unknown>(relay: AppleRelayWebSocketClient, request: AppleProvisioningRequest): Promise<AppleRelayResponse<T>>;
53
+ export declare function proxyAppStoreConnectRequest<T = unknown>(relay: AppleRelayWebSocketClient, request: AppStoreConnectRequest): Promise<AppleRelayResponse<T>>;
@@ -23,6 +23,7 @@ export declare function parseProvisioningProfile(file: File): Promise<{
23
23
  applicationIdentifier: string | undefined;
24
24
  bundleID: string | undefined;
25
25
  provisionedDevices: string[];
26
+ certificateSerialNumbers: string[];
26
27
  getTaskAllow: boolean | undefined;
27
28
  expirationDate: string | undefined;
28
29
  }>;
@@ -33,6 +34,7 @@ export declare function parseProvisioningProfileBase64(base64: string): {
33
34
  applicationIdentifier: string | undefined;
34
35
  bundleID: string | undefined;
35
36
  provisionedDevices: string[];
37
+ certificateSerialNumbers: string[];
36
38
  getTaskAllow: boolean | undefined;
37
39
  expirationDate: string | undefined;
38
40
  };
@@ -43,6 +45,12 @@ export declare function parseProvisioningProfileBytes(bytes: Uint8Array): {
43
45
  applicationIdentifier: string | undefined;
44
46
  bundleID: string | undefined;
45
47
  provisionedDevices: string[];
48
+ certificateSerialNumbers: string[];
46
49
  getTaskAllow: boolean | undefined;
47
50
  expirationDate: string | undefined;
48
51
  };
52
+ /**
53
+ * Normalizes a certificate serial number for comparison: uppercase hex
54
+ * without leading zeros, the format Apple's portal reports in serialNum.
55
+ */
56
+ export declare function normalizeCertificateSerial(serial?: string): string | undefined;
@@ -1 +1,2 @@
1
1
  export * from './browser-storage';
2
+ export * from './secret-store';