@cimplify/sdk 0.68.0 → 0.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mock/cli.mjs CHANGED
@@ -3044,23 +3044,47 @@ function buildV1(deps) {
3044
3044
  app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
3045
3045
  app.post("/auth/request-otp", async (c) => {
3046
3046
  const body = await c.req.json().catch(() => ({}));
3047
- return tryRoute(c, () => deps.auth.requestOtp(body.contact ?? ""));
3047
+ return tryRoute(c, () => {
3048
+ deps.auth.requestOtp(body.contact ?? "");
3049
+ return {
3050
+ message: `OTP sent to ${body.contact ?? "contact"}`,
3051
+ expires_in: 300,
3052
+ is_new_account: false
3053
+ };
3054
+ });
3048
3055
  });
3049
3056
  app.post("/auth/verify-otp", async (c) => {
3050
3057
  const body = await c.req.json().catch(() => ({}));
3051
3058
  return tryRoute(c, () => {
3052
3059
  const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
3053
3060
  c.header("x-session-token", session.token);
3054
- return { session, token: session.token };
3061
+ return {
3062
+ message: "Successfully authenticated",
3063
+ account_id: session.id,
3064
+ session_token: session.token,
3065
+ refresh_token: session.token,
3066
+ customer: {
3067
+ id: session.customer_id ?? session.id,
3068
+ name: session.customer_name ?? "Test User",
3069
+ email: session.customer_email ?? null,
3070
+ phone: session.customer_phone ?? null,
3071
+ delivery_address: null,
3072
+ created_at: session.created_at,
3073
+ updated_at: session.created_at
3074
+ }
3075
+ };
3055
3076
  });
3056
3077
  });
3057
3078
  app.post("/auth/logout", (c) => {
3058
3079
  deps.auth.logout(c.var.session.token);
3059
- return ok(c, { logged_out: true });
3080
+ return ok(c, { message: "Successfully logged out", action: "discard_token" });
3060
3081
  });
3061
3082
  app.post("/auth/profile", async (c) => {
3062
3083
  const body = await c.req.json().catch(() => ({}));
3063
- return tryRoute(c, () => deps.auth.updateProfile(c.var.session.token, body));
3084
+ return tryRoute(c, () => {
3085
+ deps.auth.updateProfile(c.var.session.token, body);
3086
+ return { success: true, message: "Profile updated successfully" };
3087
+ });
3064
3088
  });
3065
3089
  app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
3066
3090
  app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
@@ -3682,7 +3706,12 @@ function buildLink(deps) {
3682
3706
  const body = await c.req.json().catch(() => ({}));
3683
3707
  return tryRoute(c, () => {
3684
3708
  deps.auth.requestOtp(body.contact ?? "");
3685
- return { success: true, message: "OTP sent" };
3709
+ return {
3710
+ success: true,
3711
+ message: `OTP sent to ${body.contact ?? "contact"}`,
3712
+ expires_in: 300,
3713
+ is_new_account: false
3714
+ };
3686
3715
  });
3687
3716
  });
3688
3717
  app.post("/auth/verify-otp", async (c) => {
@@ -3700,7 +3729,29 @@ function buildLink(deps) {
3700
3729
  refresh_token: session.token,
3701
3730
  account_id: session.id,
3702
3731
  customer_id: customer.customer.id,
3703
- message: "Verified"
3732
+ name: customer.customer.name,
3733
+ email: customer.customer.email,
3734
+ phone: customer.customer.phone,
3735
+ message: "Login successful"
3736
+ };
3737
+ });
3738
+ });
3739
+ app.post("/auth/refresh", async (c) => {
3740
+ const body = await c.req.json().catch(() => ({}));
3741
+ return tryRoute(c, () => {
3742
+ const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
3743
+ const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
3744
+ c.header("x-session-token", session.token);
3745
+ return {
3746
+ success: true,
3747
+ session_token: session.token,
3748
+ refresh_token: session.token,
3749
+ account_id: session.id,
3750
+ customer_id: customer.customer.id,
3751
+ name: customer.customer.name,
3752
+ email: customer.customer.email,
3753
+ phone: customer.customer.phone,
3754
+ message: "Session refreshed"
3704
3755
  };
3705
3756
  });
3706
3757
  });
