@drawbridge/drawbridge-utils 0.0.81 → 0.0.83

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.
@@ -361,6 +361,19 @@ var createOAuthModel = ({ controller }) => ({
361
361
  const granted = intersect(scope, token.scope ?? []);
362
362
  return granted.length > 0;
363
363
  },
364
+ // Scope enforcement at AUTHORIZE time. Without this, @node-oauth's
365
+ // AuthorizeHandler grants whatever scope the request asks for — the client
366
+ // registry's scopes list was only advisory (reachable from any logged-in
367
+ // browser via the dashboard's authorize BFF). Every requested scope must be
368
+ // registered on the client; an empty request falls back to the client's
369
+ // full registered grant. Returning false → invalid_scope.
370
+ validateScope: (user, client, scope) => {
371
+ const requested = Array.isArray(scope) ? scope : scope ? String(scope).split(/\s+/).filter(Boolean) : [];
372
+ const allowed = (client == null ? void 0 : client.scopes) ?? [];
373
+ if (!requested.length) return allowed;
374
+ const invalid = requested.filter((entry) => !allowed.includes(entry));
375
+ return invalid.length ? false : requested;
376
+ },
364
377
  // client_credentials grant: treat the client as the resource owner.
365
378
  getUserFromClient: (client) => ({ id: client.id, type: "client" })
366
379
  });
