@expo/cli 0.21.6 → 0.21.7
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/rest/client.js +15 -1
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/api/user/UserSettings.js +4 -0
- package/build/src/api/user/UserSettings.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +3 -6
- package/build/src/start/server/DevelopmentSession.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 +4 -4
package/build/bin/cli
CHANGED
|
@@ -111,7 +111,7 @@ function wrapFetchWithCredentials(fetchFunction) {
|
|
|
111
111
|
return response;
|
|
112
112
|
} catch (error1) {
|
|
113
113
|
// When running `expo start`, but wifi or internet has issues
|
|
114
|
-
if (
|
|
114
|
+
if (isNetworkError(error1) || "cause" in error1 && isNetworkError(error1.cause) // undici error handling
|
|
115
115
|
) {
|
|
116
116
|
(0, _settings.disableNetwork)();
|
|
117
117
|
throw new _errors.CommandError("OFFLINE", "Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.");
|
|
@@ -120,6 +120,20 @@ function wrapFetchWithCredentials(fetchFunction) {
|
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Determine if the provided error is related to a network issue.
|
|
125
|
+
* When this returns true, offline mode should be enabled.
|
|
126
|
+
* - `ENOTFOUND` is thrown when the DNS lookup failed
|
|
127
|
+
* - `UND_ERR_CONNECT_TIMEOUT` is thrown after DNS is resolved, but server can't be reached
|
|
128
|
+
*
|
|
129
|
+
* @see https://nodejs.org/api/errors.html
|
|
130
|
+
* @see https://github.com/nodejs/undici#network-address-family-autoselection
|
|
131
|
+
*/ function isNetworkError(error) {
|
|
132
|
+
return "code" in error && error.code && [
|
|
133
|
+
"ENOTFOUND",
|
|
134
|
+
"UND_ERR_CONNECT_TIMEOUT"
|
|
135
|
+
].includes(error.code);
|
|
136
|
+
}
|
|
123
137
|
const fetchWithOffline = (0, _wrapFetchWithOffline.wrapFetchWithOffline)(_fetch.fetch);
|
|
124
138
|
const fetchWithBaseUrl = (0, _wrapFetchWithBaseUrl.wrapFetchWithBaseUrl)(fetchWithOffline, (0, _endpoint.getExpoApiBaseUrl)() + "/v2/");
|
|
125
139
|
const fetchWithProxy = (0, _wrapFetchWithProxy.wrapFetchWithProxy)(fetchWithBaseUrl);
|
|
@@ -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 ('code' in error && error.code === 'ENOTFOUND') || // node-fetch error handling\n ('cause' in error && 'code' in error.cause && error.cause.code === 'ENOTFOUND') // 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\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","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,qBAAqB;IAQrBC,oBAAoB,MAApBA,oBAAoB;IAKjBC,sBAAsB,MAAtBA,sBAAsB;IAatBC,wBAAwB,MAAxBA,wBAAwB;IAyExBC,iBAAiB,MAAjBA,iBAAiB;IA6BpBC,UAAU,MAAVA,UAAU;;;yBA7Kc,iCAAiC;;;;;;;8DAErD,MAAM;;;;;;oCAEY,4BAA4B;sCAE1B,wBAAwB;sCACxB,wBAAwB;uCACvB,yBAAyB;oCAC5B,sBAAsB;qBACrC,iBAAiB;wBACR,oBAAoB;uBAC3B,mBAAmB;0BACP,aAAa;0BAChB,aAAa;8BACD,sBAAsB;;;;;;AAE1D,MAAMN,UAAU,SAASO,KAAK;IACnC,AAASC,IAAI,GAAG,YAAY,CAAC;IAO7BC,YAAYC,QAMX,CAAE;QACD,KAAK,CAACA,QAAQ,CAACC,OAAO,CAAC,CAAC;QACxB,IAAI,CAACC,IAAI,GAAGF,QAAQ,CAACE,IAAI,CAAC;QAC1B,IAAI,CAACC,kBAAkB,GAAGH,QAAQ,CAACE,IAAI,CAAC;QACxC,IAAI,CAACE,qBAAqB,GAAGJ,QAAQ,CAACK,OAAO,CAAC;QAC9C,IAAI,CAACC,yBAAyB,GAAGN,QAAQ,CAACO,KAAK,CAAC;QAChD,IAAI,CAACC,sBAAsB,GAAGR,QAAQ,CAACS,QAAQ,CAAC;IAClD;CACD;AAMM,MAAMlB,qBAAqB,SAASM,KAAK;IAC9C,AAASC,IAAI,GAAG,uBAAuB,CAAC;C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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,qBAAqB;IAQrBC,oBAAoB,MAApBA,oBAAoB;IAKjBC,sBAAsB,MAAtBA,sBAAsB;IAatBC,wBAAwB,MAAxBA,wBAAwB;IAwFxBC,iBAAiB,MAAjBA,iBAAiB;IA6BpBC,UAAU,MAAVA,UAAU;;;yBA5Lc,iCAAiC;;;;;;;8DAErD,MAAM;;;;;;oCAEY,4BAA4B;sCAE1B,wBAAwB;sCACxB,wBAAwB;uCACvB,yBAAyB;oCAC5B,sBAAsB;qBACrC,iBAAiB;wBACR,oBAAoB;uBAC3B,mBAAmB;0BACP,aAAa;0BAChB,aAAa;8BACD,sBAAsB;;;;;;AAE1D,MAAMN,UAAU,SAASO,KAAK;IACnC,AAASC,IAAI,GAAG,YAAY,CAAC;IAO7BC,YAAYC,QAMX,CAAE;QACD,KAAK,CAACA,QAAQ,CAACC,OAAO,CAAC,CAAC;QACxB,IAAI,CAACC,IAAI,GAAGF,QAAQ,CAACE,IAAI,CAAC;QAC1B,IAAI,CAACC,kBAAkB,GAAGH,QAAQ,CAACE,IAAI,CAAC;QACxC,IAAI,CAACE,qBAAqB,GAAGJ,QAAQ,CAACK,OAAO,CAAC;QAC9C,IAAI,CAACC,yBAAyB,GAAGN,QAAQ,CAACO,KAAK,CAAC;QAChD,IAAI,CAACC,sBAAsB,GAAGR,QAAQ,CAACS,QAAQ,CAAC;IAClD;CACD;AAMM,MAAMlB,qBAAqB,SAASM,KAAK;IAC9C,AAASC,IAAI,GAAG,uBAAuB,CAAC;CACzC;AAMM,MAAMN,oBAAoB,SAASK,KAAK;IAC7C,AAASC,IAAI,GAAG,sBAAsB,CAAC;CACxC;AAGM,SAASL,sBAA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15,7 @@ _export(exports, {
|
|
|
15
15
|
getAccessToken: ()=>getAccessToken,
|
|
16
16
|
getSession: ()=>getSession,
|
|
17
17
|
setSessionAsync: ()=>setSessionAsync,
|
|
18
|
+
hasCredentials: ()=>hasCredentials,
|
|
18
19
|
getAnonymousIdAsync: ()=>getAnonymousIdAsync,
|
|
19
20
|
getAnonymousId: ()=>getAnonymousId
|
|
20
21
|
});
|
|
@@ -69,6 +70,9 @@ async function setSessionAsync(sessionData) {
|
|
|
69
70
|
ensureDir: true
|
|
70
71
|
});
|
|
71
72
|
}
|
|
73
|
+
function hasCredentials() {
|
|
74
|
+
return !!getAccessToken() || !!getSession();
|
|
75
|
+
}
|
|
72
76
|
async function getAnonymousIdAsync() {
|
|
73
77
|
const settings = getSettings();
|
|
74
78
|
let id = await settings.getAsync("uuid", null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/api/user/UserSettings.ts"],"sourcesContent":["import { getExpoHomeDirectory, getUserStatePath } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport crypto from 'crypto';\n\ntype SessionData = {\n sessionSecret: string;\n // These fields are potentially used by Expo CLI.\n userId: string;\n username: string;\n currentConnection: 'Username-Password-Authentication' | 'Browser-Flow-Authentication';\n};\n\nexport type UserSettingsData = {\n auth?: SessionData | null;\n ignoreBundledBinaries?: string[];\n PATH?: string;\n /** Last development code signing ID used for `npx expo run:ios`. */\n developmentCodeSigningId?: string;\n /** Unique user ID which is generated anonymously and can be cleared locally. */\n uuid?: string;\n};\n\n/** Return the user cache directory. */\nexport function getSettingsDirectory() {\n return getExpoHomeDirectory();\n}\n\n/** Return the file path of the settings file */\nexport function getSettingsFilePath(): string {\n return getUserStatePath();\n}\n\n/** Get a new JsonFile instance pointed towards the settings file */\nexport function getSettings(): JsonFile<UserSettingsData> {\n return new JsonFile<UserSettingsData>(getSettingsFilePath(), {\n ensureDir: true,\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nexport function getAccessToken(): string | null {\n return process.env.EXPO_TOKEN ?? null;\n}\n\nexport function getSession() {\n return getSettings().get('auth', null);\n}\n\nexport async function setSessionAsync(sessionData?: SessionData) {\n await getSettings().setAsync('auth', sessionData, {\n default: {},\n ensureDir: true,\n });\n}\n\n/**\n * Get an anonymous and randomly generated identifier.\n * This is used to group telemetry event by unknown actor,\n * and cannot be used to identify a single user.\n */\nexport async function getAnonymousIdAsync(): Promise<string> {\n const settings = getSettings();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\n/**\n * Get an anonymous and randomly generated identifier.\n * This is used to group telemetry event by unknown actor,\n * and cannot be used to identify a single user.\n */\nexport function getAnonymousId(): string {\n const settings = getSettings();\n let id = settings.get('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n settings.set('uuid', id);\n }\n\n return id;\n}\n"],"names":["getSettingsDirectory","getSettingsFilePath","getSettings","getAccessToken","getSession","setSessionAsync","getAnonymousIdAsync","getAnonymousId","getExpoHomeDirectory","getUserStatePath","JsonFile","ensureDir","jsonParseErrorDefault","cantReadFileDefault","process","env","EXPO_TOKEN","get","sessionData","setAsync","default","settings","id","getAsync","crypto","randomUUID","set"],"mappings":"AAAA;;;;;;;;;;;IAuBgBA,oBAAoB,MAApBA,oBAAoB;IAKpBC,mBAAmB,MAAnBA,mBAAmB;IAKnBC,WAAW,MAAXA,WAAW;IAQXC,cAAc,MAAdA,cAAc;IAIdC,UAAU,MAAVA,UAAU;IAIJC,eAAe,MAAfA,eAAe;
|
|
1
|
+
{"version":3,"sources":["../../../../src/api/user/UserSettings.ts"],"sourcesContent":["import { getExpoHomeDirectory, getUserStatePath } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport crypto from 'crypto';\n\ntype SessionData = {\n sessionSecret: string;\n // These fields are potentially used by Expo CLI.\n userId: string;\n username: string;\n currentConnection: 'Username-Password-Authentication' | 'Browser-Flow-Authentication';\n};\n\nexport type UserSettingsData = {\n auth?: SessionData | null;\n ignoreBundledBinaries?: string[];\n PATH?: string;\n /** Last development code signing ID used for `npx expo run:ios`. */\n developmentCodeSigningId?: string;\n /** Unique user ID which is generated anonymously and can be cleared locally. */\n uuid?: string;\n};\n\n/** Return the user cache directory. */\nexport function getSettingsDirectory() {\n return getExpoHomeDirectory();\n}\n\n/** Return the file path of the settings file */\nexport function getSettingsFilePath(): string {\n return getUserStatePath();\n}\n\n/** Get a new JsonFile instance pointed towards the settings file */\nexport function getSettings(): JsonFile<UserSettingsData> {\n return new JsonFile<UserSettingsData>(getSettingsFilePath(), {\n ensureDir: true,\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nexport function getAccessToken(): string | null {\n return process.env.EXPO_TOKEN ?? null;\n}\n\nexport function getSession() {\n return getSettings().get('auth', null);\n}\n\nexport async function setSessionAsync(sessionData?: SessionData) {\n await getSettings().setAsync('auth', sessionData, {\n default: {},\n ensureDir: true,\n });\n}\n\n/**\n * Check if there are credentials available, without fetching the user information.\n * This can be used as a faster check to see if users are authenticated.\n * Note, this isn't checking the validity of the credentials.\n */\nexport function hasCredentials() {\n return !!getAccessToken() || !!getSession();\n}\n\n/**\n * Get an anonymous and randomly generated identifier.\n * This is used to group telemetry event by unknown actor,\n * and cannot be used to identify a single user.\n */\nexport async function getAnonymousIdAsync(): Promise<string> {\n const settings = getSettings();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\n/**\n * Get an anonymous and randomly generated identifier.\n * This is used to group telemetry event by unknown actor,\n * and cannot be used to identify a single user.\n */\nexport function getAnonymousId(): string {\n const settings = getSettings();\n let id = settings.get('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n settings.set('uuid', id);\n }\n\n return id;\n}\n"],"names":["getSettingsDirectory","getSettingsFilePath","getSettings","getAccessToken","getSession","setSessionAsync","hasCredentials","getAnonymousIdAsync","getAnonymousId","getExpoHomeDirectory","getUserStatePath","JsonFile","ensureDir","jsonParseErrorDefault","cantReadFileDefault","process","env","EXPO_TOKEN","get","sessionData","setAsync","default","settings","id","getAsync","crypto","randomUUID","set"],"mappings":"AAAA;;;;;;;;;;;IAuBgBA,oBAAoB,MAApBA,oBAAoB;IAKpBC,mBAAmB,MAAnBA,mBAAmB;IAKnBC,WAAW,MAAXA,WAAW;IAQXC,cAAc,MAAdA,cAAc;IAIdC,UAAU,MAAVA,UAAU;IAIJC,eAAe,MAAfA,eAAe;IAYrBC,cAAc,MAAdA,cAAc;IASRC,mBAAmB,MAAnBA,mBAAmB;IAiBzBC,cAAc,MAAdA,cAAc;;;yBAvFyB,iCAAiC;;;;;;;8DACnE,iBAAiB;;;;;;;8DACnB,QAAQ;;;;;;;;;;;AAqBpB,SAASR,oBAAoB,GAAG;IACrC,OAAOS,IAAAA,aAAoB,EAAA,qBAAA,GAAE,CAAC;AAChC,CAAC;AAGM,SAASR,mBAAmB,GAAW;IAC5C,OAAOS,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC;AAC5B,CAAC;AAGM,SAASR,WAAW,GAA+B;IACxD,OAAO,IAAIS,CAAAA,SAAQ,EAAA,CAAA,QAAA,CAAmBV,mBAAmB,EAAE,EAAE;QAC3DW,SAAS,EAAE,IAAI;QACfC,qBAAqB,EAAE,EAAE;QACzBC,mBAAmB,EAAE,EAAE;KACxB,CAAC,CAAC;AACL,CAAC;AAEM,SAASX,cAAc,GAAkB;IAC9C,OAAOY,OAAO,CAACC,GAAG,CAACC,UAAU,IAAI,IAAI,CAAC;AACxC,CAAC;AAEM,SAASb,UAAU,GAAG;IAC3B,OAAOF,WAAW,EAAE,CAACgB,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAEM,eAAeb,eAAe,CAACc,WAAyB,EAAE;IAC/D,MAAMjB,WAAW,EAAE,CAACkB,QAAQ,CAAC,MAAM,EAAED,WAAW,EAAE;QAChDE,OAAO,EAAE,EAAE;QACXT,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAOM,SAASN,cAAc,GAAG;IAC/B,OAAO,CAAC,CAACH,cAAc,EAAE,IAAI,CAAC,CAACC,UAAU,EAAE,CAAC;AAC9C,CAAC;AAOM,eAAeG,mBAAmB,GAAoB;IAC3D,MAAMe,QAAQ,GAAGpB,WAAW,EAAE,AAAC;IAC/B,IAAIqB,EAAE,GAAG,MAAMD,QAAQ,CAACE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,AAAC;IAE/C,IAAI,CAACD,EAAE,EAAE;QACPA,EAAE,GAAGE,OAAM,EAAA,QAAA,CAACC,UAAU,EAAE,CAAC;QACzB,MAAMJ,QAAQ,CAACF,QAAQ,CAAC,MAAM,EAAEG,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,OAAOA,EAAE,CAAC;AACZ,CAAC;AAOM,SAASf,cAAc,GAAW;IACvC,MAAMc,QAAQ,GAAGpB,WAAW,EAAE,AAAC;IAC/B,IAAIqB,EAAE,GAAGD,QAAQ,CAACJ,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,AAAC;IAEpC,IAAI,CAACK,EAAE,EAAE;QACPA,EAAE,GAAGE,OAAM,EAAA,QAAA,CAACC,UAAU,EAAE,CAAC;QACzBJ,QAAQ,CAACK,GAAG,CAAC,MAAM,EAAEJ,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,OAAOA,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -14,7 +14,7 @@ function _config() {
|
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
16
|
const _updateDevelopmentSession = require("../../api/updateDevelopmentSession");
|
|
17
|
-
const
|
|
17
|
+
const _userSettings = require("../../api/user/UserSettings");
|
|
18
18
|
const _env = require("../../utils/env");
|
|
19
19
|
const _devices = /*#__PURE__*/ _interopRequireWildcard(require("../project/devices"));
|
|
20
20
|
function _getRequireWildcardCache(nodeInterop) {
|
|
@@ -57,9 +57,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
57
57
|
return newObj;
|
|
58
58
|
}
|
|
59
59
|
const debug = require("debug")("expo:start:server:developmentSession");
|
|
60
|
-
async function isAuthenticatedAsync() {
|
|
61
|
-
return !!await (0, _user.getUserAsync)().catch(()=>null);
|
|
62
|
-
}
|
|
63
60
|
class DevelopmentSession {
|
|
64
61
|
constructor(projectRoot, url){
|
|
65
62
|
this.projectRoot = projectRoot;
|
|
@@ -80,7 +77,7 @@ class DevelopmentSession {
|
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
82
79
|
const deviceIds = await this.getDeviceInstallationIdsAsync();
|
|
83
|
-
if (!
|
|
80
|
+
if (!(0, _userSettings.hasCredentials)() && !(deviceIds == null ? void 0 : deviceIds.length)) {
|
|
84
81
|
debug("Development session will not ping because the user is not authenticated and there are no devices.");
|
|
85
82
|
return;
|
|
86
83
|
}
|
|
@@ -111,7 +108,7 @@ class DevelopmentSession {
|
|
|
111
108
|
this.hasActiveSession = false;
|
|
112
109
|
try {
|
|
113
110
|
const deviceIds = await this.getDeviceInstallationIdsAsync();
|
|
114
|
-
if (!
|
|
111
|
+
if (!(0, _userSettings.hasCredentials)() && !(deviceIds == null ? void 0 : deviceIds.length)) {
|
|
115
112
|
return false;
|
|
116
113
|
}
|
|
117
114
|
if (this.url) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { hasCredentials } from '../../api/user/UserSettings';\nimport { env } from '../../utils/env';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nexport class DevelopmentSession {\n /** If the `startAsync` was successfully called */\n private hasActiveSession = false;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n try {\n if (env.CI || env.EXPO_OFFLINE) {\n debug(\n env.CI\n ? 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in CI.'\n : 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.'\n );\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!hasCredentials() && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n return;\n }\n\n if (this.url) {\n debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n this.hasActiveSession = true;\n }\n } catch (error: any) {\n debug(`Error updating development session API: ${error}`);\n }\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Try to close any pending development sessions, but always resolve */\n public async closeAsync(): Promise<boolean> {\n if (env.CI || env.EXPO_OFFLINE || !this.hasActiveSession) {\n return false;\n }\n\n // Clear out the development session, even if the call fails.\n // This blocks subsequent calls to `stopAsync`\n this.hasActiveSession = false;\n\n try {\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!hasCredentials() && !deviceIds?.length) {\n return false;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n\n return true;\n } catch (error: any) {\n debug(`Error closing development session API: ${error}`);\n return false;\n }\n }\n}\n"],"names":["DevelopmentSession","debug","require","constructor","projectRoot","url","hasActiveSession","startAsync","exp","getConfig","runtime","env","CI","EXPO_OFFLINE","deviceIds","getDeviceInstallationIdsAsync","hasCredentials","length","updateDevelopmentSessionAsync","error","devices","ProjectDevices","getDevicesInfoAsync","map","installationId","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;+BAYaA,oBAAkB;;aAAlBA,kBAAkB;;;yBAZO,cAAc;;;;;;0CAK7C,oCAAoC;8BACZ,6BAA6B;qBACxC,iBAAiB;+DACL,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAEtF,MAAMF,kBAAkB;IAI7BG,YAEUC,WAAmB,EAEpBC,GAAkB,CACzB;QAHQD,mBAAAA,WAAmB,CAAA;QAEpBC,WAAAA,GAAkB,CAAA;aANnBC,gBAAgB,GAAG,KAAK;IAO7B;IAEH;;;;;;;GAOC,SACYC,UAAU,CAAC,EACtBC,GAAG,EAAGC,IAAAA,OAAS,EAAA,UAAA,EAAC,IAAI,CAACL,WAAW,CAAC,CAACI,GAAG,CAAA,EACrCE,OAAO,CAAA,EAIR,EAAiB;QAChB,IAAI;YACF,IAAIC,IAAG,IAAA,CAACC,EAAE,IAAID,IAAG,IAAA,CAACE,YAAY,EAAE;gBAC9BZ,KAAK,CACHU,IAAG,IAAA,CAACC,EAAE,G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A6D;QAC7D,8CAA8C;QAC9C,IAAI,CAACA,gBAAgB,GAAG,KAAK,CAAC;QAE9B,IAAI;YACF,MAAMQ,SAAS,GAAG,MAAM,IAAI,CAACC,6BAA6B,EAAE,AAAC;YAE7D,IAAI,CAACC,IAAAA,aAAc,eAAA,GAAE,IAAI,CAACF,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEG,MAAM,CAAA,EAAE;gBAC3C,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,IAAI,CAACZ,GAAG,EAAE;gBACZ,MAAMqB,IAAAA,yBAA4B,6BAAA,EAAC;oBACjCrB,GAAG,EAAE,IAAI,CAACA,GAAG;oBACbS,SAAS;iBACV,CAAC,CAAC;YACL,CAAC;YAED,OAAO,IAAI,CAAC;QACd,EAAE,OAAOK,KAAK,EAAO;YACnBlB,KAAK,CAAC,CAAC,uCAAuC,EAAEkB,KAAK,CAAC,CAAC,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC;QACf,CAAC;IACH;CACD"}
|
|
@@ -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.21.
|
|
34
|
+
"user-agent": `expo-cli/${"0.21.7"}`,
|
|
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.21.
|
|
3
|
+
"version": "0.21.7",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@babel/runtime": "^7.20.0",
|
|
44
44
|
"@expo/code-signing-certificates": "^0.0.5",
|
|
45
45
|
"@expo/config": "~10.0.4",
|
|
46
|
-
"@expo/config-plugins": "~9.0.
|
|
46
|
+
"@expo/config-plugins": "~9.0.10",
|
|
47
47
|
"@expo/devcert": "^1.1.2",
|
|
48
48
|
"@expo/env": "~0.4.0",
|
|
49
49
|
"@expo/image-utils": "^0.6.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@expo/osascript": "^2.0.31",
|
|
53
53
|
"@expo/package-manager": "^1.5.0",
|
|
54
54
|
"@expo/plist": "^0.2.0",
|
|
55
|
-
"@expo/prebuild-config": "^8.0.
|
|
55
|
+
"@expo/prebuild-config": "^8.0.17",
|
|
56
56
|
"@expo/rudder-sdk-node": "^1.1.1",
|
|
57
57
|
"@expo/spawn-async": "^1.7.2",
|
|
58
58
|
"@expo/xcpretty": "^4.3.0",
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"tree-kill": "^1.2.2",
|
|
168
168
|
"tsd": "^0.28.1"
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "8b7a5da5dc407c5242f4c512e892c2ca3506a096"
|
|
171
171
|
}
|