@@ -3708,9 +3759,24 @@ function buildLink(deps) {
3708
3759
  "/auth/logout",
3709
3760
  (c) => tryRoute(c, () => {
3710
3761
  deps.auth.logout(c.var.session.token);
3711
- return { success: true, message: "Logged out" };
3762
+ return { success: true, message: "Logged out successfully", action: "discard_token" };
3712
3763
  })
3713
3764
  );
3765
+ app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
3766
+ app.post("/profile", async (c) => {
3767
+ const body = await c.req.json().catch(() => ({}));
3768
+ return tryRoute(c, () => {
3769
+ const state = deps.link.ensureCustomer(customerId(c));
3770
+ state.customer = {
3771
+ ...state.customer,
3772
+ name: body.name ?? state.customer.name,
3773
+ email: body.email ?? state.customer.email,
3774
+ phone: body.phone ?? state.customer.phone,
3775
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
3776
+ };
3777
+ return state.customer;
3778
+ });
3779
+ });
3714
3780
  app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
3715
3781
  app.post("/check-status", async (c) => {
3716
3782
  const body = await c.req.json().catch(() => ({}));
@@ -2412,23 +2412,47 @@ function buildV1(deps) {
2412
2412
  app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
2413
2413
  app.post("/auth/request-otp", async (c) => {
2414
2414
  const body = await c.req.json().catch(() => ({}));
2415
- return tryRoute(c, () => deps.auth.requestOtp(body.contact ?? ""));
2415
+ return tryRoute(c, () => {
2416
+ deps.auth.requestOtp(body.contact ?? "");
2417
+ return {
2418
+ message: `OTP sent to ${body.contact ?? "contact"}`,
2419
+ expires_in: 300,
2420
+ is_new_account: false
2421
+ };
2422
+ });
2416
2423
  });
2417
2424
  app.post("/auth/verify-otp", async (c) => {
2418
2425
  const body = await c.req.json().catch(() => ({}));
2419
2426
  return tryRoute(c, () => {
2420
2427
  const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
2421
2428
  c.header("x-session-token", session.token);
2422
- return { session, token: session.token };
2429
+ return {
2430
+ message: "Successfully authenticated",
2431
+ account_id: session.id,
2432
+ session_token: session.token,
2433
+ refresh_token: session.token,
2434
+ customer: {
2435
+ id: session.customer_id ?? session.id,
2436
+ name: session.customer_name ?? "Test User",
2437
+ email: session.customer_email ?? null,
2438
+ phone: session.customer_phone ?? null,
2439
+ delivery_address: null,
2440
+ created_at: session.created_at,
2441
+ updated_at: session.created_at
2442
+ }
2443
+ };
2423
2444
  });
2424
2445
  });
2425
2446
  app.post("/auth/logout", (c) => {
2426
2447
  deps.auth.logout(c.var.session.token);
2427
- return ok(c, { logged_out: true });
2448
+ return ok(c, { message: "Successfully logged out", action: "discard_token" });
2428
2449
  });
2429
2450
  app.post("/auth/profile", async (c) => {
2430
2451
  const body = await c.req.json().catch(() => ({}));
2431
- return tryRoute(c, () => deps.auth.updateProfile(c.var.session.token, body));
2452
+ return tryRoute(c, () => {
2453
+ deps.auth.updateProfile(c.var.session.token, body);
2454
+ return { success: true, message: "Profile updated successfully" };
2455
+ });
2432
2456
  });
2433
2457
  app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
2434
2458
  app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
@@ -3050,7 +3074,12 @@ function buildLink(deps) {
3050
3074
  const body = await c.req.json().catch(() => ({}));
3051
3075
  return tryRoute(c, () => {
3052
3076
  deps.auth.requestOtp(body.contact ?? "");
3053
- return { success: true, message: "OTP sent" };
3077
+ return {
3078
+ success: true,
3079
+ message: `OTP sent to ${body.contact ?? "contact"}`,
3080
+ expires_in: 300,
3081
+ is_new_account: false
3082
+ };
3054
3083
  });
3055
3084
  });
3056
3085
  app.post("/auth/verify-otp", async (c) => {
@@ -3068,7 +3097,29 @@ function buildLink(deps) {
3068
3097
  refresh_token: session.token,
3069
3098
  account_id: session.id,
3070
3099
  customer_id: customer.customer.id,
3071
- message: "Verified"
3100
+ name: customer.customer.name,
3101
+ email: customer.customer.email,
3102
+ phone: customer.customer.phone,
3103
+ message: "Login successful"
3104
+ };
3105
+ });
3106
+ });
3107
+ app.post("/auth/refresh", async (c) => {
3108
+ const body = await c.req.json().catch(() => ({}));
3109
+ return tryRoute(c, () => {
3110
+ const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
3111
+ const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
3112
+ c.header("x-session-token", session.token);
3113
+ return {
3114
+ success: true,
3115
+ session_token: session.token,
3116
+ refresh_token: session.token,
3117
+ account_id: session.id,
3118
+ customer_id: customer.customer.id,
3119
+ name: customer.customer.name,
3120
+ email: customer.customer.email,
3121
+ phone: customer.customer.phone,
3122
+ message: "Session refreshed"
3072
3123
  };
3073
3124
  });
3074
3125
  });
