@ranzenjs/client 0.2.1 → 0.4.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.
@@ -6,6 +6,8 @@ export interface TransportSettings {
6
6
  userAgent: string;
7
7
  timeoutMs: number;
8
8
  maxConcurrency: number;
9
+ /** Hosts requests may reach over https; defaults to Schulportal's. */
10
+ hosts?: ReadonlySet<string>;
9
11
  }
10
12
  export interface Exchange {
11
13
  url: string | URL;
@@ -29,6 +31,7 @@ export interface Reply extends Head {
29
31
  export interface StreamReply extends Head {
30
32
  body: ReadableStream<Uint8Array>;
31
33
  }
34
+ export declare const PORTAL_HOSTS: ReadonlySet<string>;
32
35
  export declare class Transport {
33
36
  private readonly settings;
34
37
  readonly jar: CookieJar;
@@ -2,7 +2,7 @@ import { RanzenError, fail, layoutChanged } from '../errors.js';
2
2
  import { CookieJar } from './cookies.js';
3
3
  import { Limiter } from './limiter.js';
4
4
  // The hosts sign-in and apps use; any other host, subdomain or port is a portal change.
5
- const PORTAL_HOSTS = new Set(['start', 'login', 'connect'].map((name) => `${name}.schulportal.hessen.de`));
5
+ export const PORTAL_HOSTS = new Set(['start', 'login', 'connect'].map((name) => `${name}.schulportal.hessen.de`));
6
6
  const MAX_REDIRECTS = 10;
7
7
  export class Transport {
8
8
  settings;
@@ -113,7 +113,7 @@ export class Transport {
113
113
  let method = exchange.method ?? 'GET';
114
114
  let body = exchange.multipart ?? (exchange.form && new URLSearchParams(exchange.form).toString());
115
115
  for (let hop = 0;; hop++) {
116
- if (url.protocol !== 'https:' || !PORTAL_HOSTS.has(url.host)) {
116
+ if (url.protocol !== 'https:' || !(this.settings.hosts ?? PORTAL_HOSTS).has(url.host)) {
117
117
  throw layoutChanged('a portal address');
118
118
  }
119
119
  const headers = new Headers(exchange.headers);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ranzenjs/client",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Typed client for Schulportal Hessen (SPH, LANIS)",
5
5
  "license": "MIT",
6
6
  "author": "Suko",
@@ -42,6 +42,10 @@
42
42
  "types": "./dist/apps/catalog/index.d.ts",
43
43
  "default": "./dist/apps/catalog/index.js"
44
44
  },
45
+ "./kurswahl": {
46
+ "types": "./dist/kurswahl/index.d.ts",
47
+ "default": "./dist/kurswahl/index.js"
48
+ },
45
49
  "./html": {
46
50
  "types": "./dist/html.d.ts",
47
51
  "default": "./dist/html.js"
@@ -66,6 +70,7 @@
66
70
  "dependencies": {
67
71
  "css-select": "^7.0.0",
68
72
  "domhandler": "^6.0.1",
73
+ "hash-wasm": "^4.12.0",
69
74
  "htmlparser2": "^12.0.0"
70
75
  },
71
76
  "devDependencies": {