@limrun/ui 0.9.0-rc.9 → 0.13.3

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 (80) hide show
  1. package/README.md +25 -8
  2. package/dist/app-store-relay/index.cjs +9 -0
  3. package/dist/app-store-relay/index.d.ts +102 -0
  4. package/dist/app-store-relay/index.js +486 -0
  5. package/dist/app-store-relay/react.cjs +1 -0
  6. package/dist/app-store-relay/react.d.ts +15 -0
  7. package/dist/app-store-relay/react.js +65 -0
  8. package/dist/browser-storage-Cx9eW-bm.mjs +205 -0
  9. package/dist/browser-storage-jJaIht4K.js +1 -0
  10. package/dist/client-ASLtHFLh.js +1 -0
  11. package/dist/client-CGdh8yoJ.mjs +234 -0
  12. package/dist/components/device-install/index.d.ts +1 -2
  13. package/dist/core/device-install/apple/provisioning.d.ts +58 -7
  14. package/dist/core/device-install/operations/limbuild-client.d.ts +15 -1
  15. package/dist/core/device-install/storage/browser-storage.d.ts +9 -5
  16. package/dist/core/device-install/types.d.ts +4 -1
  17. package/dist/device-build/index.cjs +1 -0
  18. package/dist/device-build/index.d.ts +4 -0
  19. package/dist/device-build/index.js +84 -0
  20. package/dist/device-build/react.cjs +1 -0
  21. package/dist/device-build/react.d.ts +20 -0
  22. package/dist/device-build/react.js +68 -0
  23. package/dist/device-build/signing.d.ts +20 -0
  24. package/dist/device-install/demo/demo.d.ts +0 -0
  25. package/dist/device-install/index.cjs +1 -1
  26. package/dist/device-install/index.d.ts +18 -3
  27. package/dist/device-install/index.js +583 -76
  28. package/dist/device-install/react.cjs +1 -1
  29. package/dist/device-install/react.d.ts +23 -1
  30. package/dist/device-install/react.js +98 -2
  31. package/dist/hooks/index.d.ts +1 -1
  32. package/dist/index-CMeQfhYy.js +22 -0
  33. package/dist/index-DFdCvi2_.mjs +11543 -0
  34. package/dist/index.cjs +1 -1
  35. package/dist/index.d.ts +0 -2
  36. package/dist/index.js +502 -495
  37. package/dist/limbuild-client-CgEncrgx.js +1 -0
  38. package/dist/limbuild-client-D7U7w342.mjs +81 -0
  39. package/dist/provisioning-DKbkBO-p.mjs +239 -0
  40. package/dist/provisioning-Va0PH4Kk.js +1 -0
  41. package/package.json +21 -1
  42. package/src/app-store-relay/index.test.ts +70 -0
  43. package/src/app-store-relay/index.ts +514 -0
  44. package/src/app-store-relay/react.ts +129 -0
  45. package/src/components/device-install/index.ts +1 -2
  46. package/src/core/device-install/apple/client.ts +29 -22
  47. package/src/core/device-install/apple/crypto.ts +9 -6
  48. package/src/core/device-install/apple/gsa-srp.ts +3 -7
  49. package/src/core/device-install/apple/provisioning.test.ts +84 -0
  50. package/src/core/device-install/apple/provisioning.ts +98 -16
  51. package/src/core/device-install/apple/relay.ts +5 -1
  52. package/src/core/device-install/operations/limbuild-client.ts +41 -4
  53. package/src/core/device-install/operations/operations.ts +3 -1
  54. package/src/core/device-install/operations/relay-client.ts +57 -27
  55. package/src/core/device-install/operations/usbmux.ts +3 -3
  56. package/src/core/device-install/operations/webusb.ts +9 -4
  57. package/src/core/device-install/storage/browser-storage.ts +43 -14
  58. package/src/core/device-install/types.ts +6 -8
  59. package/src/device-build/index.ts +42 -0
  60. package/src/device-build/react.ts +131 -0
  61. package/src/device-build/signing.ts +94 -0
  62. package/src/device-install/README.md +423 -0
  63. package/src/device-install/demo/demo.css +493 -0
  64. package/src/device-install/demo/demo.tsx +1069 -0
  65. package/src/device-install/demo/index.html +12 -0
  66. package/src/device-install/index.ts +49 -3
  67. package/src/device-install/react.ts +189 -1
  68. package/src/hooks/index.ts +1 -1
  69. package/src/index.ts +0 -3
  70. package/vite.config.ts +4 -0
  71. package/dist/components/device-install/device-install-dialog.d.ts +0 -5
  72. package/dist/device-install-dialog-CqxDEH85.mjs +0 -443
  73. package/dist/device-install-dialog-jvqQ-fuo.js +0 -2
  74. package/dist/device-install-dialog.css +0 -1
  75. package/dist/hooks/use-device-install.d.ts +0 -73
  76. package/dist/use-device-install-CAPli9MR.js +0 -31
  77. package/dist/use-device-install-H8dqqvbR.mjs +0 -13624
  78. package/src/components/device-install/device-install-dialog.css +0 -325
  79. package/src/components/device-install/device-install-dialog.tsx +0 -495
  80. package/src/hooks/use-device-install.ts +0 -1219
