@drawbridge/drawbridge-utils 0.0.43 → 0.0.44

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.
@@ -32,11 +32,14 @@ __export(oauth_exports, {
32
32
  compare: () => compare,
33
33
  createOAuthClient: () => createOAuthClient,
34
34
  developer: () => developer,
35
+ developerOptions: () => developerOptions,
35
36
  generateToken: () => generateToken,
36
37
  hashToken: () => hashToken,
37
38
  intersect: () => intersect,
38
39
  isDeveloperAllowed: () => isDeveloperAllowed,
39
40
  parse: () => parse,
41
+ scopeLabels: () => scopeLabels,
42
+ scopeOptions: () => scopeOptions,
40
43
  scopes: () => scopes,
41
44
  validate: () => validate
42
45
  });
@@ -113,6 +116,29 @@ var intersect = (requested, allowed) => {
113
116
  return r.filter((scope) => a.includes(scope));
114
117
  };
115
118
  var isDeveloperAllowed = (scope) => developer.includes(scope);
119
+ var scopeLabels = {
120
+ "profile:read": "Read own profile",
121
+ "profile:write": "Update own profile",
122
+ "organization:read": "Read organization info",
123
+ "organization:write": "Manage organization",
124
+ "campaigns:read": "Read campaigns",
125
+ "campaigns:write": "Manage campaigns",
126
+ "contacts:read": "Read contacts",
127
+ "contacts:write": "Manage contacts",
128
+ "workflows:read": "Read workflows",
129
+ "workflows:write": "Manage workflows",
130
+ "connections:read": "Read integrations",
131
+ "connections:write": "Manage integrations",
132
+ "billing:read": "Read billing",
133
+ "billing:write": "Manage billing",
134
+ admin: "Admin access"
135
+ };
136
+ var toOption = (scope) => ({
137
+ key: scopeLabels[scope] || scope,
138
+ value: scope
139
+ });
140
+ var developerOptions = developer.map(toOption);
141
+ var scopeOptions = scopes.map(toOption);
116
142
  var hashToken = (raw) => hash(raw, process.env.OAUTH_TOKEN_HMAC_KEY);
117
143
  var generateToken = () => generate(32, "base64url");
118
144
  var REFRESH_LEAD_SECONDS = 60;
@@ -186,11 +212,14 @@ var createOAuthClient = ({
186
212
  compare,
187
213
  createOAuthClient,
188
214
  developer,
215
+ developerOptions,
189
216
  generateToken,
190
217
  hashToken,
191
218
  intersect,
192
219
  isDeveloperAllowed,
193
220
  parse,
221
+ scopeLabels,
222
+ scopeOptions,
194
223
  scopes,
195
224
  validate
196
225
  });
