@olenbetong/appframe-vite 2.2.35 → 3.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.
package/lib/devServer.js CHANGED
@@ -65,7 +65,7 @@ export function createHtmlTransformer() {
65
65
  let userSession = await getUserSession();
66
66
  return html
67
67
  .replace("<!-- {Appframe} -->", `<script src="/lib/@olenbetong/appframe-core/2.4.0/dist/iife/af.common.js"></script>
68
- <script src="/lib/@olenbetong/appframe-data/0.7.4/dist/iife/af.data.js"></script>
68
+ <script src="/lib/@olenbetong/appframe-data/0.7.6/dist/iife/af.data.js"></script>
69
69
  <template id="PromptBeforeReloadDialog">
70
70
  <dialog class="do-prompt">
71
71
  <form method="dialog">
package/lib/proxy.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="qs" />
2
2
  /// <reference types="express" />
3
- export declare function login(hostname: string, username: string, password: string): Promise<Record<string, string>>;
3
+ type CookieObject = Record<string, string>;
4
+ export declare function login(hostname: string, username: string, password: string): Promise<CookieObject>;
4
5
  export type createProxyOptions = {
5
6
  /**
6
7
  * If true, will wait for the first login request to complete before returning.
@@ -12,3 +13,4 @@ export type createProxyOptions = {
12
13
  protocol?: "http" | "https";
13
14
  };
14
15
  export declare function createAppframeProxy(options: createProxyOptions): import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
16
+ export {};
package/lib/proxy.js CHANGED
@@ -27,11 +27,11 @@ export async function login(hostname, username, password) {
27
27
  headers: {
28
28
  Accept: "application/json",
29
29
  "Content-Type": "application/x-www-form-urlencoded",
30
- "Content-Length": data.length
31
- }
30
+ "Content-Length": data.length,
31
+ },
32
32
  };
33
33
  console.log("Authenticating...");
34
- let request = https.request(options, response => {
34
+ let request = https.request(options, (response) => {
35
35
  let status = response.statusCode ?? 600;
36
36
  if (status < 400) {
37
37
  let cookies = response.headers["set-cookie"] ?? [];
@@ -46,7 +46,7 @@ export async function login(hostname, username, password) {
46
46
  console.log("Authentication successfull.");
47
47
  lastLogin.set(hostname, {
48
48
  timestamp: Date.now(),
49
- authCookies: cookieObj
49
+ authCookies: cookieObj,
50
50
  });
51
51
  resolve(cookieObj);
52
52
  }
@@ -57,10 +57,19 @@ export async function login(hostname, username, password) {
57
57
  request.write(data);
58
58
  request.end();
59
59
  });
60
- currentLogin = loginPromise;
61
- let result = await loginPromise;
62
- currentLogin = null;
63
- return result;
60
+ try {
61
+ currentLogin = loginPromise;
62
+ let result = await loginPromise;
63
+ currentLogin = null;
64
+ return result;
65
+ }
66
+ catch (error) {
67
+ let cookies = lastLogin.get(hostname)?.authCookies;
68
+ if (cookies) {
69
+ return cookies;
70
+ }
71
+ throw error;
72
+ }
64
73
  }
65
74
  export function createAppframeProxy(options) {
66
75
  const { hostname, password, protocol = "https", username } = options;
@@ -78,7 +87,7 @@ export function createAppframeProxy(options) {
78
87
  },
79
88
  proxyReqPathResolver: function (req) {
80
89
  return req.originalUrl;
81
- }
90
+ },
82
91
  });
83
92
  return proxy;
84
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/appframe-vite",
3
- "version": "2.2.35",
3
+ "version": "3.0.0",
4
4
  "description": "Tools to use and deploy Vite applications to Appframe",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
@@ -25,19 +25,19 @@
25
25
  "vite-plugin-externals": "^0.5.1"
26
26
  },
27
27
  "devDependencies": {
28
- "typescript": "^4.8.4"
28
+ "typescript": "^4.9.4"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "express": "^4.18.2",
32
- "vite": "^3.2.4"
32
+ "vite": "^4.0.1"
33
33
  },
34
34
  "optionalDependencies": {
35
- "@types/express": "^4.17.14",
35
+ "@types/express": "^4.17.15",
36
36
  "@types/express-http-proxy": "^1.6.3",
37
37
  "@types/tcp-port-used": "^1.0.1",
38
38
  "express-http-proxy": "^1.6.3",
39
39
  "open": "^8.4.0",
40
40
  "tcp-port-used": "^1.0.2"
41
41
  },
42
- "gitHead": "d25ecebc83253a045fb4018aa80d0e7932d0ee8a"
42
+ "gitHead": "927db835948f0a80bfbc841e2eed4675afea2d22"
43
43
  }