@limrun/ui 0.9.0-rc.9 → 0.13.3-rc.1

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 (67) 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 +430 -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-BJ__DGJ6.mjs +202 -0
  9. package/dist/browser-storage-C1jQLXat.js +1 -0
  10. package/dist/client-Bk1N3XIF.mjs +228 -0
  11. package/dist/client-CnbCWvCs.js +1 -0
  12. package/dist/components/device-install/index.d.ts +1 -2
  13. package/dist/core/device-install/apple/provisioning.d.ts +55 -4
  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 +66 -0
  23. package/dist/device-build/signing.d.ts +20 -0
  24. package/dist/device-install/index.cjs +1 -1
  25. package/dist/device-install/index.d.ts +18 -3
  26. package/dist/device-install/index.js +570 -76
  27. package/dist/device-install/react.cjs +1 -1
  28. package/dist/device-install/react.d.ts +23 -1
  29. package/dist/device-install/react.js +93 -2
  30. package/dist/hooks/index.d.ts +1 -1
  31. package/dist/index-BXg7HdIs.mjs +11547 -0
  32. package/dist/index-CMeQfhYy.js +22 -0
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.d.ts +0 -2
  35. package/dist/index.js +502 -495
  36. package/dist/limbuild-client-CFJhYsRx.mjs +79 -0
  37. package/dist/limbuild-client-C_CMNLYV.js +1 -0
  38. package/dist/provisioning-CdseoMJQ.mjs +239 -0
  39. package/dist/provisioning-D2ZZQeyX.js +1 -0
  40. package/package.json +21 -1
  41. package/src/app-store-relay/index.test.ts +74 -0
  42. package/src/app-store-relay/index.ts +447 -0
  43. package/src/app-store-relay/react.ts +125 -0
  44. package/src/components/device-install/index.ts +1 -2
  45. package/src/core/device-install/apple/provisioning.test.ts +84 -0
  46. package/src/core/device-install/apple/provisioning.ts +91 -7
  47. package/src/core/device-install/operations/limbuild-client.ts +33 -3
  48. package/src/core/device-install/storage/browser-storage.ts +29 -14
  49. package/src/core/device-install/types.ts +5 -1
  50. package/src/device-build/index.ts +42 -0
  51. package/src/device-build/react.ts +128 -0
  52. package/src/device-build/signing.ts +94 -0
  53. package/src/device-install/index.ts +49 -3
  54. package/src/device-install/react.ts +180 -1
  55. package/src/hooks/index.ts +1 -1
  56. package/src/index.ts +1 -4
  57. package/vite.config.ts +4 -0
  58. package/dist/components/device-install/device-install-dialog.d.ts +0 -5
  59. package/dist/device-install-dialog-CqxDEH85.mjs +0 -443
  60. package/dist/device-install-dialog-jvqQ-fuo.js +0 -2
  61. package/dist/device-install-dialog.css +0 -1
  62. package/dist/hooks/use-device-install.d.ts +0 -73
  63. package/dist/use-device-install-CAPli9MR.js +0 -31
  64. package/dist/use-device-install-H8dqqvbR.mjs +0 -13624
  65. package/src/components/device-install/device-install-dialog.css +0 -325
  66. package/src/components/device-install/device-install-dialog.tsx +0 -495
  67. package/src/hooks/use-device-install.ts +0 -1219
package/README.md CHANGED
@@ -4,14 +4,31 @@
4
4
 
5
5
  See [examples](../../examples/) to see how it can be used.
6
6
 
7
- ## Real Device Installation
8
-
9
- `@limrun/ui` also includes a browser-based iPhone installation flow:
10
-
11
- - `@limrun/ui/device-install/react` exports the headless `useDeviceInstall` hook for clients that want to render their own UI.
12
- - `@limrun/ui/device-install` exports the guided `DeviceInstallDialog` UI, which walks users through a signed device build, USB access, browser pairing, and installation.
13
-
14
- WebUSB requires a Chromium browser and a secure context. Pair records and signing assets, including the `.p12` password, are stored in the browser's IndexedDB.
7
+ ## Real Device Installation Primitives
8
+
9
+ `@limrun/ui` includes browser primitives for building your own iPhone
10
+ installation UI. The package no longer exports a guided install dialog.
11
+
12
+ - `@limrun/ui/app-store-relay` exports framework-agnostic Apple ID relay and Apple Developer Portal calls for teams, certificates, profiles, bundle IDs, and devices.
13
+ - `@limrun/ui/app-store-relay/react` exports thin React state helpers for Apple ID login.
14
+ - `@limrun/ui/device-build` exports signing asset helpers, signed build triggering, build log watching, and OTA install metadata.
15
+ - `@limrun/ui/device-build/react` exports build state helpers.
16
+ - `@limrun/ui/device-install` exports WebUSB access, pairing, pair-record storage, and install relay primitives.
17
+ - `@limrun/ui/device-install/react` exports focused React state for device access, pairing, and relay installation.
18
+
19
+ The primitives are intentionally low-level. Your app decides whether to create
20
+ or reuse Apple certificates and provisioning profiles, how to present devices
21
+ and bundle IDs, and when to persist signing assets.
22
+
23
+ ```ts
24
+ import { listAppleTeams, createAppleProfile } from '@limrun/ui/app-store-relay';
25
+ import { startSignedDeviceBuild } from '@limrun/ui/device-build';
26
+ import { requestUSBAccess, pairDevice, startDeviceInstall } from '@limrun/ui/device-install';
27
+ ```
28
+
29
+ WebUSB requires a Chromium browser and a secure context. Pair records and signing
30
+ assets, including the `.p12` password when provided, are stored in the browser's
31
+ IndexedDB only when you call the storage helpers.
15
32
 
