lixnet 1.3.5 → 1.3.6
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/exports.d.ts +1 -1
- package/dist/lib/util/request.d.ts +11 -8
- package/dist/lib/util/request.js +13 -8
- package/package.json +1 -1
package/dist/exports.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import LixnetClient from "./lib/client";
|
|
|
3
3
|
import LixnetPeer from "./lib/peer";
|
|
4
4
|
import { LixnetResponse } from "./lib/util/response";
|
|
5
5
|
export { LixnetServer, LixnetClient, LixnetPeer, LixnetResponse };
|
|
6
|
-
export type { LixnetRequest, ReadonlyHeaders, ReadonlyRequestCookies, RequestCookie, } from "./lib/util/request";
|
|
6
|
+
export type { LixnetCookies, LixnetHeaders, LixnetRequest, ReadonlyHeaders, ReadonlyRequestCookies, RequestCookie, } from "./lib/util/request";
|
|
7
7
|
export type { LXN_ServerClient_EventType, LXNServerHandler, FunctionInput, LXN_ServerClient_Request, LixnetServerInjections, } from "./lib/types";
|
|
@@ -3,9 +3,9 @@ export type RequestCookie = {
|
|
|
3
3
|
value: string;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Cookie API exposed by `LixnetRequest`: read from the request snapshot, write via `LixnetResponse`.
|
|
7
7
|
*/
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class LixnetCookies {
|
|
9
9
|
private readonly map;
|
|
10
10
|
private readonly mut?;
|
|
11
11
|
constructor(cookieHeader: string | null, mut?: {
|
|
@@ -27,10 +27,9 @@ export declare class ReadonlyRequestCookies {
|
|
|
27
27
|
[Symbol.iterator](): IterableIterator<[string, RequestCookie]>;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* Wraps a cloned `Headers` instance so callers cannot mutate the snapshot.
|
|
30
|
+
* Headers API exposed by `LixnetRequest`: read from the request snapshot, write via `LixnetResponse`.
|
|
32
31
|
*/
|
|
33
|
-
export declare class
|
|
32
|
+
export declare class LixnetHeaders {
|
|
34
33
|
private readonly h;
|
|
35
34
|
private readonly mut?;
|
|
36
35
|
constructor(headers: Headers, mut?: {
|
|
@@ -45,15 +44,15 @@ export declare class ReadonlyHeaders {
|
|
|
45
44
|
entries(): IterableIterator<[string, string]>;
|
|
46
45
|
keys(): IterableIterator<string>;
|
|
47
46
|
values(): IterableIterator<string>;
|
|
48
|
-
forEach(callbackfn: (value: string, name: string, parent:
|
|
47
|
+
forEach(callbackfn: (value: string, name: string, parent: LixnetHeaders) => void, thisArg?: unknown): void;
|
|
49
48
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
50
49
|
set(name: string, value: string): void;
|
|
51
50
|
append(name: string, value: string): void;
|
|
52
51
|
delete(name: string): void;
|
|
53
52
|
}
|
|
54
53
|
export type LixnetRequest = Omit<Request, "headers"> & {
|
|
55
|
-
cookies():
|
|
56
|
-
headers():
|
|
54
|
+
cookies(): LixnetCookies;
|
|
55
|
+
headers(): LixnetHeaders;
|
|
57
56
|
};
|
|
58
57
|
/** Used by the server only; not part of the public package API. */
|
|
59
58
|
export declare function wrapLixnetRequest(request: Request, response: {
|
|
@@ -69,3 +68,7 @@ export declare function wrapLixnetRequest(request: Request, response: {
|
|
|
69
68
|
options?: unknown;
|
|
70
69
|
}>;
|
|
71
70
|
}): LixnetRequest;
|
|
71
|
+
/** @deprecated Use {@link LixnetCookies}. */
|
|
72
|
+
export type ReadonlyRequestCookies = LixnetCookies;
|
|
73
|
+
/** @deprecated Use {@link LixnetHeaders}. */
|
|
74
|
+
export type ReadonlyHeaders = LixnetHeaders;
|
package/dist/lib/util/request.js
CHANGED
|
@@ -28,9 +28,9 @@ function parseCookieHeader(header) {
|
|
|
28
28
|
return map;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Cookie API exposed by `LixnetRequest`: read from the request snapshot, write via `LixnetResponse`.
|
|
32
32
|
*/
|
|
33
|
-
export class
|
|
33
|
+
export class LixnetCookies {
|
|
34
34
|
map;
|
|
35
35
|
mut;
|
|
36
36
|
constructor(cookieHeader, mut) {
|
|
@@ -119,10 +119,9 @@ export class ReadonlyRequestCookies {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
*
|
|
123
|
-
* Wraps a cloned `Headers` instance so callers cannot mutate the snapshot.
|
|
122
|
+
* Headers API exposed by `LixnetRequest`: read from the request snapshot, write via `LixnetResponse`.
|
|
124
123
|
*/
|
|
125
|
-
export class
|
|
124
|
+
export class LixnetHeaders {
|
|
126
125
|
h;
|
|
127
126
|
mut;
|
|
128
127
|
constructor(headers, mut) {
|
|
@@ -178,7 +177,13 @@ export class ReadonlyHeaders {
|
|
|
178
177
|
}
|
|
179
178
|
forEach(callbackfn, thisArg) {
|
|
180
179
|
const self = this;
|
|
181
|
-
this.h
|
|
180
|
+
const merged = new Headers(this.h);
|
|
181
|
+
const staged = this.mut?.getStaged?.();
|
|
182
|
+
if (staged) {
|
|
183
|
+
for (const [k, v] of Object.entries(staged))
|
|
184
|
+
merged.set(k, v);
|
|
185
|
+
}
|
|
186
|
+
merged.forEach(function (value, name) {
|
|
182
187
|
callbackfn.call(thisArg ?? self, value, name, self);
|
|
183
188
|
});
|
|
184
189
|
}
|
|
@@ -233,12 +238,12 @@ export function wrapLixnetRequest(request, response) {
|
|
|
233
238
|
get(target, prop, receiver) {
|
|
234
239
|
if (prop === "cookies") {
|
|
235
240
|
return function cookies() {
|
|
236
|
-
return new
|
|
241
|
+
return new LixnetCookies(snapshot.get("cookie"), cookieMut);
|
|
237
242
|
};
|
|
238
243
|
}
|
|
239
244
|
if (prop === "headers") {
|
|
240
245
|
return function headers() {
|
|
241
|
-
return new
|
|
246
|
+
return new LixnetHeaders(snapshot, headerMut);
|
|
242
247
|
};
|
|
243
248
|
}
|
|
244
249
|
return Reflect.get(target, prop, receiver);
|