1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Rust library for generate Apple Wallet Passes for iOS, WatchOS, MacOS.
//!
//! # Quick start
//! [Pass] represent the displayable fields (pass.json), [Package]
//! includes [Pass] and [Resource's](resource::Resource) (images, such as logo, background, etc.) and
//! represent pass package (.pkpass file).
//!
//! Before making [Package], you need to create [Pass] structure, then include pass (and required resources) to
//! package.
//!
//! ```
//! use passes::{resource, sign, Package, PassBuilder, PassConfig};
//! use std::{fs::File, path::Path};
//!
//! // Creating a pass
//! let pass = PassBuilder::new(PassConfig {
//! organization_name: "Test organization".into(),
//! description: "Test description for pass".into(),
//! pass_type_identifier: "com.example.pass".into(),
//! team_identifier: "AA00AA0A0A".into(),
//! serial_number: "ABCDEFG1234567890".into(),
//! })
//! .grouping_identifier(String::from("com.example.pass.app"))
//! .logo_text("Test pass".into())
//! .build();
//!
//! // Creating package
//! let mut package = Package::new(pass);
//!
//! // Add required resource
//! let file = File::open(&Path::new("examples/pass-generator/template_app_icon.png")).unwrap();
//! package
//! .add_resource(resource::Type::Icon(resource::Version::Standard), file)
//! .unwrap();
//! ```
//!
//! Then you can add certificates for sign pass package. Signing is required for iOS, MacOS and other Apple stuff.
//!
//! ```rust,ignore
//! let mut file_sign_cert = File::open(&Path::new("certs/signerCert.pem"));
//! let mut sign_cert_data = Vec::new();
//! std::io::Read::read_to_end(&mut file_sign_cert, &mut sign_cert_data).unwrap();
//!
//! let mut file_sign_key_cert = File::open(&Path::new("certs/signerKey.key")).unwrap();
//! let mut sign_cert_key_data = Vec::new();
//! std::io::Read::read_to_end(&mut file_sign_key_cert, &mut sign_cert_key_data).unwrap();
//!
//! let sign_config =
//! sign::SignConfig::new(passes::sign::WWDR::G4, &sign_cert_data, &sign_cert_key_data)
//! .unwrap();
//! package.add_certificates(sign_config);
//! ```
//!
//! You can save package as .pkpass file:
//!
//! ```rust,ignore
//! // Save package as .pkpass
//! let file = File::create(&Path::new("test_pass.pkpass")).unwrap();
//! package.write(file).unwrap();
//! ```
//!
//! For more examples, see [example directory](https://github.com/mvodya/passes-rs/tree/main/examples) on GitHub.
// Primary modules
// Re-exports
pub use *;
pub use *;