@sasjs/adapter 3.8.4 → 3.8.5
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.js +2 -2
- package/node/index.js +2 -2
- package/node/types/errors/CertificateError.d.ts +3 -0
- package/node/types/errors/index.d.ts +5 -4
- package/package.json +1 -1
- package/src/SASViyaApiClient.ts +9 -3
- package/src/auth/getAccessTokenForViya.ts +2 -0
- package/src/request/RequestClient.ts +6 -1
- package/src/types/errors/CertificateError.ts +12 -0
- package/src/types/errors/index.ts +5 -4
- package/types/errors/CertificateError.d.ts +3 -0
- package/types/errors/index.d.ts +5 -4
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export * from './AuthorizeError';
|
|
2
|
+
export * from './CertificateError';
|
|
2
3
|
export * from './ComputeJobExecutionError';
|
|
4
|
+
export * from './ErrorResponse';
|
|
3
5
|
export * from './InternalServerError';
|
|
6
|
+
export * from './InvalidJsonError';
|
|
4
7
|
export * from './JobExecutionError';
|
|
5
8
|
export * from './JobStatePollError';
|
|
9
|
+
export * from './JsonParseArrayError';
|
|
6
10
|
export * from './LoginRequiredError';
|
|
7
|
-
export * from './NotFoundError';
|
|
8
|
-
export * from './ErrorResponse';
|
|
9
11
|
export * from './NoSessionStateError';
|
|
12
|
+
export * from './NotFoundError';
|
|
10
13
|
export * from './RootFolderNotFoundError';
|
|
11
|
-
export * from './JsonParseArrayError';
|
|
12
14
|
export * from './WeboutResponseError';
|
|
13
|
-
export * from './InvalidJsonError';
|
package/package.json
CHANGED
package/src/SASViyaApiClient.ts
CHANGED
|
@@ -11,7 +11,11 @@ import {
|
|
|
11
11
|
JobDefinition,
|
|
12
12
|
PollOptions
|
|
13
13
|
} from './types'
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
CertificateError,
|
|
16
|
+
JobExecutionError,
|
|
17
|
+
RootFolderNotFoundError
|
|
18
|
+
} from './types/errors'
|
|
15
19
|
import { SessionManager } from './SessionManager'
|
|
16
20
|
import { ContextManager } from './ContextManager'
|
|
17
21
|
import { SasAuthResponse, MacroVar, AuthConfig } from '@sasjs/utils/types'
|
|
@@ -878,7 +882,8 @@ export class SASViyaApiClient {
|
|
|
878
882
|
|
|
879
883
|
const { result: folder } = await this.requestClient
|
|
880
884
|
.get<Folder>(`${this.serverUrl}${url}`, accessToken)
|
|
881
|
-
.catch(() => {
|
|
885
|
+
.catch((err) => {
|
|
886
|
+
if (err instanceof CertificateError) throw err
|
|
882
887
|
return { result: null }
|
|
883
888
|
})
|
|
884
889
|
|
|
@@ -899,7 +904,8 @@ export class SASViyaApiClient {
|
|
|
899
904
|
|
|
900
905
|
const { result: folder } = await this.requestClient
|
|
901
906
|
.get<Folder>(`${this.serverUrl}${url}`, accessToken)
|
|
902
|
-
.catch(() => {
|
|
907
|
+
.catch((err) => {
|
|
908
|
+
if (err instanceof CertificateError) throw err
|
|
903
909
|
return { result: null }
|
|
904
910
|
})
|
|
905
911
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SasAuthResponse } from '@sasjs/utils/types'
|
|
2
2
|
import { prefixMessage } from '@sasjs/utils/error'
|
|
3
3
|
import { RequestClient } from '../request/RequestClient'
|
|
4
|
+
import { CertificateError } from '../types/errors'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Exchanges the auth code for an access token for the given client.
|
|
@@ -36,6 +37,7 @@ export async function getAccessTokenForViya(
|
|
|
36
37
|
.post(url, data, undefined, 'application/x-www-form-urlencoded', headers)
|
|
37
38
|
.then((res) => res.result as SasAuthResponse)
|
|
38
39
|
.catch((err) => {
|
|
40
|
+
if (err instanceof CertificateError) throw err
|
|
39
41
|
throw prefixMessage(err, 'Error while getting access token. ')
|
|
40
42
|
})
|
|
41
43
|
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
LoginRequiredError,
|
|
8
8
|
NotFoundError,
|
|
9
9
|
InternalServerError,
|
|
10
|
-
JobExecutionError
|
|
10
|
+
JobExecutionError,
|
|
11
|
+
CertificateError
|
|
11
12
|
} from '../types/errors'
|
|
12
13
|
import { SASjsRequest } from '../types'
|
|
13
14
|
import { parseWeboutResponse } from '../utils/parseWeboutResponse'
|
|
@@ -517,6 +518,10 @@ export class RequestClient implements HttpClient {
|
|
|
517
518
|
else return
|
|
518
519
|
}
|
|
519
520
|
|
|
521
|
+
if (e.isAxiosError && e.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE') {
|
|
522
|
+
throw new CertificateError(e.message)
|
|
523
|
+
}
|
|
524
|
+
|
|
520
525
|
if (e.message) throw e
|
|
521
526
|
else throw prefixMessage(e, 'Error while handling error. ')
|
|
522
527
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const instructionsToFix =
|
|
2
|
+
'https://github.com/sasjs/cli/issues/1181#issuecomment-1090638584'
|
|
3
|
+
|
|
4
|
+
export class CertificateError extends Error {
|
|
5
|
+
constructor(message: string) {
|
|
6
|
+
super(
|
|
7
|
+
`${message}\nPlease visit the link below for further information on this issue:\n- ${instructionsToFix}\n`
|
|
8
|
+
)
|
|
9
|
+
this.name = 'CertificateError'
|
|
10
|
+
Object.setPrototypeOf(this, CertificateError.prototype)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export * from './AuthorizeError'
|
|
2
|
+
export * from './CertificateError'
|
|
2
3
|
export * from './ComputeJobExecutionError'
|
|
4
|
+
export * from './ErrorResponse'
|
|
3
5
|
export * from './InternalServerError'
|
|
6
|
+
export * from './InvalidJsonError'
|
|
4
7
|
export * from './JobExecutionError'
|
|
5
8
|
export * from './JobStatePollError'
|
|
9
|
+
export * from './JsonParseArrayError'
|
|
6
10
|
export * from './LoginRequiredError'
|
|
7
|
-
export * from './NotFoundError'
|
|
8
|
-
export * from './ErrorResponse'
|
|
9
11
|
export * from './NoSessionStateError'
|
|
12
|
+
export * from './NotFoundError'
|
|
10
13
|
export * from './RootFolderNotFoundError'
|
|
11
|
-
export * from './JsonParseArrayError'
|
|
12
14
|
export * from './WeboutResponseError'
|
|
13
|
-
export * from './InvalidJsonError'
|
package/types/errors/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export * from './AuthorizeError';
|
|
2
|
+
export * from './CertificateError';
|
|
2
3
|
export * from './ComputeJobExecutionError';
|
|
4
|
+
export * from './ErrorResponse';
|
|
3
5
|
export * from './InternalServerError';
|
|
6
|
+
export * from './InvalidJsonError';
|
|
4
7
|
export * from './JobExecutionError';
|
|
5
8
|
export * from './JobStatePollError';
|
|
9
|
+
export * from './JsonParseArrayError';
|
|
6
10
|
export * from './LoginRequiredError';
|
|
7
|
-
export * from './NotFoundError';
|
|
8
|
-
export * from './ErrorResponse';
|
|
9
11
|
export * from './NoSessionStateError';
|
|
12
|
+
export * from './NotFoundError';
|
|
10
13
|
export * from './RootFolderNotFoundError';
|
|
11
|
-
export * from './JsonParseArrayError';
|
|
12
14
|
export * from './WeboutResponseError';
|
|
13
|
-
export * from './InvalidJsonError';
|