|
Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
|
In-process dynamic-app request handler for the Pharos native runtime. More...
#include "native_dynamic_runtime.h"#include "native_dynamic_dispatch.h"#include "native_dynamic_media.h"#include "native_dynamic_multipart.h"#include "native_dynamic_request_fields.h"#include "native_dynamic_relational.h"#include "native_dynamic_template.h"#include "native_yyjson_helpers.h"#include "native_fs.h"#include "native_http_response.h"#include "native_support.h"#include <stdlib.h>#include <string.h>#include <strings.h>#include <stdio.h>#include <stdint.h>#include <time.h>#include <stdarg.h>#include <fcntl.h>#include <unistd.h>Go to the source code of this file.
Data Structures | |
| struct | GeneratedAdminSurfaceDescriptor |
| struct | ResourceLinkDisplay |
| struct | Sha256Runtime |
Macros | |
| #define | DYNAMIC_HOST_PROFILE "dynamic-app" |
| Host profile string that triggers in-process dynamic handling. | |
| #define | MAX_QUERY_LEN 4096 |
| Maximum query string length we process. | |
| #define | CSRF_COOKIE_NAME "pharos_csrf" |
| CSRF cookie name used by the Pharos framework. | |
| #define | SESSION_COOKIE_NAME "pharos_session" |
| Session cookie name used by the Pharos framework. | |
| #define | CSRF_TOKEN_HEX_LEN 48 |
| Maximum CSRF token length (24 bytes = 48 hex chars). | |
| #define | CSRF_COOKIE_MAX_AGE "7200" |
| CSRF cookie max-age in seconds. | |
| #define | SHA256_BLOCK_SIZE 64 |
| #define | SHA256_DIGEST_SIZE 32 |
Functions | |
| static yyjson_val * | state_array_runtime_local (yyjson_val *root, const char *field_name) |
| static yyjson_val * | find_business_by_slug_runtime_local (yyjson_val *root, const char *business_slug) |
| static yyjson_val * | find_business_by_id_runtime_local (yyjson_val *root, long business_id) |
| Finds one business record by numeric id in the runtime state. | |
| static yyjson_val * | find_user_by_id_runtime_local (yyjson_val *root, long user_id) |
| static int | long_from_value_runtime_local (yyjson_val *value, long *out_value) |
| static yyjson_val * | find_service_for_business_runtime_local (yyjson_val *root, long service_id, long business_id) |
| static yyjson_val * | find_appointment_by_id_runtime_local (yyjson_val *root, long appointment_id) |
| static char * | page_title_dup_runtime (yyjson_val *page_spec_root, yyjson_val *body_params_root) |
| static char * | generated_surface_fixture_path_dup_runtime (const AppRuntime *app) |
| Resolves the generated-surface fixture path for the active app. | |
| static char * | request_path_dup_runtime (const HttpRequest *request) |
| static char * | generated_admin_manage_page_params_json_dup_runtime (const char *state_path, const char *business_slug, const char *surface_kind, const char *error_text) |
| static char * | business_availability_edit_page_params_json_dup_runtime (const char *state_path, const char *business_slug, long availability_id, const char *error_text) |
| static char * | profile_page_params_json_dup_runtime_local (const char *state_path, long user_id, const char *payment_preference_options_html) |
| Builds profile-page template params directly from runtime state. | |
| static yyjson_val * | proof_state_root_load_runtime (const char *state_path, yyjson_doc **doc_out) |
| static char * | proof_home_page_params_json_dup_runtime (const char *state_path) |
| static int | write_proof_state_api_response (NativeConnection *connection, const char *state_path) |
| static int | text_append_format_runtime_local (char **buffer, size_t *length, size_t *capacity, const char *format,...) |
| static char * | register_page_params_json_dup_runtime (const char *query_string) |
| static const GeneratedAdminSurfaceDescriptor * | generated_admin_surface_descriptor_runtime (const char *surface_kind) |
| Returns the generated-admin descriptor for one declared manage surface. | |
| static int | append_generated_admin_surface_rows_runtime (const GeneratedAdminSurfaceDescriptor *descriptor, yyjson_val *root, long business_id, const char *business_slug, char **row_html, size_t *row_html_length, size_t *row_html_capacity) |
| Appends row HTML for one generated-admin manage surface. | |
| static int | append_generated_admin_surface_form_fields_runtime (const GeneratedAdminSurfaceDescriptor *descriptor, char **form_fields_html, size_t *form_fields_length, size_t *form_fields_capacity, const char *day_options_html) |
| Appends create-form field HTML for one generated-admin surface. | |
| static char * | generated_admin_surface_filter_controls_dup_runtime (const GeneratedAdminSurfaceDescriptor *descriptor) |
| Duplicates the filter-control HTML for one generated-admin surface. | |
| static void | generated_admin_surface_page_copy_runtime (yyjson_mut_doc *doc, yyjson_mut_val *page, const GeneratedAdminSurfaceDescriptor *descriptor, const char *filter_controls_html) |
| Writes descriptor-owned page copy into one generated-admin params document. | |
| static char * | password_reset_request_page_params_json_dup_runtime (void) |
| static char * | password_reset_sent_page_params_json_dup_runtime (const char *preview_path) |
| static char * | password_reset_complete_page_params_json_dup_runtime (const char *request_path) |
| Builds native template params for the password-reset completion page. | |
| static char * | invite_created_page_params_json_dup_runtime (const char *invite_email, const char *invite_path, const char *return_path) |
| Builds template params for the invite-created confirmation page. | |
| static char * | invite_accept_page_params_json_dup_runtime (const char *invite_kind, const char *target_business_name, const char *error_message, const char *invite_email, const char *form_action) |
| Builds template params for the invite-accept page. | |
| static char * | invite_accept_done_page_params_json_dup_runtime (const char *continue_path) |
| Builds template params for the invite-accepted confirmation page. | |
| static char * | service_edit_page_params_json_dup_runtime (const char *state_path, const char *business_slug, long service_id) |
| char * | business_landing_render_page_params_json_dup_runtime (const char *state_path, const char *business_slug, long user_id, const char *app_root) |
| char * | business_calendar_render_page_params_json_dup_runtime (const char *state_path, const char *business_slug, const char *app_root, const char *selected_year_text, const char *selected_month_text, const char *selected_date_text) |
| char * | diagnostics_render_page_params_json_dup_runtime (const char *state_path) |
| static unsigned char * | request_body_bytes_dup_runtime (const HttpRequest *request, size_t *out_size) |
| static int | resource_link_display_load_runtime (yyjson_val *root, const char *resource_collection_name, long resource_id, ResourceLinkDisplay *display) |
| Loads slug and display-name fields for one linked resource id. | |
| static void | resource_link_display_free_runtime (ResourceLinkDisplay *display) |
| Frees a linked-resource display record. | |
| static int | append_profile_subscription_rows_runtime (yyjson_val *root, long user_id, char **subscriptions_block, size_t *subscriptions_length, size_t *subscriptions_capacity) |
| Appends profile subscription rows for one user into an HTML list buffer. | |
| static char * | profile_subscriptions_block_dup_runtime (yyjson_val *root, long user_id) |
| Builds the profile subscription block for one user. | |
| static int | runtime_page_params_add_string_runtime (yyjson_mut_doc *doc, yyjson_mut_val *root, const char *key, const char *value) |
| Builds native template params for the password-reset request page. | |
| static int | runtime_page_params_add_escaped_string_runtime (yyjson_mut_doc *doc, yyjson_mut_val *root, const char *key, const char *value) |
| Adds one HTML-escaped string field to a page-params JSON object. | |
| static char * | runtime_page_params_write_runtime (yyjson_mut_doc *doc, yyjson_mut_val *root) |
| Finalizes and writes one page-params document as compact JSON. | |
| static char * | password_reset_preview_html_dup_runtime (const char *preview_path) |
| Builds the optional password-reset preview HTML block. | |
| static char * | invite_accept_target_html_dup_runtime (const char *target_business_name) |
| Builds the optional invite target HTML fragment. | |
| static char * | request_form_value_dup_runtime (const HttpRequest *request, const char *field_name) |
| static char * | password_hash_dup_runtime (const char *password_value) |
| static char * | resolve_declared_page_params_json_runtime (const AppRuntime *app, const HttpRequest *request, const NativeDynamicRouteMatch *match, const char *request_path, const char *query_string, long active_user_id) |
| Resolves declared page parameter JSON for the matched page route. | |
| static char * | resolve_invite_accept_page_params_json_runtime (const AppRuntime *app, const NativeDynamicRouteMatch *match, const char *request_path) |
| Resolves invite-accept page parameters from the current app state. | |
| static int | handle_password_reset_request_action_runtime (NativeConnection *connection, const AppRuntime *app, const HttpRequest *request) |
| Handles password-reset request action processing. | |
| static int | handle_password_reset_complete_action_runtime (NativeConnection *connection, const AppRuntime *app, const HttpRequest *request, const NativeDynamicRouteMatch *match) |
| Handles password-reset completion action processing. | |
| static int | handle_issue_business_invite_action_runtime (NativeConnection *connection, const AppRuntime *app, const HttpRequest *request, const NativeDynamicRouteMatch *match) |
| Handles invite creation for tenant-backed business membership flows. | |
| static int | handle_accept_invite_action_runtime (NativeConnection *connection, const AppRuntime *app, const HttpRequest *request, const NativeDynamicRouteMatch *match) |
| Handles invite acceptance and initial session creation. | |
| static long | state_tenant_id_for_business_runtime_local (yyjson_val *root, long business_id) |
| Resolves the tenant id that owns a business record. | |
| static int | user_has_active_tenant_membership_runtime_local (yyjson_val *root, long user_id, long tenant_id) |
| Checks whether a user has an active membership on a tenant. | |
| static const char * | membership_role_id_for_invite_runtime_local (const char *role_hint, const char *account_type) |
| Maps invite role hints onto the canonical tenant membership role id. | |
| static int | persist_app_state_text_runtime_local (const AppRuntime *app, const char *state_json_text) |
| Appends a native auth/rate-limit event row to runtime state. | |
| static int | append_rate_limit_event_runtime_local (const AppRuntime *app, const char *policy_key, const char *bucket_key, const char *outcome) |
| static int | render_declared_page_response_runtime (NativeConnection *connection, const AppRuntime *app, const HttpRequest *request, const char *page_id, const char *request_path, const char *body_params_json) |
| static void | write_json_error (NativeConnection *connection, int status, const char *status_text, const char *error_kind, const char *message) |
| Writes a JSON error response to a connection. | |
| static void | csrf_generate_random_hex (char *buf, size_t byte_count) |
| Generates a random hex token for CSRF protection. | |
| static char * | csrf_token_from_cookie (const char *cookie_header) |
| Extracts the CSRF token from the request cookie header. | |
| static char * | csrf_token_for_response (const char *cookie_header) |
| Returns the CSRF token to use for a response. | |
| static int | request_has_session_cookie (const char *cookie_header) |
| static char * | request_header_value_dup_runtime (const char *headers, const char *header_name) |
| static char * | csrf_request_token_dup_runtime (const HttpRequest *request, const char *form_body) |
| static int | csrf_request_valid_runtime (const HttpRequest *request, const char *form_body) |
| static char * | payment_preference_options_html_dup_runtime (const char *selected_value) |
| static char * | request_body_text_dup_runtime (const HttpRequest *request) |
| static char * | route_request_path_dup_runtime (const AppRuntime *app, const HttpRequest *request) |
| static char * | proof_state_seed_json_dup_runtime (void) |
| static char * | proof_task_items_html_dup_runtime (yyjson_val *items) |
| static int | text_append_runtime_local (char **buffer, size_t *length, size_t *capacity, const char *text) |
| static char * | day_of_week_options_html_dup_runtime (const char *selected_day) |
| static int | is_business_services_api_list_path_runtime (const char *request_path) |
| Tests whether a request path is the exact business services list API path. | |
| static int | is_business_availability_api_list_path_runtime (const char *request_path) |
| Tests whether a request path is the exact business availability list API path. | |
| static int | is_business_services_api_schema_path_runtime (const char *request_path) |
| Tests whether a request path is the exact business services schema API path. | |
| static int | is_business_availability_api_schema_path_runtime (const char *request_path) |
| Tests whether a request path is the exact business availability schema API path. | |
| static int | valid_day_of_week_runtime (const char *day_text) |
| Resolves the final page title from a declarative page spec and params. | |
| static int | time_text_to_minutes_runtime (const char *time_text, int *minutes_out) |
| static int | write_business_services_api_response (NativeConnection *connection, const char *state_path, const char *business_slug) |
| static int | write_business_availability_api_response (NativeConnection *connection, const char *state_path, const char *business_slug) |
| static int | write_generated_surface_schema_response (NativeConnection *connection, const AppRuntime *app, const char *state_path, const char *business_slug, const char *surface_id) |
| Writes one generated-surface schema object from the declarative fixture. | |
| static char * | login_page_params_json_dup_runtime (const char *query_string, const char *error_message) |
| static int | secure_text_equals (const char *left, const char *right) |
| static uint32_t | sha256_rotr (uint32_t value, uint32_t bits) |
| static void | sha256_transform_runtime (Sha256Runtime *ctx, const uint8_t data[]) |
| static void | sha256_init_runtime (Sha256Runtime *ctx) |
| static void | sha256_update_runtime (Sha256Runtime *ctx, const uint8_t *data, size_t len) |
| static void | sha256_final_runtime (Sha256Runtime *ctx, uint8_t hash[SHA256_DIGEST_SIZE]) |
| static void | bytes_to_hex_runtime (const uint8_t *bytes, size_t len, char *hex_out) |
| static void | hmac_sha256_runtime (const uint8_t *key, size_t key_len, const uint8_t *data, size_t data_len, uint8_t out[SHA256_DIGEST_SIZE]) |
| static int | pbkdf2_sha256_runtime (const uint8_t *password, size_t password_len, const uint8_t *salt, size_t salt_len, uint32_t iterations, uint8_t *out, size_t out_len) |
| static int | verify_password_hash_runtime (const char *stored_hash, const char *password_value, const char *username_value) |
| static char * | sha256_hex_dup_runtime (const char *value) |
| static char * | token_hash_dup_runtime (const char *token_value) |
| static int | now_iso_utc_runtime (char out[21]) |
| static int | iso_after_seconds_runtime (long delta_seconds, char out[21]) |
| static yyjson_val * | find_user_by_username_runtime_local (yyjson_val *root, const char *username) |
| static int | value_long_equals_runtime_local (yyjson_val *value, long expected_value) |
| static int | parse_ymd_runtime_local (const char *date_value, int *year_out, int *month_out, int *day_out) |
| static int | time_ranges_overlap_runtime_local (int start_a_minutes, int duration_a, int start_b_minutes, int duration_b) |
| static const char * | day_abbrev_for_ymd_runtime_local (int year, int month, int day) |
| static int | business_open_for_slot_runtime_local (yyjson_val *root, long business_id, const char *date_value, const char *time_value, long duration_minutes) |
| static int | technician_booked_for_slot_runtime_local (yyjson_val *root, long technician_id, const char *date_value, const char *time_value, long duration_minutes) |
| static long | assign_technician_for_slot_runtime_local (yyjson_val *root, long business_id, long service_id, const char *date_value, const char *time_value) |
| static long | next_array_id_runtime_local (yyjson_val *rows) |
| static long | active_user_id_from_cookie_runtime (const char *state_path, const char *cookie_header) |
| static char * | session_cookie_header_dup_runtime (const AppRuntime *app, const HttpRequest *request, const char *session_token, int clear_cookie) |
| static const char * | default_signed_in_path_runtime (yyjson_val *user) |
| static int | revoke_session_by_cookie_runtime (const AppRuntime *app, const char *cookie_header) |
| static int | issue_browser_session_runtime (const AppRuntime *app, const HttpRequest *request, long user_id, char **session_token_out, char **session_cookie_header_out) |
| static char * | csrf_inject_hidden_inputs (const char *html, const char *csrf_token) |
| Injects CSRF hidden inputs into form tags in an HTML string. | |
| static void | write_html_response_with_headers_runtime (NativeConnection *connection, int status, const char *status_text, const char *html, const char *csrf_token, const char *extra_headers) |
| Writes an HTML response to a connection, optionally with a CSRF cookie. | |
| static void | write_html_response (NativeConnection *connection, int status, const char *status_text, const char *html, const char *csrf_token) |
| static int | render_declared_page_response_with_headers_runtime (NativeConnection *connection, const AppRuntime *app, const HttpRequest *request, const char *page_id, const char *request_path, const char *body_params_json, const char *extra_headers) |
| static void | extract_query (const char *target, char *dest, size_t dest_size) |
| Extracts the query portion from a target string. | |
| static void | serve_dynamic_home_page (NativeConnection *connection, const char *app_id, const char *route_id, const char *csrf_token) |
| Serves the Pharos dynamic-app home page or a generic landing page. | |
| static int | handle_page_route (NativeConnection *connection, const AppRuntime *app, const HttpRequest *request, const NativeDynamicRouteMatch *match, const char *request_path, const char *query_string, const char *csrf_token) |
| Handles a matched page route using dynamic template rendering. | |
| static int | handle_action_route (NativeConnection *connection, const AppRuntime *app, const HttpRequest *request, const NativeDynamicRouteMatch *match) |
| Handles a matched action route. | |
| const char * | native_dynamic_runtime_host_profile (void) |
| Returns the canonical host profile string that this module handles. | |
| int | native_dynamic_runtime_handle_request (const AppRuntime *app, const HttpRequest *request, NativeConnection *connection) |
| Serves one dynamic-app request entirely in-process. | |
In-process dynamic-app request handler for the Pharos native runtime.
Replaces the former spawn_app_request() path for apps whose host_profile is "dynamic-app". Instead of forking a child process, the request is handled entirely within the Pharos binary.
Flow:
Definition in file native_dynamic_runtime.c.
| #define CSRF_COOKIE_MAX_AGE "7200" |
CSRF cookie max-age in seconds.
Definition at line 63 of file native_dynamic_runtime.c.
Referenced by write_html_response_with_headers_runtime().
| #define CSRF_COOKIE_NAME "pharos_csrf" |
CSRF cookie name used by the Pharos framework.
Definition at line 54 of file native_dynamic_runtime.c.
Referenced by csrf_token_from_cookie(), and write_html_response_with_headers_runtime().
| #define CSRF_TOKEN_HEX_LEN 48 |
Maximum CSRF token length (24 bytes = 48 hex chars).
Definition at line 60 of file native_dynamic_runtime.c.
Referenced by csrf_token_for_response(), handle_issue_business_invite_action_runtime(), handle_password_reset_request_action_runtime(), and issue_browser_session_runtime().
| #define DYNAMIC_HOST_PROFILE "dynamic-app" |
Host profile string that triggers in-process dynamic handling.
Definition at line 48 of file native_dynamic_runtime.c.
Referenced by native_dynamic_runtime_host_profile().
| #define MAX_QUERY_LEN 4096 |
Maximum query string length we process.
Definition at line 51 of file native_dynamic_runtime.c.
Referenced by native_dynamic_runtime_handle_request().
| #define SESSION_COOKIE_NAME "pharos_session" |
Session cookie name used by the Pharos framework.
Definition at line 57 of file native_dynamic_runtime.c.
Referenced by active_user_id_from_cookie_runtime(), request_has_session_cookie(), revoke_session_by_cookie_runtime(), and session_cookie_header_dup_runtime().
| #define SHA256_BLOCK_SIZE 64 |
Definition at line 2524 of file native_dynamic_runtime.c.
Referenced by hmac_sha256_runtime().
| #define SHA256_DIGEST_SIZE 32 |
Definition at line 2525 of file native_dynamic_runtime.c.
Referenced by hmac_sha256_runtime(), password_hash_dup_runtime(), pbkdf2_sha256_runtime(), sha256_final_runtime(), sha256_hex_dup_runtime(), and verify_password_hash_runtime().
|
static |
Definition at line 3389 of file native_dynamic_runtime.c.
References native_dynamic_cookie_value(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), now_iso_utc_runtime(), SESSION_COOKIE_NAME, state_array_runtime_local(), token_hash_dup_runtime(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_equals_str(), yyjson_is_obj(), and yyjson_is_str().
Referenced by handle_action_route(), handle_issue_business_invite_action_runtime(), handle_page_route(), and render_declared_page_response_with_headers_runtime().
|
static |
Appends create-form field HTML for one generated-admin surface.
| descriptor | Surface descriptor that owns the create-form contract. |
| form_fields_html | Accumulated form field output buffer. |
| form_fields_length | Current form field length. |
| form_fields_capacity | Current form field capacity. |
| day_options_html | Optional prebuilt day-of-week options for availability surfaces. |
Definition at line 969 of file native_dynamic_runtime.c.
References streq(), GeneratedAdminSurfaceDescriptor::surface_kind, text_append_format_runtime_local(), and text_append_runtime_local().
Referenced by generated_admin_manage_page_params_json_dup_runtime().
|
static |
Appends row HTML for one generated-admin manage surface.
| descriptor | Surface descriptor that owns the row contract. |
| root | Loaded runtime state root. |
| business_id | Current business identifier. |
| business_slug | Current business slug used in edit links. |
| row_html | Accumulated row HTML output buffer. |
| row_html_length | Current row HTML length. |
| row_html_capacity | Current row HTML capacity. |
Definition at line 854 of file native_dynamic_runtime.c.
References GeneratedAdminSurfaceDescriptor::empty_state_row_html, native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), GeneratedAdminSurfaceDescriptor::resource_collection_name, state_array_runtime_local(), streq(), GeneratedAdminSurfaceDescriptor::surface_kind, GeneratedAdminSurfaceDescriptor::surface_path_segment, text_append_format_runtime_local(), text_append_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_get_bool(), and yyjson_is_obj().
Referenced by generated_admin_manage_page_params_json_dup_runtime().
|
static |
Appends profile subscription rows for one user into an HTML list buffer.
| root | Loaded runtime state root. |
| user_id | Active signed-in user id. |
| subscriptions_block | Accumulated subscription row HTML. |
| subscriptions_length | Current subscription row length. |
| subscriptions_capacity | Current subscription row capacity. |
Definition at line 1125 of file native_dynamic_runtime.c.
References native_json_obj_get_long_default(), resource_link_display_free_runtime(), resource_link_display_load_runtime(), ResourceLinkDisplay::resource_name, ResourceLinkDisplay::resource_slug, state_array_runtime_local(), text_append_format_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), and yyjson_is_obj().
Referenced by profile_subscriptions_block_dup_runtime().
|
static |
Definition at line 3336 of file native_dynamic_runtime.c.
References native_json_doc_free(), native_json_doc_load_file(), next_array_id_runtime_local(), now_iso_utc_runtime(), persist_app_state_text_runtime_local(), state_array_runtime_local(), AppRuntime::state_path, yyjson_doc_get_root(), yyjson_doc_mut_copy(), yyjson_mut_arr(), yyjson_mut_arr_append(), yyjson_mut_doc_free(), yyjson_mut_doc_get_root(), yyjson_mut_is_arr(), yyjson_mut_is_obj(), yyjson_mut_obj(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_obj_get(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_action_route().
|
static |
Definition at line 3123 of file native_dynamic_runtime.c.
References day_abbrev_for_ymd_runtime_local(), find_service_for_business_runtime_local(), long_from_value_runtime_local(), native_json_obj_get(), native_json_obj_get_array(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), parse_ymd_runtime_local(), state_array_runtime_local(), streq(), technician_booked_for_slot_runtime_local(), time_text_to_minutes_runtime(), value_long_equals_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_is_arr(), and yyjson_is_obj().
Referenced by handle_action_route().
|
static |
Definition at line 1392 of file native_dynamic_runtime.c.
References day_of_week_options_html_dup_runtime(), error_alert_html_dup_runtime(), find_business_by_slug_runtime_local(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), state_array_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_is_obj(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by resolve_declared_page_params_json_runtime().
| char * business_calendar_render_page_params_json_dup_runtime | ( | const char * | state_path, |
| const char * | business_slug, | ||
| const char * | app_root, | ||
| const char * | selected_year_text, | ||
| const char * | selected_month_text, | ||
| const char * | selected_date_text ) |
Definition at line 7814 of file native_json_runtime_ops.c.
References append_date_runtime(), day_abbrev_for_ymd_runtime(), days_in_month_runtime(), TextBufferRuntime::length, month_name_runtime(), month_shift_runtime(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), render_business_fragment_from_doc_dup_runtime(), state_array_runtime(), state_find_business_by_slug_runtime(), state_find_service_by_id_runtime(), streq(), TextBufferRuntime::text, text_buffer_append_format_runtime(), text_buffer_append_html_escaped_runtime(), text_buffer_append_text_runtime(), text_buffer_free_runtime(), text_buffer_take_runtime(), value_long_equals_runtime(), weekday_monday_index_runtime(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_is_obj(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by resolve_declared_page_params_json_runtime().
| char * business_landing_render_page_params_json_dup_runtime | ( | const char * | state_path, |
| const char * | business_slug, | ||
| long | user_id, | ||
| const char * | app_root ) |
Definition at line 10798 of file native_json_runtime_ops.c.
References business_media_url_dup_runtime(), collect_business_service_list_runtime(), business_admin_service_list_runtime::count, free_business_admin_service_list_runtime(), business_admin_service_list_runtime::items, TextBufferRuntime::length, native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), render_business_fragment_dup_runtime(), render_business_fragment_from_doc_dup_runtime(), render_service_visual_html_dup_runtime(), business_admin_service_runtime::service, business_admin_service_runtime::service_id, service_media_url_dup_runtime(), state_array_runtime(), state_find_business_by_slug_runtime(), TextBufferRuntime::text, text_buffer_append_text_runtime(), text_buffer_free_runtime(), value_long_equals_runtime(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_is_obj(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Definition at line 3030 of file native_dynamic_runtime.c.
References day_abbrev_for_ymd_runtime_local(), native_json_obj_get(), native_json_obj_get_string_dup(), parse_ymd_runtime_local(), state_array_runtime_local(), streq(), time_text_to_minutes_runtime(), value_long_equals_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), and yyjson_is_obj().
Referenced by handle_action_route().
|
static |
Definition at line 2646 of file native_dynamic_runtime.c.
References len.
Referenced by password_hash_dup_runtime(), sha256_hex_dup_runtime(), and verify_password_hash_runtime().
|
static |
Generates a random hex token for CSRF protection.
Produces byte_count random bytes encoded as hex (so the returned string is byte_count * 2 characters long).
| buf | Destination buffer (must be at least byte_count*2+1). |
| byte_count | Number of random bytes to generate. |
Definition at line 280 of file native_dynamic_runtime.c.
Referenced by csrf_token_for_response(), handle_issue_business_invite_action_runtime(), handle_password_reset_request_action_runtime(), issue_browser_session_runtime(), and password_hash_dup_runtime().
|
static |
Injects CSRF hidden inputs into form tags in an HTML string.
Scans html for <form ... method="post" ...> tags and inserts a hidden input field carrying the CSRF token after the opening tag.
| html | Original HTML string. |
| csrf_token | CSRF token value to inject. |
Definition at line 3654 of file native_dynamic_runtime.c.
Referenced by handle_page_route(), and render_declared_page_response_with_headers_runtime().
|
static |
Definition at line 374 of file native_dynamic_runtime.c.
References HttpRequest::headers, native_dynamic_form_value(), and request_header_value_dup_runtime().
Referenced by csrf_request_valid_runtime().
|
static |
Definition at line 383 of file native_dynamic_runtime.c.
References HttpRequest::cookie, csrf_request_token_dup_runtime(), csrf_token_from_cookie(), and streq().
Referenced by handle_action_route().
|
static |
Returns the CSRF token to use for a response.
Reads the token from the request cookie. If absent, generates a new random token.
| cookie_header | Raw Cookie header value, or NULL. |
Definition at line 326 of file native_dynamic_runtime.c.
References csrf_generate_random_hex(), csrf_token_from_cookie(), and CSRF_TOKEN_HEX_LEN.
Referenced by native_dynamic_runtime_handle_request(), and render_declared_page_response_with_headers_runtime().
|
static |
Extracts the CSRF token from the request cookie header.
| cookie_header | Raw Cookie header value, or NULL. |
Definition at line 313 of file native_dynamic_runtime.c.
References CSRF_COOKIE_NAME, and native_dynamic_cookie_value().
Referenced by csrf_request_valid_runtime(), and csrf_token_for_response().
|
static |
Definition at line 3015 of file native_dynamic_runtime.c.
Referenced by assign_technician_for_slot_runtime_local(), and business_open_for_slot_runtime_local().
|
static |
Definition at line 756 of file native_dynamic_runtime.c.
References streq(), and text_append_runtime_local().
Referenced by business_availability_edit_page_params_json_dup_runtime(), and generated_admin_manage_page_params_json_dup_runtime().
|
static |
Definition at line 3470 of file native_dynamic_runtime.c.
References native_json_obj_get(), streq(), and yyjson_get_str().
Referenced by handle_accept_invite_action_runtime(), and handle_action_route().
| char * diagnostics_render_page_params_json_dup_runtime | ( | const char * | state_path | ) |
Definition at line 11269 of file native_json_runtime_ops.c.
References TextBufferRuntime::length, native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), state_array_runtime(), streq(), TextBufferRuntime::text, text_buffer_append_format_runtime(), text_buffer_append_html_escaped_runtime(), text_buffer_append_text_runtime(), text_buffer_free_runtime(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_arr_size(), yyjson_doc_get_root(), yyjson_is_obj(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Extracts the query portion from a target string.
| target | Raw request target (may contain a ? ). |
| dest | Destination buffer. |
| dest_size | Size of the destination buffer. |
Definition at line 3941 of file native_dynamic_runtime.c.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Definition at line 2978 of file native_dynamic_runtime.c.
References native_json_obj_get_long_default(), state_array_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), and yyjson_is_obj().
|
static |
Finds one business record by numeric id in the runtime state.
| root | Loaded runtime state root. |
| business_id | Business id to match. |
Definition at line 2923 of file native_dynamic_runtime.c.
References native_json_obj_get_long_default(), state_array_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), and yyjson_is_obj().
Referenced by handle_accept_invite_action_runtime(), and resolve_invite_accept_page_params_json_runtime().
|
static |
Definition at line 2900 of file native_dynamic_runtime.c.
References native_json_obj_get(), state_array_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_equals_str(), and yyjson_is_str().
Referenced by business_availability_edit_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), and write_generated_surface_schema_response().
|
static |
Definition at line 2959 of file native_dynamic_runtime.c.
References native_json_obj_get_long_default(), state_array_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), and yyjson_is_obj().
Referenced by assign_technician_for_slot_runtime_local(), handle_action_route(), service_edit_page_params_json_dup_runtime(), and technician_booked_for_slot_runtime_local().
|
static |
Definition at line 2885 of file native_dynamic_runtime.c.
References native_json_obj_get_long_default(), state_array_runtime_local(), yyjson_arr_iter_init(), and yyjson_arr_iter_next().
Referenced by handle_accept_invite_action_runtime(), profile_page_params_json_dup_runtime_local(), and resolve_declared_page_params_json_runtime().
|
static |
Definition at line 2869 of file native_dynamic_runtime.c.
References native_json_obj_get(), state_array_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_equals_str(), and yyjson_is_str().
Referenced by handle_accept_invite_action_runtime(), and handle_action_route().
|
static |
Definition at line 1210 of file native_dynamic_runtime.c.
References append_generated_admin_surface_form_fields_runtime(), append_generated_admin_surface_rows_runtime(), day_of_week_options_html_dup_runtime(), GeneratedAdminSurfaceDescriptor::default_filter_controls_html, error_alert_html_dup_runtime(), find_business_by_slug_runtime_local(), generated_admin_surface_descriptor_runtime(), generated_admin_surface_filter_controls_dup_runtime(), generated_admin_surface_page_copy_runtime(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_long_default(), streq(), GeneratedAdminSurfaceDescriptor::surface_kind, GeneratedAdminSurfaceDescriptor::surface_path_segment, yyjson_doc_get_root(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Returns the generated-admin descriptor for one declared manage surface.
| surface_kind | Surface identifier requested by the page route. |
Definition at line 782 of file native_dynamic_runtime.c.
References streq().
Referenced by generated_admin_manage_page_params_json_dup_runtime().
|
static |
Duplicates the filter-control HTML for one generated-admin surface.
| descriptor | Surface descriptor that owns the filter-control contract. |
Definition at line 1020 of file native_dynamic_runtime.c.
References GeneratedAdminSurfaceDescriptor::default_filter_controls_html.
Referenced by generated_admin_manage_page_params_json_dup_runtime().
|
static |
Writes descriptor-owned page copy into one generated-admin params document.
| doc | Mutable document that owns the page object. |
| page | Mutable page params object. |
| descriptor | Surface descriptor that owns the page copy. |
| filter_controls_html | Effective filter-control HTML for the page. |
Definition at line 1037 of file native_dynamic_runtime.c.
References GeneratedAdminSurfaceDescriptor::create_button_label, GeneratedAdminSurfaceDescriptor::create_title, GeneratedAdminSurfaceDescriptor::filter_title, GeneratedAdminSurfaceDescriptor::header_html, GeneratedAdminSurfaceDescriptor::records_title, GeneratedAdminSurfaceDescriptor::sort_options_html, GeneratedAdminSurfaceDescriptor::surface_intro, GeneratedAdminSurfaceDescriptor::surface_title, and yyjson_mut_obj_add_strcpy().
Referenced by generated_admin_manage_page_params_json_dup_runtime().
|
static |
Resolves the generated-surface fixture path for the active app.
Prefers the built-artifact copy and falls back to the app-root copy.
| app | Active app runtime. |
Definition at line 1856 of file native_dynamic_runtime.c.
References AppRuntime::app_root, AppRuntime::artifact_dir, join_base_relative_path_dup_runtime(), and path_exists().
Referenced by write_generated_surface_schema_response().
|
static |
Handles invite acceptance and initial session creation.
| connection | Active client connection. |
| app | Active app runtime. |
| request | Active HTTP request. |
| match | Matched action route. |
Definition at line 4690 of file native_dynamic_runtime.c.
References default_signed_in_path_runtime(), find_business_by_id_runtime_local(), find_user_by_id_runtime_local(), find_user_by_username_runtime_local(), invite_accept_done_page_params_json_dup_runtime(), issue_browser_session_runtime(), membership_role_id_for_invite_runtime_local(), native_dynamic_dispatch_extract_param(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), native_send_text_response(), next_array_id_runtime_local(), now_iso_utc_runtime(), password_hash_dup_runtime(), NativeDynamicRouteMatch::path, persist_app_state_text_runtime_local(), render_declared_page_response_with_headers_runtime(), request_form_value_dup_runtime(), request_path_dup_runtime(), state_array_runtime_local(), AppRuntime::state_path, streq(), token_hash_dup_runtime(), write_json_error(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_doc_mut_copy(), yyjson_equals_str(), yyjson_get_str(), yyjson_is_null(), yyjson_is_obj(), yyjson_is_str(), yyjson_mut_arr(), yyjson_mut_arr_append(), yyjson_mut_arr_get(), yyjson_mut_doc_free(), yyjson_mut_doc_get_root(), yyjson_mut_int(), yyjson_mut_is_arr(), yyjson_mut_obj(), yyjson_mut_obj_add_bool(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_obj_get(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_action_route().
|
static |
Handles a matched action route.
For now, POST actions return a JSON acknowledgement. Full action processing will be added in later slices.
Definition at line 5252 of file native_dynamic_runtime.c.
References NativeDynamicRouteMatch::action_id, active_user_id_from_cookie_runtime(), AppRuntime::app_id, append_rate_limit_event_runtime_local(), AppRuntime::artifact_dir, assign_technician_for_slot_runtime_local(), AppRuntime::base_path, HttpRequest::body_file_path, business_open_for_slot_runtime_local(), HttpRequest::content_type, HttpRequest::cookie, csrf_request_valid_runtime(), default_signed_in_path_runtime(), ensure_business_media_tree(), find_business_by_slug_runtime_local(), find_service_for_business_runtime_local(), find_user_by_username_runtime_local(), handle_accept_invite_action_runtime(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), HttpRequest::is_multipart, issue_browser_session_runtime(), login_page_params_json_dup_runtime(), HttpRequest::method, native_connection_printf(), native_dynamic_dispatch_extract_param(), native_dynamic_form_value(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), native_send_text_response(), next_array_id_runtime_local(), NativeDynamicRouteMatch::path, persist_app_state_text_runtime_local(), proof_state_root_load_runtime(), remove_media_url_file(), render_declared_page_response_runtime(), request_body_text_dup_runtime(), request_form_value_dup_runtime(), request_path_dup_runtime(), revoke_session_by_cookie_runtime(), session_cookie_header_dup_runtime(), state_array_runtime_local(), AppRuntime::state_path, store_uploaded_media(), streq(), time_text_to_minutes_runtime(), valid_day_of_week_runtime(), verify_password_hash_runtime(), write_json_error(), yyjson_arr_get(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_arr_size(), yyjson_doc_get_root(), yyjson_doc_mut_copy(), yyjson_get_bool(), yyjson_is_arr(), yyjson_is_obj(), yyjson_mut_arr(), yyjson_mut_arr_append(), yyjson_mut_arr_foreach, yyjson_mut_arr_get(), yyjson_mut_arr_remove(), yyjson_mut_doc_free(), yyjson_mut_doc_get_root(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_is_arr(), yyjson_mut_is_obj(), yyjson_mut_obj(), yyjson_mut_obj_add_bool(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_obj_get(), yyjson_mut_obj_put(), yyjson_mut_sint(), yyjson_mut_strcpy(), yyjson_mut_write(), yyjson_val_mut_copy(), and YYJSON_WRITE_NOFLAG.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Handles invite creation for tenant-backed business membership flows.
| connection | Active client connection. |
| app | Active app runtime. |
| request | Active HTTP request. |
| match | Matched action route. |
Definition at line 4521 of file native_dynamic_runtime.c.
References active_user_id_from_cookie_runtime(), HttpRequest::cookie, csrf_generate_random_hex(), CSRF_TOKEN_HEX_LEN, find_business_by_slug_runtime_local(), invite_created_page_params_json_dup_runtime(), iso_after_seconds_runtime(), membership_role_id_for_invite_runtime_local(), native_dynamic_dispatch_extract_param(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_long_default(), native_send_text_response(), next_array_id_runtime_local(), now_iso_utc_runtime(), NativeDynamicRouteMatch::path, persist_app_state_text_runtime_local(), render_declared_page_response_runtime(), request_form_value_dup_runtime(), request_path_dup_runtime(), state_array_runtime_local(), AppRuntime::state_path, state_tenant_id_for_business_runtime_local(), token_hash_dup_runtime(), user_has_active_tenant_membership_runtime_local(), write_json_error(), yyjson_doc_get_root(), yyjson_doc_mut_copy(), yyjson_mut_arr(), yyjson_mut_arr_append(), yyjson_mut_doc_free(), yyjson_mut_doc_get_root(), yyjson_mut_is_arr(), yyjson_mut_is_obj(), yyjson_mut_null(), yyjson_mut_obj(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_obj_get(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_action_route().
|
static |
Handles a matched page route using dynamic template rendering.
Primary path: resolve the page spec from page_id, render the body template, wrap in the layout template, inject CSRF, and send with the CSRF cookie.
Fallback: serve a static file from the artifact directory, or generate a generic landing page.
Definition at line 5077 of file native_dynamic_runtime.c.
References active_user_id_from_cookie_runtime(), AppRuntime::app_id, AppRuntime::app_root, AppRuntime::artifact_dir, NativeDynamicRouteMatch::auth_gate, AppRuntime::base_path, HttpRequest::cookie, csrf_inject_hidden_inputs(), declared_page_relative_path_dup_runtime(), join_base_relative_path_dup_runtime(), load_root_from_text_runtime(), native_connection_printf(), native_dynamic_media_serve_asset(), native_json_doc_free(), native_json_obj_get_string_dup(), native_send_text_response(), NativeDynamicRouteMatch::page_id, page_title_dup_runtime(), path_exists(), path_join(), read_file_text(), render_file_template_dup_runtime(), render_page_html_dup_runtime(), resolve_declared_page_params_json_runtime(), NativeDynamicRouteMatch::route_id, serve_dynamic_home_page(), AppRuntime::state_path, streq(), HttpRequest::target, write_html_response(), and write_proof_state_api_response().
Referenced by native_dynamic_runtime_handle_request().
|
static |
Handles password-reset completion action processing.
| connection | Active client connection. |
| app | Active app runtime. |
| request | Active HTTP request. |
| match | Matched action route. |
Definition at line 4345 of file native_dynamic_runtime.c.
References native_dynamic_dispatch_extract_param(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), native_send_text_response(), now_iso_utc_runtime(), password_hash_dup_runtime(), NativeDynamicRouteMatch::path, persist_app_state_text_runtime_local(), render_declared_page_response_runtime(), request_form_value_dup_runtime(), request_path_dup_runtime(), state_array_runtime_local(), AppRuntime::state_path, streq(), token_hash_dup_runtime(), write_json_error(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_doc_mut_copy(), yyjson_equals_str(), yyjson_get_len(), yyjson_is_null(), yyjson_is_obj(), yyjson_is_str(), yyjson_mut_arr_get(), yyjson_mut_doc_free(), yyjson_mut_doc_get_root(), yyjson_mut_is_arr(), yyjson_mut_obj_get(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_action_route().
|
static |
Handles password-reset request action processing.
| connection | Active client connection. |
| app | Active app runtime. |
| request | Active HTTP request. |
Definition at line 4239 of file native_dynamic_runtime.c.
References csrf_generate_random_hex(), CSRF_TOKEN_HEX_LEN, iso_after_seconds_runtime(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), next_array_id_runtime_local(), now_iso_utc_runtime(), password_reset_sent_page_params_json_dup_runtime(), persist_app_state_text_runtime_local(), render_declared_page_response_runtime(), request_form_value_dup_runtime(), state_array_runtime_local(), AppRuntime::state_path, streq(), token_hash_dup_runtime(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_doc_mut_copy(), yyjson_get_bool(), yyjson_mut_arr(), yyjson_mut_arr_append(), yyjson_mut_doc_free(), yyjson_mut_doc_get_root(), yyjson_mut_is_arr(), yyjson_mut_is_obj(), yyjson_mut_null(), yyjson_mut_obj(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_obj_get(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_action_route().
|
static |
Definition at line 2656 of file native_dynamic_runtime.c.
References SHA256_BLOCK_SIZE, SHA256_DIGEST_SIZE, sha256_final_runtime(), sha256_init_runtime(), and sha256_update_runtime().
Referenced by pbkdf2_sha256_runtime().
|
static |
Builds template params for the invite-accepted confirmation page.
| continue_path | Post-accept landing path. |
Definition at line 2286 of file native_dynamic_runtime.c.
References runtime_page_params_add_escaped_string_runtime(), runtime_page_params_write_runtime(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), and yyjson_mut_obj().
Referenced by handle_accept_invite_action_runtime().
|
static |
Builds template params for the invite-accept page.
| invite_kind | Invite kind label. |
| target_business_name | Optional business name attached to the invite. |
| error_message | Optional error text. |
| invite_email | Invite email. |
| form_action | Form POST target. |
Definition at line 2256 of file native_dynamic_runtime.c.
References error_alert_html_dup_runtime(), invite_accept_target_html_dup_runtime(), runtime_page_params_add_escaped_string_runtime(), runtime_page_params_add_string_runtime(), runtime_page_params_write_runtime(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), and yyjson_mut_obj().
Referenced by resolve_invite_accept_page_params_json_runtime().
|
static |
Builds the optional invite target HTML fragment.
| target_business_name | Optional invite-associated business display name. |
Definition at line 2143 of file native_dynamic_runtime.c.
References html_escaped_dup_runtime(), and text_append_runtime_local().
Referenced by invite_accept_page_params_json_dup_runtime().
|
static |
Builds template params for the invite-created confirmation page.
| invite_email | Invite target email. |
| invite_path | Native preview path for the invite token. |
| return_path | Business return path. |
Definition at line 2230 of file native_dynamic_runtime.c.
References runtime_page_params_add_escaped_string_runtime(), runtime_page_params_write_runtime(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), and yyjson_mut_obj().
Referenced by handle_issue_business_invite_action_runtime().
|
static |
Tests whether a request path is the exact business availability list API path.
Matches only /api/businesses/{business_slug}/availability/.
| request_path | Normalized request path without query string. |
Definition at line 1516 of file native_dynamic_runtime.c.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Tests whether a request path is the exact business availability schema API path.
| request_path | Normalized request path without query string. |
Definition at line 1594 of file native_dynamic_runtime.c.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Tests whether a request path is the exact business services list API path.
Matches only /api/businesses/{business_slug}/services/ and avoids hijacking other four-segment paths that happen to contain a slug-like segment in the same position.
| request_path | Normalized request path without query string. |
Definition at line 1474 of file native_dynamic_runtime.c.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Tests whether a request path is the exact business services schema API path.
| request_path | Normalized request path without query string. |
Definition at line 1555 of file native_dynamic_runtime.c.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Definition at line 2853 of file native_dynamic_runtime.c.
Referenced by handle_issue_business_invite_action_runtime(), handle_password_reset_request_action_runtime(), and issue_browser_session_runtime().
|
static |
Definition at line 3538 of file native_dynamic_runtime.c.
References csrf_generate_random_hex(), CSRF_TOKEN_HEX_LEN, iso_after_seconds_runtime(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_long_default(), now_iso_utc_runtime(), persist_app_state_text_runtime_local(), session_cookie_header_dup_runtime(), state_array_runtime_local(), AppRuntime::state_path, token_hash_dup_runtime(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_doc_mut_copy(), yyjson_is_obj(), yyjson_mut_arr(), yyjson_mut_arr_append(), yyjson_mut_doc_free(), yyjson_mut_doc_get_root(), yyjson_mut_is_arr(), yyjson_mut_is_obj(), yyjson_mut_null(), yyjson_mut_obj(), yyjson_mut_obj_add_int(), yyjson_mut_obj_add_strcpy(), yyjson_mut_obj_get(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_accept_invite_action_runtime(), and handle_action_route().
|
static |
Definition at line 1978 of file native_dynamic_runtime.c.
References error_alert_html_dup_runtime(), hidden_next_input_html_dup_runtime(), native_dynamic_query_value(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_action_route(), and resolve_declared_page_params_json_runtime().
|
static |
Definition at line 2938 of file native_dynamic_runtime.c.
References yyjson_get_sint(), yyjson_is_int(), yyjson_is_real(), and yyjson_is_uint().
Referenced by assign_technician_for_slot_runtime_local(), service_edit_page_params_json_dup_runtime(), and value_long_equals_runtime_local().
|
static |
Maps invite role hints onto the canonical tenant membership role id.
| role_hint | Requested invite role hint. |
| account_type | Requested invite account type. |
Definition at line 3265 of file native_dynamic_runtime.c.
References streq().
Referenced by handle_accept_invite_action_runtime(), and handle_issue_business_invite_action_runtime().
| int native_dynamic_runtime_handle_request | ( | const AppRuntime * | app, |
| const HttpRequest * | request, | ||
| NativeConnection * | connection ) |
Serves one dynamic-app request entirely in-process.
This is the canonical entry point that replaces the former spawn_app_request() path for apps whose host_profile is "dynamic-app". The function reads the app's route fixture, resolves the appropriate handler, and writes the HTTP response directly to connection.
Static-only and non-dynamic host profiles continue to use their existing code paths; this function is called only for dynamic-app requests.
| app | Finalized app runtime metadata (artifact dir, state, etc.). |
| request | Parsed HTTP request record. |
| connection | Connection to write the response to. |
Definition at line 6494 of file native_dynamic_runtime.c.
References AppRuntime::app_id, AppRuntime::artifact_dir, HttpRequest::cookie, csrf_token_for_response(), extract_query(), handle_action_route(), handle_page_route(), is_business_availability_api_list_path_runtime(), is_business_availability_api_schema_path_runtime(), is_business_services_api_list_path_runtime(), is_business_services_api_schema_path_runtime(), NativeDynamicRouteMatch::kind, load_root_from_text_runtime(), MAX_QUERY_LEN, HttpRequest::method, native_connection_printf(), native_dynamic_dispatch_extract_param(), native_dynamic_dispatch_free_match(), native_dynamic_dispatch_match(), native_dynamic_dispatch_resolve_route_fixture(), native_dynamic_dispatch_response_file(), native_dynamic_media_is_static_path(), native_dynamic_media_serve_asset(), native_dynamic_relational_prepare_request_state(), native_dynamic_relational_request_sync_free(), native_dynamic_relational_sync_back_if_changed(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_send_text_response(), path_exists(), read_file_text(), request_body_text_dup_runtime(), route_request_path_dup_runtime(), AppRuntime::state_path, streq(), HttpRequest::target, time_text_to_minutes_runtime(), valid_day_of_week_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), write_json_error(), write_proof_state_api_response(), yyjson_get_str(), yyjson_is_str(), yyjson_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_app_or_runtime_request().
| const char * native_dynamic_runtime_host_profile | ( | void | ) |
Returns the canonical host profile string that this module handles.
Useful for callers that need to decide which request path to use without duplicating the profile name string.
Definition at line 6490 of file native_dynamic_runtime.c.
References DYNAMIC_HOST_PROFILE.
|
static |
Definition at line 3186 of file native_dynamic_runtime.c.
References native_json_obj_get_long_default(), yyjson_arr_iter_init(), and yyjson_arr_iter_next().
Referenced by append_rate_limit_event_runtime_local(), handle_accept_invite_action_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), and handle_password_reset_request_action_runtime().
|
static |
Definition at line 2842 of file native_dynamic_runtime.c.
Referenced by active_user_id_from_cookie_runtime(), append_rate_limit_event_runtime_local(), handle_accept_invite_action_runtime(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), issue_browser_session_runtime(), resolve_invite_accept_page_params_json_runtime(), and revoke_session_by_cookie_runtime().
|
static |
Definition at line 1671 of file native_dynamic_runtime.c.
References native_json_obj_get_string_dup().
Referenced by handle_page_route(), and render_declared_page_response_with_headers_runtime().
|
static |
Definition at line 2993 of file native_dynamic_runtime.c.
Referenced by assign_technician_for_slot_runtime_local(), and business_open_for_slot_runtime_local().
|
static |
Definition at line 2819 of file native_dynamic_runtime.c.
References bytes_to_hex_runtime(), csrf_generate_random_hex(), pbkdf2_sha256_runtime(), and SHA256_DIGEST_SIZE.
Referenced by handle_accept_invite_action_runtime(), and handle_password_reset_complete_action_runtime().
|
static |
Builds native template params for the password-reset completion page.
| request_path | Matched request path that contains the reset token. |
Definition at line 2204 of file native_dynamic_runtime.c.
References error_alert_html_dup_runtime(), runtime_page_params_add_escaped_string_runtime(), runtime_page_params_add_string_runtime(), runtime_page_params_write_runtime(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), and yyjson_mut_obj().
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Builds the optional password-reset preview HTML block.
| preview_path | Local preview path to expose. |
Definition at line 2116 of file native_dynamic_runtime.c.
Referenced by password_reset_sent_page_params_json_dup_runtime().
|
static |
Definition at line 2164 of file native_dynamic_runtime.c.
References error_alert_html_dup_runtime(), runtime_page_params_add_string_runtime(), runtime_page_params_write_runtime(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), and yyjson_mut_obj().
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Definition at line 2181 of file native_dynamic_runtime.c.
References password_reset_preview_html_dup_runtime(), runtime_page_params_add_string_runtime(), runtime_page_params_write_runtime(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), and yyjson_mut_obj().
Referenced by handle_password_reset_request_action_runtime().
|
static |
Definition at line 392 of file native_dynamic_runtime.c.
References streq().
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Definition at line 2685 of file native_dynamic_runtime.c.
References hmac_sha256_runtime(), and SHA256_DIGEST_SIZE.
Referenced by password_hash_dup_runtime(), and verify_password_hash_runtime().
|
static |
Appends a native auth/rate-limit event row to runtime state.
| state_path | Runtime state JSON path. |
| policy_key | Policy identifier. |
| bucket_key | Bucket key or actor key. |
| outcome | Result label. |
Definition at line 3303 of file native_dynamic_runtime.c.
References AppRuntime::app_id, AppRuntime::app_root, native_dynamic_relational_backend_dup(), native_dynamic_relational_runtime_export_json_dup(), native_dynamic_relational_runtime_import_state(), AppRuntime::runtime_conf_path, AppRuntime::state_path, and write_text_file().
Referenced by append_rate_limit_event_runtime_local(), handle_accept_invite_action_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), issue_browser_session_runtime(), and revoke_session_by_cookie_runtime().
|
static |
Builds profile-page template params directly from runtime state.
This local builder keeps the profile page on the native dynamic render path without depending on the older shared profile params helper.
| state_path | Runtime state JSON path. |
| user_id | Active signed-in user id. |
| payment_preference_options_html | Pre-rendered select option HTML. |
Definition at line 1323 of file native_dynamic_runtime.c.
References find_user_by_id_runtime_local(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_string_dup(), profile_subscriptions_block_dup_runtime(), yyjson_doc_get_root(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
|
static |
Builds the profile subscription block for one user.
| root | Loaded runtime state root. |
| user_id | Active signed-in user id. |
Definition at line 1180 of file native_dynamic_runtime.c.
References append_profile_subscription_rows_runtime(), and text_append_runtime_local().
Referenced by profile_page_params_json_dup_runtime_local().
|
static |
Definition at line 638 of file native_dynamic_runtime.c.
References native_json_doc_free(), native_json_obj_get(), native_json_obj_get_string_dup(), proof_state_root_load_runtime(), proof_task_items_html_dup_runtime(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Definition at line 559 of file native_dynamic_runtime.c.
References native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), proof_state_seed_json_dup_runtime(), write_text_file(), yyjson_doc_get_root(), yyjson_is_arr(), and yyjson_is_obj().
Referenced by handle_action_route(), proof_home_page_params_json_dup_runtime(), and write_proof_state_api_response().
|
static |
Definition at line 553 of file native_dynamic_runtime.c.
Referenced by proof_state_root_load_runtime().
|
static |
Definition at line 599 of file native_dynamic_runtime.c.
References html_escaped_dup_runtime(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), text_append_format_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_get_bool(), and yyjson_is_arr().
Referenced by proof_home_page_params_json_dup_runtime().
|
static |
Definition at line 2007 of file native_dynamic_runtime.c.
References error_alert_html_dup_runtime(), hidden_next_input_html_dup_runtime(), native_dynamic_query_value(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Definition at line 3923 of file native_dynamic_runtime.c.
References render_declared_page_response_with_headers_runtime().
Referenced by handle_action_route(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), and handle_password_reset_request_action_runtime().
|
static |
Definition at line 3841 of file native_dynamic_runtime.c.
References active_user_id_from_cookie_runtime(), AppRuntime::app_root, AppRuntime::base_path, HttpRequest::cookie, csrf_inject_hidden_inputs(), csrf_token_for_response(), declared_page_relative_path_dup_runtime(), join_base_relative_path_dup_runtime(), load_root_from_text_runtime(), native_json_doc_free(), native_json_obj_get_string_dup(), page_title_dup_runtime(), path_exists(), read_file_text(), render_file_template_dup_runtime(), render_page_html_dup_runtime(), AppRuntime::state_path, HttpRequest::target, and write_html_response_with_headers_runtime().
Referenced by handle_accept_invite_action_runtime(), and render_declared_page_response_runtime().
|
static |
Definition at line 469 of file native_dynamic_runtime.c.
References HttpRequest::body, HttpRequest::body_file_path, HttpRequest::body_len, and read_file_bytes_dup_runtime().
Referenced by request_form_value_dup_runtime().
|
static |
Definition at line 453 of file native_dynamic_runtime.c.
References HttpRequest::body, HttpRequest::body_file_path, and read_file_text().
Referenced by handle_action_route(), native_dynamic_runtime_handle_request(), and request_form_value_dup_runtime().
|
static |
Definition at line 494 of file native_dynamic_runtime.c.
References HttpRequest::content_type, HttpRequest::is_multipart, native_dynamic_form_value(), native_dynamic_multipart_extract_text(), request_body_bytes_dup_runtime(), and request_body_text_dup_runtime().
Referenced by handle_accept_invite_action_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), and handle_password_reset_request_action_runtime().
|
static |
Definition at line 341 of file native_dynamic_runtime.c.
References native_dynamic_cookie_value(), and SESSION_COOKIE_NAME.
|
static |
Definition at line 348 of file native_dynamic_runtime.c.
References dup_range().
Referenced by csrf_request_token_dup_runtime().
|
static |
Definition at line 518 of file native_dynamic_runtime.c.
References dup_range(), and HttpRequest::target.
Referenced by handle_accept_invite_action_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), and route_request_path_dup_runtime().
|
static |
Resolves declared page parameter JSON for the matched page route.
| app | Active app runtime. |
| request | Active HTTP request. |
| match | Matched page route. |
| request_path | Request path used for route-param extraction. |
| query_string | Raw query string. |
| active_user_id | Authenticated user id, or 0 when anonymous. |
Definition at line 4056 of file native_dynamic_runtime.c.
References AppRuntime::app_id, AppRuntime::app_root, appointments_render_page_params_json_dup_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), explore_render_page_params_json_dup_runtime(), find_user_by_id_runtime_local(), generated_admin_manage_page_params_json_dup_runtime(), login_page_params_json_dup_runtime(), native_dynamic_dispatch_extract_param(), native_dynamic_query_value(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_string_dup(), NativeDynamicRouteMatch::page_id, password_reset_complete_page_params_json_dup_runtime(), password_reset_request_page_params_json_dup_runtime(), NativeDynamicRouteMatch::path, payment_preference_options_html_dup_runtime(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), resolve_invite_accept_page_params_json_runtime(), NativeDynamicRouteMatch::route_id, service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), AppRuntime::state_path, streq(), and yyjson_doc_get_root().
Referenced by handle_page_route().
|
static |
Resolves invite-accept page parameters from the current app state.
| app | Active app runtime. |
| match | Matched route used to extract path parameters. |
| request_path | Request path for parameter extraction. |
NULL when no active invite can be resolved. Definition at line 3966 of file native_dynamic_runtime.c.
References find_business_by_id_runtime_local(), invite_accept_page_params_json_dup_runtime(), native_dynamic_dispatch_extract_param(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), now_iso_utc_runtime(), NativeDynamicRouteMatch::path, state_array_runtime_local(), AppRuntime::state_path, token_hash_dup_runtime(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_equals_str(), yyjson_is_null(), yyjson_is_obj(), and yyjson_is_str().
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Frees a linked-resource display record.
| display | Display record to release. |
Definition at line 1105 of file native_dynamic_runtime.c.
References ResourceLinkDisplay::resource_name, and ResourceLinkDisplay::resource_slug.
Referenced by append_profile_subscription_rows_runtime().
|
static |
Loads slug and display-name fields for one linked resource id.
| root | Loaded runtime state root. |
| resource_collection_name | State collection that owns the linked resource. |
| resource_id | Resource identifier to resolve. |
| display | Output record that receives duplicated slug and name values. |
Definition at line 1067 of file native_dynamic_runtime.c.
References native_json_obj_get_long_default(), native_json_obj_get_string_dup(), ResourceLinkDisplay::resource_name, ResourceLinkDisplay::resource_slug, state_array_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), and yyjson_is_obj().
Referenced by append_profile_subscription_rows_runtime().
|
static |
Definition at line 3478 of file native_dynamic_runtime.c.
References native_dynamic_cookie_value(), native_json_doc_free(), native_json_doc_load_file(), now_iso_utc_runtime(), persist_app_state_text_runtime_local(), SESSION_COOKIE_NAME, AppRuntime::state_path, token_hash_dup_runtime(), yyjson_doc_mut_copy(), yyjson_equals_str(), yyjson_get_len(), yyjson_is_null(), yyjson_is_str(), yyjson_mut_arr_foreach, yyjson_mut_doc_free(), yyjson_mut_doc_get_root(), yyjson_mut_is_arr(), yyjson_mut_is_obj(), yyjson_mut_obj_get(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_action_route().
|
static |
Definition at line 525 of file native_dynamic_runtime.c.
References AppRuntime::base_path, request_path_dup_runtime(), and streq().
Referenced by native_dynamic_runtime_handle_request().
|
static |
Adds one HTML-escaped string field to a page-params JSON object.
| doc | Mutable params document. |
| root | Mutable params object. |
| key | Field name to populate. |
| value | Raw string value to escape before storing. |
Definition at line 2075 of file native_dynamic_runtime.c.
References html_escaped_dup_runtime(), and yyjson_mut_obj_add_strcpy().
Referenced by invite_accept_done_page_params_json_dup_runtime(), invite_accept_page_params_json_dup_runtime(), invite_created_page_params_json_dup_runtime(), and password_reset_complete_page_params_json_dup_runtime().
|
static |
Builds native template params for the password-reset request page.
Adds one literal string field to a page-params JSON object.
| doc | Mutable params document. |
| root | Mutable params object. |
| key | Field name to populate. |
| value | Raw string value to store. |
Definition at line 2054 of file native_dynamic_runtime.c.
References yyjson_mut_obj_add_strcpy().
Referenced by invite_accept_page_params_json_dup_runtime(), password_reset_complete_page_params_json_dup_runtime(), password_reset_request_page_params_json_dup_runtime(), and password_reset_sent_page_params_json_dup_runtime().
|
static |
Finalizes and writes one page-params document as compact JSON.
| doc | Mutable params document. |
| root | Mutable params object. |
Definition at line 2102 of file native_dynamic_runtime.c.
References yyjson_mut_doc_set_root(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by invite_accept_done_page_params_json_dup_runtime(), invite_accept_page_params_json_dup_runtime(), invite_created_page_params_json_dup_runtime(), password_reset_complete_page_params_json_dup_runtime(), password_reset_request_page_params_json_dup_runtime(), and password_reset_sent_page_params_json_dup_runtime().
|
static |
Definition at line 2505 of file native_dynamic_runtime.c.
Referenced by verify_password_hash_runtime().
|
static |
Serves the Pharos dynamic-app home page or a generic landing page.
This is a placeholder that will be replaced by full template rendering in later Phase 3 slices. For now it provides a functional HTML page so the app is browsable.
Definition at line 5030 of file native_dynamic_runtime.c.
References len, native_send_text_response(), and write_html_response().
Referenced by handle_page_route().
|
static |
Definition at line 2300 of file native_dynamic_runtime.c.
References find_business_by_slug_runtime_local(), find_service_for_business_runtime_local(), long_from_value_runtime_local(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), state_array_runtime_local(), text_append_format_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_is_arr(), yyjson_is_obj(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_add_strcpy(), yyjson_mut_write(), and YYJSON_WRITE_NOFLAG.
Referenced by resolve_declared_page_params_json_runtime().
|
static |
Definition at line 3440 of file native_dynamic_runtime.c.
References AppRuntime::base_path, HttpRequest::headers, SESSION_COOKIE_NAME, and streq().
Referenced by handle_action_route(), and issue_browser_session_runtime().
|
static |
Definition at line 2613 of file native_dynamic_runtime.c.
References Sha256Runtime::bitlen, Sha256Runtime::data, Sha256Runtime::datalen, SHA256_DIGEST_SIZE, sha256_transform_runtime(), and Sha256Runtime::state.
Referenced by hmac_sha256_runtime(), and sha256_hex_dup_runtime().
|
static |
Definition at line 2781 of file native_dynamic_runtime.c.
References bytes_to_hex_runtime(), SHA256_DIGEST_SIZE, sha256_final_runtime(), sha256_init_runtime(), and sha256_update_runtime().
Referenced by token_hash_dup_runtime().
|
static |
Definition at line 2588 of file native_dynamic_runtime.c.
References Sha256Runtime::bitlen, Sha256Runtime::datalen, and Sha256Runtime::state.
Referenced by hmac_sha256_runtime(), and sha256_hex_dup_runtime().
|
static |
Definition at line 2534 of file native_dynamic_runtime.c.
Referenced by sha256_transform_runtime().
|
static |
Definition at line 2538 of file native_dynamic_runtime.c.
References sha256_rotr(), and Sha256Runtime::state.
Referenced by sha256_final_runtime(), and sha256_update_runtime().
|
static |
Definition at line 2601 of file native_dynamic_runtime.c.
References Sha256Runtime::bitlen, Sha256Runtime::data, Sha256Runtime::datalen, len, and sha256_transform_runtime().
Referenced by hmac_sha256_runtime(), and sha256_hex_dup_runtime().
|
static |
Definition at line 2864 of file native_dynamic_runtime.c.
References native_json_obj_get(), and yyjson_is_arr().
Referenced by active_user_id_from_cookie_runtime(), append_generated_admin_surface_rows_runtime(), append_profile_subscription_rows_runtime(), append_rate_limit_event_runtime_local(), assign_technician_for_slot_runtime_local(), business_availability_edit_page_params_json_dup_runtime(), business_open_for_slot_runtime_local(), find_appointment_by_id_runtime_local(), find_business_by_id_runtime_local(), find_business_by_slug_runtime_local(), find_service_for_business_runtime_local(), find_user_by_id_runtime_local(), find_user_by_username_runtime_local(), handle_accept_invite_action_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), issue_browser_session_runtime(), resolve_invite_accept_page_params_json_runtime(), resource_link_display_load_runtime(), service_edit_page_params_json_dup_runtime(), state_tenant_id_for_business_runtime_local(), technician_booked_for_slot_runtime_local(), user_has_active_tenant_membership_runtime_local(), write_business_availability_api_response(), and write_business_services_api_response().
|
static |
Resolves the tenant id that owns a business record.
| root | Loaded runtime state root. |
| business_id | Business id to map. |
Definition at line 3208 of file native_dynamic_runtime.c.
References native_json_obj_get_long_default(), state_array_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), and yyjson_is_obj().
Referenced by handle_issue_business_invite_action_runtime().
|
static |
Definition at line 3074 of file native_dynamic_runtime.c.
References find_service_for_business_runtime_local(), native_json_obj_get(), native_json_obj_get_long_default(), native_json_obj_get_string_dup(), state_array_runtime_local(), streq(), time_ranges_overlap_runtime_local(), time_text_to_minutes_runtime(), value_long_equals_runtime_local(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), and yyjson_is_obj().
Referenced by assign_technician_for_slot_runtime_local().
|
static |
Definition at line 727 of file native_dynamic_runtime.c.
References text_append_runtime_local().
Referenced by append_generated_admin_surface_form_fields_runtime(), append_generated_admin_surface_rows_runtime(), append_profile_subscription_rows_runtime(), proof_task_items_html_dup_runtime(), and service_edit_page_params_json_dup_runtime().
|
static |
Definition at line 696 of file native_dynamic_runtime.c.
Referenced by append_generated_admin_surface_form_fields_runtime(), append_generated_admin_surface_rows_runtime(), day_of_week_options_html_dup_runtime(), invite_accept_target_html_dup_runtime(), profile_subscriptions_block_dup_runtime(), and text_append_format_runtime_local().
|
static |
Definition at line 3009 of file native_dynamic_runtime.c.
Referenced by technician_booked_for_slot_runtime_local().
|
static |
Definition at line 1647 of file native_dynamic_runtime.c.
Referenced by assign_technician_for_slot_runtime_local(), business_open_for_slot_runtime_local(), handle_action_route(), native_dynamic_runtime_handle_request(), and technician_booked_for_slot_runtime_local().
|
static |
Definition at line 2799 of file native_dynamic_runtime.c.
References sha256_hex_dup_runtime().
Referenced by active_user_id_from_cookie_runtime(), handle_accept_invite_action_runtime(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), issue_browser_session_runtime(), resolve_invite_accept_page_params_json_runtime(), and revoke_session_by_cookie_runtime().
|
static |
Checks whether a user has an active membership on a tenant.
| root | Loaded runtime state root. |
| user_id | User id to test. |
| tenant_id | Tenant id to test. |
Definition at line 3234 of file native_dynamic_runtime.c.
References native_json_obj_get(), native_json_obj_get_long_default(), state_array_runtime_local(), streq(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_get_str(), and yyjson_is_obj().
Referenced by handle_issue_business_invite_action_runtime().
|
static |
Resolves the final page title from a declarative page spec and params.
Prefers an explicit title value from the page spec. When the spec uses title_mode instead, this treats the title-mode value as the params field name whose string value should supply the page title.
| page_spec_root | Loaded page-spec JSON root. |
| body_params_root | Loaded page-params JSON root. |
Definition at line 1640 of file native_dynamic_runtime.c.
References streq().
Referenced by handle_action_route(), and native_dynamic_runtime_handle_request().
|
static |
Definition at line 2954 of file native_dynamic_runtime.c.
References long_from_value_runtime_local().
Referenced by assign_technician_for_slot_runtime_local(), business_open_for_slot_runtime_local(), and technician_booked_for_slot_runtime_local().
|
static |
Definition at line 2722 of file native_dynamic_runtime.c.
References bytes_to_hex_runtime(), pbkdf2_sha256_runtime(), secure_text_equals(), SHA256_DIGEST_SIZE, and streq().
Referenced by handle_action_route().
|
static |
Definition at line 1768 of file native_dynamic_runtime.c.
References find_business_by_slug_runtime_local(), native_connection_printf(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_long_default(), native_send_text_response(), state_array_runtime_local(), write_json_error(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_is_obj(), yyjson_mut_arr(), yyjson_mut_arr_append(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), yyjson_val_mut_copy(), and YYJSON_WRITE_NOFLAG.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Definition at line 1689 of file native_dynamic_runtime.c.
References find_business_by_slug_runtime_local(), native_connection_printf(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get_long_default(), native_send_text_response(), state_array_runtime_local(), write_json_error(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_is_obj(), yyjson_mut_arr(), yyjson_mut_arr_append(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_obj(), yyjson_mut_obj_put(), yyjson_mut_strcpy(), yyjson_mut_write(), yyjson_val_mut_copy(), and YYJSON_WRITE_NOFLAG.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Writes one generated-surface schema object from the declarative fixture.
| connection | Connection to write to. |
| app | Active app runtime for fixture resolution. |
| state_path | Runtime state path used to validate the business slug. |
| business_slug | Business slug from the request path. |
| surface_id | Schema surface id to emit. |
Definition at line 1888 of file native_dynamic_runtime.c.
References find_business_by_slug_runtime_local(), generated_surface_fixture_path_dup_runtime(), native_connection_printf(), native_json_doc_free(), native_json_doc_load_file(), native_json_obj_get(), native_send_text_response(), write_json_error(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_doc_get_root(), yyjson_equals_str(), yyjson_is_arr(), yyjson_is_str(), yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), yyjson_mut_write(), yyjson_val_mut_copy(), and YYJSON_WRITE_NOFLAG.
Referenced by native_dynamic_runtime_handle_request().
|
static |
Definition at line 3831 of file native_dynamic_runtime.c.
References write_html_response_with_headers_runtime().
Referenced by handle_page_route(), and serve_dynamic_home_page().
|
static |
Writes an HTML response to a connection, optionally with a CSRF cookie.
| connection | Connection to write to. |
| status | HTTP status code. |
| status_text | HTTP reason phrase. |
| html | HTML body content. |
| csrf_token | CSRF token to set as cookie, or NULL to skip. |
Definition at line 3795 of file native_dynamic_runtime.c.
References CSRF_COOKIE_MAX_AGE, CSRF_COOKIE_NAME, native_connection_printf(), and native_send_text_response().
Referenced by render_declared_page_response_with_headers_runtime(), and write_html_response().
|
static |
Writes a JSON error response to a connection.
| connection | Connection to write to. |
| status | HTTP status code. |
| status_text | HTTP reason phrase. |
| error_kind | Machine-readable error kind. |
| message | Human-readable error message. |
Definition at line 238 of file native_dynamic_runtime.c.
References native_connection_printf(), and native_send_text_response().
Referenced by handle_accept_invite_action_runtime(), handle_action_route(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), native_dynamic_runtime_handle_request(), write_business_availability_api_response(), write_business_services_api_response(), and write_generated_surface_schema_response().
|
static |
Definition at line 663 of file native_dynamic_runtime.c.
References native_connection_printf(), native_json_doc_free(), native_send_text_response(), proof_state_root_load_runtime(), yyjson_write(), and YYJSON_WRITE_NOFLAG.
Referenced by handle_page_route(), and native_dynamic_runtime_handle_request().