@@ -83,6 +83,38 @@ const intersect = ( requested, allowed ) => {
83
83
 
84
84
  const isDeveloperAllowed = ( scope ) => developer.includes( scope );
85
85
 
86
+ // User-facing labels for each scope — used by UI components rendering
87
+ // scope pickers. Centralized here so the dashboard, future admin tools,
88
+ // and any other consumer surface the same strings.
89
+ const scopeLabels = {
90
+ 'profile:read' : 'Read own profile',
91
+ 'profile:write' : 'Update own profile',
92
+ 'organization:read' : 'Read organization info',
93
+ 'organization:write' : 'Manage organization',
94
+ 'campaigns:read' : 'Read campaigns',
95
+ 'campaigns:write' : 'Manage campaigns',
96
+ 'contacts:read' : 'Read contacts',
97
+ 'contacts:write' : 'Manage contacts',
98
+ 'workflows:read' : 'Read workflows',
99
+ 'workflows:write' : 'Manage workflows',
100
+ 'connections:read' : 'Read integrations',
101
+ 'connections:write' : 'Manage integrations',
102
+ 'billing:read' : 'Read billing',
103
+ 'billing:write' : 'Manage billing',
104
+ admin : 'Admin access'
105
+ };
106
+
107
+ const toOption = ( scope ) => ({
108
+ key : scopeLabels[ scope ] || scope,
109
+ value : scope
110
+ });
111
+
112
+ // `{ key, value }` option arrays ready to feed any standard checkbox-list
113
+ // component. Derived from the canonical scope arrays so vocabulary
114
+ // changes auto-propagate to every consumer on the next utils bump.
115
+ const developerOptions = developer.map( toOption );
116
+ const scopeOptions = scopes.map( toOption );
117
+
86
118
  // ─────────────────────────────────────────────────────────────────────────
87
119
  // Token primitives — convenience wrappers over drawbridge-utils/token that
88
120
  // fix the OAuth-specific conventions (32 bytes base64url, env-keyed HMAC)
@@ -228,4 +260,4 @@ const createOAuthClient = ({
228
260
 
229
261
  };
230
262
 
231
- export { createOAuthClient, developer, generateToken, hashToken, intersect, isDeveloperAllowed, parse, scopes, validate };
263
+ export { createOAuthClient, developer, developerOptions, generateToken, hashToken, intersect, isDeveloperAllowed, parse, scopeLabels, scopeOptions, scopes, validate };
@@ -83,6 +83,38 @@ const intersect = ( requested, allowed ) => {
83
83
 
84
84
  const isDeveloperAllowed = ( scope ) => developer.includes( scope );
85
85
 
86
+ // User-facing labels for each scope — used by UI components rendering
87
+ // scope pickers. Centralized here so the dashboard, future admin tools,
88
+ // and any other consumer surface the same strings.
89
+ const scopeLabels = {
90
+ 'profile:read' : 'Read own profile',
91
+ 'profile:write' : 'Update own profile',
92
+ 'organization:read' : 'Read organization info',
93
+ 'organization:write' : 'Manage organization',
94
+ 'campaigns:read' : 'Read campaigns',
95
+ 'campaigns:write' : 'Manage campaigns',
96
+ 'contacts:read' : 'Read contacts',
97
+ 'contacts:write' : 'Manage contacts',
98
+ 'workflows:read' : 'Read workflows',
99
+ 'workflows:write' : 'Manage workflows',
100
+ 'connections:read' : 'Read integrations',
101
+ 'connections:write' : 'Manage integrations',
102
+ 'billing:read' : 'Read billing',
103
+ 'billing:write' : 'Manage billing',
104
+ admin : 'Admin access'
105
+ };
106
+
107
+ const toOption = ( scope ) => ({
108
+ key : scopeLabels[ scope ] || scope,
109
+ value : scope
110
+ });
111
+
112
+ // `{ key, value }` option arrays ready to feed any standard checkbox-list
113
+ // component. Derived from the canonical scope arrays so vocabulary
114
+ // changes auto-propagate to every consumer on the next utils bump.
115
+ const developerOptions = developer.map( toOption );
116
+ const scopeOptions = scopes.map( toOption );
117
+
86
118
  // ─────────────────────────────────────────────────────────────────────────
87
119
  // Token primitives — convenience wrappers over drawbridge-utils/token that
88
120
  // fix the OAuth-specific conventions (32 bytes base64url, env-keyed HMAC)
@@ -228,4 +260,4 @@ const createOAuthClient = ({
228
260
 
229
261
  };
230
262
 
231
- export { createOAuthClient, developer, generateToken, hashToken, intersect, isDeveloperAllowed, parse, scopes, validate };
263
+ export { createOAuthClient, developer, developerOptions, generateToken, hashToken, intersect, isDeveloperAllowed, parse, scopeLabels, scopeOptions, scopes, validate };
@@ -69,6 +69,29 @@ var intersect = (requested, allowed) => {
69
69
  return r.filter((scope) => a.includes(scope));
70
70
  };
71
71
  var isDeveloperAllowed = (scope) => developer.includes(scope);
72
+ var scopeLabels = {
73
+ "profile:read": "Read own profile",
74
+ "profile:write": "Update own profile",
75
+ "organization:read": "Read organization info",
76
+ "organization:write": "Manage organization",
77
+ "campaigns:read": "Read campaigns",
78
+ "campaigns:write": "Manage campaigns",
79
+ "contacts:read": "Read contacts",
80
+ "contacts:write": "Manage contacts",
81
+ "workflows:read": "Read workflows",
82
+ "workflows:write": "Manage workflows",
83
+ "connections:read": "Read integrations",
84
+ "connections:write": "Manage integrations",
85
+ "billing:read": "Read billing",
86
+ "billing:write": "Manage billing",
87
+ admin: "Admin access"
88
+ };
89
+ var toOption = (scope) => ({
90
+ key: scopeLabels[scope] || scope,
91
+ value: scope
92
+ });
93
+ var developerOptions = developer.map(toOption);
94
+ var scopeOptions = scopes.map(toOption);
72
95
  var hashToken = (raw) => hash(raw, process.env.OAUTH_TOKEN_HMAC_KEY);
73
96
  var generateToken = () => generate(32, "base64url");
74
97
  var REFRESH_LEAD_SECONDS = 60;
@@ -141,11 +164,14 @@ export {
141
164
  compare,
142
165
  createOAuthClient,
143
166
  developer,
167
+ developerOptions,
144
168
  generateToken,
145
169
  hashToken,
146
170
  intersect,
147
171
  isDeveloperAllowed,
148
172
  parse,
173
+ scopeLabels,
174
+ scopeOptions,
149
175
  scopes,
150
176
  validate
151
177
  };
@@ -59,6 +59,23 @@ var compare = (a, b) => {
59
59
  };
60
60
 
61
61
  // lib/oauth/index.js
62
+ var scopes = [
63
+ "profile:read",
64
+ "profile:write",
65
+ "organization:read",
66
+ "organization:write",
67
+ "campaigns:read",
68
+ "campaigns:write",
69
+ "contacts:read",
70
+ "contacts:write",
71
+ "workflows:read",
72
+ "workflows:write",
73
+ "connections:read",
74
+ "connections:write",
75
+ "billing:read",
76
+ "billing:write",
77
+ "admin"
78
+ ];
62
79
  var developer = [
63
80
  "profile:read",
64
81
  "organization:read",
@@ -81,6 +98,29 @@ var intersect = (requested, allowed) => {
81
98
  const a = parse(allowed);
82
99
  return r.filter((scope) => a.includes(scope));
83
100
  };
101
+ var scopeLabels = {
102
+ "profile:read": "Read own profile",
103
+ "profile:write": "Update own profile",
104
+ "organization:read": "Read organization info",
105
+ "organization:write": "Manage organization",
106
+ "campaigns:read": "Read campaigns",
107
+ "campaigns:write": "Manage campaigns",
108
+ "contacts:read": "Read contacts",
109
+ "contacts:write": "Manage contacts",
110
+ "workflows:read": "Read workflows",
111
+ "workflows:write": "Manage workflows",
112
+ "connections:read": "Read integrations",
113
+ "connections:write": "Manage integrations",
114
+ "billing:read": "Read billing",
115
+ "billing:write": "Manage billing",
116
+ admin: "Admin access"
117
+ };
118
+ var toOption = (scope) => ({
119
+ key: scopeLabels[scope] || scope,
120
+ value: scope
121
+ });
122
+ var developerOptions = developer.map(toOption);
123
+ var scopeOptions = scopes.map(toOption);
84
124
  var hashToken = (raw) => hash(raw, process.env.OAUTH_TOKEN_HMAC_KEY);
85
125
  var generateToken = () => generate(32, "base64url");
86
126
 
@@ -24,6 +24,23 @@ var compare = (a, b) => {
24
24
  };
25
25
 
26
26
  // lib/oauth/index.js
27
+ var scopes = [
28
+ "profile:read",
29
+ "profile:write",
30
+ "organization:read",
31
+ "organization:write",
32
+ "campaigns:read",
33
+ "campaigns:write",
34
+ "contacts:read",
35
+ "contacts:write",
36
+ "workflows:read",
37
+ "workflows:write",
38
+ "connections:read",
39
+ "connections:write",
40
+ "billing:read",
41
+ "billing:write",
42
+ "admin"
43
+ ];
27
44
  var developer = [
28
45
  "profile:read",
29
46
  "organization:read",
@@ -46,6 +63,29 @@ var intersect = (requested, allowed) => {
46
63
  const a = parse(allowed);
47
64
  return r.filter((scope) => a.includes(scope));
48
65
  };
66
+ var scopeLabels = {
67
+ "profile:read": "Read own profile",
68
+ "profile:write": "Update own profile",
69
+ "organization:read": "Read organization info",
70
+ "organization:write": "Manage organization",
71
+ "campaigns:read": "Read campaigns",
72
+ "campaigns:write": "Manage campaigns",
73
+ "contacts:read": "Read contacts",
74
+ "contacts:write": "Manage contacts",
75
+ "workflows:read": "Read workflows",
76
+ "workflows:write": "Manage workflows",
77
+ "connections:read": "Read integrations",
78
+ "connections:write": "Manage integrations",
79
+ "billing:read": "Read billing",
80
+ "billing:write": "Manage billing",
81
+ admin: "Admin access"
82
+ };
83
+ var toOption = (scope) => ({
84
+ key: scopeLabels[scope] || scope,
85
+ value: scope
86
+ });
87
+ var developerOptions = developer.map(toOption);
88
+ var scopeOptions = scopes.map(toOption);
49
89
  var hashToken = (raw) => hash(raw, process.env.OAUTH_TOKEN_HMAC_KEY);
50
90
  var generateToken = () => generate(32, "base64url");
51
91
 
package/package.json CHANGED
@@ -130,5 +130,5 @@
130
130
  "build": "tsup && npm publish"
131
131
  },
132
132
  "types": "dist/index.d.ts",
133
- "version": "0.0.43"
133
+ "version": "0.0.44"
134
134
  }