@@ -3076,9 +3127,24 @@ function buildLink(deps) {
3076
3127
  "/auth/logout",
3077
3128
  (c) => tryRoute(c, () => {
3078
3129
  deps.auth.logout(c.var.session.token);
3079
- return { success: true, message: "Logged out" };
3130
+ return { success: true, message: "Logged out successfully", action: "discard_token" };
3080
3131
  })
3081
3132
  );
3133
+ app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
3134
+ app.post("/profile", async (c) => {
3135
+ const body = await c.req.json().catch(() => ({}));
3136
+ return tryRoute(c, () => {
3137
+ const state = deps.link.ensureCustomer(customerId(c));
3138
+ state.customer = {
3139
+ ...state.customer,
3140
+ name: body.name ?? state.customer.name,
3141
+ email: body.email ?? state.customer.email,
3142
+ phone: body.phone ?? state.customer.phone,
3143
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
3144
+ };
3145
+ return state.customer;
3146
+ });
3147
+ });
3082
3148
  app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
3083
3149
  app.post("/check-status", async (c) => {
3084
3150
  const body = await c.req.json().catch(() => ({}));
@@ -2410,23 +2410,47 @@ function buildV1(deps) {
2410
2410
  app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
2411
2411
  app.post("/auth/request-otp", async (c) => {
2412
2412
  const body = await c.req.json().catch(() => ({}));
2413
- return tryRoute(c, () => deps.auth.requestOtp(body.contact ?? ""));
2413
+ return tryRoute(c, () => {
2414
+ deps.auth.requestOtp(body.contact ?? "");
2415
+ return {
2416
+ message: `OTP sent to ${body.contact ?? "contact"}`,
2417
+ expires_in: 300,
2418
+ is_new_account: false
2419
+ };
2420
+ });
2414
2421
  });
2415
2422
  app.post("/auth/verify-otp", async (c) => {
2416
2423
  const body = await c.req.json().catch(() => ({}));
2417
2424
  return tryRoute(c, () => {
2418
2425
  const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
2419
2426
  c.header("x-session-token", session.token);
2420
- return { session, token: session.token };
2427
+ return {
2428
+ message: "Successfully authenticated",
2429
+ account_id: session.id,
2430
+ session_token: session.token,
2431
+ refresh_token: session.token,
2432
+ customer: {
2433
+ id: session.customer_id ?? session.id,
2434
+ name: session.customer_name ?? "Test User",
2435
+ email: session.customer_email ?? null,
2436
+ phone: session.customer_phone ?? null,
2437
+ delivery_address: null,
2438
+ created_at: session.created_at,
2439
+ updated_at: session.created_at
2440
+ }
2441
+ };
2421
2442
  });
2422
2443
  });
2423
2444
  app.post("/auth/logout", (c) => {
2424
2445
  deps.auth.logout(c.var.session.token);
2425
- return ok(c, { logged_out: true });
2446
+ return ok(c, { message: "Successfully logged out", action: "discard_token" });
2426
2447
  });
2427
2448
  app.post("/auth/profile", async (c) => {
2428
2449
  const body = await c.req.json().catch(() => ({}));
2429
- return tryRoute(c, () => deps.auth.updateProfile(c.var.session.token, body));
2450
+ return tryRoute(c, () => {
2451
+ deps.auth.updateProfile(c.var.session.token, body);
2452
+ return { success: true, message: "Profile updated successfully" };
2453
+ });
2430
2454
  });
2431
2455
  app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
2432
2456
  app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
@@ -3048,7 +3072,12 @@ function buildLink(deps) {
3048
3072
  const body = await c.req.json().catch(() => ({}));
3049
3073
  return tryRoute(c, () => {
3050
3074
  deps.auth.requestOtp(body.contact ?? "");
3051
- return { success: true, message: "OTP sent" };
3075
+ return {
3076
+ success: true,
3077
+ message: `OTP sent to ${body.contact ?? "contact"}`,
3078
+ expires_in: 300,
3079
+ is_new_account: false
3080
+ };
3052
3081
  });
3053
3082
  });
3054
3083
  app.post("/auth/verify-otp", async (c) => {
@@ -3066,7 +3095,29 @@ function buildLink(deps) {
3066
3095
  refresh_token: session.token,
3067
3096
  account_id: session.id,
3068
3097
  customer_id: customer.customer.id,
3069
- message: "Verified"
3098
+ name: customer.customer.name,
3099
+ email: customer.customer.email,
3100
+ phone: customer.customer.phone,
3101
+ message: "Login successful"
3102
+ };
3103
+ });
3104
+ });
3105
+ app.post("/auth/refresh", async (c) => {
3106
+ const body = await c.req.json().catch(() => ({}));
3107
+ return tryRoute(c, () => {
3108
+ const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
3109
+ const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
3110
+ c.header("x-session-token", session.token);
3111
+ return {
3112
+ success: true,
3113
+ session_token: session.token,
3114
+ refresh_token: session.token,
3115
+ account_id: session.id,
3116
+ customer_id: customer.customer.id,
3117
+ name: customer.customer.name,
3118
+ email: customer.customer.email,
3119
+ phone: customer.customer.phone,
3120
+ message: "Session refreshed"
3070
3121
  };
3071
3122
  });
3072
3123
  });
