@undefineds.co/xpod 0.4.32 → 0.4.33

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.
@@ -6,6 +6,8 @@ export interface SolidTokenAuthenticatorOptions {
6
6
  */
7
7
  resolveAccountId?: (webId: string) => Promise<string | undefined>;
8
8
  publicBaseUrl?: string;
9
+ /** Published API endpoint for this Cloud deployment, independent of its identity origin. */
10
+ apiBaseUrl?: string;
9
11
  internalBaseUrl?: string;
10
12
  }
11
13
  /**
@@ -16,13 +18,14 @@ export declare class SolidTokenAuthenticator implements Authenticator {
16
18
  private readonly verify;
17
19
  private readonly resolveAccountId?;
18
20
  private readonly publicOrigin?;
21
+ private readonly canonicalOrigins;
19
22
  constructor(options?: SolidTokenAuthenticatorOptions);
20
23
  canAuthenticate(request: IncomingMessage): boolean;
21
24
  authenticate(request: IncomingMessage): Promise<AuthResult>;
22
25
  private buildRequestUrl;
23
26
  private verifyRequest;
24
27
  private trustedCanonicalRouteUrl;
25
- private configuredCanonicalRequestUrl;
28
+ private configuredCanonicalRequestUrls;
26
29
  private hasLocalRouteHeader;
27
30
  private firstHeaderValue;
28
31
  private pathAndSearch;
@@ -7,6 +7,20 @@ const SolidTokenCaches_1 = require("../../authentication/SolidTokenCaches");
7
7
  const ConfiguredLoopbackSolidTokenVerifier_1 = require("../../authentication/ConfiguredLoopbackSolidTokenVerifier");
8
8
  const SOLID_LOCAL_ROUTE_CANONICAL_URL_HEADER = 'x-xpod-canonical-url';
9
9
  const SOLID_LOCAL_ROUTE_LOCAL_URL_HEADER = 'x-xpod-local-route-url';
10
+ function configuredApiOrigin(value) {
11
+ if (!value?.trim())
12
+ return undefined;
13
+ try {
14
+ const url = new URL(value);
15
+ if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash) {
16
+ return undefined;
17
+ }
18
+ return url.origin;
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ }
10
24
  /**
11
25
  * Parse one Solid Authorization header value into its canonical scheme and token.
12
26
  *
@@ -40,6 +54,12 @@ class SolidTokenAuthenticator {
40
54
  this.resolveAccountId = options.resolveAccountId;
41
55
  const { issuerKeySetCache, webIdIssuersCache, publicOrigin } = (0, SolidTokenCaches_1.createRoutedSolidTokenCaches)(options);
42
56
  this.publicOrigin = publicOrigin;
57
+ // Discovery and trusted local-route hints still use the identity authority.
58
+ // Only the no-hint retry also accepts this deployment's configured API origin.
59
+ this.canonicalOrigins = [...new Set([
60
+ publicOrigin,
61
+ configuredApiOrigin(options.apiBaseUrl),
62
+ ].filter((origin) => origin !== undefined))];
43
63
  const loopbackOrigin = (0, ConfiguredLoopbackSolidTokenVerifier_1.configuredHttpLoopbackOrigin)(publicOrigin);
44
64
  this.verify = loopbackOrigin
45
65
  ? (0, ConfiguredLoopbackSolidTokenVerifier_1.createConfiguredLoopbackSolidTokenVerifier)({
@@ -143,22 +163,20 @@ class SolidTokenAuthenticator {
143
163
  if (!dpopHeader) {
144
164
  throw error;
145
165
  }
146
- const configuredCanonicalUrl = this.configuredCanonicalRequestUrl(request, url);
147
- if (!configuredCanonicalUrl) {
148
- throw error;
149
- }
150
- try {
151
- return await this.verify(authorization, {
152
- header: dpopHeader,
153
- method,
154
- url: configuredCanonicalUrl,
155
- });
156
- }
157
- catch {
158
- // Retain the primary diagnostic when both attempts fail: reporting the
159
- // retry's htu mismatch would hide the reason the caller actually failed.
160
- throw error;
166
+ for (const configuredCanonicalUrl of this.configuredCanonicalRequestUrls(request, url)) {
167
+ try {
168
+ return await this.verify(authorization, {
169
+ header: dpopHeader,
170
+ method,
171
+ url: configuredCanonicalUrl,
172
+ });
173
+ }
174
+ catch {
175
+ // Every retry performs full verification. Preserve the primary error
176
+ // if none of the deployment's configured authorities verifies it.
177
+ }
161
178
  }
179
+ throw error;
162
180
  }
163
181
  }
164
182
  trustedCanonicalRouteUrl(request) {
@@ -194,20 +212,20 @@ class SolidTokenAuthenticator {
194
212
  }
195
213
  return canonicalUrl.href;
196
214
  }
197
- configuredCanonicalRequestUrl(request, primaryUrl) {
198
- if (!this.publicOrigin || this.hasLocalRouteHeader(request)) {
199
- return undefined;
200
- }
201
- const publicUrl = new URL(this.publicOrigin);
202
- if (publicUrl.protocol !== 'https:') {
203
- return undefined;
215
+ configuredCanonicalRequestUrls(request, primaryUrl) {
216
+ if (this.hasLocalRouteHeader(request)) {
217
+ return [];
204
218
  }
205
219
  const requestPath = this.pathAndSearch(request.url ?? '/');
206
220
  if (!requestPath) {
207
- return undefined;
221
+ return [];
208
222
  }
209
- const configuredUrl = new URL(requestPath, this.publicOrigin).href;
210
- return configuredUrl === primaryUrl ? undefined : configuredUrl;
223
+ return this.canonicalOrigins.flatMap((origin) => {
224
+ if (new URL(origin).protocol !== 'https:')
225
+ return [];
226
+ const configuredUrl = new URL(requestPath, origin).href;
227
+ return configuredUrl === primaryUrl ? [] : [configuredUrl];
228
+ });
211
229
  }
212
230
  hasLocalRouteHeader(request) {
213
231
  return this.firstHeaderValue(request.headers[SOLID_LOCAL_ROUTE_CANONICAL_URL_HEADER]) !== undefined ||
@@ -574,6 +574,7 @@ function registerCommonServices(container) {
574
574
  publicBaseUrl: config.edition === 'local' && config.publicUrl
575
575
  ? (0, storage_base_url_1.resolveLocalStorageProviderBaseUrl)(config)
576
576
  : config.solidBaseUrl,
577
+ apiBaseUrl: config.edition === 'cloud' ? config.apiBaseUrl : undefined,
577
578
  // Token discovery is a public OIDC concern. WebID/JWKS verification is
578
579
  // an internal service call and must not hairpin through public ingress.
579
580
  internalBaseUrl: resolveHostedPodCssBaseUrl(config),
@@ -179,6 +179,7 @@ function loadConfigFromEnv() {
179
179
  corsOrigins: process.env.CORS_ORIGINS?.split(',').map(s => s.trim()) ?? ['*'],
180
180
  cssTokenEndpoint: resolveCssTokenEndpoint(),
181
181
  solidBaseUrl,
182
+ apiBaseUrl: normalizeOptionalUrl(process.env.XPOD_API_BASE_URL),
182
183
  solidRootFilePath: path.resolve(rootDir),
183
184
  aiConnectionInvocationSecret: process.env.XPOD_AI_CONNECTION_INVOCATION_SECRET,
184
185
  aiConnectionInvocationKeyId: process.env.XPOD_AI_CONNECTION_INVOCATION_KEY_ID,
@@ -117,6 +117,8 @@ export interface ApiContainerConfig {
117
117
  /** CSS Token 端点 */
