@limrun/ui 0.14.0-rc.4 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +9 -26
  2. package/dist/components/remote-control.d.ts +36 -0
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +1189 -1089
  6. package/package.json +10 -51
  7. package/src/components/remote-control.tsx +267 -0
  8. package/src/index.ts +1 -1
  9. package/vite.config.ts +0 -9
  10. package/dist/app-store-relay/index.cjs +0 -9
  11. package/dist/app-store-relay/index.d.ts +0 -100
  12. package/dist/app-store-relay/index.js +0 -484
  13. package/dist/app-store-relay/react.cjs +0 -1
  14. package/dist/app-store-relay/react.d.ts +0 -15
  15. package/dist/app-store-relay/react.js +0 -69
  16. package/dist/apple-credentials/index.cjs +0 -1
  17. package/dist/apple-credentials/index.d.ts +0 -59
  18. package/dist/apple-credentials/index.js +0 -227
  19. package/dist/browser-storage-BnO-Ma-e.mjs +0 -219
  20. package/dist/browser-storage-DLxIqZk5.js +0 -1
  21. package/dist/client-D1drDXxE.js +0 -1
  22. package/dist/client-DSuNtWDv.mjs +0 -184
  23. package/dist/core/device-install/apple/client.d.ts +0 -18
  24. package/dist/core/device-install/apple/crypto.d.ts +0 -20
  25. package/dist/core/device-install/apple/gsa-srp.d.ts +0 -26
  26. package/dist/core/device-install/apple/index.d.ts +0 -5
  27. package/dist/core/device-install/apple/provisioning.d.ts +0 -212
  28. package/dist/core/device-install/apple/relay.d.ts +0 -40
  29. package/dist/core/device-install/index.d.ts +0 -4
  30. package/dist/core/device-install/operations/index.d.ts +0 -6
  31. package/dist/core/device-install/operations/limbuild-client.d.ts +0 -43
  32. package/dist/core/device-install/operations/operations.d.ts +0 -47
  33. package/dist/core/device-install/operations/relay-client.d.ts +0 -26
  34. package/dist/core/device-install/operations/relay-protocol.d.ts +0 -27
  35. package/dist/core/device-install/operations/usbmux.d.ts +0 -32
  36. package/dist/core/device-install/operations/webusb.d.ts +0 -21
  37. package/dist/core/device-install/storage/browser-storage.d.ts +0 -56
  38. package/dist/core/device-install/storage/index.d.ts +0 -2
  39. package/dist/core/device-install/storage/secret-store.d.ts +0 -101
  40. package/dist/core/device-install/types.d.ts +0 -57
  41. package/dist/core/errors.d.ts +0 -1
  42. package/dist/core/play-publish/google.d.ts +0 -13
  43. package/dist/core/play-publish/publish.d.ts +0 -34
  44. package/dist/device-build/index.cjs +0 -1
  45. package/dist/device-build/index.d.ts +0 -4
  46. package/dist/device-build/index.js +0 -85
  47. package/dist/device-build/react.cjs +0 -1
  48. package/dist/device-build/react.d.ts +0 -21
  49. package/dist/device-build/react.js +0 -68
  50. package/dist/device-build/signing.d.ts +0 -20
  51. package/dist/device-install/demo/demo.d.ts +0 -0
  52. package/dist/device-install/index.cjs +0 -1
  53. package/dist/device-install/index.d.ts +0 -18
  54. package/dist/device-install/index.js +0 -591
  55. package/dist/device-install/react.cjs +0 -1
  56. package/dist/device-install/react.d.ts +0 -24
  57. package/dist/device-install/react.js +0 -105
  58. package/dist/errors-BSkqS7U-.js +0 -1
  59. package/dist/errors-gy8yQJos.mjs +0 -6
  60. package/dist/gsa-srp-Bme3JLEi.mjs +0 -266
  61. package/dist/gsa-srp-CCIfUz7Y.js +0 -1
  62. package/dist/index-ChhtuQ7e.js +0 -22
  63. package/dist/index-YDu8K9a4.mjs +0 -11279
  64. package/dist/limbuild-client-BagK_FWE.mjs +0 -83
  65. package/dist/limbuild-client-CVDwq54z.js +0 -1
  66. package/dist/play-publish/index.cjs +0 -1
  67. package/dist/play-publish/index.d.ts +0 -2
  68. package/dist/play-publish/index.js +0 -109
  69. package/dist/play-publish/react.cjs +0 -1
  70. package/dist/play-publish/react.d.ts +0 -31
  71. package/dist/play-publish/react.js +0 -91
  72. package/dist/provisioning-B_DefBEp.mjs +0 -239
  73. package/dist/provisioning-BlQMccX_.js +0 -1
  74. package/src/app-store-relay/index.test.ts +0 -60
  75. package/src/app-store-relay/index.ts +0 -511
  76. package/src/app-store-relay/react.ts +0 -131
  77. package/src/apple-credentials/index.test.ts +0 -158
  78. package/src/apple-credentials/index.ts +0 -241
  79. package/src/core/device-install/apple/client.ts +0 -143
  80. package/src/core/device-install/apple/crypto.ts +0 -205
  81. package/src/core/device-install/apple/gsa-srp.ts +0 -123
  82. package/src/core/device-install/apple/index.ts +0 -5
  83. package/src/core/device-install/apple/provisioning.test.ts +0 -84
  84. package/src/core/device-install/apple/provisioning.ts +0 -380
  85. package/src/core/device-install/apple/relay.ts +0 -182
  86. package/src/core/device-install/index.ts +0 -4
  87. package/src/core/device-install/operations/index.ts +0 -6
  88. package/src/core/device-install/operations/limbuild-client.ts +0 -144
  89. package/src/core/device-install/operations/operations.ts +0 -234
  90. package/src/core/device-install/operations/relay-client.ts +0 -286
  91. package/src/core/device-install/operations/relay-protocol.ts +0 -71
  92. package/src/core/device-install/operations/usbmux.ts +0 -270
  93. package/src/core/device-install/operations/webusb-dom.d.ts +0 -54
  94. package/src/core/device-install/operations/webusb.ts +0 -110
  95. package/src/core/device-install/storage/browser-storage.test.ts +0 -65
  96. package/src/core/device-install/storage/browser-storage.ts +0 -325
  97. package/src/core/device-install/storage/index.ts +0 -2
  98. package/src/core/device-install/storage/secret-store.ts +0 -298
  99. package/src/core/device-install/types.ts +0 -69
  100. package/src/core/errors.ts +0 -3
  101. package/src/core/play-publish/google.ts +0 -113
  102. package/src/core/play-publish/publish.test.ts +0 -68
  103. package/src/core/play-publish/publish.ts +0 -89
  104. package/src/device-build/index.ts +0 -42
  105. package/src/device-build/react.ts +0 -130
  106. package/src/device-build/signing.ts +0 -94
  107. package/src/device-install/README.md +0 -423
  108. package/src/device-install/demo/demo.css +0 -493
  109. package/src/device-install/demo/demo.tsx +0 -1061
  110. package/src/device-install/demo/index.html +0 -12
  111. package/src/device-install/index.ts +0 -50
  112. package/src/device-install/react.ts +0 -195
  113. package/src/play-publish/README.md +0 -66
  114. package/src/play-publish/index.ts +0 -12
  115. package/src/play-publish/react.ts +0 -208