@@ -3074,9 +3125,24 @@ function buildLink(deps) {
3074
3125
  "/auth/logout",
3075
3126
  (c) => tryRoute(c, () => {
3076
3127
  deps.auth.logout(c.var.session.token);
3077
- return { success: true, message: "Logged out" };
3128
+ return { success: true, message: "Logged out successfully", action: "discard_token" };
3078
3129
  })
3079
3130
  );
3131
+ app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
3132
+ app.post("/profile", async (c) => {
3133
+ const body = await c.req.json().catch(() => ({}));
3134
+ return tryRoute(c, () => {
3135
+ const state = deps.link.ensureCustomer(customerId(c));
3136
+ state.customer = {
3137
+ ...state.customer,
3138
+ name: body.name ?? state.customer.name,
3139
+ email: body.email ?? state.customer.email,
3140
+ phone: body.phone ?? state.customer.phone,
3141
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
3142
+ };
3143
+ return state.customer;
3144
+ });
3145
+ });
3080
3146
  app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
3081
3147
  app.post("/check-status", async (c) => {
3082
3148
  const body = await c.req.json().catch(() => ({}));
package/dist/mock/msw.js CHANGED
@@ -2410,23 +2410,47 @@ function buildV1(deps) {
2410
2410
  app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
2411
2411
  app.post("/auth/request-otp", async (c) => {
2412
2412
  const body = await c.req.json().catch(() => ({}));
2413
- return tryRoute(c, () => deps.auth.requestOtp(body.contact ?? ""));
2413
+ return tryRoute(c, () => {
2414
+ deps.auth.requestOtp(body.contact ?? "");
2415
+ return {
2416
+ message: `OTP sent to ${body.contact ?? "contact"}`,
2417
+ expires_in: 300,
2418
+ is_new_account: false
2419
+ };
2420
+ });
2414
2421
  });
2415
2422
  app.post("/auth/verify-otp", async (c) => {
2416
2423
  const body = await c.req.json().catch(() => ({}));
2417
2424
  return tryRoute(c, () => {
2418
2425
  const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
2419
2426
  c.header("x-session-token", session.token);
2420
- return { session, token: session.token };
2427
+ return {
2428
+ message: "Successfully authenticated",
2429
+ account_id: session.id,
2430
+ session_token: session.token,
2431
+ refresh_token: session.token,
2432
+ customer: {
2433
+ id: session.customer_id ?? session.id,
2434
+ name: session.customer_name ?? "Test User",
2435
+ email: session.customer_email ?? null,
2436
+ phone: session.customer_phone ?? null,
2437
+ delivery_address: null,
2438
+ created_at: session.created_at,
2439
+ updated_at: session.created_at
2440
+ }
2441
+ };
2421
2442
  });
2422
2443
  });
2423
2444
  app.post("/auth/logout", (c) => {
2424
2445
  deps.auth.logout(c.var.session.token);
2425
- return ok(c, { logged_out: true });
2446
+ return ok(c, { message: "Successfully logged out", action: "discard_token" });
2426
2447
  });
2427
2448
  app.post("/auth/profile", async (c) => {
2428
2449
  const body = await c.req.json().catch(() => ({}));
2429
- return tryRoute(c, () => deps.auth.updateProfile(c.var.session.token, body));
2450
+ return tryRoute(c, () => {
2451
+ deps.auth.updateProfile(c.var.session.token, body);
2452
+ return { success: true, message: "Profile updated successfully" };
2453
+ });
2430
2454
  });
2431
2455
  app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
2432
2456
  app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
@@ -3048,7 +3072,12 @@ function buildLink(deps) {
3048
3072
  const body = await c.req.json().catch(() => ({}));
3049
3073
  return tryRoute(c, () => {
3050
3074
  deps.auth.requestOtp(body.contact ?? "");
3051
- return { success: true, message: "OTP sent" };
3075
+ return {
3076
+ success: true,
3077
+ message: `OTP sent to ${body.contact ?? "contact"}`,
3078
+ expires_in: 300,
3079
+ is_new_account: false
3080
+ };
3052
3081
  });
3053
3082
  });
3054
3083
  app.post("/auth/verify-otp", async (c) => {
@@ -3066,7 +3095,29 @@ function buildLink(deps) {
3066
3095
  refresh_token: session.token,
3067
3096
  account_id: session.id,
3068
3097
  customer_id: customer.customer.id,
3069
- message: "Verified"
3098
+ name: customer.customer.name,
3099
+ email: customer.customer.email,
3100
+ phone: customer.customer.phone,
3101
+ message: "Login successful"
3102
+ };
3103
+ });
3104
+ });
3105
+ app.post("/auth/refresh", async (c) => {
3106
+ const body = await c.req.json().catch(() => ({}));
3107
+ return tryRoute(c, () => {
3108
+ const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
3109
+ const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
3110
+ c.header("x-session-token", session.token);
3111
+ return {
3112
+ success: true,
3113
+ session_token: session.token,
3114
+ refresh_token: session.token,
3115
+ account_id: session.id,
3116
+ customer_id: customer.customer.id,
3117
+ name: customer.customer.name,
3118
+ email: customer.customer.email,
3119
+ phone: customer.customer.phone,
3120
+ message: "Session refreshed"
3070
3121
  };
3071
3122
  });
3072
3123
  });
