eas-cli 16.32.0 → 18.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -92
- package/build/branch/queries.js +6 -1
- package/build/build/createContext.js +5 -3
- package/build/build/queries.js +13 -1
- package/build/build/runBuildAndSubmit.js +2 -0
- package/build/build/utils/devClient.d.ts +1 -0
- package/build/build/utils/devClient.js +3 -2
- package/build/build/utils/repository.js +3 -3
- package/build/build/utils/resourceClass.d.ts +1 -1
- package/build/build/utils/resourceClass.js +2 -2
- package/build/channel/queries.js +10 -1
- package/build/commandUtils/new/templates/AGENTS.md +0 -1
- package/build/commands/account/login.d.ts +1 -0
- package/build/commands/account/login.js +7 -2
- package/build/commands/env/create.js +5 -2
- package/build/commands/env/list.js +1 -5
- package/build/commands/update/index.js +2 -2
- package/build/commands/upload.js +3 -3
- package/build/credentials/ios/api/graphql/mutations/AppleDistributionCertificateMutation.js +1 -3
- package/build/devices/queries.js +23 -2
- package/build/graphql/mutations/EnvironmentVariableMutation.js +1 -4
- package/build/graphql/mutations/PublishMutation.js +1 -4
- package/build/graphql/mutations/UserPreferencesMutation.js +1 -3
- package/build/graphql/mutations/WorkflowRevisionMutation.js +2 -10
- package/build/graphql/queries/AppVersionQuery.js +1 -5
- package/build/log.js +1 -1
- package/build/ora.js +1 -1
- package/build/project/discourageExpoGoForProdAsync.d.ts +4 -0
- package/build/project/discourageExpoGoForProdAsync.js +46 -0
- package/build/rollout/actions/ManageRollout.js +5 -1
- package/build/rollout/actions/SelectRuntime.js +10 -1
- package/build/update/queries.js +28 -2
- package/build/user/SessionManager.d.ts +3 -2
- package/build/user/SessionManager.js +6 -6
- package/build/user/expoBrowserAuthFlowLauncher.d.ts +3 -0
- package/build/user/expoBrowserAuthFlowLauncher.js +129 -0
- package/build/user/fetchSessionSecretAndUserFromBrowserAuthFlow.d.ts +7 -0
- package/build/user/fetchSessionSecretAndUserFromBrowserAuthFlow.js +14 -0
- package/build/utils/prompts.js +3 -3
- package/build/utils/usage/checkForOverages.js +4 -2
- package/build/worker/mutations.js +2 -8
- package/oclif.manifest.json +8 -48
- package/package.json +61 -63
- package/build/commands/submit/upload-to-asc.d.ts +0 -12
- package/build/commands/submit/upload-to-asc.js +0 -217
- package/build/submit/ios/AscApiClient.d.ts +0 -247
- package/build/submit/ios/AscApiClient.js +0 -287
- package/build/user/expoSsoLauncher.d.ts +0 -3
- package/build/user/expoSsoLauncher.js +0 -98
- package/build/user/fetchSessionSecretAndSsoUser.d.ts +0 -5
- package/build/user/fetchSessionSecretAndSsoUser.js +0 -17
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AscApiClient = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const results_1 = require("@expo/results");
|
|
6
|
-
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
7
|
-
const zod_1 = require("zod");
|
|
8
|
-
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
9
|
-
const GetApi = {
|
|
10
|
-
'/v1/apps/:id': {
|
|
11
|
-
path: zod_1.z.object({
|
|
12
|
-
id: zod_1.z.string(),
|
|
13
|
-
}),
|
|
14
|
-
request: zod_1.z.object({
|
|
15
|
-
'fields[apps]': zod_1.z.array(zod_1.z.enum(['bundleId', 'name'])).refine(opts => {
|
|
16
|
-
// Let's say we currently require fetching these two and nothing else.
|
|
17
|
-
return opts.includes('bundleId') && opts.includes('name');
|
|
18
|
-
}),
|
|
19
|
-
}),
|
|
20
|
-
response: zod_1.z.object({
|
|
21
|
-
data: zod_1.z.object({
|
|
22
|
-
type: zod_1.z.literal('apps'),
|
|
23
|
-
id: zod_1.z.string(),
|
|
24
|
-
attributes: zod_1.z.object({
|
|
25
|
-
bundleId: zod_1.z.string(),
|
|
26
|
-
name: zod_1.z.string(),
|
|
27
|
-
}),
|
|
28
|
-
}),
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
'/v1/buildUploadFiles/:id': {
|
|
32
|
-
path: zod_1.z.object({
|
|
33
|
-
id: zod_1.z.string(),
|
|
34
|
-
}),
|
|
35
|
-
request: zod_1.z.object({
|
|
36
|
-
'fields[buildUploadFiles]': zod_1.z.array(zod_1.z.enum(['assetDeliveryState'])).refine(opts => {
|
|
37
|
-
return opts.includes('assetDeliveryState');
|
|
38
|
-
}),
|
|
39
|
-
}),
|
|
40
|
-
response: zod_1.z.object({
|
|
41
|
-
data: zod_1.z.object({
|
|
42
|
-
type: zod_1.z.literal('buildUploadFiles'),
|
|
43
|
-
id: zod_1.z.string(),
|
|
44
|
-
attributes: zod_1.z.object({
|
|
45
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/appmediaassetstate
|
|
46
|
-
assetDeliveryState: zod_1.z.object({
|
|
47
|
-
state: zod_1.z.enum(['AWAITING_UPLOAD', 'UPLOAD_COMPLETE', 'COMPLETE', 'FAILED']),
|
|
48
|
-
errors: zod_1.z.array(zod_1.z.object({ code: zod_1.z.string(), description: zod_1.z.string() })).optional(),
|
|
49
|
-
warnings: zod_1.z.array(zod_1.z.object({ code: zod_1.z.string(), description: zod_1.z.string() })).optional(),
|
|
50
|
-
}),
|
|
51
|
-
}),
|
|
52
|
-
}),
|
|
53
|
-
}),
|
|
54
|
-
},
|
|
55
|
-
'/v1/buildUploads/:id': {
|
|
56
|
-
path: zod_1.z.object({
|
|
57
|
-
id: zod_1.z.string(),
|
|
58
|
-
}),
|
|
59
|
-
request: zod_1.z.object({
|
|
60
|
-
'fields[buildUploads]': zod_1.z.array(zod_1.z.enum(['build', 'state'])).refine(opts => {
|
|
61
|
-
return opts.includes('build') && opts.includes('state');
|
|
62
|
-
}),
|
|
63
|
-
include: zod_1.z.array(zod_1.z.enum(['build'])).refine(opts => {
|
|
64
|
-
return opts.includes('build');
|
|
65
|
-
}),
|
|
66
|
-
}),
|
|
67
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadresponse
|
|
68
|
-
response: zod_1.z.object({
|
|
69
|
-
data: zod_1.z.object({
|
|
70
|
-
type: zod_1.z.literal('buildUploads'),
|
|
71
|
-
id: zod_1.z.string(),
|
|
72
|
-
attributes: zod_1.z.object({
|
|
73
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/buildupload/attributes-data.dictionary/state-data.dictionary
|
|
74
|
-
state: zod_1.z.object({
|
|
75
|
-
state: zod_1.z.enum(['AWAITING_UPLOAD', 'PROCESSING', 'COMPLETE', 'FAILED']),
|
|
76
|
-
infos: zod_1.z.array(zod_1.z.object({ code: zod_1.z.string(), description: zod_1.z.string() })).optional(),
|
|
77
|
-
errors: zod_1.z.array(zod_1.z.object({ code: zod_1.z.string(), description: zod_1.z.string() })).optional(),
|
|
78
|
-
warnings: zod_1.z.array(zod_1.z.object({ code: zod_1.z.string(), description: zod_1.z.string() })).optional(),
|
|
79
|
-
}),
|
|
80
|
-
}),
|
|
81
|
-
}),
|
|
82
|
-
}),
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
const PostApi = {
|
|
86
|
-
'/v1/buildUploads': {
|
|
87
|
-
request: zod_1.z.object({
|
|
88
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadcreaterequest/data-data.dictionary
|
|
89
|
-
data: zod_1.z.object({
|
|
90
|
-
type: zod_1.z.literal('buildUploads'),
|
|
91
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadcreaterequest/data-data.dictionary/attributes-data.dictionary
|
|
92
|
-
attributes: zod_1.z.object({
|
|
93
|
-
cfBundleShortVersionString: zod_1.z.string(),
|
|
94
|
-
cfBundleVersion: zod_1.z.string(),
|
|
95
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/platform
|
|
96
|
-
platform: zod_1.z.enum(['IOS', 'MAC_OS', 'TV_OS', 'VISION_OS']),
|
|
97
|
-
}),
|
|
98
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadcreaterequest/data-data.dictionary/relationships-data.dictionary
|
|
99
|
-
relationships: zod_1.z.object({
|
|
100
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadcreaterequest/data-data.dictionary/relationships-data.dictionary/app-data.dictionary
|
|
101
|
-
app: zod_1.z.object({
|
|
102
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadcreaterequest/data-data.dictionary/relationships-data.dictionary/app-data.dictionary/data-data.dictionary
|
|
103
|
-
data: zod_1.z.object({
|
|
104
|
-
type: zod_1.z.literal('apps'),
|
|
105
|
-
id: zod_1.z.string(),
|
|
106
|
-
}),
|
|
107
|
-
}),
|
|
108
|
-
}),
|
|
109
|
-
}),
|
|
110
|
-
}),
|
|
111
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadresponse
|
|
112
|
-
response: zod_1.z.object({
|
|
113
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/buildupload
|
|
114
|
-
data: zod_1.z.object({
|
|
115
|
-
id: zod_1.z.string(),
|
|
116
|
-
type: zod_1.z.literal('buildUploads'),
|
|
117
|
-
}),
|
|
118
|
-
}),
|
|
119
|
-
},
|
|
120
|
-
'/v1/buildUploadFiles': {
|
|
121
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfilecreaterequest
|
|
122
|
-
request: zod_1.z.object({
|
|
123
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfilecreaterequest/data-data.dictionary
|
|
124
|
-
data: zod_1.z.object({
|
|
125
|
-
type: zod_1.z.literal('buildUploadFiles'),
|
|
126
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfilecreaterequest/data-data.dictionary/attributes-data.dictionary
|
|
127
|
-
attributes: zod_1.z.object({
|
|
128
|
-
assetType: zod_1.z.enum(['ASSET', 'ASSET_DESCRIPTION', 'ASSET_SPI']),
|
|
129
|
-
fileName: zod_1.z.string(),
|
|
130
|
-
fileSize: zod_1.z.number().min(1).max(9007199254740991),
|
|
131
|
-
uti: zod_1.z.enum([
|
|
132
|
-
'com.apple.binary-property-list',
|
|
133
|
-
'com.apple.ipa',
|
|
134
|
-
'com.apple.pkg',
|
|
135
|
-
'com.apple.xml-property-list',
|
|
136
|
-
'com.pkware.zip-archive',
|
|
137
|
-
]),
|
|
138
|
-
}),
|
|
139
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfilecreaterequest/data-data.dictionary/relationships-data.dictionary
|
|
140
|
-
relationships: zod_1.z.object({
|
|
141
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfilecreaterequest/data-data.dictionary/relationships-data.dictionary/buildupload-data.dictionary
|
|
142
|
-
buildUpload: zod_1.z.object({
|
|
143
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfilecreaterequest/data-data.dictionary/relationships-data.dictionary/buildupload-data.dictionary/data-data.dictionary
|
|
144
|
-
data: zod_1.z.object({
|
|
145
|
-
type: zod_1.z.literal('buildUploads'),
|
|
146
|
-
id: zod_1.z.string(),
|
|
147
|
-
}),
|
|
148
|
-
}),
|
|
149
|
-
}),
|
|
150
|
-
}),
|
|
151
|
-
}),
|
|
152
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfileresponse
|
|
153
|
-
response: zod_1.z.object({
|
|
154
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfile
|
|
155
|
-
data: zod_1.z.object({
|
|
156
|
-
type: zod_1.z.literal('buildUploadFiles'),
|
|
157
|
-
id: zod_1.z.string(),
|
|
158
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfile/attributes-data.dictionary
|
|
159
|
-
attributes: zod_1.z.object({
|
|
160
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/appmediaassetstate
|
|
161
|
-
uploadOperations: zod_1.z.array(
|
|
162
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/deliveryfileuploadoperation
|
|
163
|
-
zod_1.z.object({
|
|
164
|
-
length: zod_1.z.number().min(1).max(9007199254740991),
|
|
165
|
-
method: zod_1.z.string(),
|
|
166
|
-
offset: zod_1.z.number().min(0).max(9007199254740991),
|
|
167
|
-
partNumber: zod_1.z.number().min(1).max(9007199254740991),
|
|
168
|
-
requestHeaders: zod_1.z.array(zod_1.z.object({
|
|
169
|
-
name: zod_1.z.string(),
|
|
170
|
-
value: zod_1.z.string(),
|
|
171
|
-
})),
|
|
172
|
-
url: zod_1.z.string(),
|
|
173
|
-
})),
|
|
174
|
-
}),
|
|
175
|
-
}),
|
|
176
|
-
}),
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
const PatchApi = {
|
|
180
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/patch-v1-builduploadfiles-_id_
|
|
181
|
-
'/v1/buildUploadFiles/:id': {
|
|
182
|
-
path: zod_1.z.object({
|
|
183
|
-
id: zod_1.z.string(),
|
|
184
|
-
}),
|
|
185
|
-
request: zod_1.z.object({
|
|
186
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfileupdaterequest/data-data.dictionary
|
|
187
|
-
data: zod_1.z.object({
|
|
188
|
-
id: zod_1.z.string(),
|
|
189
|
-
type: zod_1.z.literal('buildUploadFiles'),
|
|
190
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfileupdaterequest/data-data.dictionary/attributes-data.dictionary
|
|
191
|
-
attributes: zod_1.z.object({
|
|
192
|
-
uploaded: zod_1.z.boolean(),
|
|
193
|
-
}),
|
|
194
|
-
}),
|
|
195
|
-
}),
|
|
196
|
-
response: zod_1.z.object({
|
|
197
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfile
|
|
198
|
-
data: zod_1.z.object({
|
|
199
|
-
type: zod_1.z.literal('buildUploadFiles'),
|
|
200
|
-
id: zod_1.z.string(),
|
|
201
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/builduploadfile/attributes-data.dictionary
|
|
202
|
-
attributes: zod_1.z.object({
|
|
203
|
-
// https://developer.apple.com/documentation/appstoreconnectapi/appmediaassetstate
|
|
204
|
-
assetDeliveryState: zod_1.z.object({
|
|
205
|
-
state: zod_1.z.enum(['AWAITING_UPLOAD', 'UPLOAD_COMPLETE', 'COMPLETE', 'FAILED']),
|
|
206
|
-
errors: zod_1.z.array(zod_1.z.object({ code: zod_1.z.string(), description: zod_1.z.string() })).optional(),
|
|
207
|
-
warnings: zod_1.z.array(zod_1.z.object({ code: zod_1.z.string(), description: zod_1.z.string() })).optional(),
|
|
208
|
-
}),
|
|
209
|
-
}),
|
|
210
|
-
}),
|
|
211
|
-
}),
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
class AscApiClient {
|
|
215
|
-
baseUrl = 'https://api.appstoreconnect.apple.com';
|
|
216
|
-
token;
|
|
217
|
-
constructor({ token }) {
|
|
218
|
-
this.token = token;
|
|
219
|
-
}
|
|
220
|
-
async getAsync(path, body, params) {
|
|
221
|
-
const schema = GetApi[path];
|
|
222
|
-
let effectivePath = path;
|
|
223
|
-
for (const [key, value] of Object.entries(params ?? {})) {
|
|
224
|
-
effectivePath = effectivePath.replace(`:${key}`, String(value));
|
|
225
|
-
}
|
|
226
|
-
return await this.sendRequestAsync({
|
|
227
|
-
method: 'GET',
|
|
228
|
-
path: `${effectivePath}?${new URLSearchParams(body).toString()}`,
|
|
229
|
-
body,
|
|
230
|
-
requestSchema: schema.request,
|
|
231
|
-
responseSchema: schema.response,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
async postAsync(path, body) {
|
|
235
|
-
const schema = PostApi[path];
|
|
236
|
-
return await this.sendRequestAsync({
|
|
237
|
-
method: 'POST',
|
|
238
|
-
path,
|
|
239
|
-
body,
|
|
240
|
-
requestSchema: schema.request,
|
|
241
|
-
responseSchema: schema.response,
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
async patchAsync(path, body, params) {
|
|
245
|
-
const schema = PatchApi[path];
|
|
246
|
-
let effectivePath = path;
|
|
247
|
-
for (const [key, value] of Object.entries(params)) {
|
|
248
|
-
effectivePath = effectivePath.replace(`:${key}`, String(value));
|
|
249
|
-
}
|
|
250
|
-
return await this.sendRequestAsync({
|
|
251
|
-
method: 'PATCH',
|
|
252
|
-
path: effectivePath,
|
|
253
|
-
body,
|
|
254
|
-
requestSchema: schema.request,
|
|
255
|
-
responseSchema: schema.response,
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
async sendRequestAsync({ path, method, body, requestSchema, responseSchema, }) {
|
|
259
|
-
const url = new URL(path, this.baseUrl).toString();
|
|
260
|
-
const parsedBody = await (0, results_1.asyncResult)((async () => requestSchema.parse(body))());
|
|
261
|
-
if (!parsedBody.ok) {
|
|
262
|
-
throw new Error(`Malformed request to App Store Connect: ${zod_1.z.prettifyError(parsedBody.enforceError())}`);
|
|
263
|
-
}
|
|
264
|
-
const response = await (0, node_fetch_1.default)(url, {
|
|
265
|
-
method,
|
|
266
|
-
headers: {
|
|
267
|
-
'Content-Type': 'application/json',
|
|
268
|
-
Authorization: `Bearer ${this.token}`,
|
|
269
|
-
},
|
|
270
|
-
body: method === 'GET' ? undefined : JSON.stringify(parsedBody.value),
|
|
271
|
-
});
|
|
272
|
-
if (!response.ok) {
|
|
273
|
-
const text = await response.text();
|
|
274
|
-
throw new Error(`Unexpected response (${response.status}) from App Store Connect: ${text}`, {
|
|
275
|
-
cause: response,
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
const json = await response.json();
|
|
279
|
-
log_1.default.debug(`Response from App Store Connect: ${JSON.stringify(json, null, 2)}`);
|
|
280
|
-
const parsedResponse = await (0, results_1.asyncResult)((async () => responseSchema.parse(json))());
|
|
281
|
-
if (!parsedResponse.ok) {
|
|
282
|
-
throw new Error(`Malformed response from App Store Connect: ${zod_1.z.prettifyError(parsedResponse.enforceError())}`);
|
|
283
|
-
}
|
|
284
|
-
return parsedResponse.value;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
exports.AscApiClient = AscApiClient;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSessionUsingBrowserAuthFlowAsync = getSessionUsingBrowserAuthFlowAsync;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
-
const better_opn_1 = tslib_1.__importDefault(require("better-opn"));
|
|
7
|
-
const http_1 = tslib_1.__importDefault(require("http"));
|
|
8
|
-
const querystring_1 = tslib_1.__importDefault(require("querystring"));
|
|
9
|
-
const log_1 = tslib_1.__importDefault(require("../log"));
|
|
10
|
-
const successBody = `
|
|
11
|
-
<!DOCTYPE html>
|
|
12
|
-
<html lang="en">
|
|
13
|
-
<head>
|
|
14
|
-
<title>Expo SSO Login</title>
|
|
15
|
-
<meta charset="utf-8">
|
|
16
|
-
<style type="text/css">
|
|
17
|
-
html {
|
|
18
|
-
margin: 0;
|
|
19
|
-
padding: 0
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
body {
|
|
23
|
-
background-color: #fff;
|
|
24
|
-
font-family: Tahoma,Verdana;
|
|
25
|
-
font-size: 16px;
|
|
26
|
-
color: #000;
|
|
27
|
-
max-width: 100%;
|
|
28
|
-
box-sizing: border-box;
|
|
29
|
-
padding: .5rem;
|
|
30
|
-
margin: 1em;
|
|
31
|
-
overflow-wrap: break-word
|
|
32
|
-
}
|
|
33
|
-
</style>
|
|
34
|
-
</head>
|
|
35
|
-
<body>
|
|
36
|
-
SSO login complete. You may now close this tab and return to the command prompt.
|
|
37
|
-
</body>
|
|
38
|
-
</html>`;
|
|
39
|
-
async function getSessionUsingBrowserAuthFlowAsync({ expoWebsiteUrl, }) {
|
|
40
|
-
const scheme = 'http';
|
|
41
|
-
const hostname = 'localhost';
|
|
42
|
-
const path = '/auth/callback';
|
|
43
|
-
const buildExpoSsoLoginUrl = (port) => {
|
|
44
|
-
const data = {
|
|
45
|
-
app_redirect_uri: `${scheme}://${hostname}:${port}${path}`,
|
|
46
|
-
};
|
|
47
|
-
const params = querystring_1.default.stringify(data);
|
|
48
|
-
return `${expoWebsiteUrl}/sso-login?${params}`;
|
|
49
|
-
};
|
|
50
|
-
// Start server and begin auth flow
|
|
51
|
-
const executeAuthFlow = () => {
|
|
52
|
-
return new Promise(async (resolve, reject) => {
|
|
53
|
-
const connections = new Set();
|
|
54
|
-
const server = http_1.default.createServer((request, response) => {
|
|
55
|
-
try {
|
|
56
|
-
if (!(request.method === 'GET' && request.url?.includes('/auth/callback'))) {
|
|
57
|
-
throw new Error('Unexpected SSO login response.');
|
|
58
|
-
}
|
|
59
|
-
const url = new URL(request.url, `http:${request.headers.host}`);
|
|
60
|
-
const sessionSecret = url.searchParams.get('session_secret');
|
|
61
|
-
if (!sessionSecret) {
|
|
62
|
-
throw new Error('Request missing session_secret search parameter.');
|
|
63
|
-
}
|
|
64
|
-
resolve(sessionSecret);
|
|
65
|
-
response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
66
|
-
response.write(successBody);
|
|
67
|
-
response.end();
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
reject(error);
|
|
71
|
-
}
|
|
72
|
-
finally {
|
|
73
|
-
server.close();
|
|
74
|
-
// Ensure that the server shuts down
|
|
75
|
-
for (const connection of connections) {
|
|
76
|
-
connection.destroy();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
server.listen(0, hostname, () => {
|
|
81
|
-
log_1.default.log('Waiting for browser login...');
|
|
82
|
-
const address = server.address();
|
|
83
|
-
(0, assert_1.default)(address !== null && typeof address === 'object', 'Server address and port should be set after listening has begun');
|
|
84
|
-
const port = address.port;
|
|
85
|
-
const authorizeUrl = buildExpoSsoLoginUrl(port);
|
|
86
|
-
log_1.default.log(`If your browser doesn't automatically open, visit this link to log in: ${authorizeUrl}`);
|
|
87
|
-
void (0, better_opn_1.default)(authorizeUrl);
|
|
88
|
-
});
|
|
89
|
-
server.on('connection', connection => {
|
|
90
|
-
connections.add(connection);
|
|
91
|
-
connection.on('close', () => {
|
|
92
|
-
connections.delete(connection);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
return await executeAuthFlow();
|
|
98
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchSessionSecretAndSsoUserAsync = fetchSessionSecretAndSsoUserAsync;
|
|
4
|
-
const expoSsoLauncher_1 = require("./expoSsoLauncher");
|
|
5
|
-
const fetchUser_1 = require("./fetchUser");
|
|
6
|
-
const api_1 = require("../api");
|
|
7
|
-
async function fetchSessionSecretAndSsoUserAsync() {
|
|
8
|
-
const sessionSecret = await (0, expoSsoLauncher_1.getSessionUsingBrowserAuthFlowAsync)({
|
|
9
|
-
expoWebsiteUrl: (0, api_1.getExpoWebsiteBaseUrl)(),
|
|
10
|
-
});
|
|
11
|
-
const userData = await (0, fetchUser_1.fetchUserAsync)({ sessionSecret });
|
|
12
|
-
return {
|
|
13
|
-
sessionSecret,
|
|
14
|
-
id: userData.id,
|
|
15
|
-
username: userData.username,
|
|
16
|
-
};
|
|
17
|
-
}
|