@@ -1,484 +0,0 @@
1
- import { p as D } from "../client-DSuNtWDv.mjs";
2
- import { A as Pe, f as he, o as qe, a as Be, b as Se, c as Ce, d as Re, s as Te, t as Ee, e as Ke } from "../client-DSuNtWDv.mjs";
3
- import { f as p } from "../index-YDu8K9a4.mjs";
4
- import { A as ke } from "../gsa-srp-Bme3JLEi.mjs";
5
- import { l as w, f as g, a as I, s as P, b as h, d as q, c as B, e as S, h as C, i as R, r as T, j as E, k as K, m as U, n as k, o as x } from "../provisioning-B_DefBEp.mjs";
6
- const F = {
7
- name: "RSASSA-PKCS1-v1_5",
8
- modulusLength: 2048,
9
- publicExponent: new Uint8Array([1, 0, 1]),
10
- hash: "SHA-256"
11
- };
12
- async function re(e) {
13
- if (!crypto.subtle)
14
- throw new Error("WebCrypto is not available in this browser.");
15
- const t = await crypto.subtle.generateKey(F, !0, ["sign", "verify"]), r = new Uint8Array(await crypto.subtle.exportKey("spki", t.publicKey)), n = l(
16
- $(0),
17
- N(e),
18
- r,
19
- L(0, new Uint8Array())
20
- ), i = new Uint8Array(
21
- await crypto.subtle.sign(
22
- "RSASSA-PKCS1-v1_5",
23
- t.privateKey,
24
- J(n)
25
- )
26
- ), o = l(
27
- n,
28
- l(b("1.2.840.113549.1.1.11"), H()),
29
- M(i)
30
- ), s = new Uint8Array(await crypto.subtle.exportKey("pkcs8", t.privateKey));
31
- return {
32
- privateKey: t.privateKey,
33
- privateKeyPKCS8Base64: d(s),
34
- publicKeySPKIBase64: d(r),
35
- csrPEM: j("CERTIFICATE REQUEST", o),
36
- csrBase64: d(o)
37
- };
38
- }
39
- function ne(e) {
40
- if (!e.certificateBase64 && !e.certificatePEM)
41
- throw new Error("certificateBase64 or certificatePEM is required.");
42
- const t = p.pki.privateKeyFromPem(V("PRIVATE KEY", e.privateKeyPKCS8Base64)), r = e.certificatePEM ? p.pki.certificateFromPem(e.certificatePEM) : p.pki.certificateFromAsn1(
43
- p.asn1.fromDer(p.util.createBuffer(z(e.certificateBase64)))
44
- ), n = p.pkcs12.toPkcs12Asn1(t, [r], e.password, {
45
- algorithm: "3des",
46
- friendlyName: e.friendlyName
47
- }), i = p.asn1.toDer(n).getBytes();
48
- return Q(i);
49
- }
50
- function N(e) {
51
- const t = [m("2.5.4.3", W(e.commonName))];
52
- return e.emailAddress && t.push(m("1.2.840.113549.1.9.1", G(e.emailAddress))), l(...t);
53
- }
54
- function m(e, t) {
55
- return O(l(b(e), t));
56
- }
57
- function l(...e) {
58
- return c(48, f(...e));
59
- }
60
- function O(...e) {
61
- return c(49, f(...e));
62
- }
63
- function L(e, t) {
64
- return c(160 + e, t);
65
- }
66
- function $(e) {
67
- return c(2, new Uint8Array([e]));
68
- }
69
- function H() {
70
- return new Uint8Array([5, 0]);
71
- }
72
- function W(e) {
73
- return c(12, new TextEncoder().encode(e));
74
- }
75
- function G(e) {
76
- return c(22, new TextEncoder().encode(e));
77
- }
78
- function M(e) {
79
- return c(3, f(new Uint8Array([0]), e));
80
- }
81
- function b(e) {
82
- const t = e.split(".").map((n) => parseInt(n, 10));
83
- if (t.length < 2 || t.some((n) => !Number.isFinite(n)))
84
- throw new Error(`Invalid OID: ${e}`);
85
- const r = [t[0] * 40 + t[1]];
86
- for (const n of t.slice(2)) {
87
- const i = [n & 127];
88
- let o = n >> 7;
89
- for (; o > 0; )
90
- i.unshift(o & 127 | 128), o >>= 7;
91
- r.push(...i);
92
- }
93
- return c(6, new Uint8Array(r));
94
- }
95
- function c(e, t) {
96
- return f(new Uint8Array([e]), _(t.byteLength), t);
97
- }
98
- function _(e) {
99
- if (e < 128)
100
- return new Uint8Array([e]);
101
- const t = [];
102
- let r = e;
103
- for (; r > 0; )
104
- t.unshift(r & 255), r >>= 8;
105
- return new Uint8Array([128 | t.length, ...t]);
106
- }
107
- function f(...e) {
108
- const t = e.reduce((i, o) => i + o.byteLength, 0), r = new Uint8Array(t);
109
- let n = 0;
110
- for (const i of e)
111
- r.set(i, n), n += i.byteLength;
112
- return r;
113
- }
114
- function j(e, t) {
115
- const n = d(t).match(/.{1,64}/g) ?? [];
116
- return `-----BEGIN ${e}-----
117
- ${n.join(`
118
- `)}
119
- -----END ${e}-----
120
- `;
121
- }
122
- function V(e, t) {
123
- const r = t.match(/.{1,64}/g) ?? [];
124
- return `-----BEGIN ${e}-----
125
- ${r.join(`
126
- `)}
127
- -----END ${e}-----
128
- `;
129
- }
130
- function d(e) {
131
- let t = "";
132
- for (const r of e)
133
- t += String.fromCharCode(r);
134
- return btoa(t);
135
- }
136
- function Q(e) {
137
- return btoa(e);
138
- }
139
- function z(e) {
140
- return atob(e);
141
- }
142
- function J(e) {
143
- const t = new Uint8Array(e.byteLength);
144
- return t.set(e), t.buffer;
145
- }
146
- async function a({
147
- relay: e,
148
- request: t,
149
- label: r = "Apple Developer Portal request",
150
- validatePortalResponse: n = !0,
151
- mapBody: i
152
- }) {
153
- const o = await D(e, t);
154
- return n && X(o.body, r), i ? i(o.body, o) : o;
155
- }
156
- async function ie(e) {
157
- return a({
158
- ...e,
159
- request: w(),
160
- label: "Apple Developer team list",
161
- mapBody: (t) => Y([
162
- ...t?.teams ?? [],
163
- ...t?.availableProviders ?? [],
164
- ...t?.provider ? [t.provider] : []
165
- ])
166
- });
167
- }
168
- async function oe({
169
- certificateKind: e = "development",
170
- teamId: t = "",
171
- ...r
172
- }) {
173
- return a({
174
- ...r,
175
- request: e === "distribution" ? g(t) : I(t),
176
- label: "Apple Developer certificate list",
177
- mapBody: (n) => n?.certRequests ?? []
178
- });
179
- }
180
- async function ae({
181
- certificateKind: e = "development",
182
- teamId: t = "",
183
- csrPEM: r,
184
- ...n
185
- }) {
186
- return a({
187
- ...n,
188
- request: e === "distribution" ? P({ csrPEM: r, teamID: t }) : h({ csrPEM: r, teamID: t }),
189
- label: e === "distribution" ? "Apple Distribution certificate creation" : "Apple Development certificate creation",
190
- mapBody: (i) => i?.certRequest
191
- });
192
- }
193
- async function se({
194
- certificateKind: e = "development",
195
- certificateId: t,
196
- teamId: r = "",
197
- ...n
198
- }) {
199
- return a({
200
- ...n,
201
- request: e === "distribution" ? q(t, r) : B(t, r),
202
- label: "Apple certificate download",
203
- validatePortalResponse: !1,
204
- mapBody: (i, o) => o
205
- });
206
- }
207
- async function ce({
208
- certificateKind: e = "development",
209
- certificateId: t,
210
- teamId: r = "",
211
- ...n
212
- }) {
213
- return a({
214
- ...n,
215
- request: {
216
- method: "POST",
217
- path: "/account/ios/certificate/revokeCertificate.action",
218
- payload: {
219
- teamId: r,
220
- certificateId: t,
221
- type: e === "distribution" ? "WXV89964HE" : "83Q87W3TGH"
222
- }
223
- },
224
- label: "Apple certificate deletion",
225
- mapBody: (i) => i
226
- });
227
- }
228
- async function pe({
229
- teamId: e = "",
230
- search: t = "",
231
- ...r
232
- }) {
233
- const n = t.trim().toLowerCase();
234
- return a({
235
- ...r,
236
- request: S({ bundleID: t, teamID: e }),
237
- label: "Apple bundle ID list",
238
- // Apple's listAppIds.action returns the full paginated list and does not
239
- // honor a server-side search filter, so apply the `search` filter here.
240
- mapBody: (i) => {
241
- const o = i?.appIds ?? [];
242
- return n ? o.filter(
243
- (s) => [s.identifier, s.bundleId, s.name].some(
244
- (u) => typeof u == "string" && u.toLowerCase().includes(n)
245
- )
246
- ) : o;
247
- }
248
- });
249
- }
250
- async function le({
251
- teamId: e = "",
252
- bundleId: t,
253
- name: r,
254
- ...n
255
- }) {
256
- return a({
257
- ...n,
258
- request: C({ bundleID: t, teamID: e, name: r }),
259
- label: "Apple bundle ID creation",
260
- mapBody: (i) => i?.appId
261
- });
262
- }
263
- async function ue({
264
- teamId: e = "",
265
- appIdId: t,
266
- bundleId: r,
267
- name: n,
268
- ...i
269
- }) {
270
- return a({
271
- ...i,
272
- request: {
273
- method: "POST",
274
- path: "/account/ios/identifiers/updateAppId.action",
275
- payload: {
276
- teamId: e,
277
- appIdId: t,
278
- ...r ? { identifier: r } : {},
279
- ...n ? { name: n } : {}
280
- }
281
- },
282
- label: "Apple bundle ID update",
283
- mapBody: (o) => o?.appId
284
- });
285
- }
286
- async function de({ teamId: e = "", appIdId: t, ...r }) {
287
- return a({
288
- ...r,
289
- request: {
290
- method: "POST",
291
- path: "/account/ios/identifiers/deleteAppId.action",
292
- payload: { teamId: e, appIdId: t }
293
- },
294
- label: "Apple bundle ID deletion",
295
- mapBody: (n) => n
296
- });
297
- }
298
- async function fe({
299
- teamId: e = "",
300
- deviceUDID: t = "",
301
- ...r
302
- }) {
303
- const n = A(t);
304
- return a({
305
- ...r,
306
- request: R({ deviceUDID: t, teamID: e }),
307
- label: "Apple device list",
308
- // Apple's listDevices.action returns the full paginated list and does not
309
- // honor a server-side UDID filter, so apply the `deviceUDID` filter here.
310
- mapBody: (i) => {
311
- const o = i?.devices ?? [];
312
- return n ? o.filter((s) => A(s.deviceNumber) === n) : o;
313
- }
314
- });
315
- }
316
- function A(e) {
317
- return (e ?? "").replace(/-/g, "").replace(/[^a-fA-F0-9]/g, "").toUpperCase();
318
- }
319
- async function ye({
320
- teamId: e = "",
321
- deviceUDID: t,
322
- name: r,
323
- ...n
324
- }) {
325
- return a({
326
- ...n,
327
- request: T({ deviceUDID: t, teamID: e, name: r }),
328
- label: "Apple device registration",
329
- mapBody: (i) => i?.device
330
- });
331
- }
332
- async function me({
333
- teamId: e = "",
334
- deviceId: t,
335
- name: r,
336
- ...n
337
- }) {
338
- return a({
339
- ...n,
340
- request: {
341
- method: "POST",
342
- path: "/account/ios/device/updateDevice.action",
343
- payload: { teamId: e, deviceId: t, ...r ? { name: r } : {} }
344
- },
345
- label: "Apple device update",
346
- mapBody: (i) => i?.device
347
- });
348
- }
349
- async function Ae({ teamId: e = "", deviceId: t, ...r }) {
350
- return a({
351
- ...r,
352
- request: {
353
- method: "POST",
354
- path: "/account/ios/device/deleteDevice.action",
355
- payload: { teamId: e, deviceId: t }
356
- },
357
- label: "Apple device deletion",
358
- mapBody: (n) => n
359
- });
360
- }
361
- async function be({
362
- profileKind: e = "development",
363
- teamId: t = "",
364
- bundleId: r = "",
365
- ...n
366
- }) {
367
- return a({
368
- ...n,
369
- request: e === "adhoc" ? E({ bundleID: r, teamID: t }) : K({ bundleID: r, teamID: t }),
370
- label: "Apple provisioning profile list",
371
- mapBody: (i) => i?.provisioningProfiles ?? []
372
- });
373
- }
374
- async function ve({
375
- profileKind: e = "development",
376
- teamId: t = "",
377
- bundleId: r,
378
- appIdId: n,
379
- certificateIds: i,
380
- deviceIds: o,
381
- name: s,
382
- ...u
383
- }) {
384
- const [y] = i;
385
- if (!y)
386
- throw new Error("At least one certificate ID is required to create an Apple provisioning profile.");
387
- return a({
388
- ...u,
389
- request: e === "adhoc" ? U({
390
- bundleID: r,
391
- teamID: t,
392
- appIDID: n,
393
- certificateID: y,
394
- deviceIDs: o,
395
- name: s
396
- }) : k({
397
- bundleID: r,
398
- teamID: t,
399
- appIDID: n,
400
- certificateID: y,
401
- deviceIDs: o,
402
- name: s
403
- }),
404
- label: "Apple provisioning profile creation",
405
- mapBody: (v) => v?.provisioningProfile
406
- });
407
- }
408
- async function De({
409
- teamId: e = "",
410
- profileId: t,
411
- ...r
412
- }) {
413
- return a({
414
- ...r,
415
- request: x(t, e),
416
- label: "Apple provisioning profile download",
417
- validatePortalResponse: !1,
418
- mapBody: (n, i) => i
419
- });
420
- }
421
- async function we({ teamId: e = "", profileId: t, ...r }) {
422
- return a({
423
- ...r,
424
- request: {
425
- method: "POST",
426
- path: "/account/ios/profile/deleteProvisioningProfile.action",
427
- payload: { teamId: e, provisioningProfileId: t }
428
- },
429
- label: "Apple provisioning profile deletion",
430
- mapBody: (n) => n
431
- });
432
- }
433
- function X(e, t) {
434
- if (!e)
435
- throw new Error(`${t} returned an empty response.`);
436
- if (e.resultCode !== void 0 && e.resultCode !== 0)
437
- throw new Error(
438
- `${t} failed: ${e.userString ?? e.resultString ?? e.resultCode}`
439
- );
440
- }
441
- function Y(e) {
442
- const t = /* @__PURE__ */ new Set(), r = [];
443
- for (const n of e) {
444
- const i = String(
445
- n.teamId ?? n.providerId ?? n.publicProviderId ?? n.name ?? JSON.stringify(n)
446
- );
447
- t.has(i) || (t.add(i), r.push(n));
448
- }
449
- return r;
450
- }
451
- export {
452
- ke as AppleGsaSrpClient,
453
- Pe as AppleRelayWebSocketClient,
454
- X as assertAppleDeveloperPortalResponseOK,
455
- le as createAppleBundleID,
456
- ae as createAppleCertificate,
457
- ve as createAppleProfile,
458
- de as deleteAppleBundleID,
459
- ce as deleteAppleCertificate,
460
- Ae as deleteAppleDevice,
461
- we as deleteAppleProfile,
462
- se as downloadAppleCertificate,
463
- De as downloadAppleProfile,
464
- ne as exportAppleCertificateP12,
465
- he as fetchAppleAccountSession,
466
- re as generateAppleSigningKeyAndCSR,
467
- pe as listAppleBundleIDs,
468
- oe as listAppleCertificates,
469
- fe as listAppleDevices,
470
- be as listAppleProfiles,
471
- ie as listAppleTeams,
472
- qe as openAppleRelayWebSocket,
473
- Be as proxyPhoneTwoFactorCode,
474
- Se as proxySrpComplete,
475
- Ce as proxySrpInit,
476
- Re as proxyTwoFactorCode,
477
- ye as registerAppleDevice,
478
- a as requestAppleProvisioning,
479
- Te as startBrowserOwnedAppleIDLogin,
480
- Ee as triggerPhoneTwoFactor,
481
- Ke as triggerTrustedDeviceTwoFactor,
482
- ue as updateAppleBundleID,
483
- me as updateAppleDevice
484
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),y=require("../client-D1drDXxE.js");require("../index-ChhtuQ7e.js");require("../gsa-srp-CCIfUz7Y.js");const w=require("../errors-BSkqS7U-.js");function m({registryApiUrl:i,token:u,organizationId:l}){const[g,o]=t.useState("idle"),[h,a]=t.useState(),[v,d]=t.useState(),[f,p]=t.useState(),[S,n]=t.useState(),r=t.useRef(void 0),b=t.useCallback(async()=>{await r.current?.close().catch(()=>{}),r.current=void 0,a(void 0),d(void 0),p(void 0),n(void 0),o("idle")},[]);t.useEffect(()=>()=>{r.current?.close(),r.current=void 0},[]);const C=t.useCallback(async({accountName:s,password:c})=>{o("authenticating"),n(void 0),await r.current?.close().catch(()=>{});try{const e=await y.startBrowserOwnedAppleIDLogin({registryApiUrl:i,token:u,organizationId:l,accountName:s,password:c});return r.current=e,a(e),d(e.completeResponse),p(e.twoFactorChallengeResponse),o(e.requiresTwoFactor?"two-factor-required":"authenticated"),e}catch(e){a(void 0),r.current=void 0,n(w.errorMessage(e)),o("error");return}},[i,l,u]),R=t.useCallback(async s=>{const c=r.current;if(!c)throw new Error("Start Apple ID login before submitting a two-factor code.");o("authenticating"),n(void 0);try{const e=await c.finishTwoFactor(s);return o("authenticated"),e}catch(e){n(w.errorMessage(e)),o("error");return}},[]),q=t.useCallback(async()=>{const s=r.current;if(!s)throw new Error("Start Apple ID login before finalizing the Apple session.");return s.finalize()},[]);return{status:g,session:h,completeResponse:v,twoFactorChallengeResponse:f,error:S,startLogin:C,submitTwoFactorCode:R,finalize:q,close:b}}exports.useAppleIDLogin=m;
@@ -1,15 +0,0 @@
1
- import { AppleIDLoginInput, AppleIDLoginResult, AppleRelayResponse } from './index';
2
- export type UseAppleIDLoginOptions = Pick<AppleIDLoginInput, 'registryApiUrl' | 'token' | 'organizationId'>;
3
- export type AppleIDLoginStatus = 'idle' | 'authenticating' | 'two-factor-required' | 'authenticated' | 'error';
4
- export type UseAppleIDLoginResult = {
5
- status: AppleIDLoginStatus;
6
- session?: AppleIDLoginResult;
7
- completeResponse?: AppleRelayResponse;
8
- twoFactorChallengeResponse?: AppleRelayResponse;
9
- error?: string;
10
- startLogin: (input: Pick<AppleIDLoginInput, 'accountName' | 'password'>) => Promise<AppleIDLoginResult | undefined>;
11
- submitTwoFactorCode: (code: string) => Promise<AppleRelayResponse | undefined>;
12
- finalize: () => Promise<AppleRelayResponse | undefined>;
13
- close: () => Promise<void>;
14
- };
15
- export declare function useAppleIDLogin({ registryApiUrl, token, organizationId, }: UseAppleIDLoginOptions): UseAppleIDLoginResult;
@@ -1,69 +0,0 @@
1
- import { useState as n, useRef as S, useCallback as i, useEffect as A } from "react";
2
- import { s as D } from "../client-DSuNtWDv.mjs";
3
- import "../index-YDu8K9a4.mjs";
4
- import "../gsa-srp-Bme3JLEi.mjs";
5
- import { e as w } from "../errors-gy8yQJos.mjs";
6
- function x({
7
- registryApiUrl: u,
8
- token: l,
9
- organizationId: p
10
- }) {
11
- const [h, o] = n("idle"), [v, a] = n(), [g, d] = n(), [m, f] = n(), [R, s] = n(), t = S(void 0), C = i(async () => {
12
- await t.current?.close().catch(() => {
13
- }), t.current = void 0, a(void 0), d(void 0), f(void 0), s(void 0), o("idle");
14
- }, []);
15
- A(() => () => {
16
- t.current?.close(), t.current = void 0;
17
- }, []);
18
- const F = i(
19
- async ({ accountName: r, password: c }) => {
20
- o("authenticating"), s(void 0), await t.current?.close().catch(() => {
21
- });
22
- try {
23
- const e = await D({
24
- registryApiUrl: u,
25
- token: l,
26
- organizationId: p,
27
- accountName: r,
28
- password: c
29
- });
30
- return t.current = e, a(e), d(e.completeResponse), f(e.twoFactorChallengeResponse), o(e.requiresTwoFactor ? "two-factor-required" : "authenticated"), e;
31
- } catch (e) {
32
- a(void 0), t.current = void 0, s(w(e)), o("error");
33
- return;
34
- }
35
- },
36
- [u, p, l]
37
- ), b = i(async (r) => {
38
- const c = t.current;
39
- if (!c)
40
- throw new Error("Start Apple ID login before submitting a two-factor code.");
41
- o("authenticating"), s(void 0);
42
- try {
43
- const e = await c.finishTwoFactor(r);
44
- return o("authenticated"), e;
45
- } catch (e) {
46
- s(w(e)), o("error");
47
- return;
48
- }
49
- }, []), y = i(async () => {
50
- const r = t.current;
51
- if (!r)
52
- throw new Error("Start Apple ID login before finalizing the Apple session.");
53
- return r.finalize();
54
- }, []);
55
- return {
56
- status: h,
57
- session: v,
58
- completeResponse: g,
59
- twoFactorChallengeResponse: m,
60
- error: R,
61
- startLogin: F,
62
- submitTwoFactorCode: b,
63
- finalize: y,
64
- close: C
65
- };
66
- }
67
- export {
68
- x as useAppleIDLogin
69
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../app-store-relay/index.cjs"),E=require("../browser-storage-DLxIqZk5.js"),A="appleCertificate",P="appleProvisioningProfile";function b(r){const e={};for(const[o,i]of Object.entries(r))i&&(e[o]=i);return e}async function T(r,e,o){return r.put(A,e,b(o))}async function I(r,e,o){return r.put(P,e,b(o))}function R(r){const e=r.fetch??fetch.bind(globalThis),o=r.apiUrl.replace(/\/+$/,""),i=(t,s)=>`${o}/v1/organizations/${encodeURIComponent(r.organizationId)}/secrets/${encodeURIComponent(t)}/${encodeURIComponent(s)}`,c={Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"};async function a(t,s){let n=`${t.status}`;try{const d=await t.json();d.message&&(n=d.message)}catch{}throw new Error(`Failed to ${s} secret: ${n}`)}return{async put(t,s,n){const d=await e(i(t,s),{method:"PUT",headers:c,body:JSON.stringify({data:n,replace:!0})});d.ok||await a(d,"store");const f=await d.json();return{type:f.type,name:f.name,createdAt:f.createdAt,data:f.data}},async get(t,s){const n=await e(i(t,s),{method:"GET",headers:c});if(n.status===404)return;n.ok||await a(n,"fetch");const d=await n.json();return{type:d.type,name:d.name,createdAt:d.createdAt,data:d.data}},async list(){const t=await e(`${o}/v1/organizations/${encodeURIComponent(r.organizationId)}/secrets`,{method:"GET",headers:c});return t.ok||await a(t,"list"),(await t.json()).filter(n=>n.type===A||n.type===P).map(n=>({type:n.type,name:n.name,createdAt:n.createdAt}))},async delete(t,s){const n=await e(i(t,s),{method:"DELETE",headers:c});n.status!==404&&(n.ok||await a(n,"delete"))}}}const B="limrun-signing-secrets",$=1,p="secrets";function _(){const r=(i,c)=>`${i}:${c}`;function e(){return new Promise((i,c)=>{const a=indexedDB.open(B,$);a.onupgradeneeded=()=>{const t=a.result;t.objectStoreNames.contains(p)||t.createObjectStore(p,{keyPath:"id"})},a.onsuccess=()=>i(a.result),a.onerror=()=>c(a.error??new Error("Open IndexedDB failed"))})}function o(i){return new Promise((c,a)=>{i.onsuccess=()=>c(i.result),i.onerror=()=>a(i.error??new Error("IndexedDB request failed"))})}return{async put(i,c,a){const t=await e(),s=await o(t.transaction(p,"readonly").objectStore(p).get(r(i,c))),n={id:r(i,c),type:i,name:c,data:a,createdAt:s?.createdAt??new Date().toISOString()};return await o(t.transaction(p,"readwrite").objectStore(p).put(n)),{type:i,name:c,createdAt:n.createdAt,data:a}},async get(i,c){const a=await e(),t=await o(a.transaction(p,"readonly").objectStore(p).get(r(i,c)));if(t)return{type:t.type,name:t.name,createdAt:t.createdAt,data:t.data}},async list(){const i=await e();return(await o(i.transaction(p,"readonly").objectStore(p).getAll())).map(a=>({type:a.type,name:a.name,createdAt:a.createdAt}))},async delete(i,c){const a=await e();await o(a.transaction(p,"readwrite").objectStore(p).delete(r(i,c)))}}}function h(r,e){return`${r}/${e}`}async function N({relay:r,teamId:e,secretStore:o,commonName:i,log:c=()=>{}}){const a="DEVELOPMENT",t=h(e,a),s=await S.listAppleCertificates({relay:r,teamId:e,certificateKind:"development"}),n=u=>u===void 0?void 0:s.find(m=>l(m,"certificateId")===u||l(m,"certRequestId")===u),d=await o.get(A,t),f=l(d?.data,"certificateID");if(d&&f&&d.data.certificateP12Base64){const u=n(f);if(u){const m=l(u,"certificateId")??f;return c("Reusing stored Apple certificate",m),{secret:d,certificateId:m,created:!1}}c("Stored certificate is no longer on the team","Minting a new one.")}const g=await S.generateAppleSigningKeyAndCSR({commonName:i??`Limrun ${e}`}),y=await S.createAppleCertificate({relay:r,teamId:e,certificateKind:"development",csrPEM:g.csrPEM}),w=l(y,"certificateId")??l(y,"certRequestId");if(!w)throw new Error("Apple certificate creation did not return a certificate ID.");const v=await S.downloadAppleCertificate({relay:r,teamId:e,certificateKind:"development",certificateId:w});if(!v.rawBodyBase64)throw new Error("Apple certificate download returned no bytes.");const D={certificateP12Base64:S.exportAppleCertificateP12({privateKeyPKCS8Base64:g.privateKeyPKCS8Base64,certificateBase64:v.rawBodyBase64,password:"",friendlyName:`Apple Development ${e}`}),certificateType:a,teamID:e,certificateID:w,serialNumber:E.normalizeCertificateSerial(l(y,"serialNum")),expirationDate:l(y,"expirationDateString")};let C;try{C=await T(o,t,D)}catch(u){throw new Error(`Certificate ${w} was created on the Apple Developer portal but saving its private key to the secret store failed: ${O(u)}. The key cannot be recovered; revoke certificate ${w} at developer.apple.com before retrying, or the retry will mint another certificate against Apple's limit.`)}return c("Apple certificate stored",w),{secret:C,certificateId:w,created:!0}}function O(r){return r instanceof Error?r.message:String(r)}async function j({relay:r,teamId:e,profileId:o,secretStore:i,log:c=()=>{}}){const t=(await S.downloadAppleProfile({relay:r,teamId:e,profileId:o})).rawBodyBase64;if(!t)throw new Error("Apple provisioning profile download returned no bytes.");const s=E.parseProvisioningProfileBase64(t),n=`${e}/${s.uuid??o}`,d=await I(i,n,{provisioningProfileBase64:t,certificateSerialNumbers:s.certificateSerialNumbers.join(","),bundleIDs:s.bundleID,deviceIDs:s.provisionedDevices.join(","),teamID:s.teamID??e,profileName:s.name,uuid:s.uuid,expirationDate:s.expirationDate});return c("Apple provisioning profile stored",n),d}async function k({relay:r,teamId:e}){return S.listAppleProfiles({relay:r,teamId:e,profileKind:"development"})}function l(r,e){const o=r?.[e];if(typeof o=="string")return o;if(typeof o=="number"||typeof o=="boolean")return String(o)}exports.normalizeCertificateSerial=E.normalizeCertificateSerial;exports.APPLE_CERTIFICATE_SECRET_TYPE=A;exports.APPLE_PROVISIONING_PROFILE_SECRET_TYPE=P;exports.appleCertificateSecretName=h;exports.createBrowserSecretStore=_;exports.createLimrunSecretStore=R;exports.ensureAppleCertificateSecret=N;exports.listTeamAppleProfiles=k;exports.putAppleCertificateSecret=T;exports.putAppleProvisioningProfileSecret=I;exports.saveAppleProfileSecret=j;exports.stringField=l;
@@ -1,59 +0,0 @@
1
- import { AppleRelayWebSocketClient } from '../core/device-install/apple';
2
- import { AppleCertificateType, SigningSecret, SigningSecretStore } from '../core/device-install/storage/secret-store';
3
- export { APPLE_CERTIFICATE_SECRET_TYPE, APPLE_PROVISIONING_PROFILE_SECRET_TYPE, createBrowserSecretStore, createLimrunSecretStore, putAppleCertificateSecret, putAppleProvisioningProfileSecret, type AppleCertificateSecretData, type AppleCertificateType, type AppleProvisioningProfileSecretData, type LimrunSecretStoreOptions, type SigningSecret, type SigningSecretData, type SigningSecretMetadata, type SigningSecretStore, type SigningSecretType, } from '../core/device-install/storage/secret-store';
4
- export { normalizeCertificateSerial } from '../core/device-install/storage/browser-storage';
5
- /**
6
- * Conventional secret name of a team's certificate bundle. One bundle per
7
- * team and Apple certificate type; the type is in the name so development
8
- * and distribution material never collide.
9
- */
10
- export declare function appleCertificateSecretName(teamId: string, certificateType: AppleCertificateType): string;
11
- export type EnsureAppleCertificateInput = {
12
- relay: AppleRelayWebSocketClient;
13
- teamId: string;
14
- secretStore: SigningSecretStore;
15
- /** Common name used when minting a new certificate. */
16
- commonName?: string;
17
- log?: (message: string, detail?: string) => void;
18
- };
19
- export type EnsureAppleCertificateResult = {
20
- secret: SigningSecret;
21
- certificateId: string;
22
- /** True when a new certificate was minted instead of reusing the stored one. */
23
- created: boolean;
24
- };
25
- /**
26
- * Returns a usable development certificate secret for the team, reusing the
27
- * stored one when its certificate is still on the team and minting a new
28
- * one otherwise. Apple caps development certificates at 2 and never returns
29
- * private keys, so reuse of the stored p12 is strongly preferred.
30
- *
31
- * Durability of the stored material is the secret store's concern:
32
- * implementors who want retries or fallbacks build them into their
33
- * SigningSecretStore.
34
- */
35
- export declare function ensureAppleCertificateSecret({ relay, teamId, secretStore, commonName, log, }: EnsureAppleCertificateInput): Promise<EnsureAppleCertificateResult>;
36
- export type SaveAppleProfileInput = {
37
- relay: AppleRelayWebSocketClient;
38
- teamId: string;
39
- profileId: string;
40
- secretStore: SigningSecretStore;
41
- log?: (message: string, detail?: string) => void;
42
- };
43
- /**
44
- * Downloads the provisioning profile and stores it as an
45
- * appleProvisioningProfile secret named `${teamId}/${uuid}`. The UUID is
46
- * unique per profile, so a team can hold many profiles for the same
47
- * bundle ID and certificate set; the reference fields (certificate
48
- * serials, bundle IDs, device IDs parsed out of the profile) are what
49
- * consumers filter on.
50
- */
51
- export declare function saveAppleProfileSecret({ relay, teamId, profileId, secretStore, log, }: SaveAppleProfileInput): Promise<SigningSecret>;
52
- export type ListTeamProfilesInput = {
53
- relay: AppleRelayWebSocketClient;
54
- teamId: string;
55
- };
56
- /** Lists the team's development provisioning profiles from the portal. */
57
- export declare function listTeamAppleProfiles({ relay, teamId }: ListTeamProfilesInput): Promise<Record<string, unknown>[]>;
58
- /** Read a string-ish value from a loosely typed portal record. */
59
- export declare function stringField(record: Record<string, unknown> | undefined, key: string): string | undefined;