@quantaroute/checkout 1.4.0 → 1.4.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,103 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@quantaroute/checkout` are documented here.
4
+
5
+ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
+ Release dates are from git history where available; earlier versions are estimated from the first public commit.
7
+
8
+ ## [1.4.2](https://github.com/quantaroute/checkout/compare/v1.4.1...v1.4.2) — 2026-06-16
9
+
10
+ ### Added
11
+
12
+ - **Home / Work / Other address label picker** on the address details step (web + native)
13
+ - `AddressLabel` type and `ADDRESS_LABELS` export (`'home' | 'work' | 'other'`)
14
+ - `CompleteAddress.label` — chosen label is passed to `createAddress()` instead of hardcoded `'home'`
15
+
16
+ ### Changed
17
+
18
+ - Saved addresses from the picker retain their stored label when re-selected
19
+
20
+ ## [1.4.1](https://github.com/quantaroute/checkout/compare/v1.4.0...v1.4.1) — 2026-06-13
21
+
22
+ ### Added
23
+
24
+ - Consistent email OTP — same code reused for up to 10 checkouts per email+merchant
25
+ - `SendEmailOtpResult` export with `reused` flag when send skips Resend
26
+ - `EmailOtpStep` copy when an existing code is still valid
27
+
28
+ ### Changed
29
+
30
+ - Email OTP rate limits — max 3 fresh codes / 24h; silent reuse when code is still active
31
+ - Verify lockout after 5 failed attempts (15 min)
32
+
33
+ ### Documentation
34
+
35
+ - OpenAPI spec for `/checkout-email-otp` (send, verify, `reused`, rate-limit responses)
36
+
37
+ ## [1.4.0](https://github.com/quantaroute/checkout/compare/v1.3.1...v1.4.0) — 2026-06-04
38
+
39
+ ### Added
40
+
41
+ - Email OTP auth (`enableEmailAuth`, `EmailStep`, `EmailOtpStep`, `checkout-email-otp` Edge Function)
42
+ - Per-merchant email templates (`email_from_name`, `email_logo_url`, `email_subject_template`)
43
+ - COD controls (`enableCod`, `CodAvailabilityBanner`, `checkCodEligibility()`)
44
+ - Server-side webhooks (`phone_verified`, `email_verified`, `address_completed`, `session.expired`)
45
+ - Automatic session expiry (`checkout-session-expiry` Edge Function + pg_cron)
46
+ - SDK exports: `sendEmailOtp`, `verifyEmailOtp`, `notifyAddressCompleted`
47
+ - Checkout events: `email_step_viewed`, `email_otp_sent`, `email_verified`
48
+
49
+ ## [1.3.1](https://github.com/quantaroute/checkout/compare/v1.3.0...v1.3.1) — 2026-03-14
50
+
51
+ ### Added
52
+
53
+ - Unified map search bar (`enableSearch`) with DigiPin and address autocomplete
54
+
55
+ ### Fixed
56
+
57
+ - DigiPin typing in the search box
58
+
59
+ ## [1.3.0](https://github.com/quantaroute/checkout/compare/v1.2.1...v1.3.0) — 2026-03-01
60
+
61
+ *Estimated — phone OTP and saved-address work landed before the 1.3.1 publish; no tagged commit.*
62
+
63
+ ### Added
64
+
65
+ - Phone OTP auth (`enablePhoneAuth`, `PhoneStep`, `OtpStep`, `checkout-otp` Edge Function)
66
+ - Saved addresses (`SavedAddressStep`, `checkout-addresses` CRUD API)
67
+ - Pincode validation and non-delivery warnings in `AddressForm`
68
+ - Per-merchant branding (`brandColor`, `logoUrl`, `headerBanner`)
69
+ - Client analytics hook (`onCheckoutEvent`, `CheckoutEvent` types)
70
+ - Checkout API client exports (`sendOtp`, `verifyOtp`, address helpers)
71
+
72
+ ## [1.2.1](https://github.com/quantaroute/checkout/compare/v1.2.0...v1.2.1) — 2026-02-19
73
+
74
+ ### Fixed
75
+
76
+ - npm package export paths for CSS and native entry points
77
+
78
+ ## [1.2.0](https://github.com/quantaroute/checkout/compare/v1.1.0...v1.2.0) — 2026-02-19
79
+
80
+ ### Added
81
+
82
+ - iOS and Android support via React Native / Expo (`*.native.tsx`, `expo-plugin.js`)
83
+ - Native map pin selector, address form, and checkout widget
84
+ - GPS geolocation on native (`useGeolocation.native.ts`)
85
+ - Native design system (`checkout.native.ts`, light + dark)
86
+
87
+ ## [1.1.0](https://github.com/quantaroute/checkout/compare/v1.0.0...v1.1.0) — 2026-02-18
88
+
89
+ ### Added
90
+
91
+ - DigiPin badge overlay on map
92
+ - Locality alternatives dropdown
93
+ - OSM address pre-fill (building, road, suburb)
94
+ - India boundary GeoJSON overlay
95
+
96
+ ## [1.0.0](https://github.com/quantaroute/checkout/releases/tag/v1.0.0) — 2026-02-17
97
+
98
+ ### Added
99
+
100
+ - Web checkout widget with MapLibre GL + Carto Positron
101
+ - Offline DigiPin generation and QuantaRoute API integration
102
+ - Mobile-first layout, dark mode, reduced-motion, keyboard accessibility
103
+
package/README.md CHANGED
@@ -326,6 +326,8 @@ As India Post promotes DigiPin nationally, buyers can paste their 10-character c
326
326
 
327
327
  When `enablePhoneAuth` is true the widget starts with a phone-entry step. Returning buyers can pick a previously saved address from any brand in the network instead of dropping the pin again.
328
328
 
329
+ On the address details step, buyers choose a **Home / Work / Other** label before saving. The label is stored in the checkout-addresses API and returned on `CompleteAddress.label`.
330
+
329
331
  **Requires:**
330
332
 
331
333
  1. A merchant account — sign up at [developers.quantaroute.com/onboarding](https://developers.quantaroute.com/onboarding/merchant) to get your `merchantId` and `supabaseFunctionBaseUrl`.
@@ -380,6 +382,8 @@ When `enableEmailAuth` is true the widget starts with an email-entry step. The b
380
382
 
381
383
  #### Setting up Resend (required for `enableEmailAuth`)
382
384
 
385
+ > **Hosted merchants (recommended):** If you onboarded at [developers.quantaroute.com](https://developers.quantaroute.com), QuantaRoute already runs Resend on shared infrastructure. Skip steps 1–5 below — just set `enableEmailAuth={true}` and register your domain in the portal. The steps below apply only when **self-hosting** the `checkout-email-otp` Edge Function in your own Supabase project.
386
+
383
387
  1. **Create a Resend account** at [resend.com](https://resend.com) — free tier covers ~3 000 emails / month.
384
388
 
385
389
  2. **Verify your sending domain** (e.g. `checkout.yourbrand.com` or `yourbrand.com`):
@@ -532,9 +536,16 @@ interface CompleteAddress {
532
536
  streetName: string; // "MG Road, Action Area" (OSM pre-filled)
533
537
 
534
538
  formattedAddress: string; // "4B, 3rd Floor, Sunshine Apartments, MG Road, ..."
539
+ label?: 'home' | 'work' | 'other'; // chosen on address form; defaults to home
535
540
  }
536
541
  ```
