@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.
Files changed (71) hide show
  1. package/dist/app-store-relay/index.cjs +3 -3
  2. package/dist/app-store-relay/index.js +5 -5
  3. package/dist/app-store-relay/react.cjs +1 -1
  4. package/dist/app-store-relay/react.d.ts +1 -1
  5. package/dist/app-store-relay/react.js +34 -31
  6. package/dist/apple-credentials/index.cjs +1 -0
  7. package/dist/apple-credentials/index.d.ts +59 -0
  8. package/dist/apple-credentials/index.js +227 -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-D1drDXxE.js +1 -0
  12. package/dist/{client-CBX-hLnL.mjs → client-DSuNtWDv.mjs} +2 -7
  13. package/dist/core/device-install/operations/operations.d.ts +1 -1
  14. package/dist/core/device-install/storage/browser-storage.d.ts +8 -0
  15. package/dist/core/device-install/storage/index.d.ts +1 -0
  16. package/dist/core/device-install/storage/secret-store.d.ts +101 -0
  17. package/dist/core/device-install/types.d.ts +6 -0
  18. package/dist/core/errors.d.ts +1 -0
  19. package/dist/core/play-publish/google.d.ts +13 -0
  20. package/dist/core/play-publish/publish.d.ts +34 -0
  21. package/dist/device-build/index.cjs +1 -1
  22. package/dist/device-build/index.js +25 -24
  23. package/dist/device-build/react.cjs +1 -1
  24. package/dist/device-build/react.js +42 -43
  25. package/dist/device-install/index.cjs +1 -1
  26. package/dist/device-install/index.js +164 -160
  27. package/dist/device-install/react.cjs +1 -1
  28. package/dist/device-install/react.js +61 -60
  29. package/dist/errors-BSkqS7U-.js +1 -0
  30. package/dist/errors-gy8yQJos.mjs +6 -0
  31. package/dist/gsa-srp-Bme3JLEi.mjs +266 -0
  32. package/dist/gsa-srp-CCIfUz7Y.js +1 -0
  33. package/dist/index-ChhtuQ7e.js +22 -0
  34. package/dist/index-YDu8K9a4.mjs +11279 -0
  35. package/dist/play-publish/index.cjs +1 -0
  36. package/dist/play-publish/index.d.ts +2 -0
  37. package/dist/play-publish/index.js +109 -0
  38. package/dist/play-publish/react.cjs +1 -0
  39. package/dist/play-publish/react.d.ts +31 -0
  40. package/dist/play-publish/react.js +91 -0
  41. package/dist/{provisioning-DKbkBO-p.mjs → provisioning-B_DefBEp.mjs} +9 -9
  42. package/dist/{provisioning-Va0PH4Kk.js → provisioning-BlQMccX_.js} +1 -1
  43. package/package.json +18 -2
  44. package/src/app-store-relay/index.test.ts +6 -6
  45. package/src/app-store-relay/react.ts +6 -5
  46. package/src/apple-credentials/index.test.ts +158 -0
  47. package/src/apple-credentials/index.ts +241 -0
  48. package/src/core/device-install/apple/client.ts +1 -6
  49. package/src/core/device-install/apple/relay.ts +1 -4
  50. package/src/core/device-install/operations/operations.ts +8 -5
  51. package/src/core/device-install/storage/browser-storage.test.ts +65 -0
  52. package/src/core/device-install/storage/browser-storage.ts +33 -0
  53. package/src/core/device-install/storage/index.ts +1 -0
  54. package/src/core/device-install/storage/secret-store.ts +298 -0
  55. package/src/core/device-install/types.ts +6 -0
  56. package/src/core/errors.ts +3 -0
  57. package/src/core/play-publish/google.ts +113 -0
  58. package/src/core/play-publish/publish.test.ts +68 -0
  59. package/src/core/play-publish/publish.ts +89 -0
  60. package/src/device-build/react.ts +1 -4
  61. package/src/device-install/demo/demo.tsx +2 -8
  62. package/src/device-install/react.ts +31 -31
  63. package/src/play-publish/README.md +66 -0
  64. package/src/play-publish/index.ts +12 -0
  65. package/src/play-publish/react.ts +208 -0
  66. package/vite.config.ts +3 -0
  67. package/dist/browser-storage-Cx9eW-bm.mjs +0 -205
  68. package/dist/browser-storage-jJaIht4K.js +0 -1
  69. package/dist/client-BtC4n_qf.js +0 -1
  70. package/dist/index-CMeQfhYy.js +0 -22
  71. package/dist/index-DFdCvi2_.mjs +0 -11543
