@uphold/fastify-openapi-router-plugin 1.1.0 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uphold/fastify-openapi-router-plugin",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "A plugin for Fastify to connect routes with a OpenAPI 3.x specification",
5
5
  "main": "./src/index.js",
6
6
  "types": "./types/index.d.ts",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@readme/openapi-parser": "^6.0.0",
52
- "fastify-plugin": "^4.5.1",
52
+ "fastify-plugin": "^5.1.0",
53
53
  "lodash-es": "^4.17.23",
54
54
  "openapi-types": "^12.1.3",
55
55
  "p-props": "^6.1.0"
@@ -61,9 +61,7 @@ export const verifyScopes = (providedScopes, requiredScopes) => {
61
61
  const missingScopes = requiredScopes.filter(requiredScope => {
62
62
  const hasMatchingScope = providedScopes.some(providedScope => {
63
63
  if (providedScope.endsWith('*')) {
64
- const prefixScope = providedScope.match(/(.*)\*$/)[1];
65
-
66
- return requiredScope.startsWith(prefixScope);
64
+ return requiredScope.startsWith(providedScope.slice(0, -1));
67
65
  }
68
66
 
69
67
  return providedScope === requiredScope;
@@ -69,6 +69,14 @@ describe('verifyScopes()', () => {
69
69
  runTest({ missing: ['transaction:foz'], provided, required: ['transaction:foz'] });
70
70
  runTest({ missing: [''], provided, required: [''] });
71
71
  });
72
+
73
+ it('should verify regular scopes correctly against * suffix with a newline', async () => {
74
+ const provided = ['user:\n*'];
75
+
76
+ runTest({ missing: [], provided, required: ['user:\nfoo'] });
77
+ runTest({ missing: ['user:foo'], provided, required: ['user:foo'] });
78
+ runTest({ missing: ['admin:write'], provided, required: ['admin:write'] });
79
+ });
72
80
  });
73
81
 
74
82
  describe('extractSecuritySchemeValueFromRequest()', () => {