mirror of
https://github.com/hpd840321/craftlabs-authorization-sdk.git
synced 2026-06-09 10:00:30 +08:00
feat: add build.rs pubkey embedding and webhook license/v1 endpoints
This commit is contained in:
@@ -11,11 +11,20 @@ fn main() {
|
||||
hash_dir(&src_dir, &mut hasher);
|
||||
let digest = hasher.finalize();
|
||||
let hash_hex = format!("{:x}", digest);
|
||||
|
||||
println!("cargo:rustc-env=BUILD_SRC_HASH={}", hash_hex);
|
||||
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
fs::write(out_dir.join("build_hash.txt"), format!("{}\n", hash_hex)).unwrap();
|
||||
|
||||
// 嵌入 RSA 公钥(用于 selfhosted 验签)
|
||||
let pubkey_path = PathBuf::from(&manifest_dir).join("embedded").join("pubkey.pem");
|
||||
if let Ok(pubkey) = fs::read_to_string(&pubkey_path) {
|
||||
let trimmed = pubkey.trim();
|
||||
if !trimmed.is_empty() {
|
||||
println!("cargo:rustc-env=CRAFTLABS_SELFHOSTED_PUBKEY={}", trimmed);
|
||||
}
|
||||
}
|
||||
println!("cargo:rerun-if-changed=embedded/pubkey.pem");
|
||||
}
|
||||
|
||||
fn hash_dir(dir: &PathBuf, hasher: &mut Sha256) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# Placeholder — replace with production RSA public key (PEM format)
|
||||
Reference in New Issue
Block a user