@expo/cli 0.19.13 → 0.20.0
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 +0 -1
- package/build/src/api/graphql/client.js.map +1 -1
- package/build/src/api/graphql/queries/AppQuery.js +6 -17
- package/build/src/api/graphql/queries/AppQuery.js.map +1 -1
- package/build/src/api/graphql/queries/UserQuery.js +4 -9
- package/build/src/api/graphql/queries/UserQuery.js.map +1 -1
- package/build/src/api/graphql/types/App.js +4 -9
- package/build/src/api/graphql/types/App.js.map +1 -1
- package/build/src/api/user/user.js +7 -12
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/export/createMetadataJson.js +14 -10
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +38 -95
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +3 -3
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +32 -1
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportDomComponents.js +156 -0
- package/build/src/export/exportDomComponents.js.map +1 -0
- package/build/src/export/exportHermes.js +49 -1
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/install/installExpoPackage.js +15 -15
- package/build/src/install/installExpoPackage.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +2 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +21 -5
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +2 -2
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +20 -5
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +3 -1
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
- package/build/src/utils/codesigning.js +8 -8
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/exit.js +59 -2
- package/build/src/utils/exit.js.map +1 -1
- package/build/src/utils/filePath.js +28 -0
- package/build/src/utils/filePath.js.map +1 -0
- package/build/src/utils/ip.js +89 -1
- package/build/src/utils/ip.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/clients/RudderDetachedClient.js +13 -13
- package/build/src/utils/telemetry/clients/RudderDetachedClient.js.map +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +5 -6
- package/build/src/export/embed/guessHermes.js +0 -69
- package/build/src/export/embed/guessHermes.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/codesigning.ts"],"sourcesContent":["import {\n convertCertificatePEMToCertificate,\n convertKeyPairToPEM,\n convertCSRToCSRPEM,\n generateKeyPair,\n generateCSR,\n convertPrivateKeyPEMToPrivateKey,\n validateSelfSignedCertificate,\n signBufferRSASHA256AndVerify,\n} from '@expo/code-signing-certificates';\nimport { ExpoConfig } from '@expo/config';\nimport { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport JsonFile, { JSONObject } from '@expo/json-file';\nimport { CombinedError } from '@urql/core';\nimport { promises as fs } from 'fs';\nimport { GraphQLError } from 'graphql';\nimport { pki as PKI } from 'node-forge';\nimport path from 'path';\nimport { Dictionary, parseDictionary } from 'structured-headers';\n\nimport { env } from './env';\nimport { CommandError } from './errors';\nimport { getExpoGoIntermediateCertificateAsync } from '../api/getExpoGoIntermediateCertificate';\nimport { getProjectDevelopmentCertificateAsync } from '../api/getProjectDevelopmentCertificate';\nimport { AppQuery } from '../api/graphql/queries/AppQuery';\nimport { ensureLoggedInAsync } from '../api/user/actions';\nimport { Actor } from '../api/user/user';\nimport { AppByIdQuery, Permission } from '../graphql/generated';\nimport * as Log from '../log';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:codesigning') as typeof console.log;\n\nexport type CodeSigningInfo = {\n keyId: string;\n privateKey: string;\n certificateForPrivateKey: string;\n /**\n * Chain of certificates to serve in the manifest multipart body \"certificate_chain\" part.\n * The leaf certificate must be the 0th element of the array, followed by any intermediate certificates\n * necessary to evaluate the chain of trust ending in the implicitly trusted root certificate embedded in\n * the client.\n *\n * An empty array indicates that there is no need to serve the certificate chain in the multipart response.\n */\n certificateChainForResponse: string[];\n /**\n * Scope key cached for the project when certificate is development Expo Go code signing.\n * For project-specific code signing (keyId == the project's generated keyId) this is undefined.\n */\n scopeKey: string | null;\n};\n\ntype StoredDevelopmentExpoRootCodeSigningInfo = {\n easProjectId: string | null;\n scopeKey: string | null;\n privateKey: string | null;\n certificateChain: string[] | null;\n};\nconst DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME = 'development-code-signing-settings-2.json';\n\nexport function getDevelopmentCodeSigningDirectory(): string {\n return path.join(getExpoHomeDirectory(), 'codesigning');\n}\n\nfunction getProjectDevelopmentCodeSigningInfoFile<T extends JSONObject>(defaults: T) {\n function getFile(easProjectId: string): JsonFile<T> {\n const filePath = path.join(\n getDevelopmentCodeSigningDirectory(),\n easProjectId,\n DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME\n );\n return new JsonFile<T>(filePath);\n }\n\n async function readAsync(easProjectId: string): Promise<T> {\n let projectSettings;\n try {\n projectSettings = await getFile(easProjectId).readAsync();\n } catch {\n projectSettings = await getFile(easProjectId).writeAsync(defaults, { ensureDir: true });\n }\n // Set defaults for any missing fields\n return { ...defaults, ...projectSettings };\n }\n\n async function setAsync(easProjectId: string, json: Partial<T>): Promise<T> {\n try {\n return await getFile(easProjectId).mergeAsync(json, {\n cantReadFileDefault: defaults,\n });\n } catch {\n return await getFile(easProjectId).writeAsync(\n {\n ...defaults,\n ...json,\n },\n { ensureDir: true }\n );\n }\n }\n\n return {\n getFile,\n readAsync,\n setAsync,\n };\n}\n\nexport const DevelopmentCodeSigningInfoFile =\n getProjectDevelopmentCodeSigningInfoFile<StoredDevelopmentExpoRootCodeSigningInfo>({\n easProjectId: null,\n scopeKey: null,\n privateKey: null,\n certificateChain: null,\n });\n\n/**\n * Get info necessary to generate a response `expo-signature` header given a project and incoming request `expo-expect-signature` header.\n * This only knows how to serve two code signing keyids:\n * - `expo-root` indicates that it should use a development certificate in the `expo-root` chain. See {@link getExpoRootDevelopmentCodeSigningInfoAsync}\n * - <developer's expo-updates keyid> indicates that it should sign with the configured certificate. See {@link getProjectCodeSigningCertificateAsync}\n */\nexport async function getCodeSigningInfoAsync(\n exp: ExpoConfig,\n expectSignatureHeader: string | null,\n privateKeyPath: string | undefined\n): Promise<CodeSigningInfo | null> {\n if (!expectSignatureHeader) {\n return null;\n }\n\n let parsedExpectSignature: Dictionary;\n try {\n parsedExpectSignature = parseDictionary(expectSignatureHeader);\n } catch {\n throw new CommandError('Invalid value for expo-expect-signature header');\n }\n\n const expectedKeyIdOuter = parsedExpectSignature.get('keyid');\n if (!expectedKeyIdOuter) {\n throw new CommandError('keyid not present in expo-expect-signature header');\n }\n\n const expectedKeyId = expectedKeyIdOuter[0];\n if (typeof expectedKeyId !== 'string') {\n throw new CommandError(\n `Invalid value for keyid in expo-expect-signature header: ${expectedKeyId}`\n );\n }\n\n let expectedAlg: string | null = null;\n const expectedAlgOuter = parsedExpectSignature.get('alg');\n if (expectedAlgOuter) {\n const expectedAlgTemp = expectedAlgOuter[0];\n if (typeof expectedAlgTemp !== 'string') {\n throw new CommandError('Invalid value for alg in expo-expect-signature header');\n }\n expectedAlg = expectedAlgTemp;\n }\n\n if (expectedKeyId === 'expo-root') {\n return await getExpoRootDevelopmentCodeSigningInfoAsync(exp);\n } else if (expectedKeyId === 'expo-go') {\n throw new CommandError(\n 'Invalid certificate requested: cannot sign with embedded keyid=expo-go key'\n );\n } else {\n return await getProjectCodeSigningCertificateAsync(\n exp,\n privateKeyPath,\n expectedKeyId,\n expectedAlg\n );\n }\n}\n\n/**\n * Get a development code signing certificate for the expo-root -> expo-go -> (development certificate) certificate chain.\n * This requires the user be logged in and online, otherwise try to use the cached development certificate.\n */\nasync function getExpoRootDevelopmentCodeSigningInfoAsync(\n exp: ExpoConfig\n): Promise<CodeSigningInfo | null> {\n const easProjectId = exp.extra?.eas?.projectId;\n // can't check for scope key validity since scope key is derived on the server from projectId and we may be offline.\n // we rely upon the client certificate check to validate the scope key\n if (!easProjectId) {\n debug(\n `WARN: Expo Application Services (EAS) is not configured for your project. Configuring EAS enables a more secure development experience amongst many other benefits. ${learnMore(\n 'https://docs.expo.dev/eas/'\n )}`\n );\n return null;\n }\n\n const developmentCodeSigningInfoFromFile =\n await DevelopmentCodeSigningInfoFile.readAsync(easProjectId);\n const validatedCodeSigningInfo = validateStoredDevelopmentExpoRootCertificateCodeSigningInfo(\n developmentCodeSigningInfoFromFile,\n easProjectId\n );\n\n // 1. If online, ensure logged in, generate key pair and CSR, fetch and cache certificate chain for projectId\n // (overwriting existing dev cert in case projectId changed or it has expired)\n if (!env.EXPO_OFFLINE) {\n try {\n return await fetchAndCacheNewDevelopmentCodeSigningInfoAsync(easProjectId);\n } catch (e: any) {\n if (validatedCodeSigningInfo) {\n Log.warn(\n 'There was an error fetching the Expo development certificate, falling back to cached certificate'\n );\n return validatedCodeSigningInfo;\n } else {\n // need to return null here and say a message\n throw e;\n }\n }\n }\n\n // 2. check for cached cert/private key matching projectId and scopeKey of project, if found and valid return private key and cert chain including expo-go cert\n if (validatedCodeSigningInfo) {\n return validatedCodeSigningInfo;\n }\n\n // 3. if offline, return null\n Log.warn('Offline and no cached development certificate found, unable to sign manifest');\n return null;\n}\n\n/**\n * Get the certificate configured for expo-updates for this project.\n */\nasync function getProjectCodeSigningCertificateAsync(\n exp: ExpoConfig,\n privateKeyPath: string | undefined,\n expectedKeyId: string,\n expectedAlg: string | null\n): Promise<CodeSigningInfo | null> {\n const codeSigningCertificatePath = exp.updates?.codeSigningCertificate;\n if (!codeSigningCertificatePath) {\n return null;\n }\n\n if (!privateKeyPath) {\n throw new CommandError(\n 'Must specify --private-key-path argument to sign development manifest for requested code signing key'\n );\n }\n\n const codeSigningMetadata = exp.updates?.codeSigningMetadata;\n if (!codeSigningMetadata) {\n throw new CommandError(\n 'Must specify \"codeSigningMetadata\" under the \"updates\" field of your app config file to use EAS code signing'\n );\n }\n\n const { alg, keyid } = codeSigningMetadata;\n if (!alg || !keyid) {\n throw new CommandError(\n 'Must specify \"keyid\" and \"alg\" in the \"codeSigningMetadata\" field under the \"updates\" field of your app config file to use EAS code signing'\n );\n }\n\n if (expectedKeyId !== keyid) {\n throw new CommandError(`keyid mismatch: client=${expectedKeyId}, project=${keyid}`);\n }\n\n if (expectedAlg && expectedAlg !== alg) {\n throw new CommandError(`\"alg\" field mismatch (client=${expectedAlg}, project=${alg})`);\n }\n\n const { privateKeyPEM, certificatePEM } =\n await getProjectPrivateKeyAndCertificateFromFilePathsAsync({\n codeSigningCertificatePath,\n privateKeyPath,\n });\n\n return {\n keyId: keyid,\n privateKey: privateKeyPEM,\n certificateForPrivateKey: certificatePEM,\n certificateChainForResponse: [],\n scopeKey: null,\n };\n}\n\nasync function readFileWithErrorAsync(path: string, errorMessage: string): Promise<string> {\n try {\n return await fs.readFile(path, 'utf8');\n } catch {\n throw new CommandError(errorMessage);\n }\n}\n\nasync function getProjectPrivateKeyAndCertificateFromFilePathsAsync({\n codeSigningCertificatePath,\n privateKeyPath,\n}: {\n codeSigningCertificatePath: string;\n privateKeyPath: string;\n}): Promise<{ privateKeyPEM: string; certificatePEM: string }> {\n const [codeSigningCertificatePEM, privateKeyPEM] = await Promise.all([\n readFileWithErrorAsync(\n codeSigningCertificatePath,\n `Code signing certificate cannot be read from path: ${codeSigningCertificatePath}`\n ),\n readFileWithErrorAsync(\n privateKeyPath,\n `Code signing private key cannot be read from path: ${privateKeyPath}`\n ),\n ]);\n\n const privateKey = convertPrivateKeyPEMToPrivateKey(privateKeyPEM);\n const certificate = convertCertificatePEMToCertificate(codeSigningCertificatePEM);\n validateSelfSignedCertificate(certificate, {\n publicKey: certificate.publicKey as PKI.rsa.PublicKey,\n privateKey,\n });\n\n return { privateKeyPEM, certificatePEM: codeSigningCertificatePEM };\n}\n\n/**\n * Validate that the cached code signing info is still valid for the current project and\n * that it hasn't expired. If invalid, return null.\n */\nfunction validateStoredDevelopmentExpoRootCertificateCodeSigningInfo(\n codeSigningInfo: StoredDevelopmentExpoRootCodeSigningInfo,\n easProjectId: string\n): CodeSigningInfo | null {\n if (codeSigningInfo.easProjectId !== easProjectId) {\n return null;\n }\n\n const {\n privateKey: privateKeyPEM,\n certificateChain: certificatePEMs,\n scopeKey,\n } = codeSigningInfo;\n if (!privateKeyPEM || !certificatePEMs) {\n return null;\n }\n\n const certificateChain = certificatePEMs.map((certificatePEM) =>\n convertCertificatePEMToCertificate(certificatePEM)\n );\n\n // TODO(wschurman): maybe move to @expo/code-signing-certificates\n\n // ensure all intermediate certificates are valid\n for (const certificate of certificateChain) {\n const now = new Date();\n if (certificate.validity.notBefore > now || certificate.validity.notAfter < now) {\n return null;\n }\n }\n\n // TODO(wschurman): maybe do more validation, like validation of projectID and scopeKey within eas certificate extension\n\n return {\n keyId: 'expo-go',\n certificateChainForResponse: certificatePEMs,\n certificateForPrivateKey: certificatePEMs[0],\n privateKey: privateKeyPEM,\n scopeKey,\n };\n}\n\nfunction actorCanGetProjectDevelopmentCertificate(actor: Actor, app: AppByIdQuery['app']['byId']) {\n const owningAccountId = app.ownerAccount.id;\n\n const owningAccountIsActorPrimaryAccount =\n actor.__typename === 'User' || actor.__typename === 'SSOUser'\n ? actor.primaryAccount.id === owningAccountId\n : false;\n const userHasPublishPermissionForOwningAccount = !!actor.accounts\n .find((account) => account.id === owningAccountId)\n ?.users?.find((userPermission) => userPermission.actor.id === actor.id)\n ?.permissions?.includes(Permission.Publish);\n return owningAccountIsActorPrimaryAccount || userHasPublishPermissionForOwningAccount;\n}\n\nasync function fetchAndCacheNewDevelopmentCodeSigningInfoAsync(\n easProjectId: string\n): Promise<CodeSigningInfo | null> {\n const actor = await ensureLoggedInAsync();\n let app: AppByIdQuery['app']['byId'];\n try {\n app = await AppQuery.byIdAsync(easProjectId);\n } catch (e) {\n if (e instanceof GraphQLError || e instanceof CombinedError) {\n return null;\n }\n throw e;\n }\n if (!actorCanGetProjectDevelopmentCertificate(actor, app)) {\n return null;\n }\n\n const keyPair = generateKeyPair();\n const keyPairPEM = convertKeyPairToPEM(keyPair);\n const csr = generateCSR(keyPair, `Development Certificate for ${easProjectId}`);\n const csrPEM = convertCSRToCSRPEM(csr);\n const [developmentSigningCertificate, expoGoIntermediateCertificate] = await Promise.all([\n getProjectDevelopmentCertificateAsync(easProjectId, csrPEM),\n getExpoGoIntermediateCertificateAsync(easProjectId),\n ]);\n\n await DevelopmentCodeSigningInfoFile.setAsync(easProjectId, {\n easProjectId,\n scopeKey: app.scopeKey,\n privateKey: keyPairPEM.privateKeyPEM,\n certificateChain: [developmentSigningCertificate, expoGoIntermediateCertificate],\n });\n\n return {\n keyId: 'expo-go',\n certificateChainForResponse: [developmentSigningCertificate, expoGoIntermediateCertificate],\n certificateForPrivateKey: developmentSigningCertificate,\n privateKey: keyPairPEM.privateKeyPEM,\n scopeKey: app.scopeKey,\n };\n}\n/**\n * Generate the `expo-signature` header for a manifest and code signing info.\n */\nexport function signManifestString(\n stringifiedManifest: string,\n codeSigningInfo: CodeSigningInfo\n): string {\n const privateKey = convertPrivateKeyPEMToPrivateKey(codeSigningInfo.privateKey);\n const certificate = convertCertificatePEMToCertificate(codeSigningInfo.certificateForPrivateKey);\n return signBufferRSASHA256AndVerify(\n privateKey,\n certificate,\n Buffer.from(stringifiedManifest, 'utf8')\n );\n}\n"],"names":["getDevelopmentCodeSigningDirectory","DevelopmentCodeSigningInfoFile","getCodeSigningInfoAsync","signManifestString","debug","require","DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME","path","join","getExpoHomeDirectory","getProjectDevelopmentCodeSigningInfoFile","defaults","getFile","easProjectId","filePath","JsonFile","readAsync","projectSettings","writeAsync","ensureDir","setAsync","json","mergeAsync","cantReadFileDefault","scopeKey","privateKey","certificateChain","exp","expectSignatureHeader","privateKeyPath","parsedExpectSignature","parseDictionary","CommandError","expectedKeyIdOuter","get","expectedKeyId","expectedAlg","expectedAlgOuter","expectedAlgTemp","getExpoRootDevelopmentCodeSigningInfoAsync","getProjectCodeSigningCertificateAsync","extra","eas","projectId","learnMore","developmentCodeSigningInfoFromFile","validatedCodeSigningInfo","validateStoredDevelopmentExpoRootCertificateCodeSigningInfo","env","EXPO_OFFLINE","fetchAndCacheNewDevelopmentCodeSigningInfoAsync","e","Log","warn","codeSigningCertificatePath","updates","codeSigningCertificate","codeSigningMetadata","alg","keyid","privateKeyPEM","certificatePEM","getProjectPrivateKeyAndCertificateFromFilePathsAsync","keyId","certificateForPrivateKey","certificateChainForResponse","readFileWithErrorAsync","errorMessage","fs","readFile","codeSigningCertificatePEM","Promise","all","convertPrivateKeyPEMToPrivateKey","certificate","convertCertificatePEMToCertificate","validateSelfSignedCertificate","publicKey","codeSigningInfo","certificatePEMs","map","now","Date","validity","notBefore","notAfter","actorCanGetProjectDevelopmentCertificate","actor","app","owningAccountId","ownerAccount","id","owningAccountIsActorPrimaryAccount","__typename","primaryAccount","userHasPublishPermissionForOwningAccount","accounts","find","account","users","userPermission","permissions","includes","Permission","Publish","ensureLoggedInAsync","AppQuery","byIdAsync","GraphQLError","CombinedError","keyPair","generateKeyPair","keyPairPEM","convertKeyPairToPEM","csr","generateCSR","csrPEM","convertCSRToCSRPEM","developmentSigningCertificate","expoGoIntermediateCertificate","getProjectDevelopmentCertificateAsync","getExpoGoIntermediateCertificateAsync","stringifiedManifest","signBufferRSASHA256AndVerify","Buffer","from"],"mappings":"AAAA;;;;;;;;;;;IA6DgBA,kCAAkC,MAAlCA,kC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A,EAACH,GAAG,CAAC,AAAC;IACvC,MAAM,CAACI,6BAA6B,EAAEC,6BAA6B,CAAC,GAAG,MAAMhD,OAAO,CAACC,GAAG,CAAC;QACvFgD,IAAAA,iCAAqC,sCAAA,EAAC3G,YAAY,EAAEuG,MAAM,CAAC;QAC3DK,IAAAA,iCAAqC,sCAAA,EAAC5G,YAAY,CAAC;KACpD,CAAC,AAAC;IAEH,MAAMZ,8BAA8B,CAACmB,QAAQ,CAACP,YAAY,EAAE;QAC1DA,YAAY;QACZW,QAAQ,EAAEgE,GAAG,CAAChE,QAAQ;QACtBC,UAAU,EAAEuF,UAAU,CAACpD,aAAa;QACpClC,gBAAgB,EAAE;YAAC4F,6BAA6B;YAAEC,6BAA6B;SAAC;KACjF,CAAC,CAAC;IAEH,OAAO;QACLxD,KAAK,EAAE,SAAS;QAChBE,2BAA2B,EAAE;YAACqD,6BAA6B;YAAEC,6BAA6B;SAAC;QAC3FvD,wBAAwB,EAAEsD,6BAA6B;QACvD7F,UAAU,EAAEuF,UAAU,CAACpD,aAAa;QACpCpC,QAAQ,EAAEgE,GAAG,CAAChE,QAAQ;KACvB,CAAC;AACJ,CAAC;AAIM,SAASrB,kBAAkB,CAChCuH,mBAA2B,EAC3B5C,eAAgC,EACxB;IACR,MAAMrD,UAAU,GAAGgD,IAAAA,wBAAgC,EAAA,iCAAA,EAACK,eAAe,CAACrD,UAAU,CAAC,AAAC;IAChF,MAAMiD,WAAW,GAAGC,IAAAA,wBAAkC,EAAA,mCAAA,EAACG,eAAe,CAACd,wBAAwB,CAAC,AAAC;IACjG,OAAO2D,IAAAA,wBAA4B,EAAA,6BAAA,EACjClG,UAAU,EACViD,WAAW,EACXkD,MAAM,CAACC,IAAI,CAACH,mBAAmB,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/codesigning.ts"],"sourcesContent":["import { GraphQLError } from '@0no-co/graphql.web';\nimport {\n convertCertificatePEMToCertificate,\n convertKeyPairToPEM,\n convertCSRToCSRPEM,\n generateKeyPair,\n generateCSR,\n convertPrivateKeyPEMToPrivateKey,\n validateSelfSignedCertificate,\n signBufferRSASHA256AndVerify,\n} from '@expo/code-signing-certificates';\nimport { ExpoConfig } from '@expo/config';\nimport { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport JsonFile, { JSONObject } from '@expo/json-file';\nimport { CombinedError } from '@urql/core';\nimport { promises as fs } from 'fs';\nimport { pki as PKI } from 'node-forge';\nimport path from 'path';\nimport { Dictionary, parseDictionary } from 'structured-headers';\n\nimport { env } from './env';\nimport { CommandError } from './errors';\nimport { getExpoGoIntermediateCertificateAsync } from '../api/getExpoGoIntermediateCertificate';\nimport { getProjectDevelopmentCertificateAsync } from '../api/getProjectDevelopmentCertificate';\nimport { AppQuery } from '../api/graphql/queries/AppQuery';\nimport { ensureLoggedInAsync } from '../api/user/actions';\nimport { Actor } from '../api/user/user';\nimport { AppByIdQuery, Permission } from '../graphql/generated';\nimport * as Log from '../log';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:codesigning') as typeof console.log;\n\nexport type CodeSigningInfo = {\n keyId: string;\n privateKey: string;\n certificateForPrivateKey: string;\n /**\n * Chain of certificates to serve in the manifest multipart body \"certificate_chain\" part.\n * The leaf certificate must be the 0th element of the array, followed by any intermediate certificates\n * necessary to evaluate the chain of trust ending in the implicitly trusted root certificate embedded in\n * the client.\n *\n * An empty array indicates that there is no need to serve the certificate chain in the multipart response.\n */\n certificateChainForResponse: string[];\n /**\n * Scope key cached for the project when certificate is development Expo Go code signing.\n * For project-specific code signing (keyId == the project's generated keyId) this is undefined.\n */\n scopeKey: string | null;\n};\n\ntype StoredDevelopmentExpoRootCodeSigningInfo = {\n easProjectId: string | null;\n scopeKey: string | null;\n privateKey: string | null;\n certificateChain: string[] | null;\n};\nconst DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME = 'development-code-signing-settings-2.json';\n\nexport function getDevelopmentCodeSigningDirectory(): string {\n return path.join(getExpoHomeDirectory(), 'codesigning');\n}\n\nfunction getProjectDevelopmentCodeSigningInfoFile<T extends JSONObject>(defaults: T) {\n function getFile(easProjectId: string): JsonFile<T> {\n const filePath = path.join(\n getDevelopmentCodeSigningDirectory(),\n easProjectId,\n DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME\n );\n return new JsonFile<T>(filePath);\n }\n\n async function readAsync(easProjectId: string): Promise<T> {\n let projectSettings;\n try {\n projectSettings = await getFile(easProjectId).readAsync();\n } catch {\n projectSettings = await getFile(easProjectId).writeAsync(defaults, { ensureDir: true });\n }\n // Set defaults for any missing fields\n return { ...defaults, ...projectSettings };\n }\n\n async function setAsync(easProjectId: string, json: Partial<T>): Promise<T> {\n try {\n return await getFile(easProjectId).mergeAsync(json, {\n cantReadFileDefault: defaults,\n });\n } catch {\n return await getFile(easProjectId).writeAsync(\n {\n ...defaults,\n ...json,\n },\n { ensureDir: true }\n );\n }\n }\n\n return {\n getFile,\n readAsync,\n setAsync,\n };\n}\n\nexport const DevelopmentCodeSigningInfoFile =\n getProjectDevelopmentCodeSigningInfoFile<StoredDevelopmentExpoRootCodeSigningInfo>({\n easProjectId: null,\n scopeKey: null,\n privateKey: null,\n certificateChain: null,\n });\n\n/**\n * Get info necessary to generate a response `expo-signature` header given a project and incoming request `expo-expect-signature` header.\n * This only knows how to serve two code signing keyids:\n * - `expo-root` indicates that it should use a development certificate in the `expo-root` chain. See {@link getExpoRootDevelopmentCodeSigningInfoAsync}\n * - <developer's expo-updates keyid> indicates that it should sign with the configured certificate. See {@link getProjectCodeSigningCertificateAsync}\n */\nexport async function getCodeSigningInfoAsync(\n exp: ExpoConfig,\n expectSignatureHeader: string | null,\n privateKeyPath: string | undefined\n): Promise<CodeSigningInfo | null> {\n if (!expectSignatureHeader) {\n return null;\n }\n\n let parsedExpectSignature: Dictionary;\n try {\n parsedExpectSignature = parseDictionary(expectSignatureHeader);\n } catch {\n throw new CommandError('Invalid value for expo-expect-signature header');\n }\n\n const expectedKeyIdOuter = parsedExpectSignature.get('keyid');\n if (!expectedKeyIdOuter) {\n throw new CommandError('keyid not present in expo-expect-signature header');\n }\n\n const expectedKeyId = expectedKeyIdOuter[0];\n if (typeof expectedKeyId !== 'string') {\n throw new CommandError(\n `Invalid value for keyid in expo-expect-signature header: ${expectedKeyId}`\n );\n }\n\n let expectedAlg: string | null = null;\n const expectedAlgOuter = parsedExpectSignature.get('alg');\n if (expectedAlgOuter) {\n const expectedAlgTemp = expectedAlgOuter[0];\n if (typeof expectedAlgTemp !== 'string') {\n throw new CommandError('Invalid value for alg in expo-expect-signature header');\n }\n expectedAlg = expectedAlgTemp;\n }\n\n if (expectedKeyId === 'expo-root') {\n return await getExpoRootDevelopmentCodeSigningInfoAsync(exp);\n } else if (expectedKeyId === 'expo-go') {\n throw new CommandError(\n 'Invalid certificate requested: cannot sign with embedded keyid=expo-go key'\n );\n } else {\n return await getProjectCodeSigningCertificateAsync(\n exp,\n privateKeyPath,\n expectedKeyId,\n expectedAlg\n );\n }\n}\n\n/**\n * Get a development code signing certificate for the expo-root -> expo-go -> (development certificate) certificate chain.\n * This requires the user be logged in and online, otherwise try to use the cached development certificate.\n */\nasync function getExpoRootDevelopmentCodeSigningInfoAsync(\n exp: ExpoConfig\n): Promise<CodeSigningInfo | null> {\n const easProjectId = exp.extra?.eas?.projectId;\n // can't check for scope key validity since scope key is derived on the server from projectId and we may be offline.\n // we rely upon the client certificate check to validate the scope key\n if (!easProjectId) {\n debug(\n `WARN: Expo Application Services (EAS) is not configured for your project. Configuring EAS enables a more secure development experience amongst many other benefits. ${learnMore(\n 'https://docs.expo.dev/eas/'\n )}`\n );\n return null;\n }\n\n const developmentCodeSigningInfoFromFile =\n await DevelopmentCodeSigningInfoFile.readAsync(easProjectId);\n const validatedCodeSigningInfo = validateStoredDevelopmentExpoRootCertificateCodeSigningInfo(\n developmentCodeSigningInfoFromFile,\n easProjectId\n );\n\n // 1. If online, ensure logged in, generate key pair and CSR, fetch and cache certificate chain for projectId\n // (overwriting existing dev cert in case projectId changed or it has expired)\n if (!env.EXPO_OFFLINE) {\n try {\n return await fetchAndCacheNewDevelopmentCodeSigningInfoAsync(easProjectId);\n } catch (e: any) {\n if (validatedCodeSigningInfo) {\n Log.warn(\n 'There was an error fetching the Expo development certificate, falling back to cached certificate'\n );\n return validatedCodeSigningInfo;\n } else {\n // need to return null here and say a message\n throw e;\n }\n }\n }\n\n // 2. check for cached cert/private key matching projectId and scopeKey of project, if found and valid return private key and cert chain including expo-go cert\n if (validatedCodeSigningInfo) {\n return validatedCodeSigningInfo;\n }\n\n // 3. if offline, return null\n Log.warn('Offline and no cached development certificate found, unable to sign manifest');\n return null;\n}\n\n/**\n * Get the certificate configured for expo-updates for this project.\n */\nasync function getProjectCodeSigningCertificateAsync(\n exp: ExpoConfig,\n privateKeyPath: string | undefined,\n expectedKeyId: string,\n expectedAlg: string | null\n): Promise<CodeSigningInfo | null> {\n const codeSigningCertificatePath = exp.updates?.codeSigningCertificate;\n if (!codeSigningCertificatePath) {\n return null;\n }\n\n if (!privateKeyPath) {\n throw new CommandError(\n 'Must specify --private-key-path argument to sign development manifest for requested code signing key'\n );\n }\n\n const codeSigningMetadata = exp.updates?.codeSigningMetadata;\n if (!codeSigningMetadata) {\n throw new CommandError(\n 'Must specify \"codeSigningMetadata\" under the \"updates\" field of your app config file to use EAS code signing'\n );\n }\n\n const { alg, keyid } = codeSigningMetadata;\n if (!alg || !keyid) {\n throw new CommandError(\n 'Must specify \"keyid\" and \"alg\" in the \"codeSigningMetadata\" field under the \"updates\" field of your app config file to use EAS code signing'\n );\n }\n\n if (expectedKeyId !== keyid) {\n throw new CommandError(`keyid mismatch: client=${expectedKeyId}, project=${keyid}`);\n }\n\n if (expectedAlg && expectedAlg !== alg) {\n throw new CommandError(`\"alg\" field mismatch (client=${expectedAlg}, project=${alg})`);\n }\n\n const { privateKeyPEM, certificatePEM } =\n await getProjectPrivateKeyAndCertificateFromFilePathsAsync({\n codeSigningCertificatePath,\n privateKeyPath,\n });\n\n return {\n keyId: keyid,\n privateKey: privateKeyPEM,\n certificateForPrivateKey: certificatePEM,\n certificateChainForResponse: [],\n scopeKey: null,\n };\n}\n\nasync function readFileWithErrorAsync(path: string, errorMessage: string): Promise<string> {\n try {\n return await fs.readFile(path, 'utf8');\n } catch {\n throw new CommandError(errorMessage);\n }\n}\n\nasync function getProjectPrivateKeyAndCertificateFromFilePathsAsync({\n codeSigningCertificatePath,\n privateKeyPath,\n}: {\n codeSigningCertificatePath: string;\n privateKeyPath: string;\n}): Promise<{ privateKeyPEM: string; certificatePEM: string }> {\n const [codeSigningCertificatePEM, privateKeyPEM] = await Promise.all([\n readFileWithErrorAsync(\n codeSigningCertificatePath,\n `Code signing certificate cannot be read from path: ${codeSigningCertificatePath}`\n ),\n readFileWithErrorAsync(\n privateKeyPath,\n `Code signing private key cannot be read from path: ${privateKeyPath}`\n ),\n ]);\n\n const privateKey = convertPrivateKeyPEMToPrivateKey(privateKeyPEM);\n const certificate = convertCertificatePEMToCertificate(codeSigningCertificatePEM);\n validateSelfSignedCertificate(certificate, {\n publicKey: certificate.publicKey as PKI.rsa.PublicKey,\n privateKey,\n });\n\n return { privateKeyPEM, certificatePEM: codeSigningCertificatePEM };\n}\n\n/**\n * Validate that the cached code signing info is still valid for the current project and\n * that it hasn't expired. If invalid, return null.\n */\nfunction validateStoredDevelopmentExpoRootCertificateCodeSigningInfo(\n codeSigningInfo: StoredDevelopmentExpoRootCodeSigningInfo,\n easProjectId: string\n): CodeSigningInfo | null {\n if (codeSigningInfo.easProjectId !== easProjectId) {\n return null;\n }\n\n const {\n privateKey: privateKeyPEM,\n certificateChain: certificatePEMs,\n scopeKey,\n } = codeSigningInfo;\n if (!privateKeyPEM || !certificatePEMs) {\n return null;\n }\n\n const certificateChain = certificatePEMs.map((certificatePEM) =>\n convertCertificatePEMToCertificate(certificatePEM)\n );\n\n // TODO(wschurman): maybe move to @expo/code-signing-certificates\n\n // ensure all intermediate certificates are valid\n for (const certificate of certificateChain) {\n const now = new Date();\n if (certificate.validity.notBefore > now || certificate.validity.notAfter < now) {\n return null;\n }\n }\n\n // TODO(wschurman): maybe do more validation, like validation of projectID and scopeKey within eas certificate extension\n\n return {\n keyId: 'expo-go',\n certificateChainForResponse: certificatePEMs,\n certificateForPrivateKey: certificatePEMs[0],\n privateKey: privateKeyPEM,\n scopeKey,\n };\n}\n\nfunction actorCanGetProjectDevelopmentCertificate(actor: Actor, app: AppByIdQuery['app']['byId']) {\n const owningAccountId = app.ownerAccount.id;\n\n const owningAccountIsActorPrimaryAccount =\n actor.__typename === 'User' || actor.__typename === 'SSOUser'\n ? actor.primaryAccount.id === owningAccountId\n : false;\n const userHasPublishPermissionForOwningAccount = !!actor.accounts\n .find((account) => account.id === owningAccountId)\n ?.users?.find((userPermission) => userPermission.actor.id === actor.id)\n ?.permissions?.includes(Permission.Publish);\n return owningAccountIsActorPrimaryAccount || userHasPublishPermissionForOwningAccount;\n}\n\nasync function fetchAndCacheNewDevelopmentCodeSigningInfoAsync(\n easProjectId: string\n): Promise<CodeSigningInfo | null> {\n const actor = await ensureLoggedInAsync();\n let app: AppByIdQuery['app']['byId'];\n try {\n app = await AppQuery.byIdAsync(easProjectId);\n } catch (e) {\n if (e instanceof GraphQLError || e instanceof CombinedError) {\n return null;\n }\n throw e;\n }\n if (!actorCanGetProjectDevelopmentCertificate(actor, app)) {\n return null;\n }\n\n const keyPair = generateKeyPair();\n const keyPairPEM = convertKeyPairToPEM(keyPair);\n const csr = generateCSR(keyPair, `Development Certificate for ${easProjectId}`);\n const csrPEM = convertCSRToCSRPEM(csr);\n const [developmentSigningCertificate, expoGoIntermediateCertificate] = await Promise.all([\n getProjectDevelopmentCertificateAsync(easProjectId, csrPEM),\n getExpoGoIntermediateCertificateAsync(easProjectId),\n ]);\n\n await DevelopmentCodeSigningInfoFile.setAsync(easProjectId, {\n easProjectId,\n scopeKey: app.scopeKey,\n privateKey: keyPairPEM.privateKeyPEM,\n certificateChain: [developmentSigningCertificate, expoGoIntermediateCertificate],\n });\n\n return {\n keyId: 'expo-go',\n certificateChainForResponse: [developmentSigningCertificate, expoGoIntermediateCertificate],\n certificateForPrivateKey: developmentSigningCertificate,\n privateKey: keyPairPEM.privateKeyPEM,\n scopeKey: app.scopeKey,\n };\n}\n/**\n * Generate the `expo-signature` header for a manifest and code signing info.\n */\nexport function signManifestString(\n stringifiedManifest: string,\n codeSigningInfo: CodeSigningInfo\n): string {\n const privateKey = convertPrivateKeyPEMToPrivateKey(codeSigningInfo.privateKey);\n const certificate = convertCertificatePEMToCertificate(codeSigningInfo.certificateForPrivateKey);\n return signBufferRSASHA256AndVerify(\n privateKey,\n certificate,\n Buffer.from(stringifiedManifest, 'utf8')\n );\n}\n"],"names":["getDevelopmentCodeSigningDirectory","DevelopmentCodeSigningInfoFile","getCodeSigningInfoAsync","signManifestString","debug","require","DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME","path","join","getExpoHomeDirectory","getProjectDevelopmentCodeSigningInfoFile","defaults","getFile","easProjectId","filePath","JsonFile","readAsync","projectSettings","writeAsync","ensureDir","setAsync","json","mergeAsync","cantReadFileDefault","scopeKey","privateKey","certificateChain","exp","expectSignatureHeader","privateKeyPath","parsedExpectSignature","parseDictionary","CommandError","expectedKeyIdOuter","get","expectedKeyId","expectedAlg","expectedAlgOuter","expectedAlgTemp","getExpoRootDevelopmentCodeSigningInfoAsync","getProjectCodeSigningCertificateAsync","extra","eas","projectId","learnMore","developmentCodeSigningInfoFromFile","validatedCodeSigningInfo","validateStoredDevelopmentExpoRootCertificateCodeSigningInfo","env","EXPO_OFFLINE","fetchAndCacheNewDevelopmentCodeSigningInfoAsync","e","Log","warn","codeSigningCertificatePath","updates","codeSigningCertificate","codeSigningMetadata","alg","keyid","privateKeyPEM","certificatePEM","getProjectPrivateKeyAndCertificateFromFilePathsAsync","keyId","certificateForPrivateKey","certificateChainForResponse","readFileWithErrorAsync","errorMessage","fs","readFile","codeSigningCertificatePEM","Promise","all","convertPrivateKeyPEMToPrivateKey","certificate","convertCertificatePEMToCertificate","validateSelfSignedCertificate","publicKey","codeSigningInfo","certificatePEMs","map","now","Date","validity","notBefore","notAfter","actorCanGetProjectDevelopmentCertificate","actor","app","owningAccountId","ownerAccount","id","owningAccountIsActorPrimaryAccount","__typename","primaryAccount","userHasPublishPermissionForOwningAccount","accounts","find","account","users","userPermission","permissions","includes","Permission","Publish","ensureLoggedInAsync","AppQuery","byIdAsync","GraphQLError","CombinedError","keyPair","generateKeyPair","keyPairPEM","convertKeyPairToPEM","csr","generateCSR","csrPEM","convertCSRToCSRPEM","developmentSigningCertificate","expoGoIntermediateCertificate","getProjectDevelopmentCertificateAsync","getExpoGoIntermediateCertificateAsync","stringifiedManifest","signBufferRSASHA256AndVerify","Buffer","from"],"mappings":"AAAA;;;;;;;;;;;IA6DgBA,kCAAkC,MAAlCA,kCAAkC;IAgDrCC,8BAA8B,MAA9BA,8BAA8B;IAcrBC,uBAAuB,MAAvBA,uBAAuB;IAiT7BC,kBAAkB,MAAlBA,kBAAkB;;;yBA5aL,qBAAqB;;;;;;;yBAU3C,iCAAiC;;;;;;;yBAEH,iCAAiC;;;;;;;8DACjC,iBAAiB;;;;;;;yBACxB,YAAY;;;;;;;yBACX,IAAI;;;;;;;8DAElB,MAAM;;;;;;;yBACqB,oBAAoB;;;;;;qBAE5C,OAAO;wBACE,UAAU;kDACe,yCAAyC;kDACzC,yCAAyC;0BACtE,iCAAiC;yBACtB,qBAAqB;2BAEhB,sBAAsB;2DAC1C,QAAQ;sBACH,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,AAAsB,AAAC;AA4BzE,MAAMC,2CAA2C,GAAG,0CAA0C,AAAC;AAExF,SAASN,kCAAkC,GAAW;IAC3D,OAAOO,KAAI,EAAA,QAAA,CAACC,I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AQ,EAAEgE,GAAG,CAAChE,QAAQ;KACvB,CAAC;AACJ,CAAC;AAIM,SAASrB,kBAAkB,CAChCuH,mBAA2B,EAC3B5C,eAAgC,EACxB;IACR,MAAMrD,UAAU,GAAGgD,IAAAA,wBAAgC,EAAA,iCAAA,EAACK,eAAe,CAACrD,UAAU,CAAC,AAAC;IAChF,MAAMiD,WAAW,GAAGC,IAAAA,wBAAkC,EAAA,mCAAA,EAACG,eAAe,CAACd,wBAAwB,CAAC,AAAC;IACjG,OAAO2D,IAAAA,wBAA4B,EAAA,6BAAA,EACjClG,UAAU,EACViD,WAAW,EACXkD,MAAM,CAACC,IAAI,CAACH,mBAAmB,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC"}
|
package/build/src/utils/exit.js
CHANGED
|
@@ -12,6 +12,13 @@ _export(exports, {
|
|
|
12
12
|
installExitHooks: ()=>installExitHooks,
|
|
13
13
|
ensureProcessExitsAfterDelay: ()=>ensureProcessExitsAfterDelay
|
|
14
14
|
});
|
|
15
|
+
function _nodeChildProcess() {
|
|
16
|
+
const data = require("node:child_process");
|
|
17
|
+
_nodeChildProcess = function() {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
15
22
|
function _nodeProcess() {
|
|
16
23
|
const data = /*#__PURE__*/ _interopRequireDefault(require("node:process"));
|
|
17
24
|
_nodeProcess = function() {
|
|
@@ -20,6 +27,7 @@ function _nodeProcess() {
|
|
|
20
27
|
return data;
|
|
21
28
|
}
|
|
22
29
|
const _fn = require("./fn");
|
|
30
|
+
const _log = require("../log");
|
|
23
31
|
function _interopRequireDefault(obj) {
|
|
24
32
|
return obj && obj.__esModule ? obj : {
|
|
25
33
|
default: obj
|
|
@@ -86,17 +94,36 @@ function attachMasterListener() {
|
|
|
86
94
|
};
|
|
87
95
|
}
|
|
88
96
|
function ensureProcessExitsAfterDelay(waitUntilExitMs = 10000, startedAtMs = Date.now()) {
|
|
89
|
-
//
|
|
97
|
+
// Create a list of the expected active resources before exiting.
|
|
98
|
+
// Note, the order is undeterministic
|
|
99
|
+
const expectedResources = [
|
|
100
|
+
_nodeProcess().default.stdout.isTTY ? "TTYWrap" : "PipeWrap",
|
|
101
|
+
_nodeProcess().default.stderr.isTTY ? "TTYWrap" : "PipeWrap",
|
|
102
|
+
_nodeProcess().default.stdin.isTTY ? "TTYWrap" : "PipeWrap",
|
|
103
|
+
];
|
|
104
|
+
// Check active resources, besides the TTYWrap/PipeWrap (process.stdin, process.stdout, process.stderr)
|
|
90
105
|
// @ts-expect-error Added in v17.3.0, v16.14.0 but unavailable in v18 typings
|
|
91
106
|
const activeResources = _nodeProcess().default.getActiveResourcesInfo();
|
|
92
|
-
|
|
107
|
+
// Filter the active resource list by subtracting the expected resources, in undeterministic order
|
|
108
|
+
const unexpectedActiveResources = activeResources.filter((activeResource)=>{
|
|
109
|
+
const index = expectedResources.indexOf(activeResource);
|
|
110
|
+
if (index >= 0) {
|
|
111
|
+
expectedResources.splice(index, 1);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
const canExitProcess = !unexpectedActiveResources.length;
|
|
93
117
|
if (canExitProcess) {
|
|
94
118
|
return debug("no active resources detected, process can safely exit");
|
|
119
|
+
} else {
|
|
120
|
+
debug(`process is trying to exit, but is stuck on unexpected active resources:`, unexpectedActiveResources);
|
|
95
121
|
}
|
|
96
122
|
// Check if the process needs to be force-closed
|
|
97
123
|
const elapsedTime = Date.now() - startedAtMs;
|
|
98
124
|
if (elapsedTime > waitUntilExitMs) {
|
|
99
125
|
debug("active handles detected past the exit delay, forcefully exiting:", activeResources);
|
|
126
|
+
tryWarnActiveProcesses();
|
|
100
127
|
return _nodeProcess().default.exit(0);
|
|
101
128
|
}
|
|
102
129
|
const timeoutId = setTimeout(()=>{
|
|
@@ -106,5 +133,35 @@ function ensureProcessExitsAfterDelay(waitUntilExitMs = 10000, startedAtMs = Dat
|
|
|
106
133
|
ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);
|
|
107
134
|
}, 100);
|
|
108
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Try to warn the user about unexpected active processes running in the background.
|
|
138
|
+
* This uses the internal `process._getActiveHandles` method, within a try-catch block.
|
|
139
|
+
* If active child processes are detected, the commands of these processes are logged.
|
|
140
|
+
*
|
|
141
|
+
* @example ```bash
|
|
142
|
+
* Done writing bundle output
|
|
143
|
+
* Detected 2 processes preventing Expo from exiting, forcefully exiting now.
|
|
144
|
+
* - node /Users/cedric/../node_modules/nativewind/dist/metro/tailwind/v3/child.js
|
|
145
|
+
* - node /Users/cedric/../node_modules/nativewind/dist/metro/tailwind/v3/child.js
|
|
146
|
+
* ```
|
|
147
|
+
*/ function tryWarnActiveProcesses() {
|
|
148
|
+
let activeProcesses = [];
|
|
149
|
+
try {
|
|
150
|
+
const children = _nodeProcess().default// @ts-expect-error - This is an internal method, not designed to be exposed. It's also our only way to get this info
|
|
151
|
+
._getActiveHandles().filter((handle)=>handle instanceof _nodeChildProcess().ChildProcess);
|
|
152
|
+
if (children.length) {
|
|
153
|
+
activeProcesses = children.map((child)=>child.spawnargs.join(" "));
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
debug("failed to get active process information:", error);
|
|
157
|
+
}
|
|
158
|
+
if (!activeProcesses.length) {
|
|
159
|
+
(0, _log.warn)("Something prevented Expo from exiting, forcefully exiting now.");
|
|
160
|
+
} else {
|
|
161
|
+
const singularOrPlural = activeProcesses.length === 1 ? "1 process" : `${activeProcesses.length} processes`;
|
|
162
|
+
(0, _log.warn)(`Detected ${singularOrPlural} preventing Expo from exiting, forcefully exiting now.`);
|
|
163
|
+
(0, _log.warn)(" - " + activeProcesses.join("\n - "));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
109
166
|
|
|
110
167
|
//# sourceMappingURL=exit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/exit.ts"],"sourcesContent":["import process from 'node:process';\n\nimport { guardAsync } from './fn';\n\nconst debug = require('debug')('expo:utils:exit') as typeof console.log;\n\ntype AsyncExitHook = (signal: NodeJS.Signals) => void | Promise<void>;\n\nconst PRE_EXIT_SIGNALS: NodeJS.Signals[] = ['SIGHUP', 'SIGINT', 'SIGTERM', 'SIGBREAK'];\n\n// We create a queue since Node.js throws an error if we try to append too many listeners:\n// (node:4405) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit\nconst queue: AsyncExitHook[] = [];\n\nlet unsubscribe: (() => void) | null = null;\n\n/** Add functions that run before the process exits. Returns a function for removing the listeners. */\nexport function installExitHooks(asyncExitHook: AsyncExitHook): () => void {\n // We need to instantiate the master listener the first time the queue is used.\n if (!queue.length) {\n // Track the master listener so we can remove it later.\n unsubscribe = attachMasterListener();\n }\n\n queue.push(asyncExitHook);\n\n return () => {\n const index = queue.indexOf(asyncExitHook);\n if (index >= 0) {\n queue.splice(index, 1);\n }\n // Clean up the master listener if we don't need it anymore.\n if (!queue.length) {\n unsubscribe?.();\n }\n };\n}\n\n// Create a function that runs before the process exits and guards against running multiple times.\nfunction createExitHook(signal: NodeJS.Signals) {\n return guardAsync(async () => {\n debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);\n\n for (const [index, hookAsync] of Object.entries(queue)) {\n try {\n await hookAsync(signal);\n } catch (error: any) {\n debug(`Error in exit hook: %O (queue: ${index})`, error);\n }\n }\n\n debug(`post-exit (code: ${process.exitCode ?? 0})`);\n\n process.exit();\n });\n}\n\nfunction attachMasterListener() {\n const hooks: [NodeJS.Signals, () => any][] = [];\n for (const signal of PRE_EXIT_SIGNALS) {\n const hook = createExitHook(signal);\n hooks.push([signal, hook]);\n process.on(signal, hook);\n }\n return () => {\n for (const [signal, hook] of hooks) {\n process.removeListener(signal, hook);\n }\n };\n}\n\n/**\n * Monitor if the current process is exiting before the delay is reached.\n * If there are active resources, the process will be forced to exit after the delay is reached.\n *\n * @see https://nodejs.org/docs/latest-v18.x/api/process.html#processgetactiveresourcesinfo\n */\nexport function ensureProcessExitsAfterDelay(waitUntilExitMs = 10000, startedAtMs = Date.now()) {\n // Check active resources, besides the TTYWrap (process.stdin, process.stdout, process.stderr)\n // @ts-expect-error Added in v17.3.0, v16.14.0 but unavailable in v18 typings\n const activeResources = process.getActiveResourcesInfo() as string[];\n const canExitProcess = activeResources.filter((resource) => resource !== 'TTYWrap').length === 0;\n if (canExitProcess) {\n return debug('no active resources detected, process can safely exit');\n }\n\n // Check if the process needs to be force-closed\n const elapsedTime = Date.now() - startedAtMs;\n if (elapsedTime > waitUntilExitMs) {\n debug('active handles detected past the exit delay, forcefully exiting:', activeResources);\n return process.exit(0);\n }\n\n const timeoutId = setTimeout(() => {\n // Ensure the timeout is cleared before checking the active resources\n clearTimeout(timeoutId);\n // Check if the process can exit\n ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);\n }, 100);\n}\n"],"names":["installExitHooks","ensureProcessExitsAfterDelay","debug","require","PRE_EXIT_SIGNALS","queue","unsubscribe","asyncExitHook","length","attachMasterListener","push","index","indexOf","splice","createExitHook","signal","guardAsync","hookAsync","Object","entries","error","process","exitCode","exit","hooks","hook","on","removeListener","waitUntilExitMs","startedAtMs","Date","now","activeResources","getActiveResourcesInfo","canExitProcess","filter","resource","elapsedTime","timeoutId","setTimeout","clearTimeout"],"mappings":"AAAA;;;;;;;;;;;IAiBgBA,gBAAgB,MAAhBA,gBAAgB;IA4DhBC,4BAA4B,MAA5BA,4BAA4B;;;8DA7ExB,cAAc;;;;;;oBAEP,MAAM;;;;;;AAEjC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,AAAsB,AAAC;AAIxE,MAAMC,gBAAgB,GAAqB;IAAC,QAAQ;IAAE,QAAQ;IAAE,SAAS;IAAE,UAAU;CAAC,AAAC;AAEvF,0FAA0F;AAC1F,+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ACjC1B,KAAK,CAAC,kEAAkE,EAAE8B,eAAe,CAAC,CAAC;QAC3F,OAAOX,YAAO,EAAA,QAAA,CAACE,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,MAAMe,SAAS,GAAGC,UAAU,CAAC,IAAM;QACjC,qEAAqE;QACrEC,YAAY,CAACF,SAAS,CAAC,CAAC;QACxB,gCAAgC;QAChCrC,4BAA4B,CAAC2B,eAAe,EAAEC,WAAW,CAAC,CAAC;IAC7D,CAAC,EAAE,GAAG,CAAC,AAAC;AACV,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/exit.ts"],"sourcesContent":["import { ChildProcess } from 'node:child_process';\nimport process from 'node:process';\n\nimport { guardAsync } from './fn';\nimport { warn } from '../log';\n\nconst debug = require('debug')('expo:utils:exit') as typeof console.log;\n\ntype AsyncExitHook = (signal: NodeJS.Signals) => void | Promise<void>;\n\nconst PRE_EXIT_SIGNALS: NodeJS.Signals[] = ['SIGHUP', 'SIGINT', 'SIGTERM', 'SIGBREAK'];\n\n// We create a queue since Node.js throws an error if we try to append too many listeners:\n// (node:4405) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit\nconst queue: AsyncExitHook[] = [];\n\nlet unsubscribe: (() => void) | null = null;\n\n/** Add functions that run before the process exits. Returns a function for removing the listeners. */\nexport function installExitHooks(asyncExitHook: AsyncExitHook): () => void {\n // We need to instantiate the master listener the first time the queue is used.\n if (!queue.length) {\n // Track the master listener so we can remove it later.\n unsubscribe = attachMasterListener();\n }\n\n queue.push(asyncExitHook);\n\n return () => {\n const index = queue.indexOf(asyncExitHook);\n if (index >= 0) {\n queue.splice(index, 1);\n }\n // Clean up the master listener if we don't need it anymore.\n if (!queue.length) {\n unsubscribe?.();\n }\n };\n}\n\n// Create a function that runs before the process exits and guards against running multiple times.\nfunction createExitHook(signal: NodeJS.Signals) {\n return guardAsync(async () => {\n debug(`pre-exit (signal: ${signal}, queue length: ${queue.length})`);\n\n for (const [index, hookAsync] of Object.entries(queue)) {\n try {\n await hookAsync(signal);\n } catch (error: any) {\n debug(`Error in exit hook: %O (queue: ${index})`, error);\n }\n }\n\n debug(`post-exit (code: ${process.exitCode ?? 0})`);\n\n process.exit();\n });\n}\n\nfunction attachMasterListener() {\n const hooks: [NodeJS.Signals, () => any][] = [];\n for (const signal of PRE_EXIT_SIGNALS) {\n const hook = createExitHook(signal);\n hooks.push([signal, hook]);\n process.on(signal, hook);\n }\n return () => {\n for (const [signal, hook] of hooks) {\n process.removeListener(signal, hook);\n }\n };\n}\n\n/**\n * Monitor if the current process is exiting before the delay is reached.\n * If there are active resources, the process will be forced to exit after the delay is reached.\n *\n * @see https://nodejs.org/docs/latest-v18.x/api/process.html#processgetactiveresourcesinfo\n */\nexport function ensureProcessExitsAfterDelay(waitUntilExitMs = 10000, startedAtMs = Date.now()) {\n // Create a list of the expected active resources before exiting.\n // Note, the order is undeterministic\n const expectedResources = [\n process.stdout.isTTY ? 'TTYWrap' : 'PipeWrap',\n process.stderr.isTTY ? 'TTYWrap' : 'PipeWrap',\n process.stdin.isTTY ? 'TTYWrap' : 'PipeWrap',\n ];\n // Check active resources, besides the TTYWrap/PipeWrap (process.stdin, process.stdout, process.stderr)\n // @ts-expect-error Added in v17.3.0, v16.14.0 but unavailable in v18 typings\n const activeResources = process.getActiveResourcesInfo() as string[];\n // Filter the active resource list by subtracting the expected resources, in undeterministic order\n const unexpectedActiveResources = activeResources.filter((activeResource) => {\n const index = expectedResources.indexOf(activeResource);\n if (index >= 0) {\n expectedResources.splice(index, 1);\n return false;\n }\n\n return true;\n });\n\n const canExitProcess = !unexpectedActiveResources.length;\n if (canExitProcess) {\n return debug('no active resources detected, process can safely exit');\n } else {\n debug(\n `process is trying to exit, but is stuck on unexpected active resources:`,\n unexpectedActiveResources\n );\n }\n\n // Check if the process needs to be force-closed\n const elapsedTime = Date.now() - startedAtMs;\n if (elapsedTime > waitUntilExitMs) {\n debug('active handles detected past the exit delay, forcefully exiting:', activeResources);\n tryWarnActiveProcesses();\n return process.exit(0);\n }\n\n const timeoutId = setTimeout(() => {\n // Ensure the timeout is cleared before checking the active resources\n clearTimeout(timeoutId);\n // Check if the process can exit\n ensureProcessExitsAfterDelay(waitUntilExitMs, startedAtMs);\n }, 100);\n}\n\n/**\n * Try to warn the user about unexpected active processes running in the background.\n * This uses the internal `process._getActiveHandles` method, within a try-catch block.\n * If active child processes are detected, the commands of these processes are logged.\n *\n * @example ```bash\n * Done writing bundle output\n * Detected 2 processes preventing Expo from exiting, forcefully exiting now.\n * - node /Users/cedric/../node_modules/nativewind/dist/metro/tailwind/v3/child.js\n * - node /Users/cedric/../node_modules/nativewind/dist/metro/tailwind/v3/child.js\n * ```\n */\nfunction tryWarnActiveProcesses() {\n let activeProcesses: string[] = [];\n\n try {\n const children: ChildProcess[] = process\n // @ts-expect-error - This is an internal method, not designed to be exposed. It's also our only way to get this info\n ._getActiveHandles()\n .filter((handle: any) => handle instanceof ChildProcess);\n\n if (children.length) {\n activeProcesses = children.map((child) => child.spawnargs.join(' '));\n }\n } catch (error) {\n debug('failed to get active process information:', error);\n }\n\n if (!activeProcesses.length) {\n warn('Something prevented Expo from exiting, forcefully exiting now.');\n } else {\n const singularOrPlural =\n activeProcesses.length === 1 ? '1 process' : `${activeProcesses.length} processes`;\n\n warn(`Detected ${singularOrPlural} preventing Expo from exiting, forcefully exiting now.`);\n warn(' - ' + activeProcesses.join('\\n - '));\n }\n}\n"],"names":["installExitHooks","ensureProcessExitsAfterDelay","debug","require","PRE_EXIT_SIGNALS","queue","unsubscribe","asyncExitHook","length","attachMasterListener","push","index","indexOf","splice","createExitHook","signal","guardAsync","hookAsync","Object","entries","error","process","exitCode","exit","hooks","hook","on","removeListener","waitUntilExitMs","startedAtMs","Date","now","expectedResources","stdout","isTTY","stderr","stdin","activeResources","getActiveResourcesInfo","unexpectedActiveResources","filter","activeResource","canExitProcess","elapsedTime","tryWarnActiveProcesses","timeoutId","setTimeout","clearTimeout","activeProcesses","children","_getActiveHandles","handle","ChildProcess","map","child","spawnargs","join","warn","singularOrPlural"],"mappings":"AAAA;;;;;;;;;;;IAmBgBA,gBAAgB,MAAhBA,gBAAgB;IA4DhBC,4BAA4B,MAA5BA,4BAA4B;;;yBA/Ef,oBAAoB;;;;;;;8DAC7B,cAAc;;;;;;oBAEP,MAAM;qBACZ,QAAQ;;;;;;AAE7B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,AAAsB,AAAC;AAIxE,MAAMC,gBAAgB,GAAqB;IAAC,QAAQ;IAAE,QAAQ;IAAE,SAAS;IAAE,UAAU;CAAC,AAAC;AAEvF,0FAA0F;AAC1F,+KAA+K;AAC/K,MAAMC,KAAK,GAAoB,EAAE,AAAC;AAElC,IAAIC,WAAW,GAAwB,IAAI,AAAC;AAGrC,SAASN,gBAAgB,CAACO,aAA4B,EAAc;IACzE,+EAA+E;IAC/E,IAAI,CAACF,KAAK,CAACG,MAAM,EAAE;QACjB,uDAAuD;QACvDF,WAAW,GAAGG,oBAAoB,EAAE,CAAC;IACvC,CAAC;IAEDJ,KAAK,CAACK,IAAI,CAACH,aAAa,CAAC,CAAC;IAE1B,OAAO,IAAM;QACX,MAAMI,KAAK,GAAGN,KAAK,CAACO,OAAO,CAACL,aAAa,CAAC,AAAC;QAC3C,IAAII,KAAK,IAAI,CAAC,EAAE;YACdN,KAAK,CAACQ,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC,CAAC;QACzB,CAAC;QACD,4DAA4D;QAC5D,IAAI,CAACN,KAAK,CAACG,MAAM,EAAE;YACjBF,WAAW,QAAI,GAAfA,KAAAA,CAAe,GAAfA,WAAW,EAAI,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,kGAAkG;AAClG,SAASQ,cAAc,CAACC,MAAsB,EAAE;IAC9C,OAAOC,IAAAA,GAAU,WAAA,EAAC,UAAY;QA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CAAC,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "resolveRealEntryFilePath", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>resolveRealEntryFilePath
|
|
8
|
+
});
|
|
9
|
+
function _fs() {
|
|
10
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
11
|
+
_fs = function() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
function _interopRequireDefault(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function resolveRealEntryFilePath(projectRoot, entryFile) {
|
|
22
|
+
if (projectRoot.startsWith("/private/var") && entryFile.startsWith("/var")) {
|
|
23
|
+
return _fs().default.realpathSync(entryFile);
|
|
24
|
+
}
|
|
25
|
+
return entryFile;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=filePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/filePath.ts"],"sourcesContent":["import fs from 'fs';\n\n/**\n * This is a workaround for Metro not resolving entry file paths to their real location.\n * When running exports through `eas build --local` on macOS, the `/var/folders` path is used instead of `/private/var/folders`.\n *\n * See: https://github.com/expo/expo/issues/28890\n */\nexport function resolveRealEntryFilePath(projectRoot: string, entryFile: string): string {\n if (projectRoot.startsWith('/private/var') && entryFile.startsWith('/var')) {\n return fs.realpathSync(entryFile);\n }\n\n return entryFile;\n}\n"],"names":["resolveRealEntryFilePath","projectRoot","entryFile","startsWith","fs","realpathSync"],"mappings":"AAAA;;;;+BAQgBA,0BAAwB;;aAAxBA,wBAAwB;;;8DARzB,IAAI;;;;;;;;;;;AAQZ,SAASA,wBAAwB,CAACC,WAAmB,EAAEC,SAAiB,EAAU;IACvF,IAAID,WAAW,CAACE,UAAU,CAAC,cAAc,CAAC,IAAID,SAAS,CAACC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC1E,OAAOC,GAAE,EAAA,QAAA,CAACC,YAAY,CAACH,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,OAAOA,SAAS,CAAC;AACnB,CAAC"}
|
package/build/src/utils/ip.js
CHANGED
|
@@ -13,13 +13,101 @@ function _internalIp() {
|
|
|
13
13
|
};
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
|
+
function _nodeChildProcess() {
|
|
17
|
+
const data = require("node:child_process");
|
|
18
|
+
_nodeChildProcess = function() {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
function _nodeNet() {
|
|
24
|
+
const data = require("node:net");
|
|
25
|
+
_nodeNet = function() {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
function _nodeOs() {
|
|
31
|
+
const data = require("node:os");
|
|
32
|
+
_nodeOs = function() {
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
16
37
|
function _interopRequireDefault(obj) {
|
|
17
38
|
return obj && obj.__esModule ? obj : {
|
|
18
39
|
default: obj
|
|
19
40
|
};
|
|
20
41
|
}
|
|
42
|
+
/** Gets a route address by opening a UDP socket to a publicly routed address.
|
|
43
|
+
* @privateRemarks
|
|
44
|
+
* This is wrapped in `spawnSync` since the original `getIpAddress` utility exported
|
|
45
|
+
* in this module is used synchronosly. An appropriate timeout has been set and UDP
|
|
46
|
+
* ports don't send a message when opened.
|
|
47
|
+
* @throws if `spawnSync` fails
|
|
48
|
+
*/ function getRouteAddress() {
|
|
49
|
+
const { error , status , stdout } = (0, _nodeChildProcess().spawnSync)(process.execPath, [
|
|
50
|
+
"-"
|
|
51
|
+
], {
|
|
52
|
+
// This should be the cheapest method to determine the default route
|
|
53
|
+
// By opening a socket to a publicly routed IP address, we let the default
|
|
54
|
+
// gateway handle this socket, which means the socket's address will be
|
|
55
|
+
// the prioritised route for public IP addresses.
|
|
56
|
+
// It might fall back to `"0.0.0.0"` when no network connection is established
|
|
57
|
+
input: `
|
|
58
|
+
var socket = require('dgram').createSocket({ type: 'udp4', reuseAddr: true });
|
|
59
|
+
socket.unref();
|
|
60
|
+
socket.connect(53, '1.1.1.1', function() {
|
|
61
|
+
var address = socket.address();
|
|
62
|
+
socket.close();
|
|
63
|
+
if (address && 'address' in address) {
|
|
64
|
+
process.stdout.write(address.address);
|
|
65
|
+
process.exit(0);
|
|
66
|
+
} else {
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
`,
|
|
71
|
+
shell: false,
|
|
72
|
+
timeout: 500,
|
|
73
|
+
encoding: "utf8",
|
|
74
|
+
windowsVerbatimArguments: false,
|
|
75
|
+
windowsHide: true
|
|
76
|
+
});
|
|
77
|
+
// We only use the stdout as an IP, if it validates as an IP and we got a zero exit code
|
|
78
|
+
if (status || error) {
|
|
79
|
+
return null;
|
|
80
|
+
} else if (!status && typeof stdout === "string" && (0, _nodeNet().isIPv4)(stdout.trim())) {
|
|
81
|
+
return stdout.trim();
|
|
82
|
+
} else {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Determines the internal IP address by opening a socket, then checking the socket address against non-internal network interface assignments
|
|
87
|
+
* @throws If no address can be determined.
|
|
88
|
+
*/ function getRouteIPAddress() {
|
|
89
|
+
// We check the IP address we get against the available network interfaces
|
|
90
|
+
// It's only an internal IP address if we have a matching address on an interface's IP assignment
|
|
91
|
+
let routeAddress = null;
|
|
92
|
+
try {
|
|
93
|
+
routeAddress = getRouteAddress();
|
|
94
|
+
} catch {}
|
|
95
|
+
if (!routeAddress) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const ifaces = (0, _nodeOs().networkInterfaces)();
|
|
99
|
+
for(const iface in ifaces){
|
|
100
|
+
const assignments = ifaces[iface];
|
|
101
|
+
for(let i = 0; assignments && i < assignments.length; i++){
|
|
102
|
+
const assignment = assignments[i];
|
|
103
|
+
// Only use IPv4 assigments that aren't internal
|
|
104
|
+
if (assignment.family === "IPv4" && !assignment.internal && assignment.address === routeAddress) return routeAddress;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
21
109
|
function getIpAddress() {
|
|
22
|
-
return _internalIp().default.v4.sync() || "127.0.0.1";
|
|
110
|
+
return _internalIp().default.v4.sync() || getRouteIPAddress() || "127.0.0.1";
|
|
23
111
|
}
|
|
24
112
|
|
|
25
113
|
//# sourceMappingURL=ip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/ip.ts"],"sourcesContent":["import internalIp from 'internal-ip';\n\nexport function getIpAddress(): string {\n return internalIp.v4.sync() || '127.0.0.1';\n}\n"],"names":["getIpAddress","internalIp","v4","sync"],"mappings":"AAAA;;;;+
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/ip.ts"],"sourcesContent":["import internalIp from 'internal-ip';\nimport { spawnSync } from 'node:child_process';\nimport { isIPv4 } from 'node:net';\nimport { networkInterfaces } from 'node:os';\n\n/** Gets a route address by opening a UDP socket to a publicly routed address.\n * @privateRemarks\n * This is wrapped in `spawnSync` since the original `getIpAddress` utility exported\n * in this module is used synchronosly. An appropriate timeout has been set and UDP\n * ports don't send a message when opened.\n * @throws if `spawnSync` fails\n */\nfunction getRouteAddress(): string | null {\n const { error, status, stdout } = spawnSync(process.execPath, ['-'], {\n // This should be the cheapest method to determine the default route\n // By opening a socket to a publicly routed IP address, we let the default\n // gateway handle this socket, which means the socket's address will be\n // the prioritised route for public IP addresses.\n // It might fall back to `\"0.0.0.0\"` when no network connection is established\n input: `\n var socket = require('dgram').createSocket({ type: 'udp4', reuseAddr: true });\n socket.unref();\n socket.connect(53, '1.1.1.1', function() {\n var address = socket.address();\n socket.close();\n if (address && 'address' in address) {\n process.stdout.write(address.address);\n process.exit(0);\n } else {\n process.exit(1);\n }\n });\n `,\n shell: false,\n timeout: 500,\n encoding: 'utf8',\n windowsVerbatimArguments: false,\n windowsHide: true,\n });\n // We only use the stdout as an IP, if it validates as an IP and we got a zero exit code\n if (status || error) {\n return null;\n } else if (!status && typeof stdout === 'string' && isIPv4(stdout.trim())) {\n return stdout.trim();\n } else {\n return null;\n }\n}\n\n/** Determines the internal IP address by opening a socket, then checking the socket address against non-internal network interface assignments\n * @throws If no address can be determined.\n */\nfunction getRouteIPAddress(): string | null {\n // We check the IP address we get against the available network interfaces\n // It's only an internal IP address if we have a matching address on an interface's IP assignment\n let routeAddress: string | null = null;\n try {\n routeAddress = getRouteAddress();\n } catch {}\n if (!routeAddress) {\n return null;\n }\n const ifaces = networkInterfaces();\n for (const iface in ifaces) {\n const assignments = ifaces[iface];\n for (let i = 0; assignments && i < assignments.length; i++) {\n const assignment = assignments[i];\n // Only use IPv4 assigments that aren't internal\n if (\n assignment.family === 'IPv4' &&\n !assignment.internal &&\n assignment.address === routeAddress\n )\n return routeAddress;\n }\n }\n return null;\n}\n\nexport function getIpAddress(): string {\n return internalIp.v4.sync() || getRouteIPAddress() || '127.0.0.1';\n}\n"],"names":["getIpAddress","getRouteAddress","error","status","stdout","spawnSync","process","execPath","input","shell","timeout","encoding","windowsVerbatimArguments","windowsHide","isIPv4","trim","getRouteIPAddress","routeAddress","ifaces","networkInterfaces","iface","assignments","i","length","assignment","family","internal","address","internalIp","v4","sync"],"mappings":"AAAA;;;;+BA+EgBA,cAAY;;aAAZA,YAAY;;;8DA/EL,aAAa;;;;;;;yBACV,oBAAoB;;;;;;;yBACvB,UAAU;;;;;;;yBACC,SAAS;;;;;;;;;;;AAE3C;;;;;;CAMC,GACD,SAASC,eAAe,GAAkB;IACxC,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WAAW,CAACE,MAAM,EAAED,CAAC,EAAE,CAAE;YAC1D,MAAME,UAAU,GAAGH,WAAW,CAACC,CAAC,CAAC,AAAC;YAClC,gDAAgD;YAChD,IACEE,UAAU,CAACC,MAAM,KAAK,MAAM,IAC5B,CAACD,UAAU,CAACE,QAAQ,IACpBF,UAAU,CAACG,OAAO,KAAKV,YAAY,EAEnC,OAAOA,YAAY,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,SAASjB,YAAY,GAAW;IACrC,OAAO4B,WAAU,EAAA,QAAA,CAACC,EAAE,CAACC,IAAI,EAAE,IAAId,iBAAiB,EAAE,IAAI,WAAW,CAAC;AACpE,CAAC"}
|
|
@@ -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.
|
|
34
|
+
"user-agent": `expo-cli/${"0.20.0"}`,
|
|
35
35
|
authorization: "Basic " + _nodeBuffer().Buffer.from(`${target}:`).toString("base64")
|
|
36
36
|
};
|
|
37
37
|
}
|
|
@@ -47,19 +47,19 @@ class RudderDetachedClient {
|
|
|
47
47
|
})));
|
|
48
48
|
}
|
|
49
49
|
async flush() {
|
|
50
|
-
if (!this.records.length) {
|
|
51
|
-
return debug("No records to flush, skipping...");
|
|
52
|
-
}
|
|
53
|
-
const file = (0, _createTempPath.createTempFilePath)("expo-telemetry.json");
|
|
54
|
-
const data = JSON.stringify({
|
|
55
|
-
records: this.records
|
|
56
|
-
});
|
|
57
|
-
this.records = [];
|
|
58
|
-
await _nodeFs().default.promises.mkdir(_nodePath().default.dirname(file), {
|
|
59
|
-
recursive: true
|
|
60
|
-
});
|
|
61
|
-
await _nodeFs().default.promises.writeFile(file, data);
|
|
62
50
|
try {
|
|
51
|
+
if (!this.records.length) {
|
|
52
|
+
return debug("No records to flush, skipping...");
|
|
53
|
+
}
|
|
54
|
+
const file = (0, _createTempPath.createTempFilePath)("expo-telemetry.json");
|
|
55
|
+
const data = JSON.stringify({
|
|
56
|
+
records: this.records
|
|
57
|
+
});
|
|
58
|
+
this.records = [];
|
|
59
|
+
await _nodeFs().default.promises.mkdir(_nodePath().default.dirname(file), {
|
|
60
|
+
recursive: true
|
|
61
|
+
});
|
|
62
|
+
await _nodeFs().default.promises.writeFile(file, data);
|
|
63
63
|
const child = (0, _nodeChildProcess().spawn)(process.execPath, [
|
|
64
64
|
require.resolve("./flushRudderDetached"),
|
|
65
65
|
file
|
|
@@ -71,7 +71,7 @@ class RudderDetachedClient {
|
|
|
71
71
|
});
|
|
72
72
|
child.unref();
|
|
73
73
|
} catch (error) {
|
|
74
|
-
// This could fail if
|
|
74
|
+
// This could fail if any direct or indirect imports change during an upgrade to the `expo` dependency via `npx expo install --fix`,
|
|
75
75
|
// since this file may no longer be present after the upgrade, but before the process under the old Expo CLI version is terminated.
|
|
76
76
|
debug("Exception while initiating detached flush:", error);
|
|
77
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/utils/telemetry/clients/RudderDetachedClient.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { createTempFilePath } from '../../createTempPath';\nimport type { TelemetryClient, TelemetryClientStrategy, TelemetryRecordInternal } from '../types';\n\nconst debug = require('debug')('expo:telemetry:client:detached') as typeof console.log;\n\nexport class RudderDetachedClient implements TelemetryClient {\n /** This client should be used for short-lived commands */\n readonly strategy: TelemetryClientStrategy = 'detached';\n /** All recorded telemetry events */\n private records: TelemetryRecordInternal[] = [];\n\n abort() {\n return this.records;\n }\n\n record(record: TelemetryRecordInternal[]) {\n this.records.push(\n ...record.map((record) => ({\n ...record,\n originalTimestamp: record.sentAt,\n }))\n );\n }\n\n async flush() {\n if (!this.records.length) {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/utils/telemetry/clients/RudderDetachedClient.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { createTempFilePath } from '../../createTempPath';\nimport type { TelemetryClient, TelemetryClientStrategy, TelemetryRecordInternal } from '../types';\n\nconst debug = require('debug')('expo:telemetry:client:detached') as typeof console.log;\n\nexport class RudderDetachedClient implements TelemetryClient {\n /** This client should be used for short-lived commands */\n readonly strategy: TelemetryClientStrategy = 'detached';\n /** All recorded telemetry events */\n private records: TelemetryRecordInternal[] = [];\n\n abort() {\n return this.records;\n }\n\n record(record: TelemetryRecordInternal[]) {\n this.records.push(\n ...record.map((record) => ({\n ...record,\n originalTimestamp: record.sentAt,\n }))\n );\n }\n\n async flush() {\n try {\n if (!this.records.length) {\n return debug('No records to flush, skipping...');\n }\n\n const file = createTempFilePath('expo-telemetry.json');\n const data = JSON.stringify({ records: this.records });\n\n this.records = [];\n\n await fs.promises.mkdir(path.dirname(file), { recursive: true });\n await fs.promises.writeFile(file, data);\n\n const child = spawn(process.execPath, [require.resolve('./flushRudderDetached'), file], {\n detached: true,\n windowsHide: true,\n shell: false,\n stdio: 'ignore',\n });\n\n child.unref();\n } catch (error) {\n // This could fail if any direct or indirect imports change during an upgrade to the `expo` dependency via `npx expo install --fix`,\n // since this file may no longer be present after the upgrade, but before the process under the old Expo CLI version is terminated.\n debug('Exception while initiating detached flush:', error);\n }\n\n debug('Detached flush started');\n }\n}\n"],"names":["RudderDetachedClient","debug","require","strategy","records","abort","record","push","map","originalTimestamp","sentAt","flush","length","file","createTempFilePath","data","JSON","stringify","fs","promises","mkdir","path","dirname","recursive","writeFile","child","spawn","process","execPath","resolve","detached","windowsHide","shell","stdio","unref","error"],"mappings":"AAAA;;;;+BASaA,sBAAoB;;aAApBA,oBAAoB;;;yBATX,oBAAoB;;;;;;;8DAC3B,SAAS;;;;;;;8DACP,WAAW;;;;;;gCAEO,sBAAsB;;;;;;AAGzD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,C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tFiB,QAAQ,EAAE,IAAI;gBACdC,WAAW,EAAE,IAAI;gBACjBC,KAAK,EAAE,KAAK;gBACZC,KAAK,EAAE,QAAQ;aAChB,CAAC,AAAC;YAEHR,KAAK,CAACS,KAAK,EAAE,CAAC;QAChB,EAAE,OAAOC,KAAK,EAAE;YACd,oIAAoI;YACpI,mIAAmI;YACnIlC,KAAK,CAAC,4CAA4C,EAAEkC,KAAK,CAAC,CAAC;QAC7D,CAAC;QAEDlC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAClC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/expo/expo/tree/main/packages/@expo/cli",
|
|
41
41
|
"dependencies": {
|
|
42
|
+
"@0no-co/graphql.web": "^1.0.8",
|
|
42
43
|
"@babel/runtime": "^7.20.0",
|
|
43
44
|
"@expo/code-signing-certificates": "^0.0.5",
|
|
44
45
|
"@expo/config": "~10.0.2",
|
|
@@ -56,8 +57,8 @@
|
|
|
56
57
|
"@expo/spawn-async": "^1.7.2",
|
|
57
58
|
"@expo/xcpretty": "^4.3.0",
|
|
58
59
|
"@react-native/dev-middleware": "0.76.1",
|
|
59
|
-
"@urql/core": "^
|
|
60
|
-
"@urql/exchange-retry": "
|
|
60
|
+
"@urql/core": "^5.0.6",
|
|
61
|
+
"@urql/exchange-retry": "^1.3.0",
|
|
61
62
|
"accepts": "^1.3.8",
|
|
62
63
|
"arg": "^5.0.2",
|
|
63
64
|
"better-opn": "~3.0.2",
|
|
@@ -76,8 +77,6 @@
|
|
|
76
77
|
"fs-extra": "~8.1.0",
|
|
77
78
|
"getenv": "^1.0.0",
|
|
78
79
|
"glob": "^10.4.2",
|
|
79
|
-
"graphql": "^15.8.0",
|
|
80
|
-
"graphql-tag": "^2.10.1",
|
|
81
80
|
"internal-ip": "^4.3.0",
|
|
82
81
|
"is-docker": "^2.0.0",
|
|
83
82
|
"is-wsl": "^2.1.1",
|
|
@@ -168,5 +167,5 @@
|
|
|
168
167
|
"tree-kill": "^1.2.2",
|
|
169
168
|
"tsd": "^0.28.1"
|
|
170
169
|
},
|
|
171
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "a64603dce90981bf7688657f87dfa4be3e24f58b"
|
|
172
171
|
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
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
|
-
isAndroidUsingHermes: ()=>isAndroidUsingHermes,
|
|
13
|
-
isIosUsingHermes: ()=>isIosUsingHermes
|
|
14
|
-
});
|
|
15
|
-
function _fs() {
|
|
16
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
17
|
-
_fs = function() {
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
function _path() {
|
|
23
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
24
|
-
_path = function() {
|
|
25
|
-
return data;
|
|
26
|
-
};
|
|
27
|
-
return data;
|
|
28
|
-
}
|
|
29
|
-
function _interopRequireDefault(obj) {
|
|
30
|
-
return obj && obj.__esModule ? obj : {
|
|
31
|
-
default: obj
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const ASSUME_HERMES_IS_USED_BY_DEFAULT = true;
|
|
35
|
-
function parseGradleProperties(content) {
|
|
36
|
-
const result = {};
|
|
37
|
-
for (let line of content.split("\n")){
|
|
38
|
-
line = line.trim();
|
|
39
|
-
if (!line || line.startsWith("#")) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const sepIndex = line.indexOf("=");
|
|
43
|
-
const key = line.substr(0, sepIndex);
|
|
44
|
-
const value = line.substr(sepIndex + 1);
|
|
45
|
-
result[key] = value;
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
function isAndroidUsingHermes(projectRoot) {
|
|
50
|
-
// Check gradle.properties from prebuild template
|
|
51
|
-
const gradlePropertiesPath = _path().default.join(projectRoot, "android", "gradle.properties");
|
|
52
|
-
if (_fs().default.existsSync(gradlePropertiesPath)) {
|
|
53
|
-
const props = parseGradleProperties(_fs().default.readFileSync(gradlePropertiesPath, "utf8"));
|
|
54
|
-
return props["hermesEnabled"] === "true";
|
|
55
|
-
}
|
|
56
|
-
return ASSUME_HERMES_IS_USED_BY_DEFAULT;
|
|
57
|
-
}
|
|
58
|
-
function isIosUsingHermes(projectRoot) {
|
|
59
|
-
// Trying best to check ios native project if by chance to be consistent between app config
|
|
60
|
-
// Check ios/Podfile for ":hermes_enabled => true"
|
|
61
|
-
const podfilePath = _path().default.join(projectRoot, "ios", "Podfile");
|
|
62
|
-
if (_fs().default.existsSync(podfilePath)) {
|
|
63
|
-
const content = _fs().default.readFileSync(podfilePath, "utf8");
|
|
64
|
-
return content.search(/^\s*:hermes_enabled\s*=>\s*true,?\s+/m) >= 0;
|
|
65
|
-
}
|
|
66
|
-
return ASSUME_HERMES_IS_USED_BY_DEFAULT;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
//# sourceMappingURL=guessHermes.js.map
|