@scalar/mock-server 0.2.72 → 0.2.73

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @scalar/mock-server
2
2
 
3
+ ## 0.2.73
4
+
5
+ ### Patch Changes
6
+
7
+ - b28c70f: feat: add openIdConnect support
8
+ - Updated dependencies [8c5d767]
9
+ - Updated dependencies [359ee2d]
10
+ - @scalar/oas-utils@0.2.69
11
+
3
12
  ## 0.2.72
4
13
 
5
14
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"handleAuthentication.d.ts","sourceRoot":"","sources":["../../src/utils/handleAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGnC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,EACzB,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,OAEZ,OAAO,QAAQ,MAAM,OAAO,CAAC,IAAI,CAAC;;;8BA8GpD"}
1
+ {"version":3,"file":"handleAuthentication.d.ts","sourceRoot":"","sources":["../../src/utils/handleAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGnC;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,EACzB,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,OAEZ,OAAO,QAAQ,MAAM,OAAO,CAAC,IAAI,CAAC;;;8BAoHpD"}
@@ -59,6 +59,13 @@ function handleAuthentication(schema, operation) {
59
59
  isAuthenticated = true;
60
60
  }
61
61
  break;
62
+ case 'openIdConnect':
63
+ authScheme = 'Bearer';
64
+ // Handle OpenID Connect similar to OAuth2
65
+ if (c.req.header('Authorization')?.startsWith('Bearer ')) {
66
+ isAuthenticated = true;
67
+ }
68
+ break;
62
69
  }
63
70
  }
64
71
  if (!isAuthenticated) {
@@ -1 +1 @@
1
- {"version":3,"file":"logAuthenticationInstructions.d.ts","sourceRoot":"","sources":["../../src/utils/logAuthenticationInstructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAIxD;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,oBAAoB,CAAC,QAoIlE"}
1
+ {"version":3,"file":"logAuthenticationInstructions.d.ts","sourceRoot":"","sources":["../../src/utils/logAuthenticationInstructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAIxD;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,oBAAoB,CAAC,QA0IlE"}
@@ -101,7 +101,11 @@ function logAuthenticationInstructions(securitySchemes) {
101
101
  }
102
102
  break;
103
103
  case 'openIdConnect':
104
- console.log('⚠️ OpenID Connect Authentication');
104
+ console.log(' OpenID Connect Authentication');
105
+ console.log(' Use the following OpenID Connect discovery URL:');
106
+ console.log();
107
+ console.log(` ${getPathFromUrl(scheme.openIdConnectUrl || '/.well-known/openid-configuration')}`);
108
+ console.log();
105
109
  break;
106
110
  default:
107
111
  console.warn(`Unsupported security scheme type: ${scheme.type}`);
@@ -1 +1 @@
1
- {"version":3,"file":"setupAuthenticationRoutes.d.ts","sourceRoot":"","sources":["../../src/utils/setupAuthenticationRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,uBAAuB,CAAA;AAC5E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAMhC;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,IAAI,EACT,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,QA6E1B"}
1
+ {"version":3,"file":"setupAuthenticationRoutes.d.ts","sourceRoot":"","sources":["../../src/utils/setupAuthenticationRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,uBAAuB,CAAA;AAC5E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAMhC;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,IAAI,EACT,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,QAuG1B"}
@@ -50,6 +50,28 @@ function setupAuthenticationRoutes(app, schema) {
50
50
  tokenUrls.add(tokenRoute);
51
51
  }
52
52
  }
53
+ else if (scheme.type === 'openIdConnect') {
54
+ // Handle OpenID Connect configuration
55
+ if (scheme.openIdConnectUrl) {
56
+ const configPath = getPathFromUrl(scheme.openIdConnectUrl ?? '/.well-known/openid-configuration');
57
+ // Add route for OpenID Connect configuration
58
+ app.get(configPath, (c) => {
59
+ return c.json({
60
+ issuer: 'https://example.com',
61
+ authorization_endpoint: '/oauth/authorize',
62
+ token_endpoint: '/oauth/token',
63
+ response_types_supported: ['code', 'token', 'id_token'],
64
+ subject_types_supported: ['public'],
65
+ id_token_signing_alg_values_supported: ['RS256'],
66
+ });
67
+ });
68
+ // Add standard endpoints
69
+ const authorizeRoute = '/oauth/authorize';
70
+ const tokenRoute = '/oauth/token';
71
+ authorizeUrls.add(getPathFromUrl(authorizeRoute));
72
+ tokenUrls.add(tokenRoute);
73
+ }
74
+ }
53
75
  });
54
76
  // Set up unique authorization routes
55
77
  authorizeUrls.forEach((authorizeUrl) => {
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "swagger",
17
17
  "cli"
18
18
  ],
19
- "version": "0.2.72",
19
+ "version": "0.2.73",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -39,8 +39,8 @@
39
39
  "hono": "^4.6.5",
40
40
  "object-to-xml": "^2.0.0",
41
41
  "@scalar/openapi-parser": "0.8.8",
42
- "@scalar/oas-utils": "0.2.68",
43
- "@scalar/openapi-types": "0.1.4"
42
+ "@scalar/openapi-types": "0.1.4",
43
+ "@scalar/oas-utils": "0.2.69"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@hono/node-server": "^1.11.0",