From 7633f14db196f3ab4d334d99f04d0f0c2ca0b991 Mon Sep 17 00:00:00 2001 From: Timur Gordon <31495328+timurgordon@users.noreply.github.com> Date: Fri, 31 Oct 2025 02:29:39 +0100 Subject: [PATCH] Update OSIRIS engine with signatory access control and Freezone examples --- examples/freezone/freezone copy 2.rhai | 360 ++++++++++++++++++++++++ examples/freezone/freezone copy.rhai | 370 +++++++++++++++++++++++++ examples/freezone/freezone.rhai | 205 ++++++++++---- src/engine.rs | 4 + src/objects/communication/email.rs | 175 +++++++++++- src/objects/communication/rhai.rs | 235 +++++++++++++++- src/objects/kyc/rhai.rs | 52 +++- 7 files changed, 1341 insertions(+), 60 deletions(-) create mode 100644 examples/freezone/freezone copy 2.rhai create mode 100644 examples/freezone/freezone copy.rhai diff --git a/examples/freezone/freezone copy 2.rhai b/examples/freezone/freezone copy 2.rhai new file mode 100644 index 0000000..f0ccf0e --- /dev/null +++ b/examples/freezone/freezone copy 2.rhai @@ -0,0 +1,360 @@ + + + + + + + + + + + +flow = registration_flow(); + +public_key_registration_step = step.new() + .title("Public Key Registration") + .description("Register your public key") + .add_action("Register"); + + +public_key_registration_step.complete() + +public_key = +print("Public key <>registered."); +print("Now user needs to submit email"); + + + + + + +public_key_registration_step.continue() + + + + + + +user_profile_creation_step = user_profile_creation(); +flow.add_step(user_profile_creation_step); + +step = email_verification(); +flow.add_step(step); + +step = terms_and_conditions(); +flow.add_step(step); + +step = crypto_wallet_creation(); +flow.add_step(payment_processing()); +flow.add_step(kyc_verification()); + +flow.execute(); + +print("Step 1: Public Key Registration"); +print("─────────────────────────────────────────────────────────────"); + +// User (Timur) provides their public key +print("User public key received: " + timur_pubkey); +print("✓ Public key validated and stored\n"); + +// ============================================================================ +// STEP 2: User Profile Creation & Email Verification +// ============================================================================ + +print("Step 2: User Profile Creation & Email Verification"); +print("─────────────────────────────────────────────────────────────"); + +// Collect basic user information +let user_name = "Timur Gordon"; +let user_email = "timur@freezone.example"; +print("Collecting user information:"); +print(" Name: " + user_name); +print(" Email: " + user_email); + +// Create user profile +let user_profile = new_user() + .username(user_name) + .pubkey(timur_pubkey) + .add_email(user_email); + +print("✓ User profile created"); +freezone_ctx.save(user_profile); +print("✓ Profile saved"); + +// Email Verification +print("\nInitiating email verification..."); +let verification = new_verification("user_1", user_email); + +print("✓ Email verification created"); +print(" Verification code: " + verification.get_code()); +print(" Nonce: " + verification.get_nonce()); + +// Prepare verification email +let verification_link = "https://freezone.example/verify?nonce=" + verification.get_nonce(); + +// Create verification mail with template parameters +let verification_mail = new_mail() + .to(user_email) + .template(verification_mail_template.get_id()) + .parameter("url", verification_link) + .parameter("code", verification.get_code()); + +print("✓ Verification email prepared"); +print(" To: " + user_email); +print(" Template: " + verification_mail_template.get_id()); +print(" Link: " + verification_link); +print(" Code: " + verification.get_code()); + +// Send verification email using template +// Note: In production, configure real SMTP credentials +// For now, we'll simulate sending (actual SMTP would fail with example.com) +print("✓ Verification email would be sent to: " + user_email); +print(" (Skipping actual SMTP send - configure real server in production)"); + +// Simulate user clicking verification link and verifying +print("\n✓ User clicks verification link and verifies email"); +verification.verify_nonce(verification.get_nonce()); +print("✓ Email verified: " + verification.get_status()); + +freezone_ctx.save(verification); +print("✓ Verification saved\n"); + +// ============================================================================ +// STEP 3: Terms & Conditions Signing +// ============================================================================ + +print("Step 3: Terms & Conditions Signing"); +print("─────────────────────────────────────────────────────────────"); + +// Create Terms & Conditions contract +let terms_contract = new_contract(1) + .title("Freezone Membership Terms & Conditions") + .content("By signing this agreement, you agree to abide by all freezone rules and regulations...") + .creator_id(999); // Freezone admin + +print("✓ Terms & Conditions contract created"); +print(" Title: " + terms_contract.title()); + +// User signs the contract (add their signature ID) +let user_signature_id = 1001; +terms_contract = terms_contract.add_signature(user_signature_id); +print("✓ User signature added (ID: " + user_signature_id + ")"); + +// Activate contract once signed +if terms_contract.is_fully_signed(1) { + terms_contract = terms_contract.activate(); + print("✓ Contract activated: " + terms_contract.status()); +} + +freezone_ctx.save(terms_contract); +print("✓ Signed contract saved\n"); + +// ============================================================================ +// STEP 4: Crypto Wallet Creation +// ============================================================================ + +print("Step 4: Crypto Wallet Creation"); +print("─────────────────────────────────────────────────────────────"); + +// Create TFT crypto account for user +let tft_account = new_account() + .owner_id(1) + .currency("TFT") // ThreeFold Token + .balance(0.0); + +print("✓ TFT account created"); +print(" Owner ID: 1"); +print(" Currency: TFT"); +print(" Initial balance: 0"); + +freezone_ctx.save(tft_account); + +// Create Ethereum wallet for user +print("\nCreating Ethereum wallet..."); +let eth_wallet = new_ethereum_wallet() + .owner_id(1) + .network("mainnet"); + +print("✓ Ethereum wallet created"); +print(" Address: " + eth_wallet.get_address()); +print(" Network: mainnet"); +print(" Balance: 0 ETH"); + +// Save as account +let eth_account = new_account() + .owner_id(1) + .address(eth_wallet.get_address()) + .currency("ETH") + .balance(0.0); + +freezone_ctx.save(eth_account); +print("✓ Ethereum account saved\n"); + +// ============================================================================ +// STEP 5: Payment Processing +// ============================================================================ + +print("Step 5: Payment Processing"); +print("─────────────────────────────────────────────────────────────"); + +print("Using configured Pesapal payment client..."); + +// Create payment request for registration fee +print("\nCreating payment session..."); +let payment_request = new_payment_request() + .amount(100.0) + .currency("USD") + .description("Freezone Registration Fee") + .callback_url("https://freezone.example/payment/callback") + .merchant_reference("REG_USER_1_" + timestamp()); + +print("✓ Payment request created"); +print(" Amount: $100 USD"); +print(" Description: Freezone Registration Fee"); + +// Initiate payment with Pesapal - creates real payment link +print("\nInitiating payment session with Pesapal..."); +let payment_response = freezone_payment_client.create_payment_link(payment_request); + +let payment_url = payment_response.get_payment_url(); +let order_tracking_id = payment_response.get_order_tracking_id(); + +print("✓ Payment session created"); +print(" Payment URL: " + payment_url); +print(" Order Tracking ID: " + order_tracking_id); +print(" (User would be redirected to Pesapal payment page)"); + +// In production, you would: +// 1. Redirect user to payment_url +// 2. User completes payment on Pesapal +// 3. Pesapal calls your callback_url +// 4. You verify payment status with get_payment_status(order_tracking_id) + +// For demo purposes, check payment status +print("\nChecking payment status..."); +let payment_status = freezone_payment_client.get_payment_status(order_tracking_id); + +print("✓ Payment status retrieved"); +print(" Status: " + payment_status.get_payment_status_description()); +print(" Amount: " + payment_status.get_amount() + " " + payment_status.get_currency()); +print(" Transaction ID: " + order_tracking_id); + +// Create payment transaction record +let payment_tx = new_transaction() + .source(0) // External payment + .destination(1) // Freezone account + .amount(100.0) + .assetid(1); + +print("✓ Payment transaction recorded"); + +freezone_ctx.save(payment_tx); +print("✓ Transaction saved\n"); + +// ============================================================================ +// STEP 6: KYC Verification +// ============================================================================ + +print("Step 6: KYC Verification"); +print("─────────────────────────────────────────────────────────────"); + +// Pre-fill KYC form with already collected info (first name, last name) +// User will fill in the rest at Idenfy (DOB, address, nationality, etc.) +print("\nPreparing KYC session with pre-filled data..."); +let kyc_info = new_kyc_info() + .client_id("user_1") + .first_name("Timur") // From user profile + .last_name("Gordon") // From user profile + .email(user_email); // From user profile + +print("✓ Pre-fill data prepared"); +print(" Name: Timur Gordon (pre-filled)"); +print(" Email: " + user_email + " (pre-filled)"); +print(" User will provide: DOB, address, nationality, ID document"); + +// Create KYC session +let kyc_session = new_kyc_session("user_1", "idenfy") + .callback_url("https://freezone.example/kyc/callback") + .success_url("https://freezone.example/kyc/success") + .error_url("https://freezone.example/kyc/error") + .locale("en"); + +print("✓ KYC session created"); +print(" Client ID: " + kyc_session.get_client_id()); +print(" Provider: " + kyc_session.get_provider()); + +// Create verification session with Idenfy - generates real verification URL +print("\nCreating Idenfy verification session..."); +let verification_url = freezone_kyc_client.create_verification_session(kyc_info, kyc_session); + +print("✓ Idenfy verification session created"); +print(" Verification URL: " + verification_url); +print(" (User redirected to Idenfy to complete verification)"); + +// Production flow: +// 1. Redirect user to verification_url +// 2. User fills in remaining info (DOB, address, nationality) +// 3. User uploads ID document (Passport/ID/Driver's License) +// 4. User takes selfie for liveness check +// 5. Idenfy performs automated verification +// 6. Idenfy calls callback_url with VERIFIED data from ID document +// 7. Callback handler stores verified KYC info + +print("\n✓ User completes verification at Idenfy:"); +print(" - Fills in DOB, address, nationality"); +print(" - Uploads identity document"); +print(" - Takes selfie for liveness check"); +print(" - Idenfy extracts and verifies data from ID"); + +print("\n✓ Idenfy callback will provide VERIFIED data:"); +print(" - All personal info extracted from ID document"); +print(" - Document number, issue date, expiry date"); +print(" - Verification status (APPROVED/DENIED)"); +print(" - Liveness check result"); + +// For demo purposes, simulate what callback would receive +print("\nSimulating callback data (in production, this comes from Idenfy)..."); +let kyc_info_verified = new_kyc_info() + .client_id("user_1") + .first_name("Timur") // Verified from ID + .last_name("Gordon") // Verified from ID + .email(user_email) + .date_of_birth("1990-05-15") // Extracted from ID + .nationality("US") // Extracted from ID + .document_type("passport") // From verification + .document_number("P123456789") // Extracted from ID + .provider("idenfy") + .verified(true); // Only if status == "APPROVED" + +freezone_ctx.save(kyc_info_verified); +freezone_ctx.save(kyc_session); +print("✓ KYC verification data saved"); +print("✓ KYC verification completed\n"); + +// ============================================================================ +// SUMMARY +// ============================================================================ + +print("═══════════════════════════════════════════════════════════════"); +print("REGISTRATION COMPLETE"); +print("═══════════════════════════════════════════════════════════════"); +print("\nUser Summary:"); +print(" Name: " + user_name); +print(" Email: " + user_email); +print(" Public Key: " + timur_pubkey); +print(" TFT Account: Created"); +print(" ETH Account: Created"); +print(" KYC Status: Verified"); +print(" Payment Status: Completed ($100 USD)"); +print(" Contract: Signed and Active"); +print("\nRegistration Flow:"); +print(" ✓ Freezone initialization (Email, Payment, KYC providers configured)"); +print(" ✓ Freezone Ethereum wallet created"); +print(" ✓ Public key registration"); +print(" ✓ User profile creation & email verification"); +print(" ✓ Terms & Conditions signed"); +print(" ✓ Crypto wallets created (TFT + ETH)"); +print(" ✓ Payment processed ($100 USD)"); +print(" ✓ KYC verification completed with verified info"); +print("\n" + user_name + " is now a verified Freezone member!"); +print("═══════════════════════════════════════════════════════════════\n"); diff --git a/examples/freezone/freezone copy.rhai b/examples/freezone/freezone copy.rhai new file mode 100644 index 0000000..ef8e354 --- /dev/null +++ b/examples/freezone/freezone copy.rhai @@ -0,0 +1,370 @@ +registration_flow = flow.new(); + +public_key_registration_step = step.new() + .title("Public Key Registration") + .description("Register your public key") + .add_action("Register"); + +flow_id = registration_flow.start() + + + + + + + + + + + + + + + + + + + + + +public_key_registration_step.complete() + +public_key = +print("Public key <>registered."); +print("Now user needs to submit email"); + + + + + + +public_key_registration_step.continue() + + + + + + +user_profile_creation_step = user_profile_creation(); +flow.add_step(user_profile_creation_step); + +step = email_verification(); +flow.add_step(step); + +step = terms_and_conditions(); +flow.add_step(step); + +step = crypto_wallet_creation(); +flow.add_step(payment_processing()); +flow.add_step(kyc_verification()); + +flow.execute(); + +print("Step 1: Public Key Registration"); +print("─────────────────────────────────────────────────────────────"); + +// User (Timur) provides their public key +print("User public key received: " + timur_pubkey); +print("✓ Public key validated and stored\n"); + +// ============================================================================ +// STEP 2: User Profile Creation & Email Verification +// ============================================================================ + +print("Step 2: User Profile Creation & Email Verification"); +print("─────────────────────────────────────────────────────────────"); + +// Collect basic user information +let user_name = "Timur Gordon"; +let user_email = "timur@freezone.example"; +print("Collecting user information:"); +print(" Name: " + user_name); +print(" Email: " + user_email); + +// Create user profile +let user_profile = new_user() + .username(user_name) + .pubkey(timur_pubkey) + .add_email(user_email); + +print("✓ User profile created"); +freezone_ctx.save(user_profile); +print("✓ Profile saved"); + +// Email Verification +print("\nInitiating email verification..."); +let verification = new_verification("user_1", user_email); + +print("✓ Email verification created"); +print(" Verification code: " + verification.get_code()); +print(" Nonce: " + verification.get_nonce()); + +// Prepare verification email +let verification_link = "https://freezone.example/verify?nonce=" + verification.get_nonce(); + +// Create verification mail with template parameters +let verification_mail = new_mail() + .to(user_email) + .template(verification_mail_template.get_id()) + .parameter("url", verification_link) + .parameter("code", verification.get_code()); + +print("✓ Verification email prepared"); +print(" To: " + user_email); +print(" Template: " + verification_mail_template.get_id()); +print(" Link: " + verification_link); +print(" Code: " + verification.get_code()); + +// Send verification email using template +// Note: In production, configure real SMTP credentials +// For now, we'll simulate sending (actual SMTP would fail with example.com) +print("✓ Verification email would be sent to: " + user_email); +print(" (Skipping actual SMTP send - configure real server in production)"); + +// Simulate user clicking verification link and verifying +print("\n✓ User clicks verification link and verifies email"); +verification.verify_nonce(verification.get_nonce()); +print("✓ Email verified: " + verification.get_status()); + +freezone_ctx.save(verification); +print("✓ Verification saved\n"); + +// ============================================================================ +// STEP 3: Terms & Conditions Signing +// ============================================================================ + +print("Step 3: Terms & Conditions Signing"); +print("─────────────────────────────────────────────────────────────"); + +// Create Terms & Conditions contract +let terms_contract = new_contract(1) + .title("Freezone Membership Terms & Conditions") + .content("By signing this agreement, you agree to abide by all freezone rules and regulations...") + .creator_id(999); // Freezone admin + +print("✓ Terms & Conditions contract created"); +print(" Title: " + terms_contract.title()); + +// User signs the contract (add their signature ID) +let user_signature_id = 1001; +terms_contract = terms_contract.add_signature(user_signature_id); +print("✓ User signature added (ID: " + user_signature_id + ")"); + +// Activate contract once signed +if terms_contract.is_fully_signed(1) { + terms_contract = terms_contract.activate(); + print("✓ Contract activated: " + terms_contract.status()); +} + +freezone_ctx.save(terms_contract); +print("✓ Signed contract saved\n"); + +// ============================================================================ +// STEP 4: Crypto Wallet Creation +// ============================================================================ + +print("Step 4: Crypto Wallet Creation"); +print("─────────────────────────────────────────────────────────────"); + +// Create TFT crypto account for user +let tft_account = new_account() + .owner_id(1) + .currency("TFT") // ThreeFold Token + .balance(0.0); + +print("✓ TFT account created"); +print(" Owner ID: 1"); +print(" Currency: TFT"); +print(" Initial balance: 0"); + +freezone_ctx.save(tft_account); + +// Create Ethereum wallet for user +print("\nCreating Ethereum wallet..."); +let eth_wallet = new_ethereum_wallet() + .owner_id(1) + .network("mainnet"); + +print("✓ Ethereum wallet created"); +print(" Address: " + eth_wallet.get_address()); +print(" Network: mainnet"); +print(" Balance: 0 ETH"); + +// Save as account +let eth_account = new_account() + .owner_id(1) + .address(eth_wallet.get_address()) + .currency("ETH") + .balance(0.0); + +freezone_ctx.save(eth_account); +print("✓ Ethereum account saved\n"); + +// ============================================================================ +// STEP 5: Payment Processing +// ============================================================================ + +print("Step 5: Payment Processing"); +print("─────────────────────────────────────────────────────────────"); + +print("Using configured Pesapal payment client..."); + +// Create payment request for registration fee +print("\nCreating payment session..."); +let payment_request = new_payment_request() + .amount(100.0) + .currency("USD") + .description("Freezone Registration Fee") + .callback_url("https://freezone.example/payment/callback") + .merchant_reference("REG_USER_1_" + timestamp()); + +print("✓ Payment request created"); +print(" Amount: $100 USD"); +print(" Description: Freezone Registration Fee"); + +// Initiate payment with Pesapal - creates real payment link +print("\nInitiating payment session with Pesapal..."); +let payment_response = freezone_payment_client.create_payment_link(payment_request); + +let payment_url = payment_response.get_payment_url(); +let order_tracking_id = payment_response.get_order_tracking_id(); + +print("✓ Payment session created"); +print(" Payment URL: " + payment_url); +print(" Order Tracking ID: " + order_tracking_id); +print(" (User would be redirected to Pesapal payment page)"); + +// In production, you would: +// 1. Redirect user to payment_url +// 2. User completes payment on Pesapal +// 3. Pesapal calls your callback_url +// 4. You verify payment status with get_payment_status(order_tracking_id) + +// For demo purposes, check payment status +print("\nChecking payment status..."); +let payment_status = freezone_payment_client.get_payment_status(order_tracking_id); + +print("✓ Payment status retrieved"); +print(" Status: " + payment_status.get_payment_status_description()); +print(" Amount: " + payment_status.get_amount() + " " + payment_status.get_currency()); +print(" Transaction ID: " + order_tracking_id); + +// Create payment transaction record +let payment_tx = new_transaction() + .source(0) // External payment + .destination(1) // Freezone account + .amount(100.0) + .assetid(1); + +print("✓ Payment transaction recorded"); + +freezone_ctx.save(payment_tx); +print("✓ Transaction saved\n"); + +// ============================================================================ +// STEP 6: KYC Verification +// ============================================================================ + +print("Step 6: KYC Verification"); +print("─────────────────────────────────────────────────────────────"); + +// Pre-fill KYC form with already collected info (first name, last name) +// User will fill in the rest at Idenfy (DOB, address, nationality, etc.) +print("\nPreparing KYC session with pre-filled data..."); +let kyc_info = new_kyc_info() + .client_id("user_1") + .first_name("Timur") // From user profile + .last_name("Gordon") // From user profile + .email(user_email); // From user profile + +print("✓ Pre-fill data prepared"); +print(" Name: Timur Gordon (pre-filled)"); +print(" Email: " + user_email + " (pre-filled)"); +print(" User will provide: DOB, address, nationality, ID document"); + +// Create KYC session +let kyc_session = new_kyc_session("user_1", "idenfy") + .callback_url("https://freezone.example/kyc/callback") + .success_url("https://freezone.example/kyc/success") + .error_url("https://freezone.example/kyc/error") + .locale("en"); + +print("✓ KYC session created"); +print(" Client ID: " + kyc_session.get_client_id()); +print(" Provider: " + kyc_session.get_provider()); + +// Create verification session with Idenfy - generates real verification URL +print("\nCreating Idenfy verification session..."); +let verification_url = freezone_kyc_client.create_verification_session(kyc_info, kyc_session); + +print("✓ Idenfy verification session created"); +print(" Verification URL: " + verification_url); +print(" (User redirected to Idenfy to complete verification)"); + +// Production flow: +// 1. Redirect user to verification_url +// 2. User fills in remaining info (DOB, address, nationality) +// 3. User uploads ID document (Passport/ID/Driver's License) +// 4. User takes selfie for liveness check +// 5. Idenfy performs automated verification +// 6. Idenfy calls callback_url with VERIFIED data from ID document +// 7. Callback handler stores verified KYC info + +print("\n✓ User completes verification at Idenfy:"); +print(" - Fills in DOB, address, nationality"); +print(" - Uploads identity document"); +print(" - Takes selfie for liveness check"); +print(" - Idenfy extracts and verifies data from ID"); + +print("\n✓ Idenfy callback will provide VERIFIED data:"); +print(" - All personal info extracted from ID document"); +print(" - Document number, issue date, expiry date"); +print(" - Verification status (APPROVED/DENIED)"); +print(" - Liveness check result"); + +// For demo purposes, simulate what callback would receive +print("\nSimulating callback data (in production, this comes from Idenfy)..."); +let kyc_info_verified = new_kyc_info() + .client_id("user_1") + .first_name("Timur") // Verified from ID + .last_name("Gordon") // Verified from ID + .email(user_email) + .date_of_birth("1990-05-15") // Extracted from ID + .nationality("US") // Extracted from ID + .document_type("passport") // From verification + .document_number("P123456789") // Extracted from ID + .provider("idenfy") + .verified(true); // Only if status == "APPROVED" + +freezone_ctx.save(kyc_info_verified); +freezone_ctx.save(kyc_session); +print("✓ KYC verification data saved"); +print("✓ KYC verification completed\n"); + +// ============================================================================ +// SUMMARY +// ============================================================================ + +print("═══════════════════════════════════════════════════════════════"); +print("REGISTRATION COMPLETE"); +print("═══════════════════════════════════════════════════════════════"); +print("\nUser Summary:"); +print(" Name: " + user_name); +print(" Email: " + user_email); +print(" Public Key: " + timur_pubkey); +print(" TFT Account: Created"); +print(" ETH Account: Created"); +print(" KYC Status: Verified"); +print(" Payment Status: Completed ($100 USD)"); +print(" Contract: Signed and Active"); +print("\nRegistration Flow:"); +print(" ✓ Freezone initialization (Email, Payment, KYC providers configured)"); +print(" ✓ Freezone Ethereum wallet created"); +print(" ✓ Public key registration"); +print(" ✓ User profile creation & email verification"); +print(" ✓ Terms & Conditions signed"); +print(" ✓ Crypto wallets created (TFT + ETH)"); +print(" ✓ Payment processed ($100 USD)"); +print(" ✓ KYC verification completed with verified info"); +print("\n" + user_name + " is now a verified Freezone member!"); +print("═══════════════════════════════════════════════════════════════\n"); diff --git a/examples/freezone/freezone.rhai b/examples/freezone/freezone.rhai index 799b9f4..da5a802 100644 --- a/examples/freezone/freezone.rhai +++ b/examples/freezone/freezone.rhai @@ -15,11 +15,7 @@ print("=== FREEZONE REGISTRATION FLOW ===\n"); // ============================================================================ // KEYPAIRS AND IDENTITIES // ============================================================================ - -// Freezone Organization (Keypair 1) -let freezone_pubkey = "04d0aea7f0a48bcab4389753ddc2e61623dd89d800652b11d0a383eb3ea74561d730bdd06e0ca8f4cd4013907d95782a0a584313e1d91ae5ad09b663de36bfac44"; - -// User: Timur (Keypair 2) +let freezone_pubkey = "04e58314c13ea3f9caed882001a5090797b12563d5f9bbd7f16efe020e060c780b446862311501e2e9653416527d2634ff8a8050ff3a085baccd7ddcb94185ff56"; let timur_pubkey = "04090636d0a15854c4c0b73f65b6de5f6a27a7b22d6fbf5f6d97c45476a0384fe50781444c33f5af577e017599e4b432373fbcdcd844d8783c5e52240a14b63dc3"; print("Identities:"); @@ -40,35 +36,77 @@ print("✓ Freezone context created"); print(" Context ID: " + freezone_ctx.context_id()); print(" Signatory: Freezone (" + freezone_pubkey + ")"); -// Configure Email Client -print("\nConfiguring Email Client..."); +// Configure email client for sending verification emails +// Common SMTP providers: +// - Gmail: smtp.gmail.com:587 (requires app password) +// - Outlook: smtp-mail.outlook.com:587 +// - SendGrid: smtp.sendgrid.net:587 +// - Mailgun: smtp.mailgun.org:587 +// - AWS SES: email-smtp.us-east-1.amazonaws.com:587 + let freezone_email_client = new_email_client() - .smtp_host("smtp.freezone.example") - .smtp_port(587) - .from_email("noreply@freezone.example") - .from_name("Freezone Platform"); + .smtp_host("smtp-relay.brevo.com") // Change to your SMTP server + .smtp_port(587) // 587 for TLS, 465 for SSL + .username("timur@incubaid.com") // Your SMTP username/email + .password("xsmtpsib-a470d3fffa3f3b0f66800fe065f339067a07066d6a7df405fa465759418285ee-ojLWpd4oIShqIr6X") // Your SMTP password or app password + .from_email("registrar@ourworldfreezone.com") // From address + .from_name("Zanzibar Digital Free Zone") + .use_tls(true); print("✓ Email client configured"); -print(" SMTP Host: smtp.freezone.example"); +freezone_ctx.save(freezone_email_client); + +// Create verification email template +let verification_mail_template = new_mail_template() + .id("verification_email") + .name("Email Verification Template") + .subject("Verify your email address - Freezone") + .body("Hello,\n\nPlease verify your email address by clicking the link below:\n\n${url}\n\nOr use this verification code: ${code}\n\nThis link will expire in 24 hours.\n\nIf you didn't request this, please ignore this email.\n\nBest regards,\nFreezone Team") + .html_body("
Hello,
Please verify your email address by clicking the button below:
Verify EmailOr enter this verification code:
This link will expire in 24 hours.
If you didn't request this, please ignore this email.
Best regards,
Freezone Team