@sasjs/adapter 4.3.7 → 4.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.
- package/auth/getAccessTokenForViya.d.ts +2 -2
- package/auth/getTokenRequestErrorPrefix.d.ts +44 -0
- package/auth/spec/getTokenRequestErrorPrefix.spec.d.ts +1 -0
- package/index-dev.js +2 -2
- package/index.js +1 -1
- package/minified_sas9.js +1 -1
- package/node/auth/getAccessTokenForViya.d.ts +2 -2
- package/node/auth/getTokenRequestErrorPrefix.d.ts +44 -0
- package/node/index.js +1 -1
- package/package.json +1 -1
- package/src/auth/getAccessTokenForSasjs.ts +13 -1
- package/src/auth/getAccessTokenForViya.ts +22 -6
- package/src/auth/getTokenRequestErrorPrefix.ts +88 -0
- package/src/auth/getTokens.ts +3 -0
- package/src/auth/refreshTokensForSasjs.ts +11 -1
- package/src/auth/refreshTokensForViya.ts +15 -2
- package/src/job-execution/FileUploader.ts +10 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SasAuthResponse } from '@sasjs/utils/types';
|
|
2
2
|
import { RequestClient } from '../request/RequestClient';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param requestClient - the pre-configured HTTP request client
|
|
4
|
+
* Exchange the auth code for access / refresh tokens for the given client / secret pair.
|
|
5
|
+
* @param requestClient - the pre-configured HTTP request client.
|
|
6
6
|
* @param clientId - the client ID to authenticate with.
|
|
7
7
|
* @param clientSecret - the client secret to authenticate with.
|
|
8
8
|
* @param authCode - the auth code received from the server.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ServerType } from '@sasjs/utils/types';
|
|
2
|
+
declare type Server = ServerType.SasViya | ServerType.Sasjs;
|
|
3
|
+
declare type Operation = 'fetching access token' | 'refreshing tokens';
|
|
4
|
+
/**
|
|
5
|
+
* Forms error prefix for requests related to token operations.
|
|
6
|
+
* @param operation - string describing operation ('fetching access token' or 'refreshing tokens').
|
|
7
|
+
* @param funcName - name of the function sent the request.
|
|
8
|
+
* @param server - server type (SASVIYA or SASJS).
|
|
9
|
+
* @param url - endpoint used to send the request.
|
|
10
|
+
* @param data - request payload.
|
|
11
|
+
* @param headers - request headers.
|
|
12
|
+
* @param clientId - client ID to authenticate with.
|
|
13
|
+
* @param clientSecret - client secret to authenticate with.
|
|
14
|
+
* @returns - string containing request information. Example:
|
|
15
|
+
* Error while fetching access token from /SASLogon/oauth/token
|
|
16
|
+
* Thrown by the @sasjs/adapter getAccessTokenForViya function.
|
|
17
|
+
* Payload:
|
|
18
|
+
* {
|
|
19
|
+
* "grant_type": "authorization_code",
|
|
20
|
+
* "code": "example_code"
|
|
21
|
+
* }
|
|
22
|
+
* Headers:
|
|
23
|
+
* {
|
|
24
|
+
* "Authorization": "Basic NEdMQXBwOjRHTEFwcDE=",
|
|
25
|
+
* "Accept": "application/json"
|
|
26
|
+
* }
|
|
27
|
+
* ClientId: exampleClientId
|
|
28
|
+
* ClientSecret: exampleClientSecret
|
|
29
|
+
*
|
|
30
|
+
* Response from Viya is below.
|
|
31
|
+
* Auth error: {
|
|
32
|
+
* "error": "invalid_token",
|
|
33
|
+
* "error_description": "No scopes were granted"
|
|
34
|
+
* }
|
|
35
|
+
*/
|
|
36
|
+
export declare const getTokenRequestErrorPrefix: (operation: Operation, funcName: string, server: Server, url: string, data?: {}, headers?: {}, clientId?: string, clientSecret?: string) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Parse error prefix to get response payload.
|
|
39
|
+
* @param prefix - error prefix generated by getTokenRequestErrorPrefix function.
|
|
40
|
+
* @param server - server type (SASVIYA or SASJS).
|
|
41
|
+
* @returns - response payload.
|
|
42
|
+
*/
|
|
43
|
+
export declare const getTokenRequestErrorPrefixResponse: (prefix: string, server: ServerType.SasViya | ServerType.Sasjs) => string;
|
|
44
|
+
export {};
|