@@ -0,0 +1 @@
1
+ "use strict";async function l(o,t){const a=new URL(`${o}/info`);t&&a.searchParams.set("token",t);const e=await fetch(a.toString(),{headers:t?{Authorization:`Bearer ${t}`}:void 0});if(!e.ok){const n=await e.text();throw new Error(`Info request failed: HTTP ${e.status} ${n}`)}return await e.json()}async function u({limbuildApiUrl:o,token:t,certificateP12Base64:a,certificatePassword:e,provisioningProfileBase64:n}){const d=new URL(`${o}/exec`);t&&d.searchParams.set("token",t);const r=await fetch(d.toString(),{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify({command:"xcodebuild",xcodebuild:{sdk:"iphoneos"},signing:{certificateP12Base64:a,...e?{certificatePassword:e}:{},provisioningProfileBase64:n}})});if(!r.ok){const s=await r.text();throw new Error(`Build request failed: HTTP ${r.status} ${s}`)}return await r.json()}async function f({limbuildApiUrl:o,execId:t,token:a}){const e=new URL(`${o}/exec/${encodeURIComponent(t)}/ios/ota`);a&&e.searchParams.set("token",a);const n=await fetch(e.toString(),{headers:a?{Authorization:`Bearer ${a}`}:void 0});if(!n.ok){const d=await n.text();throw new Error(`OTA install metadata failed: HTTP ${n.status} ${d}`)}return await n.json()}function h({limbuildApiUrl:o,execId:t,token:a,onLine:e,onStatus:n,onError:d}){const r=new URL(`${o}/exec/${t}/events`);a&&r.searchParams.set("token",a);const s=new EventSource(r.toString());return n("running"),s.addEventListener("command",i=>e({type:"command",data:i.data})),s.addEventListener("stdout",i=>e({type:"stdout",data:i.data})),s.addEventListener("stderr",i=>e({type:"stderr",data:i.data})),s.addEventListener("exitCode",i=>{const c=parseInt(i.data,10);n(c===0?"succeeded":c<0?"cancelled":"failed"),s.close()}),s.onerror=()=>{s.close(),n("failed"),d?.(new Error("Build log stream closed before completion."))},()=>s.close()}exports.fetchLimbuildInfo=l;exports.getIOSOTAInstall=f;exports.startSignedDeviceBuild=u;exports.watchBuildLogEvents=h;
@@ -0,0 +1,81 @@
1
+ async function u(o, t) {
2
+ const a = new URL(`${o}/info`);
3
+ t && a.searchParams.set("token", t);
4
+ const e = await fetch(a.toString(), {
5
+ headers: t ? { Authorization: `Bearer ${t}` } : void 0
6
+ });
7
+ if (!e.ok) {
8
+ const n = await e.text();
9
+ throw new Error(`Info request failed: HTTP ${e.status} ${n}`);
10
+ }
11
+ return await e.json();
12
+ }
13
+ async function l({
14
+ limbuildApiUrl: o,
15
+ token: t,
16
+ certificateP12Base64: a,
17
+ certificatePassword: e,
18
+ provisioningProfileBase64: n
19
+ }) {
20
+ const d = new URL(`${o}/exec`);
21
+ t && d.searchParams.set("token", t);
22
+ const r = await fetch(d.toString(), {
23
+ method: "POST",
24
+ headers: {
25
+ "Content-Type": "application/json",
26
+ ...t ? { Authorization: `Bearer ${t}` } : {}
27
+ },
28
+ body: JSON.stringify({
29
+ command: "xcodebuild",
30
+ xcodebuild: { sdk: "iphoneos" },
31
+ signing: {
32
+ certificateP12Base64: a,
33
+ ...e ? { certificatePassword: e } : {},
34
+ provisioningProfileBase64: n
35
+ }
36
+ })
37
+ });
38
+ if (!r.ok) {
39
+ const s = await r.text();
40
+ throw new Error(`Build request failed: HTTP ${r.status} ${s}`);
41
+ }
42
+ return await r.json();
43
+ }
44
+ async function f({ limbuildApiUrl: o, execId: t, token: a }) {
45
+ const e = new URL(`${o}/exec/${encodeURIComponent(t)}/ios/ota`);
46
+ a && e.searchParams.set("token", a);
47
+ const n = await fetch(e.toString(), {
48
+ headers: a ? { Authorization: `Bearer ${a}` } : void 0
49
+ });
50
+ if (!n.ok) {
51
+ const d = await n.text();
52
+ throw new Error(`OTA install metadata failed: HTTP ${n.status} ${d}`);
53
+ }
54
+ return await n.json();
55
+ }
56
+ function w({
57
+ limbuildApiUrl: o,
58
+ execId: t,
59
+ token: a,
60
+ onLine: e,
61
+ onStatus: n,
62
+ onError: d
63
+ }) {
64
+ const r = new URL(`${o}/exec/${t}/events`);
65
+ a && r.searchParams.set("token", a);
66
+ const s = new EventSource(r.toString());
67
+ return n("running"), s.addEventListener("command", (i) => e({ type: "command", data: i.data })), s.addEventListener("stdout", (i) => e({ type: "stdout", data: i.data })), s.addEventListener("stderr", (i) => e({ type: "stderr", data: i.data })), s.addEventListener("exitCode", (i) => {
68
+ const c = parseInt(i.data, 10);
69
+ n(
70
+ c === 0 ? "succeeded" : c < 0 ? "cancelled" : "failed"
71
+ ), s.close();
72
+ }), s.onerror = () => {
73
+ s.close(), n("failed"), d?.(new Error("Build log stream closed before completion."));
74
+ }, () => s.close();
75
+ }
76
+ export {
77
+ u as f,
78
+ f as g,
79
+ l as s,
80
+ w
81
+ };
@@ -0,0 +1,239 @@
1
+ import { e as c, a as u, n as d, b as f, c as l, i as r } from "./browser-storage-Cx9eW-bm.mjs";
2
+ function g() {
3
+ return {
4
+ method: "POST",
5
+ path: "/account/listTeams.action",
6
+ payload: {}
7
+ };
8
+ }
9
+ function v({
10
+ bundleID: e,
11
+ teamID: i = ""
12
+ }) {
13
+ return n("/account/ios/identifiers/listAppIds.action", i, { sort: "name=asc" });
14
+ }
15
+ function P({
16
+ deviceUDID: e,
17
+ teamID: i = ""
18
+ }) {
19
+ return n("/account/ios/device/listDevices.action", i, {
20
+ sort: "name=asc",
21
+ includeRemovedDevices: !1
22
+ });
23
+ }
24
+ function h(e = "") {
25
+ return n("/account/ios/certificate/listCertRequests.action", e, {
26
+ sort: "name=asc",
27
+ types: "83Q87W3TGH,5QPB9NHCEI"
28
+ });
29
+ }
30
+ function I(e = "") {
31
+ return n("/account/ios/certificate/listCertRequests.action", e, {
32
+ sort: "name=asc",
33
+ types: "WXV89964HE,R58UK2EWSO"
34
+ });
35
+ }
36
+ function R({
37
+ bundleID: e,
38
+ teamID: i = ""
39
+ }) {
40
+ return n("/account/ios/profile/listProvisioningProfiles.action", i, {
41
+ search: e,
42
+ sort: "name=asc"
43
+ });
44
+ }
45
+ function y({
46
+ bundleID: e,
47
+ teamID: i = ""
48
+ }) {
49
+ return n("/account/ios/profile/listProvisioningProfiles.action", i, {
50
+ search: e,
51
+ sort: "name=asc",
52
+ distributionType: "adhoc"
53
+ });
54
+ }
55
+ function D({
56
+ deviceUDID: e,
57
+ teamID: i = "",
58
+ name: t = "Limrun iPhone"
59
+ }) {
60
+ return {
61
+ method: "POST",
62
+ path: "/account/ios/device/addDevices.action",
63
+ payload: {
64
+ teamId: i,
65
+ deviceNames: t,
66
+ deviceNumbers: d(e),
67
+ deviceClasses: "iphone",
68
+ register: "single"
69
+ }
70
+ };
71
+ }
72
+ function q({
73
+ bundleID: e,
74
+ teamID: i = "",
75
+ name: t
76
+ }) {
77
+ return {
78
+ method: "POST",
79
+ path: "/account/ios/identifiers/addAppId.action",
80
+ payload: {
81
+ teamId: i,
82
+ name: t ?? e,
83
+ identifier: e,
84
+ type: "explicit"
85
+ }
86
+ };
87
+ }
88
+ function b({ csrPEM: e, teamID: i = "" }) {
89
+ return {
90
+ method: "POST",
91
+ path: "/account/ios/certificate/submitCertificateRequest.action",
92
+ payload: {
93
+ teamId: i,
94
+ type: "83Q87W3TGH",
95
+ csrContent: e
96
+ }
97
+ };
98
+ }
99
+ function C({ csrPEM: e, teamID: i = "" }) {
100
+ return {
101
+ method: "POST",
102
+ path: "/account/ios/certificate/submitCertificateRequest.action",
103
+ payload: {
104
+ teamId: i,
105
+ type: "WXV89964HE",
106
+ csrContent: e
107
+ }
108
+ };
109
+ }
110
+ function T(e, i = "") {
111
+ return {
112
+ method: "GET",
113
+ path: "/account/ios/certificate/downloadCertificateContent.action",
114
+ payload: {
115
+ teamId: i,
116
+ certificateId: e,
117
+ type: "83Q87W3TGH"
118
+ }
119
+ };
120
+ }
121
+ function S(e, i = "") {
122
+ return {
123
+ method: "GET",
124
+ path: "/account/ios/certificate/downloadCertificateContent.action",
125
+ payload: {
126
+ teamId: i,
127
+ certificateId: e,
128
+ type: "WXV89964HE"
129
+ }
130
+ };
131
+ }
132
+ function A({
133
+ bundleID: e,
134
+ teamID: i = "",
135
+ appIDID: t,
136
+ certificateID: o,
137
+ deviceIDs: a,
138
+ name: s
139
+ }) {
140
+ return {
141
+ method: "POST",
142
+ path: "/account/ios/profile/createProvisioningProfile.action",
143
+ payload: {
144
+ teamId: i,
145
+ provisioningProfileName: s ?? `Limrun ${e}`,
146
+ certificateIds: [o],
147
+ appIdId: t,
148
+ deviceIds: a,
149
+ distributionType: "limited",
150
+ subPlatform: "ios"
151
+ }
152
+ };
153
+ }
154
+ function w({
155
+ bundleID: e,
156
+ teamID: i = "",
157
+ appIDID: t,
158
+ certificateID: o,
159
+ deviceIDs: a,
160
+ name: s
161
+ }) {
162
+ return {
163
+ method: "POST",
164
+ path: "/account/ios/profile/createProvisioningProfile.action",
165
+ payload: {
166
+ teamId: i,
167
+ provisioningProfileName: s ?? `Limrun Ad Hoc ${e}`,
168
+ certificateIds: [o],
169
+ appIdId: t,
170
+ deviceIds: a,
171
+ distributionType: "adhoc",
172
+ subPlatform: "ios"
173
+ }
174
+ };
175
+ }
176
+ function H(e, i = "") {
177
+ return {
178
+ method: "GET",
179
+ path: "/account/ios/profile/downloadProfileContent",
180
+ payload: {
181
+ teamId: i,
182
+ provisioningProfileId: e
183
+ }
184
+ };
185
+ }
186
+ async function O({
187
+ bundleID: e,
188
+ deviceUDID: i,
189
+ teamID: t,
190
+ signingMode: o
191
+ }) {
192
+ const a = await c({ bundleID: e, deviceUDID: i, signingMode: o });
193
+ if (!(!a || !p(a, { bundleID: e, deviceUDID: i, teamID: t, signingMode: o })))
194
+ return a;
195
+ }
196
+ async function E(e) {
197
+ return u({
198
+ ...e,
199
+ certificateFileName: e.certificateID ? `${e.certificateID}.p12` : `apple-${e.signingMode ?? "development"}.p12`,
200
+ certificatePassword: e.certificatePassword || void 0,
201
+ signingMode: e.signingMode,
202
+ profileFileName: e.profile.uuid ? `${e.profile.uuid}.mobileprovision` : `${e.signingMode ?? "development"}.mobileprovision`
203
+ });
204
+ }
205
+ function p(e, { bundleID: i, deviceUDID: t, teamID: o, signingMode: a = "development" }) {
206
+ return (e.signingMode ?? "development") !== a || !f(e.profile, i) || o && e.teamID && e.teamID !== o || t && !l(e.profile, t) || e.profile.expirationDate && new Date(e.profile.expirationDate).getTime() <= Date.now() ? !1 : r(e.bundleID) === r(i);
207
+ }
208
+ function n(e, i, t = {}) {
209
+ const o = {
210
+ pageNumber: 1,
211
+ pageSize: 200,
212
+ ...t
213
+ };
214
+ return i && (o.teamId = i), {
215
+ method: "POST",
216
+ path: e,
217
+ payload: o
218
+ };
219
+ }
220
+ export {
221
+ h as a,
222
+ b,
223
+ T as c,
224
+ S as d,
225
+ v as e,
226
+ I as f,
227
+ q as g,
228
+ P as h,
229
+ y as i,
230
+ R as j,
231
+ w as k,
232
+ g as l,
233
+ A as m,
234
+ H as n,
235
+ O as o,
236
+ E as p,
237
+ D as r,
238
+ C as s
239
+ };
@@ -0,0 +1 @@
1
+ "use strict";const a=require("./browser-storage-jJaIht4K.js");function c(){return{method:"POST",path:"/account/listTeams.action",payload:{}}}function u({bundleID:e,teamID:t=""}){return s("/account/ios/identifiers/listAppIds.action",t,{sort:"name=asc"})}function d({deviceUDID:e,teamID:t=""}){return s("/account/ios/device/listDevices.action",t,{sort:"name=asc",includeRemovedDevices:!1})}function f(e=""){return s("/account/ios/certificate/listCertRequests.action",e,{sort:"name=asc",types:"83Q87W3TGH,5QPB9NHCEI"})}function l(e=""){return s("/account/ios/certificate/listCertRequests.action",e,{sort:"name=asc",types:"WXV89964HE,R58UK2EWSO"})}function p({bundleID:e,teamID:t=""}){return s("/account/ios/profile/listProvisioningProfiles.action",t,{search:e,sort:"name=asc"})}function m({bundleID:e,teamID:t=""}){return s("/account/ios/profile/listProvisioningProfiles.action",t,{search:e,sort:"name=asc",distributionType:"adhoc"})}function R({deviceUDID:e,teamID:t="",name:i="Limrun iPhone"}){return{method:"POST",path:"/account/ios/device/addDevices.action",payload:{teamId:t,deviceNames:i,deviceNumbers:a.normalizeUDID(e),deviceClasses:"iphone",register:"single"}}}function g({bundleID:e,teamID:t="",name:i}){return{method:"POST",path:"/account/ios/identifiers/addAppId.action",payload:{teamId:t,name:i??e,identifier:e,type:"explicit"}}}function q({csrPEM:e,teamID:t=""}){return{method:"POST",path:"/account/ios/certificate/submitCertificateRequest.action",payload:{teamId:t,type:"83Q87W3TGH",csrContent:e}}}function v({csrPEM:e,teamID:t=""}){return{method:"POST",path:"/account/ios/certificate/submitCertificateRequest.action",payload:{teamId:t,type:"WXV89964HE",csrContent:e}}}function P(e,t=""){return{method:"GET",path:"/account/ios/certificate/downloadCertificateContent.action",payload:{teamId:t,certificateId:e,type:"83Q87W3TGH"}}}function D(e,t=""){return{method:"GET",path:"/account/ios/certificate/downloadCertificateContent.action",payload:{teamId:t,certificateId:e,type:"WXV89964HE"}}}function I({bundleID:e,teamID:t="",appIDID:i,certificateID:o,deviceIDs:n,name:r}){return{method:"POST",path:"/account/ios/profile/createProvisioningProfile.action",payload:{teamId:t,provisioningProfileName:r??`Limrun ${e}`,certificateIds:[o],appIdId:i,deviceIds:n,distributionType:"limited",subPlatform:"ios"}}}function h({bundleID:e,teamID:t="",appIDID:i,certificateID:o,deviceIDs:n,name:r}){return{method:"POST",path:"/account/ios/profile/createProvisioningProfile.action",payload:{teamId:t,provisioningProfileName:r??`Limrun Ad Hoc ${e}`,certificateIds:[o],appIdId:i,deviceIds:n,distributionType:"adhoc",subPlatform:"ios"}}}function C(e,t=""){return{method:"GET",path:"/account/ios/profile/downloadProfileContent",payload:{teamId:t,provisioningProfileId:e}}}async function b({bundleID:e,deviceUDID:t,teamID:i,signingMode:o}){const n=await a.getSigningAssets({bundleID:e,deviceUDID:t,signingMode:o});if(!(!n||!S(n,{bundleID:e,deviceUDID:t,teamID:i,signingMode:o})))return n}async function y(e){return a.putSigningAssets({...e,certificateFileName:e.certificateID?`${e.certificateID}.p12`:`apple-${e.signingMode??"development"}.p12`,certificatePassword:e.certificatePassword||void 0,signingMode:e.signingMode,profileFileName:e.profile.uuid?`${e.profile.uuid}.mobileprovision`:`${e.signingMode??"development"}.mobileprovision`})}function S(e,{bundleID:t,deviceUDID:i,teamID:o,signingMode:n="development"}){return(e.signingMode??"development")!==n||!a.profileMatchesBundleID(e.profile,t)||o&&e.teamID&&e.teamID!==o||i&&!a.profileContainsDevice(e.profile,i)||e.profile.expirationDate&&new Date(e.profile.expirationDate).getTime()<=Date.now()?!1:a.normalizeBundleID(e.bundleID)===a.normalizeBundleID(t)}function s(e,t,i={}){const o={pageNumber:1,pageSize:200,...i};return t&&(o.teamId=t),{method:"POST",path:e,payload:o}}exports.createAdHocProfileRequest=h;exports.createBundleIDRequest=g;exports.createDevelopmentProfileRequest=I;exports.downloadCertificateRequest=P;exports.downloadDistributionCertificateRequest=D;exports.downloadProfileRequest=C;exports.findAdHocProfilesRequest=m;exports.findBundleIDRequest=u;exports.findDevelopmentCertificatesRequest=f;exports.findDevelopmentProfilesRequest=p;exports.findDeviceRequest=d;exports.findDistributionCertificatesRequest=l;exports.getReusableAppleSigningAssets=b;exports.listTeamsRequest=c;exports.putAppleGeneratedSigningAssets=y;exports.registerDeviceRequest=R;exports.submitDevelopmentCSRRequest=q;exports.submitDistributionCSRRequest=v;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limrun/ui",
3
- "version": "0.9.0-rc.9",
3
+ "version": "0.13.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -13,6 +13,26 @@
13
13
  "import": "./dist/index.js",
