@types/sap__approuter 14.3.0 → 14.3.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.
sap__approuter/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for @sap/approuter (https://www.npmjs.com
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sap__approuter.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Tue, 21 Nov 2023 10:39:42 GMT
11
+ * Last updated: Thu, 23 Nov 2023 10:36:26 GMT
12
12
  * Dependencies: [@types/http-server](https://npmjs.com/package/@types/http-server), [@types/node](https://npmjs.com/package/@types/node), [@types/verror](https://npmjs.com/package/@types/verror)
13
13
 
14
14
  # Credits
sap__approuter/index.d.ts CHANGED
@@ -75,7 +75,11 @@ declare namespace approuter {
75
75
  * @param response - Object for the outgoing Response; can be manipulated to alter the response
76
76
  * @param next - Call next to give control back to Application Router Middleware
77
77
  */
78
- type MiddlewareHandler = (request: AppRouterIncomingMessage, response: ServerResponse, next: () => void) => void;
78
+ type MiddlewareHandler = (
79
+ request: AppRouterIncomingMessage,
80
+ response: ServerResponse,
81
+ next: (value?: Error | string) => void,
82
+ ) => void;
79
83
 
80
84
  interface Extensions {
81
85
  /**
@@ -253,21 +257,6 @@ declare namespace approuter {
253
257
 
254
258
  /**
255
259
  * SAP Application Router
256
- *
257
- * For full help, please consult the README file in @sap/approuter (the source npm package) or
258
- * https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/LATEST/en-US/050d87a61faa4fb88f687abd7bdf16ce.html
259
- *
260
- * These types (and their tests) are mostly extracted from the above mentioned README file and `doc/extending.md`
261
- * in @sap/approuter (the source npm package). If some types are incorrect or missing, please open up an issue at
262
- * {@link https://github.com/DefinitelyTyped/DefinitelyTyped}, or, even better, add them by yourself via a Pull Request.
263
- *
264
- * ## Command Parser
265
- * The {@link cmdParser} property is set to a {@link Command} instance when instantiating an Approuter. It is possible
266
- * to disable this feature by setting {@link cmdParser} to false. To do this typesafe, you have to use
267
- * `Approuter<false>` as a type when creating the Approuter instance.
268
- * @example
269
- * const ar = new Approuter<false>();
270
- * ar.cmdParser = false;
271
260
  */
272
261
  interface Approuter extends EventEmitter {
273
262
  /**
@@ -0,0 +1,40 @@
1
+ import { IncomingMessage } from "http";
2
+
3
+ export type checkTokenResult = {
4
+ isValid: boolean;
5
+ details: string;
6
+ };
7
+
8
+ /**
9
+ * Checks if a token is required for an incoming request:
10
+ * - GET and HEAD requests do not require a token (except if they are used to fetch a new token)
11
+ * - public path requests do not require a token
12
+ *
13
+ * @param req
14
+ * @returns true if a token is required, else false
15
+ */
16
+ export function isTokenRequired(req: IncomingMessage): boolean;
17
+
18
+ export function isTokenFetchRequest(req: IncomingMessage): boolean;
19
+
20
+ /**
21
+ * Check a token send by the client
22
+ *
23
+ * @param req
24
+ * @returns {isValid: boolean, details: string}
25
+ */
26
+ export function checkToken(req: IncomingMessage): checkTokenResult;
27
+
28
+ /**
29
+ * Returns a new token and stores it in the session (or returns an existing one from the session)
30
+ *
31
+ * @param req
32
+ * @param cb function cb(err, token)
33
+ */
34
+ export function getToken<T = void>(req: IncomingMessage, cb: (error: Error | null, xsrfToken?: string) => T): T;
35
+
36
+ export function hasTokenFetchHeader(req: IncomingMessage): boolean;
37
+
38
+ export function isGetRequest(req: IncomingMessage): boolean;
39
+
40
+ export function isHeadRequest(req: IncomingMessage): boolean;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/sap__approuter",
3
- "version": "14.3.0",
3
+ "version": "14.3.1",
4
4
  "description": "TypeScript definitions for @sap/approuter",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sap__approuter",
6
6
  "license": "MIT",
@@ -29,6 +29,6 @@
29
29
  "@types/node": "*",
30
30
  "@types/verror": "*"
31
31
  },
32
- "typesPublisherContentHash": "6e90fefa56f7582b3db68e3977022dbabc5b4038b85d7cf8178a5fd1f8d6d89c",
32
+ "typesPublisherContentHash": "548a853deb07456b65e86e1a5ba22f2a32bd4eec6993e15f1774abaab2ec9d36",
33
33
  "typeScriptVersion": "4.5"
34
34
  }