@@ -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 F=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:h=>p(q(h)),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 R(e,t){return e.request("provisioning",t)}function q(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 F.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 h=await p.complete(r,i.body),u=await A(n,{...h,rememberMe:!1,trustTokens:[]}),y=u.status===409;let s,d={type:"trustedDevice"};if(y){s=await P(n);const c=x(s.body);if(s.status===412){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 x(e){if(!f(e))return;const t=f(e.phoneNumberVerification)?e.phoneNumberVerification:void 0,r=w(t?.trustedPhoneNumber)??w(e.trustedPhoneNumber)??w(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 w(e){return f(e)?e:void 0}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}exports.AppleRelayWebSocketClient=g;exports.fetchAppleAccountSession=v;exports.openAppleRelayWebSocket=m;exports.proxyPhoneTwoFactorCode=T;exports.proxyProvisioningRequest=R;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;
@@ -140,12 +140,7 @@ async function M({
140
140
  twoFactorChallengeResponse: s,
141
141
  requiresTwoFactor: y,
142
142
  finishTwoFactor: async (a) => {
143
- const d = l.type === "phone" ? await v(
144
- n,
145
- l.phoneNumberId,
146
- a,
147
- l.mode
148
- ) : await T(n, a);
143
+ const d = l.type === "phone" ? await v(n, l.phoneNumberId, a, l.mode) : await T(n, a);
149
144
  if (d.status < 200 || d.status >= 300)
150
145
  throw new Error(
151
146
  `Apple two-factor code failed: HTTP ${d.status} ${d.rawBody ?? ""}`.trim()
@@ -37,7 +37,7 @@ export type StartInstallRelayOptions = StartPairingRelayOptions & {
37
37
  installSource: InstallSource;
38
38
  };
39
39
  export declare function requestUSBAccess({ log }: RequestUSBAccessOptions): Promise<DeviceRelayTarget>;
40
- export declare function startPairingRelay({ registryApiUrl, token, organizationId, log, target }: StartPairingRelayOptions): Promise<{
40
+ export declare function startPairingRelay({ registryApiUrl, token, organizationId, log, target, }: StartPairingRelayOptions): Promise<{
41
41
  relay: RelayClient;
42
42
  pairRecord: PairRecordPayload;
43
43
  target: DeviceRelayTarget;
@@ -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';
@@ -0,0 +1,101 @@
1
+ /**
2
+ * A pluggable store for Apple signing secrets.
3
+ *
4
+ * Credential material always lands in the browser first (the Apple relay
5
+ * only proxies); the browser then writes it into a store implementing this
6
+ * interface. Limrun's org secret store is the default implementation, an
7
+ * IndexedDB-backed one keeps everything local, and customers can bring
8
+ * their own store by implementing the same interface.
9
+ */
10
+ export declare const APPLE_CERTIFICATE_SECRET_TYPE = "appleCertificate";
11
+ export declare const APPLE_PROVISIONING_PROFILE_SECRET_TYPE = "appleProvisioningProfile";
12
+ export type SigningSecretType = typeof APPLE_CERTIFICATE_SECRET_TYPE | typeof APPLE_PROVISIONING_PROFILE_SECRET_TYPE;
13
+ export type SigningSecretMetadata = {
14
+ type: string;
15
+ name: string;
16
+ createdAt?: string;
17
+ };
18
+ /** Type-specific flat key-value payload of a signing secret. */
19
+ export type SigningSecretData = Record<string, string>;
20
+ export type SigningSecret = SigningSecretMetadata & {
21
+ data: SigningSecretData;
22
+ };
23
+ export interface SigningSecretStore {
24
+ /**
25
+ * Stores a secret. When a secret with the same type and name already
26
+ * exists its data is overwritten. Returns the stored secret; callers
27
+ * should use the returned data.
28
+ */
29
+ put(type: SigningSecretType, name: string, data: SigningSecretData): Promise<SigningSecret>;
30
+ /** Returns the secret including its data, or undefined when absent. */
31
+ get(type: SigningSecretType, name: string): Promise<SigningSecret | undefined>;
32
+ /** Lists metadata of all stored signing secrets, never their data. */
33
+ list(): Promise<SigningSecretMetadata[]>;
34
+ /** Deletes a secret; resolves even when the secret does not exist. */
35
+ delete(type: SigningSecretType, name: string): Promise<void>;
36
+ }
37
+ /**
38
+ * Apple's certificate types as defined by the App Store Connect API
39
+ * (https://developer.apple.com/documentation/appstoreconnectapi/certificatetype).
40
+ */
41
+ export type AppleCertificateType = 'DEVELOPMENT' | 'DISTRIBUTION' | 'IOS_DEVELOPMENT' | 'IOS_DISTRIBUTION' | 'MAC_APP_DEVELOPMENT' | 'MAC_APP_DISTRIBUTION' | 'MAC_INSTALLER_DISTRIBUTION' | 'DEVELOPER_ID_APPLICATION' | 'DEVELOPER_ID_INSTALLER' | 'DEVELOPER_ID_KEXT' | 'PASS_TYPE_ID' | 'PASS_TYPE_ID_WITH_NFC';
42
+ /** Data payload of an appleCertificate secret. */
43
+ export type AppleCertificateSecretData = {
44
+ certificateP12Base64: string;
45
+ /** Which of Apple's certificate types the p12 holds. */
46
+ certificateType: AppleCertificateType;
47
+ certificatePassword?: string;
48
+ teamID?: string;
49
+ /** Apple's portal certificate id, never a Limrun DB id. */
50
+ certificateID?: string;
51
+ /** The certificate's serial number: uppercase hex, no leading zeros. */
52
+ serialNumber?: string;
53
+ expirationDate?: string;
54
+ };
55
+ /**
56
+ * Data payload of an appleProvisioningProfile secret. The
57
+ * certificateSerialNumbers, bundleIDs and deviceIDs fields duplicate what
58
+ * the signed profile binds (as comma-separated lists) so profiles can be
59
+ * filtered by certificate, bundle ID or device without parsing every
60
+ * entry. Certificates are referenced by serial number, the identifier
61
+ * Apple embeds in the profile itself.
62
+ */
63
+ export type AppleProvisioningProfileSecretData = {
64
+ provisioningProfileBase64: string;
65
+ certificateSerialNumbers?: string;
66
+ bundleIDs?: string;
67
+ deviceIDs?: string;
68
+ teamID?: string;
69
+ profileName?: string;
70
+ uuid?: string;
71
+ expirationDate?: string;
72
+ };
73
+ /** Stores an Apple certificate bundle, conventionally named `${teamID}/${certificateType}`. */
74
+ export declare function putAppleCertificateSecret(store: SigningSecretStore, name: string, data: AppleCertificateSecretData): Promise<SigningSecret>;
75
+ /**
76
+ * Stores a provisioning profile, conventionally named `${teamID}/${uuid}`
77
+ * so a team can hold many profiles for the same bundle ID and certificate
78
+ * set; consumers select by the reference fields, not by name.
79
+ */
80
+ export declare function putAppleProvisioningProfileSecret(store: SigningSecretStore, name: string, data: AppleProvisioningProfileSecretData): Promise<SigningSecret>;
81
+ export type LimrunSecretStoreOptions = {
82
+ /** Base URL of the Limrun backend API, e.g. https://api.limrun.com */
83
+ apiUrl: string;
84
+ /** Bearer token: a user or organization token. */
85
+ token: string;
86
+ /** Organization TID owning the secrets. */
87
+ organizationId: string;
88
+ /** Custom fetch, mainly for tests. */
89
+ fetch?: typeof fetch;
90
+ };
91
+ /**
92
+ * A SigningSecretStore backed by Limrun's organization secret store
93
+ * (`/v1/organizations/{org}/secrets`). Secrets are stored server-side and
94
+ * shared across the organization.
95
+ */
96
+ export declare function createLimrunSecretStore(options: LimrunSecretStoreOptions): SigningSecretStore;
97
+ /**
98
+ * A SigningSecretStore keeping everything in the browser's IndexedDB.
99
+ * Nothing leaves the machine; secrets are per-browser-profile.
100
+ */
101
+ export declare function createBrowserSecretStore(): SigningSecretStore;
@@ -30,6 +30,12 @@ export type ProvisioningProfileInfo = {
30
30
  applicationIdentifier?: string;
31
31
  bundleID?: string;
32
32
  provisionedDevices: string[];
33
+ /**
34
+ * Serial numbers (uppercase hex, no leading zeros) of the developer
35
+ * certificates embedded in the profile; the profile is only usable for
36
+ * signing with one of these certificates.
37
+ */
38
+ certificateSerialNumbers: string[];
33
39
  getTaskAllow?: boolean;
34
40
  expirationDate?: string;
35
41
  };
@@ -0,0 +1 @@
1
+ export declare function errorMessage(error: unknown): string;
@@ -0,0 +1,13 @@
1
+ export declare const ANDROID_PUBLISHER_SCOPE = "https://www.googleapis.com/auth/androidpublisher";
2
+ export declare function loadGoogleIdentityServices(): Promise<void>;
3
+ export type RequestGoogleAccessTokenInput = {
4
+ clientId: string;
5
+ scope?: string;
6
+ };
7
+ /**
8
+ * Opens the Google consent popup and resolves with a short-lived OAuth
9
+ * access token. Call from a user gesture so popup blockers allow it, and
10
+ * call loadGoogleIdentityServices beforehand (e.g. when the surrounding
11
+ * dialog opens) to keep this call synchronous with the click.
12
+ */
13
+ export declare function requestGoogleAccessToken(input: RequestGoogleAccessTokenInput): Promise<string>;
@@ -0,0 +1,34 @@
1
+ export type PlaystorePublishInput = {
2
+ registryApiUrl: string;
3
+ /** Limrun API token authenticating the registry call. */
4
+ token?: string;
5
+ /** Organization tid; required when it differs from the token's default organization. */
6
+ organizationId?: string;
7
+ /** Google OAuth access token with the androidpublisher scope. Sent per request, never stored. */
8
+ accessToken: string;
9
+ packageName: string;
10
+ assetId?: string;
11
+ assetName?: string;
12
+ /** Play track ID, defaults to internal on the server. */
13
+ track?: string;
14
+ /** Required by the server when track is production. */
15
+ releaseStatus?: 'draft' | 'completed';
16
+ };
17
+ export type PlaystorePublishResult = {
18
+ versionCode: number;
19
+ };
20
+ /**
21
+ * Registry publish failure. `code` carries the registry's machine-readable
22
+ * error code when available: invalidRequest, assetNotFound, internal, busy,
23
+ * listingNotFound, permissionDenied, versionCodeExists, uploadKeyMismatch
24
+ * or unknown; the set grows additively.
25
+ */
26
+ export declare class PlaystorePublishError extends Error {
27
+ readonly code?: string;
28
+ readonly status?: number;
29
+ constructor(message: string, options?: {
30
+ code?: string;
31
+ status?: number;
32
+ });
33
+ }
34
+ export declare function publishToPlaystore(input: PlaystorePublishInput): Promise<PlaystorePublishResult>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../limbuild-client-CVDwq54z.js");require("../index-CMeQfhYy.js");const c=require("../provisioning-Va0PH4Kk.js"),i=require("../browser-storage-jJaIht4K.js");async function v({certificateFile:t,provisioningProfileFile:e,certificatePassword:n,bundleId:s,deviceUDID:r,teamId:d,signingMode:f="development",certificateId:p}){const[u,A,o]=await Promise.all([l(t),l(e),i.parseProvisioningProfile(e)]);return g({profile:o,bundleId:s,deviceUDID:r,signingMode:f}),i.putSigningAssets({bundleID:s??o.bundleID??o.applicationIdentifier??e.name,deviceUDID:r,teamID:d??o.teamID,signingMode:f,certificateID:p,certificateP12Base64:u,certificateFileName:t.name,certificatePassword:n||void 0,provisioningProfileBase64:A,profileFileName:e.name,profile:o})}function S(t,e={}){g({profile:t.profile,bundleId:e.bundleId,deviceUDID:e.deviceUDID,signingMode:e.signingMode??t.signingMode})}function g({profile:t,bundleId:e,deviceUDID:n,signingMode:s}){if(e&&!i.profileMatchesBundleID(t,e))throw new Error(`Provisioning profile does not match bundle ID ${e}.`);if(n&&!i.profileContainsDevice(t,n))throw new Error("Provisioning profile does not include the selected iPhone.");if(s==="adhoc"&&t.getTaskAllow)throw new Error("Ad Hoc mode requires an Ad Hoc provisioning profile, not a development profile.")}async function l(t){const e=await t.arrayBuffer();let n="";const s=new Uint8Array(e);for(const r of s)n+=String.fromCharCode(r);return btoa(n)}exports.fetchLimbuildInfo=a.fetchLimbuildInfo;exports.getIOSOTAInstall=a.getIOSOTAInstall;exports.startSignedDeviceBuild=a.startSignedDeviceBuild;exports.watchBuildLogEvents=a.watchBuildLogEvents;exports.getReusableAppleSigningAssets=c.getReusableAppleSigningAssets;exports.putAppleGeneratedSigningAssets=c.putAppleGeneratedSigningAssets;exports.getLatestSigningAssets=i.getLatestSigningAssets;exports.getLatestSigningAssetsWithCertificate=i.getLatestSigningAssetsWithCertificate;exports.getSigningAssets=i.getSigningAssets;exports.parseProvisioningProfile=i.parseProvisioningProfile;exports.parseProvisioningProfileBase64=i.parseProvisioningProfileBase64;exports.parseProvisioningProfileBytes=i.parseProvisioningProfileBytes;exports.profileContainsDevice=i.profileContainsDevice;exports.profileMatchesBundleID=i.profileMatchesBundleID;exports.putSigningAssets=i.putSigningAssets;exports.fileToBase64=l;exports.importSigningAssetsFromFiles=v;exports.validateProvisioningProfileForInstall=g;exports.validateSigningAssetsForInstall=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../limbuild-client-CVDwq54z.js");require("../gsa-srp-CCIfUz7Y.js");require("../index-ChhtuQ7e.js");const c=require("../provisioning-BlQMccX_.js"),i=require("../browser-storage-DLxIqZk5.js");async function v({certificateFile:t,provisioningProfileFile:e,certificatePassword:n,bundleId:s,deviceUDID:o,teamId:d,signingMode:f="development",certificateId:p}){const[u,A,r]=await Promise.all([l(t),l(e),i.parseProvisioningProfile(e)]);return g({profile:r,bundleId:s,deviceUDID:o,signingMode:f}),i.putSigningAssets({bundleID:s??r.bundleID??r.applicationIdentifier??e.name,deviceUDID:o,teamID:d??r.teamID,signingMode:f,certificateID:p,certificateP12Base64:u,certificateFileName:t.name,certificatePassword:n||void 0,provisioningProfileBase64:A,profileFileName:e.name,profile:r})}function S(t,e={}){g({profile:t.profile,bundleId:e.bundleId,deviceUDID:e.deviceUDID,signingMode:e.signingMode??t.signingMode})}function g({profile:t,bundleId:e,deviceUDID:n,signingMode:s}){if(e&&!i.profileMatchesBundleID(t,e))throw new Error(`Provisioning profile does not match bundle ID ${e}.`);if(n&&!i.profileContainsDevice(t,n))throw new Error("Provisioning profile does not include the selected iPhone.");if(s==="adhoc"&&t.getTaskAllow)throw new Error("Ad Hoc mode requires an Ad Hoc provisioning profile, not a development profile.")}async function l(t){const e=await t.arrayBuffer();let n="";const s=new Uint8Array(e);for(const o of s)n+=String.fromCharCode(o);return btoa(n)}exports.fetchLimbuildInfo=a.fetchLimbuildInfo;exports.getIOSOTAInstall=a.getIOSOTAInstall;exports.startSignedDeviceBuild=a.startSignedDeviceBuild;exports.watchBuildLogEvents=a.watchBuildLogEvents;exports.getReusableAppleSigningAssets=c.getReusableAppleSigningAssets;exports.putAppleGeneratedSigningAssets=c.putAppleGeneratedSigningAssets;exports.getLatestSigningAssets=i.getLatestSigningAssets;exports.getLatestSigningAssetsWithCertificate=i.getLatestSigningAssetsWithCertificate;exports.getSigningAssets=i.getSigningAssets;exports.parseProvisioningProfile=i.parseProvisioningProfile;exports.parseProvisioningProfileBase64=i.parseProvisioningProfileBase64;exports.parseProvisioningProfileBytes=i.parseProvisioningProfileBytes;exports.profileContainsDevice=i.profileContainsDevice;exports.profileMatchesBundleID=i.profileMatchesBundleID;exports.putSigningAssets=i.putSigningAssets;exports.fileToBase64=l;exports.importSigningAssetsFromFiles=v;exports.validateProvisioningProfileForInstall=g;exports.validateSigningAssetsForInstall=S;
@@ -1,17 +1,18 @@
1
- import { f as b, g as B, s as D, w as y } from "../limbuild-client-BagK_FWE.mjs";
2
- import "../index-DFdCvi2_.mjs";
3
- import { o as C, p as E } from "../provisioning-DKbkBO-p.mjs";
4
- import { p as d, a as m, b as u, c as A } from "../browser-storage-Cx9eW-bm.mjs";
5
- import { g as M, d as T, e as F, f as H, h as N } from "../browser-storage-Cx9eW-bm.mjs";
6
- async function w({
1
+ import { f as B, g as D, s as y, w as x } from "../limbuild-client-BagK_FWE.mjs";
2
+ import "../gsa-srp-Bme3JLEi.mjs";
3
+ import "../index-YDu8K9a4.mjs";
4
+ import { g as E, p as L } from "../provisioning-B_DefBEp.mjs";
5
+ import { p as d, a as m, b as u, c as A } from "../browser-storage-BnO-Ma-e.mjs";
6
+ import { g as T, d as F, e as H, f as N, h as O } from "../browser-storage-BnO-Ma-e.mjs";
7
+ async function I({
7
8
  certificateFile: i,
8
9
  provisioningProfileFile: e,
9
10
  certificatePassword: t,
10
11
  bundleId: n,
11
12
  deviceUDID: o,
12
- teamId: l,
13
+ teamId: g,
13
14
  signingMode: r = "development",
14
- certificateId: g
15
+ certificateId: l
15
16
  }) {
16
17
  const [c, p, s] = await Promise.all([
17
18
  a(i),
@@ -21,9 +22,9 @@ async function w({
21
22
  return f({ profile: s, bundleId: n, deviceUDID: o, signingMode: r }), m({
22
23
  bundleID: n ?? s.bundleID ?? s.applicationIdentifier ?? e.name,
23
24
  deviceUDID: o,
24
- teamID: l ?? s.teamID,
25
+ teamID: g ?? s.teamID,
25
26
  signingMode: r,
26
- certificateID: g,
27
+ certificateID: l,
27
28
  certificateP12Base64: c,
28
29
  certificateFileName: i.name,
29
30
  certificatePassword: t || void 0,
@@ -32,7 +33,7 @@ async function w({
32
33
  profile: s
33
34
  });
34
35
  }
35
- function I(i, e = {}) {
36
+ function P(i, e = {}) {
36
37
  f({
37
38
  profile: i.profile,
38
39
  bundleId: e.bundleId,
@@ -62,23 +63,23 @@ async function a(i) {
62
63
  return btoa(t);
63
64
  }
64
65
  export {
65
- b as fetchLimbuildInfo,
66
+ B as fetchLimbuildInfo,
66
67
  a as fileToBase64,
67
- B as getIOSOTAInstall,
68
- M as getLatestSigningAssets,
69
- T as getLatestSigningAssetsWithCertificate,
70
- C as getReusableAppleSigningAssets,
71
- F as getSigningAssets,
72
- w as importSigningAssetsFromFiles,
68
+ D as getIOSOTAInstall,
69
+ T as getLatestSigningAssets,
70
+ F as getLatestSigningAssetsWithCertificate,
71
+ E as getReusableAppleSigningAssets,
72
+ H as getSigningAssets,
73
+ I as importSigningAssetsFromFiles,
73
74
  d as parseProvisioningProfile,
74
- H as parseProvisioningProfileBase64,
75
- N as parseProvisioningProfileBytes,
75
+ N as parseProvisioningProfileBase64,
76
+ O as parseProvisioningProfileBytes,
76
77
  A as profileContainsDevice,
77
78
  u as profileMatchesBundleID,
78
- E as putAppleGeneratedSigningAssets,
79
+ L as putAppleGeneratedSigningAssets,
79
80
  m as putSigningAssets,
80
- D as startSignedDeviceBuild,
81
+ y as startSignedDeviceBuild,
81
82
  f as validateProvisioningProfileForInstall,
82
- I as validateSigningAssetsForInstall,
83
- y as watchBuildLogEvents
83
+ P as validateSigningAssetsForInstall,
84
+ x as watchBuildLogEvents
84
85
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),v=require("../limbuild-client-CVDwq54z.js");require("../index-CMeQfhYy.js");function P({apiUrl:e,token:n,signingAssets:g,loadOTAInstall:I=!1}){const[w,c]=t.useState("idle"),[B,u]=t.useState([]),[h,a]=t.useState(),[x,l]=t.useState(),[E,o]=t.useState(),i=t.useRef(void 0);t.useEffect(()=>()=>{i.current?.(),i.current=void 0},[]);const m=t.useCallback(()=>{i.current?.(),i.current=void 0,c("idle"),u([]),a(void 0),l(void 0),o(void 0)},[]),q=t.useCallback(async(S={})=>{if(!e)throw new Error("apiUrl is required to start a device build.");const d=S.signingAssets??g;if(!d)throw new Error("Signing assets are required to start a device build.");i.current?.(),c("queued"),u([]),a(void 0),l(void 0),o(void 0);try{const r=await v.startSignedDeviceBuild({limbuildApiUrl:e,token:n,certificateP12Base64:d.certificateP12Base64,certificatePassword:d.certificatePassword,provisioningProfileBase64:d.provisioningProfileBase64,signedUploadUrl:S.signedUploadUrl});if(!r.execId)throw new Error("Build request did not return an exec ID.");return a(r.execId),i.current=v.watchBuildLogEvents({limbuildApiUrl:e,token:n,execId:r.execId,onLine:s=>u(f=>[...f,s]),onStatus:s=>{c(s),s==="succeeded"&&I&&v.getIOSOTAInstall({limbuildApiUrl:e,token:n,execId:r.execId}).then(l).catch(f=>o(b(f)))},onError:s=>{c("failed"),o(s.message)}}),r.execId}catch(r){c("failed"),o(b(r));return}},[e,I,g,n]);return{status:w,logs:B,execId:h,otaInstall:x,error:E,startBuild:q,reset:m}}function b(e){return e instanceof Error?e.message:String(e)}exports.useDeviceBuild=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),f=require("../limbuild-client-CVDwq54z.js");require("../gsa-srp-CCIfUz7Y.js");require("../index-ChhtuQ7e.js");const b=require("../errors-BSkqS7U-.js");function m({apiUrl:s,token:d,signingAssets:g,loadOTAInstall:I=!1}){const[w,c]=e.useState("idle"),[B,a]=e.useState([]),[h,n]=e.useState(),[q,l]=e.useState(),[x,o]=e.useState(),t=e.useRef(void 0);e.useEffect(()=>()=>{t.current?.(),t.current=void 0},[]);const E=e.useCallback(()=>{t.current?.(),t.current=void 0,c("idle"),a([]),n(void 0),l(void 0),o(void 0)},[]),P=e.useCallback(async(S={})=>{if(!s)throw new Error("apiUrl is required to start a device build.");const u=S.signingAssets??g;if(!u)throw new Error("Signing assets are required to start a device build.");t.current?.(),c("queued"),a([]),n(void 0),l(void 0),o(void 0);try{const r=await f.startSignedDeviceBuild({limbuildApiUrl:s,token:d,certificateP12Base64:u.certificateP12Base64,certificatePassword:u.certificatePassword,provisioningProfileBase64:u.provisioningProfileBase64,signedUploadUrl:S.signedUploadUrl});if(!r.execId)throw new Error("Build request did not return an exec ID.");return n(r.execId),t.current=f.watchBuildLogEvents({limbuildApiUrl:s,token:d,execId:r.execId,onLine:i=>a(v=>[...v,i]),onStatus:i=>{c(i),i==="succeeded"&&I&&f.getIOSOTAInstall({limbuildApiUrl:s,token:d,execId:r.execId}).then(l).catch(v=>o(b.errorMessage(v)))},onError:i=>{c("failed"),o(i.message)}}),r.execId}catch(r){c("failed"),o(b.errorMessage(r));return}},[s,I,g,d]);return{status:w,logs:B,execId:h,otaInstall:q,error:x,startBuild:P,reset:E}}exports.useDeviceBuild=m;