@@ -3074,9 +3125,24 @@ function buildLink(deps) {
3074
3125
  "/auth/logout",
3075
3126
  (c) => tryRoute(c, () => {
3076
3127
  deps.auth.logout(c.var.session.token);
3077
- return { success: true, message: "Logged out" };
3128
+ return { success: true, message: "Logged out successfully", action: "discard_token" };
3078
3129
  })
3079
3130
  );
3131
+ app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
3132
+ app.post("/profile", async (c) => {
3133
+ const body = await c.req.json().catch(() => ({}));
3134
+ return tryRoute(c, () => {
3135
+ const state = deps.link.ensureCustomer(customerId(c));
3136
+ state.customer = {
3137
+ ...state.customer,
3138
+ name: body.name ?? state.customer.name,
3139
+ email: body.email ?? state.customer.email,
3140
+ phone: body.phone ?? state.customer.phone,
3141
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
3142
+ };
3143
+ return state.customer;
3144
+ });
3145
+ });
3080
3146
  app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
3081
3147
  app.post("/check-status", async (c) => {
3082
3148
  const body = await c.req.json().catch(() => ({}));
package/dist/mock/msw.mjs CHANGED
@@ -2408,23 +2408,47 @@ function buildV1(deps) {
2408
2408
  app.get("/auth/status", (c) => tryRoute(c, () => deps.auth.status(c.var.session.token)));
2409
2409
  app.post("/auth/request-otp", async (c) => {
2410
2410
  const body = await c.req.json().catch(() => ({}));
2411
- return tryRoute(c, () => deps.auth.requestOtp(body.contact ?? ""));
2411
+ return tryRoute(c, () => {
2412
+ deps.auth.requestOtp(body.contact ?? "");
2413
+ return {
2414
+ message: `OTP sent to ${body.contact ?? "contact"}`,
2415
+ expires_in: 300,
2416
+ is_new_account: false
2417
+ };
2418
+ });
2412
2419
  });
2413
2420
  app.post("/auth/verify-otp", async (c) => {
2414
2421
  const body = await c.req.json().catch(() => ({}));
2415
2422
  return tryRoute(c, () => {
2416
2423
  const session = deps.auth.verifyOtp(body.contact ?? "", body.otp_code ?? body.code ?? "");
2417
2424
  c.header("x-session-token", session.token);
2418
- return { session, token: session.token };
2425
+ return {
2426
+ message: "Successfully authenticated",
2427
+ account_id: session.id,
2428
+ session_token: session.token,
2429
+ refresh_token: session.token,
2430
+ customer: {
2431
+ id: session.customer_id ?? session.id,
2432
+ name: session.customer_name ?? "Test User",
2433
+ email: session.customer_email ?? null,
2434
+ phone: session.customer_phone ?? null,
2435
+ delivery_address: null,
2436
+ created_at: session.created_at,
2437
+ updated_at: session.created_at
2438
+ }
2439
+ };
2419
2440
  });
2420
2441
  });
2421
2442
  app.post("/auth/logout", (c) => {
2422
2443
  deps.auth.logout(c.var.session.token);
2423
- return ok(c, { logged_out: true });
2444
+ return ok(c, { message: "Successfully logged out", action: "discard_token" });
2424
2445
  });
2425
2446
  app.post("/auth/profile", async (c) => {
2426
2447
  const body = await c.req.json().catch(() => ({}));
2427
- return tryRoute(c, () => deps.auth.updateProfile(c.var.session.token, body));
2448
+ return tryRoute(c, () => {
2449
+ deps.auth.updateProfile(c.var.session.token, body);
2450
+ return { success: true, message: "Profile updated successfully" };
2451
+ });
2428
2452
  });
2429
2453
  app.get("/inventory/products/:product_id/stock", (c) => tryRoute(c, () => deps.inventory.productStock(c.req.param("product_id"))));
2430
2454
  app.get("/inventory/variants/:variant_id/stock", (c) => tryRoute(c, () => deps.inventory.variantStock(c.req.param("variant_id"))));
@@ -3046,7 +3070,12 @@ function buildLink(deps) {
3046
3070
  const body = await c.req.json().catch(() => ({}));
3047
3071
  return tryRoute(c, () => {
3048
3072
  deps.auth.requestOtp(body.contact ?? "");
3049
- return { success: true, message: "OTP sent" };
3073
+ return {
3074
+ success: true,
3075
+ message: `OTP sent to ${body.contact ?? "contact"}`,
3076
+ expires_in: 300,
3077
+ is_new_account: false
3078
+ };
3050
3079
  });
3051
3080
  });
3052
3081
  app.post("/auth/verify-otp", async (c) => {
@@ -3064,7 +3093,29 @@ function buildLink(deps) {
3064
3093
  refresh_token: session.token,
3065
3094
  account_id: session.id,
3066
3095
  customer_id: customer.customer.id,
3067
- message: "Verified"
3096
+ name: customer.customer.name,
3097
+ email: customer.customer.email,
3098
+ phone: customer.customer.phone,
3099
+ message: "Login successful"
3100
+ };
3101
+ });
3102
+ });
3103
+ app.post("/auth/refresh", async (c) => {
3104
+ const body = await c.req.json().catch(() => ({}));
3105
+ return tryRoute(c, () => {
3106
+ const session = deps.auth.ensureSession(body.session_token ?? c.var.session.token);
3107
+ const customer = deps.link.ensureCustomer(session.customer_id ?? session.id);
3108
+ c.header("x-session-token", session.token);
3109
+ return {
3110
+ success: true,
3111
+ session_token: session.token,
3112
+ refresh_token: session.token,
3113
+ account_id: session.id,
3114
+ customer_id: customer.customer.id,
3115
+ name: customer.customer.name,
3116
+ email: customer.customer.email,
3117
+ phone: customer.customer.phone,
3118
+ message: "Session refreshed"
3068
3119
  };
3069
3120
  });
3070
3121
  });