@@ -304,6 +304,28 @@ const createOAuthModel = ({ controller }) => ({
304
304
 
305
305
  },
306
306
 
307
+ // Scope enforcement at AUTHORIZE time. Without this, @node-oauth's
308
+ // AuthorizeHandler grants whatever scope the request asks for — the client
309
+ // registry's scopes list was only advisory (reachable from any logged-in
310
+ // browser via the dashboard's authorize BFF). Every requested scope must be
311
+ // registered on the client; an empty request falls back to the client's
312
+ // full registered grant. Returning false → invalid_scope.
313
+ validateScope : ( user, client, scope ) => {
314
+
315
+ const requested = Array.isArray( scope )
316
+ ? scope
317
+ : ( scope ? String( scope ).split( /\s+/ ).filter( Boolean ) : [] );
318
+
319
+ const allowed = client?.scopes ?? [];
320
+
321
+ if( ! requested.length ) return allowed;
322
+
323
+ const invalid = requested.filter( ( entry ) => ! allowed.includes( entry ) );
324
+
325
+ return invalid.length ? false : requested;
326
+
327
+ },
328
+
307
329
  // client_credentials grant: treat the client as the resource owner.
308
330
  getUserFromClient : ( client ) => ({ id : client.id, type : 'client' })
309
331
 
@@ -304,6 +304,28 @@ const createOAuthModel = ({ controller }) => ({
304
304
 
305
305
  },
306
306
 
307
+ // Scope enforcement at AUTHORIZE time. Without this, @node-oauth's
308
+ // AuthorizeHandler grants whatever scope the request asks for — the client
309
+ // registry's scopes list was only advisory (reachable from any logged-in
310
+ // browser via the dashboard's authorize BFF). Every requested scope must be
311
+ // registered on the client; an empty request falls back to the client's
312
+ // full registered grant. Returning false → invalid_scope.
313
+ validateScope : ( user, client, scope ) => {
314
+
315
+ const requested = Array.isArray( scope )
316
+ ? scope
317
+ : ( scope ? String( scope ).split( /\s+/ ).filter( Boolean ) : [] );
318
+
319
+ const allowed = client?.scopes ?? [];
320
+
321
+ if( ! requested.length ) return allowed;
322
+
323
+ const invalid = requested.filter( ( entry ) => ! allowed.includes( entry ) );
324
+
325
+ return invalid.length ? false : requested;
326
+
327
+ },
328
+
307
329
  // client_credentials grant: treat the client as the resource owner.
308
330
  getUserFromClient : ( client ) => ({ id : client.id, type : 'client' })
309
331
 
@@ -326,6 +326,19 @@ var createOAuthModel = ({ controller }) => ({
326
326
  const granted = intersect(scope, token.scope ?? []);
327
327
  return granted.length > 0;
328
328
  },
329
+ // Scope enforcement at AUTHORIZE time. Without this, @node-oauth's
330
+ // AuthorizeHandler grants whatever scope the request asks for — the client
331
+ // registry's scopes list was only advisory (reachable from any logged-in
332
+ // browser via the dashboard's authorize BFF). Every requested scope must be
333
+ // registered on the client; an empty request falls back to the client's
334
+ // full registered grant. Returning false → invalid_scope.
335
+ validateScope: (user, client, scope) => {
336
+ const requested = Array.isArray(scope) ? scope : scope ? String(scope).split(/\s+/).filter(Boolean) : [];
337
+ const allowed = (client == null ? void 0 : client.scopes) ?? [];
338
+ if (!requested.length) return allowed;
339
+ const invalid = requested.filter((entry) => !allowed.includes(entry));
340
+ return invalid.length ? false : requested;
341
+ },
329
342
  // client_credentials grant: treat the client as the resource owner.
330
343
  getUserFromClient: (client) => ({ id: client.id, type: "client" })
331
344
  });
package/dist/plans.cjs CHANGED
@@ -342,7 +342,11 @@ var plans = {
342
342
  limits: all.limits({ actions: 15e3, members: 5, storage: gigabyte * 20 }),
343
343
  marketing: {
344
344
  description: "Expand your reach and grow your lead pipeline.",
345
- features: [],
345
+ features: [
346
+ "Analytics",
347
+ "Custom subdomain / URLs",
348
+ "Confirmation page ads"
349
+ ],
346
350
  limits: [
347
351
  ["Actions per month", "15,000"],
348
352
  ["Affiliates", "Unlimited"],
@@ -368,7 +372,11 @@ var plans = {
368
372
  limits: all.limits({ actions: 4e4, members: 10, storage: gigabyte * 50 }),
369
373
  marketing: {
370
374
  description: "Accelerate acquisition with more power and flexibility.",
371
- features: [],
375
+ features: [
376
+ "Analytics",
377
+ "Custom subdomain / URLs",
378
+ "Confirmation page ads"
379
+ ],
372
380
  limits: [
373
381
  ["Actions per month", "40,000"],
374
382
  ["Affiliates", "Unlimited"],
@@ -394,7 +402,11 @@ var plans = {
394
402
  limits: all.limits({ actions: 1e5, members: infinite, storage: gigabyte * 100 }),
395
403
  marketing: {
396
404
  description: "Built for brands focused on results.",
397
- features: [],
405
+ features: [
406
+ "Analytics",
407
+ "Custom subdomain / URLs",
408
+ "Confirmation page ads"
409
+ ],
398
410
  limits: [
399
411
  ["Actions per month", "100,000"],
400
412
  ["Affiliates", "Unlimited"],
package/dist/plans.d.cts CHANGED
@@ -114,7 +114,11 @@ const plans = {
114
114
  limits : all.limits({ actions : 15000, members : 5, storage : gigabyte * 20 }),
115
115
  marketing : {
116
116
  description : 'Expand your reach and grow your lead pipeline.',
117
- features : [],
117
+ features : [
118
+ 'Analytics',
119
+ 'Custom subdomain / URLs',
120
+ 'Confirmation page ads'
121
+ ],
118
122
  limits : [
119
123
  [ 'Actions per month', '15,000' ],
120
124
  [ 'Affiliates', 'Unlimited' ],
@@ -140,7 +144,11 @@ const plans = {
140
144
  limits : all.limits({ actions : 40000, members : 10, storage : gigabyte * 50 }),
141
145
  marketing : {
142
146
  description : 'Accelerate acquisition with more power and flexibility.',
143
- features : [],
147
+ features : [
148
+ 'Analytics',
149
+ 'Custom subdomain / URLs',
150
+ 'Confirmation page ads'
151
+ ],
144
152
  limits : [
145
153
  [ 'Actions per month', '40,000' ],
146
154
  [ 'Affiliates', 'Unlimited' ],
@@ -166,7 +174,11 @@ const plans = {
166
174
  limits : all.limits({ actions : 100000, members : infinite, storage : gigabyte * 100 }),
167
175
  marketing : {
168
176
  description : 'Built for brands focused on results.',
169
- features : [],
177
+ features : [
178
+ 'Analytics',
179
+ 'Custom subdomain / URLs',
180
+ 'Confirmation page ads'
181
+ ],
170
182
  limits : [
171
183
  [ 'Actions per month', '100,000' ],
172
184
  [ 'Affiliates', 'Unlimited' ],
package/dist/plans.d.ts CHANGED
@@ -114,7 +114,11 @@ const plans = {
114
114
  limits : all.limits({ actions : 15000, members : 5, storage : gigabyte * 20 }),
115
115
  marketing : {
116
116
  description : 'Expand your reach and grow your lead pipeline.',
117
- features : [],
117
+ features : [
118
+ 'Analytics',
119
+ 'Custom subdomain / URLs',
120
+ 'Confirmation page ads'
121
+ ],
118
122
  limits : [
119
123
  [ 'Actions per month', '15,000' ],
120
124
  [ 'Affiliates', 'Unlimited' ],
@@ -140,7 +144,11 @@ const plans = {
140
144
  limits : all.limits({ actions : 40000, members : 10, storage : gigabyte * 50 }),
141
145
  marketing : {
142
146
  description : 'Accelerate acquisition with more power and flexibility.',
143
- features : [],
147
+ features : [
148
+ 'Analytics',
149
+ 'Custom subdomain / URLs',
150
+ 'Confirmation page ads'
151
+ ],
144
152
  limits : [
145
153
  [ 'Actions per month', '40,000' ],
146
154
  [ 'Affiliates', 'Unlimited' ],
@@ -166,7 +174,11 @@ const plans = {
166
174
  limits : all.limits({ actions : 100000, members : infinite, storage : gigabyte * 100 }),
167
175
  marketing : {
168
176
  description : 'Built for brands focused on results.',
169
- features : [],
177
+ features : [
178
+ 'Analytics',
179
+ 'Custom subdomain / URLs',
180
+ 'Confirmation page ads'
181
+ ],
170
182
  limits : [
171
183
  [ 'Actions per month', '100,000' ],
172
184
  [ 'Affiliates', 'Unlimited' ],
package/dist/plans.js CHANGED
@@ -305,7 +305,11 @@ var plans = {
305
305
  limits: all.limits({ actions: 15e3, members: 5, storage: gigabyte * 20 }),
306
306
  marketing: {
307
307
  description: "Expand your reach and grow your lead pipeline.",
308
- features: [],
308
+ features: [
309
+ "Analytics",
310
+ "Custom subdomain / URLs",
311
+ "Confirmation page ads"
312
+ ],
309
313
  limits: [
310
314
  ["Actions per month", "15,000"],
311
315
  ["Affiliates", "Unlimited"],
@@ -331,7 +335,11 @@ var plans = {
331
335
  limits: all.limits({ actions: 4e4, members: 10, storage: gigabyte * 50 }),
332
336
  marketing: {
333
337
  description: "Accelerate acquisition with more power and flexibility.",
334
- features: [],
338
+ features: [
339
+ "Analytics",
340
+ "Custom subdomain / URLs",
341
+ "Confirmation page ads"
342
+ ],
335
343
  limits: [
336
344
  ["Actions per month", "40,000"],
337
345
  ["Affiliates", "Unlimited"],
@@ -357,7 +365,11 @@ var plans = {
357
365
  limits: all.limits({ actions: 1e5, members: infinite, storage: gigabyte * 100 }),
358
366
  marketing: {
359
367
  description: "Built for brands focused on results.",
360
- features: [],
368
+ features: [
369
+ "Analytics",
370
+ "Custom subdomain / URLs",
371
+ "Confirmation page ads"
372
+ ],
361
373
  limits: [
362
374
  ["Actions per month", "100,000"],
363
375
  ["Affiliates", "Unlimited"],
package/package.json CHANGED
@@ -164,5 +164,5 @@
164
164
  "test": "node --test test/"
165
165
  },
166
166
  "types": "dist/index.d.ts",
167
- "version": "0.0.81"
167
+ "version": "0.0.83"
168
168
  }