Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/plumesign/src/commands/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pub async fn app_ids(args: AppIdsArgs) -> Result<()> {
args.team_id.unwrap()
};

let p = session.v1_list_app_ids(&team_id).await?.data;
let p = session.v1_list_app_ids(&team_id, None).await?.data;

log::info!("{:#?}", p);

Expand Down
2 changes: 1 addition & 1 deletion crates/plume_core/src/developer/qh/certs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub struct Cert {
pub expiration_date: Date,
certificate_platform: Option<String>,
pub cert_type: Option<CertType>,
pub cert_content: Data,
pub cert_content: Option<Data>,
pub machine_id: Option<String>,
pub machine_name: Option<String>,
}
Expand Down
17 changes: 13 additions & 4 deletions crates/plume_core/src/developer/v1/app_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@ use crate::developer_endpoint;
use crate::Error;

impl DeveloperSession {
pub async fn v1_list_app_ids(&self, team: &String) -> Result<AppIDsResponse, Error> {
pub async fn v1_list_app_ids(
&self,
team: &String,
filter: Option<&String>,
) -> Result<AppIDsResponse, Error> {
let endpoint = developer_endpoint!("/v1/bundleIds");

let mut query = String::from("limit=1000");

if let Some(identifier) = filter {
query.push_str(&format!("&filter[identifier]={}", identifier));
}

let body = json!({
"teamId": team,
"urlEncodedQueryParams": "limit=1000"
"urlEncodedQueryParams": query
});

let response = self
.v1_send_request(&endpoint, Some(body), Some(RequestType::Get))
.await?;
let response_data: AppIDsResponse = serde_json::from_value(response)?;

Ok(response_data)
}

Expand All @@ -28,7 +37,7 @@ impl DeveloperSession {
team: &String,
app_id: &String,
) -> Result<Option<AppID>, Error> {
let response_data = self.v1_list_app_ids(team).await?;
let response_data = self.v1_list_app_ids(team, Some(app_id)).await?;

let app_id = response_data
.data
Expand Down
39 changes: 27 additions & 12 deletions crates/plume_core/src/utils/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ impl CertificateIdentity {
let cert_pem = encode_string(
"CERTIFICATE",
LineEnding::LF,
certificate.cert_content.as_ref(),
certificate
.cert_content
.ok_or(Error::CertificatePemMissing)?
.as_ref(),
)
.unwrap();
let key_pem = priv_key.to_pkcs8_pem(Default::default())?.to_string();
Expand All @@ -101,10 +104,14 @@ impl CertificateIdentity {
let (certificate, priv_key) = identity
.request_new_certificate(session, team_id, &machine_name, certs)
.await?;

let cert_pem = encode_string(
"CERTIFICATE",
LineEnding::LF,
certificate.cert_content.as_ref(),
certificate
.cert_content
.ok_or(Error::CertificatePemMissing)?
.as_ref(),
)
.unwrap();
let key_pem = priv_key.to_pkcs8_pem(Default::default())?.to_string();
Expand All @@ -117,8 +124,14 @@ impl CertificateIdentity {
let (cert, priv_key) = identity
.request_new_certificate(session, team_id, &machine_name, certs)
.await?;
let cert_pem =
encode_string("CERTIFICATE", LineEnding::LF, cert.cert_content.as_ref()).unwrap();
let cert_pem = encode_string(
"CERTIFICATE",
LineEnding::LF,
cert.cert_content
.ok_or(Error::CertificatePemMissing)?
.as_ref(),
)
.unwrap();
let key_pem = priv_key.to_pkcs8_pem(Default::default())?.to_string();

fs::write(&key_path, &key_pem)?;
Expand Down Expand Up @@ -231,16 +244,18 @@ impl CertificateIdentity {

for cert in certs {
if cert.machine_name.as_deref() == Some(machine_name) {
let parsed_cert = X509Certificate::from_der(&cert.cert_content)?;
if pub_key_der_obj == parsed_cert.public_key_data().as_ref() {
// We need to save the machine_id for our P12
if let Some(ref machine_id) = cert.machine_id {
self.set_machine_id(machine_id.clone());
}
if let Some(cert_content) = &cert.cert_content {
let parsed_cert = X509Certificate::from_der(&cert_content)?;
if pub_key_der_obj == parsed_cert.public_key_data().as_ref() {
// We need to save the machine_id for our P12
if let Some(ref machine_id) = cert.machine_id {
self.set_machine_id(machine_id.clone());
}

self.set_serial_number(cert.serial_number.clone());
self.set_serial_number(cert.serial_number.clone());

return Ok(Some(cert));
return Ok(Some(cert));
}
}
}
}
Expand Down