@movmo_app/types 1.15.0 → 1.16.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/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export * from './movmo_flight_offer';
15
15
  export * from './locale_preferences';
16
16
  export * from './postmessage_contracts';
17
17
  export * from './identity';
18
+ export * from './scope_copy';
package/dist/index.js CHANGED
@@ -31,3 +31,4 @@ __exportStar(require("./movmo_flight_offer"), exports);
31
31
  __exportStar(require("./locale_preferences"), exports);
32
32
  __exportStar(require("./postmessage_contracts"), exports);
33
33
  __exportStar(require("./identity"), exports);
34
+ __exportStar(require("./scope_copy"), exports);
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Centralized OAuth scope display copy (MOVMO-455). Single shared source of
3
+ * truth for the plain-language copy shown on consent surfaces — the auth-ui
4
+ * consent screen and accounts-ui's Connected Apps page previously hand-kept
5
+ * two copies of this file in sync (MOVMO-407/408); this package replaces
6
+ * both.
7
+ *
8
+ * Source of truth for the canonical scope *values* is go-services-core/scopes;
9
+ * the copy here matches the approved Figma reference table (MOVMO-441 mock
10
+ * file, page MOVMO-407). Raw scope values are never rendered to the user —
11
+ * GDPR informed consent wants plain language; identifiers live in the OAuth
12
+ * request and the consent record.
13
+ */
14
+ export interface ScopeCopy {
15
+ label: string;
16
+ detail?: string;
17
+ }
18
+ export declare const SCOPE_COPY: Record<string, ScopeCopy>;
19
+ /**
20
+ * When a client requests both `.read` and `.write` of a domain, the UI
21
+ * collapses them into ONE "View and manage" row — both scopes are still
22
+ * granted and recorded individually (write does NOT imply read in the RBAC
23
+ * mapping). `bookings` is the exception: viewing trip history and booking
24
+ * flights are distinct enough to always show separately.
25
+ */
26
+ export declare const PAIR_COPY: Record<string, ScopeCopy>;
27
+ /**
28
+ * A single row a consent/scope-management UI renders. `key` is a stable
29
+ * identifier for the row (e.g. `"profile"` for a collapsed pair, or the raw
30
+ * scope value itself for an unpaired/unknown scope) — use it as a React
31
+ * `key` or as the id a toggle/checkbox binds to. `scopes` is the underlying
32
+ * raw scope value(s) this row represents, so granular per-scope UIs (MOVMO-455)
33
+ * know exactly which scopes to grant or withhold when the row is
34
+ * toggled — a collapsed read+write pair carries both raw scopes, an unpaired
35
+ * or unknown scope carries just itself.
36
+ */
37
+ export interface ScopeDisplayRow extends ScopeCopy {
38
+ key: string;
39
+ scopes: string[];
40
+ }
41
+ /**
42
+ * displayRows converts a scope list into the rows a consent/scope-management
43
+ * UI renders, collapsing read+write pairs (except bookings) and preserving
44
+ * first-appearance order. Unknown scopes fall back to their raw value so a
45
+ * newer backend scope never renders as an empty row.
46
+ */
47
+ export declare function displayRows(scopes: string[]): ScopeDisplayRow[];
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ /**
3
+ * Centralized OAuth scope display copy (MOVMO-455). Single shared source of
4
+ * truth for the plain-language copy shown on consent surfaces — the auth-ui
5
+ * consent screen and accounts-ui's Connected Apps page previously hand-kept
6
+ * two copies of this file in sync (MOVMO-407/408); this package replaces
7
+ * both.
8
+ *
9
+ * Source of truth for the canonical scope *values* is go-services-core/scopes;
10
+ * the copy here matches the approved Figma reference table (MOVMO-441 mock
11
+ * file, page MOVMO-407). Raw scope values are never rendered to the user —
12
+ * GDPR informed consent wants plain language; identifiers live in the OAuth
13
+ * request and the consent record.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.PAIR_COPY = exports.SCOPE_COPY = void 0;
17
+ exports.displayRows = displayRows;
18
+ exports.SCOPE_COPY = {
19
+ 'profile.read': {
20
+ label: 'View your profile',
21
+ detail: 'Name and contact details',
22
+ },
23
+ 'profile.write': {
24
+ label: 'Update your profile',
25
+ detail: 'Including your profile photo',
26
+ },
27
+ 'preferences.read': {
28
+ label: 'View your travel preferences',
29
+ detail: 'Seat, meal, and assistance preferences; language and currency',
30
+ },
31
+ 'preferences.write': {
32
+ label: 'Update your travel preferences',
33
+ },
34
+ 'passengers.read': {
35
+ label: 'View your saved travelers',
36
+ detail: 'Including travel document details',
37
+ },
38
+ 'passengers.write': {
39
+ label: 'Add, update, and remove saved travelers',
40
+ },
41
+ 'payments.read': {
42
+ label: 'View saved payment methods',
43
+ detail: 'Card brand and last 4 digits only — never full numbers',
44
+ },
45
+ 'payments.write': {
46
+ label: 'Update or remove saved payment methods',
47
+ detail: 'Cannot add new cards',
48
+ },
49
+ 'bookings.read': {
50
+ label: 'View your bookings and trip history',
51
+ },
52
+ 'bookings.write': {
53
+ label: 'Search and book flights',
54
+ detail: 'Bookings are charged to a saved payment method',
55
+ },
56
+ };
57
+ /**
58
+ * When a client requests both `.read` and `.write` of a domain, the UI
59
+ * collapses them into ONE "View and manage" row — both scopes are still
60
+ * granted and recorded individually (write does NOT imply read in the RBAC
61
+ * mapping). `bookings` is the exception: viewing trip history and booking
62
+ * flights are distinct enough to always show separately.
63
+ */
64
+ exports.PAIR_COPY = {
65
+ profile: {
66
+ label: 'View and manage your profile',
67
+ detail: 'Name, contact details, and profile photo',
68
+ },
69
+ preferences: {
70
+ label: 'View and manage your travel preferences',
71
+ detail: 'Update seat, meal, and assistance preferences you’ve saved',
72
+ },
73
+ passengers: {
74
+ label: 'View and manage saved travelers',
75
+ detail: 'Add, update, and remove travelers — including travel document details',
76
+ },
77
+ payments: {
78
+ label: 'View and manage saved payment methods',
79
+ detail: 'Card brand and last 4 digits only — never full numbers. Can’t add new cards.',
80
+ },
81
+ };
82
+ /**
83
+ * displayRows converts a scope list into the rows a consent/scope-management
84
+ * UI renders, collapsing read+write pairs (except bookings) and preserving
85
+ * first-appearance order. Unknown scopes fall back to their raw value so a
86
+ * newer backend scope never renders as an empty row.
87
+ */
88
+ function displayRows(scopes) {
89
+ const set = new Set(scopes);
90
+ const emittedDomains = new Set();
91
+ const rows = [];
92
+ for (const scope of scopes) {
93
+ const [domain] = scope.split('.');
94
+ const pair = exports.PAIR_COPY[domain];
95
+ const hasBoth = set.has(`${domain}.read`) && set.has(`${domain}.write`);
96
+ if (pair && hasBoth) {
97
+ if (!emittedDomains.has(domain)) {
98
+ emittedDomains.add(domain);
99
+ rows.push(Object.assign(Object.assign({}, pair), { key: domain, scopes: [`${domain}.read`, `${domain}.write`] }));
100
+ }
101
+ continue;
102
+ }
103
+ const copy = exports.SCOPE_COPY[scope];
104
+ rows.push(copy
105
+ ? Object.assign(Object.assign({}, copy), { key: scope, scopes: [scope] }) : { label: scope, key: scope, scopes: [scope] });
106
+ }
107
+ return rows;
108
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@movmo_app/types",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "A collection of Movmo's types",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",