@geolens/sdk 1.19.1 → 1.21.0
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/README.md +20 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +6 -0
- package/dist/auth.js.map +1 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/sdk.gen.d.ts +162 -140
- package/dist/client/sdk.gen.d.ts.map +1 -1
- package/dist/client/sdk.gen.js +192 -139
- package/dist/client/sdk.gen.js.map +1 -1
- package/dist/client/types.gen.d.ts +679 -115
- package/dist/client/types.gen.d.ts.map +1 -1
- package/dist/fileReads.d.ts +37 -0
- package/dist/fileReads.d.ts.map +1 -0
- package/dist/fileReads.js +45 -0
- package/dist/fileReads.js.map +1 -0
- package/dist/index.d.ts +2 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/redirects.d.ts +48 -0
- package/dist/redirects.d.ts.map +1 -0
- package/dist/redirects.js +127 -0
- package/dist/redirects.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-read response handling for the GeoLens TypeScript SDK.
|
|
3
|
+
*
|
|
4
|
+
* Hand-maintained — NOT regenerated by `make sdks`. Wired into every client
|
|
5
|
+
* `createGeolensClient()` produces (see auth.ts); cannot live in generated
|
|
6
|
+
* code, which @hey-api/openapi-ts owns outright.
|
|
7
|
+
*
|
|
8
|
+
* The generated fetch client (client/client/client.gen.ts) infers its
|
|
9
|
+
* parsed response type from Content-Type (`getParseAs` in
|
|
10
|
+
* client/client/utils.gen.ts), and only a handful of prefixes become a
|
|
11
|
+
* Blob. These routes' declared bodies are `Blob | File`, but a type outside
|
|
12
|
+
* that list — `model/gltf-binary`, `application/json` for tileset.json,
|
|
13
|
+
* `text/csv` for a CSV export — parses as JSON or text instead, never
|
|
14
|
+
* matching the Blob case. Fixed below, scoped by request path to the
|
|
15
|
+
* routes that declare a binary body: COG download, dataset export, a 3D
|
|
16
|
+
* Tiles file and a COPC point cloud file.
|
|
17
|
+
*
|
|
18
|
+
* A 304 from a conditional read (`If-None-Match` or `If-Modified-Since`) on
|
|
19
|
+
* these same routes is a successful revalidation with no body, but the
|
|
20
|
+
* client treats any non-2xx status as an error — see `notModified` below,
|
|
21
|
+
* which reads that signal from the call's own result rather than rewriting
|
|
22
|
+
* the response.
|
|
23
|
+
*/
|
|
24
|
+
import type { Client } from './client/client/index.js';
|
|
25
|
+
/** Idempotent per client — safe to call every time a client is (re)configured. */
|
|
26
|
+
export declare function installFileReadHandling(target: Client): void;
|
|
27
|
+
/**
|
|
28
|
+
* True when `result` (a generated call's non-throwing return value) is a
|
|
29
|
+
* conditional read's cache hit: a 304 answering a request that sent
|
|
30
|
+
* `If-None-Match` or `If-Modified-Since`. With `throwOnError` a 304 throws
|
|
31
|
+
* before a result exists — call these file-read routes without it to use this.
|
|
32
|
+
*/
|
|
33
|
+
export declare function notModified(result: {
|
|
34
|
+
request?: Request;
|
|
35
|
+
response?: Response;
|
|
36
|
+
}): boolean;
|
|
37
|
+
//# sourceMappingURL=fileReads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileReads.d.ts","sourceRoot":"","sources":["../src/fileReads.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAiBvD,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAqB5D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CAAE,GAAG,OAAO,CAOvF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Matched against the request URL's pathname, so a deployment's base path
|
|
2
|
+
// prefix (e.g. `/api`) never affects the match.
|
|
3
|
+
const FILE_READ_PATHS = [
|
|
4
|
+
/\/datasets\/[^/]+\/download\/cog$/,
|
|
5
|
+
/\/datasets\/[^/]+\/export$/,
|
|
6
|
+
/\/datasets\/[^/]+\/tiles3d\/.+$/,
|
|
7
|
+
/\/datasets\/[^/]+\/copc\/[^/]+\/[^/]+\.copc\.laz$/,
|
|
8
|
+
];
|
|
9
|
+
function isFileReadPath(pathname) {
|
|
10
|
+
return FILE_READ_PATHS.some((pattern) => pattern.test(pathname));
|
|
11
|
+
}
|
|
12
|
+
const installed = new WeakSet();
|
|
13
|
+
/** Idempotent per client — safe to call every time a client is (re)configured. */
|
|
14
|
+
export function installFileReadHandling(target) {
|
|
15
|
+
if (installed.has(target)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
installed.add(target);
|
|
19
|
+
target.interceptors.request.use((request, options) => {
|
|
20
|
+
const opts = options;
|
|
21
|
+
// Only when the caller hasn't chosen a parser: an explicit `parseAs`
|
|
22
|
+
// (e.g. 'stream', to avoid buffering a large COG or export in memory)
|
|
23
|
+
// must still win over this route-level default.
|
|
24
|
+
if (isFileReadPath(new URL(request.url).pathname) &&
|
|
25
|
+
(opts.parseAs === undefined || opts.parseAs === 'auto')) {
|
|
26
|
+
// The same options object the client reads `parseAs` from after this
|
|
27
|
+
// interceptor returns (client.gen.ts's `request()`).
|
|
28
|
+
opts.parseAs = 'blob';
|
|
29
|
+
}
|
|
30
|
+
return request;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* True when `result` (a generated call's non-throwing return value) is a
|
|
35
|
+
* conditional read's cache hit: a 304 answering a request that sent
|
|
36
|
+
* `If-None-Match` or `If-Modified-Since`. With `throwOnError` a 304 throws
|
|
37
|
+
* before a result exists — call these file-read routes without it to use this.
|
|
38
|
+
*/
|
|
39
|
+
export function notModified(result) {
|
|
40
|
+
const sent = result.request?.headers;
|
|
41
|
+
return (result.response?.status === 304 &&
|
|
42
|
+
sent !== undefined &&
|
|
43
|
+
(sent.has('if-none-match') || sent.has('if-modified-since')));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=fileReads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileReads.js","sourceRoot":"","sources":["../src/fileReads.ts"],"names":[],"mappings":"AA0BA,0EAA0E;AAC1E,gDAAgD;AAChD,MAAM,eAAe,GAAG;IACtB,mCAAmC;IACnC,4BAA4B;IAC5B,iCAAiC;IACjC,mDAAmD;CACpD,CAAC;AAEF,SAAS,cAAc,CAAC,QAAgB;IACtC,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,OAAO,EAAU,CAAC;AAExC,kFAAkF;AAClF,MAAM,UAAU,uBAAuB,CAAC,MAAc;IACpD,IAAI,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IACD,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEtB,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACnD,MAAM,IAAI,GAAG,OAA+B,CAAC;QAC7C,qEAAqE;QACrE,sEAAsE;QACtE,gDAAgD;QAChD,IACE,cAAc,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;YAC7C,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,CAAC,EACvD,CAAC;YACD,qEAAqE;YACrE,qDAAqD;YACrD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,MAAkD;IAC5E,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACrC,OAAO,CACL,MAAM,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG;QAC/B,IAAI,KAAK,SAAS;QAClB,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAC7D,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public entry point for @geolens/sdk.
|
|
3
|
-
*
|
|
4
|
-
* Hand-maintained — re-exports the auth wrapper alongside the generated
|
|
5
|
-
* client + types. Drift gate excludes this file.
|
|
6
|
-
*/
|
|
7
1
|
export { createGeolensClient } from './auth.js';
|
|
8
2
|
export type { GeolensClientOptions, GeolensClient } from './auth.js';
|
|
3
|
+
export { notModified } from './fileReads.js';
|
|
4
|
+
export { RedirectError } from './redirects.js';
|
|
9
5
|
export * from './client/index.js';
|
|
10
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM/C,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,21 @@
|
|
|
5
5
|
* Hand-maintained — re-exports the auth wrapper alongside the generated
|
|
6
6
|
* client + types. Drift gate excludes this file.
|
|
7
7
|
*/
|
|
8
|
+
import { client } from './client/client.gen.js';
|
|
9
|
+
import { installFileReadHandling } from './fileReads.js';
|
|
10
|
+
import { installRedirectHandling } from './redirects.js';
|
|
8
11
|
// Hand-written auth surface
|
|
9
12
|
export { createGeolensClient } from './auth.js';
|
|
13
|
+
// Hand-written file-read result adapter
|
|
14
|
+
export { notModified } from './fileReads.js';
|
|
15
|
+
// Hand-written redirect handling
|
|
16
|
+
export { RedirectError } from './redirects.js';
|
|
10
17
|
// Generated surface — re-export everything users need to make API calls.
|
|
11
18
|
// (The generated index.ts in src/client/ already re-exports types + sdk
|
|
12
19
|
// functions + the singleton client; one-line re-export keeps the public
|
|
13
20
|
// API stable across regenerations.)
|
|
14
21
|
export * from './client/index.js';
|
|
22
|
+
// Generated functions called without createGeolensClient() use this singleton.
|
|
23
|
+
installFileReadHandling(client);
|
|
24
|
+
installRedirectHandling(client);
|
|
15
25
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,4BAA4B;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGhD,wCAAwC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,iCAAiC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,yEAAyE;AACzE,wEAAwE;AACxE,wEAAwE;AACxE,oCAAoC;AACpC,cAAc,mBAAmB,CAAC;AAElC,+EAA+E;AAC/E,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAChC,uBAAuB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redirect handling for the GeoLens TypeScript SDK.
|
|
3
|
+
*
|
|
4
|
+
* Hand-maintained — NOT regenerated by `make sdks`. Wired into every client
|
|
5
|
+
* `createGeolensClient()` produces (see auth.ts) and into the generated
|
|
6
|
+
* singleton (see index.ts).
|
|
7
|
+
*
|
|
8
|
+
* A request that leaves the GeoLens origin through a redirect carries no
|
|
9
|
+
* cookies and none of the original request's headers except `Range` and the
|
|
10
|
+
* `If-*` preconditions, and goes through the global `fetch`, never the
|
|
11
|
+
* client's `fetch` option. (On Node, a proxy set with undici's
|
|
12
|
+
* `setGlobalDispatcher` still applies.) With the default
|
|
13
|
+
* `redirect: 'follow'`, every request goes out with `redirect: 'manual'`,
|
|
14
|
+
* and a redirect answering a GET or HEAD is then handled here:
|
|
15
|
+
*
|
|
16
|
+
* - Where the redirect response is readable (Node), the SDK follows it: at
|
|
17
|
+
* most 20 hops, to http(s) URLs only. A hop that stays on the GeoLens
|
|
18
|
+
* origin resends the request unchanged. From the first hop to another
|
|
19
|
+
* origin on, requests carry only the headers named above.
|
|
20
|
+
* - A browser hides the redirect's target (an `opaqueredirect` response). A
|
|
21
|
+
* request with `Authorization` or `X-API-Key` throws {@link RedirectError}.
|
|
22
|
+
* Any other is sent once more with only the headers named above and
|
|
23
|
+
* `credentials: 'omit'`, and the browser follows it. For a COG download
|
|
24
|
+
* from a browser, mint a download token
|
|
25
|
+
* (`POST /auth/download-token/{dataset_id}`) and fetch
|
|
26
|
+
* `/datasets/{dataset_id}/download/cog?token=...` without credentials.
|
|
27
|
+
*
|
|
28
|
+
* A redirect answering any other method is returned unfollowed. Streaming
|
|
29
|
+
* (SSE) calls don't read the `fetch` option, so their manual mode comes from
|
|
30
|
+
* the request alone, which a later request interceptor can replace.
|
|
31
|
+
*
|
|
32
|
+
* Every hop, and the browser's resend, keeps the request's `mode`, `cache`,
|
|
33
|
+
* `keepalive`, `priority`, `referrer`, `referrerPolicy`, `integrity` and
|
|
34
|
+
* abort signal. A hop on the GeoLens
|
|
35
|
+
* origin also keeps its `credentials` mode. A `mode: 'same-origin'` request
|
|
36
|
+
* redirected to another origin rejects with a TypeError, as fetch does.
|
|
37
|
+
*
|
|
38
|
+
* A request with `redirect: 'manual'` or `'error'`, set per call or on the
|
|
39
|
+
* client, goes out with that setting, and fetch handles the redirect.
|
|
40
|
+
*/
|
|
41
|
+
import type { Client } from './client/client/index.js';
|
|
42
|
+
/** A redirect the SDK would not follow. */
|
|
43
|
+
export declare class RedirectError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
/** Idempotent per client — safe to call every time a client is (re)configured. */
|
|
47
|
+
export declare function installRedirectHandling(target: Client): void;
|
|
48
|
+
//# sourceMappingURL=redirects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects.d.ts","sourceRoot":"","sources":["../src/redirects.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAgBvD,2CAA2C;AAC3C,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAID,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAqB5D"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const MAX_REDIRECTS = 20;
|
|
2
|
+
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
3
|
+
const CREDENTIAL_HEADERS = ['authorization', 'x-api-key'];
|
|
4
|
+
// Not credentials, and a ranged or conditional read needs them at the
|
|
5
|
+
// storage host the backend redirects to.
|
|
6
|
+
const FORWARDED_HEADERS = [
|
|
7
|
+
'range',
|
|
8
|
+
'if-range',
|
|
9
|
+
'if-match',
|
|
10
|
+
'if-none-match',
|
|
11
|
+
'if-modified-since',
|
|
12
|
+
'if-unmodified-since',
|
|
13
|
+
];
|
|
14
|
+
/** A redirect the SDK would not follow. */
|
|
15
|
+
export class RedirectError extends Error {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'RedirectError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const installed = new WeakSet();
|
|
22
|
+
/** Idempotent per client — safe to call every time a client is (re)configured. */
|
|
23
|
+
export function installRedirectHandling(target) {
|
|
24
|
+
if (installed.has(target)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
installed.add(target);
|
|
28
|
+
target.interceptors.request.use((request, options) => {
|
|
29
|
+
if (!following(options)) {
|
|
30
|
+
return request;
|
|
31
|
+
}
|
|
32
|
+
// The client reads `fetch` after every request interceptor has run, so a
|
|
33
|
+
// later interceptor that rebuilds the request can't turn following back on.
|
|
34
|
+
const clientFetch = options.fetch ?? globalThis.fetch;
|
|
35
|
+
options.fetch = (input, init) => clientFetch(manual(input, init));
|
|
36
|
+
return manual(request);
|
|
37
|
+
});
|
|
38
|
+
target.interceptors.response.use((response, request, options) => following(options)
|
|
39
|
+
? followRedirect(response, request, options.fetch, options.priority)
|
|
40
|
+
: response);
|
|
41
|
+
}
|
|
42
|
+
function following(options) {
|
|
43
|
+
return (options.redirect ?? 'follow') === 'follow';
|
|
44
|
+
}
|
|
45
|
+
// Copying a Request resets its referrer and referrer policy unless the init
|
|
46
|
+
// names them.
|
|
47
|
+
function manual(input, init) {
|
|
48
|
+
const from = input instanceof Request ? input : undefined;
|
|
49
|
+
return new Request(input, {
|
|
50
|
+
referrer: from?.referrer,
|
|
51
|
+
referrerPolicy: from?.referrerPolicy,
|
|
52
|
+
...init,
|
|
53
|
+
redirect: 'manual',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async function followRedirect(response, request, clientFetch, priority) {
|
|
57
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
if (response.type === 'opaqueredirect') {
|
|
61
|
+
if (CREDENTIAL_HEADERS.some((name) => request.headers.has(name))) {
|
|
62
|
+
throw new RedirectError('The server redirected a request that carries credentials, and a browser ' +
|
|
63
|
+
'hides where to. Use a download token for file downloads instead.');
|
|
64
|
+
}
|
|
65
|
+
return globalThis.fetch(new Request(request.url, {
|
|
66
|
+
...carried(request, priority),
|
|
67
|
+
method: request.method,
|
|
68
|
+
headers: forwarded(request.headers),
|
|
69
|
+
redirect: 'follow',
|
|
70
|
+
credentials: 'omit',
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
const origin = new URL(request.url).origin;
|
|
74
|
+
let current = request;
|
|
75
|
+
let leftOrigin = false;
|
|
76
|
+
for (let hops = 0; isRedirect(response); hops++) {
|
|
77
|
+
await response.body?.cancel();
|
|
78
|
+
if (hops === MAX_REDIRECTS) {
|
|
79
|
+
throw new RedirectError(`Stopped after ${MAX_REDIRECTS} redirects`);
|
|
80
|
+
}
|
|
81
|
+
const target = new URL(response.headers.get('location'), current.url);
|
|
82
|
+
// The URL stays out of the message: a presigned URL is a credential.
|
|
83
|
+
if (target.protocol !== 'http:' && target.protocol !== 'https:') {
|
|
84
|
+
throw new RedirectError(`Redirected to an unsupported URL scheme: ${target.protocol}`);
|
|
85
|
+
}
|
|
86
|
+
if (request.mode === 'same-origin' && target.origin !== origin) {
|
|
87
|
+
throw new TypeError('A same-origin request was redirected to another origin');
|
|
88
|
+
}
|
|
89
|
+
leftOrigin ||= target.origin !== origin;
|
|
90
|
+
current = new Request(target, {
|
|
91
|
+
...carried(request, priority),
|
|
92
|
+
method: request.method,
|
|
93
|
+
headers: leftOrigin ? forwarded(current.headers) : current.headers,
|
|
94
|
+
credentials: leftOrigin ? 'omit' : request.credentials,
|
|
95
|
+
redirect: 'manual',
|
|
96
|
+
});
|
|
97
|
+
response = await (leftOrigin ? globalThis.fetch(current) : clientFetch(current));
|
|
98
|
+
}
|
|
99
|
+
return response;
|
|
100
|
+
}
|
|
101
|
+
// A Request doesn't expose its priority, so it comes from the call's options.
|
|
102
|
+
function carried(request, priority) {
|
|
103
|
+
return {
|
|
104
|
+
priority,
|
|
105
|
+
mode: request.mode,
|
|
106
|
+
cache: request.cache,
|
|
107
|
+
keepalive: request.keepalive,
|
|
108
|
+
referrer: request.referrer,
|
|
109
|
+
referrerPolicy: request.referrerPolicy,
|
|
110
|
+
integrity: request.integrity,
|
|
111
|
+
signal: request.signal,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function forwarded(headers) {
|
|
115
|
+
const kept = new Headers();
|
|
116
|
+
for (const name of FORWARDED_HEADERS) {
|
|
117
|
+
const value = headers.get(name);
|
|
118
|
+
if (value !== null) {
|
|
119
|
+
kept.set(name, value);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return kept;
|
|
123
|
+
}
|
|
124
|
+
function isRedirect(response) {
|
|
125
|
+
return REDIRECT_STATUSES.has(response.status) && response.headers.has('location');
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=redirects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirects.js","sourceRoot":"","sources":["../src/redirects.ts"],"names":[],"mappings":"AA2CA,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC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iB,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACpF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geolens/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "Auto-generated TypeScript SDK for the GeoLens API. Typed clients with Bearer + API-key auth helpers.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Carto Concepts, LLC",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"generate": "openapi-ts",
|
|
32
32
|
"build": "tsc && node scripts/fix-esm-extensions.mjs",
|
|
33
33
|
"verify:esm": "node -e \"import('./dist/index.js').then(m => { if (typeof m.createGeolensClient !== 'function') throw new Error('createGeolensClient export missing'); console.log('esm import ok'); })\"",
|
|
34
|
-
"test": "node --test test/auth_stale_headers.test.mjs test/auth_concurrent_clients.test.mjs test/auth_legacy_singleton.test.mjs test/prototype_substitution.test.mjs",
|
|
34
|
+
"test": "node --test test/auth_stale_headers.test.mjs test/auth_concurrent_clients.test.mjs test/auth_legacy_singleton.test.mjs test/prototype_substitution.test.mjs test/file_reads.test.mjs test/file_reads_singleton_install.test.mjs test/redirects.test.mjs test/redirects_singleton.test.mjs",
|
|
35
35
|
"prepublishOnly": "npm run build && npm run verify:esm"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|