@movmo_app/types 1.26.0 → 1.28.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/README.md CHANGED
@@ -27,15 +27,13 @@ Import the types you need in your TypeScript files:
27
27
  import {
28
28
  MovmoFlightOffer,
29
29
  FlightOfferDataSource,
30
- MovmoFrameMessageType,
31
- isTrustedOrigin,
30
+ MovmoExitReason,
32
31
  } from '@movmo_app/types';
33
32
 
34
33
  const dataSource: FlightOfferDataSource = FlightOfferDataSource.Amadeus;
35
34
  ```
36
35
 
37
- Field names are **snake_case** to match the Go backend's JSON — with one deliberate exception: the
38
- cross-frame `postMessage` payloads in `postmessage_contracts` are camelCase (browser convention).
36
+ Field names are **snake_case** to match the Go backend's JSON.
39
37
 
40
38
  ## Available Modules
41
39
 
@@ -53,11 +51,7 @@ Everything below is re-exported from the package root (see `src/index.ts`):
53
51
  - `referrals` — referral types
54
52
  - `identity` — identity-partner directory types (`IdentityPartner`, `mapIdentityPartners`)
55
53
  - `scope_copy` — shared OAuth scope display copy (one source of truth for consent-screen wording)
56
- - `postmessage_contracts` — the cross-frame `postMessage` contract shared by flights-ui and the
57
- `@movmo/express-checkout-button` / `@movmo/connect-button` embeds: `MovmoFrameMessageType`
58
- (READY/INIT handshake, booking outcomes, `RECOGNITION_STATE`/`RECOGNITION_TOKEN`/
59
- `RECOGNITION_RESIZE`/`RECOGNITION_CONNECT`/`RECOGNITION_ERROR`), the per-message payload
60
- interfaces, the origin allowlists, and `isTrustedOrigin`
54
+ - `express_checkout` — `MovmoExitReason`, the Express Checkout SDK `onExit` reason union
61
55
  - `types` — small shared helpers
62
56
 
63
57
  Conventions: `type` for DTOs, `interface` for extensible contracts, `enum` for fixed value sets
package/dist/auth.d.ts CHANGED
@@ -41,7 +41,7 @@ export type MovmoVerifyResponse = {
41
41
  export type MovmoRecoveryCancelRequest = {
42
42
  token: string;
43
43
  };
44
- export type AuthErrorCode = 'invalid_email' | 'rate_limited' | 'resend_too_soon' | 'flow_expired' | 'invalid_code' | 'too_many_attempts' | 'invalid_request' | 'invalid_credential' | 'topOrigin_required' | 'passkey_limit' | 'credential_exists' | 'not_found' | 'reauth_required' | 'movmo_session_required' | 'first_party_only' | 'issuer_unavailable' | 'passkey_failed' | 'sign_in_failed' | 'recovery_required' | 'recovery_blocked' | 'recovery_cooldown' | 'code_sends_paused';
44
+ export type AuthErrorCode = 'invalid_email' | 'rate_limited' | 'resend_too_soon' | 'flow_expired' | 'invalid_code' | 'too_many_attempts' | 'invalid_request' | 'invalid_credential' | 'passkey_limit' | 'credential_exists' | 'not_found' | 'reauth_required' | 'movmo_session_required' | 'first_party_only' | 'issuer_unavailable' | 'passkey_failed' | 'sign_in_failed' | 'recovery_required' | 'recovery_blocked' | 'recovery_cooldown' | 'code_sends_paused';
45
45
  /**
46
46
  * ContactType represents the types of contact information that can be changed
47
47
  * through the contact-change flow (initiate, verify-identity, confirm).
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Why the checkout handed control back to the airline page (MOVMO-474). Part of the Express
3
+ * Checkout SDK return contract (`onExit`).
4
+ *
5
+ * 'booking_confirmed' (MOVMO-521) is the success-path exit: the traveler clicked
6
+ * "Return to {airline}" on the booking confirmation.
7
+ */
8
+ export type MovmoExitReason = 'search_again' | 'offer_unavailable' | 'booking_confirmed';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export * from './sessions';
13
13
  export * from './booking_passenger';
14
14
  export * from './movmo_flight_offer';
15
15
  export * from './locale_preferences';
16
- export * from './postmessage_contracts';
16
+ export * from './express_checkout';
17
17
  export * from './identity';
18
18
  export * from './scope_copy';
19
19
  export * from './passkeys';
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ __exportStar(require("./sessions"), exports);
29
29
  __exportStar(require("./booking_passenger"), exports);
30
30
  __exportStar(require("./movmo_flight_offer"), exports);
31
31
  __exportStar(require("./locale_preferences"), exports);
32
- __exportStar(require("./postmessage_contracts"), exports);
32
+ __exportStar(require("./express_checkout"), exports);
33
33
  __exportStar(require("./identity"), exports);
34
34
  __exportStar(require("./scope_copy"), exports);
35
35
  __exportStar(require("./passkeys"), exports);
@@ -16,3 +16,18 @@ export type PasskeyRegistrationStart = {
16
16
  flow_id: string;
17
17
  options: WebAuthnOptionsJSON;
18
18
  };
19
+ /**
20
+ * `GET /v1/users/me/passkeys` (MOVMO-738). The four optional keys are present
21
+ * only when the user has at least one passkey, and are absent on a monolith
22
+ * that predates the WebAuthn Signal API support. `user_name` and
23
+ * `user_display_name` are exactly what the server registered with the
24
+ * authenticator; clients pass them through and never recompute them.
25
+ */
26
+ export interface PasskeyListResponse {
27
+ passkeys: PasskeySummary[];
28
+ /** base64url, no padding: the WebAuthn user handle. */
29
+ user_handle?: string;
30
+ rp_id?: string;
31
+ user_name?: string;
32
+ user_display_name?: string;
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movmo_app/types",
3
- "version": "1.26.0",
3
+ "version": "1.28.0",
4
4
  "description": "A collection of Movmo's types",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,157 +0,0 @@
1
- /**
2
- * postMessage contract between the Movmo recognition iframe (flights-ui `/recognize`) and the
3
- * embedding parent page (`@movmo/connect-button`). Checkout no longer runs in a frame: there
4
- * are no checkout messages here, only the handshake and the recognition messages.
5
- *
6
- * Both sides SHOULD coordinate exclusively via `window.postMessage` — no direct
7
- * cross-frame DOM access — validating every message against a strict origin allowlist in
8
- * both directions:
9
- *
10
- * - The PARENT should validate inbound messages against {@link MOVMO_FLIGHTS_ORIGINS}
11
- * ("is this really the Movmo iframe I embedded?").
12
- * - The IFRAME should validate the inbound handshake against {@link MOVMO_PARTNER_ORIGINS}
13
- * ("is this parent page allowed to embed me?").
14
- *
15
- * Handshake: on load the iframe posts {@link MovmoFrameMessageType.READY} (content-free)
16
- * to `"*"`; the parent replies with {@link MovmoFrameMessageType.INIT} carrying its own
17
- * origin, targeted at the iframe's origin. The iframe captures that origin so every
18
- * subsequent message goes to a specific origin instead of `"*"`.
19
- *
20
- * Note: payload field names are camelCase (browser `postMessage` data), a deliberate
21
- * departure from the snake_case Go-DTO convention used elsewhere in this package. Keep
22
- * them camelCase — the cross-repo consumers read these exact keys off the wire.
23
- */
24
- export declare enum MovmoFrameMessageType {
25
- /** iframe → parent: posted on load so the parent replies with INIT. Content-free. */
26
- READY = "MOVMO_READY",
27
- /** parent → iframe: handshake reply carrying the parent's origin so the iframe can
28
- * target subsequent messages instead of using `"*"`. */
29
- INIT = "MOVMO_INIT",
30
- /**
31
- * iframe → parent: the recognition surface's current state. Carries NO identity data by
32
- * design — PII and the durable GUID never cross the browser. Parents use this purely to
33
- * decide what to render (nothing / anonymous chip / recognized chip).
34
- */
35
- RECOGNITION_STATE = "MOVMO_RECOGNITION_STATE",
36
- /**
37
- * iframe → parent: the short-lived (120s), single-use recognition token the airline page
38
- * forwards to its own backend. This is the ONLY identity-bearing value that ever crosses
39
- * the frame boundary, and it is opaque to the parent — the parent cannot read identity out
40
- * of it, only redeem it server-side.
41
- */
42
- RECOGNITION_TOKEN = "MOVMO_RECOGNITION_TOKEN",
43
- /** iframe → parent: requested wrapper size for banner/chip transitions. */
44
- RECOGNITION_RESIZE = "MOVMO_RECOGNITION_RESIZE",
45
- /**
46
- * iframe → parent: a user gesture requesting the parent start the Movmo OAuth (Flow A)
47
- * redirect.
48
- */
49
- RECOGNITION_CONNECT = "MOVMO_RECOGNITION_CONNECT",
50
- /**
51
- * iframe → parent: the recognition surface hit an internal failure (e.g. the
52
- * recognition-token mint errored) and could not complete (MOVMO-547). Always
53
- * accompanied by a RECOGNITION_STATE settling the surface (today: 'anonymous'),
54
- * so parents that ignore this message still render a consistent state — it exists
55
- * so the airline host can OBSERVE the failure (telemetry, fallback UX) instead of
56
- * mistaking it for an ordinary anonymous visitor.
57
- *
58
- * Privacy invariant (see RECOGNITION_STATE): the payload carries NO identity data
59
- * and the `code` is deliberately coarse — it must never reveal which internal call
60
- * failed, since that could imply the visitor's Movmo auth state before consent.
61
- */
62
- RECOGNITION_ERROR = "MOVMO_RECOGNITION_ERROR",
63
- /**
64
- * iframe → parent: the traveler clicked "Not you?" inside the recognition surface and
65
- * Movmo has already signed them out of Movmo in this browser (cookies only; other
66
- * devices unaffected). Sent once, always followed by `RECOGNITION_STATE 'anonymous'`.
67
- * Not sent on chip dismissal. The airline should clear its own session for this
68
- * traveler (greeting, pre-fill, any cookie carrying the GUID) — a GUID stored against
69
- * an authenticated airline account stays valid; sign-out is not consent revocation
70
- * (MOVMO-670).
71
- */
72
- RECOGNITION_SIGNED_OUT = "MOVMO_RECOGNITION_SIGNED_OUT"
73
- }
74
- export interface MovmoReadyMessage {
75
- type: MovmoFrameMessageType.READY;
76
- }
77
- export interface MovmoInitMessage {
78
- type: MovmoFrameMessageType.INIT;
79
- /** Origin of the embedding parent page; the iframe targets this for outbound messages. */
80
- parentOrigin: string;
81
- }
82
- /**
83
- * Why the checkout handed control back to the airline page (MOVMO-474). Part of the SDK
84
- * return contract (`onExit`), not a postMessage.
85
- *
86
- * 'booking_confirmed' (MOVMO-521) is the success-path exit: the traveler clicked
87
- * "Return to {airline}" on the booking confirmation.
88
- */
89
- export type MovmoExitReason = 'search_again' | 'offer_unavailable' | 'booking_confirmed';
90
- export interface MovmoRecognitionStateMessage {
91
- type: MovmoFrameMessageType.RECOGNITION_STATE;
92
- state: 'recognized' | 'anonymous' | 'none';
93
- }
94
- export interface MovmoRecognitionTokenMessage {
95
- type: MovmoFrameMessageType.RECOGNITION_TOKEN;
96
- token: string;
97
- }
98
- export interface MovmoRecognitionResizeMessage {
99
- type: MovmoFrameMessageType.RECOGNITION_RESIZE;
100
- width: number;
101
- height: number;
102
- }
103
- export interface MovmoRecognitionConnectMessage {
104
- type: MovmoFrameMessageType.RECOGNITION_CONNECT;
105
- }
106
- export interface MovmoRecognitionErrorMessage {
107
- type: MovmoFrameMessageType.RECOGNITION_ERROR;
108
- /**
109
- * Coarse machine-readable code. Known values: `recognition_failed` (the surface
110
- * could not complete recognition due to a service error). Typed as `string` so
111
- * older parents keep compiling/forwarding when newer iframes add codes.
112
- */
113
- code: string;
114
- /** Human-readable detail for the airline's logs. Never identity data. */
115
- message: string;
116
- }
117
- export interface MovmoRecognitionSignedOutMessage {
118
- type: MovmoFrameMessageType.RECOGNITION_SIGNED_OUT;
119
- }
120
- /** Discriminated union of every message exchanged across the frame boundary. */
121
- export type MovmoFrameMessage = MovmoReadyMessage | MovmoInitMessage | MovmoRecognitionStateMessage | MovmoRecognitionTokenMessage | MovmoRecognitionResizeMessage | MovmoRecognitionConnectMessage | MovmoRecognitionErrorMessage | MovmoRecognitionSignedOutMessage;
122
- /** A per-environment origin allowlist (production vs. everything else). */
123
- export interface MovmoOriginAllowlist {
124
- prod: readonly string[];
125
- nonProd: readonly string[];
126
- }
127
- /**
128
- * Origins served by Movmo's flights-ui iframe. The PARENT
129
- * (`@movmo/express-checkout-button`) validates inbound messages against this list.
130
- */
131
- export declare const MOVMO_FLIGHTS_ORIGINS: MovmoOriginAllowlist;
132
- /**
133
- * Airline-partner origins permitted to embed the flights-ui iframe. The IFRAME
134
- * (flights-ui) validates the inbound handshake against this list.
135
- *
136
- * `prod` is intentionally empty until a real partner goes live in production; populate it
137
- * (or move it server-side, keyed by airline) as partners launch. The non-prod entries are
138
- * the cross-domain demo/test harness (MOVMO-430) plus local development.
139
- */
140
- export declare const MOVMO_PARTNER_ORIGINS: MovmoOriginAllowlist;
141
- export interface TrustedOriginOptions {
142
- isProd: boolean;
143
- /**
144
- * Extra origins to trust in NON-PROD only (e.g. an env-injected override URL such as
145
- * `REACT_APP_MOVMO_CHECKOUT_URL`). Ignored when `isProd` is true so a production build
146
- * always keeps its hardcoded allowlist. Entries may be full URLs (origin is extracted)
147
- * and `undefined`/empty values are skipped.
148
- */
149
- extraOrigins?: Array<string | undefined>;
150
- }
151
- /**
152
- * Returns true when `origin` is trusted for the given allowlist and environment.
153
- *
154
- * In production only `list.prod` is consulted (env overrides are ignored). In non-prod,
155
- * `list.nonProd` plus any valid `extraOrigins` are allowed.
156
- */
157
- export declare function isTrustedOrigin(origin: string, list: MovmoOriginAllowlist, { isProd, extraOrigins }: TrustedOriginOptions): boolean;
@@ -1,128 +0,0 @@
1
- "use strict";
2
- /**
3
- * postMessage contract between the Movmo recognition iframe (flights-ui `/recognize`) and the
4
- * embedding parent page (`@movmo/connect-button`). Checkout no longer runs in a frame: there
5
- * are no checkout messages here, only the handshake and the recognition messages.
6
- *
7
- * Both sides SHOULD coordinate exclusively via `window.postMessage` — no direct
8
- * cross-frame DOM access — validating every message against a strict origin allowlist in
9
- * both directions:
10
- *
11
- * - The PARENT should validate inbound messages against {@link MOVMO_FLIGHTS_ORIGINS}
12
- * ("is this really the Movmo iframe I embedded?").
13
- * - The IFRAME should validate the inbound handshake against {@link MOVMO_PARTNER_ORIGINS}
14
- * ("is this parent page allowed to embed me?").
15
- *
16
- * Handshake: on load the iframe posts {@link MovmoFrameMessageType.READY} (content-free)
17
- * to `"*"`; the parent replies with {@link MovmoFrameMessageType.INIT} carrying its own
18
- * origin, targeted at the iframe's origin. The iframe captures that origin so every
19
- * subsequent message goes to a specific origin instead of `"*"`.
20
- *
21
- * Note: payload field names are camelCase (browser `postMessage` data), a deliberate
22
- * departure from the snake_case Go-DTO convention used elsewhere in this package. Keep
23
- * them camelCase — the cross-repo consumers read these exact keys off the wire.
24
- */
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.MOVMO_PARTNER_ORIGINS = exports.MOVMO_FLIGHTS_ORIGINS = exports.MovmoFrameMessageType = void 0;
27
- exports.isTrustedOrigin = isTrustedOrigin;
28
- var MovmoFrameMessageType;
29
- (function (MovmoFrameMessageType) {
30
- /** iframe → parent: posted on load so the parent replies with INIT. Content-free. */
31
- MovmoFrameMessageType["READY"] = "MOVMO_READY";
32
- /** parent → iframe: handshake reply carrying the parent's origin so the iframe can
33
- * target subsequent messages instead of using `"*"`. */
34
- MovmoFrameMessageType["INIT"] = "MOVMO_INIT";
35
- /**
36
- * iframe → parent: the recognition surface's current state. Carries NO identity data by
37
- * design — PII and the durable GUID never cross the browser. Parents use this purely to
38
- * decide what to render (nothing / anonymous chip / recognized chip).
39
- */
40
- MovmoFrameMessageType["RECOGNITION_STATE"] = "MOVMO_RECOGNITION_STATE";
41
- /**
42
- * iframe → parent: the short-lived (120s), single-use recognition token the airline page
43
- * forwards to its own backend. This is the ONLY identity-bearing value that ever crosses
44
- * the frame boundary, and it is opaque to the parent — the parent cannot read identity out
45
- * of it, only redeem it server-side.
46
- */
47
- MovmoFrameMessageType["RECOGNITION_TOKEN"] = "MOVMO_RECOGNITION_TOKEN";
48
- /** iframe → parent: requested wrapper size for banner/chip transitions. */
49
- MovmoFrameMessageType["RECOGNITION_RESIZE"] = "MOVMO_RECOGNITION_RESIZE";
50
- /**
51
- * iframe → parent: a user gesture requesting the parent start the Movmo OAuth (Flow A)
52
- * redirect.
53
- */
54
- MovmoFrameMessageType["RECOGNITION_CONNECT"] = "MOVMO_RECOGNITION_CONNECT";
55
- /**
56
- * iframe → parent: the recognition surface hit an internal failure (e.g. the
57
- * recognition-token mint errored) and could not complete (MOVMO-547). Always
58
- * accompanied by a RECOGNITION_STATE settling the surface (today: 'anonymous'),
59
- * so parents that ignore this message still render a consistent state — it exists
60
- * so the airline host can OBSERVE the failure (telemetry, fallback UX) instead of
61
- * mistaking it for an ordinary anonymous visitor.
62
- *
63
- * Privacy invariant (see RECOGNITION_STATE): the payload carries NO identity data
64
- * and the `code` is deliberately coarse — it must never reveal which internal call
65
- * failed, since that could imply the visitor's Movmo auth state before consent.
66
- */
67
- MovmoFrameMessageType["RECOGNITION_ERROR"] = "MOVMO_RECOGNITION_ERROR";
68
- /**
69
- * iframe → parent: the traveler clicked "Not you?" inside the recognition surface and
70
- * Movmo has already signed them out of Movmo in this browser (cookies only; other
71
- * devices unaffected). Sent once, always followed by `RECOGNITION_STATE 'anonymous'`.
72
- * Not sent on chip dismissal. The airline should clear its own session for this
73
- * traveler (greeting, pre-fill, any cookie carrying the GUID) — a GUID stored against
74
- * an authenticated airline account stays valid; sign-out is not consent revocation
75
- * (MOVMO-670).
76
- */
77
- MovmoFrameMessageType["RECOGNITION_SIGNED_OUT"] = "MOVMO_RECOGNITION_SIGNED_OUT";
78
- })(MovmoFrameMessageType || (exports.MovmoFrameMessageType = MovmoFrameMessageType = {}));
79
- /**
80
- * Origins served by Movmo's flights-ui iframe. The PARENT
81
- * (`@movmo/express-checkout-button`) validates inbound messages against this list.
82
- */
83
- exports.MOVMO_FLIGHTS_ORIGINS = {
84
- prod: ['https://flights.movmo.io'],
85
- nonProd: ['https://flights.e2e.movmo.io', 'http://localhost:3000'],
86
- };
87
- /**
88
- * Airline-partner origins permitted to embed the flights-ui iframe. The IFRAME
89
- * (flights-ui) validates the inbound handshake against this list.
90
- *
91
- * `prod` is intentionally empty until a real partner goes live in production; populate it
92
- * (or move it server-side, keyed by airline) as partners launch. The non-prod entries are
93
- * the cross-domain demo/test harness (MOVMO-430) plus local development.
94
- */
95
- exports.MOVMO_PARTNER_ORIGINS = {
96
- prod: [],
97
- nonProd: [
98
- 'https://mockairline-e2e.app.flyeasyapp.com',
99
- 'https://mockairline-e2e.app.movmoapp.com',
100
- 'http://localhost:3000',
101
- ],
102
- };
103
- /**
104
- * Returns true when `origin` is trusted for the given allowlist and environment.
105
- *
106
- * In production only `list.prod` is consulted (env overrides are ignored). In non-prod,
107
- * `list.nonProd` plus any valid `extraOrigins` are allowed.
108
- */
109
- function isTrustedOrigin(origin, list, { isProd, extraOrigins = [] }) {
110
- if (isProd) {
111
- return list.prod.includes(origin);
112
- }
113
- const allowed = [...list.nonProd];
114
- for (const extra of extraOrigins) {
115
- if (!extra)
116
- continue;
117
- try {
118
- allowed.push(new URL(extra).origin);
119
- }
120
- catch (_a) {
121
- // Stay fail-closed (a bad override never widens trust) but leave a breadcrumb —
122
- // a fat-fingered override URL vanishing silently is a debugging trap in
123
- // security-relevant code.
124
- console.warn(`[movmo] isTrustedOrigin: ignoring malformed extra origin "${extra}"`);
125
- }
126
- }
127
- return allowed.includes(origin);
128
- }