537
542
 
543
+ When `enablePhoneAuth` or `enableEmailAuth` is on, the widget persists the address via `createAddress()` using this label.
544
+
545
+ ```ts
546
+ type AddressLabel = 'home' | 'work' | 'other';
547
+ ```
548
+
538
549
  ---
539
550
 
540
551
  ## Advanced usage
@@ -644,7 +655,7 @@ In the [Supabase Dashboard](https://supabase.com/dashboard) → your project →
644
655
 
645
656
  ### 4 · Add your domain to the allowed list
646
657
 
647
- In the developer portal at **[developers.quantaroute.com/dashboard/checkout](https://developers.quantaroute.com/dashboard/checkout)**, add your storefront's domain (e.g. `yourbrand.com`). The `checkout-otp` Edge Function enforces this list to block abuse.
658
+ In the developer portal at **[developers.quantaroute.com/dashboard/checkout](https://developers.quantaroute.com/dashboard/checkout)**, add your storefront's domain (e.g. `yourbrand.com`). The `checkout-email-otp` and `checkout-otp` Edge Functions enforce this list — requests from unlisted origins receive `403 Origin not allowed`.
648
659
 
649
660
  ### Minimal Next.js integration
650
661
 
@@ -769,12 +780,75 @@ The offline DigiPin algorithm is the official India Post implementation:
769
780
 
770
781
  | Doc | Description |
771
782
  |-----|-------------|
783
+ | [Changelog](./CHANGELOG.md) | Version history and release notes |
772
784
  | [Checkout roadmap](./docs/CHECKOUT_ROADMAP.md) | Feature phases and implementation status |
773
785
  | [MSG91 OTP setup](./docs/MSG91_INDIA_OTP_SETUP.md) | India SMS / DLT configuration for phone OTP |
774
786
  | [Brand teardown](./docs/brand-teardown.md) | Competitive analysis (Shopflo) |
775
787
 
776
788
  ---
777
789
 
790
+ ## Security & integration
791
+
792
+ ### What ships in the npm package
793
+
794
+ The published tarball contains **no secrets** — only client-side widget code:
795
+
796
+ | Included | Excluded |
797
+ |---|---|
798
+ | `dist/lib/*.js` (Terser-minified ES + UMD) | `supabase/`, Edge Functions, migrations |
799
+ | `dist/lib/index.d.ts` | `demo/`, `docs/`, `openapi.yaml`, `.env*` |
800
+ | `dist/style.css` | `vite.config.ts`, dev tooling |
801
+ | `src/` (required for React Native / Metro) | `node_modules/` |
802
+
803
+ - **Geocoding `apiKey`** (`dp_…`) is designed for the browser bundle — rate-limited, scoped to your merchant plan.
804
+ - **Admin API key** (`qca_…`) must **never** ship in frontend code. Use it server-side only (`x-api-key` on `checkout-admin`).
805
+ - OTP delivery (Resend) and session minting run on **QuantaRoute-hosted Edge Functions**, not inside the npm bundle.
806
+ - **Consistent email OTP:** the same 6-digit code is stored per `(email, merchant)` and reused for up to **10 successful logins** (not single-use). Repeat send requests skip Resend when the code is still active. This reduces email cost but is weaker than banking-grade OTP — document for your shoppers if required by policy.
807
+
808
+ Verify before every publish:
809
+
810
+ ```bash
811
+ npm run type-check && npm run build:lib
812
+ npm pack --dry-run # confirm 36 files, no .env / supabase / demo
813
+ rg -i 're_|sk_|service.role|password' dist/ # should return no matches
814
+ ```
815
+
816
+ ### Merchant integration checklist (email OTP on web)
817
+
818
+ Use this when embedding `@quantaroute/checkout` on a **hosted QuantaRoute** storefront (onboarded via [developers.quantaroute.com](https://developers.quantaroute.com)):
819
+
820
+ 1. **Onboard** — complete [merchant onboarding](https://developers.quantaroute.com/onboarding/merchant); copy `merchantId`, geocoding `apiKey`, and `supabaseFunctionBaseUrl` from the wizard or [Checkout dashboard](https://developers.quantaroute.com/dashboard/checkout).
821
+ 2. **Install** — `npm install @quantaroute/checkout maplibre-gl` (+ CSS imports).
822
+ 3. **Env vars** — expose only public values (`NEXT_PUBLIC_QUANTAROUTE_KEY`, `NEXT_PUBLIC_MERCHANT_ID`, `NEXT_PUBLIC_SUPABASE_FUNCTION_URL`). Never commit `.env` to git.
823
+ 4. **Allowed domains** — in the developer portal, add every origin that will host the widget (e.g. `yourbrand.com`, `www.yourbrand.com`, `*.yourbrand.com` for subdomains). Both `checkout-otp` and `checkout-email-otp` reject requests from unlisted origins.
824
+ 5. **Enable auth** — set `enableEmailAuth={true}` with `merchantId` and `supabaseFunctionBaseUrl`. Auth is **opt-in** and **web-only** today (React Native widget does not include the email OTP steps).
825
+ 6. **Optional branding** — `brandColor`, `logoUrl`; per-merchant email template columns (`email_from_name`, `email_logo_url`, `email_subject_template`) in the portal.
826
+ 7. **Handle completion** — implement `onComplete` to pass the `CompleteAddress` to your cart / payment gateway. Built-in payment (`enablePayment`) and COD (`enableCod`) are separate opt-in props.
827
+
828
+ > **Resend is platform-managed for hosted merchants.** QuantaRoute operates the shared `checkout-email-otp` Edge Function and Resend sender (`RESEND_API_KEY`, `RESEND_FROM_EMAIL`). Merchants do **not** need their own Resend account for the hosted MVP. See [Setting up Resend](#setting-up-resend-required-for-enableemailauth) only if you self-host the Edge Functions.
829
+
830
+ ### Platform responsibilities (QuantaRoute)
831
+
832
+ | Item | Owner |
833
+ |---|---|
834
+ | Deploy & operate `checkout-email-otp`, `checkout-addresses`, `checkout-session-expiry` | QuantaRoute |
835
+ | `RESEND_API_KEY`, `RESEND_FROM_EMAIL`, Supabase service role | QuantaRoute (Edge Function secrets) |
836
+ | `checkout.merchants` provisioning, `allowed_domains`, email template columns | QuantaRoute portal + DB |
837
+ | Buyer OTP consistent reuse (10 logins per code), fresh-code limit (3 / 24h), verify lockout (5 fails → 15 min) | Edge Function |
838
+ | Geocoding API key issuance & plan rate limits | QuantaRoute |
839
+
840
+ ### Maintainer publish checklist
841
+
842
+ When publishing a new version to npm (maintainers only):
843
+
844
+ 1. Enable **npm 2FA** on the `@quantaroute` org account (publish + modify).
845
+ 2. Run `npm run type-check && npm run build:lib && npm pack --dry-run` — confirm tarball contents.
846
+ 3. Confirm no `.env`, `.pem`, or `supabase/` paths in the pack list.
847
+ 4. Publish from a **clean git tag** with provenance: `npm publish --provenance --access public`.
848
+ 5. Do **not** bump version in the same change unless releasing; current version is `1.4.0`.
849
+
850
+ ---
851
+
778
852
  ## Development
779
853
 
780
854
  ```bash
@@ -807,54 +881,7 @@ npx expo run:android # requires Android Studio
807
881
 
808
882
  ## Changelog
809
883
 
810
- ### v1.4.0 (current)
811
-
812
- - **Email OTP auth** — `enableEmailAuth` prop; `EmailStep` / `EmailOtpStep` components; `checkout-email-otp` Edge Function (Resend); no TRAI dependency
813
- - **Per-merchant email template** — `email_from_name`, `email_logo_url`, `email_subject_template` columns on `checkout.merchants`; `{code}` / `{brand}` placeholders in subject
814
- - **COD controls** — `enableCod` prop + `CodAvailabilityBanner`; `cod_blocked_pincodes[]`, `cod_max_cart_value_paise`, `enable_cod` on merchant row; `checkCodEligibility()` in SDK
815
- - **Server-side webhooks** — `session.phone_verified`, `session.email_verified`, `session.address_completed`, `session.expired`; HMAC-SHA256 signed; 3-retry delivery log in `checkout.webhook_deliveries`
816
- - **Automatic session expiry** — `checkout-session-expiry` Edge Function; pg_cron job fires every 10 min
817
- - **New SDK exports** — `sendEmailOtp`, `verifyEmailOtp`, `VerifyEmailOtpResult`, `checkCodEligibility`, `notifyAddressCompleted`
818
- - **Event types** — added `email_step_viewed`, `email_otp_sent`, `email_verified` to `onCheckoutEvent`
819
-
820
- ### v1.3.x
821
-
822
- - **Phone OTP + saved addresses** — `enablePhoneAuth`, `merchantId`, `supabaseFunctionBaseUrl` props; `PhoneStep`, `OtpStep`, `SavedAddressStep` components
823
- - **Address autocomplete + DigiPin search** — unified search bar via `enableSearch`; "near me" / location-biased 3-pass Nominatim strategy on backend
824
- - **Pincode validation** — `validatePincode()` in `AddressForm`; fake codes (e.g. `123456`) are blocked with an inline error; non-delivery areas show a warning banner
825
- - **Per-merchant branding** — `brandColor` (hex), `logoUrl`, `headerBanner`; map pin and all accent elements use the brand colour on web and native
826
- - **Cross-merchant "Saved at [Brand]" chip** — address cards show the brand name where the address was first saved
827
- - **Client-side analytics hook** — `onCheckoutEvent` fires on every step transition for MoEngage / GTM / custom backends
828
- - `CheckoutEvent` and `CheckoutEventType` exported from the package
829
- - Checkout API client (`checkout-api.ts`) and types exported (`sendOtp`, `verifyOtp`, `listAddresses`, `createAddress`, `deleteAddress`, `setDefaultAddress`)
830
-
831
- ### v1.2.0
832
-
833
- - **iOS & Android support** via `expo-osm-sdk` (MapLibre GL Native)
834
- - `MapPinSelector.native.tsx` — draggable OSMView pin
835
- - `AddressForm.native.tsx` — `TextInput` / `ScrollView` / `Modal` locality picker
836
- - `CheckoutWidget.native.tsx` — `SafeAreaView` layout with identical flow logic
837
- - `useGeolocation.native.ts` — GPS via `expo-location`
838
- - `checkout.native.ts` — complete `StyleSheet` design system (light + dark)
839
- - `expo-plugin.js` — one-line `app.json` setup for iOS/Android
840
- - `babel.config.js` — Metro transpilation config
841
- - `mapHeight` prop now accepts `number` (native) or `string` (web, e.g. `'380px'`)
842
- - All native peer dependencies marked optional (zero impact on web bundles)
843
-
844
- ### v1.1.x
845
-
846
- - DigiPin badge overlay on map
847
- - Locality alternatives dropdown
848
- - OSM address pre-fill (building name, road, suburb)
849
- - India boundary GeoJSON overlay
850
-
851
- ### v1.0.0
852
-
853
- - Initial release: MapLibre GL + Carto Positron
854
- - Offline DigiPin generation
855
- - QuantaRoute API integration
856
- - Mobile-first responsive design
857
- - Dark mode, reduced-motion, keyboard accessible
884
+ See [CHANGELOG.md](./CHANGELOG.md) for version history. Current release: **v1.4.1**.
858
885
 
859
886
  ---
860
887
 
@@ -1,6 +1,8 @@
1
1
  import { default as default_2 } from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
+ export declare const ADDRESS_LABELS: AddressLabel[];
5
+
4
6
  /**
5
7
  * Address components from Nominatim/OpenStreetMap (via reverse geocoding).
6
8
  */
@@ -36,6 +38,9 @@ export declare interface AddressFormProps {
36
38
  theme?: 'light' | 'dark';
37
39
  }
38
40
 
41
+ /** Label for a saved buyer address — stored in checkout-addresses API. */
42
+ export declare type AddressLabel = 'home' | 'work' | 'other';
43
+
39
44
  export declare interface AdministrativeInfo {
40
45
  country?: string;
41
46
  state: string;
@@ -349,6 +354,8 @@ export declare interface CompleteAddress {
349
354
  streetName: string;
350
355
  /** Combined formatted address string */
351
356
  formattedAddress: string;
357
+ /** Buyer-chosen label for saved-address book (defaults to home) */
358
+ label?: AddressLabel;
352
359
  }
353
360
 
354
361
  export declare interface Coordinates {
@@ -403,6 +410,8 @@ export declare const EmailOtpStep: default_2.FC<EmailOtpStepProps>;
403
410
 
404
411
  export declare interface EmailOtpStepProps {
405
412
  email: string;
413
+ /** When true, no new email was sent — shopper should use their existing code. */
414
+ codeReused?: boolean;
406
415
  onVerified: (sessionToken: string, buyerId: string, sessionId?: string) => void;
407
416
  onBack: () => void;
408
417
  functionBaseUrl: string;
@@ -413,8 +422,10 @@ export declare interface EmailOtpStepProps {
413
422
  export declare const EmailStep: default_2.FC<EmailStepProps>;
414
423
 
415
424
  export declare interface EmailStepProps {
416
- /** Called with the normalised (lowercased) email once OTP is dispatched. */
417
- onOtpSent: (email: string) => void;
425
+ /** Called with the normalised (lowercased) email once OTP is ready (sent or reused). */
426
+ onOtpSent: (email: string, info?: {
427
+ reused?: boolean;
428
+ }) => void;
418
429
  onSkip: () => void;
419
430
  functionBaseUrl: string;
420
431
  merchantId: string;
@@ -720,7 +731,12 @@ export declare interface SavedAddressStepProps {
720
731
  }
721
732
 
722
733
  /** Send a 6-digit OTP to the given email via Resend (Edge: `checkout-email-otp`). */
723
- export declare function sendEmailOtp(config: CheckoutApiConfig, email: string): Promise<void>;
734
+ export declare function sendEmailOtp(config: CheckoutApiConfig, email: string): Promise<SendEmailOtpResult>;
735
+
736
+ /** Result from send email OTP — includes whether an existing code was reused (no new email). */
737
+ export declare interface SendEmailOtpResult {
738
+ reused: boolean;
739
+ }
724
740
 
725
741
  /** Send OTP to the given mobile number. Throws on failure. */
726
742
  export declare function sendOtp(config: CheckoutApiConfig, mobile: string): Promise<void>;