@sasjs/adapter 4.2.0 → 4.2.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.
- package/index-dev.js +2 -2
- package/index.js +1 -1
- package/minified_sas9.js +1 -1
- package/node/main.js +1 -1
- package/package.json +2 -2
- package/src/auth/AuthManager.ts +15 -5
- package/src/auth/isLoginRequired.ts +1 -1
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"jest-extended": "2.0.0",
|
|
60
60
|
"node-polyfill-webpack-plugin": "1.1.4",
|
|
61
61
|
"path": "0.12.7",
|
|
62
|
-
"pem": "1.14.
|
|
62
|
+
"pem": "1.14.5",
|
|
63
63
|
"prettier": "2.7.1",
|
|
64
64
|
"process": "0.11.10",
|
|
65
65
|
"rimraf": "3.0.2",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"https": "1.0.0",
|
|
85
85
|
"tough-cookie": "4.0.0"
|
|
86
86
|
},
|
|
87
|
-
"version": "4.2.
|
|
87
|
+
"version": "4.2.1"
|
|
88
88
|
}
|
package/src/auth/AuthManager.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ServerType } from '@sasjs/utils/types'
|
|
2
2
|
import { RequestClient } from '../request/RequestClient'
|
|
3
|
+
import { NotFoundError } from '../types/errors'
|
|
3
4
|
import { LoginOptions, LoginResult, LoginResultInternal } from '../types/Login'
|
|
4
5
|
import { serialize } from '../utils'
|
|
5
6
|
import { extractUserLongNameSas9 } from '../utils/sas9/extractUserLongNameSas9'
|
|
@@ -42,6 +43,9 @@ export class AuthManager {
|
|
|
42
43
|
} = await this.fetchUserName()
|
|
43
44
|
|
|
44
45
|
if (isLoggedInAlready) {
|
|
46
|
+
const logger = process.logger || console
|
|
47
|
+
logger.log('login was not attempted as a valid session already exists')
|
|
48
|
+
|
|
45
49
|
await this.loginCallback()
|
|
46
50
|
|
|
47
51
|
return {
|
|
@@ -109,6 +113,9 @@ export class AuthManager {
|
|
|
109
113
|
} = await this.checkSession()
|
|
110
114
|
|
|
111
115
|
if (isLoggedInAlready) {
|
|
116
|
+
const logger = process.logger || console
|
|
117
|
+
logger.log('login was not attempted as a valid session already exists')
|
|
118
|
+
|
|
112
119
|
await this.loginCallback()
|
|
113
120
|
|
|
114
121
|
this.userName = loginParams.username
|
|
@@ -155,10 +162,12 @@ export class AuthManager {
|
|
|
155
162
|
private async performCASSecurityCheck() {
|
|
156
163
|
const casAuthenticationUrl = `${this.serverUrl}/SASStoredProcess/j_spring_cas_security_check`
|
|
157
164
|
|
|
158
|
-
await this.requestClient
|
|
159
|
-
`/SASLogon/login?service=${casAuthenticationUrl}`,
|
|
160
|
-
|
|
161
|
-
|
|
165
|
+
await this.requestClient
|
|
166
|
+
.get<string>(`/SASLogon/login?service=${casAuthenticationUrl}`, undefined)
|
|
167
|
+
.catch((err) => {
|
|
168
|
+
// ignore if resource not found error
|
|
169
|
+
if (!(err instanceof NotFoundError)) throw err
|
|
170
|
+
})
|
|
162
171
|
}
|
|
163
172
|
|
|
164
173
|
private async sendLoginRequest(
|
|
@@ -312,12 +321,13 @@ export class AuthManager {
|
|
|
312
321
|
}
|
|
313
322
|
|
|
314
323
|
private getLoginForm(response: any) {
|
|
315
|
-
const pattern: RegExp = /<form.+action="(.*Logon[^"]*).*>/
|
|
324
|
+
const pattern: RegExp = /<form.+action="(.*(Logon)|(login)[^"]*).*>/
|
|
316
325
|
const matches = pattern.exec(response)
|
|
317
326
|
const formInputs: any = {}
|
|
318
327
|
|
|
319
328
|
if (matches && matches.length) {
|
|
320
329
|
this.setLoginUrl(matches)
|
|
330
|
+
response = response.replace(/<input/g, '\n<input')
|
|
321
331
|
const inputs = response.match(/<input.*"hidden"[^>]*>/g)
|
|
322
332
|
|
|
323
333
|
if (inputs) {
|