@groundbrick/sveltekit-adapter 0.12.0 → 0.12.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.
- package/dist/server/clientAddress.d.ts +1 -6
- package/dist/server/clientAddress.d.ts.map +1 -1
- package/dist/server/clientAddress.js +1 -6
- package/dist/server/clientAddress.js.map +1 -1
- package/dist/server/forwardedClient.d.ts +4 -8
- package/dist/server/forwardedClient.d.ts.map +1 -1
- package/dist/server/forwardedClient.js +5 -9
- package/dist/server/forwardedClient.js.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
2
|
/**
|
|
3
|
-
* `event.getClientAddress()`
|
|
4
|
-
*
|
|
5
|
-
* adapter-node throws when `ADDRESS_HEADER` is set and a request arrives without
|
|
6
|
-
* that header, which is what happens to anything reaching the container without
|
|
7
|
-
* going through the reverse proxy (health checks, a curl from the host). A
|
|
8
|
-
* logging hook or an analytics call must not turn that into a 500.
|
|
3
|
+
* `event.getClientAddress()`, or `undefined` when it throws or returns an empty value.
|
|
9
4
|
*/
|
|
10
5
|
export declare function getClientAddressSafe(event: Pick<RequestEvent, 'getClientAddress'>): string | undefined;
|
|
11
6
|
//# sourceMappingURL=clientAddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientAddress.d.ts","sourceRoot":"","sources":["../../src/server/clientAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"clientAddress.d.ts","sourceRoot":"","sources":["../../src/server/clientAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAC,GAAG,MAAM,GAAG,SAAS,CAMtG"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `event.getClientAddress()`
|
|
3
|
-
*
|
|
4
|
-
* adapter-node throws when `ADDRESS_HEADER` is set and a request arrives without
|
|
5
|
-
* that header, which is what happens to anything reaching the container without
|
|
6
|
-
* going through the reverse proxy (health checks, a curl from the host). A
|
|
7
|
-
* logging hook or an analytics call must not turn that into a 500.
|
|
2
|
+
* `event.getClientAddress()`, or `undefined` when it throws or returns an empty value.
|
|
8
3
|
*/
|
|
9
4
|
export function getClientAddressSafe(event) {
|
|
10
5
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientAddress.js","sourceRoot":"","sources":["../../src/server/clientAddress.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"clientAddress.js","sourceRoot":"","sources":["../../src/server/clientAddress.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAA6C;IAC9E,IAAI,CAAC;QACD,OAAO,KAAK,CAAC,gBAAgB,EAAE,IAAI,SAAS,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,SAAS,CAAC;IACrB,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
2
|
/**
|
|
3
|
-
* Header names and signature of the forwarded-client protocol
|
|
3
|
+
* Header names and signature of the forwarded-client protocol, the same as
|
|
4
4
|
* `FORWARDED_CLIENT_HEADERS` and `signForwardedClient` in
|
|
5
5
|
* `@groundbrick/express-adapter`, which verifies them:
|
|
6
6
|
*
|
|
@@ -16,14 +16,10 @@ export declare const FORWARDED_CLIENT_HEADERS: {
|
|
|
16
16
|
};
|
|
17
17
|
export declare function signForwardedClient(secret: string, timestamp: number, ip: string, userAgent?: string): Promise<string>;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Signed headers with the client IP and user agent of `event`, for the requests
|
|
20
|
+
* this server makes to the API on the client's behalf.
|
|
20
21
|
*
|
|
21
|
-
*
|
|
22
|
-
* API on the browser's behalf (login proxies, session renewal). Without them the
|
|
23
|
-
* API sees this server's address and user agent for every user.
|
|
24
|
-
*
|
|
25
|
-
* Returns `{}` when there is no secret or the client address cannot be resolved,
|
|
26
|
-
* so the call goes out as before instead of failing.
|
|
22
|
+
* Returns `{}` when there is no secret or the client address cannot be resolved.
|
|
27
23
|
*/
|
|
28
24
|
export declare function createForwardedClientHeaders(event: Pick<RequestEvent, 'getClientAddress' | 'request'>, secret: string | undefined, now?: () => number): Promise<Record<string, string>>;
|
|
29
25
|
//# sourceMappingURL=forwardedClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forwardedClient.d.ts","sourceRoot":"","sources":["../../src/server/forwardedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB;;;;;CAK3B,CAAC;AAIX,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,SAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAIxH;AAED
|
|
1
|
+
{"version":3,"file":"forwardedClient.d.ts","sourceRoot":"","sources":["../../src/server/forwardedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB;;;;;CAK3B,CAAC;AAIX,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,SAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAIxH;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAC9C,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,kBAAkB,GAAG,SAAS,CAAC,EACzD,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,GAAG,GAAE,MAAM,MAAiB,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiBjC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getClientAddressSafe } from './clientAddress.js';
|
|
2
2
|
/**
|
|
3
|
-
* Header names and signature of the forwarded-client protocol
|
|
3
|
+
* Header names and signature of the forwarded-client protocol, the same as
|
|
4
4
|
* `FORWARDED_CLIENT_HEADERS` and `signForwardedClient` in
|
|
5
5
|
* `@groundbrick/express-adapter`, which verifies them:
|
|
6
6
|
*
|
|
@@ -21,14 +21,10 @@ export async function signForwardedClient(secret, timestamp, ip, userAgent = '')
|
|
|
21
21
|
return Array.from(new Uint8Array(signature), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Signed headers with the client IP and user agent of `event`, for the requests
|
|
25
|
+
* this server makes to the API on the client's behalf.
|
|
25
26
|
*
|
|
26
|
-
*
|
|
27
|
-
* API on the browser's behalf (login proxies, session renewal). Without them the
|
|
28
|
-
* API sees this server's address and user agent for every user.
|
|
29
|
-
*
|
|
30
|
-
* Returns `{}` when there is no secret or the client address cannot be resolved,
|
|
31
|
-
* so the call goes out as before instead of failing.
|
|
27
|
+
* Returns `{}` when there is no secret or the client address cannot be resolved.
|
|
32
28
|
*/
|
|
33
29
|
export async function createForwardedClientHeaders(event, secret, now = Date.now) {
|
|
34
30
|
if (!secret)
|
|
@@ -36,7 +32,7 @@ export async function createForwardedClientHeaders(event, secret, now = Date.now
|
|
|
36
32
|
const ip = getClientAddressSafe(event);
|
|
37
33
|
if (!ip)
|
|
38
34
|
return {};
|
|
39
|
-
//
|
|
35
|
+
// A user agent with characters outside printable ASCII is not forwarded.
|
|
40
36
|
const rawUserAgent = event.request.headers.get('user-agent') ?? '';
|
|
41
37
|
const userAgent = /^[\x20-\x7e]*$/.test(rawUserAgent) ? rawUserAgent : '';
|
|
42
38
|
const timestamp = Math.floor(now() / 1000);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forwardedClient.js","sourceRoot":"","sources":["../../src/server/forwardedClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACpC,EAAE,EAAE,uBAAuB;IAC3B,SAAS,EAAE,uBAAuB;IAClC,SAAS,EAAE,uBAAuB;IAClC,SAAS,EAAE,wBAAwB;CAC7B,CAAC;AAEX,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAc,EAAE,SAAiB,EAAE,EAAU,EAAE,SAAS,GAAG,EAAE;IACnG,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7H,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,KAAK,EAAE,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7G,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,C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B,CAC9C,KAAyD,EACzD,MAA0B,EAC1B,MAAoB,IAAI,CAAC,GAAG;IAE5B,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAEvB,MAAM,EAAE,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC;IAEnB,yEAAyE;IACzE,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IACnE,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAE3C,OAAO;QACH,CAAC,wBAAwB,CAAC,EAAE,CAAC,EAAE,EAAE;QACjC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC;QACvD,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,MAAM,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,CAAC;KACpG,CAAC;AACN,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Server-only helpers
|
|
1
|
+
// Server-only helpers, not re-exported from the package root.
|
|
2
2
|
export { getClientAddressSafe } from './clientAddress.js';
|
|
3
3
|
export { createForwardedClientHeaders, signForwardedClient, FORWARDED_CLIENT_HEADERS } from './forwardedClient.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groundbrick/sveltekit-adapter",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "SvelteKit integration adapter with API client, stores, hooks, analytics, and cookie consent system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@sentry/sveltekit": "^10.0.0"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@groundbrick/logger": "^0.
|
|
90
|
+
"@groundbrick/logger": "^0.6.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@types/node": "^20.10.0",
|