@limrun/ui 0.14.0-rc.3 → 0.14.0-rc.4
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.js +5 -5
- package/dist/app-store-relay/react.cjs +1 -1
- package/dist/app-store-relay/react.js +32 -33
- package/dist/apple-credentials/index.cjs +1 -0
- package/dist/apple-credentials/index.d.ts +59 -0
- package/dist/apple-credentials/index.js +227 -0
- package/dist/browser-storage-BnO-Ma-e.mjs +219 -0
- package/dist/browser-storage-DLxIqZk5.js +1 -0
- package/dist/client-D1drDXxE.js +1 -0
- package/dist/{client-C8ZDEjtD.mjs → client-DSuNtWDv.mjs} +1 -1
- package/dist/components/remote-control.d.ts +156 -0
- package/dist/core/device-install/storage/browser-storage.d.ts +8 -0
- package/dist/core/device-install/storage/index.d.ts +1 -0
- package/dist/core/device-install/storage/secret-store.d.ts +101 -0
- package/dist/core/device-install/types.d.ts +6 -0
- package/dist/core/errors.d.ts +1 -0
- package/dist/core/play-publish/google.d.ts +1 -1
- package/dist/device-build/index.cjs +1 -1
- package/dist/device-build/index.js +21 -20
- package/dist/device-build/react.cjs +1 -1
- package/dist/device-build/react.js +42 -43
- package/dist/device-install/index.cjs +1 -1
- package/dist/device-install/index.js +159 -161
- package/dist/device-install/react.cjs +1 -1
- package/dist/device-install/react.js +47 -49
- package/dist/errors-BSkqS7U-.js +1 -0
- package/dist/errors-gy8yQJos.mjs +6 -0
- package/dist/gsa-srp-Bme3JLEi.mjs +266 -0
- package/dist/gsa-srp-CCIfUz7Y.js +1 -0
- package/dist/index-ChhtuQ7e.js +22 -0
- package/dist/index-YDu8K9a4.mjs +11279 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +1405 -1125
- package/dist/play-publish/index.cjs +1 -1
- package/dist/play-publish/index.js +27 -24
- package/dist/play-publish/react.cjs +1 -1
- package/dist/play-publish/react.d.ts +12 -2
- package/dist/play-publish/react.js +70 -60
- package/dist/{provisioning-BmsEnF6X.mjs → provisioning-B_DefBEp.mjs} +1 -1
- package/dist/{provisioning-Va0PH4Kk.js → provisioning-BlQMccX_.js} +1 -1
- package/package.json +6 -1
- package/src/app-store-relay/react.ts +1 -4
- package/src/apple-credentials/index.test.ts +158 -0
- package/src/apple-credentials/index.ts +241 -0
- package/src/components/remote-control.css +32 -0
- package/src/components/remote-control.tsx +865 -5
- package/src/core/device-install/operations/operations.ts +1 -4
- package/src/core/device-install/storage/browser-storage.test.ts +65 -0
- package/src/core/device-install/storage/browser-storage.ts +33 -0
- package/src/core/device-install/storage/index.ts +1 -0
- package/src/core/device-install/storage/secret-store.ts +298 -0
- package/src/core/device-install/types.ts +6 -0
- package/src/core/errors.ts +3 -0
- package/src/core/play-publish/google.ts +11 -2
- package/src/device-build/react.ts +1 -4
- package/src/device-install/demo/demo.tsx +1 -4
- package/src/device-install/react.ts +1 -4
- package/src/play-publish/README.md +5 -4
- package/src/play-publish/react.ts +72 -32
- package/vite.config.ts +1 -0
- package/dist/browser-storage-Cx9eW-bm.mjs +0 -205
- package/dist/browser-storage-jJaIht4K.js +0 -1
- package/dist/client-BtC4n_qf.js +0 -1
- package/dist/index-CMeQfhYy.js +0 -22
- package/dist/index-DFdCvi2_.mjs +0 -11543
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless helpers that turn an authenticated Apple relay session into
|
|
3
|
+
* signing credentials persisted in a SigningSecretStore. The Apple relay
|
|
4
|
+
* only proxies: certificate and profile bytes always land in the browser
|
|
5
|
+
* first, and the browser writes them into the configured store (Limrun's
|
|
6
|
+
* org secret store by default, or a customer-provided one).
|
|
7
|
+
*/
|
|
8
|
+
import {
|
|
9
|
+
createAppleCertificate,
|
|
10
|
+
downloadAppleCertificate,
|
|
11
|
+
downloadAppleProfile,
|
|
12
|
+
exportAppleCertificateP12,
|
|
13
|
+
generateAppleSigningKeyAndCSR,
|
|
14
|
+
listAppleCertificates,
|
|
15
|
+
listAppleProfiles,
|
|
16
|
+
} from '../app-store-relay';
|
|
17
|
+
import type { AppleRelayWebSocketClient } from '../core/device-install/apple';
|
|
18
|
+
import {
|
|
19
|
+
normalizeCertificateSerial,
|
|
20
|
+
parseProvisioningProfileBase64,
|
|
21
|
+
} from '../core/device-install/storage/browser-storage';
|
|
22
|
+
import {
|
|
23
|
+
APPLE_CERTIFICATE_SECRET_TYPE,
|
|
24
|
+
putAppleCertificateSecret,
|
|
25
|
+
putAppleProvisioningProfileSecret,
|
|
26
|
+
type AppleCertificateSecretData,
|
|
27
|
+
type AppleCertificateType,
|
|
28
|
+
type SigningSecret,
|
|
29
|
+
type SigningSecretStore,
|
|
30
|
+
} from '../core/device-install/storage/secret-store';
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
APPLE_CERTIFICATE_SECRET_TYPE,
|
|
34
|
+
APPLE_PROVISIONING_PROFILE_SECRET_TYPE,
|
|
35
|
+
createBrowserSecretStore,
|
|
36
|
+
createLimrunSecretStore,
|
|
37
|
+
putAppleCertificateSecret,
|
|
38
|
+
putAppleProvisioningProfileSecret,
|
|
39
|
+
type AppleCertificateSecretData,
|
|
40
|
+
type AppleCertificateType,
|
|
41
|
+
type AppleProvisioningProfileSecretData,
|
|
42
|
+
type LimrunSecretStoreOptions,
|
|
43
|
+
type SigningSecret,
|
|
44
|
+
type SigningSecretData,
|
|
45
|
+
type SigningSecretMetadata,
|
|
46
|
+
type SigningSecretStore,
|
|
47
|
+
type SigningSecretType,
|
|
48
|
+
} from '../core/device-install/storage/secret-store';
|
|
49
|
+
export { normalizeCertificateSerial } from '../core/device-install/storage/browser-storage';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Conventional secret name of a team's certificate bundle. One bundle per
|
|
53
|
+
* team and Apple certificate type; the type is in the name so development
|
|
54
|
+
* and distribution material never collide.
|
|
55
|
+
*/
|
|
56
|
+
export function appleCertificateSecretName(teamId: string, certificateType: AppleCertificateType) {
|
|
57
|
+
return `${teamId}/${certificateType}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type EnsureAppleCertificateInput = {
|
|
61
|
+
relay: AppleRelayWebSocketClient;
|
|
62
|
+
teamId: string;
|
|
63
|
+
secretStore: SigningSecretStore;
|
|
64
|
+
/** Common name used when minting a new certificate. */
|
|
65
|
+
commonName?: string;
|
|
66
|
+
log?: (message: string, detail?: string) => void;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type EnsureAppleCertificateResult = {
|
|
70
|
+
secret: SigningSecret;
|
|
71
|
+
certificateId: string;
|
|
72
|
+
/** True when a new certificate was minted instead of reusing the stored one. */
|
|
73
|
+
created: boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns a usable development certificate secret for the team, reusing the
|
|
78
|
+
* stored one when its certificate is still on the team and minting a new
|
|
79
|
+
* one otherwise. Apple caps development certificates at 2 and never returns
|
|
80
|
+
* private keys, so reuse of the stored p12 is strongly preferred.
|
|
81
|
+
*
|
|
82
|
+
* Durability of the stored material is the secret store's concern:
|
|
83
|
+
* implementors who want retries or fallbacks build them into their
|
|
84
|
+
* SigningSecretStore.
|
|
85
|
+
*/
|
|
86
|
+
export async function ensureAppleCertificateSecret({
|
|
87
|
+
relay,
|
|
88
|
+
teamId,
|
|
89
|
+
secretStore,
|
|
90
|
+
commonName,
|
|
91
|
+
log = () => {},
|
|
92
|
+
}: EnsureAppleCertificateInput): Promise<EnsureAppleCertificateResult> {
|
|
93
|
+
// The browser flow mints via the portal's development kind, which is
|
|
94
|
+
// the DEVELOPMENT certificate type in Apple's App Store Connect enum.
|
|
95
|
+
const certificateType: AppleCertificateType = 'DEVELOPMENT';
|
|
96
|
+
const secretName = appleCertificateSecretName(teamId, certificateType);
|
|
97
|
+
const current = await listAppleCertificates({ relay, teamId, certificateKind: 'development' });
|
|
98
|
+
const findOnTeam = (certificateId: string | undefined) =>
|
|
99
|
+
certificateId === undefined ? undefined : (
|
|
100
|
+
current.find(
|
|
101
|
+
(item) =>
|
|
102
|
+
stringField(item, 'certificateId') === certificateId ||
|
|
103
|
+
stringField(item, 'certRequestId') === certificateId,
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const stored = await secretStore.get(APPLE_CERTIFICATE_SECRET_TYPE, secretName);
|
|
108
|
+
const storedCertificateId = stringField(stored?.data, 'certificateID');
|
|
109
|
+
if (stored && storedCertificateId && stored.data.certificateP12Base64) {
|
|
110
|
+
// The stored value may be a certRequestId; resolve the canonical
|
|
111
|
+
// certificateId the profile API expects. If the cert is no longer on
|
|
112
|
+
// the team (revoked), fall through and mint a new one.
|
|
113
|
+
const matched = findOnTeam(storedCertificateId);
|
|
114
|
+
if (matched) {
|
|
115
|
+
const certificateId = stringField(matched, 'certificateId') ?? storedCertificateId;
|
|
116
|
+
log('Reusing stored Apple certificate', certificateId);
|
|
117
|
+
return { secret: stored, certificateId, created: false };
|
|
118
|
+
}
|
|
119
|
+
log('Stored certificate is no longer on the team', 'Minting a new one.');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The private key is generated and kept in this browser; Apple only ever
|
|
123
|
+
// sees the CSR. Without this key the downloaded cert cannot sign anything.
|
|
124
|
+
const key = await generateAppleSigningKeyAndCSR({ commonName: commonName ?? `Limrun ${teamId}` });
|
|
125
|
+
const certificate = await createAppleCertificate({
|
|
126
|
+
relay,
|
|
127
|
+
teamId,
|
|
128
|
+
certificateKind: 'development',
|
|
129
|
+
csrPEM: key.csrPEM,
|
|
130
|
+
});
|
|
131
|
+
const certificateId =
|
|
132
|
+
stringField(certificate, 'certificateId') ?? stringField(certificate, 'certRequestId');
|
|
133
|
+
if (!certificateId) {
|
|
134
|
+
throw new Error('Apple certificate creation did not return a certificate ID.');
|
|
135
|
+
}
|
|
136
|
+
const downloaded = await downloadAppleCertificate({
|
|
137
|
+
relay,
|
|
138
|
+
teamId,
|
|
139
|
+
certificateKind: 'development',
|
|
140
|
+
certificateId,
|
|
141
|
+
});
|
|
142
|
+
if (!downloaded.rawBodyBase64) {
|
|
143
|
+
throw new Error('Apple certificate download returned no bytes.');
|
|
144
|
+
}
|
|
145
|
+
const data: AppleCertificateSecretData = {
|
|
146
|
+
certificateP12Base64: exportAppleCertificateP12({
|
|
147
|
+
privateKeyPKCS8Base64: key.privateKeyPKCS8Base64,
|
|
148
|
+
certificateBase64: downloaded.rawBodyBase64,
|
|
149
|
+
password: '',
|
|
150
|
+
friendlyName: `Apple Development ${teamId}`,
|
|
151
|
+
}),
|
|
152
|
+
certificateType,
|
|
153
|
+
teamID: teamId,
|
|
154
|
+
certificateID: certificateId,
|
|
155
|
+
// Normalized so it equals the serials profiles reference.
|
|
156
|
+
serialNumber: normalizeCertificateSerial(stringField(certificate, 'serialNum')),
|
|
157
|
+
expirationDate: stringField(certificate, 'expirationDateString'),
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
let secret: SigningSecret;
|
|
161
|
+
try {
|
|
162
|
+
secret = await putAppleCertificateSecret(secretStore, secretName, data);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
// The key existed only in this browser's memory; once this throw
|
|
165
|
+
// unwinds it is gone, and the portal certificate is unusable.
|
|
166
|
+
throw new Error(
|
|
167
|
+
`Certificate ${certificateId} was created on the Apple Developer portal but saving its private ` +
|
|
168
|
+
`key to the secret store failed: ${errorText(error)}. The key cannot be recovered; revoke ` +
|
|
169
|
+
`certificate ${certificateId} at developer.apple.com before retrying, or the retry will mint ` +
|
|
170
|
+
`another certificate against Apple's limit.`,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
log('Apple certificate stored', certificateId);
|
|
174
|
+
return { secret, certificateId, created: true };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function errorText(error: unknown) {
|
|
178
|
+
return error instanceof Error ? error.message : String(error);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export type SaveAppleProfileInput = {
|
|
182
|
+
relay: AppleRelayWebSocketClient;
|
|
183
|
+
teamId: string;
|
|
184
|
+
profileId: string;
|
|
185
|
+
secretStore: SigningSecretStore;
|
|
186
|
+
log?: (message: string, detail?: string) => void;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Downloads the provisioning profile and stores it as an
|
|
191
|
+
* appleProvisioningProfile secret named `${teamId}/${uuid}`. The UUID is
|
|
192
|
+
* unique per profile, so a team can hold many profiles for the same
|
|
193
|
+
* bundle ID and certificate set; the reference fields (certificate
|
|
194
|
+
* serials, bundle IDs, device IDs parsed out of the profile) are what
|
|
195
|
+
* consumers filter on.
|
|
196
|
+
*/
|
|
197
|
+
export async function saveAppleProfileSecret({
|
|
198
|
+
relay,
|
|
199
|
+
teamId,
|
|
200
|
+
profileId,
|
|
201
|
+
secretStore,
|
|
202
|
+
log = () => {},
|
|
203
|
+
}: SaveAppleProfileInput): Promise<SigningSecret> {
|
|
204
|
+
const downloaded = await downloadAppleProfile({ relay, teamId, profileId });
|
|
205
|
+
const profileBase64 = downloaded.rawBodyBase64;
|
|
206
|
+
if (!profileBase64) {
|
|
207
|
+
throw new Error('Apple provisioning profile download returned no bytes.');
|
|
208
|
+
}
|
|
209
|
+
const info = parseProvisioningProfileBase64(profileBase64);
|
|
210
|
+
const name = `${teamId}/${info.uuid ?? profileId}`;
|
|
211
|
+
const secret = await putAppleProvisioningProfileSecret(secretStore, name, {
|
|
212
|
+
provisioningProfileBase64: profileBase64,
|
|
213
|
+
certificateSerialNumbers: info.certificateSerialNumbers.join(','),
|
|
214
|
+
bundleIDs: info.bundleID,
|
|
215
|
+
deviceIDs: info.provisionedDevices.join(','),
|
|
216
|
+
teamID: info.teamID ?? teamId,
|
|
217
|
+
profileName: info.name,
|
|
218
|
+
uuid: info.uuid,
|
|
219
|
+
expirationDate: info.expirationDate,
|
|
220
|
+
});
|
|
221
|
+
log('Apple provisioning profile stored', name);
|
|
222
|
+
return secret;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export type ListTeamProfilesInput = {
|
|
226
|
+
relay: AppleRelayWebSocketClient;
|
|
227
|
+
teamId: string;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/** Lists the team's development provisioning profiles from the portal. */
|
|
231
|
+
export async function listTeamAppleProfiles({ relay, teamId }: ListTeamProfilesInput) {
|
|
232
|
+
return listAppleProfiles({ relay, teamId, profileKind: 'development' });
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Read a string-ish value from a loosely typed portal record. */
|
|
236
|
+
export function stringField(record: Record<string, unknown> | undefined, key: string) {
|
|
237
|
+
const value = record?.[key];
|
|
238
|
+
if (typeof value === 'string') return value;
|
|
239
|
+
if (typeof value === 'number' || typeof value === 'boolean') return String(value);
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
@@ -97,3 +97,35 @@
|
|
|
97
97
|
outline: 2px solid #2563eb;
|
|
98
98
|
outline-offset: 2px;
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
.rc-terminated {
|
|
102
|
+
position: absolute;
|
|
103
|
+
z-index: 50;
|
|
104
|
+
top: 50%;
|
|
105
|
+
left: 50%;
|
|
106
|
+
transform: translate(-50%, -50%);
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: column;
|
|
109
|
+
align-items: center;
|
|
110
|
+
gap: 4px;
|
|
111
|
+
max-width: 240px;
|
|
112
|
+
padding: 12px 18px;
|
|
113
|
+
border-radius: 16px;
|
|
114
|
+
text-align: center;
|
|
115
|
+
font: inherit;
|
|
116
|
+
background: rgba(255, 255, 255, 0.92);
|
|
117
|
+
color: #111827;
|
|
118
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.rc-terminated-title {
|
|
122
|
+
font: inherit;
|
|
123
|
+
font-weight: 600;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.rc-terminated-message {
|
|
127
|
+
font: inherit;
|
|
128
|
+
font-size: 0.8125rem;
|
|
129
|
+
line-height: 1.3;
|
|
130
|
+
color: #6b7280;
|
|
131
|
+
}
|