16
33
  ### Releasing
17
34
 
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../client-CnbCWvCs.js"),l=require("../index-CMeQfhYy.js"),p=require("../provisioning-D2ZZQeyX.js"),w={name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"};async function P(e){if(!crypto.subtle)throw new Error("WebCrypto is not available in this browser.");const t=await crypto.subtle.generateKey(w,!0,["sign","verify"]),r=new Uint8Array(await crypto.subtle.exportKey("spki",t.publicKey)),i=f(B(0),S(e),r,q(0,new Uint8Array)),n=new Uint8Array(await crypto.subtle.sign("RSASSA-PKCS1-v1_5",t.privateKey,k(i))),a=f(i,f(D("1.2.840.113549.1.1.11"),C()),K(n)),u=new Uint8Array(await crypto.subtle.exportKey("pkcs8",t.privateKey));return{privateKey:t.privateKey,privateKeyPKCS8Base64:y(u),publicKeySPKIBase64:y(r),csrPEM:x("CERTIFICATE REQUEST",a),csrBase64:y(a)}}function I(e){if(!e.certificateBase64&&!e.certificatePEM)throw new Error("certificateBase64 or certificatePEM is required.");const t=l.forge.pki.privateKeyFromPem(U("PRIVATE KEY",e.privateKeyPKCS8Base64)),r=e.certificatePEM?l.forge.pki.certificateFromPem(e.certificatePEM):l.forge.pki.certificateFromAsn1(l.forge.asn1.fromDer(l.forge.util.createBuffer(O(e.certificateBase64)))),i=l.forge.pkcs12.toPkcs12Asn1(t,[r],e.password,{algorithm:"3des",friendlyName:e.friendlyName}),n=l.forge.asn1.toDer(i).getBytes();return F(n)}function S(e){const t=[m("2.5.4.3",R(e.commonName))];return e.emailAddress&&t.push(m("1.2.840.113549.1.9.1",T(e.emailAddress))),f(...t)}function m(e,t){return h(f(D(e),t))}function f(...e){return c(48,A(...e))}function h(...e){return c(49,A(...e))}function q(e,t){return c(160+e,t)}function B(e){return c(2,new Uint8Array([e]))}function C(){return new Uint8Array([5,0])}function R(e){return c(12,new TextEncoder().encode(e))}function T(e){return c(22,new TextEncoder().encode(e))}function K(e){return c(3,A(new Uint8Array([0]),e))}function D(e){const t=e.split(".").map(i=>parseInt(i,10));if(t.length<2||t.some(i=>!Number.isFinite(i)))throw new Error(`Invalid OID: ${e}`);const r=[t[0]*40+t[1]];for(const i of t.slice(2)){const n=[i&127];let a=i>>7;for(;a>0;)n.unshift(a&127|128),a>>=7;r.push(...n)}return c(6,new Uint8Array(r))}function c(e,t){return A(new Uint8Array([e]),E(t.byteLength),t)}function E(e){if(e<128)return new Uint8Array([e]);const t=[];let r=e;for(;r>0;)t.unshift(r&255),r>>=8;return new Uint8Array([128|t.length,...t])}function A(...e){const t=e.reduce((n,a)=>n+a.byteLength,0),r=new Uint8Array(t);let i=0;for(const n of e)r.set(n,i),i+=n.byteLength;return r}function x(e,t){const i=y(t).match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
2
+ ${i.join(`
3
+ `)}
4
+ -----END ${e}-----
5
+ `}function U(e,t){const r=t.match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
6
+ ${r.join(`
7
+ `)}
8
+ -----END ${e}-----
9
+ `}function y(e){let t="";for(const r of e)t+=String.fromCharCode(r);return btoa(t)}function F(e){return btoa(e)}function O(e){return atob(e)}function k(e){const t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}async function o({apiUrl:e,token:t,appleSessionId:r,request:i,label:n="Apple Developer Portal request",validatePortalResponse:a=!0,mapBody:u}){const d=await s.proxyProvisioningRequest(e,r,i,t);return a&&b(d.body,n),u?u(d.body,d):d}async function N(e){return o({...e,request:p.listTeamsRequest(),label:"Apple Developer team list",mapBody:t=>te([...t?.teams??[],...t?.availableProviders??[],...t?.provider?[t.provider]:[]])})}async function $({certificateKind:e="development",teamId:t="",...r}){return o({...r,request:e==="distribution"?p.findDistributionCertificatesRequest(t):p.findDevelopmentCertificatesRequest(t),label:"Apple Developer certificate list",mapBody:i=>i?.certRequests??[]})}async function L({certificateKind:e="development",teamId:t="",csrPEM:r,...i}){return o({...i,request:e==="distribution"?p.submitDistributionCSRRequest({csrPEM:r,teamID:t}):p.submitDevelopmentCSRRequest({csrPEM:r,teamID:t}),label:e==="distribution"?"Apple Distribution certificate creation":"Apple Development certificate creation",mapBody:n=>n?.certRequest})}async function G({certificateKind:e="development",certificateId:t,teamId:r="",...i}){return o({...i,request:e==="distribution"?p.downloadDistributionCertificateRequest(t,r):p.downloadCertificateRequest(t,r),label:"Apple certificate download",validatePortalResponse:!1,mapBody:(n,a)=>a})}async function H({certificateKind:e="development",certificateId:t,teamId:r="",...i}){return o({...i,request:{method:"POST",path:"/account/ios/certificate/revokeCertificate.action",payload:{teamId:r,certificateId:t,type:e==="distribution"?"WXV89964HE":"83Q87W3TGH"}},label:"Apple certificate deletion",mapBody:n=>n})}async function M({teamId:e="",search:t="",...r}){return o({...r,request:p.findBundleIDRequest({bundleID:t,teamID:e}),label:"Apple bundle ID list",mapBody:i=>i?.appIds??[]})}async function _({teamId:e="",bundleId:t,name:r,...i}){return o({...i,request:p.createBundleIDRequest({bundleID:t,teamID:e,name:r}),label:"Apple bundle ID creation",mapBody:n=>n?.appId})}async function j({teamId:e="",appIdId:t,bundleId:r,name:i,...n}){return o({...n,request:{method:"POST",path:"/account/ios/identifiers/updateAppId.action",payload:{teamId:e,appIdId:t,...r?{identifier:r}:{},...i?{name:i}:{}}},label:"Apple bundle ID update",mapBody:a=>a?.appId})}async function V({teamId:e="",appIdId:t,...r}){return o({...r,request:{method:"POST",path:"/account/ios/identifiers/deleteAppId.action",payload:{teamId:e,appIdId:t}},label:"Apple bundle ID deletion",mapBody:i=>i})}async function W({teamId:e="",deviceUDID:t="",...r}){return o({...r,request:p.findDeviceRequest({deviceUDID:t,teamID:e}),label:"Apple device list",mapBody:i=>i?.devices??[]})}async function Q({teamId:e="",deviceUDID:t,name:r,...i}){return o({...i,request:p.registerDeviceRequest({deviceUDID:t,teamID:e,name:r}),label:"Apple device registration",mapBody:n=>n?.device})}async function J({teamId:e="",deviceId:t,name:r,...i}){return o({...i,request:{method:"POST",path:"/account/ios/device/updateDevice.action",payload:{teamId:e,deviceId:t,...r?{name:r}:{}}},label:"Apple device update",mapBody:n=>n?.device})}async function X({teamId:e="",deviceId:t,...r}){return o({...r,request:{method:"POST",path:"/account/ios/device/deleteDevice.action",payload:{teamId:e,deviceId:t}},label:"Apple device deletion",mapBody:i=>i})}async function Y({profileKind:e="development",teamId:t="",bundleId:r="",...i}){return o({...i,request:e==="adhoc"?p.findAdHocProfilesRequest({bundleID:r,teamID:t}):p.findDevelopmentProfilesRequest({bundleID:r,teamID:t}),label:"Apple provisioning profile list",mapBody:n=>n?.provisioningProfiles??[]})}async function z({profileKind:e="development",teamId:t="",bundleId:r,appIdId:i,certificateIds:n,deviceIds:a,name:u,...d}){const[v]=n;if(!v)throw new Error("At least one certificate ID is required to create an Apple provisioning profile.");return o({...d,request:e==="adhoc"?p.createAdHocProfileRequest({bundleID:r,teamID:t,appIDID:i,certificateID:v,deviceIDs:a,name:u}):p.createDevelopmentProfileRequest({bundleID:r,teamID:t,appIDID:i,certificateID:v,deviceIDs:a,name:u}),label:"Apple provisioning profile creation",mapBody:g=>g?.provisioningProfile})}async function Z({teamId:e="",profileId:t,...r}){return o({...r,request:p.downloadProfileRequest(t,e),label:"Apple provisioning profile download",validatePortalResponse:!1,mapBody:(i,n)=>n})}async function ee({teamId:e="",profileId:t,...r}){return o({...r,request:{method:"POST",path:"/account/ios/profile/deleteProvisioningProfile.action",payload:{teamId:e,provisioningProfileId:t}},label:"Apple provisioning profile deletion",mapBody:i=>i})}function b(e,t){if(!e)throw new Error(`${t} returned an empty response.`);if(e.resultCode!==void 0&&e.resultCode!==0)throw new Error(`${t} failed: ${e.userString??e.resultString??e.resultCode}`)}function te(e){const t=new Set,r=[];for(const i of e){const n=String(i.teamId??i.providerId??i.publicProviderId??i.name??JSON.stringify(i));t.has(n)||(t.add(n),r.push(i))}return r}exports.createAppleRelaySession=s.createAppleRelaySession;exports.deleteAppleRelaySession=s.deleteAppleRelaySession;exports.fetchAppleAccountSession=s.fetchAppleAccountSession;exports.proxyPhoneTwoFactorCode=s.proxyPhoneTwoFactorCode;exports.proxySrpComplete=s.proxySrpComplete;exports.proxySrpInit=s.proxySrpInit;exports.proxyTwoFactorCode=s.proxyTwoFactorCode;exports.startBrowserOwnedAppleIDLogin=s.startBrowserOwnedAppleIDLogin;exports.triggerPhoneTwoFactor=s.triggerPhoneTwoFactor;exports.triggerTrustedDeviceTwoFactor=s.triggerTrustedDeviceTwoFactor;exports.AppleGsaSrpClient=l.AppleGsaSrpClient;exports.assertAppleDeveloperPortalResponseOK=b;exports.createAppleBundleID=_;exports.createAppleCertificate=L;exports.createAppleProfile=z;exports.deleteAppleBundleID=V;exports.deleteAppleCertificate=H;exports.deleteAppleDevice=X;exports.deleteAppleProfile=ee;exports.downloadAppleCertificate=G;exports.downloadAppleProfile=Z;exports.exportAppleCertificateP12=I;exports.generateAppleSigningKeyAndCSR=P;exports.listAppleBundleIDs=M;exports.listAppleCertificates=$;exports.listAppleDevices=W;exports.listAppleProfiles=Y;exports.listAppleTeams=N;exports.registerAppleDevice=Q;exports.requestAppleProvisioning=o;exports.updateAppleBundleID=j;exports.updateAppleDevice=J;
@@ -0,0 +1,102 @@
1
+ import { AppleDeveloperPortalAppID, AppleDeveloperPortalDevice, AppleDeveloperPortalResponse, AppleDeveloperPortalTeam, AppleProvisioningRequest, AppleRelayResponse } from '../core/device-install/apple';
2
+ export * from '../core/device-install/apple/client';
3
+ export * from '../core/device-install/apple/crypto';
4
+ export * from '../core/device-install/apple/gsa-srp';
5
+ export type { AppleDeveloperPortalAppID, AppleDeveloperPortalDevice, AppleDeveloperPortalResponse, AppleDeveloperPortalTeam, AppleProvisioningRequest, AppleRelayResponse, } from '../core/device-install/apple';
6
+ export { createAppleRelaySession, deleteAppleRelaySession, fetchAppleAccountSession, proxyPhoneTwoFactorCode, proxySrpComplete, proxySrpInit, proxyTwoFactorCode, triggerPhoneTwoFactor, triggerTrustedDeviceTwoFactor, } from '../core/device-install/apple';
7
+ export type AppleRelayClientOptions = {
8
+ apiUrl: string;
9
+ token?: string;
10
+ appleSessionId: string;
11
+ };
12
+ export type AppleTeamScopedOptions = AppleRelayClientOptions & {
13
+ teamId?: string;
14
+ };
15
+ export type AppleCertificateKind = 'development' | 'distribution';
16
+ export type AppleProfileKind = 'development' | 'adhoc';
17
+ export type RequestAppleProvisioningOptions<T = unknown> = AppleRelayClientOptions & {
18
+ request: AppleProvisioningRequest;
19
+ label?: string;
20
+ validatePortalResponse?: boolean;
21
+ mapBody?: (body: AppleDeveloperPortalResponse | undefined, response: AppleRelayResponse<T>) => T;
22
+ };
23
+ export type MappedAppleProvisioningOptions<T> = RequestAppleProvisioningOptions<T> & {
24
+ mapBody: (body: AppleDeveloperPortalResponse | undefined, response: AppleRelayResponse<T>) => T;
25
+ };
26
+ export type ListAppleCertificatesOptions = AppleTeamScopedOptions & {
27
+ certificateKind?: AppleCertificateKind;
28
+ };
29
+ export type CreateAppleCertificateOptions = AppleTeamScopedOptions & {
30
+ certificateKind?: AppleCertificateKind;
31
+ csrPEM: string;
32
+ };
33
+ export type DownloadAppleCertificateOptions = AppleTeamScopedOptions & {
34
+ certificateKind?: AppleCertificateKind;
35
+ certificateId: string;
36
+ };
37
+ export type DeleteAppleCertificateOptions = DownloadAppleCertificateOptions;
38
+ export type ListAppleBundleIDsOptions = AppleTeamScopedOptions & {
39
+ search?: string;
40
+ };
41
+ export type CreateAppleBundleIDOptions = AppleTeamScopedOptions & {
42
+ bundleId: string;
43
+ name?: string;
44
+ };
45
+ export type UpdateAppleBundleIDOptions = AppleTeamScopedOptions & {
46
+ appIdId: string;
47
+ bundleId?: string;
48
+ name?: string;
49
+ };
50
+ export type DeleteAppleBundleIDOptions = AppleTeamScopedOptions & {
51
+ appIdId: string;
52
+ };
53
+ export type ListAppleDevicesOptions = AppleTeamScopedOptions & {
54
+ deviceUDID?: string;
55
+ };
56
+ export type RegisterAppleDeviceOptions = AppleTeamScopedOptions & {
57
+ deviceUDID: string;
58
+ name?: string;
59
+ };
60
+ export type UpdateAppleDeviceOptions = AppleTeamScopedOptions & {
61
+ deviceId: string;
62
+ name?: string;
63
+ };
64
+ export type DeleteAppleDeviceOptions = AppleTeamScopedOptions & {
65
+ deviceId: string;
66
+ };
67
+ export type ListAppleProfilesOptions = AppleTeamScopedOptions & {
68
+ profileKind?: AppleProfileKind;
69
+ bundleId?: string;
70
+ };
71
+ export type CreateAppleProfileOptions = AppleTeamScopedOptions & {
72
+ profileKind?: AppleProfileKind;
73
+ bundleId: string;
74
+ appIdId: string;
75
+ certificateIds: string[];
76
+ deviceIds: string[];
77
+ name?: string;
78
+ };
79
+ export type DownloadAppleProfileOptions = AppleTeamScopedOptions & {
80
+ profileId: string;
81
+ };
82
+ export type DeleteAppleProfileOptions = DownloadAppleProfileOptions;
83
+ export declare function requestAppleProvisioning<T>(options: MappedAppleProvisioningOptions<T>): Promise<T>;
84
+ export declare function requestAppleProvisioning<T = AppleDeveloperPortalResponse>(options: RequestAppleProvisioningOptions<T>): Promise<AppleRelayResponse<T>>;
85
+ export declare function listAppleTeams(options: AppleRelayClientOptions): Promise<AppleDeveloperPortalTeam[]>;
86
+ export declare function listAppleCertificates({ certificateKind, teamId, ...options }: ListAppleCertificatesOptions): Promise<Record<string, unknown>[]>;
87
+ export declare function createAppleCertificate({ certificateKind, teamId, csrPEM, ...options }: CreateAppleCertificateOptions): Promise<Record<string, unknown> | undefined>;
88
+ export declare function downloadAppleCertificate({ certificateKind, certificateId, teamId, ...options }: DownloadAppleCertificateOptions): Promise<AppleRelayResponse>;
89
+ export declare function deleteAppleCertificate({ certificateKind, certificateId, teamId, ...options }: DeleteAppleCertificateOptions): Promise<AppleDeveloperPortalResponse | undefined>;
90
+ export declare function listAppleBundleIDs({ teamId, search, ...options }: ListAppleBundleIDsOptions): Promise<AppleDeveloperPortalAppID[]>;
91
+ export declare function createAppleBundleID({ teamId, bundleId, name, ...options }: CreateAppleBundleIDOptions): Promise<Record<string, unknown> | undefined>;
92
+ export declare function updateAppleBundleID({ teamId, appIdId, bundleId, name, ...options }: UpdateAppleBundleIDOptions): Promise<Record<string, unknown> | undefined>;
93
+ export declare function deleteAppleBundleID({ teamId, appIdId, ...options }: DeleteAppleBundleIDOptions): Promise<AppleDeveloperPortalResponse | undefined>;
94
+ export declare function listAppleDevices({ teamId, deviceUDID, ...options }: ListAppleDevicesOptions): Promise<AppleDeveloperPortalDevice[]>;
95
+ export declare function registerAppleDevice({ teamId, deviceUDID, name, ...options }: RegisterAppleDeviceOptions): Promise<Record<string, unknown> | undefined>;
96
+ export declare function updateAppleDevice({ teamId, deviceId, name, ...options }: UpdateAppleDeviceOptions): Promise<Record<string, unknown> | undefined>;
97
+ export declare function deleteAppleDevice({ teamId, deviceId, ...options }: DeleteAppleDeviceOptions): Promise<AppleDeveloperPortalResponse | undefined>;
98
+ export declare function listAppleProfiles({ profileKind, teamId, bundleId, ...options }: ListAppleProfilesOptions): Promise<Record<string, unknown>[]>;
99
+ export declare function createAppleProfile({ profileKind, teamId, bundleId, appIdId, certificateIds, deviceIds, name, ...options }: CreateAppleProfileOptions): Promise<Record<string, unknown> | undefined>;
100
+ export declare function downloadAppleProfile({ teamId, profileId, ...options }: DownloadAppleProfileOptions): Promise<AppleRelayResponse>;
101
+ export declare function deleteAppleProfile({ teamId, profileId, ...options }: DeleteAppleProfileOptions): Promise<AppleDeveloperPortalResponse | undefined>;
102
+ export declare function assertAppleDeveloperPortalResponseOK(response: AppleDeveloperPortalResponse | undefined, label: string): void;
@@ -0,0 +1,430 @@
1
+ import { p as b } from "../client-Bk1N3XIF.mjs";
2
+ import { c as Ie, d as he, f as Pe, a as qe, b as Be, e as Se, g as Re, s as Ce, t as Te, h as Ee } from "../client-Bk1N3XIF.mjs";
3
+ import { f as p } from "../index-BXg7HdIs.mjs";
4
+ import { A as Ue } from "../index-BXg7HdIs.mjs";
5
+ import { l as D, f as w, a as g, s as I, b as h, d as P, c as q, e as B, g as S, h as R, r as C, i as T, j as E, k as K, m as U, n as x } from "../provisioning-CdseoMJQ.mjs";
6
+ const k = {
7
+ name: "RSASSA-PKCS1-v1_5",
8
+ modulusLength: 2048,
9
+ publicExponent: new Uint8Array([1, 0, 1]),
10
+ hash: "SHA-256"
11
+ };
12
+ async function te(e) {
13
+ if (!crypto.subtle)
14
+ throw new Error("WebCrypto is not available in this browser.");
15
+ const t = await crypto.subtle.generateKey(k, !0, ["sign", "verify"]), r = new Uint8Array(await crypto.subtle.exportKey("spki", t.publicKey)), n = u(
16
+ $(0),
17
+ F(e),
18
+ r,
19
+ O(0, new Uint8Array())
20
+ ), i = new Uint8Array(
21
+ await crypto.subtle.sign("RSASSA-PKCS1-v1_5", t.privateKey, J(n))
22
+ ), o = u(
23
+ n,
24
+ u(m("1.2.840.113549.1.1.11"), L()),
25
+ M(i)
26
+ ), c = new Uint8Array(await crypto.subtle.exportKey("pkcs8", t.privateKey));
27
+ return {
28
+ privateKey: t.privateKey,
29
+ privateKeyPKCS8Base64: d(c),
30
+ publicKeySPKIBase64: d(r),
31
+ csrPEM: j("CERTIFICATE REQUEST", o),
32
+ csrBase64: d(o)
33
+ };
34
+ }
35
+ function re(e) {
36
+ if (!e.certificateBase64 && !e.certificatePEM)
37
+ throw new Error("certificateBase64 or certificatePEM is required.");
38
+ const t = p.pki.privateKeyFromPem(
39
+ V("PRIVATE KEY", e.privateKeyPKCS8Base64)
40
+ ), r = e.certificatePEM ? p.pki.certificateFromPem(e.certificatePEM) : p.pki.certificateFromAsn1(
41
+ p.asn1.fromDer(p.util.createBuffer(Q(e.certificateBase64)))
42
+ ), n = p.pkcs12.toPkcs12Asn1(t, [r], e.password, {
43
+ algorithm: "3des",
44
+ friendlyName: e.friendlyName
45
+ }), i = p.asn1.toDer(n).getBytes();
46
+ return W(i);
47
+ }
48
+ function F(e) {
49
+ const t = [A("2.5.4.3", H(e.commonName))];
50
+ return e.emailAddress && t.push(A("1.2.840.113549.1.9.1", G(e.emailAddress))), u(...t);
51
+ }
52
+ function A(e, t) {
53
+ return N(u(m(e), t));
54
+ }
55
+ function u(...e) {
56
+ return s(48, f(...e));
57
+ }
58
+ function N(...e) {
59
+ return s(49, f(...e));
60
+ }
61
+ function O(e, t) {
62
+ return s(160 + e, t);
63
+ }
64
+ function $(e) {
65
+ return s(2, new Uint8Array([e]));
66
+ }
67
+ function L() {
68
+ return new Uint8Array([5, 0]);
69
+ }
70
+ function H(e) {
71
+ return s(12, new TextEncoder().encode(e));
72
+ }
73
+ function G(e) {
74
+ return s(22, new TextEncoder().encode(e));
75
+ }
76
+ function M(e) {
77
+ return s(3, f(new Uint8Array([0]), e));
78
+ }
79
+ function m(e) {
80
+ const t = e.split(".").map((n) => parseInt(n, 10));
81
+ if (t.length < 2 || t.some((n) => !Number.isFinite(n)))
82
+ throw new Error(`Invalid OID: ${e}`);
83
+ const r = [t[0] * 40 + t[1]];
84
+ for (const n of t.slice(2)) {
85
+ const i = [n & 127];
86
+ let o = n >> 7;
87
+ for (; o > 0; )
88
+ i.unshift(o & 127 | 128), o >>= 7;
89
+ r.push(...i);
90
+ }
91
+ return s(6, new Uint8Array(r));
92
+ }
93
+ function s(e, t) {
94
+ return f(new Uint8Array([e]), _(t.byteLength), t);
95
+ }
96
+ function _(e) {
97
+ if (e < 128)
98
+ return new Uint8Array([e]);
99
+ const t = [];
100
+ let r = e;
101
+ for (; r > 0; )
102
+ t.unshift(r & 255), r >>= 8;
103
+ return new Uint8Array([128 | t.length, ...t]);
104
+ }
105
+ function f(...e) {
106
+ const t = e.reduce((i, o) => i + o.byteLength, 0), r = new Uint8Array(t);
107
+ let n = 0;
108
+ for (const i of e)
109
+ r.set(i, n), n += i.byteLength;
110
+ return r;
111
+ }
112
+ function j(e, t) {
113
+ const n = d(t).match(/.{1,64}/g) ?? [];
114
+ return `-----BEGIN ${e}-----
115
+ ${n.join(`
116
+ `)}
117
+ -----END ${e}-----
118
+ `;
119
+ }
120
+ function V(e, t) {
121
+ const r = t.match(/.{1,64}/g) ?? [];
122
+ return `-----BEGIN ${e}-----
123
+ ${r.join(`
124
+ `)}
125
+ -----END ${e}-----
126
+ `;
127
+ }
128
+ function d(e) {
129
+ let t = "";
130
+ for (const r of e)
131
+ t += String.fromCharCode(r);
132
+ return btoa(t);
133
+ }
134
+ function W(e) {
135
+ return btoa(e);
136
+ }
137
+ function Q(e) {
138
+ return atob(e);
139
+ }
140
+ function J(e) {
141
+ const t = new Uint8Array(e.byteLength);
142
+ return t.set(e), t.buffer;
143
+ }
144
+ async function a({
145
+ apiUrl: e,
146
+ token: t,
147
+ appleSessionId: r,
148
+ request: n,
149
+ label: i = "Apple Developer Portal request",
150
+ validatePortalResponse: o = !0,
151
+ mapBody: c
152
+ }) {
153
+ const l = await b(e, r, n, t);
154
+ return o && X(l.body, i), c ? c(l.body, l) : l;
155
+ }
156
+ async function ne(e) {
157
+ return a({
158
+ ...e,
159
+ request: D(),
160
+ label: "Apple Developer team list",
161
+ mapBody: (t) => Y([...t?.teams ?? [], ...t?.availableProviders ?? [], ...t?.provider ? [t.provider] : []])
162
+ });
163
+ }
164
+ async function ie({
165
+ certificateKind: e = "development",
166
+ teamId: t = "",
167
+ ...r
168
+ }) {
169
+ return a({
170
+ ...r,
171
+ request: e === "distribution" ? w(t) : g(t),
172
+ label: "Apple Developer certificate list",
173
+ mapBody: (n) => n?.certRequests ?? []
174
+ });
175
+ }
176
+ async function oe({
177
+ certificateKind: e = "development",
178
+ teamId: t = "",
179
+ csrPEM: r,
180
+ ...n
181
+ }) {
182
+ return a({
183
+ ...n,
184
+ request: e === "distribution" ? I({ csrPEM: r, teamID: t }) : h({ csrPEM: r, teamID: t }),
185
+ label: e === "distribution" ? "Apple Distribution certificate creation" : "Apple Development certificate creation",
186
+ mapBody: (i) => i?.certRequest
187
+ });
188
+ }
189
+ async function ae({
190
+ certificateKind: e = "development",
191
+ certificateId: t,
192
+ teamId: r = "",
193
+ ...n
194
+ }) {
195
+ return a({
196
+ ...n,
197
+ request: e === "distribution" ? P(t, r) : q(t, r),
198
+ label: "Apple certificate download",
199
+ validatePortalResponse: !1,
200
+ mapBody: (i, o) => o
201
+ });
202
+ }
203
+ async function se({
204
+ certificateKind: e = "development",
205
+ certificateId: t,
206
+ teamId: r = "",
207
+ ...n
208
+ }) {
209
+ return a({
210
+ ...n,
211
+ request: {
212
+ method: "POST",
213
+ path: "/account/ios/certificate/revokeCertificate.action",
214
+ payload: {
215
+ teamId: r,
216
+ certificateId: t,
217
+ type: e === "distribution" ? "WXV89964HE" : "83Q87W3TGH"
218
+ }
219
+ },
220
+ label: "Apple certificate deletion",
221
+ mapBody: (i) => i
222
+ });
223
+ }
224
+ async function ce({ teamId: e = "", search: t = "", ...r }) {
225
+ return a({
226
+ ...r,
227
+ request: B({ bundleID: t, teamID: e }),
228
+ label: "Apple bundle ID list",
229
+ mapBody: (n) => n?.appIds ?? []
230
+ });
231
+ }
232
+ async function pe({ teamId: e = "", bundleId: t, name: r, ...n }) {
233
+ return a({
234
+ ...n,
235
+ request: S({ bundleID: t, teamID: e, name: r }),
236
+ label: "Apple bundle ID creation",
237
+ mapBody: (i) => i?.appId
238
+ });
239
+ }
240
+ async function le({
241
+ teamId: e = "",
242
+ appIdId: t,
243
+ bundleId: r,
244
+ name: n,
245
+ ...i
246
+ }) {
247
+ return a({
248
+ ...i,
249
+ request: {
250
+ method: "POST",
251
+ path: "/account/ios/identifiers/updateAppId.action",
252
+ payload: {
253
+ teamId: e,
254
+ appIdId: t,
255
+ ...r ? { identifier: r } : {},
256
+ ...n ? { name: n } : {}
257
+ }
258
+ },
259
+ label: "Apple bundle ID update",
260
+ mapBody: (o) => o?.appId
261
+ });
262
+ }
263
+ async function ue({ teamId: e = "", appIdId: t, ...r }) {
264
+ return a({
265
+ ...r,
266
+ request: {
267
+ method: "POST",
268
+ path: "/account/ios/identifiers/deleteAppId.action",
269
+ payload: { teamId: e, appIdId: t }
270
+ },
271
+ label: "Apple bundle ID deletion",
272
+ mapBody: (n) => n
273
+ });
274
+ }
275
+ async function de({ teamId: e = "", deviceUDID: t = "", ...r }) {
276
+ return a({
277
+ ...r,
278
+ request: R({ deviceUDID: t, teamID: e }),
279
+ label: "Apple device list",
280
+ mapBody: (n) => n?.devices ?? []
281
+ });
282
+ }
283
+ async function fe({ teamId: e = "", deviceUDID: t, name: r, ...n }) {
284
+ return a({
285
+ ...n,
286
+ request: C({ deviceUDID: t, teamID: e, name: r }),
287
+ label: "Apple device registration",
288
+ mapBody: (i) => i?.device
289
+ });
290
+ }
291
+ async function ye({ teamId: e = "", deviceId: t, name: r, ...n }) {
292
+ return a({
293
+ ...n,
294
+ request: {
295
+ method: "POST",
296
+ path: "/account/ios/device/updateDevice.action",
297
+ payload: { teamId: e, deviceId: t, ...r ? { name: r } : {} }
298
+ },
299
+ label: "Apple device update",
300
+ mapBody: (i) => i?.device
301
+ });
302
+ }
303
+ async function Ae({ teamId: e = "", deviceId: t, ...r }) {
304
+ return a({
305
+ ...r,
306
+ request: {
307
+ method: "POST",
308
+ path: "/account/ios/device/deleteDevice.action",
309
+ payload: { teamId: e, deviceId: t }
310
+ },
311
+ label: "Apple device deletion",
312
+ mapBody: (n) => n
313
+ });
314
+ }
315
+ async function me({
316
+ profileKind: e = "development",
317
+ teamId: t = "",
318
+ bundleId: r = "",
319
+ ...n
320
+ }) {
321
+ return a({
322
+ ...n,
323
+ request: e === "adhoc" ? T({ bundleID: r, teamID: t }) : E({ bundleID: r, teamID: t }),
324
+ label: "Apple provisioning profile list",
325
+ mapBody: (i) => i?.provisioningProfiles ?? []
326
+ });
327
+ }
328
+ async function ve({
329
+ profileKind: e = "development",
330
+ teamId: t = "",
331
+ bundleId: r,
332
+ appIdId: n,
333
+ certificateIds: i,
334
+ deviceIds: o,
335
+ name: c,
336
+ ...l
337
+ }) {
338
+ const [y] = i;
339
+ if (!y)
340
+ throw new Error("At least one certificate ID is required to create an Apple provisioning profile.");
341
+ return a({
342
+ ...l,
343
+ request: e === "adhoc" ? K({
344
+ bundleID: r,
345
+ teamID: t,
346
+ appIDID: n,
347
+ certificateID: y,
348
+ deviceIDs: o,
349
+ name: c
350
+ }) : U({
351
+ bundleID: r,
352
+ teamID: t,
353
+ appIDID: n,
354
+ certificateID: y,
355
+ deviceIDs: o,
356
+ name: c
357
+ }),
358
+ label: "Apple provisioning profile creation",
359
+ mapBody: (v) => v?.provisioningProfile
360
+ });
361
+ }
362
+ async function be({ teamId: e = "", profileId: t, ...r }) {
363
+ return a({
364
+ ...r,
365
+ request: x(t, e),
366
+ label: "Apple provisioning profile download",
367
+ validatePortalResponse: !1,
368
+ mapBody: (n, i) => i
369
+ });
370
+ }
371
+ async function De({ teamId: e = "", profileId: t, ...r }) {
372
+ return a({
373
+ ...r,
374
+ request: {
375
+ method: "POST",
376
+ path: "/account/ios/profile/deleteProvisioningProfile.action",
377
+ payload: { teamId: e, provisioningProfileId: t }
378
+ },
379
+ label: "Apple provisioning profile deletion",
380
+ mapBody: (n) => n
381
+ });
382
+ }
383
+ function X(e, t) {
384
+ if (!e)
385
+ throw new Error(`${t} returned an empty response.`);
386
+ if (e.resultCode !== void 0 && e.resultCode !== 0)
387
+ throw new Error(`${t} failed: ${e.userString ?? e.resultString ?? e.resultCode}`);
388
+ }
389
+ function Y(e) {
390
+ const t = /* @__PURE__ */ new Set(), r = [];
391
+ for (const n of e) {
392
+ const i = String(n.teamId ?? n.providerId ?? n.publicProviderId ?? n.name ?? JSON.stringify(n));
393
+ t.has(i) || (t.add(i), r.push(n));
394
+ }
395
+ return r;
396
+ }
397
+ export {
398
+ Ue as AppleGsaSrpClient,
399
+ X as assertAppleDeveloperPortalResponseOK,
400
+ pe as createAppleBundleID,
401
+ oe as createAppleCertificate,
402
+ ve as createAppleProfile,
403
+ Ie as createAppleRelaySession,
404
+ ue as deleteAppleBundleID,
405
+ se as deleteAppleCertificate,
406
+ Ae as deleteAppleDevice,
407
+ De as deleteAppleProfile,
408
+ he as deleteAppleRelaySession,
409
+ ae as downloadAppleCertificate,
410
+ be as downloadAppleProfile,
411
+ re as exportAppleCertificateP12,
412
+ Pe as fetchAppleAccountSession,
413
+ te as generateAppleSigningKeyAndCSR,
414
+ ce as listAppleBundleIDs,
415
+ ie as listAppleCertificates,
416
+ de as listAppleDevices,
417
+ me as listAppleProfiles,
418
+ ne as listAppleTeams,
419
+ qe as proxyPhoneTwoFactorCode,
420
+ Be as proxySrpComplete,
421
+ Se as proxySrpInit,
422
+ Re as proxyTwoFactorCode,
423
+ fe as registerAppleDevice,
424
+ a as requestAppleProvisioning,
425
+ Ce as startBrowserOwnedAppleIDLogin,
426
+ Te as triggerPhoneTwoFactor,
427
+ Ee as triggerTrustedDeviceTwoFactor,
428
+ le as updateAppleBundleID,
429
+ ye as updateAppleDevice
430
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),R=require("../client-CnbCWvCs.js");require("../index-CMeQfhYy.js");function m({limbuildApiUrl:n,token:u}){const[g,o]=t.useState("idle"),[f,i]=t.useState(),[w,l]=t.useState(),[h,d]=t.useState(),[v,c]=t.useState(),r=t.useRef(void 0),S=t.useCallback(async()=>{await r.current?.close().catch(()=>{}),r.current=void 0,i(void 0),l(void 0),d(void 0),c(void 0),o("idle")},[]);t.useEffect(()=>()=>{r.current?.close(),r.current=void 0},[]);const b=t.useCallback(async({accountName:s,password:a})=>{o("authenticating"),c(void 0),await r.current?.close().catch(()=>{});try{const e=await R.startBrowserOwnedAppleIDLogin({limbuildApiUrl:n,token:u,accountName:s,password:a});return r.current=e,i(e),l(e.completeResponse),d(e.twoFactorChallengeResponse),o(e.requiresTwoFactor?"two-factor-required":"authenticated"),e}catch(e){i(void 0),r.current=void 0,c(p(e)),o("error");return}},[n,u]),C=t.useCallback(async s=>{const a=r.current;if(!a)throw new Error("Start Apple ID login before submitting a two-factor code.");o("authenticating"),c(void 0);try{const e=await a.finishTwoFactor(s);return o("authenticated"),e}catch(e){c(p(e)),o("error");return}},[]),y=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:f,completeResponse:w,twoFactorChallengeResponse:h,error:v,startLogin:b,submitTwoFactorCode:C,finalize:y,close:S}}function p(n){return n instanceof Error?n.message:String(n)}exports.useAppleIDLogin=m;
@@ -0,0 +1,15 @@
1
+ import { AppleIDLoginInput, AppleIDLoginResult, AppleRelayResponse } from './index';
2
+ export type UseAppleIDLoginOptions = Pick<AppleIDLoginInput, 'limbuildApiUrl' | 'token'>;
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({ limbuildApiUrl, token }: UseAppleIDLoginOptions): UseAppleIDLoginResult;