Compare commits

...
37 Commits
Author SHA1 Message Date
Dominik Sokal dc86f27199 v0.14.1 2021-05-11 11:23:22 +02:00
jkh d97ed80867 [eas-cli] set default urql requestPolicy to network-only (#397)
* [eas-cli] set default urql requestPolicy to network-only

* add changelog
2021-05-11 11:14:55 +02:00
Quinlan Jung 3601b448fe [eas-cli] create keystore action (#387)
* [eas-cli] create android keystore action

* 1: some pr feedback
2021-05-10 16:38:17 -07:00
Quinlan Jung 68aab13d51 [eas-cli] Keystore utils and fixtures (#386)
* [eas-cli] Keystore utils and fixtures

validate using pem decryption instead

* 0: some pr feedback

* pr feedback
2021-05-10 16:25:07 -07:00
Brent Vatne 6cef13d756 Update CHANGELOG 2021-05-10 11:36:59 -07:00
Brent Vatne 1d45941f5d v0.14.0 2021-05-10 11:28:46 -07:00
Quinlan Jung 5e5badf11f [eas-cli] credentials manager DX nits (#383) 2021-05-03 19:16:14 -07:00
jkh 840c65946b [eas-cli] remove --force to fix eas publish (#381) 2021-05-03 15:35:52 -07:00
Quinlan Jung fdbd786126 [eas-cli] move from deprecated iosAppCredentialsArray to iosAppCredentialsList (#380) 2021-05-03 13:16:33 -07:00
Quinlan Jung d5365275e0 [eas-cli] beta android credentials manager (#378) 2021-04-29 12:07:20 -07:00
Quinlan Jung 886e48d3ee [eas-cli] android graphql types (#377) 2021-04-29 11:17:18 -07:00
Wojciech Kozyra 342c78a4f6 [eas-cli] disable pending build check (#373)
* [eas-cli] disable pending builds check

* update CHANGELOG.md
2021-04-28 15:13:51 +02:00
Axel Delafosse a483d94e26 [eas-cli] assert (#372) 2021-04-28 11:54:33 +02:00
Axel DelafosseandDominik Sokal b40412a7a1 [eas-cli] add QR code to install internal distribution build on device (#371)
* [website] add qr code to install internal distribution build on device

* [eas-cli] update changelog

* [eas-cli] sort imports

* [eas-cli] sort imports

* [eas-cli] improve getInstallUrl typing

Co-authored-by: Dominik Sokal <[email protected]>

* [eas-cli] fix typing

* [eas-cli] clean code

Co-authored-by: Dominik Sokal <[email protected]>
2021-04-28 11:43:21 +02:00
Quinlan Jung d652e04f7b [eas-cli] getAppAsync not used anywhere outside (#369) 2021-04-27 13:09:10 -07:00
Quinlan Jung 85326d1104 [eas-cli] merge beta and main cred utils (#368) 2021-04-27 13:08:51 -07:00
Quinlan Jung 28c087138b [eas-cli] replace printCredentials with printCredentialsBeta (#367) 2021-04-27 13:08:30 -07:00
jkh 8badf14ec3 [eas-cli] create asset keys without an extension (#366)
* Clients must be using expo-asset >= 8.3.2 in order to handle this new update format.
2021-04-27 06:02:12 -07:00
Wojciech Kozyra 4f1db29ef8 [eas-cli] increase build wait timeout (#370)
* [eas-cli] increase build wait timeout

* Update CHANGELOG.md
2021-04-27 14:19:23 +02:00
Quinlan Jung 2354dc1b71 update changelog 2021-04-26 12:16:21 -07:00
Quinlan Jung f106bfa6d7 [eas-cli] replace ctx.ios with ctx.newIos (#365)
remove old ctx.ios

ctx.newIos -> ctx.ios

fix lint

unused fixtures

remove unused fixtures

merge fixtures

fix lint
2021-04-26 12:11:36 -07:00
Quinlan Jung 1a7edbea06 [eas-cli] merge everything from actions/new to actions (#364)
delete unused actions

delete old inner class

remove uneeded dist cert utils

merge dist cert utils

remove unused functions of pprofile utils

pop out new directory
2021-04-26 12:10:27 -07:00
Quinlan Jung 5bfaee9e4d [eas-cli] swap beta credentials manager with current (#363) 2021-04-26 12:07:35 -07:00
Quinlan Jung 0cb2309d7d [eas-cli] add additionalTypenames to delete mutations to clear urql cache 2021-04-23 13:43:50 -07:00
Quinlan Jung 0415a1d97f changelog stuff 2021-04-23 12:47:59 -07:00
Quinlan Jung 249c60f4d1 [eas-cli] add remove provisioning profile to beta manager (#361) 2021-04-23 12:33:48 -07:00
Quinlan Jung c357cc378c [eas-cli] add high level actions to beta manager (#360) 2021-04-23 12:29:14 -07:00
Quinlan Jung f7c0d731b6 changelog stuff" 2021-04-22 22:48:38 -07:00
Quinlan Jung e852e3edac [eas-cli] add CreateDistCert and UseExistingDistCert to beta manager (#357)
* [eas-cli] add create and add existing dist cert options

* nits:

* fix dx
2021-04-22 17:27:17 -07:00
Quinlan Jung 2a283b74a3 [eas-cli][eas-json] add getBuildProfileNamesAsync helper (#351)
* [eas-cli][eas-json] getProfileNames helper

* tweak name

* pr feedback

* pr feedback
2021-04-22 13:47:18 -07:00
Quinlan Jung c749bc2372 [eas-cli] refactor UpdateCredentialsJson (#352)
* [eas-cli] refactor UpdateCredentialsJson

* fix broken tests from switching b64 pprofile test fixture

* fix lint

* add to beta manager
2021-04-22 12:02:45 -07:00
Brent Vatne 9c60f7190e Update CHANGELOG 2021-04-22 10:49:49 -07:00
Brent Vatne 8126b2276e v0.13.0 2021-04-22 10:16:06 -07:00
Dominik Sokal e1de21015f implement SetupInternalProvisioningProfile (#344) 2021-04-22 10:01:35 -07:00
Dominik Sokal 61e505f1f8 fix typo 2021-04-22 16:00:39 +02:00
Wojciech KozyraandDominik Sokal 2e3611161e fix api deprecation error (#359)
* fix api deprecation error

* update CHANGELOG.md

* Update packages/eas-cli/src/build/build.ts

Co-authored-by: Dominik Sokal <[email protected]>

Co-authored-by: Dominik Sokal <[email protected]>
2021-04-22 14:08:25 +02:00
Dominik Sokal 95f5eaaacf update changelog 2021-04-22 11:40:42 +02:00
112 changed files with 3342 additions and 2937 deletions

No files matched your search

+42 -2
View File
@@ -8,6 +8,48 @@ This is the log of notable changes to EAS CLI and related packages.
### 🎉 New features
### 🐛 Bug fixes
- Make the default urql requestPolicy 'network-only' [#397](https://github.com/expo/eas-cli/pull/397) by [@jkhales](https://github.com/jkhales))
### 🧹 Chores
## [0.14.0](https://github.com/expo/eas-cli/releases/tag/v0.14.0) - 2021-05-10
### 🛠 Breaking changes
- Make eas branch:publish work with expo-cli >= 4.4.3 ([#366](https://github.com/expo/eas-cli/pull/366) by [@jkhales](https://github.com/jkhales))
- Create asset keys without an extension. ([#366](https://github.com/expo/eas-cli/pull/366) by [@jkhales](https://github.com/jkhales))
### 🎉 New features
- Release new credentials manager. ([#363](https://github.com/expo/eas-cli/pull/363) by [@quinlanj](https://github.com/quinlanj))
- Add QR code to install internal distribution build on device. ([#371](https://github.com/expo/eas-cli/pull/371) by [@axeldelafosse](https://github.com/axeldelafosse))
### 🧹 Chores
- Cleanup unused code. ([#364](https://github.com/expo/eas-cli/pull/364), [#365](https://github.com/expo/eas-cli/pull/365) by [@quinlanj](https://github.com/quinlanj))
- Redesign UX in beta credentials manager. ([#360](https://github.com/expo/eas-cli/pull/360) by [@quinlanj](https://github.com/quinlanj))
- Port more options to the beta credentials manager. ([#352](https://github.com/expo/eas-cli/pull/352), [357](https://github.com/expo/eas-cli/pull/357), [361](https://github.com/expo/eas-cli/pull/361) by [@quinlanj](https://github.com/quinlanj))
- Add getBuildProfileNamesAsync helper to EasJsonReader. ([#351](https://github.com/expo/eas-cli/pull/351) by [@quinlanj](https://github.com/quinlanj))
- Increase build timeout to 1 hour. ([#370](https://github.com/expo/eas-cli/pull/370) by [@wkozyra95](https://github.com/wkozyra95))
- Remove check for pending builds. ([#373](https://github.com/expo/eas-cli/pull/373) by [@wkozyra95](https://github.com/wkozyra95))
## [0.13.0](https://github.com/expo/eas-cli/releases/tag/v0.13.0) - 2021-04-22
### 🎉 New features
- Implement offline distribution certificate validation when running a build in non-interactive mode. ([#344](https://github.com/expo/eas-cli/pull/344) by [@dsokal](https://github.com/dsokal))
- Add support for building internal distribution apps for Apple Enterprise Teams. ([#344](https://github.com/expo/eas-cli/pull/344) by [@dsokal](https://github.com/dsokal))
### 🐛 Bug fixes
- Display descriptive error message when API for EAS Build changes. ([#359](https://github.com/expo/eas-cli/pull/359) by [@wkozyra95](https://github.com/wkozyra95))
## [0.12.0](https://github.com/expo/eas-cli/releases/tag/v0.12.0) - 2021-04-22
### 🎉 New features
- Add the initiating user's username to the build metadata. ([#354](https://github.com/expo/eas-cli/pull/354) by [@dsokal](https://github.com/dsokal))
- Add `--clear-cache` flag for `eas build`. ([#355](https://github.com/expo/eas-cli/pull/355) by [@wkozyra95](https://github.com/wkozyra95))
@@ -15,8 +57,6 @@ This is the log of notable changes to EAS CLI and related packages.
- Fix the bug where the account name was used as the username. ([#354](https://github.com/expo/eas-cli/pull/354) by [@dsokal](https://github.com/dsokal))
### 🧹 Chores
## [0.11.1](https://github.com/expo/eas-cli/releases/tag/v0.11.1) - 2021-04-20
### 🎉 New features
+1 -1
View File
@@ -1,5 +1,5 @@
{
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.12.0"
"version": "0.14.1"
}
+22 -22
View File
@@ -69,7 +69,7 @@ ALIASES
$ eas login
```
_See code: [build/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/account/login.ts)_
_See code: [build/commands/account/login.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/account/login.ts)_
## `eas account:logout`
@@ -83,7 +83,7 @@ ALIASES
$ eas logout
```
_See code: [build/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/account/logout.ts)_
_See code: [build/commands/account/logout.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/account/logout.ts)_
## `eas account:view`
@@ -97,7 +97,7 @@ ALIASES
$ eas whoami
```
_See code: [build/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/account/view.ts)_
_See code: [build/commands/account/view.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/account/view.ts)_
## `eas analytics [STATUS]`
@@ -108,7 +108,7 @@ USAGE
$ eas analytics [STATUS]
```
_See code: [build/commands/analytics.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/analytics.ts)_
_See code: [build/commands/analytics.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/analytics.ts)_
## `eas build`
@@ -129,7 +129,7 @@ OPTIONS
--[no-]wait Wait for build(s) to complete
```
_See code: [build/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/build/index.ts)_
_See code: [build/commands/build/index.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/build/index.ts)_
## `eas build:cancel [BUILD_ID]`
@@ -140,7 +140,7 @@ USAGE
$ eas build:cancel [BUILD_ID]
```
_See code: [build/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/build/cancel.ts)_
_See code: [build/commands/build/cancel.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/build/cancel.ts)_
## `eas build:configure`
@@ -155,7 +155,7 @@ OPTIONS
--allow-experimental Enable experimental configuration steps.
```
_See code: [build/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/build/configure.ts)_
_See code: [build/commands/build/configure.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/build/configure.ts)_
## `eas build:list`
@@ -171,7 +171,7 @@ OPTIONS
--status=(in-queue|in-progress|errored|finished|canceled)
```
_See code: [build/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/build/list.ts)_
_See code: [build/commands/build/list.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/build/list.ts)_
## `eas build:view [BUILD_ID]`
@@ -182,7 +182,7 @@ USAGE
$ eas build:view [BUILD_ID]
```
_See code: [build/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/build/view.ts)_
_See code: [build/commands/build/view.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/build/view.ts)_
## `eas credentials`
@@ -193,7 +193,7 @@ USAGE
$ eas credentials
```
_See code: [build/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/credentials.ts)_
_See code: [build/commands/credentials.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/credentials.ts)_
## `eas device:create`
@@ -204,7 +204,7 @@ USAGE
$ eas device:create
```
_See code: [build/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/device/create.ts)_
_See code: [build/commands/device/create.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/device/create.ts)_
## `eas device:list`
@@ -218,7 +218,7 @@ OPTIONS
--apple-team-id=apple-team-id
```
_See code: [build/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/device/list.ts)_
_See code: [build/commands/device/list.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/device/list.ts)_
## `eas device:view [UDID]`
@@ -229,7 +229,7 @@ USAGE
$ eas device:view [UDID]
```
_See code: [build/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/device/view.ts)_
_See code: [build/commands/device/view.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/device/view.ts)_
## `eas help [COMMAND]`
@@ -262,7 +262,7 @@ OPTIONS
--value=value Value of the secret
```
_See code: [build/commands/secret/create.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/secret/create.ts)_
_See code: [build/commands/secret/create.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/secret/create.ts)_
## `eas secret:delete`
@@ -279,7 +279,7 @@ DESCRIPTION
Unsure where to find the secret's ID? Run eas secrets:list
```
_See code: [build/commands/secret/delete.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/secret/delete.ts)_
_See code: [build/commands/secret/delete.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/secret/delete.ts)_
## `eas secret:list`
@@ -290,7 +290,7 @@ USAGE
$ eas secret:list
```
_See code: [build/commands/secret/list.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/secret/list.ts)_
_See code: [build/commands/secret/list.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/secret/list.ts)_
## `eas submit --platform=(android|ios)`
@@ -370,7 +370,7 @@ EXAMPLES
and provide its App ID
```
_See code: [build/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/submit.ts)_
_See code: [build/commands/submit.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/submit.ts)_
## `eas webhook:create`
@@ -389,7 +389,7 @@ OPTIONS
--url=url Webhook URL
```
_See code: [build/commands/webhook/create.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/webhook/create.ts)_
_See code: [build/commands/webhook/create.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/webhook/create.ts)_
## `eas webhook:delete [ID]`
@@ -403,7 +403,7 @@ ARGUMENTS
ID ID of the webhook to delete
```
_See code: [build/commands/webhook/delete.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/webhook/delete.ts)_
_See code: [build/commands/webhook/delete.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/webhook/delete.ts)_
## `eas webhook:list`
@@ -417,7 +417,7 @@ OPTIONS
--event=(BUILD) Event type that triggers the webhook
```
_See code: [build/commands/webhook/list.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/webhook/list.ts)_
_See code: [build/commands/webhook/list.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/webhook/list.ts)_
## `eas webhook:update`
@@ -437,7 +437,7 @@ OPTIONS
--url=url Webhook URL
```
_See code: [build/commands/webhook/update.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/webhook/update.ts)_
_See code: [build/commands/webhook/update.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/webhook/update.ts)_
## `eas webhook:view ID`
@@ -451,5 +451,5 @@ ARGUMENTS
ID ID of the webhook to view
```
_See code: [build/commands/webhook/view.ts](https://github.com/expo/eas-cli/blob/v0.12.0/build/commands/webhook/view.ts)_
_See code: [build/commands/webhook/view.ts](https://github.com/expo/eas-cli/blob/v0.14.1/build/commands/webhook/view.ts)_
<!-- commandsstop -->
+1
View File
@@ -3,6 +3,7 @@ schema: 'https://staging.exp.host/--/graphql'
documents:
- 'src/graphql/**/!(*.d).{ts,tsx}'
- 'src/credentials/ios/api/graphql/**/!(*.d).{ts,tsx}'
- 'src/credentials/android/api/graphql/**/!(*.d).{ts,tsx}'
- 'src/commands/**/*.ts'
generates:
src/graphql/generated.ts:
+528 -20
View File
@@ -896,6 +896,22 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "manifestPermalink",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
@@ -1559,6 +1575,55 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "buildOrBuildJobs",
"description": "Coalesced Build (EAS) or BuildJob (Classic) items for this account. Use \"createdBefore\" to offset a query.",
"args": [
{
"name": "limit",
"description": "",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "createdBefore",
"description": " Use a Date to offset queries ",
"type": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INTERFACE",
"name": "BuildOrBuildJob",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "owner",
"description": "Owning User of this account if personal account",
@@ -1977,6 +2042,22 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "stripeId",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "price",
"description": "",
@@ -2861,6 +2942,55 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "buildOrBuildJobs",
"description": "Coalesced Build (EAS) or BuildJob (Classic) items for this app. Use \"createdBefore\" to offset a query.",
"args": [
{
"name": "limit",
"description": "",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "createdBefore",
"description": " Use a Date to offset queries ",
"type": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INTERFACE",
"name": "BuildOrBuildJob",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "submissions",
"description": "EAS Submissions associated with this app",
@@ -4061,11 +4191,54 @@
"kind": "INTERFACE",
"name": "ActivityTimelineProjectActivity",
"ofType": null
},
{
"kind": "INTERFACE",
"name": "BuildOrBuildJob",
"ofType": null
}
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INTERFACE",
"name": "BuildOrBuildJob",
"description": "",
"fields": [
{
"name": "id",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": [
{
"kind": "OBJECT",
"name": "Build",
"ofType": null
},
{
"kind": "OBJECT",
"name": "BuildJob",
"ofType": null
}
]
},
{
"kind": "OBJECT",
"name": "User",
@@ -4275,22 +4448,6 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isEmailUnsubscribed",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isExpoAdmin",
"description": "",
@@ -4348,9 +4505,25 @@
"deprecationReason": null
},
{
"name": "accounts",
"name": "primaryAccount",
"description": "Associated accounts",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "Account",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "accounts",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
@@ -4586,6 +4759,22 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isEmailUnsubscribed",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": true,
"deprecationReason": "No longer supported"
},
{
"name": "lastPasswordReset",
"description": "",
@@ -5599,6 +5788,11 @@
"kind": "INTERFACE",
"name": "ActivityTimelineProjectActivity",
"ofType": null
},
{
"kind": "INTERFACE",
"name": "BuildOrBuildJob",
"ofType": null
}
],
"enumValues": null,
@@ -6042,6 +6236,30 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "androidConfig",
"description": "",
"args": [],
"type": {
"kind": "OBJECT",
"name": "AndroidSubmissionConfig",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "iosConfig",
"description": "",
"args": [],
"type": {
"kind": "OBJECT",
"name": "IosSubmissionConfig",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "logsUrl",
"description": "",
@@ -6110,6 +6328,213 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "AndroidSubmissionConfig",
"description": "",
"fields": [
{
"name": "applicationIdentifier",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "archiveType",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "SubmissionAndroidArchiveType",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "track",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "SubmissionAndroidTrack",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "releaseStatus",
"description": "",
"args": [],
"type": {
"kind": "ENUM",
"name": "SubmissionAndroidReleaseStatus",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "SubmissionAndroidArchiveType",
"description": "",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "APK",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "AAB",
"description": "",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "SubmissionAndroidTrack",
"description": "",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "PRODUCTION",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "INTERNAL",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "ALPHA",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "BETA",
"description": "",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "SubmissionAndroidReleaseStatus",
"description": "",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "DRAFT",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "IN_PROGRESS",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "HALTED",
"description": "",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "COMPLETED",
"description": "",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "IosSubmissionConfig",
"description": "",
"fields": [
{
"name": "ascAppIdentifier",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "appleIdUsername",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "SubmissionError",
@@ -7922,9 +8347,13 @@
"description": "",
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
@@ -8471,6 +8900,16 @@
}
},
"defaultValue": null
},
{
"name": "filter",
"description": null,
"type": {
"kind": "INPUT_OBJECT",
"name": "UpdatesFilter",
"ofType": null
},
"defaultValue": null
}
],
"type": {
@@ -8499,6 +8938,45 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "INPUT_OBJECT",
"name": "UpdatesFilter",
"description": "",
"fields": null,
"inputFields": [
{
"name": "platform",
"description": "",
"type": {
"kind": "ENUM",
"name": "AppPlatform",
"ofType": null
},
"defaultValue": null
},
{
"name": "runtimeVersions",
"description": "",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "EnvironmentSecret",
@@ -15157,6 +15635,16 @@
},
"defaultValue": null
},
{
"name": "clear",
"description": "",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": null
},
{
"name": "key",
"description": "",
@@ -15321,6 +15809,16 @@
"ofType": null
},
"defaultValue": null
},
{
"name": "username",
"description": "",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
@@ -15714,6 +16212,16 @@
},
"defaultValue": null
},
{
"name": "buildConfiguration",
"description": "",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "artifactPath",
"description": "",
+4 -2
View File
@@ -1,7 +1,7 @@
{
"name": "eas-cli",
"description": "EAS command line tool",
"version": "0.12.0",
"version": "0.14.1",
"author": "Expo <[email protected]>",
"bin": {
"eas": "./bin/run"
@@ -14,8 +14,9 @@
"@expo/config": "~3.3.19",
"@expo/config-plugins": "1.0.24",
"@expo/eas-build-job": "0.2.28",
"@expo/eas-json": "^0.12.0",
"@expo/eas-json": "^0.14.0",
"@expo/json-file": "^8.2.24",
"@expo/pkcs12": "^0.0.4",
"@expo/plist": "^0.0.11",
"@expo/plugin-warn-if-update-available": "^1.7.0",
"@expo/results": "^1.0.0",
@@ -41,6 +42,7 @@
"graphql": "^15.3.0",
"graphql-tag": "^2.11.0",
"indent-string": "^4.0.0",
"jks-js": "^1.0.0",
"keychain": "^1.3.0",
"lodash": "^4.17.20",
"mime": "^2.4.7",
@@ -56,7 +56,8 @@ async function prepareJobCommonAsync(
dataBase64: credentials.keystore.keystore,
keystorePassword: credentials.keystore.keystorePassword,
keyAlias: credentials.keystore.keyAlias,
keyPassword: credentials.keystore.keyPassword,
// TODO(quin): this is a hack for pkcs12 keystores which don't actually require a keyPassword
keyPassword: credentials.keystore.keyPassword ?? credentials.keystore.keystorePassword,
},
},
}
+17 -3
View File
@@ -109,10 +109,24 @@ export async function prepareBuildRequestForPlatformAsync<
return undefined;
} else {
try {
return sendBuildRequestAsync(builder, job, metadata);
return await sendBuildRequestAsync(builder, job, metadata);
} catch (error) {
if (error?.expoApiV2ErrorCode === 'TURTLE_DEPRECATED_JOB_FORMAT') {
Log.error('EAS Build API has changed, please upgrade to the latest eas-cli');
if (error?.graphQLErrors?.[0]?.extensions?.errorCode === 'TURTLE_DEPRECATED_JOB_FORMAT') {
Log.error('EAS Build API has changed, please upgrade to the latest eas-cli version.');
throw new Error('Build request failed.');
} else if (
error?.graphQLErrors?.[0]?.extensions?.errorCode === 'EAS_BUILD_TOO_MANY_PENDING_BUILDS'
) {
Log.error(
`You have already reached the maximum number of pending ${
requestedPlatformDisplayNames[job.platform]
} builds for your account. Try again later.`
);
throw new Error('Build request failed.');
} else if (error?.graphQLErrors) {
Log.error(
'Build request failed. Make sure you are using the latest eas-cli version. If the problem persists, please report the issue.'
);
}
throw error;
}
+1 -1
View File
@@ -71,7 +71,7 @@ async function startBuildsAsync(
async function waitForBuildEndAsync(
buildIds: string[],
{ timeoutSec = 1800, intervalSec = 30 } = {}
{ timeoutSec = 3600, intervalSec = 30 } = {}
): Promise<(BuildFragment | null)[]> {
Log.log('Waiting for build to complete. You can press Ctrl+C to exit.');
const spinner = ora().start();
@@ -6,7 +6,7 @@ import { createCredentialsContextAsync } from '../../credentials/context';
import IosCredentialsProvider, {
IosCredentials,
} from '../../credentials/ios/IosCredentialsProvider';
import { getAppLookupParamsFromContext } from '../../credentials/ios/actions/new/BuildCredentialsUtils';
import { getAppLookupParamsFromContext } from '../../credentials/ios/actions/BuildCredentialsUtils';
import { AppLookupParams } from '../../credentials/ios/credentials';
import { CredentialsResult } from '../build';
import { BuildContext } from '../context';
@@ -1,5 +1,7 @@
import assert from 'assert';
import chalk from 'chalk';
import indentString from 'indent-string';
import qrcodeTerminal from 'qrcode-terminal';
import {
BuildError,
@@ -15,7 +17,7 @@ import {
appPlatformEmojis,
requestedPlatformDisplayNames,
} from '../constants';
import { getBuildLogsUrl } from './url';
import { getBuildLogsUrl, getInternalDistributionInstallUrl } from './url';
export function printLogsUrls(
accountName: string,
@@ -82,10 +84,12 @@ function printBuildResult(accountName: string, build: BuildFragment): void {
buildId: build.id,
account: accountName,
});
const installUrl = getInternalDistributionInstallUrl(build);
qrcodeTerminal.generate(installUrl, code => console.log(`${indentString(code, 2)}\n`));
Log.log(
`${appPlatformEmojis[build.platform]} Open this link on your ${
appPlatformDisplayNames[build.platform]
} devices to install the app:`
} devices (or scan the QR code) to install the app:`
);
Log.log(`${chalk.underline(logsUrl)}`);
} else {
+16 -1
View File
@@ -1,4 +1,7 @@
import { getExpoWebsiteBaseUrl } from '../../api';
import assert from 'assert';
import { getExpoApiBaseUrl, getExpoWebsiteBaseUrl } from '../../api';
import { AppPlatform, BuildFragment } from '../../graphql/generated';
export function getBuildLogsUrl({
buildId,
@@ -13,3 +16,15 @@ export function getBuildLogsUrl({
export function getArtifactUrl(artifactId: string): string {
return `${getExpoWebsiteBaseUrl()}/artifacts/${artifactId}`;
}
export function getInternalDistributionInstallUrl(build: BuildFragment): string {
if (build.platform === AppPlatform.Ios) {
return `itms-services://?action=download-manifest;url=${getExpoApiBaseUrl()}/--/api/v2/projects/${
build.project.id
}/builds/${build.id}/manifest.plist`;
}
assert(build.artifacts?.buildUrl, 'buildUrl is missing');
return build.artifacts.buildUrl;
}
+2 -75
View File
@@ -2,7 +2,6 @@ import { ExpoConfig, getConfig } from '@expo/config';
import { Command, flags } from '@oclif/command';
import chalk from 'chalk';
import fs from 'fs-extra';
import nullthrows from 'nullthrows';
import path from 'path';
import {
@@ -13,22 +12,14 @@ import { configureAsync } from '../../build/configure';
import { createCommandContextAsync } from '../../build/context';
import { buildAsync } from '../../build/create';
import { RequestedPlatform } from '../../build/types';
import { formatGraphQLBuild } from '../../build/utils/formatBuild';
import { isGitStatusCleanAsync } from '../../build/utils/repository';
import { AppPlatform } from '../../graphql/generated';
import { BuildQuery } from '../../graphql/queries/BuildQuery';
import Log, { learnMore } from '../../log';
import {
isEasEnabledForProjectAsync,
warnEasUnavailable,
} from '../../project/isEasEnabledForProject';
import {
findProjectRootAsync,
getProjectAccountNameAsync,
getProjectIdAsync,
} from '../../project/projectUtils';
import { findProjectRootAsync, getProjectIdAsync } from '../../project/projectUtils';
import { confirmAsync, promptAsync } from '../../prompts';
import { Actor } from '../../user/User';
import { ensureLoggedInAsync } from '../../user/actions';
export default class Build extends Command {
@@ -71,7 +62,7 @@ export default class Build extends Command {
const { flags } = this.parse(Build);
await initAnalyticsAsync(); // TODO: run in oclif hook for every command
try {
const user = await ensureLoggedInAsync();
await ensureLoggedInAsync();
const nonInteractive = flags['non-interactive'];
if (!flags.platform && nonInteractive) {
@@ -95,17 +86,6 @@ export default class Build extends Command {
return;
}
const accountName = await getProjectAccountNameAsync(exp);
const accountHasPendingBuilds = await ensureNoPendingBuildsExistAsync({
accountName,
platform,
projectId,
user,
});
if (accountHasPendingBuilds) {
return;
}
exp = (await ensureProjectConfiguredAsync(projectDir)) ?? exp;
const commandCtx = await createCommandContextAsync({
@@ -128,49 +108,6 @@ export default class Build extends Command {
}
}
async function ensureNoPendingBuildsExistAsync({
user,
platform,
accountName,
projectId,
}: {
user: Actor;
platform: RequestedPlatform;
accountName: string;
projectId: string;
}): Promise<boolean> {
// allow expo admins to run as many builds as they wish
if (user.isExpoAdmin) {
return false;
}
const appPlatforms = toAppPlatforms(platform);
const maybePendingBuilds = await Promise.all(
appPlatforms.map(appPlatform => BuildQuery.getPendingBuildIdAsync(accountName, appPlatform))
);
const pendingBuilds = maybePendingBuilds.filter(i => i !== null);
if (pendingBuilds.length > 0) {
Log.newLine();
Log.error(
'Your other builds are still pending. Wait for them to complete before running this command again.'
);
Log.newLine();
const results = await Promise.all(
pendingBuilds.map(pendingBuild => {
return BuildQuery.byIdAsync(nullthrows(pendingBuild).id);
})
);
for (const result of results) {
Log.log(formatGraphQLBuild(result));
}
process.exitCode = 1;
return true;
}
return false;
}
function verifyOptionsForLocalBuilds(platform: RequestedPlatform): boolean {
if (platform === RequestedPlatform.All) {
Log.error('Builds for multiple platforms are not supported with flag --local');
@@ -183,16 +120,6 @@ function verifyOptionsForLocalBuilds(platform: RequestedPlatform): boolean {
}
}
function toAppPlatforms(requestedPlatform: RequestedPlatform): AppPlatform[] {
if (requestedPlatform === RequestedPlatform.All) {
return [AppPlatform.Android, AppPlatform.Ios];
} else if (requestedPlatform === RequestedPlatform.Android) {
return [AppPlatform.Android];
} else {
return [AppPlatform.Ios];
}
}
async function promptForPlatformAsync(): Promise<RequestedPlatform> {
const { platform } = await promptAsync({
type: 'select',
@@ -0,0 +1,69 @@
import {
AndroidAppBuildCredentialsFragment,
AndroidKeystoreFragment,
AndroidKeystoreType,
AppFragment,
CommonAndroidAppCredentialsFragment,
} from '../../graphql/generated';
import { testKeystore } from './fixtures-android';
import { testKeystoreBase64 } from './fixtures-base64-data';
export const testAppFragment: AppFragment = {
id: 'test-app-id',
fullName: '@testuser/testapp',
slug: 'testapp',
};
export const testJksAndroidKeystoreFragment: AndroidKeystoreFragment = {
id: 'test-id',
type: AndroidKeystoreType.Jks,
keystore: testKeystoreBase64,
keystorePassword: testKeystore.keystorePassword,
keyAlias: testKeystore.keyAlias,
keyPassword: testKeystore.keyPassword,
md5CertificateFingerprint: 'test-md5',
sha1CertificateFingerprint: 'test-sha1',
sha256CertificateFingerprint: 'test-sha256',
createdAt: new Date(),
updatedAt: new Date(),
};
export const testLegacyAndroidBuildCredentialsFragment: AndroidAppBuildCredentialsFragment = {
id: 'test-id',
isDefault: true,
isLegacy: true,
name: 'legacy',
androidKeystore: testJksAndroidKeystoreFragment,
};
export const testLegacyAndroidAppCredentialsFragment: CommonAndroidAppCredentialsFragment = {
id: 'test-id',
applicationIdentifier: null,
isLegacy: true,
app: testAppFragment,
androidAppBuildCredentialsList: [testLegacyAndroidBuildCredentialsFragment],
};
export const testAndroidBuildCredentialsFragment: AndroidAppBuildCredentialsFragment = {
id: 'test-id',
isDefault: true,
isLegacy: false,
name: 'Google App Store Build Credentials',
androidKeystore: testJksAndroidKeystoreFragment,
};
export const testAndroidAppCredentialsFragment: CommonAndroidAppCredentialsFragment = {
id: 'test-id',
applicationIdentifier: null,
isLegacy: false,
app: testAppFragment,
androidAppBuildCredentialsList: [testLegacyAndroidBuildCredentialsFragment],
};
export function getNewAndroidApiMockWithoutCredentials() {
return {
getAndroidAppCredentialsWithCommonFieldsAsync: jest.fn(),
getLegacyAndroidAppCredentialsWithCommonFieldsAsync: jest.fn(),
createKeystoreAsync: jest.fn(),
};
}
@@ -1,20 +1,33 @@
import { AndroidCredentials } from '../android/credentials';
import { testKeystore2Base64, testKeystoreBase64 } from './fixtures-base64-data';
import { AndroidCredentials, Keystore } from '../android/credentials';
import {
testKeystore2Base64,
testKeystoreBase64,
testPKCS12KeystoreBase64,
} from './fixtures-base64-data';
import { testExperienceName, testJester2ExperienceName } from './fixtures-constants';
export const testKeystore = {
export const testKeystore: Keystore = {
keystore: testKeystoreBase64,
keystorePassword: 'ae6777e9444a436dbe533d2be46c83ba',
keyAlias: 'QHdrb3p5cmEvY3JlZGVudGlhbHMtdGVzdA==',
keyPassword: '43f760fe7ecd4e6a925779eb45bc787b',
};
export const testKeystore2 = {
export const testKeystore2: Keystore = {
keystore: testKeystore2Base64,
keystorePassword: '6faeed2326b94effadbeb731510c2378',
keyAlias: 'QHdrb3p5cmEvY3JlZGVudGlhbHMtdGVzdA==',
keyPassword: 'e4829b38057042d78f25053f390478f9',
};
// Generated by: keytool -genkey -alias test-alias -keystore keystore.p12 -storetype PKCS12 -keyalg RSA -storepass password -validity 730 -keysize 2048
// A Keystore in a PKCS#12 file, where all entries are under aliases
// This particular PKCS#12 has one key and one certificate under 'test-alias'
export const testPKCS12Keystore: Keystore = {
keystore: testPKCS12KeystoreBase64,
keystorePassword: 'password',
keyAlias: 'test-alias',
};
export const testPushCredentials = {
fcmApiKey: 'examplefcmapikey',
};
@@ -4,4 +4,7 @@ export const testKeystoreBase64 =
export const testKeystore2Base64 =
'/u3+7QAAAAIAAAABAAAAAQAkcWhkcmIzcDVjbWV2eTNqbHpndnVkZ2xoYmhtdGRndnpkYT09AAABcpPsjJ8AAAUBMIIE/TAOBgorBgEEASoCEQEBBQAEggTprcWt08cZEZs02fntByaniCbvi9gWiZ7E7sNaEra/NW1fKEJv9fWG/KZryZlnxtYMTXnUtmyX0zI9pYXNd4lBc0QC0Bd2IlGA7vUwGXVTEAOuBtyT4kfENRgoSUoNgfIDU45eDS/A7qXRaQuo6nzyzD4x2je0cjmQCa6IZsRkGFIg9htoPeCdgvA966+nGE4qzlQh56V88IYfG26lLTZZlBLfzPDuOi05KDHn6Kcqg3kRcMOB3XTdtwn9W9h6Xd/M5wYvAhCTTKEu0vlFhhuo9jy8zwBQZCNoo5gLyiUtQqEVjscToBNGfePS6AzprTEDQzXkxypI+FrntiCIFw9PunUGPMyVUwUwr7t6tpjf+W2XGeOJc7Xd92k8FaZqJ0Wi2DVqK8GWorXhZSdxqQnBg0DeZ/kcW30PTH0vIcoIjmEjmwLRr9QIC/rYzdVow35OETmhLYB37+DvmI8xvNCOvz/tbmL7gcSPyfaEwNUD8Ekx7D6dDigmwrkTzmac5pXbx2eluQF8gNrstO7GDTtj0xPR/dWcudXQ+miLk1NFsGj23Y3mzOKjSRJQjHTRURIxQDMfWqLA707yvKc4YWmyM3z+fvbzA9QVJtdFRovjfbQRXEpMcIesP5gXtdi+KUh0pqbrlryX45s6NsY8GjR9LDKpiW9UUXizf58RjI20zFKklbeyCVSJV+dyo7mQi20Jeq4EcTI9QXsLFzBP1Fd/nUx39TK/xfNf2+vtvhRC3pkpG8wG4lw716Oiz6eIaqUtl+LY2Qq6Th8pHXo9OxhTHFJAjMawKF2IkITSoRR2aKBFCJJXo/xpECvfMDx4xKekX+8rJYuqFK6vk0FLob6LdF7DqETQZc3HMJswSyQbWkFR6q6t++pHjkLGNsanGkVIH62HQguXY5/8/X1WTrs3x22FotKVc48UynYnHoftpm5iG9TpSZ+O8jGXdSqonS/5WsYKwW4RWQ3z73Dm5y16ydnatzEu+uYX0DevygiBKrZXQEzGA9wOkMuzCnQ9edLAAfm9g8Ur6Ioj8PtpHnRT7T/1UBH+5mMfXV5BH6ysN3W+/fh4Himri4NU4EvOQgOzybaB24KX2dKNMGV7bA/EFTJvLxTabpcIPzdWDjlpmb/8/Ffmlp5E+zlHx9MMm29BxzN7gLaUOaA6TmxyYUMNRzoulICBSe2OCe6gzR/mwVWcspzUz9U/EU42Nayhc91zbAUzhMqt8z9RHVKZElgXS5+ERjaTMtkPFPxadkONTjesVn0cD4x6K+aQGOM0NKH2VjgQsu8CtV0mWwi55pA03azMf9ol8fOfVGO7JI4pb3HbQM80qVE+9p6NOi29B8jWnoC+J9P9lLYF9lWIUAp4pyg1CBivzOE/RAY2KmbsL0hQYLyQlLKHf2bFx1+SA1JTSL4VsW8CkV4iTzZKNPv0zQj/qCwsHyJLnHVmTO4SugJ++AGJwmUvdeb5BaeJNmNtz+fbtwPkygEwKsMq1zD42X/ss0mCWt20HHkm7r2vFgWNxX7twNsOBTuQZOiHawKswdR3W2684+dFShdDQPwMkrP6AJXzT7vY2Lq4896u5wI2z7HgWVIQemSqt1XA0q4VgIPpa9paaiOQPgiHuqN0vF+GgZt4QHyVBZWib+jF5X+spQ1fRLl1PJWtTPE7/IuPk6DSZ0ad8vpoAAAAAQAFWC41MDkAAANHMIIDQzCCAiugAwIBAgIEI+zyBzANBgkqhkiG9w0BAQsFADBSMQswCQYDVQQGEwJVUzEJMAcGA1UECBMAMQkwBwYDVQQHEwAxCTAHBgNVBAoTADEJMAcGA1UECxMAMRcwFQYDVQQDEw4tLS0tLS0tLS0tLS0tLTAeFw0yMDA2MDgxMjM0MTJaFw00NzEwMjUxMjM0MTJaMFIxCzAJBgNVBAYTAlVTMQkwBwYDVQQIEwAxCTAHBgNVBAcTADEJMAcGA1UEChMAMQkwBwYDVQQLEwAxFzAVBgNVBAMTDi0tLS0tLS0tLS0tLS0tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq3QxHjFwDlkMruqxOMNTbw74Bh6CTBPtlTmcMwLtqk+wWleuv2ZvKn7k0qurOe9/i1AlEa8vzvtxcrrU7tN8EH199/x93MZfVBpU+0SaR9NHIspji7GIGGIF1HFDinaSp5wBwO7h/qVFiAz4lFlIziWL9Bp7d/ubuLgl3ikW7I81oR/7xg9wkXIOryLrLERpFSdCpxl66h07Ir2c8mTuvbIJrJ4aAz323ngo5GRslnW5r1KK5ECLFAOYaeH98AhZ/iiG7c0NDKzmF+qs0wovxvxIDoLiG+fnajdqaYF4BsHj/5Cxn3avs20B8Ey66fa23V7b+xHPGWXYJB7C/+RQoQIDAQABoyEwHzAdBgNVHQ4EFgQU9vep9CVJiMjFH8/Gp4Aqc7VdHyQwDQYJKoZIhvcNAQELBQADggEBAFokeI/CtHVMaPlTmp/NWygwjUyi0oQif3iCOI9sBJY/uFSiqFBfEKnXnXqBeoM2I7fzNkQWMTTvsJ86GJZ8RbpsWY5rpqxH2qCHI65FZOy4+HMQ8fMe6qXi+HJw7V4ITyVnh5NXJmX5ff6MOCZaoeNh2KLo8wG4IXhrbZeY7/SC+v32f5c9vlMDdZTFIpIGOaOaxIQp7fiRFGi7OAQmx5+dpGLmljXJmpDnx9ieKTnjCyEmnHhQt9LIZe4L9NdhqCrHpWvbgONop8dLaeZuR3YjnTA/fQydRTwXxkIBaNgx9VkFNBQ2AzdYvVXz7EkneptJZG+Kf4AL+TeN69HG33ITyr7xLWRWChI0FlE6G3uvvfkVVg==';
export const testPKCS12KeystoreBase64 =
'MIIKIAIBAzCCCdoGCSqGSIb3DQEHAaCCCcsEggnHMIIJwzCCBXAGCSqGSIb3DQEHAaCCBWEEggVdMIIFWTCCBVUGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBRL1ZAQAe2uDgQ/8fOeQM0bkOpjdwICBAAEggTIwbo6AGi+KXBdZL4ysxz829d7mPkEUI1ZAGJHXfJiCrEPj2qRy/fZdurAq0WUGds/kqJYu68q9ZV6x+MkOr99Fm3AB5gBfI6I8yVZl6cdoYJ9jbAXLq3Md4Yx9NE6J7Krz1st/GTRxMlcAfs+aymdAG8XbFEyMkvcFKQD3pmiwklQLbAy+I0z7cyGw4qs3FhqYDcYUCZ/AIAQEm+c10oCX6IFwi2PvmIGU8vXjf99Ee9MkMGPn4m/h2DIIYNfyHYuG7MtG65Wcb9Nc5jLXCXg5BuC4c/cnBS8MkG7MLFLhUyRY6WE5OtEQvXeq2rn8h0Eeb6GTbXqG4ZNNpXle0eRr6x8Id+VjTJGOC9rBCPwznzgLizNM2ZQmbG68XC5ZAHvoFP8r2d5rlzmNiTsGqBuIfiIKANEhdT2aAiCqHhL8WxbgOk4bnNhdQyVBFGPt5FUM9193S9fUOJK3TLMyhTnshO5vI2KxP8kFoE+ePWCltpad6w7KBio150zDRQDbUsVcf4PMgs++r1aN06AkGeqYLBsle3mT7o3IvK04k+gP243O/kPF+jvApEPDOVLVgKG5AQkZEM75L9uAQqcgZ+VidNhz87X3WvVVgBqFzjDkW4/MHFTSxwr5zI7MPjxkeGnjEeINaIkYPdsV3vGHT6RUXodZK+pW8iWaA9JlzuBvoCu6vf88Kwx9mqWKbUC/wejQS1JMscuP/IaQYoLsiCy93puopmkezoZn9EPVCtE0QULoJWdZ0xuWsr4fl/KIMpFr4ivJp+PrBP+PxmuI3RpfaGQfi3p8rMvHqwtkFWtfXFjF9DLHI0R0nUY2bcLCk96RMrqA0hcUCJpzHcxNDcgiXyBMPlACRT5JGv3E7V+1rs/SuDZaGXoijt7G6MhL2zs80OdoWNneozYJ5jMFkLvwI0zYKf8djD4vpMOGzamRnFH3xyq0ACM5RaVOGRQEWp4SFSuUSTSUQrdSi553xevd4WZwwNjCI2Kox/jPn7LzWa69wSAY1ZlgNiW8ISsMvq073IPg9wnp32ShGKAs3ivkpAGcS3HXaMHxEb0/h08kt0ee1039ldncNav0HzNdT+fuGR1spCLyvVEUJ+z3IEzFRje80QSDs2dC6ZjjnoR9CFfp5DulU97qTy04HnHI2UALBZ7VOfkbAmzqQ1+ggY12rQa0htYyw5xcJ/1zbiVyfHaOo4bM0g1kN2XK1YF3cTxnD87OhyZVktE74y22B5+D/LXPUiQP4HxmNMV4vDs4Y/km/RymKrG7U+ju8yVasIYgT6mPfQ5N2NpFtQnEW31siOMAR1PCsYDK/XYHczhuk2HF8bR5U5ev5jLc6qSEyvlAZmBQtJMJVmaLiKbvGQXeMp+v8zbqP4IuynpBts6s4ODT888sAUCrFz2dIBsodowOpxLiKmVOYlXkCpR948GwrjOYOHpBJKKMZB6ec/yT/5dgHGNvFCTnuPPhRDmrHOizmelR3n0xn3mILGEHJmBUPiXy7eZL3PjunUxPrHuvKsQo8oCvo9dJN0EjvjNVyWTjB3mKUL3d7Ce4+DToYyxeAHMv99aQ/8ZxlPkTdBYUSAhixUX2Hl6DN1thCuNNjqdqlmg91koxNmNsXrh6brd6ySPTi0R64E9MUgwIwYJKoZIhvcNAQkUMRYeFAB0AGUAcwB0AC0AYQBsAGkAYQBzMCEGCSqGSIb3DQEJFTEUBBJUaW1lIDE2MDIxNTU3ODIzMzAwggRLBgkqhkiG9w0BBwagggQ8MIIEOAIBADCCBDEGCSqGSIb3DQEHATAoBgoqhkiG9w0BDAEGMBoEFF/lSFudPAx/ZJ2iptxeZUA7a0yOAgIEAICCA/gE1nqwzU9Cw+6I7LHhFi2QZzaK2D5YMgr8xfFP/dxOD0ZUHFia7IJVJIQu22gygm5JB++L6yoptSrFWHVDvm93fQSMo3VW871+NpCqDLSMRk7pVSrwsSOP1HjSVpOQk+QoqjPf1N647SotAGdF3UxU4zQNteuoxN+vryXtA74z2TfQq2QYhLfFMb2vC/bevr2SIECR+b52NjIKoTxni07tzLKF7TOGwZh0HutdpQWS0iBnwHfKU5t0R6Mv8dB3bp9QmhMqqfM4Hj4CtnxzfAtPbfXUJSsx5j42Mhm18rnTFUL0vYQOiWLx6go5kAORSEUa6q64+ga7Zt59e028F1Q8oVviaaeUnJooVhs3kQW+/qT1OqTBWUmichzXbrA1pEedXVzVoQIEVUgbwV29jFjKfX8D9EvQv6P4bUHf9nIQyD66evzYEgNssfe3OT42IyCN/N3f+lzRQAKE3ExBeBIL/f1v3e69V/FygMmEuH6M9jTzcuV5FyC/rCArMLJZ56Zx5dVZcZ7LxTfWPb95atFJ/89FVWrpxhS6xvjOVjWFRc/SjdEju/qMN2NortcNNnnKSDms+BuEmb9gqwj/uuaHY3Q08tQCPwYeZ+4IlWxDR7O7UiEY5KY1I0ath4tWt0t/m6v7juydIOpX+rVdPCHbhZIWmuqMhU6zHb7yH+CzhIhv1E41pt75UPNRPrRCOtZgCCeS1ARp2HkB+D4TrPLKHiII1wLGCFGv/CfYm1feq8fHRItqWW7oCWdXaD234Zhc7vpqZQSjonSpk+6hVNngqzBfj2ZP9ZM/Ot5mkFm3ws0Wtp5IDQ0FXIYdksFzVIY0nRvNcBOlJzu0CmFq/WQQ6CO+Q/ApfV8ybnLSu98t44404NRu0ZNhkXIZ1pdLqb6+k6mzIw9+N/+hxPOvTf33aNnTOb1tEOPYII3t0MFkudox5c7n92+xW/SnijdEiPE6+K8iKPR/DUr2YxSUH24mIy355xgZaVRyViG+JCF1do7Bxx052UYmawTPKyS2RbqE9iXZf7SedAT2ALLwXC39rblRpwl7P+cLeu5if/qoTLDisfmgwlKXEVn8NFOR1vFzFnCZxHDrZ+EH5l9zqkeDtwHfnyeqrDj83VVTPVe4Hr9QXAqDi4kevcjWLW4VBUGsa0+L6021c1aHmWa/gzm//MrDKVS2RZPPfX5f4KUUNX/rYSvnr7vKHZ2FrpiP96w/HaGnuT3A/Nye1UqfPIYYN26L7Vr1dYolsvo2GAdX4x7EjJGpVUt8RPTSj4fcLNqXN6LdpMfrwMlkpl3wSBCoDjAn3jMmeyhic3rIGEYqlf3DpodpUNC4p4Q57rck21A4jjBycCTBZTA9MCEwCQYFKw4DAhoFAAQU3TeAb7mBYAHCMdzxMG9pfxvCLlsEFHO4kStrckWktQa7mPq269mrTHk3AgIEAA==';
export const testProvisioningProfileBase64 = `MIIdDQYJKoZIhvcNAQcCoIIc/jCCHPoCAQExCzAJBgUrDgMCGgUAMIINoAYJKoZIhvcNAQcBoIINkQSCDY08P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJVVEYtOCI/Pgo8IURPQ1RZUEUgcGxpc3QgUFVCTElDICItLy9BcHBsZS8vRFREIFBMSVNUIDEuMC8vRU4iICJodHRwOi8vd3d3LmFwcGxlLmNvbS9EVERzL1Byb3BlcnR5TGlzdC0xLjAuZHRkIj4KPHBsaXN0IHZlcnNpb249IjEuMCI+CjxkaWN0PgoJPGtleT5BcHBJRE5hbWU8L2tleT4KCTxzdHJpbmc+dGVzdGFwcCA8L3N0cmluZz4KCTxrZXk+QXBwbGljYXRpb25JZGVudGlmaWVyUHJlZml4PC9rZXk+Cgk8YXJyYXk+Cgk8c3RyaW5nPlFMNzZYWUg3M1A8L3N0cmluZz4KCTwvYXJyYXk+Cgk8a2V5PkNyZWF0aW9uRGF0ZTwva2V5PgoJPGRhdGU+MjAyMC0wNy0xM1QxMjozNzowM1o8L2RhdGU+Cgk8a2V5PlBsYXRmb3JtPC9rZXk+Cgk8YXJyYXk+CgkJPHN0cmluZz5pT1M8L3N0cmluZz4KCTwvYXJyYXk+Cgk8a2V5PklzWGNvZGVNYW5hZ2VkPC9rZXk+Cgk8ZmFsc2UvPgoJPGtleT5EZXZlbG9wZXJDZXJ0aWZpY2F0ZXM8L2tleT4KCTxhcnJheT4KCQk8ZGF0YT5NSUlGb1RDQ0JJbWdBd0lCQWdJSU9UWW9sUmhEaTlrd0RRWUpLb1pJaHZjTkFRRUxCUUF3Z1pZeEN6QUpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUtEQXBCY0hCc1pTQkpibU11TVN3d0tnWURWUVFMRENOQmNIQnNaU0JYYjNKc1pIZHBaR1VnUkdWMlpXeHZjR1Z5SUZKbGJHRjBhVzl1Y3pGRU1FSUdBMVVFQXd3N1FYQndiR1VnVjI5eWJHUjNhV1JsSUVSbGRtVnNiM0JsY2lCU1pXeGhkR2x2Ym5NZ1EyVnlkR2xtYVdOaGRHbHZiaUJCZFhSb2IzSnBkSGt3SGhjTk1qQXdOekV6TVRJeU5qRTJXaGNOTWpFd056RXpNVEl5TmpFMldqQ0JsREVhTUJnR0NnbVNKb21UOGl4a0FRRU1DbEZNTnpaWVdVZzNNMUF4T2pBNEJnTlZCQU1NTVdsUWFHOXVaU0JFYVhOMGNtbGlkWFJwYjI0NklFRnNhV05xWVNCWFlYSmphR0hGZ2lBb1VVdzNObGhaU0RjelVDa3hFekFSQmdOVkJBc01DbEZNTnpaWVdVZzNNMUF4R0RBV0JnTlZCQW9NRDBGc2FXTnFZU0JYWVhKamFHSEZnakVMTUFrR0ExVUVCaE1DVlZNd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUUNuTUNPT2VqWjEvUjBBTTJ3Sis0cjBDc2F3N0x3N2xFenBTREQ5OUd4TjA2ZkZ3cW1HRnBWdFhsRzhWYUN0cW1sZzl5MzJiMVltd1pJcXJRR3FteVY1cUk4RDJvTzh2QjVvRDJVT3IrUHgzOTQ0YnQyZFFZaUlHQTNlZi81SktZa1E3VDhXWXFQczg3Q1NORnZ5MHhJa1dHbFBpa0dhd0xXcmtzZmJUNFdkMU90dVhiYUtoTEZGNmp5alU0ZCtYN2NoNGtQOFFvdHlkWk5vWmltQTVTYWNtVmRidUM0YTlvQStPL3dscUliaXdiTUtGQlE2Q29tRTFKelpQaWtXMDFoZ1V2T2kvSEtKb0Nsdnp5SmZMLzhZbm43dDRSdUs5bmxHaHNIanJ5b3hFRDdiTGZpcUlKRTllcWlvNTBTK2cycFllWS9tNUh6SW04V1lOZ0RXcjFsTkFnTUJBQUdqZ2dIeE1JSUI3VEFNQmdOVkhSTUJBZjhFQWpBQU1COEdBMVVkSXdRWU1CYUFGSWduRndtcHRoaGdpK3pydXZaSFdjVlNWS08zTUQ4R0NDc0dBUVVGQndFQkJETXdNVEF2QmdnckJnRUZCUWN3QVlZamFIUjBjRG92TDI5amMzQXVZWEJ3YkdVdVkyOXRMMjlqYzNBd015MTNkMlJ5TVRFd2dnRWRCZ05WSFNBRWdnRVVNSUlCRURDQ0FRd0dDU3FHU0liM1kyUUZBVENCL2pDQnd3WUlLd1lCQlFVSEFnSXdnYllNZ2JOU1pXeHBZVzVqWlNCdmJpQjBhR2x6SUdObGNuUnBabWxqWVhSbElHSjVJR0Z1ZVNCd1lYSjBlU0JoYzNOMWJXVnpJR0ZqWTJWd2RHRnVZMlVnYjJZZ2RHaGxJSFJvWlc0Z1lYQndiR2xqWVdKc1pTQnpkR0Z1WkdGeVpDQjBaWEp0Y3lCaGJtUWdZMjl1WkdsMGFXOXVjeUJ2WmlCMWMyVXNJR05sY25ScFptbGpZWFJsSUhCdmJHbGplU0JoYm1RZ1kyVnlkR2xtYVdOaGRHbHZiaUJ3Y21GamRHbGpaU0J6ZEdGMFpXMWxiblJ6TGpBMkJnZ3JCZ0VGQlFjQ0FSWXFhSFIwY0RvdkwzZDNkeTVoY0hCc1pTNWpiMjB2WTJWeWRHbG1hV05oZEdWaGRYUm9iM0pwZEhrdk1CWUdBMVVkSlFFQi93UU1NQW9HQ0NzR0FRVUZCd01ETUIwR0ExVWREZ1FXQkJUTGhSdGRhRVRjRmx4Q0grZnRGQ3d4U3UvZmlUQU9CZ05WSFE4QkFmOEVCQU1DQjRBd0V3WUtLb1pJaHZkalpBWUJCQUVCL3dRQ0JRQXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBSEJxL2VSeitIYTRtemZ0cHZ0SGQ4TTFNb2d0c01UaVNNVDFZK0VGbUQ5UWZYdXdCM3F1ckhQbHFiMjFvV01CWU9TaWcwRDlFZG9Ta29STXAwdU5kaUltVnMycVc0bEgvQ25zL0w1QkhqU2NQc3kwbXUrSitlQjZXZzNXTDduNm1pM3BlOCtxZ2dxak41RVU2YW1Ca04wMmU3Z0pMZnlkcHRSRlBOaklOWFh6bDkxOVNDeUo2VXl3OGFUblBrZFc5eTI1UHgrUHJBSmNDVm1hbFRlYkJvNWxnbUNKejlKUkU3Q3pQd2xmaVBRbUZRMlJVTEpONTBrMmRGSmtESk1jUHd1OFdvUmNBMFE3M21NU256OVNiS21UcHhzeUNEUUo2WHJ5Sm1vKy9aQmEvM0k0dE15dkNBUVQ1alNLWjFrUXJ4c2xFdGJHZE5Bb0xUaUJ6dHY3Wjk0PTwvZGF0YT4KCTwvYXJyYXk+CgoJCQkJCQkJCQkJCgk8a2V5PkVudGl0bGVtZW50czwva2V5PgoJPGRpY3Q+CgkJPGtleT5iZXRhLXJlcG9ydHMtYWN0aXZlPC9rZXk+CgkJPHRydWUvPgoJCQkJCgkJCQk8a2V5PmFwcGxpY2F0aW9uLWlkZW50aWZpZXI8L2tleT4KCQk8c3RyaW5nPlFMNzZYWUg3M1Aub3JnLnJlYWN0anMubmF0aXZlLmV4YW1wbGUudGVzdGFwcC50dXJ0bGV2Mjwvc3RyaW5nPgoJCQkJCgkJCQk8a2V5PmtleWNoYWluLWFjY2Vzcy1ncm91cHM8L2tleT4KCQk8YXJyYXk+CgkJCQk8c3RyaW5nPlFMNzZYWUg3M1AuKjwvc3RyaW5nPgoJCQkJPHN0cmluZz5jb20uYXBwbGUudG9rZW48L3N0cmluZz4KCQk8L2FycmF5PgoJCQkJCgkJCQk8a2V5PmdldC10YXNrLWFsbG93PC9rZXk+CgkJPGZhbHNlLz4KCQkJCQoJCQkJPGtleT5jb20uYXBwbGUuZGV2ZWxvcGVyLnRlYW0taWRlbnRpZmllcjwva2V5PgoJCTxzdHJpbmc+UUw3NlhZSDczUDwvc3RyaW5nPgoJCQkJCgkJCQk8a2V5PmFwcy1lbnZpcm9ubWVudDwva2V5PgoJCTxzdHJpbmc+cHJvZHVjdGlvbjwvc3RyaW5nPgoKCTwvZGljdD4KCTxrZXk+RXhwaXJhdGlvbkRhdGU8L2tleT4KCTxkYXRlPjIwMjEtMDctMTNUMTI6MjY6MTZaPC9kYXRlPgoJPGtleT5OYW1lPC9rZXk+Cgk8c3RyaW5nPm9yZy5yZWFjdGpzLm5hdGl2ZS5leGFtcGxlLnRlc3RhcHAudHVydGxldjIgcHJvZmlsPC9zdHJpbmc+Cgk8a2V5PlRlYW1JZGVudGlmaWVyPC9rZXk+Cgk8YXJyYXk+CgkJPHN0cmluZz5RTDc2WFlINzNQPC9zdHJpbmc+Cgk8L2FycmF5PgoJPGtleT5UZWFtTmFtZTwva2V5PgoJPHN0cmluZz5BbGljamEgV2FyY2hhxYI8L3N0cmluZz4KCTxrZXk+VGltZVRvTGl2ZTwva2V5PgoJPGludGVnZXI+MzY0PC9pbnRlZ2VyPgoJPGtleT5VVUlEPC9rZXk+Cgk8c3RyaW5nPjQ1NjBiNTU1LWFhODMtNDRiNy1iYjMxLTAwMGIwMDZjNDM2ZDwvc3RyaW5nPgoJPGtleT5WZXJzaW9uPC9rZXk+Cgk8aW50ZWdlcj4xPC9pbnRlZ2VyPgo8L2RpY3Q+CjwvcGxpc3Q+oIIMsjCCA/MwggLboAMCAQICARcwDQYJKoZIhvcNAQEFBQAwYjELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkFwcGxlIEluYy4xJjAkBgNVBAsTHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRYwFAYDVQQDEw1BcHBsZSBSb290IENBMB4XDTA3MDQxMjE3NDMyOFoXDTIyMDQxMjE3NDMyOFoweTELMAkGA1UEBhMCVVMxE Line truncated
@@ -34,6 +34,7 @@ export const testAppJson = {
slug: testSlug,
sdkVersion: '38.0.0',
ios: { bundleIdentifier: testBundleIdentifier },
android: { package: testPackageName },
};
export const testAppJsonWithDifferentOwner = {
@@ -3,17 +3,18 @@ import merge from 'lodash/merge';
import { CredentialsManager } from '../CredentialsManager';
import { Context } from '../context';
import { getAndroidApiMockWithoutCredentials } from './fixtures-android';
import { getNewAndroidApiMockWithoutCredentials } from './fixtures-android-new';
import { getAppstoreMock } from './fixtures-appstore';
import { testAppJson, testUsername } from './fixtures-constants';
import { getIosApiMockWithoutCredentials } from './fixtures-ios';
import { getNewIosApiMockWithoutCredentials } from './fixtures-new-ios';
import { getNewIosApiMockWithoutCredentials } from './fixtures-ios';
export function createCtxMock(mockOverride: Record<string, any> = {}): Context {
const defaultMock = {
ios: getIosApiMockWithoutCredentials(),
newIos: getNewIosApiMockWithoutCredentials(),
ios: getNewIosApiMockWithoutCredentials(),
android: getAndroidApiMockWithoutCredentials(),
newAndroid: getNewAndroidApiMockWithoutCredentials(),
appStore: getAppstoreMock(),
bestEffortAppStoreAuthenticateAsync: jest.fn(),
ensureAppleCtx: jest.fn(),
ensureProjectContext: jest.fn(),
user: {
@@ -4,45 +4,25 @@ import {
AppleDistributionCertificateFragment,
AppleProvisioningProfileFragment,
AppleTeamFragment,
CommonIosAppCredentialsFragment,
IosAppBuildCredentialsFragment,
IosDistributionType,
} from '../../graphql/generated';
import { IosAppCredentialsWithBuildCredentialsQueryResult } from '../ios/api/graphql/queries/IosAppCredentialsQuery';
import {
DistributionCertificate,
DistributionCertificateStoreInfo,
ProvisioningProfile,
ProvisioningProfileStoreInfo,
PushKey,
PushKeyStoreInfo,
} from '../ios/appstore/Credentials.types';
import { IosDistCredentials, IosPushCredentials } from '../ios/credentials';
import { testProvisioningProfileBase64 } from './fixtures-base64-data';
import { testBundleIdentifier, testExperienceName } from './fixtures-constants';
const today = new Date();
const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
export const testAppleTeam = {
id: 'test-team-id',
};
export const testProvisioningProfile: ProvisioningProfile = {
provisioningProfileId: 'test-id',
provisioningProfile: testProvisioningProfileBase64,
teamId: 'id',
};
export const testProvisioningProfiles = [testProvisioningProfile];
export const testProvisioningProfileFromApple: ProvisioningProfileStoreInfo = {
name: 'test-name',
status: 'Active',
expires: tomorrow.getTime(),
distributionMethod: 'test',
certificates: [],
provisioningProfileId: testProvisioningProfile.provisioningProfileId,
provisioningProfile: testProvisioningProfile.provisioningProfile,
teamId: 'id',
};
export const testProvisioningProfilesFromApple = [testProvisioningProfileFromApple];
export const testAppleTeamFragment: AppleTeamFragment = {
id: 'test-apple-team-id-1',
@@ -64,7 +44,7 @@ export const testProvisioningProfileFragment: AppleProvisioningProfileFragment =
id: 'test-prov-prof-id-1',
expiration: new Date(),
developerPortalIdentifier: 'test-developer-identifier',
provisioningProfile: 'test-provisioning-profile',
provisioningProfile: testProvisioningProfileBase64,
updatedAt: new Date(),
status: 'Active',
appleTeam: { ...testAppleTeamFragment },
@@ -117,11 +97,61 @@ export const testIosAppBuildCredentialsFragment: IosAppBuildCredentialsFragment
provisioningProfile: testProvisioningProfileFragment,
};
export const testCommonIosAppCredentialsFragment: CommonIosAppCredentialsFragment = {
id: 'test-common-ios-app-credentials-id',
app: testAppFragment,
appleTeam: testAppleTeamFragment,
appleAppIdentifier: testAppleAppIdentifierFragment,
iosAppBuildCredentialsList: [testIosAppBuildCredentialsFragment],
};
export const testIosAppCredentialsWithBuildCredentialsQueryResult: IosAppCredentialsWithBuildCredentialsQueryResult = {
id: 'test-app-credential-id',
iosAppBuildCredentialsArray: [testIosAppBuildCredentialsFragment],
iosAppBuildCredentialsList: [testIosAppBuildCredentialsFragment],
};
export const testAppleTeam = {
id: 'test-team-id',
};
export function getNewIosApiMockWithoutCredentials() {
return {
createOrUpdateIosAppBuildCredentialsAsync: jest.fn(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(),
createOrGetExistingIosAppCredentialsWithBuildCredentialsAsync: jest.fn(),
createOrGetExistingAppleTeamAsync: () => testAppleTeam,
createOrGetExistingAppleAppIdentifierAsync: jest.fn(),
getDevicesForAppleTeamAsync: jest.fn(),
createProvisioningProfileAsync: jest.fn(),
getProvisioningProfileAsync: jest.fn(),
updateProvisioningProfileAsync: jest.fn(),
deleteProvisioningProfilesAsync: jest.fn(),
getDistributionCertificateForAppAsync: jest.fn(),
getDistributionCertificatesForAccountAsync: jest.fn(),
createDistributionCertificateAsync: jest.fn(),
deleteDistributionCertificateAsync: jest.fn(),
};
}
export function getNewIosApiMockWithCredentials() {
return {
createOrUpdateIosAppBuildCredentialsAsync: jest.fn(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(),
createOrGetExistingIosAppCredentialsWithBuildCredentialsAsync: jest.fn(),
createOrGetExistingAppleTeamAsync: jest.fn(),
createOrGetExistingAppleAppIdentifierAsync: jest.fn(),
getDevicesForAppleTeamAsync: jest.fn(),
createProvisioningProfileAsync: jest.fn(),
getProvisioningProfileAsync: jest.fn(),
updateProvisioningProfileAsync: jest.fn(),
deleteProvisioningProfilesAsync: jest.fn(),
getDistributionCertificateForAppAsync: jest.fn(),
getDistributionCertificatesForAccountAsync: jest.fn(),
createDistributionCertificateAsync: jest.fn(),
deleteDistributionCertificateAsync: jest.fn(),
};
}
export const testDistCert: DistributionCertificate = {
certP12: 'Y2VydHAxMg==',
certPassword: 'test-password',
@@ -133,18 +163,6 @@ export const testIosDistCredential: IosDistCredentials = {
type: 'dist-cert',
...testDistCert,
};
export const testIosDistCredentials = [testIosDistCredential];
export const testDistCertFromApple: DistributionCertificateStoreInfo = {
id: 'test-id',
name: 'test-name',
status: 'Active',
created: today.getTime(),
expires: tomorrow.getTime(),
ownerName: 'test-owner',
ownerId: 'test-id',
serialNumber: testIosDistCredential.distCertSerialNumber as string,
};
export const testDistCertsFromApple = [testDistCertFromApple];
export const testPushKey: PushKey = {
apnsKeyP8: 'test-p8',
@@ -152,22 +170,16 @@ export const testPushKey: PushKey = {
teamId: 'test-team-id',
};
/**
* Legacy format fixtures
*/
export const testIosPushCredential: IosPushCredentials = {
id: 2,
type: 'push-key',
...testPushKey,
};
export const testIosPushCredentials = [testIosPushCredential];
export const testPushKeyFromApple: PushKeyStoreInfo = {
id: testIosPushCredential.apnsKeyId,
name: 'test-name',
};
export const testPushKeysFromApple = [testPushKeyFromApple];
export const testLegacyPushCert = {
pushId: 'test-push-id',
pushP12: 'test-push-p12',
pushPassword: 'test-push-password',
};
export const testAppCredential = {
experienceName: testExperienceName,
bundleIdentifier: testBundleIdentifier,
@@ -182,62 +194,3 @@ export const testAllCredentialsForApp = {
pushCredentials: testPushKey,
distCredentials: testDistCert,
};
export const testAppCredentials = [testAppCredential];
export const testAllCredentials = {
userCredentials: [...testIosDistCredentials, ...testIosPushCredentials],
appCredentials: testAppCredentials,
};
export function getIosApiMock() {
return {
getAllCredentials: jest.fn(() => testAllCredentials),
getDistributionCertificateAsync: jest.fn(() => testIosDistCredential),
getDistributionCertificateByIdAsync: jest.fn(id =>
id === testIosDistCredential.id ? testIosDistCredential : null
),
createDistributionCertificateAsync: jest.fn((owner, cert) => ({
id: 123,
type: 'dist-cert',
...cert,
})),
updateDistributionCertificateAsync: jest.fn(),
deleteDistributionCertificateAsync: jest.fn(),
useDistributionCertificateAsync: jest.fn(),
getPushKey: jest.fn(() => testIosPushCredential),
createPushKeyAsync: jest.fn((owner, key) => ({ id: 124, type: 'push-key', ...key })),
updatePushKeyAsync: jest.fn(),
deletePushKeyAsync: jest.fn(),
usePushKeyAsync: jest.fn(),
getAppCredentialsAsync: jest.fn(() => testAppCredentials),
getProvisioningProfileAsync: jest.fn(() => testProvisioningProfile),
updateProvisioningProfileAsync: jest.fn(),
deleteProvisioningProfileAsync: jest.fn(),
};
}
export function getIosApiMockWithoutCredentials() {
return {
getAllCredentials: jest.fn(() => ({ appCredentials: [], userCredentials: [] })),
getDistributionCertificateAsync: jest.fn(() => null),
getDistributionCertificateByIdAsync: jest.fn(() => {
throw new Error('not found');
}),
createDistributionCertificateAsync: jest.fn(),
updateDistributionCertificateAsync: jest.fn(),
deleteDistributionCertificateAsync: jest.fn(),
useDistributionCertificateAsync: jest.fn(),
getPushKeyAsync: jest.fn(() => null),
createPushKeyAsync: jest.fn(),
updatePushKeyAsync: jest.fn(),
deletePushKeyAsync: jest.fn(),
usePushKeyAsync: jest.fn(),
getAppCredentialsAsync: jest.fn(app => ({
experienceName: `${app.accountName}/${app.projectName}`,
bundleIdentifier: app.bundleIdentifier,
})),
getProvisioningProfileAsync: jest.fn(() => null),
updateProvisioningProfileAsync: jest.fn(),
deleteProvisioningProfileAsync: jest.fn(),
};
}
@@ -1,141 +0,0 @@
import {
DistributionCertificate,
DistributionCertificateStoreInfo,
ProvisioningProfile,
ProvisioningProfileStoreInfo,
PushKey,
PushKeyStoreInfo,
} from '../ios/appstore/Credentials.types';
import { IosDistCredentials, IosPushCredentials } from '../ios/credentials';
import { testProvisioningProfileBase64 } from './fixtures-base64-data';
import { testBundleIdentifier, testExperienceName } from './fixtures-constants';
const today = new Date();
const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
export const testAppleTeam = {
id: 'test-team-id',
};
export const testProvisioningProfile: ProvisioningProfile = {
provisioningProfileId: 'test-id',
provisioningProfile: testProvisioningProfileBase64,
teamId: 'id',
};
export const testProvisioningProfiles = [testProvisioningProfile];
export const testProvisioningProfileFromApple: ProvisioningProfileStoreInfo = {
name: 'test-name',
status: 'Active',
expires: tomorrow.getTime(),
distributionMethod: 'test',
certificates: [],
provisioningProfileId: testProvisioningProfile.provisioningProfileId,
provisioningProfile: testProvisioningProfile.provisioningProfile,
teamId: 'id',
};
export const testProvisioningProfilesFromApple = [testProvisioningProfileFromApple];
export const testDistCert: DistributionCertificate = {
certP12: 'Y2VydHAxMg==',
certPassword: 'test-password',
distCertSerialNumber: 'test-serial',
teamId: 'test-team-id',
};
export const testIosDistCredential: IosDistCredentials = {
id: 1,
type: 'dist-cert',
...testDistCert,
};
export const testIosDistCredentials = [testIosDistCredential];
export const testDistCertFromApple: DistributionCertificateStoreInfo = {
id: 'test-id',
name: 'test-name',
status: 'Active',
created: today.getTime(),
expires: tomorrow.getTime(),
ownerName: 'test-owner',
ownerId: 'test-id',
serialNumber: testIosDistCredential.distCertSerialNumber as string,
};
export const testDistCertsFromApple = [testDistCertFromApple];
export const testPushKey: PushKey = {
apnsKeyP8: 'test-p8',
apnsKeyId: 'test-key-id',
teamId: 'test-team-id',
};
export const testIosPushCredential: IosPushCredentials = {
id: 2,
type: 'push-key',
...testPushKey,
};
export const testIosPushCredentials = [testIosPushCredential];
export const testPushKeyFromApple: PushKeyStoreInfo = {
id: testIosPushCredential.apnsKeyId,
name: 'test-name',
};
export const testPushKeysFromApple = [testPushKeyFromApple];
export const testLegacyPushCert = {
pushId: 'test-push-id',
pushP12: 'test-push-p12',
pushPassword: 'test-push-password',
};
export const testAppCredential = {
experienceName: testExperienceName,
bundleIdentifier: testBundleIdentifier,
distCredentialsId: testIosDistCredential.id,
pushCredentialsId: testIosPushCredential.id,
credentials: {
...testProvisioningProfile,
},
};
export const testAllCredentialsForApp = {
...testAppCredential,
pushCredentials: testPushKey,
distCredentials: testDistCert,
};
export const testAppCredentials = [testAppCredential];
export const testAllCredentials = {
userCredentials: [...testIosDistCredentials, ...testIosPushCredentials],
appCredentials: testAppCredentials,
};
export function getNewIosApiMockWithoutCredentials() {
return {
getAppAsync: jest.fn(),
createOrUpdateIosAppBuildCredentialsAsync: jest.fn(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(),
createOrGetExistingIosAppCredentialsWithBuildCredentialsAsync: jest.fn(),
createOrGetExistingAppleTeamAsync: () => testAppleTeam,
createOrGetExistingAppleAppIdentifierAsync: jest.fn(),
getDevicesForAppleTeamAsync: jest.fn(),
createProvisioningProfileAsync: jest.fn(),
getProvisioningProfileAsync: jest.fn(),
updateProvisioningProfileAsync: jest.fn(),
deleteProvisioningProfilesAsync: jest.fn(),
getDistributionCertificateForAppAsync: jest.fn(),
getDistributionCertificatesForAccountAsync: jest.fn(),
createDistributionCertificateAsync: jest.fn(),
deleteDistributionCertificateAsync: jest.fn(),
};
}
export function getNewIosApiMockWithCredentials() {
return {
getAppAsync: jest.fn(),
createOrUpdateIosAppBuildCredentialsAsync: jest.fn(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(),
createOrGetExistingIosAppCredentialsWithBuildCredentialsAsync: jest.fn(),
createOrGetExistingAppleTeamAsync: jest.fn(),
createOrGetExistingAppleAppIdentifierAsync: jest.fn(),
getDevicesForAppleTeamAsync: jest.fn(),
createProvisioningProfileAsync: jest.fn(),
getProvisioningProfileAsync: jest.fn(),
updateProvisioningProfileAsync: jest.fn(),
deleteProvisioningProfilesAsync: jest.fn(),
getDistributionCertificateForAppAsync: jest.fn(),
getDistributionCertificatesForAccountAsync: jest.fn(),
createDistributionCertificateAsync: jest.fn(),
deleteDistributionCertificateAsync: jest.fn(),
};
}
@@ -0,0 +1,25 @@
import { getProjectAccountName, getProjectConfigDescription } from '../../../project/projectUtils';
import { findAccountByName } from '../../../user/Account';
import { Context } from '../../context';
import { AppLookupParams } from '../api/GraphqlClient';
export function getAppLookupParamsFromContext(ctx: Context): AppLookupParams {
ctx.ensureProjectContext();
const projectName = ctx.exp.slug;
const accountName = getProjectAccountName(ctx.exp, ctx.user);
const account = findAccountByName(ctx.user.accounts, accountName);
if (!account) {
throw new Error(`You do not have access to account: ${accountName}`);
}
const androidApplicationIdentifier = ctx.exp.android?.package;
if (!androidApplicationIdentifier) {
throw new Error(
`android.package needs to be defined in your ${getProjectConfigDescription(
ctx.projectDir
)} file`
);
}
return { account, projectName, androidApplicationIdentifier };
}
@@ -0,0 +1,31 @@
import { AndroidKeystoreFragment } from '../../../../graphql/generated';
import Log from '../../../../log';
import { Account } from '../../../../user/Account';
import { Context } from '../../../context';
import { askForUserProvidedAsync } from '../../../utils/promptForCredentials';
import { KeystoreWithType, keystoreSchema } from '../../credentials';
import { generateRandomKeystoreAsync } from '../../utils/keystore';
import { getKeystoreWithType, validateKeystore } from '../../utils/keystoreNew';
export class CreateKeystore {
constructor(private account: Account) {}
public async runAsync(ctx: Context): Promise<AndroidKeystoreFragment> {
if (ctx.nonInteractive) {
throw new Error(`New keystore cannot be created in non-interactive mode.`);
}
const keystore = await this.provideOrGenerateAsync();
const keystoreFragment = await ctx.newAndroid.createKeystoreAsync(this.account, keystore);
Log.succeed('Created keystore');
return keystoreFragment;
}
private async provideOrGenerateAsync(): Promise<KeystoreWithType> {
const providedKeystore = await askForUserProvidedAsync(keystoreSchema);
if (providedKeystore) {
const providedKeystoreWithType = getKeystoreWithType(providedKeystore);
validateKeystore(providedKeystoreWithType);
}
return await generateRandomKeystoreAsync();
}
}
@@ -0,0 +1,27 @@
import { confirmAsync } from '../../../../../prompts';
import { createCtxMock } from '../../../../__tests__/fixtures-context';
import { getAppLookupParamsFromContext } from '../../BuildCredentialsUtils';
import { CreateKeystore } from '../CreateKeystore';
jest.mock('../../../../../prompts');
(confirmAsync as jest.Mock).mockImplementation(() => true);
describe('CreateKeystore', () => {
it('creates a keystore in Interactive Mode', async () => {
const ctx = createCtxMock({ nonInteractive: false });
const appLookupParams = getAppLookupParamsFromContext(ctx);
const createKeystoreAction = new CreateKeystore(appLookupParams.account);
await createKeystoreAction.runAsync(ctx);
// expect keystore to be created on expo servers
expect(ctx.newAndroid.createKeystoreAsync as any).toHaveBeenCalledTimes(1);
});
it('errors in Non-Interactive Mode', async () => {
const ctx = createCtxMock({ nonInteractive: true });
const appLookupParams = getAppLookupParamsFromContext(ctx);
const createKeystoreAction = new CreateKeystore(appLookupParams.account);
// fail if users are running in non-interactive mode
await expect(createKeystoreAction.runAsync(ctx)).rejects.toThrowError();
});
});
@@ -0,0 +1,60 @@
import {
AndroidKeystoreFragment,
CommonAndroidAppCredentialsFragment,
} from '../../../graphql/generated';
import { Account } from '../../../user/Account';
import { KeystoreWithType } from '../credentials';
import { AndroidKeystoreMutation } from './graphql/mutations/AndroidKeystoreMutation';
import { AndroidAppCredentialsQuery } from './graphql/queries/AndroidAppCredentialsQuery';
export interface AppLookupParams {
account: Account;
projectName: string;
androidApplicationIdentifier: string; // 'android.package' field in app.json
}
export async function getAndroidAppCredentialsWithCommonFieldsAsync(
appLookupParams: AppLookupParams
): Promise<CommonAndroidAppCredentialsFragment | null> {
const { androidApplicationIdentifier } = appLookupParams;
const projectFullName = formatProjectFullName(appLookupParams);
return await AndroidAppCredentialsQuery.withCommonFieldsByApplicationIdentifierAsync(
projectFullName,
{
androidApplicationIdentifier,
legacyOnly: false,
}
);
}
/* There is at most one set of legacy android app credentials associated with an Expo App */
export async function getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
appLookupParams: AppLookupParams
): Promise<CommonAndroidAppCredentialsFragment | null> {
const projectFullName = formatProjectFullName(appLookupParams);
return await AndroidAppCredentialsQuery.withCommonFieldsByApplicationIdentifierAsync(
projectFullName,
{
legacyOnly: true,
}
);
}
export async function createKeystoreAsync(
account: Account,
keystore: KeystoreWithType
): Promise<AndroidKeystoreFragment> {
return await AndroidKeystoreMutation.createAndroidKeystore(
{
base64EncodedKeystore: keystore.keystore,
keystorePassword: keystore.keystorePassword,
keyAlias: keystore.keyAlias,
keyPassword: keystore.keyPassword,
type: keystore.type,
},
account.id
);
}
const formatProjectFullName = ({ account, projectName }: AppLookupParams): string =>
`@${account.name}/${projectName}`;
@@ -0,0 +1,59 @@
import assert from 'assert';
import { print } from 'graphql';
import gql from 'graphql-tag';
import { graphqlClient, withErrorHandlingAsync } from '../../../../../graphql/client';
import {
AndroidKeystoreFragment,
AndroidKeystoreType,
CreateAndroidKeystoreMutation,
} from '../../../../../graphql/generated';
import { AndroidKeystoreFragmentNode } from '../../../../../graphql/types/credentials/AndroidKeystore';
const AndroidKeystoreMutation = {
async createAndroidKeystore(
androidKeystoreInput: {
base64EncodedKeystore: string;
keystorePassword: string;
keyAlias: string;
keyPassword?: string;
type: AndroidKeystoreType;
},
accountId: string
): Promise<AndroidKeystoreFragment> {
const data = await withErrorHandlingAsync(
graphqlClient
.mutation<CreateAndroidKeystoreMutation>(
gql`
mutation CreateAndroidKeystoreMutation(
$androidKeystoreInput: AndroidKeystoreInput!
$accountId: ID!
) {
androidKeystore {
createAndroidKeystore(
androidKeystoreInput: $androidKeystoreInput
accountId: $accountId
) {
id
...AndroidKeystoreFragment
}
}
}
${print(AndroidKeystoreFragmentNode)}
`,
{
androidKeystoreInput,
accountId,
}
)
.toPromise()
);
assert(
data.androidKeystore.createAndroidKeystore,
'GraphQL: `createAndroidKeystore` not defined in server response'
);
return data.androidKeystore.createAndroidKeystore;
},
};
export { AndroidKeystoreMutation };
@@ -0,0 +1,65 @@
import assert from 'assert';
import { print } from 'graphql';
import gql from 'graphql-tag';
import { graphqlClient, withErrorHandlingAsync } from '../../../../../graphql/client';
import {
CommonAndroidAppCredentialsFragment,
CommonAndroidAppCredentialsWithBuildCredentialsByApplicationIdentifierQuery,
} from '../../../../../graphql/generated';
import { CommonAndroidAppCredentialsFragmentNode } from '../../../../../graphql/types/credentials/AndroidAppCredentials';
const AndroidAppCredentialsQuery = {
async withCommonFieldsByApplicationIdentifierAsync(
projectFullName: string,
{
androidApplicationIdentifier,
legacyOnly,
}: {
androidApplicationIdentifier?: string;
legacyOnly?: boolean;
}
): Promise<CommonAndroidAppCredentialsFragment | null> {
const data = await withErrorHandlingAsync(
graphqlClient
.query<CommonAndroidAppCredentialsWithBuildCredentialsByApplicationIdentifierQuery>(
gql`
query CommonAndroidAppCredentialsWithBuildCredentialsByApplicationIdentifierQuery(
$projectFullName: String!
$applicationIdentifier: String
$legacyOnly: Boolean
) {
app {
byFullName(fullName: $projectFullName) {
id
androidAppCredentials(
filter: {
applicationIdentifier: $applicationIdentifier
legacyOnly: $legacyOnly
}
) {
id
...CommonAndroidAppCredentialsFragment
}
}
}
}
${print(CommonAndroidAppCredentialsFragmentNode)}
`,
{
projectFullName,
applicationIdentifier: androidApplicationIdentifier,
legacyOnly,
},
{
additionalTypenames: ['AndroidAppCredentials', 'AndroidAppBuildCredentials', 'App'],
}
)
.toPromise()
);
assert(data.app, 'GraphQL: `app` not defined in server response');
return data.app.byFullName.androidAppCredentials[0] ?? null;
},
};
export { AndroidAppCredentialsQuery };
@@ -1,3 +1,4 @@
import { AndroidKeystoreType } from '../../graphql/generated';
import { CredentialSchema } from '../utils/promptForCredentials';
export interface FcmCredentials {
@@ -8,9 +9,13 @@ export interface Keystore {
keystore: string;
keystorePassword: string;
keyAlias: string;
keyPassword: string;
keyPassword?: string;
}
export type KeystoreWithType = Keystore & {
type: AndroidKeystoreType;
};
export type AndroidCredentials = {
experienceName: string;
keystore: Keystore | null;
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`print credentials prints the AndroidAppCredentials fragment 1`] = `"Android Credentials Project: testApp Application Identifier: test.com.app EAS Credentials: These will take precedence over Expo Classic credentials Configuration: legacy (Default) Keystore: Type: JKS Key Alias: QHdrb3p5cmEvY3JlZGVudGlhbHMtdGVzdA== MD5 Fingerprint: TE:ST:-M:D5 SHA1 Fingerprint: TE:ST:-S:HA:1 SHA256 Fingerprint: TE:ST:-S:HA:25:6 Updated 0 second ago Credentials ported from Expo Classic (expo-cli): Keystore: Type: JKS Key Alias: QHdrb3p5cmEvY3JlZGVudGlhbHMtdGVzdA== MD5 Fingerprint: TE:ST:-M:D5 SHA1 Fingerprint: TE:ST:-S:HA:1 SHA256 Fingerprint: TE:ST:-S:HA:25:6 Updated 0 second ago"`;
@@ -0,0 +1,64 @@
import { AndroidKeystoreType } from '../../../../graphql/generated';
import { testKeystore, testPKCS12Keystore } from '../../../__tests__/fixtures-android';
import { getKeystoreType, getKeystoreWithType, validateKeystore } from '../keystoreNew';
describe('getKeystoreType', () => {
it('identifies a valid jks keystore', async () => {
const type = getKeystoreType(testKeystore);
expect(type).toBe(AndroidKeystoreType.Jks);
});
it('identifies a valid pkcs12 keystore', async () => {
const type = getKeystoreType(testPKCS12Keystore);
expect(type).toBe(AndroidKeystoreType.Pkcs12);
});
it('identifies a jks keystore with bad password as unknown', async () => {
const keystoreWithType = getKeystoreType({
...testKeystore,
keystorePassword: 'not-the-password',
});
expect(keystoreWithType).toBe(AndroidKeystoreType.Unknown);
});
it('identifies a pkcs keystore with bad password as unknown', async () => {
const keystoreWithType = getKeystoreType({
...testPKCS12Keystore,
keystorePassword: 'not-the-password',
});
expect(keystoreWithType).toBe(AndroidKeystoreType.Unknown);
});
it('identifies a bogus keystore as unknown', async () => {
const type = getKeystoreType({ ...testKeystore, keystore: 'sdfsdfsdfdsfsfdsf' });
expect(type).toBe(AndroidKeystoreType.Unknown);
});
});
describe('validateKeystore', () => {
it('validates a correctly formatted jks keystore', async () => {
const keystoreWithType = getKeystoreWithType(testKeystore);
expect(() => validateKeystore(keystoreWithType)).not.toThrow();
});
it('doesnt validate a jks keystore with wrong alias', async () => {
const keystoreWithType = getKeystoreWithType({
...testKeystore,
keyAlias: 'non-existent-alias',
});
expect(() => validateKeystore(keystoreWithType)).toThrow();
});
it('doesnt validate a jks keystore with wrong key password', async () => {
const keystoreWithType = getKeystoreWithType({
...testKeystore,
keyPassword: 'not-the-password',
});
expect(() => validateKeystore(keystoreWithType)).toThrow();
});
it('validates a correctly formatted pkcs 12 keystore', async () => {
const keystoreWithType = getKeystoreWithType(testPKCS12Keystore);
expect(() => validateKeystore(keystoreWithType)).not.toThrow();
});
it('doesnt validate a PKCS 12 keystore with wrong alias', async () => {
const keystoreWithType = getKeystoreWithType({
...testPKCS12Keystore,
keyAlias: 'non-existent-alias',
});
expect(() => validateKeystore(keystoreWithType)).toThrow();
});
});
@@ -0,0 +1,31 @@
import mockdate from 'mockdate';
import Log from '../../../../log';
import {
testAndroidAppCredentialsFragment,
testLegacyAndroidAppCredentialsFragment,
} from '../../../__tests__/fixtures-android-new';
import { createCtxMock } from '../../../__tests__/fixtures-context';
import { getAppLookupParamsFromContext } from '../../actions/BuildCredentialsUtils';
import { displayAndroidAppCredentials } from '../printCredentialsBeta';
jest.mock('../../../../log');
jest.mock('chalk', () => ({ bold: jest.fn(log => log) }));
mockdate.set(new Date('4/20/2021'));
describe('print credentials', () => {
it('prints the AndroidAppCredentials fragment', async () => {
const ctx = createCtxMock();
const appLookupParams = getAppLookupParamsFromContext(ctx);
displayAndroidAppCredentials({
appLookupParams,
legacyAppCredentials: testLegacyAndroidAppCredentialsFragment,
appCredentials: testAndroidAppCredentialsFragment,
});
const loggedSoFar = (Log.log as jest.Mock).mock.calls.reduce(
(acc, mockValue) => acc + mockValue
);
expect(loggedSoFar).toMatchSnapshot();
});
});
@@ -5,9 +5,10 @@ import path from 'path';
import tempy from 'tempy';
import { v4 as uuidv4 } from 'uuid';
import { AndroidKeystoreType } from '../../../graphql/generated';
import Log from '../../../log';
import { getTmpDirectory } from '../../../utils/paths';
import { Keystore } from '../credentials';
import { Keystore, KeystoreWithType } from '../credentials';
export async function keytoolCommandExistsAsync(): Promise<boolean> {
try {
@@ -82,7 +83,7 @@ async function createKeystoreAsync(credentials: {
keystorePassword: string;
keyAlias: string;
keyPassword: string;
}): Promise<Keystore> {
}): Promise<KeystoreWithType> {
await ensureKeytoolCommandExistsAsync();
await fs.mkdirp(getTmpDirectory());
const keystorePath = path.join(getTmpDirectory(), `${uuidv4()}-keystore.jks`);
@@ -112,13 +113,14 @@ async function createKeystoreAsync(credentials: {
return {
...credentials,
keystore: await fs.readFile(keystorePath, 'base64'),
type: AndroidKeystoreType.Jks,
};
} finally {
await fs.remove(keystorePath);
}
}
export async function generateRandomKeystoreAsync(): Promise<Keystore> {
export async function generateRandomKeystoreAsync(): Promise<KeystoreWithType> {
const keystoreData = {
keystorePassword: crypto.randomBytes(16).toString('hex'),
keyPassword: crypto.randomBytes(16).toString('hex'),
@@ -0,0 +1,91 @@
import { getX509Asn1ByFriendlyName, parsePKCS12 } from '@expo/pkcs12';
import jks from 'jks-js';
import { asn1 } from 'node-forge';
import { AndroidKeystoreType } from '../../../graphql/generated';
import Log from '../../../log';
import { Keystore, KeystoreWithType } from '../credentials';
export function getKeystoreWithType(keystore: Keystore): KeystoreWithType {
const type = getKeystoreType(keystore);
return { ...keystore, type };
}
export function getKeystoreType(keystore: Keystore): AndroidKeystoreType {
if (isPKCSKeystore(keystore)) {
return AndroidKeystoreType.Pkcs12;
} else if (isJKSKeystore(keystore)) {
return AndroidKeystoreType.Jks;
}
return AndroidKeystoreType.Unknown;
}
function isPKCSKeystore(keystore: Keystore): boolean {
try {
parsePKCS12(keystore.keystore, keystore.keystorePassword);
return true;
} catch (e) {
return false;
}
}
function isJKSKeystore(keystore: Keystore): boolean {
try {
jks.parseJks(Buffer.from(keystore.keystore, 'base64'), keystore.keystorePassword);
return true;
} catch (e) {
return false;
}
}
export function validateKeystore(keystore: KeystoreWithType): void {
if (keystore.type === AndroidKeystoreType.Jks) {
getPemFromJksKeystore(keystore);
} else if (keystore.type === AndroidKeystoreType.Pkcs12) {
getX509Asn1FromPKCS12Keystore(keystore.keystore, keystore.keystorePassword, keystore.keyAlias);
} else if (keystore.type === AndroidKeystoreType.Unknown) {
Log.warn('Unknown keystore type, skipping validation.');
} else {
Log.warn(`Unsupported keystore type: ${keystore.type}, skipping validation.`);
}
}
function getPemFromJksKeystore(keystore: Keystore): string {
const keystoreEntries = jks.parseJks(
Buffer.from(keystore.keystore, 'base64'),
keystore.keystorePassword
);
// keystore entries are case insensitive in both keytool and jks-js implementations
const keystoreEntry = keystoreEntries.find(
(entry: any) => entry.alias.toLowerCase() === keystore.keyAlias.toLowerCase()
);
if (!keystoreEntry) {
throw new Error(`JKS Keystore does not contain alias: ${keystore.keyAlias}`);
}
const { protectedPrivateKey } = keystoreEntry;
try {
return jks.decrypt(protectedPrivateKey, keystore.keyPassword);
} catch (e) {
throw new Error(`${e.message}: Check that your key password is correct`);
}
}
function getX509Asn1FromPKCS12Keystore(
p12BufferOrBase64String: Buffer | string,
maybePassword: string | null,
keyAlias: string
): asn1.Asn1 {
let x509Asn1;
try {
const p12 = parsePKCS12(p12BufferOrBase64String, maybePassword);
x509Asn1 = getX509Asn1ByFriendlyName(p12, keyAlias);
} catch (e) {
throw new Error(`Invalid PKCS#12 (.p12) keystore: ${e.message}`);
}
if (!x509Asn1) {
throw new Error(
`PKCS#12 keystore: Unable to get certificate under alias: ${keyAlias}. Run this to find the available aliases: keytool -list -v -keystore [your-keystore-path]`
);
}
return x509Asn1;
}
@@ -0,0 +1,143 @@
import chalk from 'chalk';
import {
AndroidAppBuildCredentialsFragment,
CommonAndroidAppCredentialsFragment,
} from '../../../graphql/generated';
import Log from '../../../log';
import { fromNow } from '../../../utils/date';
import { AppLookupParams } from '../api/GraphqlClient';
export function displayEmptyAndroidCredentials(appLookupParams: AppLookupParams): void {
const { projectName, androidApplicationIdentifier } = appLookupParams;
Log.log(chalk.bold(`Android Credentials`));
Log.log(` Project: ${projectName}`);
Log.log(` Application Identifier: ${androidApplicationIdentifier}`);
Log.log(` No credentials set up yet!`);
}
/**
* sort a build credentials array in descending order of preference
* prefer default credentials, then prefer names that come first lexicographically
*/
function sortBuildCredentials(
androidAppBuildCredentialsList: AndroidAppBuildCredentialsFragment[]
): AndroidAppBuildCredentialsFragment[] {
return androidAppBuildCredentialsList.sort((buildCredentialsA, buildCredentialsB) => {
if (buildCredentialsA.isDefault) {
return -1;
} else if (buildCredentialsB.isDefault) {
return 1;
}
return buildCredentialsA.name.localeCompare(buildCredentialsB.name);
});
}
function displayLegacyAndroidAppCredentials(
legacyAppCredentials: CommonAndroidAppCredentialsFragment,
appCredentials: CommonAndroidAppCredentialsFragment | null
): void {
if (appCredentials) {
// differentiate between old and new if there's both
Log.log(chalk.bold(` Credentials ported from Expo Classic (expo-cli):`));
}
// There can only be one set of build credentials in legacy app credentials
const [legacyBuildCredentials] = legacyAppCredentials.androidAppBuildCredentialsList;
if (legacyBuildCredentials) {
displayAndroidBuildCredentials(
legacyBuildCredentials,
/* only one set to show, skip config display */ true
);
}
}
function displayEASAndroidAppCredentials(
legacyAppCredentials: CommonAndroidAppCredentialsFragment | null,
appCredentials: CommonAndroidAppCredentialsFragment
): void {
if (legacyAppCredentials) {
// differentiate between old and new if there's both
Log.log(chalk.bold(` EAS Credentials:`));
Log.log(` These will take precedence over Expo Classic credentials`);
}
const sortedBuildCredentialsList = sortBuildCredentials(
appCredentials.androidAppBuildCredentialsList
);
for (const buildCredentials of sortedBuildCredentialsList) {
displayAndroidBuildCredentials(buildCredentials);
}
}
function formatFingerprint(fingerprint: string | null): string {
if (!fingerprint) {
return 'unavailable';
}
const uppercaseFingerprint = fingerprint.toUpperCase();
const bytes = [];
for (let i = 0; i < uppercaseFingerprint.length; i++) {
const halfByte = uppercaseFingerprint.charAt(i);
if (i % 2 === 0) {
bytes.push(halfByte); // first half of the byte
} else {
bytes[bytes.length - 1] += halfByte; // second half of the byte
}
}
return bytes.join(':');
}
function displayAndroidBuildCredentials(
buildCredentials: AndroidAppBuildCredentialsFragment,
skipConfigurationDisplay?: boolean
): void {
if (!skipConfigurationDisplay) {
const { isDefault, name } = buildCredentials;
Log.log(chalk.bold(` Configuration: ${name}${isDefault ? ' (Default)' : ''}`));
Log.newLine();
}
const maybeKeystore = buildCredentials.androidKeystore;
Log.log(` Keystore:`);
if (maybeKeystore) {
const {
keyAlias,
type,
md5CertificateFingerprint,
sha1CertificateFingerprint,
sha256CertificateFingerprint,
updatedAt,
} = maybeKeystore;
Log.log(` Type: ${type}`);
Log.log(` Key Alias: ${keyAlias}`);
Log.log(` MD5 Fingerprint: ${formatFingerprint(md5CertificateFingerprint ?? null)}`);
Log.log(` SHA1 Fingerprint: ${formatFingerprint(sha1CertificateFingerprint ?? null)}`);
Log.log(` SHA256 Fingerprint: ${formatFingerprint(sha256CertificateFingerprint ?? null)}`);
Log.log(` Updated ${fromNow(new Date(updatedAt))} ago`);
} else {
Log.log(` None assigned yet`);
}
Log.newLine();
}
export function displayAndroidAppCredentials({
appLookupParams,
legacyAppCredentials,
appCredentials,
}: {
appLookupParams: AppLookupParams;
legacyAppCredentials: CommonAndroidAppCredentialsFragment | null;
appCredentials: CommonAndroidAppCredentialsFragment | null;
}): void {
const { projectName, androidApplicationIdentifier } = appLookupParams;
Log.log(chalk.bold(`Android Credentials`));
Log.log(` Project: ${projectName}`);
Log.log(` Application Identifier: ${androidApplicationIdentifier}`);
Log.newLine();
if (appCredentials) {
displayEASAndroidAppCredentials(legacyAppCredentials, appCredentials);
}
if (legacyAppCredentials) {
displayLegacyAndroidAppCredentials(legacyAppCredentials, appCredentials);
}
}
+5 -5
View File
@@ -8,7 +8,7 @@ import { confirmAsync } from '../prompts';
import { Actor, getActorDisplayName } from '../user/User';
import { ensureLoggedInAsync } from '../user/actions';
import AndroidApi from './android/api/Client';
import IosApi from './ios/api/Client';
import * as AndroidGraphqlClient from './android/api/GraphqlClient';
import * as IosGraphqlClient from './ios/api/GraphqlClient';
import AppStoreApi from './ios/appstore/AppStoreApi';
@@ -27,8 +27,8 @@ export interface Context {
readonly user: Actor;
readonly nonInteractive: boolean;
readonly android: AndroidApi;
readonly ios: IosApi;
readonly newIos: typeof IosGraphqlClient;
readonly newAndroid: typeof AndroidGraphqlClient;
readonly ios: typeof IosGraphqlClient;
readonly appStore: AppStoreApi;
readonly hasProjectContext: boolean;
readonly exp: ExpoConfig;
@@ -56,8 +56,8 @@ export async function createCredentialsContextAsync(
class CredentialsContext implements Context {
public readonly android = new AndroidApi();
public readonly ios = new IosApi();
public readonly newIos = IosGraphqlClient;
public readonly newAndroid = AndroidGraphqlClient;
public readonly ios = IosGraphqlClient;
public readonly appStore: AppStoreApi;
public readonly nonInteractive: boolean;
private shouldAskAuthenticateAppStore: boolean = true;
@@ -3,13 +3,15 @@ import { vol } from 'memfs';
import prompts from 'prompts';
import { asMock } from '../../../__tests__/utils';
import { IosDistributionType } from '../../../graphql/generated';
import { testKeystore } from '../../__tests__/fixtures-android';
import { createCtxMock } from '../../__tests__/fixtures-context';
import {
getNewIosApiMockWithoutCredentials,
testAllCredentialsForApp,
testIosDistCredential,
testProvisioningProfile,
testCommonIosAppCredentialsFragment,
} from '../../__tests__/fixtures-ios';
import { getAppLookupParamsFromContext } from '../../ios/actions/BuildCredentialsUtils';
import { updateAndroidCredentialsAsync, updateIosCredentialsAsync } from '../update';
jest.mock('fs');
@@ -195,9 +197,10 @@ describe('update credentials.json', () => {
it('should update ios credentials in credentials.json if www returns valid credentials', async () => {
const ctx = createCtxMock({
ios: {
getAppCredentialsAsync: jest.fn(() => testAllCredentialsForApp),
getDistributionCertificateAsync: jest.fn(() => testIosDistCredential),
getProvisioningProfileAsync: jest.fn(() => testProvisioningProfile),
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithCommonFieldsAsync: jest.fn(
() => testCommonIosAppCredentialsFragment
),
},
});
vol.fromJSON({
@@ -213,12 +216,19 @@ describe('update credentials.json', () => {
'./pprofile': 'somebinarycontent',
'./cert.p12': 'somebinarycontent2',
});
await updateIosCredentialsAsync(ctx, 'bundleIdentifier');
const appLookupParams = getAppLookupParamsFromContext(ctx);
await updateIosCredentialsAsync(ctx, appLookupParams, IosDistributionType.AppStore);
const certP12 = await fs.readFile('./cert.p12', 'base64');
const pprofile = await fs.readFile('./pprofile', 'base64');
const credJson = await fs.readJson('./credentials.json');
expect(certP12).toEqual(testAllCredentialsForApp.distCredentials.certP12);
expect(pprofile).toEqual(testAllCredentialsForApp.credentials.provisioningProfile);
expect(certP12).toEqual(
testCommonIosAppCredentialsFragment.iosAppBuildCredentialsList[0].distributionCertificate
?.certificateP12
);
expect(pprofile).toEqual(
testCommonIosAppCredentialsFragment.iosAppBuildCredentialsList[0].provisioningProfile
?.provisioningProfile
);
expect(credJson).toEqual({
ios: {
provisioningProfilePath: 'pprofile',
@@ -232,12 +242,14 @@ describe('update credentials.json', () => {
it('should create credentials.json provisioning profile and distribution certificate if credentials.json does not exist', async () => {
const ctx = createCtxMock({
ios: {
getAppCredentialsAsync: jest.fn(() => testAllCredentialsForApp),
getDistributionCertificateAsync: jest.fn(() => testIosDistCredential),
getProvisioningProfileAsync: jest.fn(() => testProvisioningProfile),
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithCommonFieldsAsync: jest.fn(
() => testCommonIosAppCredentialsFragment
),
},
});
await updateIosCredentialsAsync(ctx, 'bundleIdentifier');
const appLookupParams = getAppLookupParamsFromContext(ctx);
await updateIosCredentialsAsync(ctx, appLookupParams, IosDistributionType.AppStore);
const certP12 = await fs.readFile('./ios/certs/dist-cert.p12', 'base64');
const pprofile = await fs.readFile('./ios/certs/profile.mobileprovision', 'base64');
const credJson = await fs.readJson('./credentials.json');
@@ -256,9 +268,8 @@ describe('update credentials.json', () => {
it('should not do anything if no credentials are returned from www', async () => {
const ctx = createCtxMock({
ios: {
getAppCredentialsAsync: jest.fn(() => null),
getDistributionCertificateAsync: jest.fn(() => null),
getProvisioningProfileAsync: jest.fn(() => null),
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithCommonFieldsAsync: jest.fn(() => null),
},
});
const credJson = {
@@ -276,11 +287,12 @@ describe('update credentials.json', () => {
'./cert.p12': 'somebinarycontent2',
});
try {
await updateIosCredentialsAsync(ctx, 'bundleIdentifier');
const appLookupParams = getAppLookupParamsFromContext(ctx);
await updateIosCredentialsAsync(ctx, appLookupParams, IosDistributionType.AppStore);
throw new Error('updateIosCredentialsAsync should throw na error');
} catch (e) {
expect(e.message).toMatch(
'There are no credentials configured for this project on EAS servers'
'There are no credentials configured for the APP_STORE distribution of this project on EAS servers'
);
}
const certP12 = await fs.readFile('./cert.p12', 'base64');
@@ -291,15 +303,15 @@ describe('update credentials.json', () => {
expect(newCredJson).toEqual(credJson);
});
it('should display confirm prompt if some credentials are missing in www (confirm: true)', async () => {
// create deep clone the quick and dirty way
const testIosAppCredentialsNoDistCert = JSON.parse(
JSON.stringify(testCommonIosAppCredentialsFragment)
);
testIosAppCredentialsNoDistCert.iosAppBuildCredentialsList[0].distributionCertificate = null;
const ctx = createCtxMock({
ios: {
getAppCredentialsAsync: jest.fn(() => ({
...testAllCredentialsForApp,
distCredentialsId: undefined,
distCredentials: undefined,
})),
getDistributionCertificateAsync: jest.fn(() => null),
getProvisioningProfileAsync: jest.fn(() => testProvisioningProfile),
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithCommonFieldsAsync: jest.fn(() => testIosAppCredentialsNoDistCert),
},
});
@@ -322,7 +334,8 @@ describe('update credentials.json', () => {
'./pprofile': 'somebinarycontent',
'./cert.p12': 'somebinarycontent2',
});
await updateIosCredentialsAsync(ctx, 'bundleIdentifier');
const appLookupParams = getAppLookupParamsFromContext(ctx);
await updateIosCredentialsAsync(ctx, appLookupParams, IosDistributionType.AppStore);
const certP12Exists = await fs.pathExists('./cert.p12');
const pprofile = await fs.readFile('./pprofile', 'base64');
const credJson = await fs.readJson('./credentials.json');
@@ -337,9 +350,10 @@ describe('update credentials.json', () => {
it('should throw an error if credentials.json contains credentials for multi-target projects', async () => {
const ctx = createCtxMock({
ios: {
getAppCredentialsAsync: jest.fn(() => testAllCredentialsForApp),
getDistributionCertificateAsync: jest.fn(() => testIosDistCredential),
getProvisioningProfileAsync: jest.fn(() => testProvisioningProfile),
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithCommonFieldsAsync: jest.fn(
() => testCommonIosAppCredentialsFragment
),
},
});
vol.fromJSON({
@@ -366,16 +380,18 @@ describe('update credentials.json', () => {
'./dist-cert-1.p12': 'cert-1-somebinarycontent',
'./dist-cert-2.p12': 'cert-2-somebinarycontent',
});
await expect(() => updateIosCredentialsAsync(ctx, 'bundleIdentifier')).rejects.toThrow(
/Updating credentials.json failed/
);
const appLookupParams = getAppLookupParamsFromContext(ctx);
await expect(() =>
updateIosCredentialsAsync(ctx, appLookupParams, IosDistributionType.AppStore)
).rejects.toThrow(/Updating credentials.json failed/);
});
it(`should throw an error if there is a typo in credentials.json (because we can't tell if this is a target name or not)`, async () => {
const ctx = createCtxMock({
ios: {
getAppCredentialsAsync: jest.fn(() => testAllCredentialsForApp),
getDistributionCertificateAsync: jest.fn(() => testIosDistCredential),
getProvisioningProfileAsync: jest.fn(() => testProvisioningProfile),
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithCommonFieldsAsync: jest.fn(
() => testCommonIosAppCredentialsFragment
),
},
});
vol.fromJSON({
@@ -392,9 +408,10 @@ describe('update credentials.json', () => {
'./pprofile-1.mobileprovision': 'pprofile-1-somebinarycontent',
'./dist-cert-1.p12': 'cert-1-somebinarycontent',
});
await expect(() => updateIosCredentialsAsync(ctx, 'bundleIdentifier')).rejects.toThrow(
/Updating credentials.json failed/
);
const appLookupParams = getAppLookupParamsFromContext(ctx);
await expect(() =>
updateIosCredentialsAsync(ctx, appLookupParams, IosDistributionType.AppStore)
).rejects.toThrow(/Updating credentials.json failed/);
});
});
});
@@ -17,7 +17,7 @@ export interface CredentialsJson {
keystorePath: string;
keystorePassword: string;
keyAlias: string;
keyPassword: string;
keyPassword?: string;
};
};
ios?: CredentialsJsonIosCredentials | Record<string, CredentialsJsonIosCredentials>;
@@ -1,11 +1,13 @@
import fs from 'fs-extra';
import path from 'path';
import { IosDistributionType as IosDistributionTypeGraphql } from '../../graphql/generated';
import Log from '../../log';
import { getProjectAccountName } from '../../project/projectUtils';
import { confirmAsync } from '../../prompts';
import { gitStatusAsync } from '../../utils/git';
import { Context } from '../context';
import { AppLookupParams } from '../ios/api/GraphqlClient';
import { CredentialsJson } from './read';
/**
@@ -84,7 +86,8 @@ export async function updateAndroidCredentialsAsync(ctx: Context): Promise<void>
*/
export async function updateIosCredentialsAsync(
ctx: Context,
bundleIdentifier: string
appLookupParams: AppLookupParams,
iosDistributionTypeGraphql: IosDistributionTypeGraphql
): Promise<void> {
const credentialsJsonFilePath = path.join(ctx.projectDir, 'credentials.json');
let rawCredentialsJsonObject: any = {};
@@ -118,26 +121,27 @@ export async function updateIosCredentialsAsync(
}
}
const accountName = getProjectAccountName(ctx.exp, ctx.user);
const appLookupParams = {
accountName,
projectName: ctx.exp.slug,
bundleIdentifier,
};
const profilePath =
rawCredentialsJsonObject?.ios?.provisioningProfilePath ?? 'ios/certs/profile.mobileprovision';
const distCertPath =
rawCredentialsJsonObject?.ios?.distributionCertificate?.path ?? 'ios/certs/dist-cert.p12';
const appCredentials = await ctx.ios.getAppCredentialsAsync(appLookupParams);
const distCredentials = await ctx.ios.getDistributionCertificateAsync(appLookupParams);
if (!appCredentials?.credentials?.provisioningProfile && !distCredentials) {
throw new Error('There are no credentials configured for this project on EAS servers');
const iosAppCredentials = await ctx.ios.getIosAppCredentialsWithCommonFieldsAsync(
appLookupParams
);
const buildCredentials =
iosAppCredentials?.iosAppBuildCredentialsList.find(
buildCredentials => buildCredentials.iosDistributionType === iosDistributionTypeGraphql
) ?? null;
if (!buildCredentials) {
throw new Error(
`There are no credentials configured for the ${iosDistributionTypeGraphql} distribution of this project on EAS servers`
);
}
const areCredentialsComplete =
appCredentials?.credentials?.provisioningProfile &&
distCredentials?.certP12 &&
distCredentials?.certPassword;
buildCredentials.provisioningProfile?.provisioningProfile &&
buildCredentials.distributionCertificate?.certificateP12 &&
buildCredentials.distributionCertificate.certificatePassword;
if (!areCredentialsComplete) {
const confirm = await confirmAsync({
@@ -149,28 +153,27 @@ export async function updateIosCredentialsAsync(
return;
}
}
const provisioningProfile =
buildCredentials.provisioningProfile?.provisioningProfile ?? undefined;
const distributionCertificateP12 =
buildCredentials.distributionCertificate?.certificateP12 ?? undefined;
const distributionCertificatePassword =
buildCredentials.distributionCertificate?.certificatePassword ?? undefined;
Log.log(`Writing Provisioning Profile to ${profilePath}`);
await updateFileAsync(
ctx.projectDir,
profilePath,
appCredentials?.credentials?.provisioningProfile
);
await updateFileAsync(ctx.projectDir, profilePath, provisioningProfile);
const shouldWarnPProfile = await isFileUntrackedAsync(profilePath);
Log.log(`Writing Distribution Certificate to ${distCertPath}`);
await updateFileAsync(ctx.projectDir, distCertPath, distCredentials?.certP12);
await updateFileAsync(ctx.projectDir, distCertPath, distributionCertificateP12);
const shouldWarnDistCert = await isFileUntrackedAsync(distCertPath);
const iosCredentials: Partial<CredentialsJson['ios']> = {
...(appCredentials?.credentials?.provisioningProfile
? { provisioningProfilePath: profilePath }
: {}),
...(distCredentials?.certP12 && distCredentials?.certPassword
...(provisioningProfile ? { provisioningProfilePath: profilePath } : {}),
...(distributionCertificateP12 && distributionCertificatePassword
? {
distributionCertificate: {
path: distCertPath,
password: distCredentials?.certPassword,
password: distributionCertificatePassword,
},
}
: {}),
@@ -1,17 +1,11 @@
import { Platform } from '@expo/eas-build-job';
import { CredentialsSource, IosDistributionType, IosEnterpriseProvisioning } from '@expo/eas-json';
import { IosAppBuildCredentialsFragment } from '../../graphql/generated';
import Log from '../../log';
import { CredentialsManager } from '../CredentialsManager';
import { Context } from '../context';
import * as credentialsJsonReader from '../credentialsJson/read';
import type { IosCredentials } from '../credentialsJson/read';
import { SetupBuildCredentials } from './actions/SetupBuildCredentials';
import {
getBuildCredentialsAsync,
resolveDistributionType,
} from './actions/new/BuildCredentialsUtils';
import { AppLookupParams } from './api/GraphqlClient';
import { isAdHocProfile } from './utils/provisioningProfile';
@@ -32,11 +26,10 @@ export default class IosCredentialsProvider {
public async getCredentialsAsync(
src: CredentialsSource.LOCAL | CredentialsSource.REMOTE
): Promise<IosCredentials> {
switch (src) {
case CredentialsSource.LOCAL:
return await this.getLocalAsync();
case CredentialsSource.REMOTE:
return await this.getRemoteAsync();
if (src === CredentialsSource.LOCAL) {
return await this.getLocalAsync();
} else {
return await this.getRemoteAsync();
}
}
@@ -70,54 +63,18 @@ export default class IosCredentialsProvider {
}
private async getRemoteAsync(): Promise<IosCredentials> {
if (this.options.skipCredentialsCheck) {
Log.log('Skipping credentials check');
} else {
await new CredentialsManager(this.ctx).runActionAsync(
new SetupBuildCredentials({
app: this.options.app,
distribution: this.options.distribution,
enterpriseProvisioning: this.options.enterpriseProvisioning,
})
);
}
const buildCredentials = await this.fetchRemoteAsync();
if (
!buildCredentials?.distributionCertificate?.certificateP12 ||
!buildCredentials.distributionCertificate?.certificatePassword
) {
if (this.options.skipCredentialsCheck) {
throw new Error(
'Distribution certificate is missing and credentials check was skipped. Run without --skip-credentials-check to set it up.'
);
} else {
throw new Error('Distribution certificate is missing');
}
}
if (!buildCredentials.provisioningProfile?.provisioningProfile) {
if (this.options.skipCredentialsCheck) {
throw new Error(
'Provisioning profile is missing and credentials check was skipped. Run without --skip-credentials-check to set it up.'
);
} else {
throw new Error('Provisioning profile is missing');
}
}
const manager = new CredentialsManager(this.ctx);
const { provisioningProfile, distributionCertificate } = await new SetupBuildCredentials({
app: this.options.app,
distribution: this.options.distribution,
enterpriseProvisioning: this.options.enterpriseProvisioning,
}).runAsync(manager, this.ctx);
return {
provisioningProfile: buildCredentials.provisioningProfile.provisioningProfile,
provisioningProfile,
distributionCertificate: {
certP12: buildCredentials.distributionCertificate.certificateP12,
certPassword: buildCredentials.distributionCertificate.certificatePassword,
certP12: distributionCertificate.certificateP12,
certPassword: distributionCertificate.certificatePassword,
},
};
}
private async fetchRemoteAsync(): Promise<IosAppBuildCredentialsFragment | null> {
const distributionType = resolveDistributionType(
this.options.distribution,
this.options.enterpriseProvisioning
);
return await getBuildCredentialsAsync(this.ctx, this.options.app, distributionType);
}
}
@@ -1,21 +1,43 @@
import { CredentialsSource } from '@expo/eas-json';
import { vol } from 'memfs';
import { IosAppBuildCredentialsFragment } from '../../../graphql/generated';
import { getAppstoreMock } from '../../__tests__/fixtures-appstore';
import { createCtxMock } from '../../__tests__/fixtures-context';
import { testIosAppCredentialsWithBuildCredentialsQueryResult } from '../../__tests__/fixtures-ios';
import { getNewIosApiMockWithoutCredentials } from '../../__tests__/fixtures-new-ios';
import {
getNewIosApiMockWithoutCredentials,
testIosAppCredentialsWithBuildCredentialsQueryResult,
} from '../../__tests__/fixtures-ios';
import IosCredentialsProvider from '../IosCredentialsProvider';
import { getAppLookupParamsFromContext } from '../actions/new/BuildCredentialsUtils';
import { getAppLookupParamsFromContext } from '../actions/BuildCredentialsUtils';
jest.mock('fs');
jest.mock('../validators/validateProvisioningProfile', () => ({
validateProvisioningProfileAsync: async (
_ctx: any,
_app: any,
buildCredentials: Partial<IosAppBuildCredentialsFragment> | null
): Promise<boolean> => {
return !!(
buildCredentials &&
buildCredentials.distributionCertificate &&
buildCredentials.provisioningProfile
);
},
}));
const originalConsoleLog = console.log;
const originalConsoleError = console.error;
const originalConsoleWarn = console.warn;
beforeAll(() => {
console.log = jest.fn();
console.error = jest.fn();
console.warn = jest.fn();
});
afterAll(() => {
console.log = originalConsoleLog;
console.error = originalConsoleError;
console.warn = originalConsoleWarn;
});
beforeEach(() => {
@@ -27,10 +49,10 @@ describe(IosCredentialsProvider, () => {
describe('remote credentials', () => {
it('throws an error is credentials do not exist', async () => {
const ctx = createCtxMock({
nonInteractive: false,
nonInteractive: true,
appStore: getAppstoreMock(),
projectDir: '/app',
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(() => null),
},
@@ -46,22 +68,28 @@ describe(IosCredentialsProvider, () => {
projectName: appLookupParams.projectName,
},
distribution: 'store',
skipCredentialsCheck: true,
});
await expect(provider.getCredentialsAsync(CredentialsSource.REMOTE)).rejects.toThrowError();
await expect(provider.getCredentialsAsync(CredentialsSource.REMOTE)).rejects.toThrowError(
/Credentials are not set up/
);
});
it('returns credentials if they exist', async () => {
const ctx = createCtxMock({
nonInteractive: false,
nonInteractive: true,
appStore: getAppstoreMock(),
projectDir: '/app',
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(
() => testIosAppCredentialsWithBuildCredentialsQueryResult
),
getDistributionCertificateForAppAsync: jest.fn(
() =>
testIosAppCredentialsWithBuildCredentialsQueryResult.iosAppBuildCredentialsList[0]
.distributionCertificate
),
},
});
const appLookupParams = getAppLookupParamsFromContext(ctx);
@@ -75,11 +103,10 @@ describe(IosCredentialsProvider, () => {
projectName: appLookupParams.projectName,
},
distribution: 'store',
skipCredentialsCheck: true,
});
const buildCredentials =
testIosAppCredentialsWithBuildCredentialsQueryResult.iosAppBuildCredentialsArray[0];
testIosAppCredentialsWithBuildCredentialsQueryResult.iosAppBuildCredentialsList[0];
await expect(provider.getCredentialsAsync(CredentialsSource.REMOTE)).resolves.toMatchObject(
{
distributionCertificate: {
@@ -1,6 +1,6 @@
import { AppleTeamFragment } from '../../../../graphql/generated';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { AppleTeamFragment } from '../../../graphql/generated';
import { Context } from '../../context';
import { AppLookupParams } from '../api/GraphqlClient';
export async function resolveAppleTeamIfAuthenticatedAsync(
ctx: Context,
@@ -9,7 +9,7 @@ export async function resolveAppleTeamIfAuthenticatedAsync(
if (!ctx.appStore.authCtx) {
return null;
}
return await ctx.newIos.createOrGetExistingAppleTeamAsync(app, {
return await ctx.ios.createOrGetExistingAppleTeamAsync(app.account, {
appleTeamIdentifier: ctx.appStore.authCtx.team.id,
appleTeamName: ctx.appStore.authCtx.team.name,
});
@@ -1,4 +1,3 @@
import { IosDistributionType, IosEnterpriseProvisioning } from '@expo/eas-json';
import nullthrows from 'nullthrows';
import {
@@ -7,28 +6,36 @@ import {
AppleTeamFragment,
IosDistributionType as GraphQLIosDistributionType,
IosAppBuildCredentialsFragment,
} from '../../../../graphql/generated';
import {
getProjectAccountName,
getProjectConfigDescription,
} from '../../../../project/projectUtils';
import { findAccountByName } from '../../../../user/Account';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
} from '../../../graphql/generated';
import { getProjectAccountName, getProjectConfigDescription } from '../../../project/projectUtils';
import { findAccountByName } from '../../../user/Account';
import { Context } from '../../context';
import { AppLookupParams } from '../api/GraphqlClient';
import { resolveAppleTeamIfAuthenticatedAsync } from './AppleTeamUtils';
export async function getAllBuildCredentialsAsync(
ctx: Context,
app: AppLookupParams
): Promise<IosAppBuildCredentialsFragment[]> {
const appCredentials = await ctx.ios.getIosAppCredentialsWithBuildCredentialsAsync(app, {});
if (!appCredentials) {
return [];
}
return appCredentials.iosAppBuildCredentialsList;
}
export async function getBuildCredentialsAsync(
ctx: Context,
app: AppLookupParams,
iosDistributionType: GraphQLIosDistributionType
): Promise<IosAppBuildCredentialsFragment | null> {
const appCredentials = await ctx.newIos.getIosAppCredentialsWithBuildCredentialsAsync(app, {
const appCredentials = await ctx.ios.getIosAppCredentialsWithBuildCredentialsAsync(app, {
iosDistributionType,
});
if (!appCredentials || appCredentials.iosAppBuildCredentialsArray.length === 0) {
if (!appCredentials || appCredentials.iosAppBuildCredentialsList.length === 0) {
return null;
}
const [buildCredentials] = appCredentials.iosAppBuildCredentialsArray;
const [buildCredentials] = appCredentials.iosAppBuildCredentialsList;
return buildCredentials;
}
@@ -61,11 +68,11 @@ export async function assignBuildCredentialsAsync(
const resolvedAppleTeam = nullthrows(
appleTeam ?? (await resolveAppleTeamIfAuthenticatedAsync(ctx, app))
);
const appleAppIdentifier = await ctx.newIos.createOrGetExistingAppleAppIdentifierAsync(
const appleAppIdentifier = await ctx.ios.createOrGetExistingAppleAppIdentifierAsync(
app,
resolvedAppleTeam
);
return await ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync(app, {
return await ctx.ios.createOrUpdateIosAppBuildCredentialsAsync(app, {
appleTeam: resolvedAppleTeam,
appleAppIdentifierId: appleAppIdentifier.id,
appleDistributionCertificateId: distCert.id,
@@ -94,20 +101,3 @@ export function getAppLookupParamsFromContext(ctx: Context): AppLookupParams {
return { account, projectName, bundleIdentifier };
}
export function resolveDistributionType(
distribution: IosDistributionType,
enterpriseProvisioning?: IosEnterpriseProvisioning
): GraphQLIosDistributionType {
if (distribution === 'internal') {
if (enterpriseProvisioning === 'adhoc') {
return GraphQLIosDistributionType.AdHoc;
} else if (enterpriseProvisioning === 'universal') {
return GraphQLIosDistributionType.Enterprise;
} else {
return GraphQLIosDistributionType.AdHoc;
}
} else {
return GraphQLIosDistributionType.AppStore;
}
}
@@ -2,91 +2,109 @@ import assert from 'assert';
import chalk from 'chalk';
import ora from 'ora';
import Log from '../../../log';
import { Action, CredentialsManager } from '../../CredentialsManager';
import { Context } from '../../context';
import {
DistributionCertificate,
ProvisioningProfileStoreInfo,
} from '../appstore/Credentials.types';
import { AppLookupParams } from '../credentials';
import { selectProvisioningProfileFromAppleAsync } from './ProvisioningProfileUtils';
AppleDistributionCertificateFragment,
AppleProvisioningProfileFragment,
} from '../../../graphql/generated';
import Log from '../../../log';
import { Context } from '../../context';
import { AppLookupParams } from '../api/GraphqlClient';
import { AppleProvisioningProfileMutationResult } from '../api/graphql/mutations/AppleProvisioningProfileMutation';
import { ProvisioningProfileStoreInfo } from '../appstore/Credentials.types';
import { AuthCtx } from '../appstore/authenticate';
import { MissingCredentialsNonInteractiveError } from '../errors';
export class UseExistingProvisioningProfile implements Action {
constructor(private app: AppLookupParams) {}
export class ConfigureProvisioningProfile {
constructor(
private app: AppLookupParams,
private distributionCertificate: AppleDistributionCertificateFragment,
private originalProvisioningProfile: AppleProvisioningProfileFragment
) {}
public async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const selected = await selectProvisioningProfileFromAppleAsync(ctx, this.app.bundleIdentifier);
if (selected) {
const distCert = await ctx.ios.getDistributionCertificateAsync(this.app);
assert(distCert, 'missing distribution certificate');
await manager.runActionAsync(new ConfigureProvisioningProfile(this.app));
}
}
}
export class ConfigureProvisioningProfile implements Action {
constructor(private app: AppLookupParams) {}
public async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const profile = await ctx.ios.getProvisioningProfileAsync(this.app);
if (!profile) {
throw new Error('No provisioning profile to configure');
}
if (!profile.provisioningProfileId) {
Log.warn("The provisioning profile we have on file cannot be validated on Apple's servers.");
return;
}
if (ctx.appStore.authCtx) {
const distCert = await ctx.ios.getDistributionCertificateAsync(this.app);
if (!distCert) {
Log.warn('There is no distribution certificate for this app.');
return;
}
const profilesFromApple = await ctx.appStore.listProvisioningProfilesAsync(
this.app.bundleIdentifier
public async runAsync(ctx: Context): Promise<AppleProvisioningProfileMutationResult | null> {
if (ctx.nonInteractive) {
throw new MissingCredentialsNonInteractiveError(
'Configuring Provisioning Profiles is only supported in interactive mode.'
);
const profilesWithMatchingId = profilesFromApple.filter(
appleInfo => appleInfo.provisioningProfileId === profile.provisioningProfileId
);
if (!profilesWithMatchingId || profilesWithMatchingId.length < 1) {
Log.warn('This profile is no longer valid on Apple Developer Portal.');
}
}
const { developerPortalIdentifier, provisioningProfile } = this.originalProvisioningProfile;
if (!developerPortalIdentifier && !provisioningProfile) {
Log.warn("The provisioning profile we have on file cannot be configured on Apple's servers.");
return null;
}
await this.configureAndUpdateAsync(ctx, this.app, distCert, profilesWithMatchingId[0]);
} else {
if (!ctx.appStore.authCtx) {
Log.warn(
"Without access to your Apple account we can't configure provisioning profiles for you."
);
Log.warn('Make sure to recreate the profile if you selected a new distribution certificate.');
return null;
}
const profilesFromApple = await ctx.appStore.listProvisioningProfilesAsync(
this.app.bundleIdentifier
);
const [matchingProfile] = profilesFromApple.filter(appleInfo =>
developerPortalIdentifier
? appleInfo.provisioningProfileId === developerPortalIdentifier
: appleInfo.provisioningProfile === provisioningProfile
);
if (!matchingProfile) {
Log.warn(
`Profile ${
developerPortalIdentifier ? `${developerPortalIdentifier} ` : ''
}not found on Apple Developer Portal.`
);
return null;
}
return await this.configureAndUpdateAsync(ctx, ctx.appStore.authCtx, this.app, matchingProfile);
}
private async configureAndUpdateAsync(
ctx: Context,
authCtx: AuthCtx,
app: AppLookupParams,
distCert: DistributionCertificate,
profileFromApple: ProvisioningProfileStoreInfo
) {
): Promise<AppleProvisioningProfileMutationResult> {
const {
developerPortalIdentifier,
certificateP12,
certificatePassword,
serialNumber,
} = this.distributionCertificate;
assert(
certificateP12 && certificatePassword,
'Distribution Certificate P12 and Password is required'
);
// configure profile on Apple's Server to use our distCert
const updatedProfile = await ctx.appStore.useExistingProvisioningProfileAsync(
app.bundleIdentifier,
profileFromApple,
distCert
{
certId: developerPortalIdentifier ?? undefined,
certP12: certificateP12,
certPassword: certificatePassword,
distCertSerialNumber: serialNumber,
teamId: authCtx.appleId,
}
);
const bundleIdTag = `(${app.bundleIdentifier})`;
const slugTag = `@${app.accountName}/${app.projectName}`;
const slugTag = `@${app.account.name}/${app.projectName}`;
const projectTag = `${chalk.bold(slugTag)} ${chalk.dim(bundleIdTag)}`;
const spinner = ora(`Updating Expo profile for ${projectTag}`).start();
try {
// Update profile on EAS servers
await ctx.ios.updateProvisioningProfileAsync(app, updatedProfile);
const configuredProvisioningProfile = await ctx.ios.updateProvisioningProfileAsync(
this.originalProvisioningProfile.id,
{
appleProvisioningProfile: updatedProfile.provisioningProfile,
developerPortalIdentifier: updatedProfile.provisioningProfileId,
}
);
spinner.succeed(`Updated Expo profile for ${projectTag}`);
return configuredProvisioningProfile;
} catch (error) {
spinner.fail();
throw error;
@@ -1,41 +1,16 @@
import assert from 'assert';
import Log from '../../../log';
import { Action, CredentialsManager } from '../../CredentialsManager';
import { Account } from '../../../user/Account';
import { Context } from '../../context';
import { IosDistCredentials } from '../credentials';
import { displayIosUserCredentials } from '../utils/printCredentials';
import { AppleDistributionCertificateMutationResult } from '../api/graphql/mutations/AppleDistributionCertificateMutation';
import { provideOrGenerateDistributionCertificateAsync } from './DistributionCertificateUtils';
export class CreateDistributionCertificateStandaloneManager implements Action {
constructor(private accountName: string) {}
export class CreateDistributionCertificate {
constructor(private account: Account) {}
public async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const action = new CreateDistributionCertificate(this.accountName);
await manager.runActionAsync(action);
Log.newLine();
displayIosUserCredentials(action.distCredentials);
Log.newLine();
}
}
export class CreateDistributionCertificate implements Action {
private _distCredentials?: IosDistCredentials;
constructor(private accountName: string) {}
public get distCredentials(): IosDistCredentials {
assert(this._distCredentials, 'distCredentials can be accessed only after runAsync');
return this._distCredentials;
}
public async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const distCert = await provideOrGenerateDistributionCertificateAsync(ctx, this.accountName);
this._distCredentials = await ctx.ios.createDistributionCertificateAsync(
this.accountName,
distCert
);
public async runAsync(ctx: Context): Promise<AppleDistributionCertificateMutationResult> {
const distCert = await provideOrGenerateDistributionCertificateAsync(ctx, this.account.name);
const result = await ctx.ios.createDistributionCertificateAsync(this.account, distCert);
Log.succeed('Created distribution certificate');
return result;
}
}
@@ -1,18 +1,18 @@
import assert from 'assert';
import nullthrows from 'nullthrows';
import { AppleDistributionCertificateFragment } from '../../../../graphql/generated';
import Log from '../../../../log';
import { Context } from '../../../context';
import { askForUserProvidedAsync } from '../../../utils/promptForCredentials';
import { AppLookupParams } from '../../api/GraphqlClient';
import { AppleProvisioningProfileMutationResult } from '../../api/graphql/mutations/AppleProvisioningProfileMutation';
import { ProvisioningProfile } from '../../appstore/Credentials.types';
import { AuthCtx } from '../../appstore/authenticate';
import { provisioningProfileSchema } from '../../credentials';
import { MissingCredentialsNonInteractiveError } from '../../errors';
import { generateProvisioningProfileAsync } from '../ProvisioningProfileUtils';
import { AppleDistributionCertificateFragment } from '../../../graphql/generated';
import Log from '../../../log';
import { Context } from '../../context';
import { askForUserProvidedAsync } from '../../utils/promptForCredentials';
import { AppLookupParams } from '../api/GraphqlClient';
import { AppleProvisioningProfileMutationResult } from '../api/graphql/mutations/AppleProvisioningProfileMutation';
import { ProvisioningProfile } from '../appstore/Credentials.types';
import { AuthCtx } from '../appstore/authenticate';
import { provisioningProfileSchema } from '../credentials';
import { MissingCredentialsNonInteractiveError } from '../errors';
import { resolveAppleTeamIfAuthenticatedAsync } from './AppleTeamUtils';
import { generateProvisioningProfileAsync } from './ProvisioningProfileUtils';
export class CreateProvisioningProfile {
constructor(
@@ -29,11 +29,11 @@ export class CreateProvisioningProfile {
const appleAuthCtx = await ctx.appStore.ensureAuthenticatedAsync();
const provisioningProfile = await this.provideOrGenerateAsync(ctx, appleAuthCtx);
const appleTeam = nullthrows(await resolveAppleTeamIfAuthenticatedAsync(ctx, this.app));
const appleAppIdentifier = await ctx.newIos.createOrGetExistingAppleAppIdentifierAsync(
const appleAppIdentifier = await ctx.ios.createOrGetExistingAppleAppIdentifierAsync(
this.app,
appleTeam
);
const provisioningProfileMutationResult = await ctx.newIos.createProvisioningProfileAsync(
const provisioningProfileMutationResult = await ctx.ios.createProvisioningProfileAsync(
this.app,
appleAppIdentifier,
{
@@ -1,6 +1,6 @@
import { AppleDevice, AppleDeviceFragment } from '../../../../graphql/generated';
import { APPLE_DEVICE_CLASS_LABELS } from '../../../../graphql/types/credentials/AppleDevice';
import { promptAsync } from '../../.././../prompts';
import { AppleDevice, AppleDeviceFragment } from '../../../graphql/generated';
import { APPLE_DEVICE_CLASS_LABELS } from '../../../graphql/types/credentials/AppleDevice';
import { promptAsync } from '../.././../prompts';
export async function chooseDevices(
allDevices: AppleDeviceFragment[],
@@ -1,26 +1,154 @@
import assert from 'assert';
import chalk from 'chalk';
import dateformat from 'dateformat';
import {
AppleDistributionCertificateFragment,
AppleTeamFragment,
} from '../../../graphql/generated';
import Log, { learnMore } from '../../../log';
import { promptAsync } from '../../../prompts';
import { Account } from '../../../user/Account';
import { fromNow } from '../../../utils/date';
import { Context } from '../../context';
import { askForUserProvidedAsync } from '../../utils/promptForCredentials';
import { AppLookupParams } from '../api/GraphqlClient';
import { AppleTooManyCertsError } from '../appstore/AppStoreApi';
import {
DistributionCertificate,
DistributionCertificateStoreInfo,
} from '../appstore/Credentials.types';
import {
filterRevokedDistributionCerts,
sortCertificatesByExpiryDesc,
} from '../appstore/CredentialsUtils';
import {
IosAppCredentials,
IosDistCredentials,
distributionCertificateSchema,
} from '../credentials';
import { findP12CertSerialNumber } from '../utils/p12Certificate';
import { filterRevokedDistributionCertsFromEasServers } from '../appstore/CredentialsUtils';
import { distributionCertificateSchema } from '../credentials';
import { validateDistributionCertificateAsync } from '../validators/validateDistributionCertificate';
export function formatDistributionCertificate(
distributionCertificate: AppleDistributionCertificateFragment,
validSerialNumbers?: string[]
): string {
const {
serialNumber,
developerPortalIdentifier,
appleTeam,
validityNotBefore,
validityNotAfter,
updatedAt,
} = distributionCertificate;
let line: string = '';
if (developerPortalIdentifier) {
line += `Cert ID: ${developerPortalIdentifier}`;
}
line += `${line === '' ? '' : ', '}Serial number: ${serialNumber}${
appleTeam ? `, ${formatAppleTeam(appleTeam)}` : ''
}`;
line += chalk.gray(
`\n Created: ${fromNow(new Date(validityNotBefore))} ago, Updated: ${fromNow(
new Date(updatedAt)
)} ago,`
);
line += chalk.gray(`\n Expires: ${dateformat(validityNotAfter, 'expiresHeaderFormat')}`);
const apps = distributionCertificate.iosAppBuildCredentialsList.map(
buildCredentials => buildCredentials.iosAppCredentials.app
);
if (apps.length) {
const appFullNames = apps.map(app => app.fullName).join(',');
line += chalk.gray(`\n 📲 Used by: ${appFullNames}`);
}
if (validSerialNumbers?.includes(serialNumber)) {
line += chalk.gray("\n ✅ Currently valid on Apple's servers.");
} else {
line += '';
}
return line;
}
function formatAppleTeam({ appleTeamIdentifier, appleTeamName }: AppleTeamFragment): string {
return `Team ID: ${appleTeamIdentifier}${appleTeamName ? `, Team name: ${appleTeamName}` : ''}`;
}
async function _selectDistributionCertificateAsync(
distCerts: AppleDistributionCertificateFragment[],
validDistributionCertificates?: AppleDistributionCertificateFragment[]
): Promise<AppleDistributionCertificateFragment | null> {
const validDistCertSerialNumbers = validDistributionCertificates?.map(
distCert => distCert.serialNumber
);
const { chosenDistCert } = await promptAsync({
type: 'select',
name: 'chosenDistCert',
message: 'Select certificate from the list.',
choices: distCerts.map(distCert => ({
title: formatDistributionCertificate(distCert, validDistCertSerialNumbers),
value: distCert,
})),
});
return chosenDistCert;
}
/**
* select a distribution certificate from an account (validity status shown on a best effort basis)
* */
export async function selectDistributionCertificateWithDependenciesAsync(
ctx: Context,
account: Account
): Promise<AppleDistributionCertificateFragment | null> {
const distCertsForAccount = await ctx.ios.getDistributionCertificatesForAccountAsync(account);
if (distCertsForAccount.length === 0) {
Log.warn(`There are no Distribution Certificates available in your EAS account.`);
return null;
}
if (!ctx.appStore.authCtx) {
return _selectDistributionCertificateAsync(distCertsForAccount);
}
// get valid certs on the developer portal
const certInfoFromApple = await ctx.appStore.listDistributionCertificatesAsync();
const validDistCerts = await filterRevokedDistributionCertsFromEasServers(
distCertsForAccount,
certInfoFromApple
);
return _selectDistributionCertificateAsync(distCertsForAccount, validDistCerts);
}
/**
* select a distribution certificate from a valid set (curated on a best effort basis)
* */
export async function selectValidDistributionCertificateAsync(
ctx: Context,
appLookupParams: AppLookupParams
): Promise<AppleDistributionCertificateFragment | null> {
const distCertsForAccount = await ctx.ios.getDistributionCertificatesForAccountAsync(
appLookupParams.account
);
if (distCertsForAccount.length === 0) {
Log.warn(`There are no Distribution Certificates available in your EAS account.`);
return null;
}
if (!ctx.appStore.authCtx) {
return _selectDistributionCertificateAsync(distCertsForAccount);
}
// filter by apple team
assert(ctx.appStore.authCtx, 'authentication to the Apple App Store is required');
const appleTeamIdentifier = ctx.appStore.authCtx.team.id;
const distCertsForAppleTeam = distCertsForAccount.filter(distCert => {
return !distCert.appleTeam || distCert.appleTeam.appleTeamIdentifier === appleTeamIdentifier;
});
// filter by valid certs on the developer portal
const certInfoFromApple = await ctx.appStore.listDistributionCertificatesAsync();
const validDistCerts = await filterRevokedDistributionCertsFromEasServers(
distCertsForAppleTeam,
certInfoFromApple
);
Log.log(
`${validDistCerts.length}/${distCertsForAccount.length} Distribution Certificates are currently valid for Apple Team ${ctx.appStore.authCtx?.team.id}.`
);
return _selectDistributionCertificateAsync(validDistCerts);
}
const APPLE_DIST_CERTS_TOO_MANY_GENERATED_ERROR = `
You can have only ${chalk.underline(
'three'
@@ -125,100 +253,6 @@ async function generateDistributionCertificateAsync(
return await generateDistributionCertificateAsync(ctx, accountName);
}
interface SelectOptions {
filterInvalid?: boolean;
}
type ValidityStatus = 'UNKNOWN' | 'VALID' | 'INVALID';
export async function selectDistributionCertificateAsync(
ctx: Context,
accountName: string,
options: SelectOptions = {}
): Promise<IosDistCredentials | null> {
const credentials = await ctx.ios.getAllCredentialsAsync(accountName);
let distCredentials = credentials.userCredentials.filter(
(cred): cred is IosDistCredentials => cred.type === 'dist-cert'
);
let validDistCredentials: IosDistCredentials[] | null = null;
if (ctx.appStore.authCtx) {
const certInfoFromApple = await ctx.appStore.listDistributionCertificatesAsync();
validDistCredentials = filterRevokedDistributionCerts(distCredentials, certInfoFromApple);
}
distCredentials =
options.filterInvalid && validDistCredentials ? validDistCredentials : distCredentials;
if (distCredentials.length === 0) {
Log.warn('There are no Distribution Certificates available in your Expo account.');
return null;
}
const format = (distCredentials: IosDistCredentials): string => {
const usedByApps = credentials.appCredentials.filter(
cred => cred.distCredentialsId === distCredentials.id
);
let validityStatus: ValidityStatus;
if (!validDistCredentials) {
validityStatus = 'UNKNOWN';
} else if (validDistCredentials.includes(distCredentials)) {
validityStatus = 'VALID';
} else {
validityStatus = 'INVALID';
}
return formatDistributionCertificate(distCredentials, usedByApps, validityStatus);
};
const { credentialsIndex } = await promptAsync({
type: 'select',
name: 'credentialsIndex',
message: 'Select certificate from the list.',
choices: distCredentials.map((entry, index) => ({
title: format(entry),
value: index,
})),
});
return distCredentials[credentialsIndex];
}
export function formatDistributionCertificate(
distributionCertificate: IosDistCredentials,
usedByApps: IosAppCredentials[],
validityStatus: ValidityStatus = 'UNKNOWN'
): string {
const joinApps = usedByApps.map(i => `${i.experienceName} (${i.bundleIdentifier})`).join(', ');
const usedByString = joinApps
? `\n ${chalk.gray(`used by ${joinApps}`)}`
: `\n ${chalk.gray(`not used by any apps`)}`;
let serialNumber = distributionCertificate.distCertSerialNumber;
try {
if (!serialNumber) {
serialNumber = findP12CertSerialNumber(
distributionCertificate.certP12,
distributionCertificate.certPassword
);
}
} catch (error) {
serialNumber = chalk.red('invalid serial number');
}
let validityText;
if (validityStatus === 'VALID') {
validityText = chalk.gray("\n ✅ Currently valid on Apple's servers.");
} else if (validityStatus === 'INVALID') {
validityText = chalk.gray("\n ❌ No longer valid on Apple's servers.");
} else {
validityText = chalk.gray(
"\n ❓ Validity of this certificate on Apple's servers is unknown."
);
}
return `Distribution Certificate (Cert ID: ${
distributionCertificate.certId || '-----'
}, Serial number: ${serialNumber}, Team ID: ${
distributionCertificate.teamId
})${usedByString}${validityText}`;
}
function formatDistributionCertificateFromApple(
appleInfo: DistributionCertificateStoreInfo
): string {
@@ -228,20 +262,3 @@ function formatDistributionCertificateFromApple(
return `${name} (${status}) - Cert ID: ${id}, Serial number: ${serialNumber}, Team ID: ${appleInfo.ownerId}, Team name: ${ownerName}
expires: ${expiresDate}, created: ${createdDate}`;
}
export async function getValidDistCertsAsync(
ctx: Context,
accountName: string
): Promise<IosDistCredentials[]> {
const credentials = await ctx.ios.getAllCredentialsAsync(accountName);
const distCredentials = credentials.userCredentials.filter(
(cred): cred is IosDistCredentials => cred.type === 'dist-cert'
);
if (!ctx.appStore.authCtx) {
Log.log(chalk.yellow(`Unable to determine validity of Distribution Certificates.`));
return distCredentials;
}
const certInfoFromApple = await ctx.appStore.listDistributionCertificatesAsync();
const validCerts = await filterRevokedDistributionCerts(distCredentials, certInfoFromApple);
return sortCertificatesByExpiryDesc(certInfoFromApple, validCerts);
}
@@ -1,38 +1,11 @@
import chalk from 'chalk';
import Log from '../../../log';
import { promptAsync } from '../../../prompts';
import { Context } from '../../context';
import {
DistributionCertificate,
ProvisioningProfile,
ProvisioningProfileStoreInfo,
} from '../appstore/Credentials.types';
import { IosAppCredentials } from '../credentials';
export async function selectProvisioningProfileFromAppleAsync(
ctx: Context,
bundleIdentifier: string
): Promise<ProvisioningProfileStoreInfo | null> {
const profiles = await ctx.appStore.listProvisioningProfilesAsync(bundleIdentifier);
if (profiles.length === 0) {
Log.warn(
`There are no provisioning profiles available on Apple Developer Portal for bundle identifier ${bundleIdentifier}.`
);
return null;
}
const { credentialsIndex } = await promptAsync({
type: 'select',
name: 'credentialsIndex',
message: 'Select provisioning profile from the list.',
choices: profiles.map((entry, index) => ({
title: formatProvisioningProfileFromApple(entry),
value: index,
})),
});
return profiles[credentialsIndex];
}
export function formatProvisioningProfileFromApple(
appleInfo: ProvisioningProfileStoreInfo
@@ -45,36 +18,6 @@ export function formatProvisioningProfileFromApple(
return `Provisioning Profile - ID: ${id}${details}`;
}
export async function selectProvisioningProfileFromExpoAsync(
ctx: Context,
accountName: string
): Promise<IosAppCredentials | null> {
const profiles = (await ctx.ios.getAllCredentialsAsync(accountName)).appCredentials.filter(
({ credentials }) => !!credentials.provisioningProfile && !!credentials.provisioningProfileId
);
if (profiles.length === 0) {
Log.warn('There are no provisioning profiles available in your Expo account.');
return null;
}
const format = (profile: IosAppCredentials) => {
const id = chalk.green(profile.credentials.provisioningProfileId || '-----');
const teamId = profile.credentials.teamId || '------';
return `Provisioning Profile (ID: ${id}, Team ID: ${teamId})`;
};
const { credentialsIndex } = await promptAsync({
type: 'select',
name: 'credentialsIndex',
message: 'Select provisioning profile from the list.',
choices: profiles.map((entry, index) => ({
title: format(entry),
value: index,
})),
});
return profiles[credentialsIndex];
}
export async function generateProvisioningProfileAsync(
ctx: Context,
bundleIdentifier: string,
@@ -1,57 +1,47 @@
import chalk from 'chalk';
import {
AppleDistributionCertificateFragment,
AppleProvisioningProfileIdentifiersFragment,
} from '../../../graphql/generated';
import Log from '../../../log';
import { confirmAsync } from '../../../prompts';
import { Action, CredentialsManager } from '../../CredentialsManager';
import { Account } from '../../../user/Account';
import { Context } from '../../context';
import { IosAppCredentials, getAppLookupParams } from '../credentials';
import { selectDistributionCertificateAsync } from './DistributionCertificateUtils';
import { RemoveSpecificProvisioningProfile } from './RemoveProvisioningProfile';
import { AppLookupParams } from '../api/GraphqlClient';
import { selectDistributionCertificateWithDependenciesAsync } from './DistributionCertificateUtils';
import { RemoveProvisioningProfiles } from './RemoveProvisioningProfile';
interface RemoveOptions {
shouldRevoke?: boolean;
}
export class SelectAndRemoveDistributionCertificate {
constructor(private account: Account) {}
export class RemoveDistributionCertificate implements Action {
constructor(private accountName: string, private options: RemoveOptions = {}) {}
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const selected = await selectDistributionCertificateAsync(ctx, this.accountName);
if (selected?.id) {
await manager.runActionAsync(
new RemoveSpecificDistributionCertificate(selected?.id, this.accountName, this.options)
);
async runAsync(ctx: Context): Promise<void> {
const selected = await selectDistributionCertificateWithDependenciesAsync(ctx, this.account);
if (selected) {
await new RemoveDistributionCertificate(this.account, selected).runAsync(ctx);
Log.succeed('Removed distribution certificate');
Log.newLine();
}
}
}
interface RemoveSpecificOptions {
shouldRevoke?: boolean;
}
export class RemoveSpecificDistributionCertificate implements Action {
export class RemoveDistributionCertificate {
constructor(
private userCredentialsId: number | string,
private accountName: string,
private options: RemoveSpecificOptions = {}
private account: Account,
private distributionCertificate: AppleDistributionCertificateFragment
) {}
public async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const distributionCertificate = await ctx.ios.getDistributionCertificateByIdAsync(
this.userCredentialsId,
this.accountName
public async runAsync(ctx: Context): Promise<void> {
const apps = this.distributionCertificate.iosAppBuildCredentialsList.map(
buildCredentials => buildCredentials.iosAppCredentials.app
);
const credentials = await ctx.ios.getAllCredentialsAsync(this.accountName);
const apps = credentials.appCredentials.filter(
cred => cred.distCredentialsId === this.userCredentialsId
);
const appList = apps.map(appCred => chalk.green(appCred.experienceName)).join(', ');
if (appList && !ctx.nonInteractive) {
if (apps.length !== 0) {
const appFullNames = apps.map(app => app.fullName).join(',');
if (ctx.nonInteractive) {
throw new Error(
`Certificate is currently used by ${appFullNames} and cannot be deleted in non-interactive mode.`
);
}
const confirm = await confirmAsync({
message: `You are removing certificate used by ${appList}. Do you want to continue?`,
message: `You are removing certificate used by ${appFullNames}. Do you want to continue?`,
});
if (!confirm) {
Log.log('Aborting');
@@ -60,43 +50,41 @@ export class RemoveSpecificDistributionCertificate implements Action {
}
Log.log('Removing Distribution Certificate');
await ctx.ios.deleteDistributionCertificateAsync(this.userCredentialsId, this.accountName);
await ctx.ios.deleteDistributionCertificateAsync(this.distributionCertificate.id);
let shouldRevoke = this.options.shouldRevoke;
if (distributionCertificate.certId) {
if (!shouldRevoke && !ctx.nonInteractive) {
if (this.distributionCertificate.developerPortalIdentifier) {
let shouldRevoke = false;
if (!ctx.nonInteractive) {
shouldRevoke = await confirmAsync({
message: `Do you also want to revoke this Distribution Certificate on Apple Developer Portal?`,
});
} else if (ctx.nonInteractive) {
Log.log('Skipping certificate revocation on the Apple Developer Portal.');
}
if (shouldRevoke) {
await ctx.appStore.revokeDistributionCertificateAsync([distributionCertificate.certId]);
await ctx.appStore.revokeDistributionCertificateAsync([
this.distributionCertificate.developerPortalIdentifier,
]);
}
}
await this.removeInvalidProvisioningProfilesAsync(manager, ctx, apps, shouldRevoke);
await this.removeInvalidProvisioningProfilesAsync(ctx);
}
private async removeInvalidProvisioningProfilesAsync(
manager: CredentialsManager,
ctx: Context,
apps: IosAppCredentials[],
shouldRevoke?: boolean
) {
for (const appCredentials of apps) {
const appLookupParams = getAppLookupParams(
appCredentials.experienceName,
appCredentials.bundleIdentifier
);
if (!(await ctx.ios.getProvisioningProfileAsync(appLookupParams))) {
continue;
private async removeInvalidProvisioningProfilesAsync(ctx: Context): Promise<void> {
const buildCredentialsList = this.distributionCertificate.iosAppBuildCredentialsList;
const appsWithProfilesToRemove: AppLookupParams[] = [];
const profilesToRemove: AppleProvisioningProfileIdentifiersFragment[] = [];
for (const buildCredentials of buildCredentialsList) {
const projectName = buildCredentials.iosAppCredentials.app.slug;
const { bundleIdentifier } = buildCredentials.iosAppCredentials.appleAppIdentifier;
const appLookupParams = { account: this.account, projectName, bundleIdentifier };
const maybeProvisioningProfile = buildCredentials.provisioningProfile;
if (maybeProvisioningProfile) {
appsWithProfilesToRemove.push(appLookupParams);
profilesToRemove.push(maybeProvisioningProfile);
}
Log.log(
`Removing Provisioning Profile for ${appCredentials.experienceName} (${appCredentials.bundleIdentifier})`
);
await manager.runActionAsync(
new RemoveSpecificProvisioningProfile(appLookupParams, { shouldRevoke })
);
}
await new RemoveProvisioningProfiles(appsWithProfilesToRemove, profilesToRemove).runAsync(ctx);
}
}
@@ -1,48 +1,32 @@
import { assert } from '@expo/config';
import { AppleProvisioningProfileIdentifiersFragment } from '../../../graphql/generated';
import Log from '../../../log';
import { confirmAsync } from '../../../prompts';
import { Action, CredentialsManager } from '../../CredentialsManager';
import { Context } from '../../context';
import { AppLookupParams, getAppLookupParams } from '../credentials';
import { selectProvisioningProfileFromExpoAsync } from './ProvisioningProfileUtils';
import { AppLookupParams } from '../api/GraphqlClient';
interface RemoveOptions {
shouldRevoke?: boolean;
}
export class RemoveProvisioningProfile implements Action {
constructor(private accountName: string, private options: RemoveOptions = {}) {}
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const selected = await selectProvisioningProfileFromExpoAsync(ctx, this.accountName);
if (selected) {
const app = getAppLookupParams(selected.experienceName, selected.bundleIdentifier);
await manager.runActionAsync(new RemoveSpecificProvisioningProfile(app, this.options));
}
}
}
interface RemoveSpecificOptions {
shouldRevoke?: boolean;
}
export class RemoveSpecificProvisioningProfile implements Action {
constructor(private app: AppLookupParams, private options: RemoveSpecificOptions = {}) {}
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
await ctx.ios.deleteProvisioningProfileAsync(this.app);
Log.succeed(
`Removed provisioning profile for @${this.app.accountName}/${this.app.projectName} (${this.app.bundleIdentifier})`
export class RemoveProvisioningProfiles {
constructor(
private apps: AppLookupParams[],
private provisioningProfiles: AppleProvisioningProfileIdentifiersFragment[]
) {
assert(
apps.length === provisioningProfiles.length,
'apps must correspond to the provisioning profiles being removed'
);
}
let { shouldRevoke } = this.options;
if (!shouldRevoke && !ctx.nonInteractive) {
shouldRevoke = await confirmAsync({
message: 'Do you also want to revoke this provisioning profile on Apple Developer Portal?',
});
}
if (shouldRevoke) {
await ctx.appStore.revokeProvisioningProfileAsync(this.app.bundleIdentifier);
async runAsync(ctx: Context): Promise<void> {
if (this.provisioningProfiles.length === 0) {
Log.log(`Skipping deletion of Provisioning Profiles`);
return;
}
await ctx.ios.deleteProvisioningProfilesAsync(
this.provisioningProfiles.map(profile => profile.id)
);
const appAndBundles = this.apps
.map(app => `@${app.account.name}/${app.projectName} (${app.bundleIdentifier})`)
.join(',');
Log.succeed(`Successfully removed provisioning profiles for ${appAndBundles}`);
}
}
@@ -4,20 +4,21 @@ import differenceBy from 'lodash/differenceBy';
import isEqual from 'lodash/isEqual';
import nullthrows from 'nullthrows';
import DeviceCreateAction, { RegistrationMethod } from '../../../../devices/actions/create/action';
import DeviceCreateAction, { RegistrationMethod } from '../../../devices/actions/create/action';
import {
AppleDeviceFragment,
AppleDistributionCertificateFragment,
AppleProvisioningProfileFragment,
AppleTeamFragment,
IosAppBuildCredentialsFragment,
IosDistributionType,
} from '../../../../graphql/generated';
import Log from '../../../../log';
import { confirmAsync, pressAnyKeyToContinueAsync } from '../../../../prompts';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { MissingCredentialsNonInteractiveError } from '../../errors';
import { validateProvisioningProfileAsync } from '../../validators/validateProvisioningProfile';
} from '../../../graphql/generated';
import Log from '../../../log';
import { confirmAsync, pressAnyKeyToContinueAsync } from '../../../prompts';
import { Context } from '../../context';
import { AppLookupParams } from '../api/GraphqlClient';
import { MissingCredentialsNonInteractiveError } from '../errors';
import { validateProvisioningProfileAsync } from '../validators/validateProvisioningProfile';
import { resolveAppleTeamIfAuthenticatedAsync } from './AppleTeamUtils';
import { assignBuildCredentialsAsync, getBuildCredentialsAsync } from './BuildCredentialsUtils';
import { chooseDevices, formatDeviceLabel } from './DeviceUtils';
@@ -56,6 +57,19 @@ export class SetupAdhocProvisioningProfile {
}
}
return await this.runWithDistributionCertificateAsync(ctx, distCert);
}
async runWithDistributionCertificateAsync(
ctx: Context,
distCert: AppleDistributionCertificateFragment
): Promise<IosAppBuildCredentialsFragment> {
const currentBuildCredentials = await getBuildCredentialsAsync(
ctx,
this.app,
IosDistributionType.AdHoc
);
// 1. Resolve Apple Team
let appleTeam: AppleTeamFragment | null =
distCert.appleTeam ?? currentBuildCredentials?.provisioningProfile?.appleTeam ?? null;
@@ -66,7 +80,7 @@ export class SetupAdhocProvisioningProfile {
assert(appleTeam, 'Apple Team must be defined here');
// 2. Fetch devices registered on EAS servers
let registeredAppleDevices = await ctx.newIos.getDevicesForAppleTeamAsync(this.app, appleTeam);
let registeredAppleDevices = await ctx.ios.getDevicesForAppleTeamAsync(this.app, appleTeam);
if (registeredAppleDevices.length === 0) {
const shouldRegisterDevices = await confirmAsync({
message: `You don't have any registered devices yet. Would you like to register them now?`,
@@ -94,7 +108,7 @@ export class SetupAdhocProvisioningProfile {
);
// 5. Create or update the profile on servers
const appleAppIdentifier = await ctx.newIos.createOrGetExistingAppleAppIdentifierAsync(
const appleAppIdentifier = await ctx.ios.createOrGetExistingAppleAppIdentifierAsync(
this.app,
appleTeam
);
@@ -104,10 +118,10 @@ export class SetupAdhocProvisioningProfile {
currentBuildCredentials.provisioningProfile.developerPortalIdentifier !==
provisioningProfileStoreInfo.provisioningProfileId
) {
await ctx.newIos.deleteProvisioningProfilesAsync([
await ctx.ios.deleteProvisioningProfilesAsync([
currentBuildCredentials.provisioningProfile.id,
]);
appleProvisioningProfile = await ctx.newIos.createProvisioningProfileAsync(
appleProvisioningProfile = await ctx.ios.createProvisioningProfileAsync(
this.app,
appleAppIdentifier,
{
@@ -119,7 +133,7 @@ export class SetupAdhocProvisioningProfile {
appleProvisioningProfile = currentBuildCredentials.provisioningProfile;
}
} else {
appleProvisioningProfile = await ctx.newIos.createProvisioningProfileAsync(
appleProvisioningProfile = await ctx.ios.createProvisioningProfileAsync(
this.app,
appleAppIdentifier,
{
@@ -157,10 +171,7 @@ export class SetupAdhocProvisioningProfile {
const provisioningProfile = nullthrows(buildCredentials.provisioningProfile);
const appleTeam = nullthrows(provisioningProfile.appleTeam);
const registeredAppleDevices = await ctx.newIos.getDevicesForAppleTeamAsync(
this.app,
appleTeam
);
const registeredAppleDevices = await ctx.ios.getDevicesForAppleTeamAsync(this.app, appleTeam);
const provisionedDevices = provisioningProfile.appleDevices;
@@ -202,7 +213,7 @@ export class SetupAdhocProvisioningProfile {
}
Log.newLine();
const devices = await ctx.newIos.getDevicesForAppleTeamAsync(this.app, appleTeam, {
const devices = await ctx.ios.getDevicesForAppleTeamAsync(this.app, appleTeam, {
useCache: false,
});
if (devices.length === 0) {
@@ -1,23 +1,19 @@
import { IosDistributionType, IosEnterpriseProvisioning } from '@expo/eas-json';
import chalk from 'chalk';
import nullthrows from 'nullthrows';
import {
IosDistributionType as GraphQLIosDistributionType,
IosAppBuildCredentialsFragment,
} from '../../../graphql/generated';
import Log from '../../../log';
import { promptAsync } from '../../../prompts';
import { Action, CredentialsManager } from '../../CredentialsManager';
import { Context } from '../../context';
import { isCredentialsMap, readIosCredentialsAsync } from '../../credentialsJson/read';
import { AppLookupParams as GraphQLAppLookupParams } from '../api/GraphqlClient';
import { AppLookupParams, IosAppCredentials } from '../credentials';
import { displayProjectCredentials as legacyDisplayProjectCredentials } from '../utils/printCredentials';
import { displayProjectCredentials } from '../utils/printCredentialsBeta';
import { readAppleTeam } from '../utils/provisioningProfile';
import { SetupAdhocProvisioningProfile } from './new/SetupAdhocProvisioningProfile';
import { SetupInternalProvisioningProfile } from './new/SetupInternalProvisioningProfile';
import { SetupProvisioningProfile } from './new/SetupProvisioningProfile';
import { displayProjectCredentials } from '../utils/printCredentials';
import { SetupAdhocProvisioningProfile } from './SetupAdhocProvisioningProfile';
import { SetupInternalProvisioningProfile } from './SetupInternalProvisioningProfile';
import { SetupProvisioningProfile } from './SetupProvisioningProfile';
interface Options {
app: GraphQLAppLookupParams;
@@ -26,10 +22,19 @@ interface Options {
skipCredentialsCheck?: boolean;
}
export class SetupBuildCredentials implements Action {
interface IosAppBuildCredentials {
iosDistributionType: GraphQLIosDistributionType;
provisioningProfile: string;
distributionCertificate: {
certificateP12: string;
certificatePassword: string;
};
}
export class SetupBuildCredentials implements Action<IosAppBuildCredentials> {
constructor(private options: Options) {}
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
async runAsync(manager: CredentialsManager, ctx: Context): Promise<IosAppBuildCredentials> {
const { app } = this.options;
await ctx.bestEffortAppStoreAuthenticateAsync();
@@ -46,12 +51,21 @@ export class SetupBuildCredentials implements Action {
}
try {
const buildCredentials = await this.setupBuildCredentials(ctx);
const appInfo = `@${app.account.name}/${app.projectName} (${app.bundleIdentifier})`;
displayProjectCredentials(app, buildCredentials);
Log.newLine();
Log.log(chalk.green(`All credentials are ready to build ${appInfo}`));
Log.newLine();
return {
iosDistributionType: buildCredentials.iosDistributionType,
provisioningProfile: nullthrows(buildCredentials.provisioningProfile?.provisioningProfile),
distributionCertificate: {
certificateP12: nullthrows(buildCredentials.distributionCertificate?.certificateP12),
certificatePassword: nullthrows(
buildCredentials.distributionCertificate?.certificatePassword
),
},
};
} catch (error) {
Log.error('Failed to setup credentials.');
throw error;
@@ -78,94 +92,3 @@ export class SetupBuildCredentials implements Action {
}
}
}
export class SetupBuildCredentialsFromCredentialsJson implements Action {
constructor(private app: AppLookupParams) {}
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
let localCredentials;
try {
localCredentials = await readIosCredentialsAsync(ctx.projectDir);
} catch (error) {
Log.error(
'Reading credentials from credentials.json failed. Make sure this file is correct and all credentials are present there.'
);
throw error;
}
// TODO: implement storing multi-target credentials on EAS servers
if (isCredentialsMap(localCredentials)) {
throw new Error(
'Storing multi-target iOS credentials from credentials.json on EAS servers is not yet supported.'
);
}
const team = readAppleTeam(localCredentials.provisioningProfile);
await ctx.ios.updateProvisioningProfileAsync(this.app, {
...team,
provisioningProfile: localCredentials.provisioningProfile,
});
const credentials = await ctx.ios.getAllCredentialsAsync(this.app.accountName);
const distCert = await ctx.ios.getDistributionCertificateAsync(this.app);
const appsUsingCert = distCert?.id
? (credentials.appCredentials || []).filter(
(cred: IosAppCredentials) => cred.distCredentialsId === distCert.id
)
: [];
const appInfo = `@${this.app.accountName}/${this.app.projectName} (${this.app.bundleIdentifier})`;
const newDistCert = {
...team,
certP12: localCredentials.distributionCertificate.certP12,
certPassword: localCredentials.distributionCertificate.certPassword,
};
if (appsUsingCert.length > 1 && distCert?.id) {
const { update } = await promptAsync({
type: 'select',
name: 'update',
message:
'Current distribution certificate is used by multiple apps. Do you want to update all of them?',
choices: [
{ title: 'Update all apps', value: 'all' },
{ title: `Update only ${appInfo}`, value: 'app' },
],
});
if (update === 'all') {
await ctx.ios.updateDistributionCertificateAsync(
distCert.id,
this.app.accountName,
newDistCert
);
} else {
const createdDistCert = await ctx.ios.createDistributionCertificateAsync(
this.app.accountName,
newDistCert
);
await ctx.ios.useDistributionCertificateAsync(this.app, createdDistCert.id);
}
} else if (distCert?.id) {
await ctx.ios.updateDistributionCertificateAsync(
distCert.id,
this.app.accountName,
newDistCert
);
} else {
const createdDistCert = await ctx.ios.createDistributionCertificateAsync(
this.app.accountName,
newDistCert
);
await ctx.ios.useDistributionCertificateAsync(this.app, createdDistCert.id);
}
legacyDisplayProjectCredentials(
this.app,
await ctx.ios.getAppCredentialsAsync(this.app),
undefined,
await ctx.ios.getDistributionCertificateAsync(this.app)
);
Log.newLine();
Log.log(chalk.green(`All credentials are ready to build ${appInfo}`));
Log.newLine();
}
}
@@ -7,18 +7,18 @@ import {
AppleTeamFragment,
IosAppBuildCredentialsFragment,
IosDistributionType,
} from '../../../../graphql/generated';
import Log from '../../../../log';
import { confirmAsync } from '../../../../prompts';
import { Context } from '../../../context';
} from '../../../graphql/generated';
import Log from '../../../log';
import { confirmAsync } from '../../../prompts';
import { Context } from '../../context';
import {
IosTargetCredentials,
isCredentialsMap,
readIosCredentialsAsync,
} from '../../../credentialsJson/read';
import { AppLookupParams } from '../../api/GraphqlClient';
import { displayProjectCredentials } from '../../utils/printCredentialsBeta';
import { readAppleTeam } from '../../utils/provisioningProfile';
} from '../../credentialsJson/read';
import { AppLookupParams } from '../api/GraphqlClient';
import { displayProjectCredentials } from '../utils/printCredentials';
import { readAppleTeam } from '../utils/provisioningProfile';
import {
assignBuildCredentialsAsync,
getBuildCredentialsAsync,
@@ -39,7 +39,7 @@ export class SetupBuildCredentialsFromCredentialsJson {
const { certP12, certPassword } = distributionCertificate;
if (!currentDistributionCertificate) {
return await ctx.newIos.createDistributionCertificateAsync(this.app, {
return await ctx.ios.createDistributionCertificateAsync(this.app.account, {
certP12,
certPassword,
teamId: appleTeam.appleTeamIdentifier,
@@ -49,7 +49,7 @@ export class SetupBuildCredentialsFromCredentialsJson {
const isSameCertificate = currentDistributionCertificate.certificateP12 === certP12;
if (!isSameCertificate) {
return await ctx.newIos.createDistributionCertificateAsync(this.app, {
return await ctx.ios.createDistributionCertificateAsync(this.app.account, {
certP12,
certPassword,
teamId: appleTeam.appleTeamIdentifier,
@@ -68,11 +68,11 @@ export class SetupBuildCredentialsFromCredentialsJson {
): Promise<AppleProvisioningProfileFragment> {
const { provisioningProfile } = targetCredentials;
const appleAppIdentifier = await ctx.newIos.createOrGetExistingAppleAppIdentifierAsync(
const appleAppIdentifier = await ctx.ios.createOrGetExistingAppleAppIdentifierAsync(
this.app,
appleTeam
);
return await ctx.newIos.createProvisioningProfileAsync(this.app, appleAppIdentifier, {
return await ctx.ios.createProvisioningProfileAsync(this.app, appleAppIdentifier, {
appleProvisioningProfile: provisioningProfile,
});
}
@@ -128,7 +128,7 @@ export class SetupBuildCredentialsFromCredentialsJson {
// new credentials from local json
const appleTeamFromProvisioningProfile = readAppleTeam(localCredentials.provisioningProfile);
const appleTeam = await ctx.newIos.createOrGetExistingAppleTeamAsync(this.app, {
const appleTeam = await ctx.ios.createOrGetExistingAppleTeamAsync(this.app.account, {
appleTeamIdentifier: appleTeamFromProvisioningProfile.teamId,
appleTeamName: appleTeamFromProvisioningProfile.teamName,
});
@@ -5,14 +5,14 @@ import {
AppleDistributionCertificate,
AppleDistributionCertificateFragment,
IosDistributionType,
} from '../../../../graphql/generated';
import Log from '../../../../log';
import { confirmAsync, promptAsync } from '../../../../prompts';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { AppleDistributionCertificateMutationResult } from '../../api/graphql/mutations/AppleDistributionCertificateMutation';
import { getValidCertSerialNumbers } from '../../appstore/CredentialsUtils';
import { AppleTeamMissingError, MissingCredentialsNonInteractiveError } from '../../errors';
} from '../../../graphql/generated';
import Log from '../../../log';
import { confirmAsync, promptAsync } from '../../../prompts';
import { Context } from '../../context';
import { AppLookupParams } from '../api/GraphqlClient';
import { AppleDistributionCertificateMutationResult } from '../api/graphql/mutations/AppleDistributionCertificateMutation';
import { getValidCertSerialNumbers } from '../appstore/CredentialsUtils';
import { AppleTeamMissingError, MissingCredentialsNonInteractiveError } from '../errors';
import { resolveAppleTeamIfAuthenticatedAsync } from './AppleTeamUtils';
import { CreateDistributionCertificate } from './CreateDistributionCertificate';
import { formatDistributionCertificate } from './DistributionCertificateUtils';
@@ -26,7 +26,7 @@ export class SetupDistributionCertificate {
const appleTeam = await resolveAppleTeamIfAuthenticatedAsync(ctx, this.app);
try {
const currentCertificate = await ctx.newIos.getDistributionCertificateForAppAsync(
const currentCertificate = await ctx.ios.getDistributionCertificateForAppAsync(
this.app,
this.distributionType,
{ appleTeam }
@@ -80,6 +80,22 @@ export class SetupDistributionCertificate {
if (!currentCertificate) {
return false;
}
const now = new Date();
if (
now < new Date(currentCertificate.validityNotBefore) ||
now > new Date(currentCertificate.validityNotAfter)
) {
return false;
}
if (!ctx.appStore.authCtx) {
Log.warn(
"Skipping Distribution Certificate validation on Apple Servers because we aren't authenticated."
);
return true;
}
const validCertSerialNumbers = (await this.getValidDistCertsAsync(ctx)).map(
i => i.serialNumber
);
@@ -130,10 +146,10 @@ export class SetupDistributionCertificate {
private async createNewDistCertAsync(
ctx: Context
): Promise<AppleDistributionCertificateMutationResult> {
return new CreateDistributionCertificate(this.app).runAsync(ctx);
return new CreateDistributionCertificate(this.app.account).runAsync(ctx);
}
private async reuseDistCertAsync(ctx: Context): Promise<AppleDistributionCertificate> {
async reuseDistCertAsync(ctx: Context): Promise<AppleDistributionCertificate> {
const validDistCerts = await this.getValidDistCertsAsync(ctx);
const { distCert } = await promptAsync({
type: 'select',
@@ -159,7 +175,7 @@ export class SetupDistributionCertificate {
);
const validDistCertSerialNumberSet = new Set(validDistCertSerialNumbers);
const distCertsForAccount = await ctx.newIos.getDistributionCertificatesForAccountAsync(
const distCertsForAccount = await ctx.ios.getDistributionCertificatesForAccountAsync(
this.app.account
);
const distCertsForAppleTeam = distCertsForAccount.filter(distCert => {
@@ -0,0 +1,115 @@
import { IosAppBuildCredentialsFragment, IosDistributionType } from '../../../graphql/generated';
import Log from '../../../log';
import { promptAsync } from '../../../prompts';
import { Context } from '../../context';
import { AppLookupParams } from '../api/GraphqlClient';
import { getAllBuildCredentialsAsync } from './BuildCredentialsUtils';
import { SetupAdhocProvisioningProfile } from './SetupAdhocProvisioningProfile';
import { SetupProvisioningProfile } from './SetupProvisioningProfile';
/**
* It's used when setting up credentials for internal distribution but `enterpriseProvisioning` is not set.
*
* TLDR: If the user authenticates with an account with Apple Developer Enterprise Program membership we ask them
* to choose if they want to set up an adhoc or universal distribution provisioning profile. Otherwise, always
* set up an adhoc provisioning profile.
*/
export class SetupInternalProvisioningProfile {
constructor(private app: AppLookupParams) {}
async runAsync(ctx: Context): Promise<IosAppBuildCredentialsFragment> {
const buildCredentials = await getAllBuildCredentialsAsync(ctx, this.app);
const adhocBuildCredentialsExist =
buildCredentials.filter(
({ iosDistributionType }) => iosDistributionType === IosDistributionType.AdHoc
).length > 0;
const enterpriseBuildCredentialsExist =
buildCredentials.filter(
({ iosDistributionType }) => iosDistributionType === IosDistributionType.Enterprise
).length > 0;
if (!ctx.nonInteractive) {
if (ctx.appStore.authCtx) {
if (ctx.appStore.authCtx.team.inHouse) {
return await this.askForDistributionTypeAndSetupAsync(
ctx,
'Which credentials would you like to set up?'
);
} else {
return await this.setupAdhocProvisioningProfileAsync(ctx);
}
} else {
if (adhocBuildCredentialsExist && enterpriseBuildCredentialsExist) {
Log.log('You have set up both adhoc and universal distribution credentials.');
return await this.askForDistributionTypeAndSetupAsync(
ctx,
'Which credentials would you like to use?'
);
} else if (adhocBuildCredentialsExist) {
return await this.setupAdhocProvisioningProfileAsync(ctx);
} else if (enterpriseBuildCredentialsExist) {
return await this.setupUniversalProvisioningProfileAsync(ctx);
} else {
const { team } = await ctx.appStore.ensureAuthenticatedAsync();
if (team.inHouse) {
return await this.askForDistributionTypeAndSetupAsync(
ctx,
'Which credentials would you like to set up?'
);
} else {
return await this.setupAdhocProvisioningProfileAsync(ctx);
}
}
}
} else {
if (adhocBuildCredentialsExist && enterpriseBuildCredentialsExist) {
throw new Error(
`You're in non-interactive mode. You have set up both adhoc and universal distribution credentials. Please set the 'enterpriseProvisioning' property (to 'adhoc' or 'universal') in eas.json to choose the credentials to use.`
);
} else if (adhocBuildCredentialsExist) {
return await this.setupAdhocProvisioningProfileAsync(ctx);
} else if (enterpriseBuildCredentialsExist) {
return await this.setupUniversalProvisioningProfileAsync(ctx);
} else {
throw new Error(
`You're in non-interactive mode. EAS CLI couldn't find any credentials suitable for internal distribution. Please run again in interactive mode.`
);
}
}
}
private async setupAdhocProvisioningProfileAsync(
ctx: Context
): Promise<IosAppBuildCredentialsFragment> {
return await new SetupAdhocProvisioningProfile(this.app).runAsync(ctx);
}
private async setupUniversalProvisioningProfileAsync(
ctx: Context
): Promise<IosAppBuildCredentialsFragment> {
return await new SetupProvisioningProfile(this.app, IosDistributionType.Enterprise).runAsync(
ctx
);
}
private async askForDistributionTypeAndSetupAsync(
ctx: Context,
message: string
): Promise<IosAppBuildCredentialsFragment> {
const { distributionType } = await promptAsync({
type: 'select',
name: 'distributionType',
message,
choices: [
{ title: 'Universal Distribution', value: IosDistributionType.Enterprise },
{ title: 'Adhoc Distribution', value: IosDistributionType.AdHoc },
],
});
if (distributionType === IosDistributionType.Enterprise) {
return await this.setupUniversalProvisioningProfileAsync(ctx);
} else {
return await this.setupAdhocProvisioningProfileAsync(ctx);
}
}
}
@@ -5,14 +5,13 @@ import {
AppleProvisioningProfileFragment,
IosAppBuildCredentialsFragment,
IosDistributionType,
} from '../../../../graphql/generated';
import { confirmAsync } from '../../../../prompts';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { ProvisioningProfileStoreInfo } from '../../appstore/Credentials.types';
import { MissingCredentialsNonInteractiveError } from '../../errors';
import { validateProvisioningProfileAsync } from '../../validators/validateProvisioningProfile';
import { formatProvisioningProfileFromApple } from '../ProvisioningProfileUtils';
} from '../../../graphql/generated';
import { confirmAsync } from '../../../prompts';
import { Context } from '../../context';
import { AppLookupParams } from '../api/GraphqlClient';
import { ProvisioningProfileStoreInfo } from '../appstore/Credentials.types';
import { MissingCredentialsNonInteractiveError } from '../errors';
import { validateProvisioningProfileAsync } from '../validators/validateProvisioningProfile';
import {
assignBuildCredentialsAsync,
getBuildCredentialsAsync,
@@ -20,8 +19,12 @@ import {
} from './BuildCredentialsUtils';
import { ConfigureProvisioningProfile } from './ConfigureProvisioningProfile';
import { CreateProvisioningProfile } from './CreateProvisioningProfile';
import { formatProvisioningProfileFromApple } from './ProvisioningProfileUtils';
import { SetupDistributionCertificate } from './SetupDistributionCertificate';
/**
* Sets up either APP_STORE or ENTERPRISE provisioning profiles
*/
export class SetupProvisioningProfile {
constructor(private app: AppLookupParams, private distributionType: IosDistributionType) {}
@@ -37,7 +40,7 @@ export class SetupProvisioningProfile {
): Promise<IosAppBuildCredentialsFragment> {
const buildCredentials = await this.createAndAssignProfileAsync(ctx, distCert);
// delete 'currentProfile' since its no longer valid
await ctx.newIos.deleteProvisioningProfilesAsync([currentProfile.id]);
await ctx.ios.deleteProvisioningProfilesAsync([currentProfile.id]);
return buildCredentials;
}
@@ -1,23 +1,18 @@
import { Platform } from '@expo/eas-build-job';
import { IosDistributionType as IosDistributionTypeGraphql } from '../../../graphql/generated';
import Log from '../../../log';
import { ensureAppIdentifierIsDefinedAsync } from '../../../project/projectUtils';
import { Action, CredentialsManager } from '../../CredentialsManager';
import { Context } from '../../context';
import { updateIosCredentialsAsync } from '../../credentialsJson/update';
import { AppLookupParams } from '../credentials';
import { AppLookupParams } from '../api/GraphqlClient';
export class UpdateCredentialsJson implements Action {
constructor(private app: AppLookupParams) {}
export class UpdateCredentialsJson {
constructor(
private app: AppLookupParams,
private iosDistributionTypeGraphql: IosDistributionTypeGraphql
) {}
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const bundleIdentifer = await ensureAppIdentifierIsDefinedAsync({
projectDir: ctx.projectDir,
platform: Platform.IOS,
exp: ctx.exp,
});
async runAsync(ctx: Context): Promise<void> {
Log.log('Updating iOS credentials in credentials.json');
await updateIosCredentialsAsync(ctx, bundleIdentifer);
await updateIosCredentialsAsync(ctx, this.app, this.iosDistributionTypeGraphql);
Log.succeed(
'iOS part of your local credentials.json is synced with values stored on EAS servers.'
);
@@ -1,87 +0,0 @@
import chalk from 'chalk';
import Log from '../../../log';
import { confirmAsync } from '../../../prompts';
import { Action, CredentialsManager } from '../../CredentialsManager';
import { Context } from '../../context';
import { getAppLookupParams } from '../credentials';
import { displayIosUserCredentials } from '../utils/printCredentials';
import {
provideOrGenerateDistributionCertificateAsync,
selectDistributionCertificateAsync,
} from './DistributionCertificateUtils';
import { RemoveSpecificProvisioningProfile } from './RemoveProvisioningProfile';
export class UpdateDistributionCertificate implements Action {
constructor(private accountName: string) {}
public async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const selected = await selectDistributionCertificateAsync(ctx, this.accountName);
if (!selected) {
return;
}
const credentials = await ctx.ios.getAllCredentialsAsync(this.accountName);
const apps = credentials.appCredentials.filter(cred => cred.distCredentialsId === selected.id);
const appList = apps.map(appCred => chalk.green(appCred.experienceName)).join(', ');
if (apps.length > 1) {
if (ctx.nonInteractive) {
throw new Error(
`Start the CLI without the '--non-interactive' flag to update the certificate used by ${appList}.`
);
}
const confirm = await confirmAsync({
message: `You are updating certificate used by ${appList}. Do you want to continue?`,
});
if (!confirm) {
Log.log('Aborting update process');
return;
}
}
await manager.runActionAsync(
new UpdateSpecificDistributionCertificate(selected.id, this.accountName)
);
const newDistCert = await ctx.ios.getDistributionCertificateByIdAsync(
selected.id,
this.accountName
);
displayIosUserCredentials(newDistCert);
Log.newLine();
}
}
export class UpdateSpecificDistributionCertificate implements Action {
constructor(private userCredentialsId: number | string, private accountName: string) {}
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const credentials = await ctx.ios.getAllCredentialsAsync(this.accountName);
const apps = credentials.appCredentials.filter(
cred => cred.distCredentialsId === this.userCredentialsId
);
const newDistCert = await provideOrGenerateDistributionCertificateAsync(ctx, this.accountName);
await ctx.ios.updateDistributionCertificateAsync(
this.userCredentialsId,
this.accountName,
newDistCert
);
Log.succeed('Updated distribution certificate');
Log.newLine();
for (const appCredentials of apps) {
Log.log(
`Removing provisioning profile for ${appCredentials.experienceName} (${appCredentials.bundleIdentifier})`
);
const appLookupParams = getAppLookupParams(
appCredentials.experienceName,
appCredentials.bundleIdentifier
);
await manager.runActionAsync(
new RemoveSpecificProvisioningProfile(appLookupParams, { shouldRevoke: true })
);
}
}
}
@@ -1,34 +0,0 @@
import Log from '../../../log';
import { Action, CredentialsManager } from '../../CredentialsManager';
import { Context } from '../../context';
import { AppLookupParams } from '../credentials';
import { ConfigureProvisioningProfile } from './ConfigureProvisioningProfile';
import { selectDistributionCertificateAsync } from './DistributionCertificateUtils';
export class UseExistingDistributionCertificate implements Action {
constructor(private app: AppLookupParams) {}
public async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
const selected = await selectDistributionCertificateAsync(ctx, this.app.accountName, {
filterInvalid: true,
});
if (selected) {
await manager.runActionAsync(new UseSpecificDistributionCertificate(this.app, selected.id));
}
const profile = await ctx.ios.getProvisioningProfileAsync(this.app);
if (profile) {
await manager.runActionAsync(new ConfigureProvisioningProfile(this.app));
}
}
}
export class UseSpecificDistributionCertificate implements Action {
constructor(private app: AppLookupParams, private userCredentialsId: number | string) {}
public async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
await ctx.ios.useDistributionCertificateAsync(this.app, this.userCredentialsId);
Log.succeed(
`Assigned distribution certificate to @${this.app.accountName}/${this.app.projectName} (${this.app.bundleIdentifier})`
);
}
}
@@ -1,11 +1,11 @@
import {
AppleDistributionCertificateFragment,
AppleProvisioningProfileFragment,
} from '../../../../../graphql/generated';
import { testProvisioningProfileFragment } from '../../../../__tests__/fixtures-ios';
import { Context } from '../../../../context';
import { AppLookupParams } from '../../../api/GraphqlClient';
import { AppleProvisioningProfileMutationResult } from '../../../api/graphql/mutations/AppleProvisioningProfileMutation';
} from '../../../../graphql/generated';
import { testProvisioningProfileFragment } from '../../../__tests__/fixtures-ios';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { AppleProvisioningProfileMutationResult } from '../../api/graphql/mutations/AppleProvisioningProfileMutation';
export class ConfigureProvisioningProfile {
constructor(
@@ -1,8 +1,8 @@
import { AppleDistributionCertificateFragment } from '../../../../../graphql/generated';
import { testProvisioningProfileFragment } from '../../../../__tests__/fixtures-ios';
import { Context } from '../../../../context';
import { AppLookupParams } from '../../../api/GraphqlClient';
import { AppleProvisioningProfileMutationResult } from '../../../api/graphql/mutations/AppleProvisioningProfileMutation';
import { AppleDistributionCertificateFragment } from '../../../../graphql/generated';
import { testProvisioningProfileFragment } from '../../../__tests__/fixtures-ios';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { AppleProvisioningProfileMutationResult } from '../../api/graphql/mutations/AppleProvisioningProfileMutation';
export class CreateProvisioningProfile {
constructor(
@@ -1,10 +1,10 @@
import {
AppleDistributionCertificateFragment,
IosDistributionType,
} from '../../../../../graphql/generated';
import { testDistCertFragmentOneDependency } from '../../../../__tests__/fixtures-ios';
import { Context } from '../../../../context';
import { AppLookupParams } from '../../../api/GraphqlClient';
} from '../../../../graphql/generated';
import { testDistCertFragmentOneDependency } from '../../../__tests__/fixtures-ios';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
export class SetupDistributionCertificate {
constructor(private app: AppLookupParams, private distributionType: IosDistributionType) {}
@@ -1,15 +1,15 @@
import { confirmAsync } from '../../../../../prompts';
import { getAppstoreMock, testAuthCtx } from '../../../../__tests__/fixtures-appstore';
import { createCtxMock } from '../../../../__tests__/fixtures-context';
import { confirmAsync } from '../../../../prompts';
import { getAppstoreMock, testAuthCtx } from '../../../__tests__/fixtures-appstore';
import { createCtxMock } from '../../../__tests__/fixtures-context';
import {
testDistCertFragmentNoDependencies,
testProvisioningProfile,
testProvisioningProfileFragment,
} from '../../../../__tests__/fixtures-ios';
import { MissingCredentialsNonInteractiveError } from '../../../errors';
} from '../../../__tests__/fixtures-ios';
import { MissingCredentialsNonInteractiveError } from '../../errors';
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
import { ConfigureProvisioningProfile } from '../ConfigureProvisioningProfile';
jest.mock('../../../../../prompts');
jest.mock('../../../../prompts');
(confirmAsync as jest.Mock).mockImplementation(() => true);
describe('ConfigureProvisioningProfile', () => {
@@ -38,7 +38,7 @@ describe('ConfigureProvisioningProfile', () => {
await provProfConfigurator.runAsync(ctx);
// expect provisioning profile not to be updated on expo servers
expect((ctx.newIos.updateProvisioningProfileAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.updateProvisioningProfileAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile not to be updated on apple portal
expect((ctx.appStore.useExistingProvisioningProfileAsync as any).mock.calls.length).toBe(1);
});
@@ -57,7 +57,7 @@ describe('ConfigureProvisioningProfile', () => {
);
// expect provisioning profile not to be updated on expo servers
expect((ctx.newIos.updateProvisioningProfileAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.updateProvisioningProfileAsync as any).mock.calls.length).toBe(0);
// expect provisioning profile not to be updated on apple portal
expect((ctx.appStore.useExistingProvisioningProfileAsync as any).mock.calls.length).toBe(0);
});
@@ -1,14 +1,14 @@
import { confirmAsync } from '../../../../../prompts';
import { getAppstoreMock, testAuthCtx } from '../../../../__tests__/fixtures-appstore';
import { createCtxMock } from '../../../../__tests__/fixtures-context';
import { confirmAsync } from '../../../../prompts';
import { getAppstoreMock, testAuthCtx } from '../../../__tests__/fixtures-appstore';
import { createCtxMock } from '../../../__tests__/fixtures-context';
import {
testDistCertFragmentNoDependencies,
testProvisioningProfile,
} from '../../../../__tests__/fixtures-ios';
import { MissingCredentialsNonInteractiveError } from '../../../errors';
} from '../../../__tests__/fixtures-ios';
import { MissingCredentialsNonInteractiveError } from '../../errors';
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
import { CreateProvisioningProfile } from '../CreateProvisioningProfile';
jest.mock('../../../../../prompts');
jest.mock('../../../../prompts');
(confirmAsync as jest.Mock).mockImplementation(() => true);
describe('CreateProvisioningProfile', () => {
@@ -30,7 +30,7 @@ describe('CreateProvisioningProfile', () => {
await createProvProfAction.runAsync(ctx);
// expect provisioning profile to be created on expo servers
expect((ctx.newIos.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile to be created on apple portal
expect((ctx.appStore.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
});
@@ -48,7 +48,7 @@ describe('CreateProvisioningProfile', () => {
);
// expect provisioning profile not to be created on expo servers
expect((ctx.newIos.createProvisioningProfileAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.createProvisioningProfileAsync as any).mock.calls.length).toBe(0);
// expect provisioning profile not to be created on apple portal
expect((ctx.appStore.createProvisioningProfileAsync as any).mock.calls.length).toBe(0);
});
@@ -1,12 +1,12 @@
import mockdate from 'mockdate';
import { AppleDistributionCertificateQuery } from '../../../api/graphql/queries/AppleDistributionCertificateQuery';
import { AppleDistributionCertificateQuery } from '../../api/graphql/queries/AppleDistributionCertificateQuery';
import { formatDistributionCertificate } from '../DistributionCertificateUtils';
jest.mock('../../../api/graphql/queries/AppleDistributionCertificateQuery');
jest.mock('../../api/graphql/queries/AppleDistributionCertificateQuery');
jest.mock('chalk', () => {
return {
__esModule: true, // this property makes it work
default: { gray: jest.fn(log => log) },
default: { gray: jest.fn(log => log), underline: jest.fn(log => log) },
};
});
@@ -1,13 +1,13 @@
import { confirmAsync } from '../../../../../prompts';
import { createCtxMock } from '../../../../__tests__/fixtures-context';
import { confirmAsync } from '../../../../prompts';
import { createCtxMock } from '../../../__tests__/fixtures-context';
import {
testDistCertFragmentNoDependencies,
testDistCertFragmentOneDependency,
} from '../../../../__tests__/fixtures-ios';
} from '../../../__tests__/fixtures-ios';
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
import { RemoveDistributionCertificate } from '../RemoveDistributionCertificate';
jest.mock('../../../../../prompts');
jest.mock('../../../../prompts');
(confirmAsync as jest.Mock).mockImplementation(() => true);
describe('RemoveDistributionCertificate', () => {
@@ -21,11 +21,11 @@ describe('RemoveDistributionCertificate', () => {
await removeDistCertAction.runAsync(ctx);
// expect dist cert to be deleted on expo servers
expect((ctx.newIos.deleteDistributionCertificateAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.deleteDistributionCertificateAsync as any).mock.calls.length).toBe(1);
// expect dist cert to be deleted on apple portal
expect((ctx.appStore.revokeDistributionCertificateAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile deletion to be skipped because there arent any associated with the dist cert
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
});
it('deletes the distribution certificate on Expo servers when there are no App Dependencies in Non-Interactive Mode', async () => {
const ctx = createCtxMock({ nonInteractive: true });
@@ -37,11 +37,11 @@ describe('RemoveDistributionCertificate', () => {
await removeDistCertAction.runAsync(ctx);
// expect dist cert to be deleted on expo servers
expect((ctx.newIos.deleteDistributionCertificateAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.deleteDistributionCertificateAsync as any).mock.calls.length).toBe(1);
// not supported in non-interactive mode
expect((ctx.appStore.revokeDistributionCertificateAsync as any).mock.calls.length).toBe(0);
// expect provisioning profile deletion to be skipped because there arent any associated with the dist cert
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
});
it('deletes the distribution certificate and its provisioning profile on Expo and Apple servers when there are App Dependencies in Interactive Mode', async () => {
const ctx = createCtxMock({ nonInteractive: false });
@@ -53,11 +53,11 @@ describe('RemoveDistributionCertificate', () => {
await removeDistCertAction.runAsync(ctx);
// expect dist cert to be deleted on expo servers
expect((ctx.newIos.deleteDistributionCertificateAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.deleteDistributionCertificateAsync as any).mock.calls.length).toBe(1);
// expect dist cert to be deleted on apple portal
expect((ctx.appStore.revokeDistributionCertificateAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile deletion to be invoked on expo servers
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(1);
});
it('errors when the distribution certificate has App Dependencies in Non-Interactive Mode', async () => {
const ctx = createCtxMock({ nonInteractive: true });
@@ -1,4 +1,4 @@
import { createCtxMock } from '../../../../__tests__/fixtures-context';
import { createCtxMock } from '../../../__tests__/fixtures-context';
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
import { RemoveProvisioningProfiles } from '../RemoveProvisioningProfile';
@@ -17,6 +17,6 @@ describe('RemoveProvisioningProfile', () => {
await removeProfilesAction.runAsync(ctx);
// expect provisioning profile to be deleted from servers
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(1);
});
});
@@ -1,21 +1,21 @@
import { asMock } from '../../../../../__tests__/utils';
import { IosDistributionType } from '../../../../../graphql/generated';
import { confirmAsync } from '../../../../../prompts';
import { createCtxMock } from '../../../../__tests__/fixtures-context';
import { asMock } from '../../../../__tests__/utils';
import { IosDistributionType } from '../../../../graphql/generated';
import { confirmAsync } from '../../../../prompts';
import { createCtxMock } from '../../../__tests__/fixtures-context';
import {
getNewIosApiMockWithoutCredentials,
testAppleAppIdentifierFragment,
testDistCert,
testDistCertFragmentNoDependencies,
testIosAppCredentialsWithBuildCredentialsQueryResult,
testProvisioningProfile,
testProvisioningProfileFragment,
} from '../../../../__tests__/fixtures-ios';
import { getNewIosApiMockWithoutCredentials } from '../../../../__tests__/fixtures-new-ios';
import { readIosCredentialsAsync } from '../../../../credentialsJson/read';
} from '../../../__tests__/fixtures-ios';
import { readIosCredentialsAsync } from '../../../credentialsJson/read';
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
import { SetupBuildCredentialsFromCredentialsJson } from '../SetupBuildCredentialsFromCredentialsJson';
jest.mock('../../../../../prompts');
jest.mock('../../../../credentialsJson/read');
jest.mock('../../../../prompts');
jest.mock('../../../credentialsJson/read');
const originalConsoleLog = console.log;
const originalConsoleWarn = console.warn;
@@ -48,12 +48,12 @@ describe('SetupBuildCredentialsFromCredentialsJson', () => {
const testBuildCreds = JSON.parse(
JSON.stringify(testIosAppCredentialsWithBuildCredentialsQueryResult)
);
testBuildCreds.iosAppBuildCredentialsArray[0].distributionCertificate.certificateP12 =
testBuildCreds.iosAppBuildCredentialsList[0].distributionCertificate.certificateP12 =
testDistCert.certP12;
testBuildCreds.iosAppBuildCredentialsArray[0].provisioningProfile.provisioningProfile =
testBuildCreds.iosAppBuildCredentialsList[0].provisioningProfile.provisioningProfile =
testProvisioningProfile.provisioningProfile;
const ctx = createCtxMock({
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(() => testBuildCreds),
createOrGetExistingAppleAppIdentifierAsync: jest.fn(() => testAppleAppIdentifierFragment),
@@ -70,15 +70,15 @@ describe('SetupBuildCredentialsFromCredentialsJson', () => {
await setupBuildCredentialsFromCredentialsJsonAction.runAsync(ctx);
// expect build credentials not to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(0);
// expect distribution certificate not to be uploaded on expo servers
expect((ctx.newIos.createDistributionCertificateAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.createDistributionCertificateAsync as any).mock.calls.length).toBe(0);
// expect provisioning profile not to be uploaded on expo servers
expect((ctx.newIos.createProvisioningProfileAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.createProvisioningProfileAsync as any).mock.calls.length).toBe(0);
});
it('sets up build credentials with no prior configuration in Interactive Mode', async () => {
const ctx = createCtxMock({
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(() => null),
createOrGetExistingAppleAppIdentifierAsync: jest.fn(() => testAppleAppIdentifierFragment),
@@ -97,21 +97,23 @@ describe('SetupBuildCredentialsFromCredentialsJson', () => {
await setupBuildCredentialsFromCredentialsJsonAction.runAsync(ctx);
// expect build credentials to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
// expect distribution certificate to be uploaded on expo servers
expect((ctx.newIos.createDistributionCertificateAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createDistributionCertificateAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile to be uploaded on expo servers
expect((ctx.newIos.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
});
it('sets up build credentials with different prior configuration in Interactive Mode', async () => {
// create deep clone the quick and dirty way
const testBuildCreds = JSON.parse(
JSON.stringify(testIosAppCredentialsWithBuildCredentialsQueryResult)
);
testBuildCreds.iosAppBuildCredentialsArray[0].distributionCertificate.certificateP12 =
testBuildCreds.iosAppBuildCredentialsList[0].distributionCertificate.certificateP12 =
'something different so SetupBuildCredentialsFromCredentialsJson doesnt think we want to exact the same cert and skip upload to expo servers';
testBuildCreds.iosAppBuildCredentialsList[0].provisioningProfile.provisioningProfile =
'something different so SetupBuildCredentialsFromCredentialsJson doesnt think we want to exact the same cert and skip upload to expo servers';
const ctx = createCtxMock({
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(() => testBuildCreds),
createOrGetExistingAppleAppIdentifierAsync: jest.fn(() => testAppleAppIdentifierFragment),
@@ -128,22 +130,24 @@ describe('SetupBuildCredentialsFromCredentialsJson', () => {
await setupBuildCredentialsFromCredentialsJsonAction.runAsync(ctx);
// expect build credentials to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
// expect distribution certificate to be uploaded on expo servers
expect((ctx.newIos.createDistributionCertificateAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createDistributionCertificateAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile to be uploaded on expo servers
expect((ctx.newIos.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
});
it('works in Non Interactive Mode - sets up build credentials with different prior configuration', async () => {
// create deep clone the quick and dirty way
const testBuildCreds = JSON.parse(
JSON.stringify(testIosAppCredentialsWithBuildCredentialsQueryResult)
);
testBuildCreds.iosAppBuildCredentialsArray[0].distributionCertificate.certificateP12 =
testBuildCreds.iosAppBuildCredentialsList[0].distributionCertificate.certificateP12 =
'something different so SetupBuildCredentialsFromCredentialsJson doesnt think we want to exact the same cert and skip upload to expo servers';
testBuildCreds.iosAppBuildCredentialsList[0].provisioningProfile.provisioningProfile =
'something different so SetupBuildCredentialsFromCredentialsJson doesnt think we want to exact the same cert and skip upload to expo servers';
const ctx = createCtxMock({
nonInteractive: true,
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(() => testBuildCreds),
createOrGetExistingAppleAppIdentifierAsync: jest.fn(() => testAppleAppIdentifierFragment),
@@ -162,10 +166,10 @@ describe('SetupBuildCredentialsFromCredentialsJson', () => {
// expect no prompts to be called
expect((confirmAsync as any).mock.calls.length).toBe(0);
// expect build credentials to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
// expect distribution certificate to be uploaded on expo servers
expect((ctx.newIos.createDistributionCertificateAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createDistributionCertificateAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile to be uploaded on expo servers
expect((ctx.newIos.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createProvisioningProfileAsync as any).mock.calls.length).toBe(1);
});
});
@@ -0,0 +1,311 @@
import { asMock } from '../../../../__tests__/utils';
import { IosAppBuildCredentialsFragment, IosDistributionType } from '../../../../graphql/generated';
import { promptAsync } from '../../../../prompts';
import { getAppstoreMock, testAuthCtx } from '../../../__tests__/fixtures-appstore';
import { createCtxMock } from '../../../__tests__/fixtures-context';
import { getAllBuildCredentialsAsync } from '../BuildCredentialsUtils';
import { SetupAdhocProvisioningProfile } from '../SetupAdhocProvisioningProfile';
import { SetupInternalProvisioningProfile } from '../SetupInternalProvisioningProfile';
import { SetupProvisioningProfile } from '../SetupProvisioningProfile';
jest.mock('../../../../prompts');
jest.mock('../SetupAdhocProvisioningProfile');
jest.mock('../SetupProvisioningProfile');
jest.mock('../BuildCredentialsUtils', () => ({ getAllBuildCredentialsAsync: jest.fn() }));
beforeEach(() => {
asMock(promptAsync).mockReset();
asMock(getAllBuildCredentialsAsync).mockReset();
asMock(getAllBuildCredentialsAsync).mockImplementation(() => {
throw new Error(
`unhandled getAllBuildCredentialsAsync call - this shouldn't happen - fix tests!`
);
});
});
const testAdhocBuildCredentials: IosAppBuildCredentialsFragment = {
id: 'test-app-build-credentials-id-1',
iosDistributionType: IosDistributionType.AdHoc,
};
const testEnterpriseBuildCredentials: IosAppBuildCredentialsFragment = {
id: 'test-app-build-credentials-id-2',
iosDistributionType: IosDistributionType.Enterprise,
};
describe(SetupInternalProvisioningProfile, () => {
describe('interactive mode', () => {
describe('when authenticated with apple', () => {
it('runs the SetupAdhocProvisioningProfile action for non-enterprise team', async () => {
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: false,
appStore: {
...getAppstoreMock(),
ensureAuthenticatedAsync: jest.fn(() => testAuthCtx),
authCtx: testAuthCtx,
},
});
const runAsync = jest.fn();
SetupAdhocProvisioningProfile.prototype.runAsync = runAsync;
await action.runAsync(ctx);
expect(runAsync).toHaveBeenCalled();
});
it('asks the user for an action to run when they have access to an enterprise team', async () => {
asMock(promptAsync).mockImplementationOnce(() => ({
distributionType: IosDistributionType.Enterprise,
}));
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: false,
appStore: {
...getAppstoreMock(),
ensureAuthenticatedAsync: jest.fn(() => ({
...testAuthCtx,
team: { ...testAuthCtx.team, inHouse: true },
})),
authCtx: { ...testAuthCtx, team: { ...testAuthCtx.team, inHouse: true } },
},
});
const runAsync = jest.fn();
SetupProvisioningProfile.prototype.runAsync = runAsync;
await action.runAsync(ctx);
expect(runAsync).toHaveBeenCalled();
});
});
describe('when not authenticated with apple', () => {
it('asks the user for an action to run when both adhoc and universal distribution credentials exist', async () => {
asMock(promptAsync).mockImplementationOnce(() => ({
distributionType: IosDistributionType.Enterprise,
}));
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [
testAdhocBuildCredentials,
testEnterpriseBuildCredentials,
];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: false,
appStore: {
...getAppstoreMock(),
ensureAuthenticatedAsync: jest.fn(() => null),
authCtx: null,
},
});
const runAsync = jest.fn();
SetupProvisioningProfile.prototype.runAsync = runAsync;
await action.runAsync(ctx);
expect(runAsync).toHaveBeenCalled();
});
it('runs the SetupAdhocProvisioningProfile action when adhoc credentials exist', async () => {
asMock(promptAsync).mockImplementationOnce(() => ({
distributionType: IosDistributionType.Enterprise,
}));
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [testAdhocBuildCredentials];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: false,
appStore: {
...getAppstoreMock(),
ensureAuthenticatedAsync: jest.fn(() => null),
authCtx: null,
},
});
const runAsync = jest.fn();
SetupAdhocProvisioningProfile.prototype.runAsync = runAsync;
await action.runAsync(ctx);
expect(runAsync).toHaveBeenCalled();
});
it('runs the SetupProvisioningProfile action when enterprise credentials exist', async () => {
asMock(promptAsync).mockImplementationOnce(() => ({
distributionType: IosDistributionType.Enterprise,
}));
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [
testEnterpriseBuildCredentials,
];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: false,
appStore: {
...getAppstoreMock(),
ensureAuthenticatedAsync: jest.fn(() => null),
authCtx: null,
},
});
const runAsync = jest.fn();
SetupProvisioningProfile.prototype.runAsync = runAsync;
await action.runAsync(ctx);
expect(runAsync).toHaveBeenCalled();
});
it('forces the apple authentication when neither adhoc nor enterprise credentials exist', async () => {
asMock(promptAsync).mockImplementationOnce(() => ({
distributionType: IosDistributionType.Enterprise,
}));
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: false,
appStore: {
...getAppstoreMock(),
ensureAuthenticatedAsync: jest.fn(() => testAuthCtx),
authCtx: null,
},
});
await action.runAsync(ctx);
expect(ctx.appStore.ensureAuthenticatedAsync).toHaveBeenCalled();
});
});
});
describe('non-interactive mode', () => {
it('throws an error when both adhoc and enterprise credentials are set up', async () => {
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [
testAdhocBuildCredentials,
testEnterpriseBuildCredentials,
];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: true,
});
await expect(action.runAsync(ctx)).rejects.toThrow(
/You have set up both adhoc and universal distribution credentials/
);
});
it('throws an error when neither adhoc nor enterprise credentials are set up', async () => {
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: true,
});
await expect(action.runAsync(ctx)).rejects.toThrow(/couldn't find any credentials/);
});
it('runs the SetupAdhocProvisioningProfile action when adhoc credentials exist', async () => {
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [testAdhocBuildCredentials];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: true,
});
const runAsync = jest.fn();
SetupAdhocProvisioningProfile.prototype.runAsync = runAsync;
await action.runAsync(ctx);
expect(runAsync).toHaveBeenCalled();
});
it('runs the SetupProvisioningProfile action when enterprise credentials exist', async () => {
asMock(getAllBuildCredentialsAsync).mockImplementationOnce(() => {
const buildCredentials: IosAppBuildCredentialsFragment[] = [testEnterpriseBuildCredentials];
return buildCredentials;
});
const action = new SetupInternalProvisioningProfile({
account: { id: 'account-id', name: 'account-name' },
bundleIdentifier: 'com.expo.test',
projectName: 'testproject',
});
const ctx = createCtxMock({
nonInteractive: true,
});
const runAsync = jest.fn();
SetupProvisioningProfile.prototype.runAsync = runAsync;
await action.runAsync(ctx);
expect(runAsync).toHaveBeenCalled();
});
});
});
@@ -1,25 +1,25 @@
import nullthrows from 'nullthrows';
import { IosDistributionType } from '../../../../../graphql/generated';
import { confirmAsync } from '../../../../../prompts';
import { getAppstoreMock, testAuthCtx } from '../../../../__tests__/fixtures-appstore';
import { createCtxMock } from '../../../../__tests__/fixtures-context';
import { IosDistributionType } from '../../../../graphql/generated';
import { confirmAsync } from '../../../../prompts';
import { getAppstoreMock, testAuthCtx } from '../../../__tests__/fixtures-appstore';
import { createCtxMock } from '../../../__tests__/fixtures-context';
import {
getNewIosApiMockWithoutCredentials,
testAppleAppIdentifierFragment,
testIosAppBuildCredentialsFragment,
testIosAppCredentialsWithBuildCredentialsQueryResult,
} from '../../../../__tests__/fixtures-ios';
import { getNewIosApiMockWithoutCredentials } from '../../../../__tests__/fixtures-new-ios';
import { MissingCredentialsNonInteractiveError } from '../../../errors';
import { validateProvisioningProfileAsync } from '../../../validators/validateProvisioningProfile';
} from '../../../__tests__/fixtures-ios';
import { MissingCredentialsNonInteractiveError } from '../../errors';
import { validateProvisioningProfileAsync } from '../../validators/validateProvisioningProfile';
import { getAppLookupParamsFromContext } from '../BuildCredentialsUtils';
import { SetupProvisioningProfile } from '../SetupProvisioningProfile';
jest.mock('../../../../../prompts');
jest.mock('../../../../prompts');
(confirmAsync as jest.Mock).mockImplementation(() => true);
jest.mock('../SetupDistributionCertificate');
jest.mock('../ConfigureProvisioningProfile');
jest.mock('../CreateProvisioningProfile');
jest.mock('../../../validators/validateProvisioningProfile');
jest.mock('../../validators/validateProvisioningProfile');
describe('SetupProvisioningProfile', () => {
it('repairs existing Provisioning Profile with bad build credentials in Interactive Mode', async () => {
@@ -33,13 +33,13 @@ describe('SetupProvisioningProfile', () => {
listProvisioningProfilesAsync: jest.fn(() => [
{
provisioningProfileId: nullthrows(
testIosAppCredentialsWithBuildCredentialsQueryResult.iosAppBuildCredentialsArray[0]
testIosAppCredentialsWithBuildCredentialsQueryResult.iosAppBuildCredentialsList[0]
.provisioningProfile
).developerPortalIdentifier,
},
]),
},
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(
() => testIosAppCredentialsWithBuildCredentialsQueryResult
@@ -58,9 +58,9 @@ describe('SetupProvisioningProfile', () => {
await setupProvisioningProfileAction.runAsync(ctx);
// expect build credentials to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile not to be deleted on expo servers
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
});
it('sets up a new Provisioning Profile with bad build credentials in Interactive Mode', async () => {
(validateProvisioningProfileAsync as jest.Mock).mockImplementation(() => false);
@@ -72,7 +72,7 @@ describe('SetupProvisioningProfile', () => {
authCtx: testAuthCtx,
listProvisioningProfilesAsync: jest.fn(() => []),
},
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(
() => testIosAppCredentialsWithBuildCredentialsQueryResult
@@ -88,9 +88,9 @@ describe('SetupProvisioningProfile', () => {
await setupProvisioningProfileAction.runAsync(ctx);
// expect build credentials to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile to be deleted on expo servers
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(1);
});
it('skips setting up a Provisioning Profile with prior build credentials configured properly in Interactive Mode', async () => {
(validateProvisioningProfileAsync as jest.Mock).mockImplementation(() => true);
@@ -102,7 +102,7 @@ describe('SetupProvisioningProfile', () => {
authCtx: testAuthCtx,
//listProvisioningProfilesAsync: jest.fn(() => []),
},
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
getIosAppCredentialsWithBuildCredentialsAsync: jest.fn(
() => testIosAppCredentialsWithBuildCredentialsQueryResult
@@ -118,9 +118,9 @@ describe('SetupProvisioningProfile', () => {
await setupProvisioningProfileAction.runAsync(ctx);
// expect build credentials not to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(0);
// expect provisioning profile not to be deleted on expo servers
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
});
it('sets up a Provisioning Profile with no prior build credentials configured in Interactive Mode', async () => {
(validateProvisioningProfileAsync as jest.Mock).mockImplementation(() => false);
@@ -131,7 +131,7 @@ describe('SetupProvisioningProfile', () => {
ensureAuthenticatedAsync: jest.fn(() => testAuthCtx),
authCtx: testAuthCtx,
},
newIos: {
ios: {
...getNewIosApiMockWithoutCredentials(),
createOrGetExistingAppleAppIdentifierAsync: jest.fn(() => testAppleAppIdentifierFragment),
},
@@ -144,9 +144,9 @@ describe('SetupProvisioningProfile', () => {
await setupProvisioningProfileAction.runAsync(ctx);
// expect build credentials to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(1);
// expect provisioning profile not to be deleted on expo servers
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
});
it('errors in Non Interactive Mode', async () => {
(validateProvisioningProfileAsync as jest.Mock).mockImplementation(() => false);
@@ -163,8 +163,8 @@ describe('SetupProvisioningProfile', () => {
);
// expect build credentials not to be created or updated on expo servers
expect((ctx.newIos.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.createOrUpdateIosAppBuildCredentialsAsync as any).mock.calls.length).toBe(0);
// expect provisioning profile not to be deleted on expo servers
expect((ctx.newIos.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
expect((ctx.ios.deleteProvisioningProfilesAsync as any).mock.calls.length).toBe(0);
});
});
@@ -1,113 +0,0 @@
import assert from 'assert';
import chalk from 'chalk';
import ora from 'ora';
import {
AppleDistributionCertificateFragment,
AppleProvisioningProfileFragment,
} from '../../../../graphql/generated';
import Log from '../../../../log';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { AppleProvisioningProfileMutationResult } from '../../api/graphql/mutations/AppleProvisioningProfileMutation';
import { ProvisioningProfileStoreInfo } from '../../appstore/Credentials.types';
import { AuthCtx } from '../../appstore/authenticate';
import { MissingCredentialsNonInteractiveError } from '../../errors';
export class ConfigureProvisioningProfile {
constructor(
private app: AppLookupParams,
private distributionCertificate: AppleDistributionCertificateFragment,
private originalProvisioningProfile: AppleProvisioningProfileFragment
) {}
public async runAsync(ctx: Context): Promise<AppleProvisioningProfileMutationResult | null> {
if (ctx.nonInteractive) {
throw new MissingCredentialsNonInteractiveError(
'Configuring Provisioning Profiles is only supported in interactive mode.'
);
}
const { developerPortalIdentifier, provisioningProfile } = this.originalProvisioningProfile;
if (!developerPortalIdentifier && !provisioningProfile) {
Log.warn("The provisioning profile we have on file cannot be configured on Apple's servers.");
return null;
}
if (!ctx.appStore.authCtx) {
Log.warn(
"Without access to your Apple account we can't configure provisioning profiles for you."
);
Log.warn('Make sure to recreate the profile if you selected a new distribution certificate.');
return null;
}
const profilesFromApple = await ctx.appStore.listProvisioningProfilesAsync(
this.app.bundleIdentifier
);
const [matchingProfile] = profilesFromApple.filter(appleInfo =>
developerPortalIdentifier
? appleInfo.provisioningProfileId === developerPortalIdentifier
: appleInfo.provisioningProfile === provisioningProfile
);
if (!matchingProfile) {
Log.warn(
`Profile ${
developerPortalIdentifier ? `${developerPortalIdentifier} ` : ''
}not found on Apple Developer Portal.`
);
return null;
}
return await this.configureAndUpdateAsync(ctx, ctx.appStore.authCtx, this.app, matchingProfile);
}
private async configureAndUpdateAsync(
ctx: Context,
authCtx: AuthCtx,
app: AppLookupParams,
profileFromApple: ProvisioningProfileStoreInfo
): Promise<AppleProvisioningProfileMutationResult> {
const {
developerPortalIdentifier,
certificateP12,
certificatePassword,
serialNumber,
} = this.distributionCertificate;
assert(
certificateP12 && certificatePassword,
'Distribution Certificate P12 and Password is required'
);
// configure profile on Apple's Server to use our distCert
const updatedProfile = await ctx.appStore.useExistingProvisioningProfileAsync(
app.bundleIdentifier,
profileFromApple,
{
certId: developerPortalIdentifier ?? undefined,
certP12: certificateP12,
certPassword: certificatePassword,
distCertSerialNumber: serialNumber,
teamId: authCtx.appleId,
}
);
const bundleIdTag = `(${app.bundleIdentifier})`;
const slugTag = `@${app.account.name}/${app.projectName}`;
const projectTag = `${chalk.bold(slugTag)} ${chalk.dim(bundleIdTag)}`;
const spinner = ora(`Updating Expo profile for ${projectTag}`).start();
try {
const configuredProvisioningProfile = await ctx.newIos.updateProvisioningProfileAsync(
this.originalProvisioningProfile.id,
{
appleProvisioningProfile: updatedProfile.provisioningProfile,
developerPortalIdentifier: updatedProfile.provisioningProfileId,
}
);
spinner.succeed(`Updated Expo profile for ${projectTag}`);
return configuredProvisioningProfile;
} catch (error) {
spinner.fail();
throw error;
}
}
}
@@ -1,19 +0,0 @@
import Log from '../../../../log';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { AppleDistributionCertificateMutationResult } from '../../api/graphql/mutations/AppleDistributionCertificateMutation';
import { provideOrGenerateDistributionCertificateAsync } from '../DistributionCertificateUtils';
export class CreateDistributionCertificate {
constructor(private app: AppLookupParams) {}
public async runAsync(ctx: Context): Promise<AppleDistributionCertificateMutationResult> {
const distCert = await provideOrGenerateDistributionCertificateAsync(
ctx,
this.app.account.name
);
const result = await ctx.newIos.createDistributionCertificateAsync(this.app, distCert);
Log.succeed('Created distribution certificate');
return result;
}
}
@@ -1,142 +0,0 @@
import assert from 'assert';
import chalk from 'chalk';
import dateformat from 'dateformat';
import {
AppleDistributionCertificateFragment,
AppleTeamFragment,
} from '../../../../graphql/generated';
import Log from '../../../../log';
import { promptAsync } from '../../../../prompts';
import { Account } from '../../../../user/Account';
import { fromNow } from '../../../../utils/date';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { filterRevokedDistributionCerts } from '../../appstore/CredentialsUtilsBeta';
export function formatDistributionCertificate(
distributionCertificate: AppleDistributionCertificateFragment,
validSerialNumbers?: string[]
): string {
const {
serialNumber,
developerPortalIdentifier,
appleTeam,
validityNotBefore,
validityNotAfter,
updatedAt,
} = distributionCertificate;
let line: string = '';
if (developerPortalIdentifier) {
line += `Cert ID: ${developerPortalIdentifier}`;
}
line += `${line === '' ? '' : ', '}Serial number: ${serialNumber}${
appleTeam ? `, ${formatAppleTeam(appleTeam)}` : ''
}`;
line += chalk.gray(
`\n Created: ${fromNow(new Date(validityNotBefore))} ago, Updated: ${fromNow(
new Date(updatedAt)
)} ago,`
);
line += chalk.gray(`\n Expires: ${dateformat(validityNotAfter, 'expiresHeaderFormat')}`);
const apps = distributionCertificate.iosAppBuildCredentialsList.map(
buildCredentials => buildCredentials.iosAppCredentials.app
);
if (apps.length) {
const appFullNames = apps.map(app => app.fullName).join(',');
line += chalk.gray(`\n 📲 Used by: ${appFullNames}`);
}
if (validSerialNumbers?.includes(serialNumber)) {
line += chalk.gray("\n ✅ Currently valid on Apple's servers.");
} else {
line += '';
}
return line;
}
function formatAppleTeam({ appleTeamIdentifier, appleTeamName }: AppleTeamFragment): string {
return `Team ID: ${appleTeamIdentifier}${appleTeamName ? `, Team name: ${appleTeamName}` : ''}`;
}
async function _selectDistributionCertificateAsync(
distCerts: AppleDistributionCertificateFragment[],
validDistributionCertificates?: AppleDistributionCertificateFragment[]
): Promise<AppleDistributionCertificateFragment | null> {
const validDistCertSerialNumbers = validDistributionCertificates?.map(
distCert => distCert.serialNumber
);
const { chosenDistCert } = await promptAsync({
type: 'select',
name: 'chosenDistCert',
message: 'Select certificate from the list.',
choices: distCerts.map(distCert => ({
title: formatDistributionCertificate(distCert, validDistCertSerialNumbers),
value: distCert,
})),
});
return chosenDistCert;
}
/**
* select a distribution certificate from an account (validity status shown on a best effort basis)
* */
export async function selectDistributionCertificateWithDependenciesAsync(
ctx: Context,
account: Account
): Promise<AppleDistributionCertificateFragment | null> {
const distCertsForAccount = await ctx.newIos.getDistributionCertificatesForAccountAsync(account);
if (distCertsForAccount.length === 0) {
Log.warn(`There are no Distribution Certificates available in your EAS account.`);
return null;
}
if (!ctx.appStore.authCtx) {
return _selectDistributionCertificateAsync(distCertsForAccount);
}
// get valid certs on the developer portal
const certInfoFromApple = await ctx.appStore.listDistributionCertificatesAsync();
const validDistCerts = await filterRevokedDistributionCerts(
distCertsForAccount,
certInfoFromApple
);
return _selectDistributionCertificateAsync(distCertsForAccount, validDistCerts);
}
/**
* select a distribution certificate from a valid set (curated on a best effort basis)
* */
export async function selectValidDistributionCertificateAsync(
ctx: Context,
appLookupParams: AppLookupParams
): Promise<AppleDistributionCertificateFragment | null> {
const distCertsForAccount = await ctx.newIos.getDistributionCertificatesForAccountAsync(
appLookupParams.account
);
if (distCertsForAccount.length === 0) {
Log.warn(`There are no Distribution Certificates available in your EAS account.`);
return null;
}
if (!ctx.appStore.authCtx) {
return _selectDistributionCertificateAsync(distCertsForAccount);
}
// filter by apple team
assert(ctx.appStore.authCtx, 'authentication to the Apple App Store is required');
const appleTeamIdentifier = ctx.appStore.authCtx.team.id;
const distCertsForAppleTeam = distCertsForAccount.filter(distCert => {
return !distCert.appleTeam || distCert.appleTeam.appleTeamIdentifier === appleTeamIdentifier;
});
// filter by valid certs on the developer portal
const certInfoFromApple = await ctx.appStore.listDistributionCertificatesAsync();
const validDistCerts = await filterRevokedDistributionCerts(
distCertsForAppleTeam,
certInfoFromApple
);
Log.log(
`${validDistCerts.length}/${distCertsForAccount.length} Distribution Certificates are currently valid for Apple Team ${ctx.appStore.authCtx?.team.id}.`
);
return _selectDistributionCertificateAsync(validDistCerts);
}
@@ -1,90 +0,0 @@
import {
AppleDistributionCertificateFragment,
AppleProvisioningProfileIdentifiersFragment,
} from '../../../../graphql/generated';
import Log from '../../../../log';
import { confirmAsync } from '../../../../prompts';
import { Account } from '../../../../user/Account';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { selectDistributionCertificateWithDependenciesAsync } from './DistributionCertificateUtils';
import { RemoveProvisioningProfiles } from './RemoveProvisioningProfile';
export class SelectAndRemoveDistributionCertificate {
constructor(private account: Account) {}
async runAsync(ctx: Context): Promise<void> {
const selected = await selectDistributionCertificateWithDependenciesAsync(ctx, this.account);
if (selected) {
await new RemoveDistributionCertificate(this.account, selected).runAsync(ctx);
Log.succeed('Removed distribution certificate');
Log.newLine();
}
}
}
export class RemoveDistributionCertificate {
constructor(
private account: Account,
private distributionCertificate: AppleDistributionCertificateFragment
) {}
public async runAsync(ctx: Context): Promise<void> {
const apps = this.distributionCertificate.iosAppBuildCredentialsList.map(
buildCredentials => buildCredentials.iosAppCredentials.app
);
if (apps.length !== 0) {
const appFullNames = apps.map(app => app.fullName).join(',');
if (ctx.nonInteractive) {
throw new Error(
`Certificate is currently used by ${appFullNames} and cannot be deleted in non-interactive mode.`
);
}
const confirm = await confirmAsync({
message: `You are removing certificate used by ${appFullNames}. Do you want to continue?`,
});
if (!confirm) {
Log.log('Aborting');
return;
}
}
Log.log('Removing Distribution Certificate');
await ctx.newIos.deleteDistributionCertificateAsync(this.distributionCertificate.id);
if (this.distributionCertificate.developerPortalIdentifier) {
let shouldRevoke = false;
if (!ctx.nonInteractive) {
shouldRevoke = await confirmAsync({
message: `Do you also want to revoke this Distribution Certificate on Apple Developer Portal?`,
});
} else if (ctx.nonInteractive) {
Log.log('Skipping certificate revocation on the Apple Developer Portal.');
}
if (shouldRevoke) {
await ctx.appStore.revokeDistributionCertificateAsync([
this.distributionCertificate.developerPortalIdentifier,
]);
}
}
await this.removeInvalidProvisioningProfilesAsync(ctx);
}
private async removeInvalidProvisioningProfilesAsync(ctx: Context): Promise<void> {
const buildCredentialsList = this.distributionCertificate.iosAppBuildCredentialsList;
const appsWithProfilesToRemove: AppLookupParams[] = [];
const profilesToRemove: AppleProvisioningProfileIdentifiersFragment[] = [];
for (const buildCredentials of buildCredentialsList) {
const projectName = buildCredentials.iosAppCredentials.app.slug;
const { bundleIdentifier } = buildCredentials.iosAppCredentials.appleAppIdentifier;
const appLookupParams = { account: this.account, projectName, bundleIdentifier };
const maybeProvisioningProfile = buildCredentials.provisioningProfile;
if (maybeProvisioningProfile) {
appsWithProfilesToRemove.push(appLookupParams);
profilesToRemove.push(maybeProvisioningProfile);
}
}
await new RemoveProvisioningProfiles(appsWithProfilesToRemove, profilesToRemove).runAsync(ctx);
}
}
@@ -1,32 +0,0 @@
import { assert } from '@expo/config';
import { AppleProvisioningProfileIdentifiersFragment } from '../../../../graphql/generated';
import Log from '../../../../log';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
export class RemoveProvisioningProfiles {
constructor(
private apps: AppLookupParams[],
private provisioningProfiles: AppleProvisioningProfileIdentifiersFragment[]
) {
assert(
apps.length === provisioningProfiles.length,
'apps must correspond to the provisioning profiles being removed'
);
}
async runAsync(ctx: Context): Promise<void> {
if (this.provisioningProfiles.length === 0) {
Log.log(`Skipping deletion of Provisioning Profiles`);
return;
}
await ctx.newIos.deleteProvisioningProfilesAsync(
this.provisioningProfiles.map(profile => profile.id)
);
const appAndBundles = this.apps
.map(app => `@${app.account.name}/${app.projectName} (${app.bundleIdentifier})`)
.join(',');
Log.succeed(`Successfully removed provisioning profiles for ${appAndBundles}`);
}
}
@@ -1,12 +0,0 @@
import { IosAppBuildCredentialsFragment } from '../../../../graphql/generated';
import { Context } from '../../../context';
import { AppLookupParams } from '../../api/GraphqlClient';
import { SetupAdhocProvisioningProfile } from './SetupAdhocProvisioningProfile';
export class SetupInternalProvisioningProfile {
constructor(private app: AppLookupParams) {}
async runAsync(ctx: Context): Promise<IosAppBuildCredentialsFragment> {
return await new SetupAdhocProvisioningProfile(this.app).runAsync(ctx);
}
}
@@ -1,382 +0,0 @@
import assert from 'assert';
import keyBy from 'lodash/keyBy';
import omit from 'lodash/omit';
import pick from 'lodash/pick';
import {
DistributionCertificate,
ProvisioningProfile,
PushKey,
} from '../appstore/Credentials.types';
import {
AppLookupParams,
IosAppCredentials,
IosCredentials,
IosDistCredentials,
IosPushCredentials,
} from '../credentials';
import ApiClient from './ClientWrapper';
type CredentialFields = {
credentials: { [key: string]: any };
};
// appCredentials are identified by `${projectFullName} ${bundleIdentifier}` (see getAppCredentialsCacheIndex method)
// userCredentials are identified by id (string or numeric depending on API)
//
// Expected behavior of cache (internals)
//
// - when isPrefetched[accountName] true assume everything is synced for that account
// - when credentials[accountName].appCredentials[experienceNameBundleIdentifier] is truthy assume that user and app credentials for that app are synced
// - when accessing user or app credentials identified by AppLookupParams fetch all credentials for that app (user and app credentials)
// - when updating userCredentials refetch only userCredentials
// - when deleting userCredentials modify prefetched appCredentials without calling api
// - when updating provisioningProfile refetch all credentials for that app (user and app credentials)
// - when deleting provisioningProfile modify appCredentials in cache
// - when deleting pushCert refetch all credentials for app (app + user)
//
//
interface CredentialsCache {
[accountName: string]: {
appCredentials: {
[experienceNameBundleIdentifier: string]: IosAppCredentials;
};
userCredentials: {
[id: string]: IosDistCredentials | IosPushCredentials;
};
};
}
export default class IosApi {
client = new ApiClient();
credentials: CredentialsCache = {};
isPrefetched: { [accountName: string]: boolean } = {};
public async getAllCredentialsAsync(accountName: string): Promise<IosCredentials> {
if (!this.isPrefetched[accountName]) {
const credentials = await this.client.getAllCredentialsApi(accountName);
this.credentials[accountName] = {
appCredentials: keyBy(
credentials.appCredentials,
cred => `${cred.experienceName} ${cred.bundleIdentifier}`
),
userCredentials: keyBy(credentials.userCredentials, cred => String(cred.id)),
};
this.isPrefetched[accountName] = true;
}
return {
appCredentials: Object.values(this.credentials[accountName]?.appCredentials ?? {}),
userCredentials: Object.values(this.credentials[accountName]?.userCredentials ?? {}),
};
}
public async getDistributionCertificateAsync(
appLookupParams: AppLookupParams
): Promise<IosDistCredentials | null> {
await this.ensureAppCredentialsAsync(appLookupParams);
const appCredentialsIndex = this.getAppCredentialsCacheIndex(appLookupParams);
const { accountName } = appLookupParams;
const appCredentials = this.credentials[accountName]?.appCredentials?.[appCredentialsIndex];
if (!appCredentials || !appCredentials.distCredentialsId) {
return null;
}
const distCert = this.credentials[accountName]?.userCredentials?.[
appCredentials.distCredentialsId
] as IosDistCredentials | null;
return distCert ?? null;
}
public async getDistributionCertificateByIdAsync(
id: string | number,
accountName: string
): Promise<IosDistCredentials> {
if (!this.credentials[accountName]?.userCredentials?.[String(id)]) {
await this.refetchUserCredentialsAsync(id, accountName);
}
const distCert = this.credentials[accountName]?.userCredentials?.[String(id)];
assert(id && distCert, 'distribution certificate does not exists');
assert(distCert.type === 'dist-cert', 'wrong type of user credential');
return distCert as IosDistCredentials;
}
public async createDistributionCertificateAsync(
accountName: string,
credentials: DistributionCertificate
): Promise<IosDistCredentials> {
const id = await this.client.createDistributionCertificateApi(accountName, credentials);
// refetching because www might add some fields (e.g. certSerialNumber)
await this.refetchUserCredentialsAsync(id, accountName);
const distCert = this.credentials[accountName]?.userCredentials?.[String(id)];
assert(id && distCert, 'distribution certificate does not exists');
assert(distCert.type === 'dist-cert', 'wrong type of user credential');
return distCert as IosDistCredentials;
}
public async updateDistributionCertificateAsync(
id: number | string,
accountName: string,
credentials: DistributionCertificate
): Promise<IosDistCredentials> {
await this.client.updateDistributionCertificateApi(id, accountName, credentials);
// refetching because www might add some fields (e.g. certSerialNumber)
await this.refetchUserCredentialsAsync(id, accountName);
const distCert = this.credentials[accountName]?.userCredentials[String(id)];
assert(distCert, 'distribution certificate does not exists');
assert(distCert.type === 'dist-cert', 'wrong type of user credential');
return distCert as IosDistCredentials;
}
public async deleteDistributionCertificateAsync(
id: number | string,
accountName: string
): Promise<void> {
await this.client.deleteDistributionCertificateApi(id, accountName);
await this.removeUserCredentialFromCache(id, accountName);
}
public async useDistributionCertificateAsync(
appLookupParams: AppLookupParams,
userCredentialsId: number | string
): Promise<void> {
await this.client.useDistributionCertificateApi(appLookupParams, userCredentialsId);
await this.refetchAppCredentialsAsync(appLookupParams);
}
public async createPushKeyAsync(
accountName: string,
credentials: PushKey
): Promise<IosPushCredentials> {
const id = await this.client.createPushKeyApi(accountName, credentials);
await this.refetchUserCredentialsAsync(id, accountName);
const pushKey = this.credentials[accountName]?.userCredentials?.[String(id)];
assert(id && pushKey, 'push key does not exists');
assert(pushKey.type === 'push-key', 'wrong type of user credentials');
return pushKey;
}
public async updatePushKeyAsync(
id: number | string,
accountName: string,
credentials: PushKey
): Promise<IosPushCredentials> {
await this.client.updatePushKeyApi(id, accountName, credentials);
await this.refetchUserCredentialsAsync(id, accountName);
const pushKey = this.credentials[accountName]?.userCredentials?.[String(id)];
assert(id && pushKey, 'push key does not exists');
assert(pushKey.type === 'push-key', 'wrong type of user credentials');
return pushKey;
}
public async deletePushKeyAsync(id: number | string, accountName: string) {
await this.client.deletePushKeyApi(id, accountName);
await this.removeUserCredentialFromCache(id, accountName);
}
public async getPushKeyAsync(
appLookupParams: AppLookupParams
): Promise<IosPushCredentials | null> {
await this.ensureAppCredentialsAsync(appLookupParams);
const appCredentialsIndex = this.getAppCredentialsCacheIndex(appLookupParams);
const { accountName } = appLookupParams;
const appCredentials = this.credentials[accountName]?.appCredentials?.[appCredentialsIndex];
if (!appCredentials || !appCredentials.pushCredentialsId) {
return null;
}
const pushKey = this.credentials[accountName]?.userCredentials?.[
appCredentials.pushCredentialsId
] as IosPushCredentials | null;
return pushKey ?? null;
}
public async usePushKeyAsync(
appLookupParams: AppLookupParams,
userCredentialsId: number | string
): Promise<void> {
await this.client.usePushKeyApi(appLookupParams, userCredentialsId);
await this.refetchAppCredentialsAsync(appLookupParams);
}
public async getPushCertAsync(
appLookupParams: AppLookupParams
): Promise<{ pushId: string; pushP12: string; pushPassword: string } | null> {
const appCredentials = await this.getAppCredentialsAsync(appLookupParams);
const pushId = appCredentials?.credentials?.pushId;
const pushP12 = appCredentials?.credentials?.pushP12;
const pushPassword = appCredentials?.credentials?.pushPassword;
if (!pushId || !pushP12 || !pushPassword) {
return null;
}
return { pushId, pushP12, pushPassword };
}
public async deletePushCertAsync(appLookupParams: AppLookupParams): Promise<void> {
await this.client.deletePushCertApi(appLookupParams);
await this.refetchAppCredentialsAsync(appLookupParams);
}
public async getAppCredentialsAsync(
appLookupParams: AppLookupParams
): Promise<IosAppCredentials> {
const appCredentialsIndex = this.getAppCredentialsCacheIndex(appLookupParams);
const { accountName } = appLookupParams;
await this.ensureAppCredentialsAsync(appLookupParams);
return this.credentials[accountName]?.appCredentials?.[appCredentialsIndex];
}
public async getProvisioningProfileAsync(
appLookupParams: AppLookupParams
): Promise<ProvisioningProfile | null> {
const appCredentials = await this.getAppCredentialsAsync(appLookupParams);
const provisioningProfile = appCredentials?.credentials?.provisioningProfile;
if (!provisioningProfile) {
return null;
}
return pick(appCredentials.credentials, [
'provisioningProfile',
'provisioningProfileId',
'teamId',
'teamName',
]) as ProvisioningProfile;
}
public async updateProvisioningProfileAsync(
appLookupParams: AppLookupParams,
provisioningProfile: ProvisioningProfile
): Promise<ProvisioningProfile> {
const appCredentialsIndex = this.getAppCredentialsCacheIndex(appLookupParams);
const { accountName } = appLookupParams;
await this.client.updateProvisioningProfileApi(appLookupParams, provisioningProfile);
await this.refetchAppCredentialsAsync(appLookupParams);
return pick(this.credentials[accountName]?.appCredentials?.[appCredentialsIndex]?.credentials, [
'provisioningProfile',
'provisioningProfileId',
'teamId',
'teamName',
]) as ProvisioningProfile;
}
public async deleteProvisioningProfileAsync(appLookupParams: AppLookupParams): Promise<void> {
const appCredentialsIndex = this.getAppCredentialsCacheIndex(appLookupParams);
const { accountName } = appLookupParams;
await this.client.deleteProvisioningProfileApi(appLookupParams);
const appCredentials = this.credentials?.[accountName]?.appCredentials?.[appCredentialsIndex];
if (appCredentials?.credentials) {
// teamId should still be there because it might be part of push cert definition
appCredentials.credentials = omit(appCredentials.credentials, [
'provisioningProfile',
'provisioningProfileId',
]);
}
}
private getAppCredentialsCacheIndex(appLookupParams: AppLookupParams): string {
const { accountName, projectName, bundleIdentifier } = appLookupParams;
const projectFullName = `@${accountName}/${projectName}`;
return `${projectFullName} ${bundleIdentifier}`;
}
private removeUserCredentialFromCache(id: number | string, accountName: string): void {
if (this.credentials[accountName]?.userCredentials?.[String(id)]) {
delete this.credentials[accountName].userCredentials[String(id)];
}
const appCredentials = this.credentials[accountName]?.appCredentials;
if (appCredentials) {
for (const cred of Object.values(appCredentials)) {
if (cred.distCredentialsId === id) {
delete cred.distCredentialsId;
}
if (cred.pushCredentialsId === id) {
delete cred.pushCredentialsId;
}
}
}
}
// ensures that credentials are fetched from the server if they exist
// if there are no credentials on server for specific app this function should still succeed
private async ensureAppCredentialsAsync(appLookupParams: AppLookupParams): Promise<void> {
const appCredentialsIndex = this.getAppCredentialsCacheIndex(appLookupParams);
const { accountName } = appLookupParams;
if (
this.isPrefetched[accountName] ||
this.credentials?.[accountName]?.appCredentials?.[appCredentialsIndex]
) {
return;
}
await this.refetchAppCredentialsAsync(appLookupParams);
}
private async refetchUserCredentialsAsync(
id: number | string,
accountName: string
): Promise<void> {
const userCredentials = await this.client.getUserCredentialsByIdApi(id, accountName);
if (!userCredentials || !userCredentials.id) {
return;
}
this.credentials[accountName] = {
...this.credentials[accountName],
userCredentials: {
...this.credentials[accountName]?.userCredentials,
[String(id)]: userCredentials,
},
};
}
private async refetchAppCredentialsAsync(app: AppLookupParams): Promise<void> {
const { accountName } = app;
const appCredentialsIndex = this.getAppCredentialsCacheIndex(app);
const data = await this.client.getAllCredentialsForAppApi(app);
if (!data) {
return;
}
this.credentials[accountName] = {
appCredentials: {
...this.credentials[accountName]?.appCredentials,
[appCredentialsIndex]: omit(data, [
'pushCredentials',
'distCredentials',
]) as IosAppCredentials,
},
userCredentials: {
...this.credentials[accountName]?.userCredentials,
...(data.pushCredentialsId
? {
[String(data.pushCredentialsId)]: {
...data.pushCredentials,
id: data.pushCredentialsId,
type: 'push-key',
},
}
: {}),
...(data.distCredentialsId
? {
[String(data.distCredentialsId)]: {
...data.distCredentials,
id: data.distCredentialsId,
type: 'dist-cert',
},
}
: {}),
},
};
}
}
@@ -1,188 +0,0 @@
import { apiClient } from '../../../api';
import {
DistributionCertificate,
ProvisioningProfile,
PushKey,
} from '../appstore/Credentials.types';
import { IosAppCredentials, IosDistCredentials, IosPushCredentials } from '../credentials';
export interface AppLookupParams {
accountName: string;
projectName: string;
bundleIdentifier: string;
}
interface IosAllCredentialsForApp extends IosAppCredentials {
pushCredentials: Omit<IosPushCredentials, 'id' | 'type'>;
distCredentials: Omit<IosDistCredentials, 'id' | 'type'>;
}
interface AllCredentialsApiResponse {
appCredentials: IosAppCredentials[];
userCredentials: (IosDistCredentials | IosPushCredentials)[];
}
// This class should not be used directly, use only as part of cached api client from ./Client.ts
// or mock it in tests (it's easier to mock this class than got directly)
export default class ApiClient {
public async getAllCredentialsApi(accountName: string): Promise<AllCredentialsApiResponse> {
const response: any = await apiClient
.get('credentials/ios', { searchParams: { owner: accountName } })
.json();
return response.data;
}
public async getAllCredentialsForAppApi({
accountName,
projectName,
bundleIdentifier,
}: AppLookupParams): Promise<IosAllCredentialsForApp> {
const response: any = await apiClient
.get(`credentials/ios/@${accountName}/${projectName}/${bundleIdentifier}`)
.json();
return response.data;
}
public async getUserCredentialsByIdApi(
id: number | string,
accountName: string
): Promise<IosDistCredentials | IosPushCredentials> {
const response: any = await apiClient
.get(`credentials/ios/userCredentials/${id}`, { searchParams: { owner: accountName } })
.json();
return response.data;
}
public async createDistributionCertificateApi(
accountName: string,
credentials: DistributionCertificate
): Promise<number | string> {
const response: any = await apiClient
.post('credentials/ios/dist', {
json: {
owner: accountName,
credentials,
},
})
.json();
return response.data?.id;
}
public async updateDistributionCertificateApi(
id: number | string,
accountName: string,
credentials: DistributionCertificate
): Promise<void> {
await apiClient.put(`credentials/ios/dist/${id}`, {
json: { credentials, owner: accountName },
});
}
public async deleteDistributionCertificateApi(
id: number | string,
accountName: string
): Promise<void> {
await apiClient.delete(`credentials/ios/dist/${id}`, { searchParams: { owner: accountName } });
}
public async useDistributionCertificateApi(
{ accountName, projectName, bundleIdentifier }: AppLookupParams,
userCredentialsId: number | string
): Promise<void> {
await apiClient.post('credentials/ios/use/dist', {
json: {
experienceName: `@${accountName}/${projectName}`,
owner: accountName,
bundleIdentifier,
userCredentialsId,
},
});
}
public async createPushKeyApi(
accountName: string,
credentials: PushKey
): Promise<number | string> {
const response: any = await apiClient
.post('credentials/ios/push', {
json: {
owner: accountName,
credentials,
},
})
.json();
return response.data?.id;
}
public async updatePushKeyApi(
id: number | string,
accountName: string,
credentials: PushKey
): Promise<IosPushCredentials> {
const response: any = await apiClient
.put(`credentials/ios/push/${id}`, {
json: { owner: accountName },
})
.json();
return response.data;
}
public async deletePushKeyApi(id: number | string, accountName: string): Promise<void> {
await apiClient.delete(`credentials/ios/push/${id}`, { searchParams: { owner: accountName } });
}
public async usePushKeyApi(
{ accountName, projectName, bundleIdentifier }: AppLookupParams,
userCredentialsId: number | string
): Promise<void> {
await apiClient.post('credentials/ios/use/push', {
json: {
experienceName: `@${accountName}/${projectName}`,
owner: accountName,
bundleIdentifier,
userCredentialsId,
},
});
}
public async deletePushCertApi({
accountName,
projectName,
bundleIdentifier,
}: AppLookupParams): Promise<void> {
await apiClient.post(`credentials/ios/pushCert/delete`, {
json: {
experienceName: `@${accountName}/${projectName}`,
owner: accountName,
bundleIdentifier,
},
});
}
public async updateProvisioningProfileApi(
{ accountName, projectName, bundleIdentifier }: AppLookupParams,
credentials: ProvisioningProfile
): Promise<void> {
await apiClient.post(`credentials/ios/provisioningProfile/update`, {
json: {
experienceName: `@${accountName}/${projectName}`,
owner: accountName,
bundleIdentifier,
credentials,
},
});
}
public async deleteProvisioningProfileApi({
accountName,
projectName,
bundleIdentifier,
}: AppLookupParams): Promise<void> {
await apiClient.post(`credentials/ios/provisioningProfile/delete`, {
json: {
experienceName: `@${accountName}/${projectName}`,
owner: accountName,
bundleIdentifier,
},
});
}
}
@@ -45,7 +45,7 @@ export interface AppLookupParams {
bundleIdentifier: string;
}
export async function getAppAsync(appLookupParams: AppLookupParams): Promise<AppFragment> {
async function getAppAsync(appLookupParams: AppLookupParams): Promise<AppFragment> {
const projectFullName = formatProjectFullName(appLookupParams);
return await AppQuery.byFullNameAsync(projectFullName);
}
@@ -74,7 +74,7 @@ export async function createOrUpdateIosAppBuildCredentialsAsync(
iosDistributionType,
}
);
const iosAppBuildCredentials = iosAppCredentials.iosAppBuildCredentialsArray?.[0];
const iosAppBuildCredentials = iosAppCredentials.iosAppBuildCredentialsList?.[0];
if (!iosAppBuildCredentials) {
return await IosAppBuildCredentialsMutation.createIosAppBuildCredentialsAsync(
{
@@ -98,7 +98,7 @@ export async function createOrUpdateIosAppBuildCredentialsAsync(
export async function getIosAppCredentialsWithBuildCredentialsAsync(
appLookupParams: AppLookupParams,
{ iosDistributionType }: { iosDistributionType: IosDistributionType }
{ iosDistributionType }: { iosDistributionType?: IosDistributionType }
): Promise<IosAppCredentialsWithBuildCredentialsQueryResult | null> {
const { account, bundleIdentifier } = appLookupParams;
const appleAppIdentifier = await AppleAppIdentifierQuery.byBundleIdentifierAsync(
@@ -173,7 +173,7 @@ export async function createOrGetExistingIosAppCredentialsWithBuildCredentialsAs
}
export async function createOrGetExistingAppleTeamAsync(
{ account }: AppLookupParams,
account: Account,
{ appleTeamIdentifier, appleTeamName }: { appleTeamIdentifier: string; appleTeamName?: string }
): Promise<AppleTeamFragment> {
const appleTeam = await AppleTeamQuery.getByAppleTeamIdentifierAsync(
@@ -296,14 +296,13 @@ export async function getDistributionCertificatesForAccountAsync(
}
export async function createDistributionCertificateAsync(
appLookupParams: AppLookupParams,
account: Account,
distCert: DistributionCertificate
): Promise<AppleDistributionCertificateMutationResult> {
const appleTeam = await createOrGetExistingAppleTeamAsync(appLookupParams, {
const appleTeam = await createOrGetExistingAppleTeamAsync(account, {
appleTeamIdentifier: distCert.teamId,
appleTeamName: distCert.teamName,
});
const { account } = appLookupParams;
return await AppleDistributionCertificateMutation.createAppleDistributionCertificate(
{
certP12: distCert.certP12,
@@ -82,6 +82,9 @@ const AppleDistributionCertificateMutation = {
`,
{
appleDistributionCertificateId,
},
{
additionalTypenames: ['AppleDistributionCertificate'],
}
)
.toPromise()
@@ -117,6 +117,9 @@ const AppleProvisioningProfileMutation = {
`,
{
appleProvisioningProfileIds,
},
{
additionalTypenames: ['AppleProvisioningProfile'],
}
)
.toPromise()
@@ -34,7 +34,7 @@ const AppleDistributionCertificateQuery = {
id
iosAppCredentials(filter: { appleAppIdentifierId: $appleAppIdentifierId }) {
id
iosAppBuildCredentialsArray(
iosAppBuildCredentialsList(
filter: { iosDistributionType: $iosDistributionType }
) {
id
@@ -67,7 +67,7 @@ const AppleDistributionCertificateQuery = {
);
assert(data.app, 'GraphQL: `app` not defined in server response');
return (
data.app.byFullName.iosAppCredentials[0]?.iosAppBuildCredentialsArray[0]
data.app.byFullName.iosAppCredentials[0]?.iosAppBuildCredentialsList[0]
?.distributionCertificate ?? null
);
},
@@ -41,7 +41,7 @@ const AppleProvisioningProfileQuery = {
id
iosAppCredentials(filter: { appleAppIdentifierId: $appleAppIdentifierId }) {
id
iosAppBuildCredentialsArray(
iosAppBuildCredentialsList(
filter: { iosDistributionType: $iosDistributionType }
) {
id
@@ -84,7 +84,7 @@ const AppleProvisioningProfileQuery = {
);
assert(data.app, 'GraphQL: `app` not defined in server response');
return (
data.app.byFullName.iosAppCredentials[0]?.iosAppBuildCredentialsArray[0]
data.app.byFullName.iosAppCredentials[0]?.iosAppBuildCredentialsList[0]
?.provisioningProfile ?? null
);
},
@@ -32,7 +32,7 @@ const IosAppBuildCredentialsQuery = {
id
iosAppCredentials(filter: { appleAppIdentifierId: $appleAppIdentifierId }) {
id
iosAppBuildCredentialsArray(
iosAppBuildCredentialsList(
filter: { iosDistributionType: $iosDistributionType }
) {
id
@@ -56,7 +56,7 @@ const IosAppBuildCredentialsQuery = {
.toPromise()
);
assert(data.app, 'GraphQL: `app` not defined in server response');
return data.app.byFullName.iosAppCredentials[0]?.iosAppBuildCredentialsArray[0] ?? null;
return data.app.byFullName.iosAppCredentials[0]?.iosAppBuildCredentialsList[0] ?? null;
},
};
@@ -19,7 +19,7 @@ import {
} from '../../../../../graphql/types/credentials/IosAppCredentials';
export type IosAppCredentialsWithBuildCredentialsQueryResult = IosAppCredentialsFragment & {
iosAppBuildCredentialsArray: IosAppBuildCredentialsFragment[];
iosAppBuildCredentialsList: IosAppBuildCredentialsFragment[];
};
const IosAppCredentialsQuery = {
async byAppIdentifierIdAsync(
@@ -66,7 +66,7 @@ const IosAppCredentialsQuery = {
iosDistributionType,
}: {
appleAppIdentifierId: string;
iosDistributionType: IosDistributionType;
iosDistributionType?: IosDistributionType;
}
): Promise<IosAppCredentialsWithBuildCredentialsQueryResult | null> {
const data = await withErrorHandlingAsync(
@@ -76,7 +76,7 @@ const IosAppCredentialsQuery = {
query IosAppCredentialsWithBuildCredentialsByAppIdentifierIdQuery(
$projectFullName: String!
$appleAppIdentifierId: String!
$iosDistributionType: IosDistributionType!
$iosDistributionType: IosDistributionType
) {
app {
byFullName(fullName: $projectFullName) {
@@ -84,7 +84,7 @@ const IosAppCredentialsQuery = {
iosAppCredentials(filter: { appleAppIdentifierId: $appleAppIdentifierId }) {
id
...IosAppCredentialsFragment
iosAppBuildCredentialsArray(
iosAppBuildCredentialsList(
filter: { iosDistributionType: $iosDistributionType }
) {
id
@@ -18,7 +18,7 @@ const IosAppCredentialsQuery = {
bundleIdentifier: 'com.quinlanj.test52',
__typename: 'AppleAppIdentifier',
},
iosAppBuildCredentialsArray: [
iosAppBuildCredentialsList: [
{
id: '6f8d0175-0caf-4922-b09b-eae757b83144',
iosDistributionType: 'APP_STORE',
@@ -1,5 +1,26 @@
import { AppleDistributionCertificateFragment } from '../../../graphql/generated';
import { DistributionCertificate, DistributionCertificateStoreInfo } from './Credentials.types';
export function filterRevokedDistributionCertsFromEasServers(
distributionCerts: AppleDistributionCertificateFragment[],
certInfoFromApple: DistributionCertificateStoreInfo[]
): AppleDistributionCertificateFragment[] {
if (distributionCerts.length === 0) {
return [];
}
// if the cert is valid, check it against apple to make sure it hasnt been revoked
const validCertSerialsOnAppleServer = certInfoFromApple
.filter(
// remove expired certs
cert => cert.expires > Math.floor(Date.now() / 1000)
)
.map(cert => cert.serialNumber);
return distributionCerts.filter(cert =>
validCertSerialsOnAppleServer.includes(cert.serialNumber)
);
}
export function filterRevokedDistributionCerts<T extends DistributionCertificate>(
distributionCerts: T[],
certInfoFromApple: DistributionCertificateStoreInfo[]
@@ -1,22 +0,0 @@
import { AppleDistributionCertificateFragment } from '../../../graphql/generated';
import { DistributionCertificateStoreInfo } from './Credentials.types';
export function filterRevokedDistributionCerts(
distributionCerts: AppleDistributionCertificateFragment[],
certInfoFromApple: DistributionCertificateStoreInfo[]
): AppleDistributionCertificateFragment[] {
if (distributionCerts.length === 0) {
return [];
}
// if the cert is valid, check it against apple to make sure it hasnt been revoked
const validCertSerialsOnAppleServer = certInfoFromApple
.filter(
// remove expired certs
cert => cert.expires > Math.floor(Date.now() / 1000)
)
.map(cert => cert.serialNumber);
return distributionCerts.filter(cert =>
validCertSerialsOnAppleServer.includes(cert.serialNumber)
);
}
@@ -3,7 +3,7 @@ import nullthrows from 'nullthrows';
import Log from '../../../../log';
import { IosAppCredentialsQuery } from '../../api/graphql/queries/IosAppCredentialsQuery';
import { displayIosAppCredentials } from '../printCredentialsBeta';
import { displayIosAppCredentials } from '../printCredentials';
jest.mock('../../../../log');
jest.mock('chalk', () => ({ bold: jest.fn(log => log) }));
@@ -1,104 +1,159 @@
import chalk from 'chalk';
import dateformat from 'dateformat';
import { AppleDevice } from '../../../graphql/generated';
import {
AppleDeviceFragment,
CommonIosAppCredentialsFragment,
IosAppBuildCredentialsFragment,
IosDistributionType,
} from '../../../graphql/generated';
import { APPLE_DEVICE_CLASS_LABELS } from '../../../graphql/types/credentials/AppleDevice';
import Log from '../../../log';
import {
AppLookupParams,
IosAppCredentials,
IosCredentials,
IosDistCredentials,
IosPushCredentials,
} from '../credentials';
import { fromNow } from '../../../utils/date';
import { AppLookupParams } from '../api/GraphqlClient';
function prettyIosDistributionType(distributionType: IosDistributionType): string {
switch (distributionType) {
case IosDistributionType.AppStore:
return 'App Store';
case IosDistributionType.AdHoc:
return 'Ad Hoc';
case IosDistributionType.Development:
return 'Development';
case IosDistributionType.Enterprise:
return 'Enterprise';
default:
return 'Unknown';
}
}
export function displayEmptyIosCredentials(appLookupParams: AppLookupParams): void {
const { projectName, bundleIdentifier } = appLookupParams;
Log.log(chalk.bold(`iOS Credentials`));
Log.log(` Project: ${projectName}`);
Log.log(` Bundle Identifier: ${bundleIdentifier}`);
Log.log(` No credentials set up yet!`);
}
/**
* sort a build credentials array in descending order of preference
*/
function sortBuildCredentialsByDistributionType(
iosAppBuildCredentialsList: IosAppBuildCredentialsFragment[]
): IosAppBuildCredentialsFragment[] {
// The order in which we choose the distribution type from least to most preferred
const typePriority = [
IosDistributionType.Development,
IosDistributionType.AdHoc,
IosDistributionType.Enterprise,
IosDistributionType.AppStore,
];
return iosAppBuildCredentialsList
.sort(
(buildCredentialsA, buildCredentialsB) =>
typePriority.indexOf(buildCredentialsA.iosDistributionType) -
typePriority.indexOf(buildCredentialsB.iosDistributionType)
)
.reverse();
}
export function displayIosAppCredentials(credentials: CommonIosAppCredentialsFragment): void {
Log.log(chalk.bold(`iOS Credentials`));
Log.log(` Project: ${credentials.app.fullName}`);
Log.log(` Bundle Identifier: ${credentials.appleAppIdentifier.bundleIdentifier}`);
const appleTeam = credentials.appleTeam;
if (appleTeam) {
const { appleTeamIdentifier, appleTeamName } = appleTeam;
Log.log(` Apple Team: ${appleTeamIdentifier} ${appleTeamName ? `(${appleTeamName})` : ''}`);
}
Log.newLine();
if (credentials.iosAppBuildCredentialsList.length === 0) {
Log.log(` Configuration: None setup yet`);
Log.newLine();
return;
}
const sortedIosAppBuildCredentialsList = sortBuildCredentialsByDistributionType(
credentials.iosAppBuildCredentialsList
);
for (const iosAppBuildCredentials of sortedIosAppBuildCredentialsList) {
displayIosAppBuildCredentials(iosAppBuildCredentials);
}
}
export function displayProjectCredentials(
appLookupParams: AppLookupParams,
appCredentials?: IosAppCredentials | null,
pushKey?: IosPushCredentials | null,
distCert?: IosDistCredentials | null
buildCredentials: IosAppBuildCredentialsFragment
): void {
const experienceName = `@${appLookupParams.accountName}/${appLookupParams.projectName}`;
const bundleIdentifier = appLookupParams.bundleIdentifier;
if (!appCredentials) {
Log.log(
chalk.bold(
`No credentials configured for app ${experienceName} with bundle identifier ${bundleIdentifier}\n`
)
);
return;
}
Log.log();
const experienceName = `@${appLookupParams.account.name}/${appLookupParams.projectName}`;
Log.addNewLineIfNone();
Log.log(chalk.bold('Project Credentials Configuration:'));
displayIosAppCredentials(appCredentials);
Log.log();
if (distCert) {
displayIosUserCredentials(distCert);
}
if (pushKey) {
displayIosUserCredentials(pushKey);
}
Log.log(` Project: ${chalk.bold(experienceName)}`);
Log.log(` Bundle Identifier: ${appLookupParams.bundleIdentifier}`);
displayIosAppBuildCredentials(buildCredentials);
}
export async function displayAllIosCredentials(credentials: IosCredentials) {
Log.log(chalk.bold('Available credentials for iOS apps'));
Log.newLine();
Log.log(chalk.bold('Application credentials'));
Log.newLine();
for (const cred of credentials.appCredentials) {
displayIosAppCredentials(cred);
Log.log();
}
Log.log(chalk.bold('User credentials\n'));
for (const cred of credentials.userCredentials) {
displayIosUserCredentials(cred, credentials);
Log.newLine();
}
Log.newLine();
}
export function displayIosAppCredentials(appCredentials: IosAppCredentials) {
function displayIosAppBuildCredentials(buildCredentials: IosAppBuildCredentialsFragment): void {
Log.log(
` Project: ${chalk.bold(appCredentials.experienceName)}, bundle identifier: ${
appCredentials.bundleIdentifier
}`
chalk.bold(
` Configuration: ${prettyIosDistributionType(buildCredentials.iosDistributionType)}`
)
);
if (appCredentials.credentials.provisioningProfile) {
Log.log(
` Provisioning profile (ID: ${chalk.green(
appCredentials.credentials.provisioningProfileId || '---------'
)})`
);
} else {
Log.log(' Provisioning profile is missing. It will be generated during the next build');
}
if (appCredentials.credentials.devices && appCredentials.credentials.devices.length > 0) {
Log.log(` Provisioned devices:`);
for (const device of appCredentials.credentials.devices) {
Log.log(` - ${formatDevice(device)}`);
Log.newLine();
const maybeDistCert = buildCredentials.distributionCertificate;
Log.log(` Distribution Certificate:`);
if (maybeDistCert) {
const { serialNumber, updatedAt, validityNotAfter, appleTeam } = maybeDistCert;
Log.log(` Serial Number: ${serialNumber}`);
Log.log(` Expiration Date: ${dateformat(validityNotAfter, 'expiresHeaderFormat')}`);
if (appleTeam) {
const { appleTeamIdentifier, appleTeamName } = appleTeam;
Log.log(
` Apple Team: ${appleTeamIdentifier} ${appleTeamName ? `(${appleTeamName})` : ''}`
);
}
Log.log(` Updated ${fromNow(new Date(updatedAt))} ago`);
} else {
Log.log(` None assigned yet`);
}
if (appCredentials.credentials.teamId || appCredentials.credentials.teamName) {
Log.log(
` Apple Team ID: ${chalk.green(
appCredentials.credentials.teamId || '---------'
)}, Apple Team Name: ${chalk.green(appCredentials.credentials.teamName || '---------')}`
);
}
if (appCredentials.credentials.pushP12 && appCredentials.credentials.pushPassword) {
Log.log(
` (deprecated) Push Certificate (Push ID: ${chalk.green(
appCredentials.credentials.pushId || '-----'
)})`
);
Log.newLine();
const maybeProvProf = buildCredentials.provisioningProfile;
Log.log(` Provisioning Profile:`);
if (maybeProvProf) {
const {
expiration,
updatedAt,
status,
developerPortalIdentifier,
appleTeam,
appleDevices,
} = maybeProvProf;
if (developerPortalIdentifier) {
Log.log(` Developer Portal ID: ${developerPortalIdentifier}`);
}
Log.log(` Status: ${status}`);
Log.log(` Expiration Date: ${dateformat(expiration, 'expiresHeaderFormat')}`);
if (appleTeam) {
const { appleTeamIdentifier, appleTeamName } = appleTeam;
Log.log(
` Apple Team: ${appleTeamIdentifier} ${appleTeamName ? `(${appleTeamName})` : ''}`
);
}
if (appleDevices && appleDevices.length > 0) {
Log.log(` Provisioned devices:`);
for (const appleDevice of appleDevices) {
Log.log(` - ${formatAppleDevice(appleDevice)}`);
}
}
Log.log(` Updated ${fromNow(new Date(updatedAt))} ago`);
} else {
Log.log(` None assigned yet`);
}
Log.newLine();
}
function formatDevice(device: AppleDevice): string {
function formatAppleDevice(device: AppleDeviceFragment): string {
let deviceString = '';
if (device.name) {
deviceString += device.name;
@@ -124,38 +179,3 @@ function formatDevice(device: AppleDevice): string {
}
return deviceString;
}
export function displayIosUserCredentials(
userCredentials: IosPushCredentials | IosDistCredentials,
credentials?: IosCredentials
) {
if (userCredentials.type === 'push-key') {
Log.log(` Push Notifications Key - Key ID: ${chalk.green(userCredentials.apnsKeyId)}`);
} else if (userCredentials.type === 'dist-cert') {
Log.log(
` Distribution Certificate - Certificate ID: ${chalk.green(
userCredentials.certId || '-----'
)}`
);
} else {
Log.warn(` Unknown key type ${(userCredentials as any).type}`);
}
Log.log(
` Apple Team ID: ${chalk.green(
userCredentials.teamId || '---------'
)}, Apple Team Name: ${chalk.green(userCredentials.teamName || '---------')}`
);
if (credentials) {
const field = userCredentials.type === 'push-key' ? 'pushCredentialsId' : 'distCredentialsId';
const usedByApps = [
...new Set(
credentials.appCredentials
.filter(c => c[field] === userCredentials.id)
.map(c => `${c.experienceName} (${c.bundleIdentifier})`)
),
].join(',\n ');
const usedByAppsText = usedByApps ? `used by\n ${usedByApps}` : 'not used by any apps';
Log.log(` ${chalk.gray(usedByAppsText)}`);
}
}
@@ -1,181 +0,0 @@
import chalk from 'chalk';
import dateformat from 'dateformat';
import {
AppleDeviceFragment,
CommonIosAppCredentialsFragment,
IosAppBuildCredentialsFragment,
IosDistributionType,
} from '../../../graphql/generated';
import { APPLE_DEVICE_CLASS_LABELS } from '../../../graphql/types/credentials/AppleDevice';
import Log from '../../../log';
import { fromNow } from '../../../utils/date';
import { AppLookupParams } from '../api/GraphqlClient';
function prettyIosDistributionType(distributionType: IosDistributionType): string {
switch (distributionType) {
case IosDistributionType.AppStore:
return 'App Store';
case IosDistributionType.AdHoc:
return 'Ad Hoc';
case IosDistributionType.Development:
return 'Development';
case IosDistributionType.Enterprise:
return 'Enterprise';
default:
return 'Unknown';
}
}
export function displayEmptyIosCredentials(appLookupParams: AppLookupParams): void {
const { projectName, bundleIdentifier } = appLookupParams;
Log.log(chalk.bold(`iOS Credentials`));
Log.log(` Project: ${projectName}`);
Log.log(` Bundle Identifier: ${bundleIdentifier}`);
Log.log(` No credentials set up yet!`);
}
/**
* sort a build credentials array in descending order of preference
*/
function sortBuildCredentialsByDistributionType(
iosAppBuildCredentialsArray: IosAppBuildCredentialsFragment[]
): IosAppBuildCredentialsFragment[] {
// The order in which we choose the distribution type from least to most preferred
const typePriority = [
IosDistributionType.Development,
IosDistributionType.AdHoc,
IosDistributionType.Enterprise,
IosDistributionType.AppStore,
];
return iosAppBuildCredentialsArray
.sort(
(buildCredentialsA, buildCredentialsB) =>
typePriority.indexOf(buildCredentialsA.iosDistributionType) -
typePriority.indexOf(buildCredentialsB.iosDistributionType)
)
.reverse();
}
export function displayIosAppCredentials(credentials: CommonIosAppCredentialsFragment): void {
Log.log(chalk.bold(`iOS Credentials`));
Log.log(` Project: ${credentials.app.fullName}`);
Log.log(` Bundle Identifier: ${credentials.appleAppIdentifier.bundleIdentifier}`);
const appleTeam = credentials.appleTeam;
if (appleTeam) {
const { appleTeamIdentifier, appleTeamName } = appleTeam;
Log.log(` Apple Team: ${appleTeamIdentifier} ${appleTeamName ? `(${appleTeamName})` : ''}`);
}
Log.newLine();
if (credentials.iosAppBuildCredentialsArray.length === 0) {
Log.log(` Configuration: None setup yet`);
Log.newLine();
return;
}
const sortedIosAppBuildCredentialsArray = sortBuildCredentialsByDistributionType(
credentials.iosAppBuildCredentialsArray
);
for (const iosAppBuildCredentials of sortedIosAppBuildCredentialsArray) {
displayIosAppBuildCredentials(iosAppBuildCredentials);
}
}
export function displayProjectCredentials(
appLookupParams: AppLookupParams,
buildCredentials: IosAppBuildCredentialsFragment
): void {
const experienceName = `@${appLookupParams.account.name}/${appLookupParams.projectName}`;
Log.addNewLineIfNone();
Log.log(chalk.bold('Project Credentials Configuration:'));
Log.log(` Project: ${chalk.bold(experienceName)}`);
Log.log(` Bundle Identifier: ${appLookupParams.bundleIdentifier}`);
displayIosAppBuildCredentials(buildCredentials);
}
function displayIosAppBuildCredentials(buildCredentials: IosAppBuildCredentialsFragment): void {
Log.log(
chalk.bold(
` Configuration: ${prettyIosDistributionType(buildCredentials.iosDistributionType)}`
)
);
Log.newLine();
const maybeDistCert = buildCredentials.distributionCertificate;
Log.log(` Distribution Certificate:`);
if (maybeDistCert) {
const { serialNumber, updatedAt, validityNotAfter, appleTeam } = maybeDistCert;
Log.log(` Serial Number: ${serialNumber}`);
Log.log(` Expiration Date: ${dateformat(validityNotAfter, 'expiresHeaderFormat')}`);
if (appleTeam) {
const { appleTeamIdentifier, appleTeamName } = appleTeam;
Log.log(
` Apple Team: ${appleTeamIdentifier} ${appleTeamName ? `(${appleTeamName})` : ''}`
);
}
Log.log(` Updated ${fromNow(new Date(updatedAt))} ago`);
} else {
Log.log(` None assigned yet`);
}
Log.newLine();
const maybeProvProf = buildCredentials.provisioningProfile;
Log.log(` Provisioning Profile:`);
if (maybeProvProf) {
const {
expiration,
updatedAt,
status,
developerPortalIdentifier,
appleTeam,
appleDevices,
} = maybeProvProf;
if (developerPortalIdentifier) {
Log.log(` Developer Portal ID: ${developerPortalIdentifier}`);
}
Log.log(` Status: ${status}`);
Log.log(` Expiration Date: ${dateformat(expiration, 'expiresHeaderFormat')}`);
if (appleTeam) {
const { appleTeamIdentifier, appleTeamName } = appleTeam;
Log.log(
` Apple Team: ${appleTeamIdentifier} ${appleTeamName ? `(${appleTeamName})` : ''}`
);
}
if (appleDevices && appleDevices.length > 0) {
Log.log(` Provisioned devices:`);
for (const appleDevice of appleDevices) {
Log.log(` - ${formatAppleDevice(appleDevice)}`);
}
}
Log.log(` Updated ${fromNow(new Date(updatedAt))} ago`);
} else {
Log.log(` None assigned yet`);
}
Log.newLine();
}
function formatAppleDevice(device: AppleDeviceFragment): string {
let deviceString = '';
if (device.name) {
deviceString += device.name;
}
if (device.deviceClass || device.model) {
const deviceDetails = [
device.deviceClass && APPLE_DEVICE_CLASS_LABELS[device.deviceClass],
device.model,
]
.filter(i => i)
.join(' ');
if (deviceString === '') {
deviceString += deviceDetails;
} else {
deviceString += ` - ${deviceDetails}`;
}
}
if (deviceString === '') {
deviceString += device.identifier;
} else {
deviceString += ` (UDID: ${device.identifier})`;
}
return deviceString;
}
@@ -0,0 +1,63 @@
import Log from '../../log';
import { getProjectAccountName } from '../../project/projectUtils';
import { findAccountByName } from '../../user/Account';
import { ensureActorHasUsername } from '../../user/actions';
import { Action, CredentialsManager } from '../CredentialsManager';
import { getAppLookupParamsFromContext } from '../android/actions/BuildCredentialsUtils';
import {
displayAndroidAppCredentials,
displayEmptyAndroidCredentials,
} from '../android/utils/printCredentialsBeta';
import { Context } from '../context';
import { PressAnyKeyToContinue } from './HelperActions';
enum ActionType {}
enum Scope {
Project,
Account,
Manager,
}
type ActionInfo = { value: ActionType; title: string; scope: Scope };
const highLevelActions: ActionInfo[] = [];
export class ManageAndroid implements Action {
async runAsync(
manager: CredentialsManager,
ctx: Context,
_currentActions: ActionInfo[] = highLevelActions
): Promise<void> {
while (true) {
try {
const accountName = ctx.hasProjectContext
? getProjectAccountName(ctx.exp, ctx.user)
: ensureActorHasUsername(ctx.user);
const account = findAccountByName(ctx.user.accounts, accountName);
if (!account) {
throw new Error(`You do not have access to account: ${accountName}`);
}
if (ctx.hasProjectContext) {
const appLookupParams = getAppLookupParamsFromContext(ctx);
const legacyAppCredentials = await ctx.newAndroid.getLegacyAndroidAppCredentialsWithCommonFieldsAsync(
appLookupParams
);
const appCredentials = await ctx.newAndroid.getAndroidAppCredentialsWithCommonFieldsAsync(
appLookupParams
);
if (!legacyAppCredentials && !appCredentials) {
displayEmptyAndroidCredentials(appLookupParams);
} else {
displayAndroidAppCredentials({ appLookupParams, legacyAppCredentials, appCredentials });
}
throw new Error('Not Implemented Yet');
}
} catch (err) {
Log.error(err);
await manager.runActionAsync(new PressAnyKeyToContinue());
}
}
}
}
@@ -1,37 +1,76 @@
import { EasConfig, EasJsonReader } from '@expo/eas-json';
import {
AppleDistributionCertificateFragment,
IosAppBuildCredentialsFragment,
IosDistributionType as IosDistributionTypeGraphql,
} from '../../graphql/generated';
import Log from '../../log';
import { getProjectAccountName } from '../../project/projectUtils';
import { promptAsync } from '../../prompts';
import { confirmAsync, promptAsync } from '../../prompts';
import { Account, findAccountByName } from '../../user/Account';
import { ensureActorHasUsername } from '../../user/actions';
import { Action, CredentialsManager } from '../CredentialsManager';
import { Context } from '../context';
import { CreateDistributionCertificateStandaloneManager } from '../ios/actions/CreateDistributionCertificate';
import { RemoveDistributionCertificate } from '../ios/actions/RemoveDistributionCertificate';
import { RemoveSpecificProvisioningProfile } from '../ios/actions/RemoveProvisioningProfile';
import {
SetupBuildCredentials,
SetupBuildCredentialsFromCredentialsJson,
} from '../ios/actions/SetupBuildCredentials';
import { getAppLookupParamsFromContext } from '../ios/actions/BuildCredentialsUtils';
import { CreateDistributionCertificate } from '../ios/actions/CreateDistributionCertificate';
import { selectValidDistributionCertificateAsync } from '../ios/actions/DistributionCertificateUtils';
import { SelectAndRemoveDistributionCertificate } from '../ios/actions/RemoveDistributionCertificate';
import { RemoveProvisioningProfiles } from '../ios/actions/RemoveProvisioningProfile';
import { SetupAdhocProvisioningProfile } from '../ios/actions/SetupAdhocProvisioningProfile';
import { SetupBuildCredentials } from '../ios/actions/SetupBuildCredentials';
import { SetupBuildCredentialsFromCredentialsJson } from '../ios/actions/SetupBuildCredentialsFromCredentialsJson';
import { SetupProvisioningProfile } from '../ios/actions/SetupProvisioningProfile';
import { UpdateCredentialsJson } from '../ios/actions/UpdateCredentialsJson';
import { UpdateDistributionCertificate } from '../ios/actions/UpdateDistributionCertificate';
import { UseExistingDistributionCertificate } from '../ios/actions/UseDistributionCertificate';
import { getAppLookupParamsFromContext } from '../ios/actions/new/BuildCredentialsUtils';
import { AppLookupParams } from '../ios/credentials';
import { displayAllIosCredentials } from '../ios/utils/printCredentials';
import { AppLookupParams } from '../ios/api/GraphqlClient';
import {
displayEmptyIosCredentials,
displayIosAppCredentials,
} from '../ios/utils/printCredentials';
import { PressAnyKeyToContinue } from './HelperActions';
import { SelectBuildProfileFromEasJson } from './SelectBuildProfileFromEasJson';
import { SelectIosDistributionTypeGraphqlFromBuildProfile } from './SelectIosDistributionTypeGraphqlFromBuildProfile';
enum ActionType {
ManageCredentialsJson,
ManageBuildCredentials,
GoBackToHighLevelActions,
SetupBuildCredentials,
SetupBuildCredentialsFromCredentialsJson,
UpdateCredentialsJson,
UseExistingDistributionCertificate,
RemoveSpecificProvisioningProfile,
RemoveProvisioningProfile,
CreateDistributionCertificate,
UpdateDistributionCertificate,
RemoveDistributionCertificate,
}
enum Scope {
Project,
Account,
Manager,
}
type ActionInfo = { value: ActionType; title: string; scope: Scope };
const highLevelActions: ActionInfo[] = [
{
value: ActionType.ManageBuildCredentials,
title: 'Build Credentials: Manage everything needed to build your project',
scope: Scope.Manager,
},
{
value: ActionType.ManageCredentialsJson,
title: 'Credentials.json: Upload/Download credentials between EAS servers and your local json ',
scope: Scope.Manager,
},
];
export class ManageIos implements Action {
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
async runAsync(
manager: CredentialsManager,
ctx: Context,
currentActions: ActionInfo[] = highLevelActions
): Promise<void> {
while (true) {
try {
await ctx.bestEffortAppStoreAuthenticateAsync();
@@ -39,60 +78,116 @@ export class ManageIos implements Action {
const accountName = ctx.hasProjectContext
? getProjectAccountName(ctx.exp, ctx.user)
: ensureActorHasUsername(ctx.user);
const iosCredentials = await ctx.ios.getAllCredentialsAsync(accountName);
await displayAllIosCredentials(iosCredentials);
const account = findAccountByName(ctx.user.accounts, accountName);
if (!account) {
throw new Error(`You do not have access to account: ${accountName}`);
}
if (ctx.hasProjectContext) {
const appLookupParams = getAppLookupParamsFromContext(ctx);
const iosAppCredentials = await ctx.ios.getIosAppCredentialsWithCommonFieldsAsync(
appLookupParams
);
if (!iosAppCredentials) {
displayEmptyIosCredentials(appLookupParams);
} else {
displayIosAppCredentials(iosAppCredentials);
}
}
const projectSpecificActions: { value: ActionType; title: string }[] = ctx.hasProjectContext
? [
{
// This command will be triggered during build to ensure all credentials are ready
// I'm leaving it here for now to simplify testing
value: ActionType.SetupBuildCredentials,
title: 'Ensure all credentials for project are valid',
},
{
value: ActionType.UpdateCredentialsJson,
title: 'Update credentials.json with values from EAS servers',
},
{
value: ActionType.SetupBuildCredentialsFromCredentialsJson,
title: 'Update credentials on EAS servers with values from credentials.json',
},
{
value: ActionType.UseExistingDistributionCertificate,
title: 'Use existing Distribution Certificate in current project',
},
{
value: ActionType.RemoveSpecificProvisioningProfile,
title: 'Remove Provisioning Profile from current project',
},
]
: [];
const { action } = await promptAsync({
const credentialsJsonActions: { value: ActionType; title: string; scope: Scope }[] = [
{
value: ActionType.UpdateCredentialsJson,
title: 'Download credentials from EAS to credentials.json',
scope: Scope.Project,
},
{
value: ActionType.SetupBuildCredentialsFromCredentialsJson,
title: 'Upload credentials from credentials.json to EAS',
scope: Scope.Project,
},
{
value: ActionType.GoBackToHighLevelActions,
title: 'Go back',
scope: Scope.Manager,
},
];
const buildCredentialsActions: { value: ActionType; title: string; scope: Scope }[] = [
{
// This command will be triggered during build to ensure all credentials are ready
// I'm leaving it here for now to simplify testing
value: ActionType.SetupBuildCredentials,
title: 'All: Set up all the required credentials to build your project',
scope: Scope.Project,
},
{
value: ActionType.UseExistingDistributionCertificate,
title: 'Distribution Certificate: Use an existing one for your project',
scope: Scope.Project,
},
{
value: ActionType.CreateDistributionCertificate,
title: `Distribution Certificate: Add a new one to your account`,
scope: ctx.hasProjectContext ? Scope.Project : Scope.Account,
},
{
value: ActionType.RemoveDistributionCertificate,
title: 'Distribution Certificate: Delete one from your account',
scope: Scope.Account,
},
{
value: ActionType.RemoveProvisioningProfile,
title: 'Provisioning Profile: Delete one from your project',
scope: Scope.Project,
},
{
value: ActionType.GoBackToHighLevelActions,
title: 'Go back',
scope: Scope.Manager,
},
];
const { action: chosenAction } = await promptAsync({
type: 'select',
name: 'action',
message: 'What do you want to do?',
choices: [
...projectSpecificActions,
{
value: ActionType.CreateDistributionCertificate,
title: 'Add new Distribution Certificate',
},
{
value: ActionType.RemoveDistributionCertificate,
title: 'Remove Distribution Certificate',
},
{
value: ActionType.UpdateDistributionCertificate,
title: 'Update Distribution Certificate',
},
],
choices: currentActions.map(action => ({
value: action.value,
title: action.title,
})),
});
try {
await manager.runActionAsync(this.getAction(manager, ctx, accountName, action));
const actionInfo = currentActions.find(action => action.value === chosenAction);
if (!actionInfo) {
throw new Error('Action not supported yet');
}
if (actionInfo.scope === Scope.Manager) {
if (chosenAction === ActionType.ManageBuildCredentials) {
currentActions = buildCredentialsActions;
continue;
} else if (chosenAction === ActionType.ManageCredentialsJson) {
currentActions = credentialsJsonActions;
continue;
} else if (chosenAction === ActionType.GoBackToHighLevelActions) {
currentActions = highLevelActions;
continue;
}
} else if (actionInfo.scope === Scope.Project) {
const appLookupParams = getAppLookupParamsFromContext(ctx);
const easJsonReader = await new EasJsonReader(ctx.projectDir, 'ios');
const easConfig = await new SelectBuildProfileFromEasJson(easJsonReader).runAsync(ctx);
await this.runProjectSpecificActionAsync(
manager,
ctx,
appLookupParams,
easConfig,
chosenAction
);
} else if (actionInfo.scope === Scope.Account) {
await this.runAccountSpecificActionAsync(ctx, account, chosenAction);
} else {
throw new Error('Unknown action selected');
}
} catch (err) {
Log.error(err);
}
@@ -104,52 +199,127 @@ export class ManageIos implements Action {
}
}
private getAppLookupParamsFromContext(ctx: Context): AppLookupParams {
const projectName = ctx.exp.slug;
const accountName = getProjectAccountName(ctx.exp, ctx.user);
const bundleIdentifier = ctx.exp.ios?.bundleIdentifier;
if (!bundleIdentifier) {
throw new Error(`ios.bundleIdentifier needs to be defined`);
private async runAccountSpecificActionAsync(
ctx: Context,
account: Account,
action: ActionType
): Promise<void> {
if (action === ActionType.RemoveDistributionCertificate) {
await new SelectAndRemoveDistributionCertificate(account).runAsync(ctx);
} else if (action === ActionType.CreateDistributionCertificate) {
await new CreateDistributionCertificate(account).runAsync(ctx);
}
return { accountName, projectName, bundleIdentifier };
}
private getAction(
private async runProjectSpecificActionAsync(
manager: CredentialsManager,
ctx: Context,
accountName: string,
appLookupParams: AppLookupParams,
easConfig: EasConfig,
action: ActionType
): Action {
): Promise<void> {
if (action === ActionType.SetupBuildCredentials) {
const iosDistributionTypeEasConfig = easConfig.builds.ios?.distribution;
if (!iosDistributionTypeEasConfig) {
throw new Error(`The distributionType field is required in your iOS build profile`);
}
await new SetupBuildCredentials({
app: appLookupParams,
distribution: iosDistributionTypeEasConfig,
}).runAsync(manager, ctx);
return;
}
const iosAppCredentials = await ctx.ios.getIosAppCredentialsWithCommonFieldsAsync(
appLookupParams
);
const iosDistributionTypeGraphql = await new SelectIosDistributionTypeGraphqlFromBuildProfile(
easConfig
).runAsync(ctx, iosAppCredentials);
switch (action) {
case ActionType.CreateDistributionCertificate:
return new CreateDistributionCertificateStandaloneManager(accountName);
case ActionType.UpdateDistributionCertificate:
return new UpdateDistributionCertificate(accountName);
case ActionType.RemoveDistributionCertificate:
return new RemoveDistributionCertificate(accountName);
case ActionType.UseExistingDistributionCertificate: {
const app = this.getAppLookupParamsFromContext(ctx);
return new UseExistingDistributionCertificate(app);
}
case ActionType.SetupBuildCredentials: {
const appLookupParams = getAppLookupParamsFromContext(ctx);
return new SetupBuildCredentials({ app: appLookupParams, distribution: 'store' });
}
case ActionType.RemoveSpecificProvisioningProfile: {
const app = this.getAppLookupParamsFromContext(ctx);
return new RemoveSpecificProvisioningProfile(app);
case ActionType.SetupBuildCredentialsFromCredentialsJson: {
await new SetupBuildCredentialsFromCredentialsJson(
appLookupParams,
iosDistributionTypeGraphql
).runAsync(ctx);
return;
}
case ActionType.UpdateCredentialsJson: {
const app = this.getAppLookupParamsFromContext(ctx);
return new UpdateCredentialsJson(app);
await new UpdateCredentialsJson(appLookupParams, iosDistributionTypeGraphql).runAsync(ctx);
return;
}
case ActionType.SetupBuildCredentialsFromCredentialsJson: {
const app = this.getAppLookupParamsFromContext(ctx);
return new SetupBuildCredentialsFromCredentialsJson(app);
case ActionType.UseExistingDistributionCertificate: {
const distCert = await selectValidDistributionCertificateAsync(ctx, appLookupParams);
if (!distCert) {
return;
}
await this.setupProvisioningProfileWithSpecificDistCertAsync(
ctx,
appLookupParams,
distCert,
iosDistributionTypeGraphql
);
return;
}
case ActionType.CreateDistributionCertificate: {
const distCert = await new CreateDistributionCertificate(appLookupParams.account).runAsync(
ctx
);
const confirm = await confirmAsync({
message: `Do you want ${appLookupParams.projectName} to use the new Distribution Certificate?`,
});
if (confirm) {
await this.setupProvisioningProfileWithSpecificDistCertAsync(
ctx,
appLookupParams,
distCert,
iosDistributionTypeGraphql
);
}
return;
}
case ActionType.RemoveProvisioningProfile: {
const provisioningProfile = iosAppCredentials?.iosAppBuildCredentialsList.find(
buildCredentials => buildCredentials.iosDistributionType === iosDistributionTypeGraphql
)?.provisioningProfile;
if (!provisioningProfile) {
Log.log(
`No provisioning profile associated with the ${iosDistributionTypeGraphql} configuration of ${appLookupParams.projectName}`
);
return;
}
const confirm = await confirmAsync({
message: `Delete the provisioning profile associated with the ${iosDistributionTypeGraphql} configuration of ${appLookupParams.projectName}?`,
});
if (confirm) {
await new RemoveProvisioningProfiles([appLookupParams], [provisioningProfile]).runAsync(
ctx
);
}
return;
}
default:
throw new Error('Unknown action selected');
}
}
private async setupProvisioningProfileWithSpecificDistCertAsync(
ctx: Context,
appLookupParams: AppLookupParams,
distCert: AppleDistributionCertificateFragment,
iosDistributionTypeGraphql: IosDistributionTypeGraphql
): Promise<IosAppBuildCredentialsFragment> {
Log.log(`Setting up ${appLookupParams.projectName} to use Distribution Certificate`);
Log.log(`Creating provisioning profile...`);
if (iosDistributionTypeGraphql === IosDistributionTypeGraphql.AdHoc) {
return await new SetupAdhocProvisioningProfile(
appLookupParams
).runWithDistributionCertificateAsync(ctx, distCert);
} else {
return await new SetupProvisioningProfile(
appLookupParams,
iosDistributionTypeGraphql
).createAndAssignProfileAsync(ctx, distCert);
}
}
}
@@ -1,152 +0,0 @@
import { EasConfig, EasJsonReader } from '@expo/eas-json';
import Log from '../../log';
import { getProjectAccountName } from '../../project/projectUtils';
import { promptAsync } from '../../prompts';
import { findAccountByName } from '../../user/Account';
import { ensureActorHasUsername } from '../../user/actions';
import { Action, CredentialsManager } from '../CredentialsManager';
import { Context } from '../context';
import { SetupBuildCredentials } from '../ios/actions/SetupBuildCredentials';
import { getAppLookupParamsFromContext } from '../ios/actions/new/BuildCredentialsUtils';
import { SelectAndRemoveDistributionCertificate } from '../ios/actions/new/RemoveDistributionCertificate';
import { SetupBuildCredentialsFromCredentialsJson } from '../ios/actions/new/SetupBuildCredentialsFromCredentialsJson';
import { AppLookupParams } from '../ios/api/GraphqlClient';
import {
displayEmptyIosCredentials,
displayIosAppCredentials,
} from '../ios/utils/printCredentialsBeta';
import { PressAnyKeyToContinue } from './HelperActions';
import { SelectBuildProfileFromEasJson } from './SelectBuildProfileFromEasJson';
import { SelectIosDistributionTypeGraphqlFromBuildProfile } from './SelectIosDistributionTypeGraphqlFromBuildProfile';
enum ActionType {
SetupBuildCredentials,
SetupBuildCredentialsFromCredentialsJson,
UpdateCredentialsJson,
UseExistingDistributionCertificate,
RemoveSpecificProvisioningProfile,
CreateDistributionCertificate,
UpdateDistributionCertificate,
RemoveDistributionCertificate,
}
export class ManageIosBeta implements Action {
async runAsync(manager: CredentialsManager, ctx: Context): Promise<void> {
while (true) {
try {
await ctx.bestEffortAppStoreAuthenticateAsync();
const accountName = ctx.hasProjectContext
? getProjectAccountName(ctx.exp, ctx.user)
: ensureActorHasUsername(ctx.user);
const account = findAccountByName(ctx.user.accounts, accountName);
if (!account) {
throw new Error(`You do not have access to account: ${accountName}`);
}
if (ctx.hasProjectContext) {
const appLookupParams = getAppLookupParamsFromContext(ctx);
const iosAppCredentials = await ctx.newIos.getIosAppCredentialsWithCommonFieldsAsync(
appLookupParams
);
if (!iosAppCredentials) {
displayEmptyIosCredentials(appLookupParams);
} else {
displayIosAppCredentials(iosAppCredentials);
}
}
const projectSpecificActions: { value: ActionType; title: string }[] = ctx.hasProjectContext
? [
{
// This command will be triggered during build to ensure all credentials are ready
// I'm leaving it here for now to simplify testing
value: ActionType.SetupBuildCredentials,
title: 'Ensure all credentials for project are valid',
},
{
value: ActionType.SetupBuildCredentialsFromCredentialsJson,
title: 'Update credentials on EAS servers with values from credentials.json',
},
]
: [];
const { action } = await promptAsync({
type: 'select',
name: 'action',
message: 'What do you want to do?',
choices: [
...projectSpecificActions,
{
value: ActionType.RemoveDistributionCertificate,
title: 'Remove Distribution Certificate',
},
],
});
try {
const isProjectSpecific = projectSpecificActions.find(
actionItem => actionItem.value === action
);
if (isProjectSpecific) {
const appLookupParams = getAppLookupParamsFromContext(ctx);
const easJsonReader = await new EasJsonReader(ctx.projectDir, 'ios');
const easConfig = await new SelectBuildProfileFromEasJson(easJsonReader).runAsync(ctx);
await this.runProjectSpecificActionAsync(
manager,
ctx,
appLookupParams,
easConfig,
action
);
} else if (action === ActionType.RemoveDistributionCertificate) {
await new SelectAndRemoveDistributionCertificate(account).runAsync(ctx);
} else {
throw new Error('Unknown action selected');
}
} catch (err) {
Log.error(err);
}
await manager.runActionAsync(new PressAnyKeyToContinue());
} catch (err) {
Log.error(err);
await manager.runActionAsync(new PressAnyKeyToContinue());
}
}
}
private async runProjectSpecificActionAsync(
manager: CredentialsManager,
ctx: Context,
appLookupParams: AppLookupParams,
easConfig: EasConfig,
action: ActionType
): Promise<void> {
switch (action) {
case ActionType.SetupBuildCredentials: {
const iosDistributionTypeEasConfig = easConfig.builds.ios?.distribution;
if (!iosDistributionTypeEasConfig) {
throw new Error(`The distributionType field is required in your iOS build profile`);
}
return await new SetupBuildCredentials({
app: appLookupParams,
distribution: iosDistributionTypeEasConfig,
}).runAsync(manager, ctx);
}
case ActionType.SetupBuildCredentialsFromCredentialsJson: {
const iosAppCredentials = await ctx.newIos.getIosAppCredentialsWithCommonFieldsAsync(
appLookupParams
);
const iosDistributionTypeGraphql = await new SelectIosDistributionTypeGraphqlFromBuildProfile(
easConfig
).runAsync(ctx, iosAppCredentials);
await new SetupBuildCredentialsFromCredentialsJson(
appLookupParams,
iosDistributionTypeGraphql
).runAsync(ctx);
return;
}
default:
throw new Error('Unknown action selected');
}
}
}
@@ -14,8 +14,7 @@ export class SelectBuildProfileFromEasJson {
}
async getProfileNameFromEasConfigAsync(ctx: Context): Promise<string> {
const easJson = await this.easJsonReader.readRawAsync();
const buildProfileNames = Object.keys(easJson.builds?.ios || {});
const buildProfileNames = await this.easJsonReader.getBuildProfileNamesAsync();
if (buildProfileNames.length === 0) {
throw new Error(
'You need at least one iOS build profile declared in eas.json. Go to https://docs.expo.io/build/eas-json/ for more details'
@@ -51,9 +51,9 @@ export class SelectIosDistributionTypeGraphqlFromBuildProfile {
}
// extrapolate type from existing app credentials
const iosAppBuildCredentialsArray = iosAppCredentials?.iosAppBuildCredentialsArray ?? [];
const iosAppBuildCredentialsList = iosAppCredentials?.iosAppBuildCredentialsList ?? [];
const existingInternalIosDistributionTypes = uniq(
iosAppBuildCredentialsArray
iosAppBuildCredentialsList
.map(buildCredentials => buildCredentials.iosDistributionType)
.filter(
distributionTypeGraphql =>
@@ -1,11 +1,8 @@
import { EasConfig } from '@expo/eas-json';
import {
CommonIosAppCredentialsFragment,
IosDistributionType as IosDistributionTypeGraphql,
} from '../../../graphql/generated';
import { IosDistributionType as IosDistributionTypeGraphql } from '../../../graphql/generated';
import { createCtxMock } from '../../__tests__/fixtures-context';
import { testIosAppCredentialsWithBuildCredentialsQueryResult } from '../../__tests__/fixtures-ios';
import { testCommonIosAppCredentialsFragment } from '../../__tests__/fixtures-ios';
import { SelectIosDistributionTypeGraphqlFromBuildProfile } from '../SelectIosDistributionTypeGraphqlFromBuildProfile';
describe('SelectIosDistributionTypeGraphqlFromBuildProfile', () => {
@@ -113,10 +110,8 @@ describe('SelectIosDistributionTypeGraphqlFromBuildProfile', () => {
);
// create deep clone the quick and dirty way
const testAppCredentials = JSON.parse(
JSON.stringify(testIosAppCredentialsWithBuildCredentialsQueryResult)
) as CommonIosAppCredentialsFragment;
testAppCredentials.iosAppBuildCredentialsArray[0].iosDistributionType =
const testAppCredentials = JSON.parse(JSON.stringify(testCommonIosAppCredentialsFragment));
testAppCredentials.iosAppBuildCredentialsList[0].iosDistributionType =
IosDistributionTypeGraphql.AdHoc;
const iosDistributionTypeGraphql = await selectIosDistributionTypeGraphqlFromBuildProfileAction.runAsync(
ctx,
+1
View File
@@ -0,0 +1 @@
declare module 'jks-js';
+1 -1
View File
@@ -19,7 +19,7 @@ Your app archive (.ipa) will be installable on your equipment as long as you sig
The provisioning profile needs to contain the UDIDs (unique identifiers) of your iPhones and iPads.
First of all, please choose the Expo account under which you want to register your devices.
Later, authenticate with Apple and choose your desired Apple Team (if you're Apple ID has access to multiple teams).`;
Later, authenticate with Apple and choose your desired Apple Team (if your Apple ID has access to multiple teams).`;
export default class DeviceManager {
constructor(private ctx: DeviceManagerContext) {}
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more