@limrun/ui 0.14.0-rc.5 → 0.14.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/README.md +9 -26
- package/dist/components/remote-control.d.ts +36 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1351 -1196
- package/package.json +10 -51
- package/src/components/remote-control.tsx +414 -2
- package/src/index.ts +1 -1
- package/vite.config.ts +0 -9
- package/dist/app-store-relay/index.cjs +0 -9
- package/dist/app-store-relay/index.d.ts +0 -204
- package/dist/app-store-relay/index.js +0 -677
- package/dist/app-store-relay/react.cjs +0 -1
- package/dist/app-store-relay/react.d.ts +0 -15
- package/dist/app-store-relay/react.js +0 -69
- package/dist/apple-credentials/index.cjs +0 -1
- package/dist/apple-credentials/index.d.ts +0 -110
- package/dist/apple-credentials/index.js +0 -291
- package/dist/browser-storage-BnO-Ma-e.mjs +0 -219
- package/dist/browser-storage-DLxIqZk5.js +0 -1
- package/dist/client-C9z_sgOf.js +0 -1
- package/dist/client-CFDB4mX5.mjs +0 -191
- package/dist/core/device-install/apple/client.d.ts +0 -18
- package/dist/core/device-install/apple/crypto.d.ts +0 -20
- package/dist/core/device-install/apple/gsa-srp.d.ts +0 -26
- package/dist/core/device-install/apple/index.d.ts +0 -5
- package/dist/core/device-install/apple/provisioning.d.ts +0 -237
- package/dist/core/device-install/apple/relay.d.ts +0 -53
- package/dist/core/device-install/index.d.ts +0 -4
- package/dist/core/device-install/operations/index.d.ts +0 -6
- package/dist/core/device-install/operations/limbuild-client.d.ts +0 -43
- package/dist/core/device-install/operations/operations.d.ts +0 -47
- package/dist/core/device-install/operations/relay-client.d.ts +0 -26
- package/dist/core/device-install/operations/relay-protocol.d.ts +0 -27
- package/dist/core/device-install/operations/usbmux.d.ts +0 -32
- package/dist/core/device-install/operations/webusb.d.ts +0 -21
- package/dist/core/device-install/storage/browser-storage.d.ts +0 -56
- package/dist/core/device-install/storage/index.d.ts +0 -2
- package/dist/core/device-install/storage/secret-store.d.ts +0 -124
- package/dist/core/device-install/types.d.ts +0 -57
- package/dist/core/errors.d.ts +0 -1
- package/dist/core/play-publish/google.d.ts +0 -13
- package/dist/core/play-publish/publish.d.ts +0 -34
- package/dist/device-build/index.cjs +0 -1
- package/dist/device-build/index.d.ts +0 -4
- package/dist/device-build/index.js +0 -85
- package/dist/device-build/react.cjs +0 -1
- package/dist/device-build/react.d.ts +0 -21
- package/dist/device-build/react.js +0 -68
- package/dist/device-build/signing.d.ts +0 -20
- package/dist/device-install/demo/demo.d.ts +0 -0
- package/dist/device-install/index.cjs +0 -1
- package/dist/device-install/index.d.ts +0 -18
- package/dist/device-install/index.js +0 -594
- package/dist/device-install/react.cjs +0 -1
- package/dist/device-install/react.d.ts +0 -24
- package/dist/device-install/react.js +0 -105
- package/dist/errors-BSkqS7U-.js +0 -1
- package/dist/errors-gy8yQJos.mjs +0 -6
- package/dist/gsa-srp-Bme3JLEi.mjs +0 -266
- package/dist/gsa-srp-CCIfUz7Y.js +0 -1
- package/dist/index-ChhtuQ7e.js +0 -22
- package/dist/index-YDu8K9a4.mjs +0 -11279
- package/dist/limbuild-client-BagK_FWE.mjs +0 -83
- package/dist/limbuild-client-CVDwq54z.js +0 -1
- package/dist/play-publish/index.cjs +0 -1
- package/dist/play-publish/index.d.ts +0 -2
- package/dist/play-publish/index.js +0 -109
- package/dist/play-publish/react.cjs +0 -1
- package/dist/play-publish/react.d.ts +0 -31
- package/dist/play-publish/react.js +0 -91
- package/dist/provisioning-CDPvxd1h.mjs +0 -270
- package/dist/provisioning-CbC4h--7.js +0 -1
- package/src/app-store-relay/index.test.ts +0 -60
- package/src/app-store-relay/index.ts +0 -846
- package/src/app-store-relay/react.ts +0 -131
- package/src/apple-credentials/index.test.ts +0 -180
- package/src/apple-credentials/index.ts +0 -388
- package/src/core/device-install/apple/client.ts +0 -150
- package/src/core/device-install/apple/crypto.ts +0 -205
- package/src/core/device-install/apple/gsa-srp.ts +0 -123
- package/src/core/device-install/apple/index.ts +0 -5
- package/src/core/device-install/apple/provisioning.test.ts +0 -114
- package/src/core/device-install/apple/provisioning.ts +0 -419
- package/src/core/device-install/apple/relay.ts +0 -202
- package/src/core/device-install/index.ts +0 -4
- package/src/core/device-install/operations/index.ts +0 -6
- package/src/core/device-install/operations/limbuild-client.ts +0 -144
- package/src/core/device-install/operations/operations.ts +0 -239
- package/src/core/device-install/operations/relay-client.ts +0 -286
- package/src/core/device-install/operations/relay-protocol.ts +0 -71
- package/src/core/device-install/operations/usbmux.ts +0 -270
- package/src/core/device-install/operations/webusb-dom.d.ts +0 -54
- package/src/core/device-install/operations/webusb.ts +0 -110
- package/src/core/device-install/storage/browser-storage.test.ts +0 -65
- package/src/core/device-install/storage/browser-storage.ts +0 -325
- package/src/core/device-install/storage/index.ts +0 -2
- package/src/core/device-install/storage/secret-store.ts +0 -332
- package/src/core/device-install/types.ts +0 -69
- package/src/core/errors.ts +0 -3
- package/src/core/play-publish/google.ts +0 -113
- package/src/core/play-publish/publish.test.ts +0 -68
- package/src/core/play-publish/publish.ts +0 -89
- package/src/device-build/index.ts +0 -42
- package/src/device-build/react.ts +0 -130
- package/src/device-build/signing.ts +0 -94
- package/src/device-install/README.md +0 -423
- package/src/device-install/demo/demo.css +0 -493
- package/src/device-install/demo/demo.tsx +0 -1061
- package/src/device-install/demo/index.html +0 -12
- package/src/device-install/index.ts +0 -50
- package/src/device-install/react.ts +0 -195
- package/src/play-publish/README.md +0 -66
- package/src/play-publish/index.ts +0 -12
- package/src/play-publish/react.ts +0 -208
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useState as n, useRef as S, useCallback as i, useEffect as A } from "react";
|
|
2
|
-
import { s as D } from "../client-CFDB4mX5.mjs";
|
|
3
|
-
import "../index-YDu8K9a4.mjs";
|
|
4
|
-
import "../gsa-srp-Bme3JLEi.mjs";
|
|
5
|
-
import { e as w } from "../errors-gy8yQJos.mjs";
|
|
6
|
-
function x({
|
|
7
|
-
registryApiUrl: u,
|
|
8
|
-
token: l,
|
|
9
|
-
organizationId: p
|
|
10
|
-
}) {
|
|
11
|
-
const [h, o] = n("idle"), [v, a] = n(), [g, d] = n(), [m, f] = n(), [R, s] = n(), t = S(void 0), C = i(async () => {
|
|
12
|
-
await t.current?.close().catch(() => {
|
|
13
|
-
}), t.current = void 0, a(void 0), d(void 0), f(void 0), s(void 0), o("idle");
|
|
14
|
-
}, []);
|
|
15
|
-
A(() => () => {
|
|
16
|
-
t.current?.close(), t.current = void 0;
|
|
17
|
-
}, []);
|
|
18
|
-
const F = i(
|
|
19
|
-
async ({ accountName: r, password: c }) => {
|
|
20
|
-
o("authenticating"), s(void 0), await t.current?.close().catch(() => {
|
|
21
|
-
});
|
|
22
|
-
try {
|
|
23
|
-
const e = await D({
|
|
24
|
-
registryApiUrl: u,
|
|
25
|
-
token: l,
|
|
26
|
-
organizationId: p,
|
|
27
|
-
accountName: r,
|
|
28
|
-
password: c
|
|
29
|
-
});
|
|
30
|
-
return t.current = e, a(e), d(e.completeResponse), f(e.twoFactorChallengeResponse), o(e.requiresTwoFactor ? "two-factor-required" : "authenticated"), e;
|
|
31
|
-
} catch (e) {
|
|
32
|
-
a(void 0), t.current = void 0, s(w(e)), o("error");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
[u, p, l]
|
|
37
|
-
), b = i(async (r) => {
|
|
38
|
-
const c = t.current;
|
|
39
|
-
if (!c)
|
|
40
|
-
throw new Error("Start Apple ID login before submitting a two-factor code.");
|
|
41
|
-
o("authenticating"), s(void 0);
|
|
42
|
-
try {
|
|
43
|
-
const e = await c.finishTwoFactor(r);
|
|
44
|
-
return o("authenticated"), e;
|
|
45
|
-
} catch (e) {
|
|
46
|
-
s(w(e)), o("error");
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
}, []), y = i(async () => {
|
|
50
|
-
const r = t.current;
|
|
51
|
-
if (!r)
|
|
52
|
-
throw new Error("Start Apple ID login before finalizing the Apple session.");
|
|
53
|
-
return r.finalize();
|
|
54
|
-
}, []);
|
|
55
|
-
return {
|
|
56
|
-
status: h,
|
|
57
|
-
session: v,
|
|
58
|
-
completeResponse: g,
|
|
59
|
-
twoFactorChallengeResponse: m,
|
|
60
|
-
error: R,
|
|
61
|
-
startLogin: F,
|
|
62
|
-
submitTwoFactorCode: b,
|
|
63
|
-
finalize: y,
|
|
64
|
-
close: C
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
x as useAppleIDLogin
|
|
69
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../app-store-relay/index.cjs"),T=require("../browser-storage-DLxIqZk5.js"),v="appleCertificate",b="appleProvisioningProfile",I="appStoreConnectApiKey";function h(e){const t={};for(const[o,r]of Object.entries(e))r&&(t[o]=r);return t}async function _(e,t,o){return e.put(v,t,h(o))}async function R(e,t,o){return e.put(b,t,h(o))}async function D(e,t,o){return e.put(I,t,h(o))}function B(e){const t=e.fetch??fetch.bind(globalThis),o=e.apiUrl.replace(/\/+$/,""),r=(n,s)=>`${o}/v1/organizations/${encodeURIComponent(e.organizationId)}/secrets/${encodeURIComponent(n)}/${encodeURIComponent(s)}`,c={Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"};async function a(n,s){let i=`${n.status}`;try{const p=await n.json();p.message&&(i=p.message)}catch{}throw new Error(`Failed to ${s} secret: ${i}`)}return{async put(n,s,i){const p=await t(r(n,s),{method:"PUT",headers:c,body:JSON.stringify({data:i,replace:!0})});p.ok||await a(p,"store");const d=await p.json();return{type:d.type,name:d.name,createdAt:d.createdAt,data:d.data}},async get(n,s){const i=await t(r(n,s),{method:"GET",headers:c});if(i.status===404)return;i.ok||await a(i,"fetch");const p=await i.json();return{type:p.type,name:p.name,createdAt:p.createdAt,data:p.data}},async list(){const n=await t(`${o}/v1/organizations/${encodeURIComponent(e.organizationId)}/secrets`,{method:"GET",headers:c});return n.ok||await a(n,"list"),(await n.json()).filter(i=>i.type===v||i.type===b||i.type===I).map(i=>({type:i.type,name:i.name,createdAt:i.createdAt}))},async delete(n,s){const i=await t(r(n,s),{method:"DELETE",headers:c});i.status!==404&&(i.ok||await a(i,"delete"))}}}const O="limrun-signing-secrets",K=1,l="secrets";function j(){const e=(r,c)=>`${r}:${c}`;function t(){return new Promise((r,c)=>{const a=indexedDB.open(O,K);a.onupgradeneeded=()=>{const n=a.result;n.objectStoreNames.contains(l)||n.createObjectStore(l,{keyPath:"id"})},a.onsuccess=()=>r(a.result),a.onerror=()=>c(a.error??new Error("Open IndexedDB failed"))})}function o(r){return new Promise((c,a)=>{r.onsuccess=()=>c(r.result),r.onerror=()=>a(r.error??new Error("IndexedDB request failed"))})}return{async put(r,c,a){const n=await t(),s=await o(n.transaction(l,"readonly").objectStore(l).get(e(r,c))),i={id:e(r,c),type:r,name:c,data:a,createdAt:s?.createdAt??new Date().toISOString()};return await o(n.transaction(l,"readwrite").objectStore(l).put(i)),{type:r,name:c,createdAt:i.createdAt,data:a}},async get(r,c){const a=await t(),n=await o(a.transaction(l,"readonly").objectStore(l).get(e(r,c)));if(n)return{type:n.type,name:n.name,createdAt:n.createdAt,data:n.data}},async list(){const r=await t();return(await o(r.transaction(l,"readonly").objectStore(l).getAll())).map(a=>({type:a.type,name:a.name,createdAt:a.createdAt}))},async delete(r,c){const a=await t();await o(a.transaction(l,"readwrite").objectStore(l).delete(e(r,c)))}}}function N(e,t){return`${e}/${t}`}async function x({relay:e,teamId:t,secretStore:o,certificateKind:r="development",commonName:c,log:a=()=>{}}){const n=r==="distribution"?"DISTRIBUTION":"DEVELOPMENT",s=N(t,n),i=await u.listAppleCertificates({relay:e,teamId:t,certificateKind:r}),p=S=>S===void 0?void 0:i.find(C=>f(C,"certificateId")===S||f(C,"certRequestId")===S),d=await o.get(v,s),m=f(d?.data,"certificateID");if(d&&m&&d.data.certificateP12Base64){const S=p(m);if(S){const C=f(S,"certificateId")??m;return a("Reusing stored Apple certificate",C),{secret:d,certificateId:C,created:!1}}a("Stored certificate is no longer on the team","Minting a new one.")}const y=await u.generateAppleSigningKeyAndCSR({commonName:c??`Limrun ${t}`}),w=await u.createAppleCertificate({relay:e,teamId:t,certificateKind:r,csrPEM:y.csrPEM}),A=f(w,"certificateId")??f(w,"certRequestId");if(!A)throw new Error("Apple certificate creation did not return a certificate ID.");const E=await u.downloadAppleCertificate({relay:e,teamId:t,certificateKind:r,certificateId:A});if(!E.rawBodyBase64)throw new Error("Apple certificate download returned no bytes.");const g={certificateP12Base64:u.exportAppleCertificateP12({privateKeyPKCS8Base64:y.privateKeyPKCS8Base64,certificateBase64:E.rawBodyBase64,password:"",friendlyName:`Apple ${r==="distribution"?"Distribution":"Development"} ${t}`}),certificateType:n,teamID:t,certificateID:A,serialNumber:T.normalizeCertificateSerial(f(w,"serialNum")),expirationDate:f(w,"expirationDateString")};let P;try{P=await _(o,s,g)}catch(S){throw new Error(`Certificate ${A} was created on the Apple Developer portal but saving its private key to the secret store failed: ${k(S)}. The key cannot be recovered; revoke certificate ${A} at developer.apple.com before retrying, or the retry will mint another certificate against Apple's limit.`)}return a("Apple certificate stored",A),{secret:P,certificateId:A,created:!0}}function k(e){return e instanceof Error?e.message:String(e)}async function L({relay:e,teamId:t,profileId:o,secretStore:r,log:c=()=>{}}){const n=(await u.downloadAppleProfile({relay:e,teamId:t,profileId:o})).rawBodyBase64;if(!n)throw new Error("Apple provisioning profile download returned no bytes.");const s=T.parseProvisioningProfileBase64(n),i=`${t}/${s.uuid??o}`,p=await R(r,i,{provisioningProfileBase64:n,certificateSerialNumbers:s.certificateSerialNumbers.join(","),bundleIDs:s.bundleID,deviceIDs:s.provisionedDevices.join(","),teamID:s.teamID??t,profileName:s.name,uuid:s.uuid,expirationDate:s.expirationDate});return c("Apple provisioning profile stored",i),p}function $(e){return`${e}/APP_STORE_CONNECT_API_KEY`}async function F({relay:e,teamId:t,providerId:o,secretStore:r,nickname:c,roles:a,log:n=()=>{}}){if(!c)throw new Error("A nickname is required to ensure an App Store Connect API key.");o!==void 0&&await u.switchAppStoreConnectProvider({relay:e,providerId:o});const s=$(t),i=await u.listAppStoreConnectApiKeys({relay:e}),p=await r.get(I,s),d=f(p?.data,"keyId");if(p&&d&&p.data.privateKeyP8Base64){if(i.find(P=>P.id===d&&!Y(P.attributes)))return n("Reusing stored App Store Connect API key",d),{secret:p,keyId:d,created:!1};n("Stored App Store Connect API key is no longer active","Minting a new one.")}const y=(await u.createAppStoreConnectApiKey({relay:e,nickname:c,roles:a})).id,w=await u.downloadAppStoreConnectApiKeyPrivateKey({relay:e,keyId:y}),A={privateKeyP8Base64:z(w.privateKeyPem),keyId:y,issuerId:w.issuerId,nickname:c,teamID:t};let E;try{E=await D(r,s,A)}catch(g){throw new Error(`App Store Connect API key ${y} was created but saving its private key to the secret store failed: ${k(g)}. The key cannot be downloaded again; revoke key ${y} in App Store Connect before retrying, or the retry will mint another key.`)}return n("App Store Connect API key stored",y),{secret:E,keyId:y,created:!0}}function Y(e){if(!e)return!1;if(e.isActive===!1)return!0;const t=e.revokingDate??e.revocationDate;return typeof t=="string"&&t!==""}function z(e){const t=new TextEncoder().encode(e);let o="";for(const r of t)o+=String.fromCharCode(r);return btoa(o)}async function M({relay:e,teamId:t,profileKind:o="development"}){return u.listAppleProfiles({relay:e,teamId:t,profileKind:o})}function f(e,t){const o=e?.[t];if(typeof o=="string")return o;if(typeof o=="number"||typeof o=="boolean")return String(o)}exports.normalizeCertificateSerial=T.normalizeCertificateSerial;exports.APPLE_CERTIFICATE_SECRET_TYPE=v;exports.APPLE_PROVISIONING_PROFILE_SECRET_TYPE=b;exports.APP_STORE_CONNECT_API_KEY_SECRET_TYPE=I;exports.appStoreConnectApiKeySecretName=$;exports.appleCertificateSecretName=N;exports.createBrowserSecretStore=j;exports.createLimrunSecretStore=B;exports.ensureAppStoreConnectApiKeySecret=F;exports.ensureAppleCertificateSecret=x;exports.listTeamAppleProfiles=M;exports.putAppStoreConnectApiKeySecret=D;exports.putAppleCertificateSecret=_;exports.putAppleProvisioningProfileSecret=R;exports.saveAppleProfileSecret=L;exports.stringField=f;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { AppleCertificateKind, AppleProfileKind, AppStoreConnectApiKeyRole } from '../app-store-relay';
|
|
2
|
-
import { AppleRelayWebSocketClient } from '../core/device-install/apple';
|
|
3
|
-
import { AppleCertificateType, SigningSecret, SigningSecretStore } from '../core/device-install/storage/secret-store';
|
|
4
|
-
export { APP_STORE_CONNECT_API_KEY_SECRET_TYPE, APPLE_CERTIFICATE_SECRET_TYPE, APPLE_PROVISIONING_PROFILE_SECRET_TYPE, createBrowserSecretStore, createLimrunSecretStore, putAppleCertificateSecret, putAppleProvisioningProfileSecret, putAppStoreConnectApiKeySecret, type AppleCertificateSecretData, type AppleCertificateType, type AppleProvisioningProfileSecretData, type AppStoreConnectApiKeySecretData, type LimrunSecretStoreOptions, type SigningSecret, type SigningSecretData, type SigningSecretMetadata, type SigningSecretStore, type SigningSecretType, } from '../core/device-install/storage/secret-store';
|
|
5
|
-
export { normalizeCertificateSerial } from '../core/device-install/storage/browser-storage';
|
|
6
|
-
/**
|
|
7
|
-
* Conventional secret name of a team's certificate bundle. One bundle per
|
|
8
|
-
* team and Apple certificate type; the type is in the name so development
|
|
9
|
-
* and distribution material never collide.
|
|
10
|
-
*/
|
|
11
|
-
export declare function appleCertificateSecretName(teamId: string, certificateType: AppleCertificateType): string;
|
|
12
|
-
export type EnsureAppleCertificateInput = {
|
|
13
|
-
relay: AppleRelayWebSocketClient;
|
|
14
|
-
teamId: string;
|
|
15
|
-
secretStore: SigningSecretStore;
|
|
16
|
-
/**
|
|
17
|
-
* Which portal certificate kind to ensure. Ad-hoc and App Store signing
|
|
18
|
-
* both use the distribution certificate. Defaults to development.
|
|
19
|
-
*/
|
|
20
|
-
certificateKind?: AppleCertificateKind;
|
|
21
|
-
/** Common name used when minting a new certificate. */
|
|
22
|
-
commonName?: string;
|
|
23
|
-
log?: (message: string, detail?: string) => void;
|
|
24
|
-
};
|
|
25
|
-
export type EnsureAppleCertificateResult = {
|
|
26
|
-
secret: SigningSecret;
|
|
27
|
-
certificateId: string;
|
|
28
|
-
/** True when a new certificate was minted instead of reusing the stored one. */
|
|
29
|
-
created: boolean;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Returns a usable certificate secret of the requested kind for the team,
|
|
33
|
-
* reusing the stored one when its certificate is still on the team and
|
|
34
|
-
* minting a new one otherwise. Apple caps certificates per kind (2 for
|
|
35
|
-
* development, 3 for distribution) and never returns private keys, so
|
|
36
|
-
* reuse of the stored p12 is strongly preferred.
|
|
37
|
-
*
|
|
38
|
-
* Durability of the stored material is the secret store's concern:
|
|
39
|
-
* implementors who want retries or fallbacks build them into their
|
|
40
|
-
* SigningSecretStore.
|
|
41
|
-
*/
|
|
42
|
-
export declare function ensureAppleCertificateSecret({ relay, teamId, secretStore, certificateKind, commonName, log, }: EnsureAppleCertificateInput): Promise<EnsureAppleCertificateResult>;
|
|
43
|
-
export type SaveAppleProfileInput = {
|
|
44
|
-
relay: AppleRelayWebSocketClient;
|
|
45
|
-
teamId: string;
|
|
46
|
-
profileId: string;
|
|
47
|
-
secretStore: SigningSecretStore;
|
|
48
|
-
log?: (message: string, detail?: string) => void;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Downloads the provisioning profile and stores it as an
|
|
52
|
-
* appleProvisioningProfile secret named `${teamId}/${uuid}`. The UUID is
|
|
53
|
-
* unique per profile, so a team can hold many profiles for the same
|
|
54
|
-
* bundle ID and certificate set; the reference fields (certificate
|
|
55
|
-
* serials, bundle IDs, device IDs parsed out of the profile) are what
|
|
56
|
-
* consumers filter on.
|
|
57
|
-
*/
|
|
58
|
-
export declare function saveAppleProfileSecret({ relay, teamId, profileId, secretStore, log, }: SaveAppleProfileInput): Promise<SigningSecret>;
|
|
59
|
-
/**
|
|
60
|
-
* Conventional secret name of a team's App Store Connect API key: one
|
|
61
|
-
* shared key per team.
|
|
62
|
-
*/
|
|
63
|
-
export declare function appStoreConnectApiKeySecretName(teamId: string): string;
|
|
64
|
-
export type EnsureAppStoreConnectApiKeyInput = {
|
|
65
|
-
relay: AppleRelayWebSocketClient;
|
|
66
|
-
teamId: string;
|
|
67
|
-
/**
|
|
68
|
-
* Numeric provider ID of the team from the Apple team list. When given,
|
|
69
|
-
* the App Store Connect session is switched to this provider first;
|
|
70
|
-
* required for accounts that belong to multiple teams.
|
|
71
|
-
*/
|
|
72
|
-
providerId?: string | number;
|
|
73
|
-
secretStore: SigningSecretStore;
|
|
74
|
-
/** Display name for a newly minted key. Required; there is no default. */
|
|
75
|
-
nickname: string;
|
|
76
|
-
/** Roles of a newly minted key. Defaults to APP_MANAGER. */
|
|
77
|
-
roles?: AppStoreConnectApiKeyRole[];
|
|
78
|
-
log?: (message: string, detail?: string) => void;
|
|
79
|
-
};
|
|
80
|
-
export type EnsureAppStoreConnectApiKeyResult = {
|
|
81
|
-
secret: SigningSecret;
|
|
82
|
-
keyId: string;
|
|
83
|
-
/** True when a new key was minted instead of reusing the stored one. */
|
|
84
|
-
created: boolean;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Returns a usable App Store Connect API key secret for the team, reusing
|
|
88
|
-
* the stored one when its key is still active and minting a new one
|
|
89
|
-
* otherwise. Apple serves a key's private half exactly once (at creation
|
|
90
|
-
* time through the sparse fieldset download), so reuse of the stored .p8
|
|
91
|
-
* is strongly preferred.
|
|
92
|
-
*
|
|
93
|
-
* The session user must be a team Admin to list or create keys.
|
|
94
|
-
*/
|
|
95
|
-
export declare function ensureAppStoreConnectApiKeySecret({ relay, teamId, providerId, secretStore, nickname, roles, log, }: EnsureAppStoreConnectApiKeyInput): Promise<EnsureAppStoreConnectApiKeyResult>;
|
|
96
|
-
export type ListTeamProfilesInput = {
|
|
97
|
-
relay: AppleRelayWebSocketClient;
|
|
98
|
-
teamId: string;
|
|
99
|
-
/**
|
|
100
|
-
* Which portal profile listing to use. The development listing is
|
|
101
|
-
* unfiltered on the portal side and returns profiles of every
|
|
102
|
-
* distribution method; adhoc narrows to ad-hoc profiles. Defaults to
|
|
103
|
-
* development.
|
|
104
|
-
*/
|
|
105
|
-
profileKind?: AppleProfileKind;
|
|
106
|
-
};
|
|
107
|
-
/** Lists the team's provisioning profiles from the portal. */
|
|
108
|
-
export declare function listTeamAppleProfiles({ relay, teamId, profileKind, }: ListTeamProfilesInput): Promise<Record<string, unknown>[]>;
|
|
109
|
-
/** Read a string-ish value from a loosely typed portal record. */
|
|
110
|
-
export declare function stringField(record: Record<string, unknown> | undefined, key: string): string | undefined;
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { listAppleCertificates as T, generateAppleSigningKeyAndCSR as D, createAppleCertificate as k, downloadAppleCertificate as $, exportAppleCertificateP12 as B, downloadAppleProfile as N, switchAppStoreConnectProvider as R, listAppStoreConnectApiKeys as _, createAppStoreConnectApiKey as O, downloadAppStoreConnectApiKeyPrivateKey as j, listAppleProfiles as K } from "../app-store-relay/index.js";
|
|
2
|
-
import { l as x, f as U } from "../browser-storage-BnO-Ma-e.mjs";
|
|
3
|
-
const C = "appleCertificate", I = "appleProvisioningProfile", v = "appStoreConnectApiKey";
|
|
4
|
-
function b(e) {
|
|
5
|
-
const t = {};
|
|
6
|
-
for (const [o, r] of Object.entries(e))
|
|
7
|
-
r && (t[o] = r);
|
|
8
|
-
return t;
|
|
9
|
-
}
|
|
10
|
-
async function L(e, t, o) {
|
|
11
|
-
return e.put(C, t, b(o));
|
|
12
|
-
}
|
|
13
|
-
async function M(e, t, o) {
|
|
14
|
-
return e.put(I, t, b(o));
|
|
15
|
-
}
|
|
16
|
-
async function z(e, t, o) {
|
|
17
|
-
return e.put(v, t, b(o));
|
|
18
|
-
}
|
|
19
|
-
function W(e) {
|
|
20
|
-
const t = e.fetch ?? fetch.bind(globalThis), o = e.apiUrl.replace(/\/+$/, ""), r = (n, s) => `${o}/v1/organizations/${encodeURIComponent(e.organizationId)}/secrets/${encodeURIComponent(
|
|
21
|
-
n
|
|
22
|
-
)}/${encodeURIComponent(s)}`, c = {
|
|
23
|
-
Authorization: `Bearer ${e.token}`,
|
|
24
|
-
"Content-Type": "application/json"
|
|
25
|
-
};
|
|
26
|
-
async function a(n, s) {
|
|
27
|
-
let i = `${n.status}`;
|
|
28
|
-
try {
|
|
29
|
-
const d = await n.json();
|
|
30
|
-
d.message && (i = d.message);
|
|
31
|
-
} catch {
|
|
32
|
-
}
|
|
33
|
-
throw new Error(`Failed to ${s} secret: ${i}`);
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
async put(n, s, i) {
|
|
37
|
-
const d = await t(r(n, s), {
|
|
38
|
-
method: "PUT",
|
|
39
|
-
headers: c,
|
|
40
|
-
body: JSON.stringify({ data: i, replace: !0 })
|
|
41
|
-
});
|
|
42
|
-
d.ok || await a(d, "store");
|
|
43
|
-
const p = await d.json();
|
|
44
|
-
return { type: p.type, name: p.name, createdAt: p.createdAt, data: p.data };
|
|
45
|
-
},
|
|
46
|
-
async get(n, s) {
|
|
47
|
-
const i = await t(r(n, s), { method: "GET", headers: c });
|
|
48
|
-
if (i.status === 404) return;
|
|
49
|
-
i.ok || await a(i, "fetch");
|
|
50
|
-
const d = await i.json();
|
|
51
|
-
return { type: d.type, name: d.name, createdAt: d.createdAt, data: d.data };
|
|
52
|
-
},
|
|
53
|
-
async list() {
|
|
54
|
-
const n = await t(
|
|
55
|
-
`${o}/v1/organizations/${encodeURIComponent(e.organizationId)}/secrets`,
|
|
56
|
-
{ method: "GET", headers: c }
|
|
57
|
-
);
|
|
58
|
-
return n.ok || await a(n, "list"), (await n.json()).filter(
|
|
59
|
-
(i) => i.type === C || i.type === I || i.type === v
|
|
60
|
-
).map((i) => ({ type: i.type, name: i.name, createdAt: i.createdAt }));
|
|
61
|
-
},
|
|
62
|
-
async delete(n, s) {
|
|
63
|
-
const i = await t(r(n, s), { method: "DELETE", headers: c });
|
|
64
|
-
i.status !== 404 && (i.ok || await a(i, "delete"));
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const F = "limrun-signing-secrets", Y = 1, f = "secrets";
|
|
69
|
-
function X() {
|
|
70
|
-
const e = (r, c) => `${r}:${c}`;
|
|
71
|
-
function t() {
|
|
72
|
-
return new Promise((r, c) => {
|
|
73
|
-
const a = indexedDB.open(F, Y);
|
|
74
|
-
a.onupgradeneeded = () => {
|
|
75
|
-
const n = a.result;
|
|
76
|
-
n.objectStoreNames.contains(f) || n.createObjectStore(f, { keyPath: "id" });
|
|
77
|
-
}, a.onsuccess = () => r(a.result), a.onerror = () => c(a.error ?? new Error("Open IndexedDB failed"));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function o(r) {
|
|
81
|
-
return new Promise((c, a) => {
|
|
82
|
-
r.onsuccess = () => c(r.result), r.onerror = () => a(r.error ?? new Error("IndexedDB request failed"));
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
async put(r, c, a) {
|
|
87
|
-
const n = await t(), s = await o(
|
|
88
|
-
n.transaction(f, "readonly").objectStore(f).get(e(r, c))
|
|
89
|
-
), i = {
|
|
90
|
-
id: e(r, c),
|
|
91
|
-
type: r,
|
|
92
|
-
name: c,
|
|
93
|
-
data: a,
|
|
94
|
-
createdAt: s?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
95
|
-
};
|
|
96
|
-
return await o(
|
|
97
|
-
n.transaction(f, "readwrite").objectStore(f).put(i)
|
|
98
|
-
), { type: r, name: c, createdAt: i.createdAt, data: a };
|
|
99
|
-
},
|
|
100
|
-
async get(r, c) {
|
|
101
|
-
const a = await t(), n = await o(
|
|
102
|
-
a.transaction(f, "readonly").objectStore(f).get(e(r, c))
|
|
103
|
-
);
|
|
104
|
-
if (n)
|
|
105
|
-
return { type: n.type, name: n.name, createdAt: n.createdAt, data: n.data };
|
|
106
|
-
},
|
|
107
|
-
async list() {
|
|
108
|
-
const r = await t();
|
|
109
|
-
return (await o(
|
|
110
|
-
r.transaction(f, "readonly").objectStore(f).getAll()
|
|
111
|
-
)).map((a) => ({ type: a.type, name: a.name, createdAt: a.createdAt }));
|
|
112
|
-
},
|
|
113
|
-
async delete(r, c) {
|
|
114
|
-
const a = await t();
|
|
115
|
-
await o(
|
|
116
|
-
a.transaction(f, "readwrite").objectStore(f).delete(e(r, c))
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function G(e, t) {
|
|
122
|
-
return `${e}/${t}`;
|
|
123
|
-
}
|
|
124
|
-
async function Z({
|
|
125
|
-
relay: e,
|
|
126
|
-
teamId: t,
|
|
127
|
-
secretStore: o,
|
|
128
|
-
certificateKind: r = "development",
|
|
129
|
-
commonName: c,
|
|
130
|
-
log: a = () => {
|
|
131
|
-
}
|
|
132
|
-
}) {
|
|
133
|
-
const n = r === "distribution" ? "DISTRIBUTION" : "DEVELOPMENT", s = G(t, n), i = await T({ relay: e, teamId: t, certificateKind: r }), d = (w) => w === void 0 ? void 0 : i.find(
|
|
134
|
-
(E) => y(E, "certificateId") === w || y(E, "certRequestId") === w
|
|
135
|
-
), p = await o.get(C, s), P = y(p?.data, "certificateID");
|
|
136
|
-
if (p && P && p.data.certificateP12Base64) {
|
|
137
|
-
const w = d(P);
|
|
138
|
-
if (w) {
|
|
139
|
-
const E = y(w, "certificateId") ?? P;
|
|
140
|
-
return a("Reusing stored Apple certificate", E), { secret: p, certificateId: E, created: !1 };
|
|
141
|
-
}
|
|
142
|
-
a("Stored certificate is no longer on the team", "Minting a new one.");
|
|
143
|
-
}
|
|
144
|
-
const l = await D({ commonName: c ?? `Limrun ${t}` }), A = await k({
|
|
145
|
-
relay: e,
|
|
146
|
-
teamId: t,
|
|
147
|
-
certificateKind: r,
|
|
148
|
-
csrPEM: l.csrPEM
|
|
149
|
-
}), u = y(A, "certificateId") ?? y(A, "certRequestId");
|
|
150
|
-
if (!u)
|
|
151
|
-
throw new Error("Apple certificate creation did not return a certificate ID.");
|
|
152
|
-
const S = await $({
|
|
153
|
-
relay: e,
|
|
154
|
-
teamId: t,
|
|
155
|
-
certificateKind: r,
|
|
156
|
-
certificateId: u
|
|
157
|
-
});
|
|
158
|
-
if (!S.rawBodyBase64)
|
|
159
|
-
throw new Error("Apple certificate download returned no bytes.");
|
|
160
|
-
const g = {
|
|
161
|
-
certificateP12Base64: B({
|
|
162
|
-
privateKeyPKCS8Base64: l.privateKeyPKCS8Base64,
|
|
163
|
-
certificateBase64: S.rawBodyBase64,
|
|
164
|
-
password: "",
|
|
165
|
-
friendlyName: `Apple ${r === "distribution" ? "Distribution" : "Development"} ${t}`
|
|
166
|
-
}),
|
|
167
|
-
certificateType: n,
|
|
168
|
-
teamID: t,
|
|
169
|
-
certificateID: u,
|
|
170
|
-
// Normalized so it equals the serials profiles reference.
|
|
171
|
-
serialNumber: x(y(A, "serialNum")),
|
|
172
|
-
expirationDate: y(A, "expirationDateString")
|
|
173
|
-
};
|
|
174
|
-
let m;
|
|
175
|
-
try {
|
|
176
|
-
m = await L(o, s, g);
|
|
177
|
-
} catch (w) {
|
|
178
|
-
throw new Error(
|
|
179
|
-
`Certificate ${u} was created on the Apple Developer portal but saving its private key to the secret store failed: ${h(w)}. The key cannot be recovered; revoke certificate ${u} at developer.apple.com before retrying, or the retry will mint another certificate against Apple's limit.`
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
return a("Apple certificate stored", u), { secret: m, certificateId: u, created: !0 };
|
|
183
|
-
}
|
|
184
|
-
function h(e) {
|
|
185
|
-
return e instanceof Error ? e.message : String(e);
|
|
186
|
-
}
|
|
187
|
-
async function ee({
|
|
188
|
-
relay: e,
|
|
189
|
-
teamId: t,
|
|
190
|
-
profileId: o,
|
|
191
|
-
secretStore: r,
|
|
192
|
-
log: c = () => {
|
|
193
|
-
}
|
|
194
|
-
}) {
|
|
195
|
-
const n = (await N({ relay: e, teamId: t, profileId: o })).rawBodyBase64;
|
|
196
|
-
if (!n)
|
|
197
|
-
throw new Error("Apple provisioning profile download returned no bytes.");
|
|
198
|
-
const s = U(n), i = `${t}/${s.uuid ?? o}`, d = await M(r, i, {
|
|
199
|
-
provisioningProfileBase64: n,
|
|
200
|
-
certificateSerialNumbers: s.certificateSerialNumbers.join(","),
|
|
201
|
-
bundleIDs: s.bundleID,
|
|
202
|
-
deviceIDs: s.provisionedDevices.join(","),
|
|
203
|
-
teamID: s.teamID ?? t,
|
|
204
|
-
profileName: s.name,
|
|
205
|
-
uuid: s.uuid,
|
|
206
|
-
expirationDate: s.expirationDate
|
|
207
|
-
});
|
|
208
|
-
return c("Apple provisioning profile stored", i), d;
|
|
209
|
-
}
|
|
210
|
-
function V(e) {
|
|
211
|
-
return `${e}/APP_STORE_CONNECT_API_KEY`;
|
|
212
|
-
}
|
|
213
|
-
async function te({
|
|
214
|
-
relay: e,
|
|
215
|
-
teamId: t,
|
|
216
|
-
providerId: o,
|
|
217
|
-
secretStore: r,
|
|
218
|
-
nickname: c,
|
|
219
|
-
roles: a,
|
|
220
|
-
log: n = () => {
|
|
221
|
-
}
|
|
222
|
-
}) {
|
|
223
|
-
if (!c)
|
|
224
|
-
throw new Error("A nickname is required to ensure an App Store Connect API key.");
|
|
225
|
-
o !== void 0 && await R({ relay: e, providerId: o });
|
|
226
|
-
const s = V(t), i = await _({ relay: e }), d = await r.get(v, s), p = y(d?.data, "keyId");
|
|
227
|
-
if (d && p && d.data.privateKeyP8Base64) {
|
|
228
|
-
if (i.find((m) => m.id === p && !q(m.attributes)))
|
|
229
|
-
return n("Reusing stored App Store Connect API key", p), { secret: d, keyId: p, created: !1 };
|
|
230
|
-
n("Stored App Store Connect API key is no longer active", "Minting a new one.");
|
|
231
|
-
}
|
|
232
|
-
const l = (await O({ relay: e, nickname: c, roles: a })).id, A = await j({ relay: e, keyId: l }), u = {
|
|
233
|
-
privateKeyP8Base64: J(A.privateKeyPem),
|
|
234
|
-
keyId: l,
|
|
235
|
-
issuerId: A.issuerId,
|
|
236
|
-
nickname: c,
|
|
237
|
-
teamID: t
|
|
238
|
-
};
|
|
239
|
-
let S;
|
|
240
|
-
try {
|
|
241
|
-
S = await z(r, s, u);
|
|
242
|
-
} catch (g) {
|
|
243
|
-
throw new Error(
|
|
244
|
-
`App Store Connect API key ${l} was created but saving its private key to the secret store failed: ${h(g)}. The key cannot be downloaded again; revoke key ${l} in App Store Connect before retrying, or the retry will mint another key.`
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
return n("App Store Connect API key stored", l), { secret: S, keyId: l, created: !0 };
|
|
248
|
-
}
|
|
249
|
-
function q(e) {
|
|
250
|
-
if (!e) return !1;
|
|
251
|
-
if (e.isActive === !1) return !0;
|
|
252
|
-
const t = e.revokingDate ?? e.revocationDate;
|
|
253
|
-
return typeof t == "string" && t !== "";
|
|
254
|
-
}
|
|
255
|
-
function J(e) {
|
|
256
|
-
const t = new TextEncoder().encode(e);
|
|
257
|
-
let o = "";
|
|
258
|
-
for (const r of t)
|
|
259
|
-
o += String.fromCharCode(r);
|
|
260
|
-
return btoa(o);
|
|
261
|
-
}
|
|
262
|
-
async function re({
|
|
263
|
-
relay: e,
|
|
264
|
-
teamId: t,
|
|
265
|
-
profileKind: o = "development"
|
|
266
|
-
}) {
|
|
267
|
-
return K({ relay: e, teamId: t, profileKind: o });
|
|
268
|
-
}
|
|
269
|
-
function y(e, t) {
|
|
270
|
-
const o = e?.[t];
|
|
271
|
-
if (typeof o == "string") return o;
|
|
272
|
-
if (typeof o == "number" || typeof o == "boolean") return String(o);
|
|
273
|
-
}
|
|
274
|
-
export {
|
|
275
|
-
C as APPLE_CERTIFICATE_SECRET_TYPE,
|
|
276
|
-
I as APPLE_PROVISIONING_PROFILE_SECRET_TYPE,
|
|
277
|
-
v as APP_STORE_CONNECT_API_KEY_SECRET_TYPE,
|
|
278
|
-
V as appStoreConnectApiKeySecretName,
|
|
279
|
-
G as appleCertificateSecretName,
|
|
280
|
-
X as createBrowserSecretStore,
|
|
281
|
-
W as createLimrunSecretStore,
|
|
282
|
-
te as ensureAppStoreConnectApiKeySecret,
|
|
283
|
-
Z as ensureAppleCertificateSecret,
|
|
284
|
-
re as listTeamAppleProfiles,
|
|
285
|
-
x as normalizeCertificateSerial,
|
|
286
|
-
z as putAppStoreConnectApiKeySecret,
|
|
287
|
-
L as putAppleCertificateSecret,
|
|
288
|
-
M as putAppleProvisioningProfileSecret,
|
|
289
|
-
ee as saveAppleProfileSecret,
|
|
290
|
-
y as stringField
|
|
291
|
-
};
|