118
118
  cssTokenEndpoint: string;
119
119
  solidBaseUrl?: string;
120
+ /** Published API endpoint from XPOD_API_BASE_URL; distinct from the Solid identity origin. */
121
+ apiBaseUrl?: string;
120
122
  /** Captured CSS filesystem root for this runtime, independent of later process.env changes. */
121
123
  solidRootFilePath?: string;
122
124
  /** Stateless AI Connections invocation token signing config. */
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "sourceAuthority": {
4
- "sourceCommit": "326cdab7c29a107ce566bdc6ea543c5abaf88b6b",
4
+ "sourceCommit": "db6c51aa1a0a9551f8b7b6149767f188b101c9a4",
5
5
  "tracked": true,
6
6
  "dirty": false,
7
7
  "snapshotSHA256": "85f739d81735baf4e1263e55c2542335233393872ee761179ff0b9fa4411879e",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "sourceAuthority": {
4
- "sourceCommit": "326cdab7c29a107ce566bdc6ea543c5abaf88b6b",
4
+ "sourceCommit": "db6c51aa1a0a9551f8b7b6149767f188b101c9a4",
5
5
  "tracked": true,
6
6
  "dirty": false,
7
7
  "snapshotSHA256": "85f739d81735baf4e1263e55c2542335233393872ee761179ff0b9fa4411879e",
@@ -12,7 +12,7 @@
12
12
  {
13
13
  "path": "build-provenance.json",
14
14
  "bytes": 1727,
15
- "sha256": "dee7e8e0129abe6b67a3848d8bc0413e6db0ea9bdcefa3589933d0e4a6e89e0b"
15
+ "sha256": "707d41090d3b44c9b3c23e94e9fc1e4f23ad8248ccc4da37d938e6af4fdcceb3"
16
16
  },
17
17
  {
18
18
  "path": "generated/provider-catalog/index.json",
@@ -322,7 +322,7 @@
322
322
  {
323
323
  "path": "source-inventory.json",
324
324
  "bytes": 4713,
325
- "sha256": "70c3db163597a7e5b6d3f5aaadbc58cc089c4156cbd60625b7abff008af55a8e"
325
+ "sha256": "cf0f1bbcfd5b20c36039a4296ea3dc48c1a5bac63b2aaa13d94ec3826b8716c0"
326
326
  }
327
327
  ]
328
328
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "sourceAuthority": {
4
- "sourceCommit": "326cdab7c29a107ce566bdc6ea543c5abaf88b6b",
4
+ "sourceCommit": "db6c51aa1a0a9551f8b7b6149767f188b101c9a4",
5
5
  "tracked": true,
6
6
  "dirty": false,
7
7
  "snapshotSHA256": "85f739d81735baf4e1263e55c2542335233393872ee761179ff0b9fa4411879e",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "sourceAuthority": {
4
- "sourceCommit": "326cdab7c29a107ce566bdc6ea543c5abaf88b6b",
4
+ "sourceCommit": "db6c51aa1a0a9551f8b7b6149767f188b101c9a4",
5
5
  "tracked": true,
6
6
  "dirty": false,
7
7
  "snapshotSHA256": "c3b65827fdfc0e13c743cd5129b9db7626ec2419e12b06d8478d97fc859e851a",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "sourceAuthority": {
4
- "sourceCommit": "326cdab7c29a107ce566bdc6ea543c5abaf88b6b",
4
+ "sourceCommit": "db6c51aa1a0a9551f8b7b6149767f188b101c9a4",
5
5
  "tracked": true,
6
6
  "dirty": false,
7
7
  "snapshotSHA256": "c3b65827fdfc0e13c743cd5129b9db7626ec2419e12b06d8478d97fc859e851a",
@@ -12,7 +12,7 @@
12
12
  {
13
13
  "path": "build-provenance.json",
14
14
  "bytes": 398,
15
- "sha256": "83a33120bc17de14d8b5b7ea28fd9d932cfa5d10da693d0471a449d0e084b74a"
15
+ "sha256": "eb2c33afee31058e69d3670b7e6a7f673cb21c33bdb942aaa23a876ef2848d39"
16
16
  },
17
17
  {
18
18
  "path": "source/LICENSE",
@@ -52,7 +52,7 @@
52
52
  {
53
53
  "path": "source-inventory.json",
54
54
  "bytes": 1585,
55
- "sha256": "767f0ee730e5408d03c5d62dec8cccf7b9761108268a8ca7ef430182c6a3aa24"
55
+ "sha256": "9dd493e84ece7bcf1e5089d8273ec42e4bc2d202beb83f89284952b601c71d9b"
56
56
  }
57
57
  ]
58
58
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "sourceAuthority": {
4
- "sourceCommit": "326cdab7c29a107ce566bdc6ea543c5abaf88b6b",
4
+ "sourceCommit": "db6c51aa1a0a9551f8b7b6149767f188b101c9a4",
5
5
  "tracked": true,
6
6
  "dirty": false,
7
7
  "snapshotSHA256": "c3b65827fdfc0e13c743cd5129b9db7626ec2419e12b06d8478d97fc859e851a",
@@ -5,7 +5,7 @@
5
5
  "version": "0.1.0-preview.2",
6
6
  "bunVersion": "1.4.2"
7
7
  },
8
- "indexSHA256": "77f607c06fd91dc53fb4f7e4de18ff7bcdadc97edc988cc6c77cff74c959fcd4",
8
+ "indexSHA256": "c65e62014a116bb2196474cd542e477d4b33c6372bd751a841a4a793c7f02363",
9
9
  "outputPayloads": {
10
10
  "esmSHA256": "7f610395a47a79acd1bb2181a71a16e887272fa4e5522fa095db78625f3c8eb0"
11
11
  }
@@ -159,7 +159,7 @@
159
159
  }
160
160
  ],
161
161
  "sourceAuthority": {
162
- "sourceCommit": "326cdab7c29a107ce566bdc6ea543c5abaf88b6b",
162
+ "sourceCommit": "db6c51aa1a0a9551f8b7b6149767f188b101c9a4",
163
163
  "dirty": false,
164
164
  "snapshotSHA256": "a198c5f28999d0c763c3bb5d166823a5a5eb0eff8e7e4557b7b8d299200198a9",
165
165
  "scope": "CLI source plus explicitly mapped canonical host and runtime-client source; no claim of release acceptance or external dependency closure."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@undefineds.co/xpod",
3
- "version": "0.4.32",
3
+ "version": "0.4.33",
4
4
  "description": "Xpod is an extended Community Solid Server, offering rich-feature, production-level Solid Pod and identity management.",
5
5
  "repository": "https://github.com/undefinedsco/xpod",
6
6
  "author": "developer@undefineds.co",
@@ -388,7 +388,7 @@
388
388
  }
389
389
  },
390
390
  "optionalDependencies": {
391
- "@undefineds.co/xpod-darwin-arm64": "0.4.32",
391
+ "@undefineds.co/xpod-darwin-arm64": "0.4.33",
392
392
  "@undefineds.co/drizzle-solid": "0.3.26",
393
393
  "@undefineds.co/extensions": "0.1.0",
394
394
  "@undefineds.co/ai-connections": "0.1.6",