webdaemon 11.5.1 → 12.0.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.
@@ -0,0 +1,257 @@
1
+ export class Token {
2
+ static Source: {
3
+ PARTY_CONTROL: string;
4
+ };
5
+ static Counterparty: {
6
+ PUBLIC: string;
7
+ };
8
+ static Capability: {
9
+ OPEN: string;
10
+ CLOSE: string;
11
+ GRANT: string;
12
+ REVOKE: string;
13
+ OFFER: string;
14
+ RETRACT: string;
15
+ DELETE: string;
16
+ CATALOG: string;
17
+ ALIAS: string;
18
+ UNALIAS: string;
19
+ GET_ITEM: string;
20
+ SET_ITEM: string;
21
+ ALERT: string;
22
+ LOG: string;
23
+ READ: string;
24
+ WRITE: string;
25
+ };
26
+ static DEFAULT_EXPIRY_MILLIS: number;
27
+ static TOKEN_HEADER: string;
28
+ static SCOPE_SEPARATOR: RegExp;
29
+ /**
30
+ * Returns a base64 JSON string corresponding to the provided byte array.
31
+ *
32
+ * @param {Uint8Array} bytes to be encoded as a base64 string.
33
+ * @returns {string} the encoded bytes.
34
+ */
35
+ static bytesToBase64(bytes: Uint8Array): string;
36
+ /**
37
+ * Returns the byte array decoded from the base64 string.
38
+ *
39
+ * @param {string} base64
40
+ * @returns {Uint8Array} the decoded bytes.
41
+ */
42
+ static base64ToBytes(base64: string): Uint8Array;
43
+ /**
44
+ * Returns a new token using the x-tabserver-token header on the
45
+ * request.
46
+ *
47
+ * @param {Request} request the request.
48
+ * @return {Token | null} the token, or null if no header is present.
49
+ * @throws {string} exception if token cannot be constructed.
50
+ */
51
+ static from(request: Request): Token | null;
52
+ /**
53
+ * Converts an object whose string keys map to token objects
54
+ * into URL-friendly search params suitable for use in a
55
+ * query string or fragment.
56
+ *
57
+ * The string keys are normally the audience hostname, or the
58
+ * special key 'party' which holds the identity token whose
59
+ * `aud` and `sub` are the same.
60
+ *
61
+ * @param {TokenSet} tokenSet the set of tokens keyed by string.
62
+ * @returns {string}
63
+ */
64
+ static toSearchString(tokenSet: TokenSet): string;
65
+ /**
66
+ * Constructor takes either a signed base64 token, or a payload object.
67
+ *
68
+ * If successful, the payload and optionally the signature fields are
69
+ * populated.
70
+ *
71
+ * @param {object | string} source a payload, or a base64 token
72
+ */
73
+ constructor(source: object | string);
74
+ /**
75
+ * Generates the signature for the object using the private key provided by the
76
+ * supplied callback and stores the result.
77
+ *
78
+ * @param {Promise<JsonWebKey>} privateJwkPromise the private key used for signing.
79
+ * @return {Promise<string>} resolved with the base64 signature if signed successfully.
80
+ */
81
+ signWith(privateJwkPromise: Promise<JsonWebKey>): Promise<string>;
82
+ /**
83
+ * Retrieves the signatory using the `iss` field, checks the signature
84
+ * and if valid sets the signatory property in this instance.
85
+ *
86
+ * @throws {string} if signatory cannot be retrieved or signature doesn't match.
87
+ */
88
+ verifySignatory(): Promise<void>;
89
+ /**
90
+ * Fetches the signatory from the `iss` URL, setting the instance
91
+ * property.
92
+ *
93
+ * The signatory comprises the `src` representing the app that has
94
+ * signed the token and the public `jwk`.
95
+ *
96
+ * Caching may be introduced to reduce latency and bandwidth use.
97
+ *
98
+ * @throws {string} error if fetch fails or returns an error response.
99
+ */
100
+ fetchSignatory(): Promise<void>;
101
+ /**
102
+ * Checks the signature using the public key provided by the supplied callback,
103
+ * and stores the result.
104
+ *
105
+ * @param {Promise<JsonWebKey>} publicJwkPromise the public key used to verify the signature.
106
+ * @throws {string} exception if signature cannot be verified or the public key is null or error.
107
+ */
108
+ checkSignature(publicJwkPromise: Promise<JsonWebKey>): Promise<void>;
109
+ /**
110
+ * Returns the payload with the `sig` property added.
111
+ *
112
+ * @return {TokenPayload} the payload with `sig` property.
113
+ */
114
+ getSignedPayload(): TokenPayload;
115
+ /**
116
+ * Returns the payload whether signed or not.
117
+ *
118
+ * @return {TokenPayload} the payload object without signature.
119
+ */
120
+ getPayload(): TokenPayload;
121
+ /**
122
+ * Returns the `aud` field as a string.
123
+ *
124
+ * @return {string} the `aud` field value.
125
+ */
126
+ getAud(): string;
127
+ /**
128
+ * Returns the `aud` host which is the party name handling the request.
129
+ *
130
+ * @return {string} the party name.
131
+ */
132
+ getParty(): string;
133
+ /**
134
+ * Returns the `sub` field as a string.
135
+ *
136
+ * @return {string} the `sub` field value.
137
+ */
138
+ getSub(): string;
139
+ /**
140
+ * Returns the `sub` host, which is the counterparty name making the
141
+ * request.
142
+ *
143
+ * @return {string} the counterparty name.
144
+ */
145
+ getCounterparty(): string;
146
+ /**
147
+ * Returns the source of the signatory who signed on behalf of the
148
+ * counterparty. This is only available once the token is
149
+ * verified, as it is provided by the `iss` endpoint.
150
+ *
151
+ * @returns {string} source of the verified signatory.
152
+ */
153
+ getSignatorySrc(): string;
154
+ /**
155
+ * Returns the `src` URL.
156
+ *
157
+ * @return {URL} the source URL.
158
+ */
159
+ getSourceUrl(): URL;
160
+ /**
161
+ * Returns the `issuer` field as a URL. The counterparty is inferred from
162
+ * the host name which generally matches the sub field.
163
+ *
164
+ * @return {URL} the issuer URL.
165
+ */
166
+ getIssuer(): URL;
167
+ /**
168
+ * Returns the list of zero or more sources for which scope is requested.
169
+ *
170
+ * @return {string[]} a list of source URL strings.
171
+ */
172
+ getSources(): string[];
173
+ /**
174
+ * Returns the scope for the source as an array of capability tokens.
175
+ *
176
+ * These can be separated by any mix of space, comma, semicolon
177
+ * or vertical bar.
178
+ *
179
+ * @param {string} source whose capabilities are returned.
180
+ * @return {string[]} zero or more scope tokens.
181
+ */
182
+ getCapabilities(source: string): string[];
183
+ /**
184
+ * Returns true if the supplied capability is present in the token
185
+ * scope under the specified source, otherwise false.
186
+ *
187
+ * @param {string} source the source under which the capability is expected.
188
+ * @param {string} capability the capability being tested.
189
+ * @return {boolean} true if capability is present in the scope, otherwise false.
190
+ */
191
+ hasCapability(source: string, capability: string): boolean;
192
+ /**
193
+ * Checks the token is within the period defined by the `iat` and `exp`
194
+ * date fields.
195
+ *
196
+ * @throws {string} exception if not within valid period.
197
+ */
198
+ checkPeriod(): void;
199
+ /**
200
+ * Returns the signed object including the `sig` property as a base64 string.
201
+ *
202
+ * @return {string} the signed object as a base64 string.
203
+ */
204
+ asSignedBase64(): string;
205
+ #private;
206
+ }
207
+ export type Scope = {
208
+ [x: string]: string;
209
+ };
210
+ export type TokenPayload = {
211
+ /**
212
+ * // URL of public key of counterparty making request.
213
+ */
214
+ iss: string;
215
+ /**
216
+ * // Party origin handling the request.
217
+ */
218
+ aud: string;
219
+ /**
220
+ * // Counterparty origin making the request.
221
+ */
222
+ sub: string;
223
+ /**
224
+ * // Source HTML document context of the request excluding fragment and query.
225
+ */
226
+ src: string;
227
+ /**
228
+ * // Map of scope (space-separated capabilities) keyed by source URL.
229
+ */
230
+ scope: Scope;
231
+ /**
232
+ * // Issued at time.
233
+ */
234
+ iat: number;
235
+ /**
236
+ * // Expiry time.
237
+ */
238
+ exp: number;
239
+ /**
240
+ * // Signature if signed.
241
+ */
242
+ sig: string;
243
+ };
244
+ /**
245
+ * the object to be served on the iss URL.
246
+ */
247
+ export type Signatory = {
248
+ /**
249
+ * which is 'party:control' if the shell, or source URL if a runner.
250
+ */
251
+ src: string | null;
252
+ jwk: JsonWebKey;
253
+ };
254
+ export type TokenSet = {
255
+ [x: string]: Token;
256
+ };
257
+ //# sourceMappingURL=Token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Token.d.ts","sourceRoot":"","sources":["../../../js/Token.js"],"names":[],"mappings":"AAmFA;IAGE;;MAEC;IAGD;;MAEC;IAGD;;;;;;;;;;;;;;;;;MAiBC;IAED,qCAAkD;IAClD,4BAAyC;IACzC,+BAAoC;IAsXpC;;;;;OAKG;IACH,4BAHW,UAAU,GACR,MAAM,CAKlB;IAED;;;;;OAKG;IACH,6BAHW,MAAM,GACJ,UAAU,CAKtB;IAED;;;;;;;OAOG;IACH,qBAJW,OAAO,GACN,KAAK,GAAG,IAAI,CAUvB;IAED;;;;;;;;;;;OAWG;IACH,gCAHW,QAAQ,GACN,MAAM,CAUlB;IA5ZD;;;;;;;OAOG;IACH,oBAFW,MAAM,GAAG,MAAM,EA8DzB;IAED;;;;;;OAMG;IACH,4BAHW,OAAO,CAAC,UAAU,CAAC,GAClB,OAAO,CAAC,MAAM,CAAC,CAgB1B;IAED;;;;;OAKG;IACH,iCAMC;IAED;;;;;;;;;;OAUG;IACH,gCAkBC;IAED;;;;;;OAMG;IACH,iCAHW,OAAO,CAAC,UAAU,CAAC,iBAoB7B;IAED;;;;OAIG;IACH,oBAFY,YAAY,CAWvB;IAED;;;;OAIG;IACH,cAFY,YAAY,CAOvB;IAED;;;;OAIG;IACH,UAFY,MAAM,CAIjB;IAGD;;;;OAIG;IACH,YAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,UAFY,MAAM,CAIjB;IAED;;;;;OAKG;IACH,mBAFY,MAAM,CAIjB;IAED;;;;;;OAMG;IACH,mBAFa,MAAM,CAWlB;IAED;;;;OAIG;IACH,gBAFY,GAAG,CAId;IAED;;;;;OAKG;IACH,aAFY,GAAG,CAId;IAED;;;;OAIG;IACH,cAFY,MAAM,EAAE,CAYnB;IAED;;;;;;;;OAQG;IACH,wBAHW,MAAM,GACL,MAAM,EAAE,CAanB;IAED;;;;;;;OAOG;IACH,sBAJW,MAAM,cACN,MAAM,GACL,OAAO,CAIlB;IAED;;;;;OAKG;IACH,oBAkBC;IAED;;;;OAIG;IACH,kBAFY,MAAM,CAIjB;;CA8DF;;;;;;;;SAzfa,MAAM;;;;SACN,MAAM;;;;SACN,MAAM;;;;SACN,MAAM;;;;WACN,KAAK;;;;SACL,MAAM;;;;SACN,MAAM;;;;SACN,MAAM;;;;;;;;;SAKN,MAAM,OAAC;SACP,UAAU"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Use this type to reference a plain object with
3
+ * random string keys.
4
+ */
5
+ export interface Plain {
6
+ [key: string]: any;
7
+ }
8
+ /**
9
+ * Any JSON-serialisable type.
10
+ */
11
+ export type JSONPrimitive = string | number | boolean | null;
12
+ export type JSONArray = JSONValue[];
13
+ export interface JSONObject {
14
+ [key: string]: JSONValue;
15
+ }
16
+ export type JSONValue = JSONPrimitive | JSONObject | JSONArray;
17
+ /**
18
+ * Type predicates to be used in type-narrowing assertions, e.g.
19
+ *
20
+ * assert(notNull(someValue))
21
+ * ... now the type of someValue does not include null ...
22
+ *
23
+ * or
24
+ * if (isOk(returnValue)) {
25
+ * ...in this block we know returnValue.ok is present and of the correct type.
26
+ * }
27
+ *
28
+ * @param value the value to be tested.
29
+ * @returns true if not null, otherwise false.
30
+ */
31
+ export declare function notNull<T>(value: T | null): value is T;
32
+ export declare function isDefined<T>(value: T | undefined): value is T;
33
+ //# sourceMappingURL=Assertions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assertions.d.ts","sourceRoot":"","sources":["../../../ts/Assertions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,KAAK;IAEpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;AAC5D,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAA;AACnC,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CACzB;AACD,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,CAAA;AAG9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,KAAK,IAAI,CAAC,CAEtD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,KAAK,IAAI,CAAC,CAE7D"}
@@ -0,0 +1,102 @@
1
+ import { Plain } from './Assertions.ts';
2
+ import { Token, Scope } from '../js/Token.js';
3
+ export interface DaemonConfig {
4
+ system: {
5
+ protocol: 'http:' | 'https:';
6
+ party: string;
7
+ issuer: string;
8
+ source: string;
9
+ sourcePrefix: string;
10
+ tab: string;
11
+ privateJwk: JsonWebKey;
12
+ };
13
+ user: Plain;
14
+ }
15
+ export declare const DAEMON_PREFIX = "daemon";
16
+ export declare const CONFIG_PATH = "config";
17
+ export declare const EVENT_PATH = "event";
18
+ /**
19
+ * Encapsulates the lifecycle event requests that occur on
20
+ * runner start and termination and when alerts are resolved
21
+ * or rejected.
22
+ *
23
+ * The Lifecycle object also provides static methods to retrieve
24
+ * configuration items, a public and private key pair, and also to
25
+ * produce the signed token that is required in requests from this party
26
+ * to third parties.
27
+ */
28
+ export declare class Lifecycle extends EventTarget {
29
+ #private;
30
+ static Ev: {
31
+ Config: string;
32
+ };
33
+ static getInstance(): Lifecycle;
34
+ /**
35
+ * All system requests are under the /daemon/ path.
36
+ *
37
+ * @param {Request} request to be tested.
38
+ * @returns {boolean} true if the request is a lifecycle request.
39
+ */
40
+ static shouldHandle(request: Request): boolean;
41
+ static isConfig(request: Request): boolean;
42
+ static isEvent(request: Request): boolean;
43
+ /**
44
+ * Handles a lifecycle request.
45
+ *
46
+ * @param {Request} request to be handled.
47
+ * @returns {Response} response for caller.
48
+ */
49
+ handler(request: Request): Promise<Response>;
50
+ /**
51
+ * Saves the lifecycle config object provided in the request body.
52
+ *
53
+ * Fires a 'config' lifecycle event.
54
+ *
55
+ * @param {Request} request containing the configuration json.
56
+ * @return {Response} ok response.
57
+ */
58
+ handleConfig(request: Request): Promise<Response>;
59
+ /**
60
+ * Fires a lifecycle event upon receiving an event request.
61
+ *
62
+ * @param {Request} request containing the event.
63
+ * @return {Response} ok response.
64
+ */
65
+ handleEvent(request: Request): Promise<Response>;
66
+ /**
67
+ * Returns the configuration object stored on initialisation.
68
+ * @return {DaemonConfig} the daemon configuration object.
69
+ * @throws {string} exception if config is not yet initialised.
70
+ */
71
+ static getConfig(): DaemonConfig;
72
+ /**
73
+ * Generates if necessary and returns a private key for
74
+ * use in signing tokens.
75
+ *
76
+ * @returns {JSONWebKey} the private key for this session.
77
+ */
78
+ static getPrivateKey(): Promise<JsonWebKey>;
79
+ /**
80
+ * Returns a token suitable for the `x-tabserver-token` header
81
+ * in a request to the supplied party with the required
82
+ * scope.
83
+ *
84
+ * If party is omitted, it defaults to this party.
85
+ * If
86
+ *
87
+ * @param {Scope} scope map of string source -> space-separated capabilities.
88
+ * @param {string=} party the party host name to whom the request will be sent.
89
+ * @param { src=} src the HTML page from which the request is (actually or notionally) made.
90
+ * @param {number=} ttlMillis the lifetime of this token.
91
+ * @returns {Token} the signed token.
92
+ * @throws {string} if configuration not yet initialised.
93
+ *
94
+ */
95
+ static getTokenFor(scope: Scope, party?: string | null, src?: string | null, ttlMillis?: number): Promise<Token>;
96
+ /**
97
+ * Returns a token for our party with the setitem and getitem
98
+ * capabilities on the party control source.
99
+ */
100
+ static getStorageToken(): Promise<Token>;
101
+ }
102
+ //# sourceMappingURL=Lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Lifecycle.d.ts","sourceRoot":"","sources":["../../../ts/Lifecycle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAa,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAG7C,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE;QACN,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAA;QAC5B,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,CAAA;QACd,YAAY,EAAE,MAAM,CAAA;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,UAAU,CAAA;KACvB,CAAA;IACD,IAAI,EAAE,KAAK,CAAA;CACZ;AAGD,eAAO,MAAM,aAAa,WAAW,CAAA;AAGrC,eAAO,MAAM,WAAW,WAAW,CAAA;AACnC,eAAO,MAAM,UAAU,UAAU,CAAA;AAkBjC;;;;;;;;;GASG;AACH,qBAAa,SAAU,SAAQ,WAAW;;IAIxC,MAAM,CAAC,EAAE;;MAAK;IAEd,MAAM,CAAC,WAAW;IAIlB;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAO9C,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IAS1C,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO;IASzC;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAYlD;;;;;;;OAOG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAWvD;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAatD;;;;OAIG;IACH,MAAM,CAAC,SAAS,IAAI,YAAY;IAQhC;;;;;OAKG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC;IAS3C;;;;;;;;;;;;;;;MAeE;WACW,WAAW,CACtB,KAAK,EAAE,KAAK,EACZ,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,GAAG,GAAE,MAAM,GAAG,IAAW,EACzB,SAAS,GAAE,MAA2B,GACrC,OAAO,CAAC,KAAK,CAAC;IAsCjB;;;OAGG;IACH,MAAM,CAAC,eAAe,IAAI,OAAO,CAAC,KAAK,CAAC;CAazC"}
@@ -0,0 +1,69 @@
1
+ import { Plain } from "./Assertions.ts";
2
+ /**
3
+ * Returns the request protocol. This is the first of the following:
4
+ *
5
+ * 1. The `x-forwarded-proto` header, if present, with trailing colon.
6
+ * 2. The request URL protocol, ditto.
7
+ *
8
+ * @param request the request.
9
+ * @returns {string} the protocol with trailing colon.
10
+ */
11
+ export declare function getClientProtocol(request: Request): string;
12
+ /**
13
+ * Returns the request host name. This is the first of the following:
14
+ *
15
+ * 1. The `x-forwarded-host` header, if present.
16
+ * 2. The request URL hostname (including port, if present)
17
+ *
18
+ * @param request the request.
19
+ * @returns the protocol.
20
+ */
21
+ export declare function getClientHost(request: Request): string;
22
+ /**
23
+ * Returns the request pathname. This is the first of the following:
24
+ *
25
+ * 1. The `x-forwarded-pathname` header, if present.
26
+ * 2. The request URL pathname.
27
+ */
28
+ export declare function getClientPathname(request: Request): string;
29
+ /**
30
+ * Returns the client request protocol, host and pathname components
31
+ * only.
32
+ *
33
+ * @param request the request.
34
+ * @return {URL} the protocol://host/pathname
35
+ */
36
+ export declare function getClientUrlPhp(request: Request): URL;
37
+ /**
38
+ * Returns the URL as requested by the client taking account
39
+ * of the x-forwarded protocol and host.
40
+ *
41
+ * @param request the request.
42
+ * @returns the URL.
43
+ */
44
+ export declare function getClientUrl(request: Request): URL;
45
+ /**
46
+ * Returns the pathname portion of the request URL, excluding
47
+ * query and fragment components.
48
+ *
49
+ * @param {request} the request.
50
+ * @returns {string} the pathname which starts with a forward slash.
51
+ */
52
+ export declare function getPathname(request: Request): string;
53
+ /**
54
+ * Returns the string value of a named cookie, or null if it is not
55
+ * present in the request.
56
+ *
57
+ * @param {Request} request the request.
58
+ * @param {string} cookieName the name of the cookie
59
+ * @returns {string} the cookie value, or null if not present.
60
+ */
61
+ export declare function getCookie(request: Request, cookieName: string): string | null;
62
+ /**
63
+ * Returns a map of request cookie names to values, which can be empty.
64
+ *
65
+ * @param {Request} request the request.
66
+ * @returns {Plain} the plain object with zero or more cookie keys.
67
+ */
68
+ export declare function getCookies(request: Request): Plain;
69
+ //# sourceMappingURL=Requests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Requests.d.ts","sourceRoot":"","sources":["../../../ts/Requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AASxC;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAM1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAMtD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAM1D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,GAAG,CAKrD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,GAAG,CAMlD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAGpD;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM7E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,CAUlD"}
@@ -0,0 +1,54 @@
1
+ import { Plain } from './Assertions.ts';
2
+ export interface Ok<T> {
3
+ ok: T;
4
+ }
5
+ export interface Error {
6
+ error: string;
7
+ }
8
+ /**
9
+ * Returns an ok response or an error response corresponding
10
+ * to the standard ok or error return value.
11
+ *
12
+ * If the error string starts with a space-separated status code,
13
+ * then that is used as the status code for the response.
14
+ *
15
+ * For example:
16
+ *
17
+ * {error: 'Ordinary Error'}
18
+ * is sent as is with status 200.
19
+ * {error: '401 Authentication Error'}
20
+ * is sent as {error: 'Authentication Error'} with status 401
21
+ */
22
+ export declare function response<T>(rvalue: Ok<T> | Error, extraHeaders?: Plain): Response;
23
+ /**
24
+ * Returns a 404 error response, including
25
+ * the standard JSON error return value.
26
+ * @deprecated Use response instead using a status-prefixed error message.
27
+ */
28
+ export declare function response404<T>(json?: Error): Response;
29
+ /**
30
+ * Returns a 302 permanent redirect response.
31
+ * @param url the url to redirect to.
32
+ * @returns Response object.
33
+ */
34
+ export declare function response302(url: URL, extraHeaders?: Plain): Response;
35
+ /**
36
+ * Simple build-a-cookie support.
37
+ *
38
+ * If the `expires` attribute is not defined, it's a session cookie.
39
+ * Otherwise it's a permanent cookie. To delete a cookie, use the
40
+ * `expires` attribute set to `new Date(0)`.
41
+ */
42
+ export interface CookiePayload {
43
+ name: string;
44
+ value: string;
45
+ domain?: string;
46
+ sameSite?: 'Strict' | 'Lax' | 'None';
47
+ path?: string;
48
+ expires?: Date;
49
+ secure?: boolean;
50
+ httpOnly?: boolean;
51
+ }
52
+ export type CookieString = string;
53
+ export declare function buildCookie(payload: CookiePayload): CookieString;
54
+ //# sourceMappingURL=Responses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Responses.d.ts","sourceRoot":"","sources":["../../../ts/Responses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,MAAM,WAAW,EAAE,CAAC,CAAC;IACnB,EAAE,EAAE,CAAC,CAAA;CACN;AAED,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,YAAY,CAAC,EAAE,KAAK,YA2BtE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,GAAE,KAEpC,YASA;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,GAAE,KAAU,GAAG,QAAQ,CASxE;AAED;;;;;;GAMG;AAEH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAA;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AAEjC,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CAuBhE"}
package/package.json CHANGED
@@ -2,10 +2,11 @@
2
2
  "name": "webdaemon",
3
3
  "type": "module",
4
4
  "main": "dist/index.js",
5
+ "types": "dist/types/index.d.ts",
5
6
  "files": [
6
7
  "dist"
7
8
  ],
8
- "version": "11.5.1",
9
+ "version": "12.0.0",
9
10
  "description": "Web Daemon",
10
11
  "module": "./dist/index.js",
11
12
  "keywords": [
@@ -19,6 +20,10 @@
19
20
  "typescript": "^5.7.2"
20
21
  },
21
22
  "scripts": {
22
- "build": "node esbuild.esm.js"
23
+ "build": "deno --allow-all esbuild.esm.js && tsc --project tsconfig.json",
24
+ "types": "tsc --project tsconfig.json"
25
+ },
26
+ "bin": {
27
+ "test": "./bin/test.js"
23
28
  }
24
29
  }