@@ -3072,9 +3123,24 @@ function buildLink(deps) {
3072
3123
  "/auth/logout",
3073
3124
  (c) => tryRoute(c, () => {
3074
3125
  deps.auth.logout(c.var.session.token);
3075
- return { success: true, message: "Logged out" };
3126
+ return { success: true, message: "Logged out successfully", action: "discard_token" };
3076
3127
  })
3077
3128
  );
3129
+ app.get("/profile", (c) => tryRoute(c, () => deps.link.getProfile(customerId(c))));
3130
+ app.post("/profile", async (c) => {
3131
+ const body = await c.req.json().catch(() => ({}));
3132
+ return tryRoute(c, () => {
3133
+ const state = deps.link.ensureCustomer(customerId(c));
3134
+ state.customer = {
3135
+ ...state.customer,
3136
+ name: body.name ?? state.customer.name,
3137
+ email: body.email ?? state.customer.email,
3138
+ phone: body.phone ?? state.customer.phone,
3139
+ updated_at: (/* @__PURE__ */ new Date()).toISOString()
3140
+ };
3141
+ return state.customer;
3142
+ });
3143
+ });
3078
3144
  app.get("/data", (c) => tryRoute(c, () => deps.link.getLinkData(customerId(c))));
3079
3145
  app.post("/check-status", async (c) => {
3080
3146
  const body = await c.req.json().catch(() => ({}));