@limrun/ui 0.13.7 → 0.14.0-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.
- package/dist/app-store-relay/index.cjs +3 -3
- package/dist/app-store-relay/index.d.ts +3 -5
- package/dist/app-store-relay/index.js +56 -58
- package/dist/app-store-relay/react.cjs +1 -1
- package/dist/app-store-relay/react.d.ts +2 -2
- package/dist/app-store-relay/react.js +35 -34
- package/dist/client-BtC4n_qf.js +1 -0
- package/dist/client-CBX-hLnL.mjs +189 -0
- package/dist/core/device-install/apple/client.d.ts +5 -4
- package/dist/core/device-install/apple/relay.d.ts +24 -13
- package/dist/core/device-install/operations/limbuild-client.d.ts +2 -1
- package/dist/core/device-install/operations/operations.d.ts +19 -4
- package/dist/core/device-install/operations/relay-client.d.ts +2 -1
- package/dist/device-build/index.cjs +1 -1
- package/dist/device-build/index.js +1 -1
- package/dist/device-build/react.cjs +1 -1
- package/dist/device-build/react.d.ts +1 -0
- package/dist/device-build/react.js +34 -33
- package/dist/device-install/index.cjs +1 -1
- package/dist/device-install/index.d.ts +1 -1
- package/dist/device-install/index.js +121 -119
- package/dist/device-install/react.cjs +1 -1
- package/dist/device-install/react.d.ts +4 -3
- package/dist/device-install/react.js +58 -54
- package/dist/index.cjs +1 -1
- package/dist/index.js +519 -531
- package/dist/limbuild-client-BagK_FWE.mjs +83 -0
- package/dist/limbuild-client-CVDwq54z.js +1 -0
- package/package.json +1 -1
- package/src/app-store-relay/index.test.ts +19 -29
- package/src/app-store-relay/index.ts +6 -9
- package/src/app-store-relay/react.ts +5 -4
- package/src/components/remote-control.tsx +1 -28
- package/src/core/device-install/apple/client.ts +22 -33
- package/src/core/device-install/apple/relay.ts +108 -148
- package/src/core/device-install/operations/limbuild-client.ts +3 -0
- package/src/core/device-install/operations/operations.ts +21 -9
- package/src/core/device-install/operations/relay-client.ts +3 -2
- package/src/device-build/react.ts +2 -0
- package/src/device-install/README.md +5 -5
- package/src/device-install/demo/demo.tsx +26 -28
- package/src/device-install/index.ts +1 -0
- package/src/device-install/react.ts +12 -6
- package/dist/client-ASLtHFLh.js +0 -1
- package/dist/client-CGdh8yoJ.mjs +0 -234
- package/dist/limbuild-client-CgEncrgx.js +0 -1
- package/dist/limbuild-client-D7U7w342.mjs +0 -81
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../client-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../client-BtC4n_qf.js"),c=require("../index-CMeQfhYy.js"),p=require("../provisioning-Va0PH4Kk.js"),P={name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"};async function I(e){if(!crypto.subtle)throw new Error("WebCrypto is not available in this browser.");const t=await crypto.subtle.generateKey(P,!0,["sign","verify"]),r=new Uint8Array(await crypto.subtle.exportKey("spki",t.publicKey)),n=d(C(0),h(e),r,B(0,new Uint8Array)),i=new Uint8Array(await crypto.subtle.sign("RSASSA-PKCS1-v1_5",t.privateKey,N(n))),o=d(n,d(b("1.2.840.113549.1.1.11"),R()),E(i)),s=new Uint8Array(await crypto.subtle.exportKey("pkcs8",t.privateKey));return{privateKey:t.privateKey,privateKeyPKCS8Base64:y(s),publicKeySPKIBase64:y(r),csrPEM:U("CERTIFICATE REQUEST",o),csrBase64:y(o)}}function S(e){if(!e.certificateBase64&&!e.certificatePEM)throw new Error("certificateBase64 or certificatePEM is required.");const t=c.forge.pki.privateKeyFromPem(k("PRIVATE KEY",e.privateKeyPKCS8Base64)),r=e.certificatePEM?c.forge.pki.certificateFromPem(e.certificatePEM):c.forge.pki.certificateFromAsn1(c.forge.asn1.fromDer(c.forge.util.createBuffer(O(e.certificateBase64)))),n=c.forge.pkcs12.toPkcs12Asn1(t,[r],e.password,{algorithm:"3des",friendlyName:e.friendlyName}),i=c.forge.asn1.toDer(n).getBytes();return F(i)}function h(e){const t=[v("2.5.4.3",T(e.commonName))];return e.emailAddress&&t.push(v("1.2.840.113549.1.9.1",K(e.emailAddress))),d(...t)}function v(e,t){return q(d(b(e),t))}function d(...e){return u(48,A(...e))}function q(...e){return u(49,A(...e))}function B(e,t){return u(160+e,t)}function C(e){return u(2,new Uint8Array([e]))}function R(){return new Uint8Array([5,0])}function T(e){return u(12,new TextEncoder().encode(e))}function K(e){return u(22,new TextEncoder().encode(e))}function E(e){return u(3,A(new Uint8Array([0]),e))}function b(e){const t=e.split(".").map(n=>parseInt(n,10));if(t.length<2||t.some(n=>!Number.isFinite(n)))throw new Error(`Invalid OID: ${e}`);const r=[t[0]*40+t[1]];for(const n of t.slice(2)){const i=[n&127];let o=n>>7;for(;o>0;)i.unshift(o&127|128),o>>=7;r.push(...i)}return u(6,new Uint8Array(r))}function u(e,t){return A(new Uint8Array([e]),x(t.byteLength),t)}function x(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((i,o)=>i+o.byteLength,0),r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.byteLength;return r}function U(e,t){const n=y(t).match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
|
|
2
2
|
${n.join(`
|
|
3
3
|
`)}
|
|
4
4
|
-----END ${e}-----
|
|
5
|
-
`}function
|
|
5
|
+
`}function k(e,t){const r=t.match(/.{1,64}/g)??[];return`-----BEGIN ${e}-----
|
|
6
6
|
${r.join(`
|
|
7
7
|
`)}
|
|
8
8
|
-----END ${e}-----
|
|
9
|
-
`}function y(e){let t="";for(const r of e)t+=String.fromCharCode(r);return btoa(t)}function
|
|
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 N(e){const t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}async function a({relay:e,request:t,label:r="Apple Developer Portal request",validatePortalResponse:n=!0,mapBody:i}){const o=await l.proxyProvisioningRequest(e,t);return n&&g(o.body,r),i?i(o.body,o):o}async function L(e){return a({...e,request:p.listTeamsRequest(),label:"Apple Developer team list",mapBody:t=>re([...t?.teams??[],...t?.availableProviders??[],...t?.provider?[t.provider]:[]])})}async function $({certificateKind:e="development",teamId:t="",...r}){return a({...r,request:e==="distribution"?p.findDistributionCertificatesRequest(t):p.findDevelopmentCertificatesRequest(t),label:"Apple Developer certificate list",mapBody:n=>n?.certRequests??[]})}async function W({certificateKind:e="development",teamId:t="",csrPEM:r,...n}){return a({...n,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:i=>i?.certRequest})}async function G({certificateKind:e="development",certificateId:t,teamId:r="",...n}){return a({...n,request:e==="distribution"?p.downloadDistributionCertificateRequest(t,r):p.downloadCertificateRequest(t,r),label:"Apple certificate download",validatePortalResponse:!1,mapBody:(i,o)=>o})}async function H({certificateKind:e="development",certificateId:t,teamId:r="",...n}){return a({...n,request:{method:"POST",path:"/account/ios/certificate/revokeCertificate.action",payload:{teamId:r,certificateId:t,type:e==="distribution"?"WXV89964HE":"83Q87W3TGH"}},label:"Apple certificate deletion",mapBody:i=>i})}async function M({teamId:e="",search:t="",...r}){const n=t.trim().toLowerCase();return a({...r,request:p.findBundleIDRequest({bundleID:t,teamID:e}),label:"Apple bundle ID list",mapBody:i=>{const o=i?.appIds??[];return n?o.filter(s=>[s.identifier,s.bundleId,s.name].some(f=>typeof f=="string"&&f.toLowerCase().includes(n))):o}})}async function _({teamId:e="",bundleId:t,name:r,...n}){return a({...n,request:p.createBundleIDRequest({bundleID:t,teamID:e,name:r}),label:"Apple bundle ID creation",mapBody:i=>i?.appId})}async function j({teamId:e="",appIdId:t,bundleId:r,name:n,...i}){return a({...i,request:{method:"POST",path:"/account/ios/identifiers/updateAppId.action",payload:{teamId:e,appIdId:t,...r?{identifier:r}:{},...n?{name:n}:{}}},label:"Apple bundle ID update",mapBody:o=>o?.appId})}async function V({teamId:e="",appIdId:t,...r}){return a({...r,request:{method:"POST",path:"/account/ios/identifiers/deleteAppId.action",payload:{teamId:e,appIdId:t}},label:"Apple bundle ID deletion",mapBody:n=>n})}async function Q({teamId:e="",deviceUDID:t="",...r}){const n=D(t);return a({...r,request:p.findDeviceRequest({deviceUDID:t,teamID:e}),label:"Apple device list",mapBody:i=>{const o=i?.devices??[];return n?o.filter(s=>D(s.deviceNumber)===n):o}})}function D(e){return(e??"").replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"").toUpperCase()}async function z({teamId:e="",deviceUDID:t,name:r,...n}){return a({...n,request:p.registerDeviceRequest({deviceUDID:t,teamID:e,name:r}),label:"Apple device registration",mapBody:i=>i?.device})}async function J({teamId:e="",deviceId:t,name:r,...n}){return a({...n,request:{method:"POST",path:"/account/ios/device/updateDevice.action",payload:{teamId:e,deviceId:t,...r?{name:r}:{}}},label:"Apple device update",mapBody:i=>i?.device})}async function X({teamId:e="",deviceId:t,...r}){return a({...r,request:{method:"POST",path:"/account/ios/device/deleteDevice.action",payload:{teamId:e,deviceId:t}},label:"Apple device deletion",mapBody:n=>n})}async function Y({profileKind:e="development",teamId:t="",bundleId:r="",...n}){return a({...n,request:e==="adhoc"?p.findAdHocProfilesRequest({bundleID:r,teamID:t}):p.findDevelopmentProfilesRequest({bundleID:r,teamID:t}),label:"Apple provisioning profile list",mapBody:i=>i?.provisioningProfiles??[]})}async function Z({profileKind:e="development",teamId:t="",bundleId:r,appIdId:n,certificateIds:i,deviceIds:o,name:s,...f}){const[m]=i;if(!m)throw new Error("At least one certificate ID is required to create an Apple provisioning profile.");return a({...f,request:e==="adhoc"?p.createAdHocProfileRequest({bundleID:r,teamID:t,appIDID:n,certificateID:m,deviceIDs:o,name:s}):p.createDevelopmentProfileRequest({bundleID:r,teamID:t,appIDID:n,certificateID:m,deviceIDs:o,name:s}),label:"Apple provisioning profile creation",mapBody:w=>w?.provisioningProfile})}async function ee({teamId:e="",profileId:t,...r}){return a({...r,request:p.downloadProfileRequest(t,e),label:"Apple provisioning profile download",validatePortalResponse:!1,mapBody:(n,i)=>i})}async function te({teamId:e="",profileId:t,...r}){return a({...r,request:{method:"POST",path:"/account/ios/profile/deleteProvisioningProfile.action",payload:{teamId:e,provisioningProfileId:t}},label:"Apple provisioning profile deletion",mapBody:n=>n})}function g(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 re(e){const t=new Set,r=[];for(const n of e){const i=String(n.teamId??n.providerId??n.publicProviderId??n.name??JSON.stringify(n));t.has(i)||(t.add(i),r.push(n))}return r}exports.AppleRelayWebSocketClient=l.AppleRelayWebSocketClient;exports.fetchAppleAccountSession=l.fetchAppleAccountSession;exports.openAppleRelayWebSocket=l.openAppleRelayWebSocket;exports.proxyPhoneTwoFactorCode=l.proxyPhoneTwoFactorCode;exports.proxySrpComplete=l.proxySrpComplete;exports.proxySrpInit=l.proxySrpInit;exports.proxyTwoFactorCode=l.proxyTwoFactorCode;exports.startBrowserOwnedAppleIDLogin=l.startBrowserOwnedAppleIDLogin;exports.triggerPhoneTwoFactor=l.triggerPhoneTwoFactor;exports.triggerTrustedDeviceTwoFactor=l.triggerTrustedDeviceTwoFactor;exports.AppleGsaSrpClient=c.AppleGsaSrpClient;exports.assertAppleDeveloperPortalResponseOK=g;exports.createAppleBundleID=_;exports.createAppleCertificate=W;exports.createAppleProfile=Z;exports.deleteAppleBundleID=V;exports.deleteAppleCertificate=H;exports.deleteAppleDevice=X;exports.deleteAppleProfile=te;exports.downloadAppleCertificate=G;exports.downloadAppleProfile=ee;exports.exportAppleCertificateP12=S;exports.generateAppleSigningKeyAndCSR=I;exports.listAppleBundleIDs=M;exports.listAppleCertificates=$;exports.listAppleDevices=Q;exports.listAppleProfiles=Y;exports.listAppleTeams=L;exports.registerAppleDevice=z;exports.requestAppleProvisioning=a;exports.updateAppleBundleID=j;exports.updateAppleDevice=J;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { AppleDeveloperPortalAppID, AppleDeveloperPortalDevice, AppleDeveloperPortalResponse, AppleDeveloperPortalTeam, AppleProvisioningRequest, AppleRelayResponse } from '../core/device-install/apple';
|
|
1
|
+
import { AppleDeveloperPortalAppID, AppleDeveloperPortalDevice, AppleDeveloperPortalResponse, AppleDeveloperPortalTeam, AppleProvisioningRequest, AppleRelayResponse, AppleRelayWebSocketClient } from '../core/device-install/apple';
|
|
2
2
|
export * from '../core/device-install/apple/client';
|
|
3
3
|
export * from '../core/device-install/apple/crypto';
|
|
4
4
|
export * from '../core/device-install/apple/gsa-srp';
|
|
5
5
|
export type { AppleDeveloperPortalAppID, AppleDeveloperPortalDevice, AppleDeveloperPortalResponse, AppleDeveloperPortalTeam, AppleProvisioningRequest, AppleRelayResponse, } from '../core/device-install/apple';
|
|
6
|
-
export {
|
|
6
|
+
export { AppleRelayWebSocketClient, fetchAppleAccountSession, openAppleRelayWebSocket, proxyPhoneTwoFactorCode, proxySrpComplete, proxySrpInit, proxyTwoFactorCode, triggerPhoneTwoFactor, triggerTrustedDeviceTwoFactor, } from '../core/device-install/apple';
|
|
7
7
|
export type AppleRelayClientOptions = {
|
|
8
|
-
|
|
9
|
-
token?: string;
|
|
10
|
-
appleSessionId: string;
|
|
8
|
+
relay: AppleRelayWebSocketClient;
|
|
11
9
|
};
|
|
12
10
|
export type AppleTeamScopedOptions = AppleRelayClientOptions & {
|
|
13
11
|
teamId?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { p as D } from "../client-
|
|
2
|
-
import {
|
|
3
|
-
import { f as
|
|
4
|
-
import { A as
|
|
5
|
-
import { l as w, f as g, a as I, s as
|
|
1
|
+
import { p as D } from "../client-CBX-hLnL.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-CBX-hLnL.mjs";
|
|
3
|
+
import { f as p } from "../index-DFdCvi2_.mjs";
|
|
4
|
+
import { A as ke } from "../index-DFdCvi2_.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, g as C, h as R, r as T, i as E, j as K, k as U, m as k, n as x } from "../provisioning-DKbkBO-p.mjs";
|
|
6
6
|
const F = {
|
|
7
7
|
name: "RSASSA-PKCS1-v1_5",
|
|
8
8
|
modulusLength: 2048,
|
|
@@ -12,7 +12,7 @@ const F = {
|
|
|
12
12
|
async function re(e) {
|
|
13
13
|
if (!crypto.subtle)
|
|
14
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 =
|
|
15
|
+
const t = await crypto.subtle.generateKey(F, !0, ["sign", "verify"]), r = new Uint8Array(await crypto.subtle.exportKey("spki", t.publicKey)), n = l(
|
|
16
16
|
$(0),
|
|
17
17
|
N(e),
|
|
18
18
|
r,
|
|
@@ -23,62 +23,62 @@ async function re(e) {
|
|
|
23
23
|
t.privateKey,
|
|
24
24
|
J(n)
|
|
25
25
|
)
|
|
26
|
-
), o =
|
|
26
|
+
), o = l(
|
|
27
27
|
n,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
l(b("1.2.840.113549.1.1.11"), H()),
|
|
29
|
+
M(i)
|
|
30
30
|
), s = new Uint8Array(await crypto.subtle.exportKey("pkcs8", t.privateKey));
|
|
31
31
|
return {
|
|
32
32
|
privateKey: t.privateKey,
|
|
33
33
|
privateKeyPKCS8Base64: d(s),
|
|
34
34
|
publicKeySPKIBase64: d(r),
|
|
35
|
-
csrPEM:
|
|
35
|
+
csrPEM: j("CERTIFICATE REQUEST", o),
|
|
36
36
|
csrBase64: d(o)
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
function ne(e) {
|
|
40
40
|
if (!e.certificateBase64 && !e.certificatePEM)
|
|
41
41
|
throw new Error("certificateBase64 or certificatePEM is required.");
|
|
42
|
-
const t =
|
|
43
|
-
|
|
44
|
-
), n =
|
|
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
45
|
algorithm: "3des",
|
|
46
46
|
friendlyName: e.friendlyName
|
|
47
|
-
}), i =
|
|
47
|
+
}), i = p.asn1.toDer(n).getBytes();
|
|
48
48
|
return Q(i);
|
|
49
49
|
}
|
|
50
50
|
function N(e) {
|
|
51
|
-
const t = [m("2.5.4.3",
|
|
52
|
-
return e.emailAddress && t.push(m("1.2.840.113549.1.9.1",
|
|
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
53
|
}
|
|
54
54
|
function m(e, t) {
|
|
55
|
-
return O(
|
|
55
|
+
return O(l(b(e), t));
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
return
|
|
57
|
+
function l(...e) {
|
|
58
|
+
return c(48, f(...e));
|
|
59
59
|
}
|
|
60
60
|
function O(...e) {
|
|
61
|
-
return
|
|
61
|
+
return c(49, f(...e));
|
|
62
62
|
}
|
|
63
63
|
function L(e, t) {
|
|
64
|
-
return
|
|
64
|
+
return c(160 + e, t);
|
|
65
65
|
}
|
|
66
66
|
function $(e) {
|
|
67
|
-
return
|
|
67
|
+
return c(2, new Uint8Array([e]));
|
|
68
68
|
}
|
|
69
69
|
function H() {
|
|
70
70
|
return new Uint8Array([5, 0]);
|
|
71
71
|
}
|
|
72
|
+
function W(e) {
|
|
73
|
+
return c(12, new TextEncoder().encode(e));
|
|
74
|
+
}
|
|
72
75
|
function G(e) {
|
|
73
|
-
return
|
|
76
|
+
return c(22, new TextEncoder().encode(e));
|
|
74
77
|
}
|
|
75
78
|
function M(e) {
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
function _(e) {
|
|
79
|
-
return p(3, f(new Uint8Array([0]), e));
|
|
79
|
+
return c(3, f(new Uint8Array([0]), e));
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function b(e) {
|
|
82
82
|
const t = e.split(".").map((n) => parseInt(n, 10));
|
|
83
83
|
if (t.length < 2 || t.some((n) => !Number.isFinite(n)))
|
|
84
84
|
throw new Error(`Invalid OID: ${e}`);
|
|
@@ -90,12 +90,12 @@ function v(e) {
|
|
|
90
90
|
i.unshift(o & 127 | 128), o >>= 7;
|
|
91
91
|
r.push(...i);
|
|
92
92
|
}
|
|
93
|
-
return
|
|
93
|
+
return c(6, new Uint8Array(r));
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
return f(new Uint8Array([e]),
|
|
95
|
+
function c(e, t) {
|
|
96
|
+
return f(new Uint8Array([e]), _(t.byteLength), t);
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function _(e) {
|
|
99
99
|
if (e < 128)
|
|
100
100
|
return new Uint8Array([e]);
|
|
101
101
|
const t = [];
|
|
@@ -111,7 +111,7 @@ function f(...e) {
|
|
|
111
111
|
r.set(i, n), n += i.byteLength;
|
|
112
112
|
return r;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function j(e, t) {
|
|
115
115
|
const n = d(t).match(/.{1,64}/g) ?? [];
|
|
116
116
|
return `-----BEGIN ${e}-----
|
|
117
117
|
${n.join(`
|
|
@@ -119,7 +119,7 @@ ${n.join(`
|
|
|
119
119
|
-----END ${e}-----
|
|
120
120
|
`;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function V(e, t) {
|
|
123
123
|
const r = t.match(/.{1,64}/g) ?? [];
|
|
124
124
|
return `-----BEGIN ${e}-----
|
|
125
125
|
${r.join(`
|
|
@@ -144,16 +144,14 @@ function J(e) {
|
|
|
144
144
|
return t.set(e), t.buffer;
|
|
145
145
|
}
|
|
146
146
|
async function a({
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
validatePortalResponse: o = !0,
|
|
153
|
-
mapBody: s
|
|
147
|
+
relay: e,
|
|
148
|
+
request: t,
|
|
149
|
+
label: r = "Apple Developer Portal request",
|
|
150
|
+
validatePortalResponse: n = !0,
|
|
151
|
+
mapBody: i
|
|
154
152
|
}) {
|
|
155
|
-
const
|
|
156
|
-
return
|
|
153
|
+
const o = await D(e, t);
|
|
154
|
+
return n && X(o.body, r), i ? i(o.body, o) : o;
|
|
157
155
|
}
|
|
158
156
|
async function ie(e) {
|
|
159
157
|
return a({
|
|
@@ -187,7 +185,7 @@ async function ae({
|
|
|
187
185
|
}) {
|
|
188
186
|
return a({
|
|
189
187
|
...n,
|
|
190
|
-
request: e === "distribution" ?
|
|
188
|
+
request: e === "distribution" ? P({ csrPEM: r, teamID: t }) : h({ csrPEM: r, teamID: t }),
|
|
191
189
|
label: e === "distribution" ? "Apple Distribution certificate creation" : "Apple Development certificate creation",
|
|
192
190
|
mapBody: (i) => i?.certRequest
|
|
193
191
|
});
|
|
@@ -243,7 +241,7 @@ async function pe({
|
|
|
243
241
|
const o = i?.appIds ?? [];
|
|
244
242
|
return n ? o.filter(
|
|
245
243
|
(s) => [s.identifier, s.bundleId, s.name].some(
|
|
246
|
-
(
|
|
244
|
+
(u) => typeof u == "string" && u.toLowerCase().includes(n)
|
|
247
245
|
)
|
|
248
246
|
) : o;
|
|
249
247
|
}
|
|
@@ -360,7 +358,7 @@ async function Ae({ teamId: e = "", deviceId: t, ...r }) {
|
|
|
360
358
|
mapBody: (n) => n
|
|
361
359
|
});
|
|
362
360
|
}
|
|
363
|
-
async function
|
|
361
|
+
async function be({
|
|
364
362
|
profileKind: e = "development",
|
|
365
363
|
teamId: t = "",
|
|
366
364
|
bundleId: r = "",
|
|
@@ -373,7 +371,7 @@ async function ve({
|
|
|
373
371
|
mapBody: (i) => i?.provisioningProfiles ?? []
|
|
374
372
|
});
|
|
375
373
|
}
|
|
376
|
-
async function
|
|
374
|
+
async function ve({
|
|
377
375
|
profileKind: e = "development",
|
|
378
376
|
teamId: t = "",
|
|
379
377
|
bundleId: r,
|
|
@@ -381,13 +379,13 @@ async function be({
|
|
|
381
379
|
certificateIds: i,
|
|
382
380
|
deviceIds: o,
|
|
383
381
|
name: s,
|
|
384
|
-
...
|
|
382
|
+
...u
|
|
385
383
|
}) {
|
|
386
384
|
const [y] = i;
|
|
387
385
|
if (!y)
|
|
388
386
|
throw new Error("At least one certificate ID is required to create an Apple provisioning profile.");
|
|
389
387
|
return a({
|
|
390
|
-
...
|
|
388
|
+
...u,
|
|
391
389
|
request: e === "adhoc" ? U({
|
|
392
390
|
bundleID: r,
|
|
393
391
|
teamID: t,
|
|
@@ -395,7 +393,7 @@ async function be({
|
|
|
395
393
|
certificateID: y,
|
|
396
394
|
deviceIDs: o,
|
|
397
395
|
name: s
|
|
398
|
-
}) :
|
|
396
|
+
}) : k({
|
|
399
397
|
bundleID: r,
|
|
400
398
|
teamID: t,
|
|
401
399
|
appIDID: n,
|
|
@@ -404,7 +402,7 @@ async function be({
|
|
|
404
402
|
name: s
|
|
405
403
|
}),
|
|
406
404
|
label: "Apple provisioning profile creation",
|
|
407
|
-
mapBody: (
|
|
405
|
+
mapBody: (v) => v?.provisioningProfile
|
|
408
406
|
});
|
|
409
407
|
}
|
|
410
408
|
async function De({
|
|
@@ -414,7 +412,7 @@ async function De({
|
|
|
414
412
|
}) {
|
|
415
413
|
return a({
|
|
416
414
|
...r,
|
|
417
|
-
request:
|
|
415
|
+
request: x(t, e),
|
|
418
416
|
label: "Apple provisioning profile download",
|
|
419
417
|
validatePortalResponse: !1,
|
|
420
418
|
mapBody: (n, i) => i
|
|
@@ -451,27 +449,27 @@ function Y(e) {
|
|
|
451
449
|
return r;
|
|
452
450
|
}
|
|
453
451
|
export {
|
|
454
|
-
|
|
452
|
+
ke as AppleGsaSrpClient,
|
|
453
|
+
Pe as AppleRelayWebSocketClient,
|
|
455
454
|
X as assertAppleDeveloperPortalResponseOK,
|
|
456
455
|
le as createAppleBundleID,
|
|
457
456
|
ae as createAppleCertificate,
|
|
458
|
-
|
|
459
|
-
he as createAppleRelaySession,
|
|
457
|
+
ve as createAppleProfile,
|
|
460
458
|
de as deleteAppleBundleID,
|
|
461
459
|
ce as deleteAppleCertificate,
|
|
462
460
|
Ae as deleteAppleDevice,
|
|
463
461
|
we as deleteAppleProfile,
|
|
464
|
-
Pe as deleteAppleRelaySession,
|
|
465
462
|
se as downloadAppleCertificate,
|
|
466
463
|
De as downloadAppleProfile,
|
|
467
464
|
ne as exportAppleCertificateP12,
|
|
468
|
-
|
|
465
|
+
he as fetchAppleAccountSession,
|
|
469
466
|
re as generateAppleSigningKeyAndCSR,
|
|
470
467
|
pe as listAppleBundleIDs,
|
|
471
468
|
oe as listAppleCertificates,
|
|
472
469
|
fe as listAppleDevices,
|
|
473
|
-
|
|
470
|
+
be as listAppleProfiles,
|
|
474
471
|
ie as listAppleTeams,
|
|
472
|
+
qe as openAppleRelayWebSocket,
|
|
475
473
|
Be as proxyPhoneTwoFactorCode,
|
|
476
474
|
Se as proxySrpComplete,
|
|
477
475
|
Ce as proxySrpInit,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),y=require("../client-BtC4n_qf.js");require("../index-CMeQfhYy.js");function F({registryApiUrl:s,token:u,organizationId:l}){const[g,r]=t.useState("idle"),[w,i]=t.useState(),[h,d]=t.useState(),[v,p]=t.useState(),[S,c]=t.useState(),o=t.useRef(void 0),b=t.useCallback(async()=>{await o.current?.close().catch(()=>{}),o.current=void 0,i(void 0),d(void 0),p(void 0),c(void 0),r("idle")},[]);t.useEffect(()=>()=>{o.current?.close(),o.current=void 0},[]);const C=t.useCallback(async({accountName:n,password:a})=>{r("authenticating"),c(void 0),await o.current?.close().catch(()=>{});try{const e=await y.startBrowserOwnedAppleIDLogin({registryApiUrl:s,token:u,organizationId:l,accountName:n,password:a});return o.current=e,i(e),d(e.completeResponse),p(e.twoFactorChallengeResponse),r(e.requiresTwoFactor?"two-factor-required":"authenticated"),e}catch(e){i(void 0),o.current=void 0,c(f(e)),r("error");return}},[s,l,u]),R=t.useCallback(async n=>{const a=o.current;if(!a)throw new Error("Start Apple ID login before submitting a two-factor code.");r("authenticating"),c(void 0);try{const e=await a.finishTwoFactor(n);return r("authenticated"),e}catch(e){c(f(e)),r("error");return}},[]),m=t.useCallback(async()=>{const n=o.current;if(!n)throw new Error("Start Apple ID login before finalizing the Apple session.");return n.finalize()},[]);return{status:g,session:w,completeResponse:h,twoFactorChallengeResponse:v,error:S,startLogin:C,submitTwoFactorCode:R,finalize:m,close:b}}function f(s){return s instanceof Error?s.message:String(s)}exports.useAppleIDLogin=F;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppleIDLoginInput, AppleIDLoginResult, AppleRelayResponse } from './index';
|
|
2
|
-
export type UseAppleIDLoginOptions = Pick<AppleIDLoginInput, '
|
|
2
|
+
export type UseAppleIDLoginOptions = Pick<AppleIDLoginInput, 'registryApiUrl' | 'token' | 'organizationId'>;
|
|
3
3
|
export type AppleIDLoginStatus = 'idle' | 'authenticating' | 'two-factor-required' | 'authenticated' | 'error';
|
|
4
4
|
export type UseAppleIDLoginResult = {
|
|
5
5
|
status: AppleIDLoginStatus;
|
|
@@ -12,4 +12,4 @@ export type UseAppleIDLoginResult = {
|
|
|
12
12
|
finalize: () => Promise<AppleRelayResponse | undefined>;
|
|
13
13
|
close: () => Promise<void>;
|
|
14
14
|
};
|
|
15
|
-
export declare function useAppleIDLogin({
|
|
15
|
+
export declare function useAppleIDLogin({ registryApiUrl, token, organizationId }: UseAppleIDLoginOptions): UseAppleIDLoginResult;
|
|
@@ -1,65 +1,66 @@
|
|
|
1
|
-
import { useState as c, useRef as
|
|
2
|
-
import { s as
|
|
1
|
+
import { useState as c, useRef as y, useCallback as a, useEffect as E } from "react";
|
|
2
|
+
import { s as A } from "../client-CBX-hLnL.mjs";
|
|
3
3
|
import "../index-DFdCvi2_.mjs";
|
|
4
|
-
function
|
|
5
|
-
const [
|
|
6
|
-
await
|
|
7
|
-
}),
|
|
4
|
+
function L({ registryApiUrl: r, token: l, organizationId: d }) {
|
|
5
|
+
const [h, o] = c("idle"), [v, u] = c(), [g, p] = c(), [m, f] = c(), [R, s] = c(), t = y(void 0), C = a(async () => {
|
|
6
|
+
await t.current?.close().catch(() => {
|
|
7
|
+
}), t.current = void 0, u(void 0), p(void 0), f(void 0), s(void 0), o("idle");
|
|
8
8
|
}, []);
|
|
9
9
|
E(() => () => {
|
|
10
|
-
|
|
10
|
+
t.current?.close(), t.current = void 0;
|
|
11
11
|
}, []);
|
|
12
|
-
const
|
|
12
|
+
const F = a(
|
|
13
13
|
async ({ accountName: n, password: i }) => {
|
|
14
|
-
o("authenticating"), s(void 0), await
|
|
14
|
+
o("authenticating"), s(void 0), await t.current?.close().catch(() => {
|
|
15
15
|
});
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const e = await A({
|
|
18
|
+
registryApiUrl: r,
|
|
19
19
|
token: l,
|
|
20
|
+
organizationId: d,
|
|
20
21
|
accountName: n,
|
|
21
22
|
password: i
|
|
22
23
|
});
|
|
23
|
-
return
|
|
24
|
-
} catch (
|
|
25
|
-
u(void 0),
|
|
24
|
+
return t.current = e, u(e), p(e.completeResponse), f(e.twoFactorChallengeResponse), o(e.requiresTwoFactor ? "two-factor-required" : "authenticated"), e;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
u(void 0), t.current = void 0, s(w(e)), o("error");
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
|
-
[r, l]
|
|
30
|
-
),
|
|
31
|
-
const i =
|
|
30
|
+
[r, d, l]
|
|
31
|
+
), S = a(async (n) => {
|
|
32
|
+
const i = t.current;
|
|
32
33
|
if (!i)
|
|
33
34
|
throw new Error("Start Apple ID login before submitting a two-factor code.");
|
|
34
35
|
o("authenticating"), s(void 0);
|
|
35
36
|
try {
|
|
36
|
-
const
|
|
37
|
-
return o("authenticated"),
|
|
38
|
-
} catch (
|
|
39
|
-
s(
|
|
37
|
+
const e = await i.finishTwoFactor(n);
|
|
38
|
+
return o("authenticated"), e;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
s(w(e)), o("error");
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
}, []),
|
|
43
|
-
const n =
|
|
43
|
+
}, []), b = a(async () => {
|
|
44
|
+
const n = t.current;
|
|
44
45
|
if (!n)
|
|
45
46
|
throw new Error("Start Apple ID login before finalizing the Apple session.");
|
|
46
47
|
return n.finalize();
|
|
47
48
|
}, []);
|
|
48
49
|
return {
|
|
49
|
-
status:
|
|
50
|
-
session:
|
|
51
|
-
completeResponse:
|
|
52
|
-
twoFactorChallengeResponse:
|
|
53
|
-
error:
|
|
54
|
-
startLogin:
|
|
55
|
-
submitTwoFactorCode:
|
|
56
|
-
finalize:
|
|
57
|
-
close:
|
|
50
|
+
status: h,
|
|
51
|
+
session: v,
|
|
52
|
+
completeResponse: g,
|
|
53
|
+
twoFactorChallengeResponse: m,
|
|
54
|
+
error: R,
|
|
55
|
+
startLogin: F,
|
|
56
|
+
submitTwoFactorCode: S,
|
|
57
|
+
finalize: b,
|
|
58
|
+
close: C
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
+
function w(r) {
|
|
61
62
|
return r instanceof Error ? r.message : String(r);
|
|
62
63
|
}
|
|
63
64
|
export {
|
|
64
|
-
|
|
65
|
+
L as useAppleIDLogin
|
|
65
66
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const F=require("./index-CMeQfhYy.js");class m{constructor(t,r,o){this.apiUrl=t,this.token=r,this.organizationId=o}socket;nextId=1;pending=new Map;async connect(){if(this.socket&&this.socket.readyState===WebSocket.OPEN)return;const t=new WebSocket(E(this.apiUrl,this.token,this.organizationId));this.socket=t,t.onmessage=r=>this.handleMessage(r),t.onclose=()=>this.rejectPending(new Error("Apple relay WebSocket closed")),t.onerror=()=>this.rejectPending(new Error("Apple relay WebSocket failed")),await new Promise((r,o)=>{t.onopen=()=>r(),t.onerror=()=>o(new Error("Apple relay WebSocket connection failed"))})}request(t,r){const o=this.socket;if(!o||o.readyState!==WebSocket.OPEN)throw new Error("Apple relay WebSocket is not connected.");const a=String(this.nextId++),n=new Promise((p,i)=>{this.pending.set(a,{resolve:h=>p(q(h)),reject:i})});return o.send(JSON.stringify({id:a,type:t,...r===void 0?{}:{payload:r}})),n}close(){this.rejectPending(new Error("Apple relay WebSocket closed")),this.socket?.close(),this.socket=void 0}handleMessage(t){const r=JSON.parse(String(t.data)),o=this.pending.get(r.id);if(o){if(this.pending.delete(r.id),!r.ok){o.reject(new Error(r.error||"Apple relay request failed"));return}if(!r.response){o.reject(new Error("Apple relay response was empty."));return}o.resolve(r.response)}}rejectPending(t){for(const r of this.pending.values())r.reject(t);this.pending.clear()}}async function g(e,t,r){const o=new m(e,t,r);return await o.connect(),o}async function A(e,t){return e.request("srpInit",t)}async function S(e,t){return e.request("srpComplete",t)}async function P(e){return e.request("triggerTrustedDevice2FA")}async function b(e,t,r="sms"){return e.request("triggerPhone2FA",{phoneNumberId:t,mode:r})}async function k(e,t){return e.request("submitTrustedDevice2FA",{code:t})}async function T(e,t,r,o="sms"){return e.request("submitPhone2FA",{phoneNumberId:t,mode:o,code:r})}async function v(e){return e.request("finalize")}async function R(e,t){return e.request("provisioning",t)}function q(e){if(e.body!==void 0||!e.rawBody)return e;try{return{...e,body:JSON.parse(e.rawBody)}}catch{return e}}function E(e,t,r){const o=new URL(e);return o.protocol=o.protocol==="https:"?"wss:":"ws:",o.pathname=`${o.pathname.replace(/\/$/,"")}/ios/appstoreconnect/ws`,t&&o.searchParams.set("token",t),r&&o.searchParams.set("organization",r),o.toString()}async function x({registryApiUrl:e,accountName:t,password:r,token:o,organizationId:a}){const n=await g(e,o,a);try{const p=new F.AppleGsaSrpClient(t),i=await A(n,await p.init());if(i.status<200||i.status>=300)throw new Error(`Apple SRP init failed: HTTP ${i.status} ${i.rawBody??""}`.trim());if(!i.body)throw new Error("Apple SRP init response did not include a body.");const h=await p.complete(r,i.body),u=await S(n,{...h,rememberMe:!1,trustTokens:[]}),y=u.status===409;let s,d={type:"trustedDevice"};if(y){s=await P(n);const c=N(s.body);if(s.status===412){if(!c)throw new Error("Apple requested phone verification but did not include a trusted phone number.");d={type:"phone",phoneNumberId:c.id,mode:c.pushMode??"sms"},s=await b(n,c.id,c.pushMode??"sms")}if(s.status<200||s.status>=300)throw new Error(`Apple two-factor challenge failed: HTTP ${s.status} ${s.rawBody??""}`.trim())}else if(u.status<200||u.status>=300)throw new Error(`Apple SRP complete failed: HTTP ${u.status} ${u.rawBody??""}`.trim());return{relay:n,completeResponse:u,twoFactorChallengeResponse:s,requiresTwoFactor:y,finishTwoFactor:async c=>{const l=d.type==="phone"?await T(n,d.phoneNumberId,c,d.mode):await k(n,c);if(l.status<200||l.status>=300)throw new Error(`Apple two-factor code failed: HTTP ${l.status} ${l.rawBody??""}`.trim());return l},finalize:async()=>v(n),close:async()=>n.close()}}catch(p){throw n.close(),p}}function N(e){if(!f(e))return;const t=f(e.phoneNumberVerification)?e.phoneNumberVerification:void 0,r=w(t?.trustedPhoneNumber)??w(e.trustedPhoneNumber)??w(e.phoneNumber);if(!r)return;const o=r.id;if(typeof o!="number")return;const a=typeof r.pushMode=="string"?r.pushMode:typeof e.mode=="string"?e.mode:void 0;return{id:o,pushMode:a}}function w(e){return f(e)?e:void 0}function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}exports.AppleRelayWebSocketClient=m;exports.fetchAppleAccountSession=v;exports.openAppleRelayWebSocket=g;exports.proxyPhoneTwoFactorCode=T;exports.proxyProvisioningRequest=R;exports.proxySrpComplete=S;exports.proxySrpInit=A;exports.proxyTwoFactorCode=k;exports.startBrowserOwnedAppleIDLogin=x;exports.triggerPhoneTwoFactor=b;exports.triggerTrustedDeviceTwoFactor=P;
|