14
14
  "require": "./dist/index.cjs"
15
15
  },
16
+ "./app-store-relay": {
17
+ "types": "./dist/app-store-relay/index.d.ts",
18
+ "import": "./dist/app-store-relay/index.js",
19
+ "require": "./dist/app-store-relay/index.cjs"
20
+ },
21
+ "./app-store-relay/react": {
22
+ "types": "./dist/app-store-relay/react.d.ts",
23
+ "import": "./dist/app-store-relay/react.js",
24
+ "require": "./dist/app-store-relay/react.cjs"
25
+ },
26
+ "./device-build": {
27
+ "types": "./dist/device-build/index.d.ts",
28
+ "import": "./dist/device-build/index.js",
29
+ "require": "./dist/device-build/index.cjs"
30
+ },
31
+ "./device-build/react": {
32
+ "types": "./dist/device-build/react.d.ts",
33
+ "import": "./dist/device-build/react.js",
34
+ "require": "./dist/device-build/react.cjs"
35
+ },
16
36
  "./device-install": {
17
37
  "types": "./dist/device-install/index.d.ts",
18
38
  "import": "./dist/device-install/index.js",
@@ -0,0 +1,70 @@
1
+ // @vitest-environment node
2
+
3
+ import { afterEach, describe, expect, test, vi } from 'vitest';
4
+ import { assertAppleDeveloperPortalResponseOK, deleteAppleProfile, listAppleTeams } from './index';
5
+
6
+ describe('App Store relay primitives', () => {
7
+ afterEach(() => {
8
+ vi.restoreAllMocks();
9
+ });
10
+
11
+ test('sends explicit CRUD requests through the provisioning proxy', async () => {
12
+ const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
13
+ new Response(JSON.stringify({ status: 200, body: { resultCode: 0 } }), {
14
+ status: 200,
15
+ }),
16
+ );
17
+
18
+ await deleteAppleProfile({
19
+ apiUrl: 'https://limbuild.example',
20
+ token: 'token',
21
+ appleSessionId: 'apple-session',
22
+ teamId: 'TEAM',
23
+ profileId: 'PROFILE',
24
+ });
25
+
26
+ expect(fetchMock).toHaveBeenCalledOnce();
27
+ const [url, init] = fetchMock.mock.calls[0];
28
+ expect(String(url)).toBe('https://limbuild.example/apple/provisioning?token=token');
29
+ expect(JSON.parse(String(init?.body))).toMatchObject({
30
+ appleSessionId: 'apple-session',
31
+ method: 'POST',
32
+ path: '/account/ios/profile/deleteProvisioningProfile.action',
33
+ payload: {
34
+ teamId: 'TEAM',
35
+ provisioningProfileId: 'PROFILE',
36
+ },
37
+ });
38
+ });
39
+
40
+ test('maps team list responses to teams', async () => {
41
+ vi.spyOn(globalThis, 'fetch').mockResolvedValue(
42
+ new Response(
43
+ JSON.stringify({
44
+ status: 200,
45
+ body: {
46
+ resultCode: 0,
47
+ teams: [{ name: 'Team One', teamId: 'TEAM1' }],
48
+ },
49
+ }),
50
+ { status: 200 },
51
+ ),
52
+ );
53
+
54
+ await expect(
55
+ listAppleTeams({
56
+ apiUrl: 'https://limbuild.example',
57
+ appleSessionId: 'apple-session',
58
+ }),
59
+ ).resolves.toEqual([{ name: 'Team One', teamId: 'TEAM1' }]);
60
+ });
61
+
62
+ test('surfaces Apple portal errors', () => {
63
+ expect(() =>
64
+ assertAppleDeveloperPortalResponseOK(
65
+ { resultCode: 35, userString: 'No permission' },
66
+ 'Apple device list',
67
+ ),
68
+ ).toThrow('Apple device list failed: No permission');
69
+ });
70
+ });