@expo/cli 0.22.0 → 0.22.2
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/build/bin/cli +1 -1
- package/build/src/api/graphql/client.js +2 -1
- package/build/src/api/graphql/client.js.map +1 -1
- package/build/src/api/rest/client.js +2 -1
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithUserAgent.js +32 -0
- package/build/src/api/rest/wrapFetchWithUserAgent.js.map +1 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js +1 -1
- package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -1
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +30 -6
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -1
- package/build/src/utils/fetch.js +11 -4
- package/build/src/utils/fetch.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +2 -2
package/build/bin/cli
CHANGED
|
@@ -32,6 +32,7 @@ const _fetch = require("../../utils/fetch");
|
|
|
32
32
|
const _endpoint = require("../endpoint");
|
|
33
33
|
const _wrapFetchWithOffline = require("../rest/wrapFetchWithOffline");
|
|
34
34
|
const _wrapFetchWithProxy = require("../rest/wrapFetchWithProxy");
|
|
35
|
+
const _wrapFetchWithUserAgent = require("../rest/wrapFetchWithUserAgent");
|
|
35
36
|
const _userSettings = require("../user/UserSettings");
|
|
36
37
|
function _getRequireWildcardCache(nodeInterop) {
|
|
37
38
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -88,7 +89,7 @@ const graphqlClient = (0, _core().createClient)({
|
|
|
88
89
|
_core().fetchExchange,
|
|
89
90
|
],
|
|
90
91
|
// @ts-ignore Type 'typeof fetch' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.
|
|
91
|
-
fetch: (0, _wrapFetchWithOffline.wrapFetchWithOffline)((0, _wrapFetchWithProxy.wrapFetchWithProxy)(_fetch.fetch)),
|
|
92
|
+
fetch: (0, _wrapFetchWithOffline.wrapFetchWithOffline)((0, _wrapFetchWithProxy.wrapFetchWithProxy)((0, _wrapFetchWithUserAgent.wrapFetchWithUserAgent)(_fetch.fetch))),
|
|
92
93
|
fetchOptions: ()=>{
|
|
93
94
|
var ref;
|
|
94
95
|
const token = (0, _userSettings.getAccessToken)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/graphql/client.ts"],"sourcesContent":["import {\n cacheExchange,\n Client,\n CombinedError as GraphqlError,\n AnyVariables,\n DocumentInput,\n createClient as createUrqlClient,\n fetchExchange,\n OperationContext,\n OperationResult,\n OperationResultSource,\n} from '@urql/core';\nimport { retryExchange } from '@urql/exchange-retry';\n\nimport * as Log from '../../log';\nimport { fetch } from '../../utils/fetch';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { wrapFetchWithOffline } from '../rest/wrapFetchWithOffline';\nimport { wrapFetchWithProxy } from '../rest/wrapFetchWithProxy';\nimport { getAccessToken, getSession } from '../user/UserSettings';\n\ntype AccessTokenHeaders = {\n authorization: string;\n};\n\ntype SessionHeaders = {\n 'expo-session': string;\n};\n\nexport const graphqlClient = createUrqlClient({\n url: getExpoApiBaseUrl() + '/graphql',\n exchanges: [\n cacheExchange,\n retryExchange({\n maxDelayMs: 4000,\n retryIf: (err) =>\n !!(err && (err.networkError || err.graphQLErrors.some((e) => e?.extensions?.isTransient))),\n }),\n fetchExchange,\n ],\n // @ts-ignore Type 'typeof fetch' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.\n fetch: wrapFetchWithOffline(wrapFetchWithProxy(fetch)),\n fetchOptions: (): { headers?: AccessTokenHeaders | SessionHeaders } => {\n const token = getAccessToken();\n if (token) {\n return {\n headers: {\n authorization: `Bearer ${token}`,\n },\n };\n }\n const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n return {\n headers: {\n 'expo-session': sessionSecret,\n },\n };\n }\n return {};\n },\n}) as StricterClient;\n\n/* Please specify additionalTypenames in your Graphql queries */\nexport interface StricterClient extends Client {\n query<Data = any, Variables extends AnyVariables = AnyVariables>(\n query: DocumentInput<Data, Variables>,\n variables: Variables,\n context: Partial<OperationContext> & { additionalTypenames: string[] }\n ): OperationResultSource<OperationResult<Data, Variables>>;\n}\n\nexport async function withErrorHandlingAsync<T>(promise: Promise<OperationResult<T>>): Promise<T> {\n const { data, error } = await promise;\n\n if (error) {\n if (error.graphQLErrors.some((e) => e?.extensions?.isTransient)) {\n Log.error(`We've encountered a transient error, please try again shortly.`);\n }\n throw error;\n }\n\n // Check for a malformed response. This only checks the root query's existence. It doesn't affect\n // returning responses with an empty result set.\n if (!data) {\n throw new Error('Returned query result data is null!');\n }\n\n return data;\n}\n\nexport { GraphqlError };\n"],"names":["graphqlClient","withErrorHandlingAsync","GraphqlError","createUrqlClient","url","getExpoApiBaseUrl","exchanges","cacheExchange","retryExchange","maxDelayMs","retryIf","err","networkError","graphQLErrors","some","e","extensions","isTransient","fetchExchange","fetch","wrapFetchWithOffline","wrapFetchWithProxy","fetchOptions","getSession","token","getAccessToken","headers","authorization","sessionSecret","promise","data","error","Log","Error"],"mappings":"AAAA;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/graphql/client.ts"],"sourcesContent":["import {\n cacheExchange,\n Client,\n CombinedError as GraphqlError,\n AnyVariables,\n DocumentInput,\n createClient as createUrqlClient,\n fetchExchange,\n OperationContext,\n OperationResult,\n OperationResultSource,\n} from '@urql/core';\nimport { retryExchange } from '@urql/exchange-retry';\n\nimport * as Log from '../../log';\nimport { fetch } from '../../utils/fetch';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { wrapFetchWithOffline } from '../rest/wrapFetchWithOffline';\nimport { wrapFetchWithProxy } from '../rest/wrapFetchWithProxy';\nimport { wrapFetchWithUserAgent } from '../rest/wrapFetchWithUserAgent';\nimport { getAccessToken, getSession } from '../user/UserSettings';\n\ntype AccessTokenHeaders = {\n authorization: string;\n};\n\ntype SessionHeaders = {\n 'expo-session': string;\n};\n\nexport const graphqlClient = createUrqlClient({\n url: getExpoApiBaseUrl() + '/graphql',\n exchanges: [\n cacheExchange,\n retryExchange({\n maxDelayMs: 4000,\n retryIf: (err) =>\n !!(err && (err.networkError || err.graphQLErrors.some((e) => e?.extensions?.isTransient))),\n }),\n fetchExchange,\n ],\n // @ts-ignore Type 'typeof fetch' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.\n fetch: wrapFetchWithOffline(wrapFetchWithProxy(wrapFetchWithUserAgent(fetch))),\n fetchOptions: (): { headers?: AccessTokenHeaders | SessionHeaders } => {\n const token = getAccessToken();\n if (token) {\n return {\n headers: {\n authorization: `Bearer ${token}`,\n },\n };\n }\n const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n return {\n headers: {\n 'expo-session': sessionSecret,\n },\n };\n }\n return {};\n },\n}) as StricterClient;\n\n/* Please specify additionalTypenames in your Graphql queries */\nexport interface StricterClient extends Client {\n query<Data = any, Variables extends AnyVariables = AnyVariables>(\n query: DocumentInput<Data, Variables>,\n variables: Variables,\n context: Partial<OperationContext> & { additionalTypenames: string[] }\n ): OperationResultSource<OperationResult<Data, Variables>>;\n}\n\nexport async function withErrorHandlingAsync<T>(promise: Promise<OperationResult<T>>): Promise<T> {\n const { data, error } = await promise;\n\n if (error) {\n if (error.graphQLErrors.some((e) => e?.extensions?.isTransient)) {\n Log.error(`We've encountered a transient error, please try again shortly.`);\n }\n throw error;\n }\n\n // Check for a malformed response. This only checks the root query's existence. It doesn't affect\n // returning responses with an empty result set.\n if (!data) {\n throw new Error('Returned query result data is null!');\n }\n\n return data;\n}\n\nexport { GraphqlError };\n"],"names":["graphqlClient","withErrorHandlingAsync","GraphqlError","createUrqlClient","url","getExpoApiBaseUrl","exchanges","cacheExchange","retryExchange","maxDelayMs","retryIf","err","networkError","graphQLErrors","some","e","extensions","isTransient","fetchExchange","fetch","wrapFetchWithOffline","wrapFetchWithProxy","wrapFetchWithUserAgent","fetchOptions","getSession","token","getAccessToken","headers","authorization","sessionSecret","promise","data","error","Log","Error"],"mappings":"AAAA;;;;;;;;;;;IA8BaA,aAAa,MAAbA,aAAa;IA2CJC,sBAAsB,MAAtBA,sBAAsB;IAmBnCC,YAAY,MAAZA,KAAY,EAAA,cAAA;;;yBAjFd,YAAY;;;;;;;yBACW,sBAAsB;;;;;;2DAE/B,WAAW;uBACV,mBAAmB;0BACP,aAAa;sCACV,8BAA8B;oCAChC,4BAA4B;wCACxB,gCAAgC;8BAC5B,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAU1D,MAAMF,aAAa,GAAGG,IAAAA,KAAgB,EAAA,aAAA,EAAC;IAC5CC,GAAG,EAAEC,IAAAA,SAAiB,kBAAA,GAAE,GAAG,UAAU;IACrCC,SAAS,EAAE;QACTC,KAAa,EAAA,cAAA;QACbC,IAAAA,cAAa,EAAA,cAAA,EAAC;YACZC,UAAU,EAAE,IAAI;YAChBC,OAAO,EAAE,CAACC,GAAG;gBACX,OAAA,CAAC,CAAC,CAACA,GAAG,IAAI,CAACA,GAAG,CAACC,YAAY,IAAID,GAAG,CAACE,aAAa,CAACC,IAAI,CAAC,CAACC,CAAC;wBAAKA,GAAa;oBAAbA,OAAAA,CAAC,QAAY,GAAbA,KAAAA,CAAa,GAAbA,CAAAA,GAAa,GAAbA,CAAC,CAAEC,UAAU,SAAA,GAAbD,KAAAA,CAAa,GAAbA,GAAa,CAAEE,WAAW,AAAb,CAAa;iBAAA,CAAC,CAAC,CAAC,CAAA;aAAA;SAC7F,CAAC;QACFC,KAAa,EAAA,cAAA;KACd;IACD,wIAAwI;IACxIC,KAAK,EAAEC,IAAAA,qBAAoB,qBAAA,EAACC,IAAAA,mBAAkB,mBAAA,EAACC,IAAAA,uBAAsB,uBAAA,EAACH,MAAK,MAAA,CAAC,CAA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
|
|
@@ -36,6 +36,7 @@ const _wrapFetchWithBaseUrl = require("./wrapFetchWithBaseUrl");
|
|
|
36
36
|
const _wrapFetchWithOffline = require("./wrapFetchWithOffline");
|
|
37
37
|
const _wrapFetchWithProgress = require("./wrapFetchWithProgress");
|
|
38
38
|
const _wrapFetchWithProxy = require("./wrapFetchWithProxy");
|
|
39
|
+
const _wrapFetchWithUserAgent = require("./wrapFetchWithUserAgent");
|
|
39
40
|
const _env = require("../../utils/env");
|
|
40
41
|
const _errors = require("../../utils/errors");
|
|
41
42
|
const _fetch = require("../../utils/fetch");
|
|
@@ -134,7 +135,7 @@ function wrapFetchWithCredentials(fetchFunction) {
|
|
|
134
135
|
"UND_ERR_CONNECT_TIMEOUT"
|
|
135
136
|
].includes(error.code);
|
|
136
137
|
}
|
|
137
|
-
const fetchWithOffline = (0, _wrapFetchWithOffline.wrapFetchWithOffline)(_fetch.fetch);
|
|
138
|
+
const fetchWithOffline = (0, _wrapFetchWithOffline.wrapFetchWithOffline)((0, _wrapFetchWithUserAgent.wrapFetchWithUserAgent)(_fetch.fetch));
|
|
138
139
|
const fetchWithBaseUrl = (0, _wrapFetchWithBaseUrl.wrapFetchWithBaseUrl)(fetchWithOffline, (0, _endpoint.getExpoApiBaseUrl)() + "/v2/");
|
|
139
140
|
const fetchWithProxy = (0, _wrapFetchWithProxy.wrapFetchWithProxy)(fetchWithBaseUrl);
|
|
140
141
|
const fetchWithCredentials = (0, _wrapFetchWithProgress.wrapFetchWithProgress)(wrapFetchWithCredentials(fetchWithProxy));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/rest/client.ts"],"sourcesContent":["import { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport type { JSONValue } from '@expo/json-file';\nimport path from 'path';\n\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport type { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProgress } from './wrapFetchWithProgress';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { fetch } from '../../utils/fetch';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport { getAccessToken, getSession } from '../user/UserSettings';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\n readonly code: string;\n readonly expoApiV2ErrorCode: string;\n readonly expoApiV2ErrorDetails?: JSONValue;\n readonly expoApiV2ErrorServerStack?: string;\n readonly expoApiV2ErrorMetadata?: object;\n\n constructor(response: {\n message: string;\n code: string;\n stack?: string;\n details?: JSONValue;\n metadata?: object;\n }) {\n super(response.message);\n this.code = response.code;\n this.expoApiV2ErrorCode = response.code;\n this.expoApiV2ErrorDetails = response.details;\n this.expoApiV2ErrorServerStack = response.stack;\n this.expoApiV2ErrorMetadata = response.metadata;\n }\n}\n\n/**\n * An Expo server error that didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the server.\n */\nexport class UnexpectedServerError extends Error {\n readonly name = 'UnexpectedServerError';\n}\n\n/**\n * An error defining that the server didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the client.\n */\nexport class UnexpectedServerData extends Error {\n readonly name = 'UnexpectedServerData';\n}\n\n/** Validate the response json contains `.data` property, or throw an unexpected server data error */\nexport function getResponseDataOrThrow<T = any>(json: unknown): T {\n if (!!json && typeof json === 'object' && 'data' in json) {\n return json.data as T;\n }\n\n throw new UnexpectedServerData(\n !!json && typeof json === 'object' ? JSON.stringify(json) : 'Unknown data received from server.'\n );\n}\n\n/**\n * @returns a `fetch` function that will inject user authentication information and handle errors from the Expo API.\n */\nexport function wrapFetchWithCredentials(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithCredentials(url, options = {}) {\n if (Array.isArray(options.headers)) {\n throw new Error('request headers must be in object form');\n }\n\n const resolvedHeaders = options.headers ?? ({} as any);\n\n const token = getAccessToken();\n if (token) {\n resolvedHeaders.authorization = `Bearer ${token}`;\n } else {\n const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n resolvedHeaders['expo-session'] = sessionSecret;\n }\n }\n\n try {\n const response = await fetchFunction(url, {\n ...options,\n headers: resolvedHeaders,\n });\n\n // Handle expected API errors (4xx)\n if (response.status >= 400 && response.status < 500) {\n const body = await response.text();\n try {\n const data = JSON.parse(body);\n if (data?.errors?.length) {\n throw new ApiV2Error(data.errors[0]);\n }\n } catch (error: any) {\n // Server returned non-json response.\n if (error.message.includes('in JSON at position')) {\n throw new UnexpectedServerError(body);\n }\n throw error;\n }\n }\n\n return response;\n } catch (error: any) {\n // When running `expo start`, but wifi or internet has issues\n if (\n isNetworkError(error) || // node-fetch error handling\n ('cause' in error && isNetworkError(error.cause)) // undici error handling\n ) {\n disableNetwork();\n\n throw new CommandError(\n 'OFFLINE',\n 'Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.'\n );\n }\n\n throw error;\n }\n };\n}\n\n/**\n * Determine if the provided error is related to a network issue.\n * When this returns true, offline mode should be enabled.\n * - `ENOTFOUND` is thrown when the DNS lookup failed\n * - `UND_ERR_CONNECT_TIMEOUT` is thrown after DNS is resolved, but server can't be reached\n *\n * @see https://nodejs.org/api/errors.html\n * @see https://github.com/nodejs/undici#network-address-family-autoselection\n */\nfunction isNetworkError(error: Error & { code?: string }) {\n return (\n 'code' in error && error.code && ['ENOTFOUND', 'UND_ERR_CONNECT_TIMEOUT'].includes(error.code)\n );\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(fetch);\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithProxy = wrapFetchWithProxy(fetchWithBaseUrl);\n\nconst fetchWithCredentials = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n\n/**\n * Create an instance of the fully qualified fetch command (auto authentication and api) but with caching in the '~/.expo' directory.\n * Caching is disabled automatically if the EXPO_NO_CACHE or EXPO_BETA environment variables are enabled.\n */\nexport function createCachedFetch({\n fetch = fetchWithCredentials,\n cacheDirectory,\n ttl,\n skipCache,\n}: {\n fetch?: FetchLike;\n cacheDirectory: string;\n ttl?: number;\n skipCache?: boolean;\n}): FetchLike {\n // Disable all caching in EXPO_BETA.\n if (skipCache || env.EXPO_BETA || env.EXPO_NO_CACHE) {\n return fetch;\n }\n\n const { FileSystemResponseCache } =\n require('./cache/FileSystemResponseCache') as typeof import('./cache/FileSystemResponseCache');\n\n return wrapFetchWithCache(\n fetch,\n new FileSystemResponseCache({\n cacheDirectory: path.join(getExpoHomeDirectory(), cacheDirectory),\n ttl,\n })\n );\n}\n\n/** Instance of fetch with automatic base URL pointing to the Expo API, user credential injection, and API error handling. Caching not included. */\nexport const fetchAsync = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n"],"names":["ApiV2Error","UnexpectedServerError","UnexpectedServerData","getResponseDataOrThrow","wrapFetchWithCredentials","createCachedFetch","fetchAsync","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","json","data","JSON","stringify","fetchFunction","fetchWithCredentials","url","options","Array","isArray","headers","resolvedHeaders","token","getAccessToken","authorization","getSession","sessionSecret","status","body","text","parse","errors","length","error","includes","isNetworkError","cause","disableNetwork","CommandError","fetchWithOffline","wrapFetchWithOffline","fetch","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetchWithProxy","wrapFetchWithProxy","wrapFetchWithProgress","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","FileSystemResponseCache","require","wrapFetchWithCache","path","join","getExpoHomeDirectory"],"mappings":"AAAA;;;;;;;;;;;IAiBaA,UAAU,MAAVA,UAAU;IA4BVC,qBAAqB,MAArBA,qB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AErD,MAAMC,gBAAgB,GAAGC,IAAAA,qBAAoB,qBAAA,EAACJ,gBAAgB,EAAEK,IAAAA,SAAiB,kBAAA,GAAE,GAAG,MAAM,CAAC,AAAC;AAE9F,MAAMC,cAAc,GAAGC,IAAAA,mBAAkB,mBAAA,EAACJ,gBAAgB,CAAC,AAAC;AAE5D,MAAM3B,oBAAoB,GAAGgC,IAAAA,sBAAqB,sBAAA,EAACrD,wBAAwB,CAACmD,cAAc,CAAC,CAAC,AAAC;AAMtF,SAASlD,iBAAiB,CAAC,EAChC8C,KAAK,EAAG1B,oBAAoB,CAAA,EAC5BiC,cAAc,CAAA,EACdC,GAAG,CAAA,EACHC,SAAS,CAAA,EAMV,EAAa;IACZ,oCAAoC;IACpC,IAAIA,SAAS,IAAIC,IAAG,IAAA,CAACC,SAAS,IAAID,IAAG,IAAA,CAACE,aAAa,EAAE;QACnD,OAAOZ,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAEa,uBAAuB,CAAA,EAAE,GAC/BC,OAAO,CAAC,iCAAiC,CAAC,AAAoD,AAAC;IAEjG,OAAOC,IAAAA,mBAAkB,mBAAA,EACvBf,KAAK,EACL,IAAIa,uBAAuB,CAAC;QAC1BN,cAAc,EAAES,KAAI,EAAA,QAAA,CAACC,IAAI,CAACC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,EAAEX,cAAc,CAAC;QACjEC,GAAG;KACJ,CAAC,CACH,CAAC;AACJ,CAAC;AAGM,MAAMrD,UAAU,GAAGmD,IAAAA,sBAAqB,sBAAA,EAACrD,wBAAwB,CAACmD,cAAc,CAAC,CAAC,AAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/rest/client.ts"],"sourcesContent":["import { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport type { JSONValue } from '@expo/json-file';\nimport path from 'path';\n\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport type { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProgress } from './wrapFetchWithProgress';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\nimport { wrapFetchWithUserAgent } from './wrapFetchWithUserAgent';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { fetch } from '../../utils/fetch';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport { getAccessToken, getSession } from '../user/UserSettings';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\n readonly code: string;\n readonly expoApiV2ErrorCode: string;\n readonly expoApiV2ErrorDetails?: JSONValue;\n readonly expoApiV2ErrorServerStack?: string;\n readonly expoApiV2ErrorMetadata?: object;\n\n constructor(response: {\n message: string;\n code: string;\n stack?: string;\n details?: JSONValue;\n metadata?: object;\n }) {\n super(response.message);\n this.code = response.code;\n this.expoApiV2ErrorCode = response.code;\n this.expoApiV2ErrorDetails = response.details;\n this.expoApiV2ErrorServerStack = response.stack;\n this.expoApiV2ErrorMetadata = response.metadata;\n }\n}\n\n/**\n * An Expo server error that didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the server.\n */\nexport class UnexpectedServerError extends Error {\n readonly name = 'UnexpectedServerError';\n}\n\n/**\n * An error defining that the server didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the client.\n */\nexport class UnexpectedServerData extends Error {\n readonly name = 'UnexpectedServerData';\n}\n\n/** Validate the response json contains `.data` property, or throw an unexpected server data error */\nexport function getResponseDataOrThrow<T = any>(json: unknown): T {\n if (!!json && typeof json === 'object' && 'data' in json) {\n return json.data as T;\n }\n\n throw new UnexpectedServerData(\n !!json && typeof json === 'object' ? JSON.stringify(json) : 'Unknown data received from server.'\n );\n}\n\n/**\n * @returns a `fetch` function that will inject user authentication information and handle errors from the Expo API.\n */\nexport function wrapFetchWithCredentials(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithCredentials(url, options = {}) {\n if (Array.isArray(options.headers)) {\n throw new Error('request headers must be in object form');\n }\n\n const resolvedHeaders = options.headers ?? ({} as any);\n\n const token = getAccessToken();\n if (token) {\n resolvedHeaders.authorization = `Bearer ${token}`;\n } else {\n const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n resolvedHeaders['expo-session'] = sessionSecret;\n }\n }\n\n try {\n const response = await fetchFunction(url, {\n ...options,\n headers: resolvedHeaders,\n });\n\n // Handle expected API errors (4xx)\n if (response.status >= 400 && response.status < 500) {\n const body = await response.text();\n try {\n const data = JSON.parse(body);\n if (data?.errors?.length) {\n throw new ApiV2Error(data.errors[0]);\n }\n } catch (error: any) {\n // Server returned non-json response.\n if (error.message.includes('in JSON at position')) {\n throw new UnexpectedServerError(body);\n }\n throw error;\n }\n }\n\n return response;\n } catch (error: any) {\n // When running `expo start`, but wifi or internet has issues\n if (\n isNetworkError(error) || // node-fetch error handling\n ('cause' in error && isNetworkError(error.cause)) // undici error handling\n ) {\n disableNetwork();\n\n throw new CommandError(\n 'OFFLINE',\n 'Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.'\n );\n }\n\n throw error;\n }\n };\n}\n\n/**\n * Determine if the provided error is related to a network issue.\n * When this returns true, offline mode should be enabled.\n * - `ENOTFOUND` is thrown when the DNS lookup failed\n * - `UND_ERR_CONNECT_TIMEOUT` is thrown after DNS is resolved, but server can't be reached\n *\n * @see https://nodejs.org/api/errors.html\n * @see https://github.com/nodejs/undici#network-address-family-autoselection\n */\nfunction isNetworkError(error: Error & { code?: string }) {\n return (\n 'code' in error && error.code && ['ENOTFOUND', 'UND_ERR_CONNECT_TIMEOUT'].includes(error.code)\n );\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(wrapFetchWithUserAgent(fetch));\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithProxy = wrapFetchWithProxy(fetchWithBaseUrl);\n\nconst fetchWithCredentials = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n\n/**\n * Create an instance of the fully qualified fetch command (auto authentication and api) but with caching in the '~/.expo' directory.\n * Caching is disabled automatically if the EXPO_NO_CACHE or EXPO_BETA environment variables are enabled.\n */\nexport function createCachedFetch({\n fetch = fetchWithCredentials,\n cacheDirectory,\n ttl,\n skipCache,\n}: {\n fetch?: FetchLike;\n cacheDirectory: string;\n ttl?: number;\n skipCache?: boolean;\n}): FetchLike {\n // Disable all caching in EXPO_BETA.\n if (skipCache || env.EXPO_BETA || env.EXPO_NO_CACHE) {\n return fetch;\n }\n\n const { FileSystemResponseCache } =\n require('./cache/FileSystemResponseCache') as typeof import('./cache/FileSystemResponseCache');\n\n return wrapFetchWithCache(\n fetch,\n new FileSystemResponseCache({\n cacheDirectory: path.join(getExpoHomeDirectory(), cacheDirectory),\n ttl,\n })\n );\n}\n\n/** Instance of fetch with automatic base URL pointing to the Expo API, user credential injection, and API error handling. Caching not included. */\nexport const fetchAsync = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n"],"names":["ApiV2Error","UnexpectedServerError","UnexpectedServerData","getResponseDataOrThrow","wrapFetchWithCredentials","createCachedFetch","fetchAsync","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","json","data","JSON","stringify","fetchFunction","fetchWithCredentials","url","options","Array","isArray","headers","resolvedHeaders","token","getAccessToken","authorization","getSession","sessionSecret","status","body","text","parse","errors","length","error","includes","isNetworkError","cause","disableNetwork","CommandError","fetchWithOffline","wrapFetchWithOffline","wrapFetchWithUserAgent","fetch","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetchWithProxy","wrapFetchWithProxy","wrapFetchWithProgress","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","FileSystemResponseCache","require","wrapFetchWithC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Module", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "wrapFetchWithUserAgent", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>wrapFetchWithUserAgent
|
|
8
|
+
});
|
|
9
|
+
function _nodeProcess() {
|
|
10
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("node:process"));
|
|
11
|
+
_nodeProcess = function() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
const _fetch = require("../../utils/fetch");
|
|
17
|
+
function _interopRequireDefault(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function wrapFetchWithUserAgent(fetch) {
|
|
23
|
+
return (url, init = {})=>{
|
|
24
|
+
const headers = new _fetch.Headers(init.headers);
|
|
25
|
+
// Version is added in the build script
|
|
26
|
+
headers.append("User-Agent", `expo-cli/${_nodeProcess().default.env.__EXPO_VERSION}`);
|
|
27
|
+
init.headers = headers;
|
|
28
|
+
return fetch(url, init);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=wrapFetchWithUserAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/rest/wrapFetchWithUserAgent.ts"],"sourcesContent":["import process from 'node:process';\n\nimport { FetchLike } from './client.types';\nimport { Headers } from '../../utils/fetch';\n\nexport function wrapFetchWithUserAgent(fetch: FetchLike): FetchLike {\n return (url, init = {}) => {\n const headers = new Headers(init.headers);\n // Version is added in the build script\n headers.append('User-Agent', `expo-cli/${process.env.__EXPO_VERSION}`);\n init.headers = headers;\n return fetch(url, init);\n };\n}\n"],"names":["wrapFetchWithUserAgent","fetch","url","init","headers","Headers","append","process","env","__EXPO_VERSION"],"mappings":"AAAA;;;;+BAKgBA,wBAAsB;;aAAtBA,sBAAsB;;;8DALlB,cAAc;;;;;;uBAGV,mBAAmB;;;;;;AAEpC,SAASA,sBAAsB,CAACC,KAAgB,EAAa;IAClE,OAAO,CAACC,GAAG,EAAEC,IAAI,GAAG,EAAE,GAAK;QACzB,MAAMC,OAAO,GAAG,IAAIC,MAAO,QAAA,CAACF,IAAI,CAACC,OAAO,CAAC,AAAC;QAC1C,uCAAuC;QACvCA,OAAO,CAACE,MAAM,CAAC,YAAY,EAAE,CAAC,SAAS,EAAEC,YAAO,EAAA,QAAA,CAACC,GAAG,CAACC,cAAc,CAAC,CAAC,CAAC,CAAC;QACvEN,IAAI,CAACC,OAAO,GAAGA,OAAO,CAAC;QACvB,OAAOH,KAAK,CAACC,GAAG,EAAEC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -93,7 +93,7 @@ function isCodeSigningConfigured(projectRoot) {
|
|
|
93
93
|
}
|
|
94
94
|
async function configureCodeSigningAsync(projectRoot) {
|
|
95
95
|
const ids = await _security.findIdentitiesAsync();
|
|
96
|
-
const id = await (0, _resolveCertificateSigningIdentity.resolveCertificateSigningIdentityAsync)(ids);
|
|
96
|
+
const id = await (0, _resolveCertificateSigningIdentity.resolveCertificateSigningIdentityAsync)(projectRoot, ids);
|
|
97
97
|
_log.log(`\u203A Signing and building iOS app with: ${id.codeSigningInfo}`);
|
|
98
98
|
(0, _xcodeCodeSigning.setAutoCodeSigningInfoForPbxproj)(projectRoot, {
|
|
99
99
|
appleTeamId: id.appleTeamId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/run/ios/codeSigning/configureCodeSigning.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Security from './Security';\nimport { resolveCertificateSigningIdentityAsync } from './resolveCertificateSigningIdentity';\nimport { getCodeSigningInfoForPbxproj, setAutoCodeSigningInfoForPbxproj } from './xcodeCodeSigning';\nimport * as Log from '../../../log';\n\nexport async function ensureDeviceIsCodeSignedForDeploymentAsync(\n projectRoot: string\n): Promise<string | null> {\n if (isCodeSigningConfigured(projectRoot)) {\n return null;\n }\n return configureCodeSigningAsync(projectRoot);\n}\n\nfunction isCodeSigningConfigured(projectRoot: string): boolean {\n // Check if the app already has a development team defined.\n const signingInfo = getCodeSigningInfoForPbxproj(projectRoot);\n\n const allTargetsHaveTeams = Object.values(signingInfo).reduce((prev, curr) => {\n return prev && !!curr.developmentTeams.length;\n }, true);\n\n if (allTargetsHaveTeams) {\n const teamList = Object.values(signingInfo).reduce<string[]>((prev, curr) => {\n return prev.concat([curr.developmentTeams[0]]);\n }, []);\n Log.log(chalk.dim`\\u203A Auto signing app using team(s): ${teamList.join(', ')}`);\n return true;\n }\n\n const allTargetsHaveProfiles = Object.values(signingInfo).reduce((prev, curr) => {\n return prev && !!curr.provisioningProfiles.length;\n }, true);\n\n if (allTargetsHaveProfiles) {\n // this indicates that the user has manual code signing setup (possibly for production).\n return true;\n }\n return false;\n}\n\nasync function configureCodeSigningAsync(projectRoot: string) {\n const ids = await Security.findIdentitiesAsync();\n\n const id = await resolveCertificateSigningIdentityAsync(ids);\n\n Log.log(`\\u203A Signing and building iOS app with: ${id.codeSigningInfo}`);\n\n setAutoCodeSigningInfoForPbxproj(projectRoot, {\n appleTeamId: id.appleTeamId!,\n });\n return id.appleTeamId!;\n}\n"],"names":["ensureDeviceIsCodeSignedForDeploymentAsync","projectRoot","isCodeSigningConfigured","configureCodeSigningAsync","signingInfo","getCodeSigningInfoForPbxproj","allTargetsHaveTeams","Object","values","reduce","prev","curr","developmentTeams","length","teamList","concat","Log","log","chalk","dim","join","allTargetsHaveProfiles","provisioningProfiles","ids","Security","findIdentitiesAsync","id","resolveCertificateSigningIdentityAsync","codeSigningInfo","setAutoCodeSigningInfoForPbxproj","appleTeamId"],"mappings":"AAAA;;;;+BAOsBA,4CAA0C;;aAA1CA,0CAA0C;;;8DAP9C,OAAO;;;;;;gEAEC,YAAY;mDACiB,qCAAqC;kCACb,oBAAoB;2DAC9E,c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AACT,MAAM,CAAC;IACpD,CAAC,EAAE,IAAI,CAAC,AAAC;IAET,IAAIQ,sBAAsB,EAAE;QAC1B,wFAAwF;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,eAAelB,yBAAyB,CAACF,WAAmB,EAAE;IAC5D,MAAMsB,GAAG,GAAG,MAAMC,SAAQ,CAACC,mBAAmB,EAAE,AAAC;IAEjD,MAAMC,EAAE,GAAG,MAAMC,IAAAA,kCAAsC,uCAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/run/ios/codeSigning/configureCodeSigning.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Security from './Security';\nimport { resolveCertificateSigningIdentityAsync } from './resolveCertificateSigningIdentity';\nimport { getCodeSigningInfoForPbxproj, setAutoCodeSigningInfoForPbxproj } from './xcodeCodeSigning';\nimport * as Log from '../../../log';\n\nexport async function ensureDeviceIsCodeSignedForDeploymentAsync(\n projectRoot: string\n): Promise<string | null> {\n if (isCodeSigningConfigured(projectRoot)) {\n return null;\n }\n return configureCodeSigningAsync(projectRoot);\n}\n\nfunction isCodeSigningConfigured(projectRoot: string): boolean {\n // Check if the app already has a development team defined.\n const signingInfo = getCodeSigningInfoForPbxproj(projectRoot);\n\n const allTargetsHaveTeams = Object.values(signingInfo).reduce((prev, curr) => {\n return prev && !!curr.developmentTeams.length;\n }, true);\n\n if (allTargetsHaveTeams) {\n const teamList = Object.values(signingInfo).reduce<string[]>((prev, curr) => {\n return prev.concat([curr.developmentTeams[0]]);\n }, []);\n Log.log(chalk.dim`\\u203A Auto signing app using team(s): ${teamList.join(', ')}`);\n return true;\n }\n\n const allTargetsHaveProfiles = Object.values(signingInfo).reduce((prev, curr) => {\n return prev && !!curr.provisioningProfiles.length;\n }, true);\n\n if (allTargetsHaveProfiles) {\n // this indicates that the user has manual code signing setup (possibly for production).\n return true;\n }\n return false;\n}\n\nasync function configureCodeSigningAsync(projectRoot: string) {\n const ids = await Security.findIdentitiesAsync();\n\n const id = await resolveCertificateSigningIdentityAsync(projectRoot, ids);\n\n Log.log(`\\u203A Signing and building iOS app with: ${id.codeSigningInfo}`);\n\n setAutoCodeSigningInfoForPbxproj(projectRoot, {\n appleTeamId: id.appleTeamId!,\n });\n return id.appleTeamId!;\n}\n"],"names":["ensureDeviceIsCodeSignedForDeploymentAsync","projectRoot","isCodeSigningConfigured","configureCodeSigningAsync","signingInfo","getCodeSigningInfoForPbxproj","allTargetsHaveTeams","Object","values","reduce","prev","curr","developmentTeams","length","teamList","concat","Log","log","chalk","dim","join","allTargetsHaveProfiles","provisioningProfiles","ids","Security","findIdentitiesAsync","id","resolveCertificateSigningIdentityAsync","codeSigningInfo","setAutoCodeSigningInfoForPbxproj","appleTeamId"],"mappings":"AAAA;;;;+BAOsBA,4CAA0C;;aAA1CA,0CAA0C;;;8DAP9C,OAAO;;;;;;gEAEC,YAAY;mDACiB,qCAAqC;kCACb,oBAAoB;2DAC9E,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5B,eAAeA,0CAA0C,CAC9DC,WAAmB,EACK;IACxB,IAAIC,uBAAuB,CAACD,WAAW,CAAC,EAAE;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAOE,yBAAyB,CAACF,WAAW,CAAC,CAAC;AAChD,CAAC;AAED,SAASC,uBAAuB,CAACD,WAAmB,EAAW;IAC7D,2DAA2D;IAC3D,MAAMG,WAAW,GAAGC,IAAAA,iBAA4B,6BAAA,EAACJ,WAAW,CAAC,AAAC;IAE9D,MAAMK,mBAAmB,GAAGC,MAAM,CAACC,MAAM,CAACJ,WAAW,CAAC,CAACK,MAAM,CAAC,CAACC,IAAI,EAAEC,IAAI,GAAK;QAC5E,OAAOD,IAAI,IAAI,CAAC,CAACC,IAAI,CAACC,gBAAgB,CAACC,MAAM,CAAC;IAChD,CAAC,EAAE,IAAI,CAAC,AAAC;IAET,IAAIP,mBAAmB,EA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,CAAC"}
|
|
@@ -13,6 +13,13 @@ _export(exports, {
|
|
|
13
13
|
resolveCertificateSigningIdentityAsync: ()=>resolveCertificateSigningIdentityAsync,
|
|
14
14
|
selectDevelopmentTeamAsync: ()=>selectDevelopmentTeamAsync
|
|
15
15
|
});
|
|
16
|
+
function _config() {
|
|
17
|
+
const data = require("@expo/config");
|
|
18
|
+
_config = function() {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
16
23
|
function _chalk() {
|
|
17
24
|
const data = /*#__PURE__*/ _interopRequireDefault(require("chalk"));
|
|
18
25
|
_chalk = function() {
|
|
@@ -93,7 +100,8 @@ async function sortDefaultIdToBeginningAsync(identities) {
|
|
|
93
100
|
_log.log(`\u203A Your computer requires some additional setup before you can build onto physical iOS devices.\n ${_chalk().default.bold((0, _link.learnMore)("https://expo.fyi/setup-xcode-signing"))}`);
|
|
94
101
|
throw new _errors.CommandError("No code signing certificates are available to use.");
|
|
95
102
|
}
|
|
96
|
-
async function resolveCertificateSigningIdentityAsync(ids) {
|
|
103
|
+
async function resolveCertificateSigningIdentityAsync(projectRoot, ids) {
|
|
104
|
+
var ref;
|
|
97
105
|
// The user has no valid code signing identities.
|
|
98
106
|
if (!ids.length) {
|
|
99
107
|
assertCodeSigningSetup();
|
|
@@ -108,11 +116,27 @@ async function resolveCertificateSigningIdentityAsync(ids) {
|
|
|
108
116
|
}
|
|
109
117
|
// Get identities and sort by the one that the user is most likely to choose.
|
|
110
118
|
const [identities, preferred] = await sortDefaultIdToBeginningAsync(await _security.resolveIdentitiesAsync(ids));
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
119
|
+
// Read the config to interact with the `ios.appleTeamId` property
|
|
120
|
+
const { exp } = (0, _config().getConfig)(projectRoot, {
|
|
121
|
+
// We don't need very many fields here, just use the lightest possible read.
|
|
122
|
+
skipSDKVersionRequirement: true,
|
|
123
|
+
skipPlugins: true
|
|
124
|
+
});
|
|
125
|
+
const configuredTeamId = (ref = exp.ios) == null ? void 0 : ref.appleTeamId;
|
|
126
|
+
const configuredIdentity = configuredTeamId ? identities.find((identity)=>identity.appleTeamId === configuredTeamId) : undefined;
|
|
127
|
+
const selectedIdentity = configuredIdentity ?? await selectDevelopmentTeamAsync(identities, preferred);
|
|
128
|
+
await Promise.all([
|
|
129
|
+
// Store the last used value and suggest it as the first value
|
|
130
|
+
// next time the user has to select a code signing identity.
|
|
131
|
+
(0, _settings.setLastDeveloperCodeSigningIdAsync)(selectedIdentity.signingCertificateId),
|
|
132
|
+
// Store the last used team id in the app manifest, when no team id has been configured yet
|
|
133
|
+
configuredTeamId || !selectedIdentity.appleTeamId ? Promise.resolve() : (0, _config().modifyConfigAsync)(projectRoot, {
|
|
134
|
+
ios: {
|
|
135
|
+
appleTeamId: selectedIdentity.appleTeamId
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
]);
|
|
139
|
+
return selectedIdentity;
|
|
116
140
|
}
|
|
117
141
|
async function selectDevelopmentTeamAsync(identities, preferredId) {
|
|
118
142
|
const index = await (0, _prompts.selectAsync)("Development team for signing the app", identities.map((value, i)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/run/ios/codeSigning/resolveCertificateSigningIdentity.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Security from './Security';\nimport { getLastDeveloperCodeSigningIdAsync, setLastDeveloperCodeSigningIdAsync } from './settings';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { learnMore } from '../../../utils/link';\nimport { selectAsync } from '../../../utils/prompts';\n\n/**\n * Sort the code signing items so the last selected item (user's default) is the first suggested.\n */\nexport async function sortDefaultIdToBeginningAsync(\n identities: Security.CertificateSigningInfo[]\n): Promise<[Security.CertificateSigningInfo[], string | null]> {\n const lastSelected = await getLastDeveloperCodeSigningIdAsync();\n\n if (lastSelected) {\n let iterations = 0;\n while (identities[0].signingCertificateId !== lastSelected && iterations < identities.length) {\n identities.push(identities.shift()!);\n iterations++;\n }\n }\n return [identities, lastSelected];\n}\n\n/**\n * Assert that the computer needs code signing setup.\n * This links to an FYI page that was user tested internally.\n */\nfunction assertCodeSigningSetup(): never {\n // TODO: We can probably do this too automatically.\n Log.log(\n `\\u203A Your computer requires some additional setup before you can build onto physical iOS devices.\\n ${chalk.bold(\n learnMore('https://expo.fyi/setup-xcode-signing')\n )}`\n );\n\n throw new CommandError('No code signing certificates are available to use.');\n}\n\n/**\n * Resolve the best certificate signing identity from a given list of IDs.\n * - If no IDs: Assert that the user has to setup code signing.\n * - If one ID: Return the first ID.\n * - If multiple IDs: Ask the user to select one, then store the value to be suggested first next time (since users generally use the same ID).\n */\nexport async function resolveCertificateSigningIdentityAsync(\n ids: string[]\n): Promise<Security.CertificateSigningInfo> {\n // The user has no valid code signing identities.\n if (!ids.length) {\n assertCodeSigningSetup();\n }\n\n // One ID available 🤝 Program is not interactive\n //\n // using the the first available option\n if (ids.length === 1 || !isInteractive()) {\n // This method is cheaper than `resolveIdentitiesAsync` and checking the\n // cached user preference so we should use this as early as possible.\n return Security.resolveCertificateSigningInfoAsync(ids[0]);\n }\n\n // Get identities and sort by the one that the user is most likely to choose.\n const [identities, preferred] = await sortDefaultIdToBeginningAsync(\n await Security.resolveIdentitiesAsync(ids)\n );\n\n const
|
|
1
|
+
{"version":3,"sources":["../../../../../src/run/ios/codeSigning/resolveCertificateSigningIdentity.ts"],"sourcesContent":["import { getConfig, modifyConfigAsync } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Security from './Security';\nimport { getLastDeveloperCodeSigningIdAsync, setLastDeveloperCodeSigningIdAsync } from './settings';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { learnMore } from '../../../utils/link';\nimport { selectAsync } from '../../../utils/prompts';\n\n/**\n * Sort the code signing items so the last selected item (user's default) is the first suggested.\n */\nexport async function sortDefaultIdToBeginningAsync(\n identities: Security.CertificateSigningInfo[]\n): Promise<[Security.CertificateSigningInfo[], string | null]> {\n const lastSelected = await getLastDeveloperCodeSigningIdAsync();\n\n if (lastSelected) {\n let iterations = 0;\n while (identities[0].signingCertificateId !== lastSelected && iterations < identities.length) {\n identities.push(identities.shift()!);\n iterations++;\n }\n }\n return [identities, lastSelected];\n}\n\n/**\n * Assert that the computer needs code signing setup.\n * This links to an FYI page that was user tested internally.\n */\nfunction assertCodeSigningSetup(): never {\n // TODO: We can probably do this too automatically.\n Log.log(\n `\\u203A Your computer requires some additional setup before you can build onto physical iOS devices.\\n ${chalk.bold(\n learnMore('https://expo.fyi/setup-xcode-signing')\n )}`\n );\n\n throw new CommandError('No code signing certificates are available to use.');\n}\n\n/**\n * Resolve the best certificate signing identity from a given list of IDs.\n * - If no IDs: Assert that the user has to setup code signing.\n * - If one ID: Return the first ID.\n * - If multiple IDs: Ask the user to select one, then store the value to be suggested first next time (since users generally use the same ID).\n */\nexport async function resolveCertificateSigningIdentityAsync(\n projectRoot: string,\n ids: string[]\n): Promise<Security.CertificateSigningInfo> {\n // The user has no valid code signing identities.\n if (!ids.length) {\n assertCodeSigningSetup();\n }\n\n // One ID available 🤝 Program is not interactive\n //\n // using the the first available option\n if (ids.length === 1 || !isInteractive()) {\n // This method is cheaper than `resolveIdentitiesAsync` and checking the\n // cached user preference so we should use this as early as possible.\n return Security.resolveCertificateSigningInfoAsync(ids[0]);\n }\n\n // Get identities and sort by the one that the user is most likely to choose.\n const [identities, preferred] = await sortDefaultIdToBeginningAsync(\n await Security.resolveIdentitiesAsync(ids)\n );\n\n // Read the config to interact with the `ios.appleTeamId` property\n const { exp } = getConfig(projectRoot, {\n // We don't need very many fields here, just use the lightest possible read.\n skipSDKVersionRequirement: true,\n skipPlugins: true,\n });\n const configuredTeamId = exp.ios?.appleTeamId;\n\n const configuredIdentity = configuredTeamId\n ? identities.find((identity) => identity.appleTeamId === configuredTeamId)\n : undefined;\n\n const selectedIdentity =\n configuredIdentity ?? (await selectDevelopmentTeamAsync(identities, preferred));\n\n await Promise.all([\n // Store the last used value and suggest it as the first value\n // next time the user has to select a code signing identity.\n setLastDeveloperCodeSigningIdAsync(selectedIdentity.signingCertificateId),\n // Store the last used team id in the app manifest, when no team id has been configured yet\n configuredTeamId || !selectedIdentity.appleTeamId\n ? Promise.resolve()\n : modifyConfigAsync(projectRoot, { ios: { appleTeamId: selectedIdentity.appleTeamId } }),\n ]);\n\n return selectedIdentity;\n}\n\n/** Prompt the user to select a development team, highlighting the preferred value based on the user history. */\nexport async function selectDevelopmentTeamAsync(\n identities: Security.CertificateSigningInfo[],\n preferredId: string | null\n): Promise<Security.CertificateSigningInfo> {\n const index = await selectAsync(\n 'Development team for signing the app',\n identities.map((value, i) => {\n const format =\n value.signingCertificateId === preferredId ? chalk.bold : (message: string) => message;\n return {\n // Formatted like: `650 Industries, Inc. (A1BCDEF234) - Apple Development: Evan Bacon (AA00AABB0A)`\n title: format(\n [value.appleTeamName, `(${value.appleTeamId}) -`, value.codeSigningInfo].join(' ')\n ),\n value: i,\n };\n })\n );\n\n return identities[index];\n}\n"],"names":["sortDefaultIdToBeginningAsync","resolveCertificateSigningIdentityAsync","selectDevelopmentTeamAsync","identities","lastSelected","getLastDeveloperCodeSigningIdAsync","iterations","signingCertificateId","length","push","shift","assertCodeSigningSetup","Log","log","chalk","bold","learnMore","CommandError","projectRoot","ids","exp","isInteractive","Security","resolveCertificateSigningInfoAsync","preferred","resolveIdentitiesAsync","getConfig","skipSDKVersionRequirement","skipPlugins","configuredTeamId","ios","appleTeamId","configuredIdentity","find","identity","undefined","selectedIdentity","Promise","all","setLastDeveloperCodeSigningIdAsync","resolve","modifyConfigAsync","preferredId","index","selectAsync","map","value","i","format","message","title","appleTeamName","codeSigningInfo","join"],"mappings":"AAAA;;;;;;;;;;;IAcsBA,6BAA6B,MAA7BA,6BAA6B;IAoC7BC,sCAAsC,MAAtCA,s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B,CAACL,WAAW;aAAE;SAAE,CAAC;KAC3F,CAAC,CAAC;IAEH,OAAOK,gBAAgB,CAAC;AAC1B,CAAC;AAGM,eAAelC,0BAA0B,CAC9CC,UAA6C,EAC7CuC,WAA0B,EACgB;IAC1C,MAAMC,KAAK,GAAG,MAAMC,IAAAA,QAAW,YAAA,EAC7B,sCAAsC,EACtCzC,UAAU,CAAC0C,GAAG,CAAC,CAACC,KAAK,EAAEC,CAAC,GAAK;QAC3B,MAAMC,MAAM,GACVF,KAAK,CAACvC,oBAAoB,KAAKmC,WAAW,GAAG5B,MAAK,EAAA,QAAA,CAACC,IAAI,GAAG,CAACkC,OAAe,GAAKA,OAAO,AAAC;QACzF,OAAO;YACL,mGAAmG;YACnGC,KAAK,EAAEF,MAAM,CACX;gBAACF,KAAK,CAACK,aAAa;gBAAE,CAAC,CAAC,EAAEL,KAAK,CAACf,WAAW,CAAC,GAAG,CAAC;gBAAEe,KAAK,CAACM,eAAe;aAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CACnF;YACDP,KAAK,EAAEC,CAAC;SACT,CAAC;IACJ,CAAC,CAAC,CACH,AAAC;IAEF,OAAO5C,UAAU,CAACwC,KAAK,CAAC,CAAC;AAC3B,CAAC"}
|
package/build/src/utils/fetch.js
CHANGED
|
@@ -2,10 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
fetch: ()=>fetch,
|
|
13
|
+
Headers: ()=>Headers
|
|
8
14
|
});
|
|
9
|
-
const fetch = typeof globalThis.fetch
|
|
15
|
+
const fetch = typeof globalThis.fetch !== "undefined" ? globalThis.fetch : require("undici").fetch;
|
|
16
|
+
const Headers = typeof globalThis.Headers !== "undefined" ? globalThis.Headers : require("undici").Headers;
|
|
10
17
|
|
|
11
18
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/fetch.ts"],"sourcesContent":["import type { FetchLike } from '../api/rest/client.types';\n\n/**\n * The Node's built-in fetch API, but polyfilled from `undici` if necessary.\n * @todo(cedric): remove this once we min-support a Node version where fetch can't be disabled\n */\nexport const fetch: FetchLike =\n typeof globalThis.fetch
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/fetch.ts"],"sourcesContent":["import type { FetchLike } from '../api/rest/client.types';\n\n/**\n * The Node's built-in fetch API, but polyfilled from `undici` if necessary.\n * @todo(cedric): remove this once we min-support a Node version where fetch can't be disabled\n */\nexport const fetch: FetchLike =\n typeof globalThis.fetch !== 'undefined' ? globalThis.fetch : require('undici').fetch;\n\n/**\n * Node's built-in fetch Headers class, or the polyfilled Headers from `undici` when unavailable.\n * @todo(cedric): remove this once we min-support a Node version where fetch can't be disabled\n */\nexport const Headers: typeof import('undici').Headers =\n typeof globalThis.Headers !== 'undefined' ? globalThis.Headers : require('undici').Headers;\n"],"names":["fetch","Headers","globalThis","require"],"mappings":"AAAA;;;;;;;;;;;IAMaA,KAAK,MAALA,KAAK;IAOLC,OAAO,MAAPA,OAAO;;AAPb,MAAMD,KAAK,GAChB,OAAOE,UAAU,CAACF,KAAK,KAAK,WAAW,GAAGE,UAAU,CAACF,KAAK,GAAGG,OAAO,CAAC,QAAQ,CAAC,CAACH,KAAK,AAAC;AAMhF,MAAMC,OAAO,GAClB,OAAOC,UAAU,CAACD,OAAO,KAAK,WAAW,GAAGC,UAAU,CAACD,OAAO,GAAGE,OAAO,CAAC,QAAQ,CAAC,CAACF,OAAO,AAAC"}
|
|
@@ -31,7 +31,7 @@ class FetchClient {
|
|
|
31
31
|
this.headers = {
|
|
32
32
|
accept: "application/json",
|
|
33
33
|
"content-type": "application/json",
|
|
34
|
-
"user-agent": `expo-cli/${"0.22.
|
|
34
|
+
"user-agent": `expo-cli/${"0.22.2"}`,
|
|
35
35
|
authorization: "Basic " + _nodeBuffer().Buffer.from(`${target}:`).toString("base64")
|
|
36
36
|
};
|
|
37
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"tree-kill": "^1.2.2",
|
|
168
168
|
"tsd": "^0.28.1"
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "9d4e373d6a0feaaba5df625f0b2eb3a60be16616"
|
|
171
171
|
}
|