@crombolo/api-delivery 0.64.0 → 0.65.1

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/settings.ts +7 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/api-delivery",
3
- "version": "0.64.0",
3
+ "version": "0.65.1",
4
4
  "description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Umbraco's Content Delivery API for crombolo: published content and media as JSON, served from the published cache.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -28,8 +28,8 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@crombolo/core": "0.64.0",
32
- "@crombolo/contracts": "0.64.0",
33
- "@crombolo/render": "0.64.0"
31
+ "@crombolo/core": "0.65.1",
32
+ "@crombolo/contracts": "0.65.1",
33
+ "@crombolo/render": "0.65.1"
34
34
  }
35
35
  }
package/src/settings.ts CHANGED
@@ -67,7 +67,8 @@ export function resolveDeliveryApiSettings(options: DeliveryApiOptions = {}): De
67
67
  const code = options.memberAuthorization?.authorizationCodeFlow ?? {}
68
68
  const credentials = options.memberAuthorization?.clientCredentialsFlow ?? {}
69
69
  return {
70
- enabled: options.enabled ?? false,
70
+ // Story 348: on, serving what the site publishes to anyone, unless a site says otherwise.
71
+ enabled: options.enabled ?? true,
71
72
  publicAccess: options.publicAccess ?? true,
72
73
  apiKey: options.apiKey?.trim() ? options.apiKey : undefined,
73
74
  allowedContentTypeAliases: [...(options.allowedContentTypeAliases ?? [])].filter(
@@ -81,9 +82,11 @@ export function resolveDeliveryApiSettings(options: DeliveryApiOptions = {}): De
81
82
  publicAccess: options.media?.publicAccess ?? true,
82
83
  },
83
84
  cors: {
84
- allowedOrigins: [...(options.cors?.allowedOrigins ?? [])].filter(
85
- (origin): origin is string => typeof origin === 'string' && origin.trim() !== '',
86
- ),
85
+ // Any origin for public reads unless a list is given, an empty one included;
86
+ // none for a private API, whose key must not be usable from any page.
87
+ allowedOrigins: [
88
+ ...(options.cors?.allowedOrigins ?? ((options.publicAccess ?? true) ? ['*'] : [])),
89
+ ].filter((origin): origin is string => typeof origin === 'string' && origin.trim() !== ''),
87
90
  },
88
91
  preview: {
89
92
  url: options.preview?.url?.trim() || undefined,