@sasjs/adapter 3.9.3 → 3.10.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.
@@ -63,6 +63,7 @@
63
63
  /*!
64
64
  * mime-db
65
65
  * Copyright(c) 2014 Jonathan Ong
66
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
66
67
  * MIT Licensed
67
68
  */
68
69
 
@@ -0,0 +1,3 @@
1
+ export declare class InvalidCsrfError extends Error {
2
+ constructor();
3
+ }
package/package.json CHANGED
@@ -8,14 +8,17 @@
8
8
  "build": "rimraf build && rimraf node && mkdir node && copyfiles -u 1 \"./src/**/*\" ./node && webpack && rimraf build/src && rimraf node",
9
9
  "package:lib": "npm run build && copyfiles ./package.json ./checkNodeVersion.js build && cd build && npm version \"5.0.0\" && npm pack",
10
10
  "publish:lib": "npm run build && cd build && npm publish",
11
- "lint:fix": "npx prettier --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
12
- "lint": "npx prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
11
+ "lint:fix": "npx prettier --loglevel silent --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --write \"cypress/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
12
+ "lint": "npx prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --check \"cypress/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
13
+ "lint:silent": "npx prettier --loglevel silent --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --check \"cypress/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
13
14
  "test": "jest --silent --coverage",
14
15
  "prepublishOnly": "cp -r ./build/* . && rm -rf ./build",
15
16
  "postpublish": "git clean -fd",
16
17
  "semantic-release": "semantic-release",
17
18
  "typedoc": "node createTSDocs",
18
- "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks && git config core.autocrlf false || true"
19
+ "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks && git config core.autocrlf false || true",
20
+ "cypress": "cypress open",
21
+ "cy:run": "cypress run"
19
22
  },
20
23
  "publishConfig": {
21
24
  "access": "public"
@@ -40,9 +43,13 @@
40
43
  },
41
44
  "license": "ISC",
42
45
  "devDependencies": {
46
+ "@cypress/webpack-preprocessor": "5.9.1",
47
+ "@types/form-data": "2.5.0",
48
+ "cypress": "7.7.0",
49
+ "typedoc-neo-theme": "1.1.1",
50
+ "typedoc-plugin-external-module-name": "4.0.6",
43
51
  "@types/axios": "0.14.0",
44
52
  "@types/express": "4.17.13",
45
- "@types/form-data": "2.5.0",
46
53
  "@types/jest": "27.4.0",
47
54
  "@types/mime": "2.0.3",
48
55
  "@types/pem": "1.9.6",
@@ -79,5 +86,5 @@
79
86
  "https": "1.0.0",
80
87
  "tough-cookie": "4.0.0"
81
88
  },
82
- "version": "3.9.3"
89
+ "version": "3.10.1"
83
90
  }
package/src/SASjs.ts CHANGED
@@ -592,15 +592,6 @@ export default class SASjs {
592
592
  'A username and password are required when using the default login mechanism.'
593
593
  )
594
594
 
595
- if (this.sasjsConfig.serverType === ServerType.Sasjs) {
596
- if (!clientId)
597
- throw new Error(
598
- 'A username, password and clientId are required when using the default login mechanism with server type SASJS.'
599
- )
600
-
601
- return this.authManager!.logInSasjs(username, password, clientId)
602
- }
603
-
604
595
  return this.authManager!.logIn(username, password)
605
596
  }
606
597
 
@@ -3,7 +3,6 @@ import { ExecutionQuery } from './types'
3
3
  import { RequestClient } from './request/RequestClient'
4
4
  import { getAccessTokenForSasjs } from './auth/getAccessTokenForSasjs'
5
5
  import { refreshTokensForSasjs } from './auth/refreshTokensForSasjs'
6
- import { getAuthCodeForSasjs } from './auth/getAuthCodeForSasjs'
7
6
  import { parseWeboutResponse } from './utils'
8
7
  import { getTokens } from './auth/getTokens'
9
8
 
@@ -114,20 +113,6 @@ export class SASjsApiClient {
114
113
  public async refreshTokens(refreshToken: string): Promise<SASjsAuthResponse> {
115
114
  return refreshTokensForSasjs(this.requestClient, refreshToken)
116
115
  }
117
-
118
- /**
119
- * Performs a login authenticate and returns an auth code for the given client.
120
- * @param username - a string representing the username.
121
- * @param password - a string representing the password.
122
- * @param clientId - the client ID to authenticate with.
123
- */
124
- public async getAuthCode(
125
- username: string,
126
- password: string,
127
- clientId: string
128
- ) {
129
- return getAuthCodeForSasjs(this.requestClient, username, password, clientId)
130
- }
131
116
  }
132
117
 
133
118
  // todo move to sasjs/utils
@@ -2,8 +2,6 @@ import { ServerType } from '@sasjs/utils/types'
2
2
  import { RequestClient } from '../request/RequestClient'
3
3
  import { LoginOptions, LoginResult } from '../types/Login'
4
4
  import { serialize } from '../utils'
5
- import { getAccessTokenForSasjs } from './getAccessTokenForSasjs'
6
- import { getAuthCodeForSasjs } from './getAuthCodeForSasjs'
7
5
  import { openWebPage } from './openWebPage'
8
6
  import { verifySas9Login } from './verifySas9Login'
9
7
  import { verifySasViyaLogin } from './verifySasViyaLogin'
@@ -83,39 +81,6 @@ export class AuthManager {
83
81
  return { isLoggedIn: false, userName: '' }
84
82
  }
85
83
 
86
- /**
87
- * Logs into the SAS server with the supplied credentials.
88
- * @param userName - a string representing the username.
89
- * @param password - a string representing the password.
90
- * @param clientId - a string representing the client ID.
91
- * @returns - a boolean `isLoggedin` and a string `username`
92
- */
93
- public async logInSasjs(
94
- username: string,
95
- password: string,
96
- clientId: string
97
- ): Promise<LoginResult> {
98
- const isLoggedIn = await this.sendLoginRequestSasjs(
99
- username,
100
- password,
101
- clientId
102
- )
103
- .then((res) => {
104
- this.userName = username
105
- this.requestClient.saveLocalStorageToken(
106
- res.access_token,
107
- res.refresh_token
108
- )
109
- return true
110
- })
111
- .catch(() => false)
112
-
113
- return {
114
- isLoggedIn,
115
- userName: this.userName
116
- }
117
- }
118
-
119
84
  /**
120
85
  * Logs into the SAS server with the supplied credentials.
121
86
  * @param username - a string representing the username.
@@ -152,7 +117,7 @@ export class AuthManager {
152
117
 
153
118
  let loginResponse = await this.sendLoginRequest(loginForm, loginParams)
154
119
 
155
- let isLoggedIn = isLogInSuccess(loginResponse)
120
+ let isLoggedIn = isLogInSuccess(this.serverType, loginResponse)
156
121
 
157
122
  if (!isLoggedIn) {
158
123
  if (isCredentialsVerifyError(loginResponse)) {
@@ -196,6 +161,17 @@ export class AuthManager {
196
161
  loginForm: { [key: string]: any },
197
162
  loginParams: { [key: string]: any }
198
163
  ) {
164
+ if (this.serverType === ServerType.Sasjs) {
165
+ const { username, password } = loginParams
166
+ const { result: loginResponse } = await this.requestClient.post<string>(
167
+ this.loginUrl,
168
+ { username, password },
169
+ undefined
170
+ )
171
+
172
+ return loginResponse
173
+ }
174
+
199
175
  for (const key in loginForm) {
200
176
  loginParams[key] = loginForm[key]
201
177
  }
@@ -215,19 +191,6 @@ export class AuthManager {
215
191
  return loginResponse
216
192
  }
217
193
 
218
- private async sendLoginRequestSasjs(
219
- username: string,
220
- password: string,
221
- clientId: string
222
- ) {
223
- const authCode = await getAuthCodeForSasjs(
224
- this.requestClient,
225
- username,
226
- password,
227
- clientId
228
- )
229
- return getAccessTokenForSasjs(this.requestClient, clientId, authCode)
230
- }
231
194
  /**
232
195
  * Checks whether a session is active, or login is required.
233
196
  * @returns - a promise which resolves with an object containing three values
@@ -248,8 +211,7 @@ export class AuthManager {
248
211
  //Residue can happen in case of session expiration
249
212
  await this.logOut()
250
213
 
251
- if (this.serverType !== ServerType.Sasjs)
252
- loginForm = await this.getNewLoginForm()
214
+ loginForm = await this.getNewLoginForm()
253
215
  }
254
216
 
255
217
  return Promise.resolve({
@@ -260,6 +222,12 @@ export class AuthManager {
260
222
  }
261
223
 
262
224
  private async getNewLoginForm() {
225
+ if (this.serverType === ServerType.Sasjs) {
226
+ // server will be sending CSRF cookie,
227
+ // http client will use it automatically
228
+ return this.requestClient.get('/', undefined)
229
+ }
230
+
263
231
  const { result: formResponse } = await this.requestClient.get<string>(
264
232
  this.loginUrl.replace('.do', ''),
265
233
  undefined,
@@ -289,6 +257,12 @@ export class AuthManager {
289
257
  const isLoggedIn = loginResponse !== 'authErr'
290
258
  const userName = isLoggedIn ? this.extractUserName(loginResponse) : ''
291
259
 
260
+ if (!isLoggedIn) {
261
+ //We will logout to make sure cookies are removed and login form is presented
262
+ //Residue can happen in case of session expiration
263
+ await this.logOut()
264
+ }
265
+
292
266
  return { isLoggedIn, userName }
293
267
  }
294
268
 
@@ -384,5 +358,8 @@ const isCredentialsVerifyError = (response: string): boolean =>
384
358
  response
385
359
  )
386
360
 
387
- const isLogInSuccess = (response: string): boolean =>
388
- /You have signed in/gm.test(response)
361
+ const isLogInSuccess = (serverType: ServerType, response: any): boolean => {
362
+ if (serverType === ServerType.Sasjs) return response?.loggedin
363
+
364
+ return /You have signed in/gm.test(response)
365
+ }
@@ -92,7 +92,7 @@ export class WebJobExecutor extends BaseJobExecutor {
92
92
  if (jobUri.length > 0) {
93
93
  apiUrl += '&_job=' + jobUri
94
94
  /**
95
- * Using both _job and _program parameters will cause a conflict in the JES web app, as it’s not clear whether or not the server should make the extra fetch for the job uri.
95
+ * Using both _job and _program parameters will cause a conflict in the JES web app, as it's not clear whether or not the server should make the extra fetch for the job uri.
96
96
  * To handle this, we add the extra underscore and recreate the _program variable in the SAS side of the SASjs adapter so it remains available for backend developers.
97
97
  */
98
98
  apiUrl = apiUrl.replace('_program=', '__program=')
@@ -169,13 +169,17 @@ export class WebJobExecutor extends BaseJobExecutor {
169
169
  ? res.result.log.map((logLine: any) => logLine.line).join('\n')
170
170
  : res.result.log
171
171
 
172
- const resObj =
173
- this.serverType === ServerType.Sasjs
174
- ? {
175
- result: res.result._webout,
176
- log: parsedSasjsServerLog
177
- }
178
- : res
172
+ const resObj = res
173
+
174
+ if (this.serverType === ServerType.Sasjs) {
175
+ if (res.result._webout.length < 1)
176
+ throw new JobExecutionError(
177
+ 0,
178
+ 'Job execution failed',
179
+ parsedSasjsServerLog
180
+ )
181
+ }
182
+
179
183
  this.requestClient!.appendRequest(resObj, sasJob, config.debug)
180
184
 
181
185
  let jsonResponse = res.result
@@ -19,6 +19,7 @@ import {
19
19
  parseSourceCode,
20
20
  createAxiosInstance
21
21
  } from '../utils'
22
+ import { InvalidCsrfError } from '../types/errors/InvalidCsrfError'
22
23
 
23
24
  export interface HttpClient {
24
25
  get<T>(
@@ -498,6 +499,24 @@ export class RequestClient implements HttpClient {
498
499
  throw e
499
500
  }
500
501
 
502
+ if (e instanceof InvalidCsrfError) {
503
+ // Fetching root will inject CSRF token in cookie
504
+ await this.httpClient
505
+ .get('/', {
506
+ withCredentials: true
507
+ })
508
+ .catch((err) => {
509
+ throw prefixMessage(err, 'Error while re-fetching CSRF token.')
510
+ })
511
+
512
+ return await callback().catch((err: any) => {
513
+ throw prefixMessage(
514
+ err,
515
+ 'Error while executing callback in handleError. '
516
+ )
517
+ })
518
+ }
519
+
501
520
  if (response?.status === 403 || response?.status === 449) {
502
521
  this.parseAndSetCsrfToken(response)
503
522
 
@@ -584,9 +603,17 @@ export class RequestClient implements HttpClient {
584
603
  export const throwIfError = (response: AxiosResponse) => {
585
604
  switch (response.status) {
586
605
  case 400:
587
- if (typeof response.data === 'object') {
606
+ if (
607
+ typeof response.data === 'object' &&
608
+ response.data.error === 'invalid_grant'
609
+ ) {
610
+ // In SASVIYA when trying to get access token, if auth code is wrong status code will be 400 so in such case we return login required error.
588
611
  throw new LoginRequiredError(response.data)
589
612
  }
613
+
614
+ if (response.data.toLowerCase() === 'invalid csrf token!') {
615
+ throw new InvalidCsrfError()
616
+ }
590
617
  break
591
618
  case 401:
592
619
  if (typeof response.data === 'object') {
@@ -0,0 +1,9 @@
1
+ export class InvalidCsrfError extends Error {
2
+ constructor() {
3
+ const message = 'Invalid CSRF token!'
4
+
5
+ super(`Auth error: ${message}`)
6
+ this.name = 'InvalidCsrfError'
7
+ Object.setPrototypeOf(this, InvalidCsrfError.prototype)
8
+ }
9
+ }
@@ -1,4 +1,4 @@
1
- import { isSpecialMissing } from '@sasjs/utils'
1
+ import { isSpecialMissing } from '@sasjs/utils/input/validators'
2
2
 
3
3
  /**
4
4
  * Converts the given JSON object array to a CSV string.
@@ -0,0 +1,3 @@
1
+ export declare class InvalidCsrfError extends Error {
2
+ constructor();
3
+ }
package/.gitpod.yml DELETED
@@ -1,2 +0,0 @@
1
- tasks:
2
- - init: npm install && npm run build
package/.prettierrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "trailingComma": "none",
3
- "tabWidth": 2,
4
- "semi": false,
5
- "singleQuote": true
6
- }
@@ -1,9 +0,0 @@
1
- import { RequestClient } from '../request/RequestClient';
2
- /**
3
- * Performs a login authenticate and returns an auth code for the given client.
4
- * @param requestClient - the pre-configured HTTP request client
5
- * @param username - a string representing the username.
6
- * @param password - a string representing the password.
7
- * @param clientId - the client ID to authenticate with.
8
- */
9
- export declare const getAuthCodeForSasjs: (requestClient: RequestClient, username: string, password: string, clientId: string) => Promise<string>;
package/jest.config.js DELETED
@@ -1,184 +0,0 @@
1
- // For a detailed explanation regarding each configuration property, visit:
2
- // https://jestjs.io/docs/en/configuration.html
3
-
4
- module.exports = {
5
- testTimeout: 90000,
6
- // All imported modules in your tests should be mocked automatically
7
- // automock: false,
8
-
9
- // Stop running tests after `n` failures
10
- // bail: 1,
11
-
12
- // Respect "browser" field in package.json when resolving modules
13
- // browser: false,
14
-
15
- // The directory where Jest should store its cached dependency information
16
- // cacheDirectory: "/private/var/folders/7y/nmqg1srj29q6210rs9dfsdzc0000gn/T/jest_dx",
17
-
18
- // Automatically clear mock calls and instances between every test
19
- clearMocks: true,
20
-
21
- // Indicates whether the coverage information should be collected while executing the test
22
- // collectCoverage: false,
23
-
24
- // An array of glob patterns indicating a set of files for which coverage information should be collected
25
- // collectCoverageFrom: undefined,
26
-
27
- // The directory where Jest should output its coverage files
28
- coverageDirectory: 'coverage',
29
-
30
- // An array of regexp pattern strings used to skip coverage collection
31
- // coveragePathIgnorePatterns: [
32
- // "/node_modules/"
33
- // ],
34
-
35
- // A list of reporter names that Jest uses when writing coverage reports
36
- // coverageReporters: [
37
- // "json",
38
- // "text",
39
- // "lcov",
40
- // "clover"
41
- // ],
42
-
43
- // An object that configures minimum threshold enforcement for coverage results
44
- // coverageThreshold: undefined,
45
-
46
- // A path to a custom dependency extractor
47
- // dependencyExtractor: undefined,
48
-
49
- // Make calling deprecated APIs throw helpful error messages
50
- // errorOnDeprecated: false,
51
-
52
- // Force coverage collection from ignored files using an array of glob patterns
53
- // forceCoverageMatch: [],
54
-
55
- // A path to a module which exports an async function that is triggered once before all test suites
56
- // globalSetup: undefined,
57
-
58
- // A path to a module which exports an async function that is triggered once after all test suites
59
- // globalTeardown: undefined,
60
-
61
- // A set of global variables that need to be available in all test environments
62
- // globals: {},
63
-
64
- // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
65
- // maxWorkers: "50%",
66
-
67
- // An array of directory names to be searched recursively up from the requiring module's location
68
- // moduleDirectories: [
69
- // "node_modules"
70
- // ],
71
-
72
- // An array of file extensions your modules use
73
- // moduleFileExtensions: [
74
- // "js",
75
- // "json",
76
- // "jsx",
77
- // "ts",
78
- // "tsx",
79
- // "node"
80
- // ],
81
-
82
- // A map from regular expressions to module names that allow to stub out resources with a single module
83
- moduleNameMapper: {},
84
-
85
- // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
86
- // modulePathIgnorePatterns: [],
87
-
88
- // Activates notifications for test results
89
- // notify: false,
90
-
91
- // An enum that specifies notification mode. Requires { notify: true }
92
- // notifyMode: "failure-change",
93
-
94
- // A preset that is used as a base for Jest's configuration
95
- preset: 'ts-jest/presets/js-with-ts',
96
-
97
- // Run tests from one or more projects
98
- // projects: undefined,
99
-
100
- // Use this configuration option to add custom reporters to Jest
101
- // reporters: undefined,
102
-
103
- // Automatically reset mock state between every test
104
- // resetMocks: false,
105
-
106
- // Reset the module registry before running each individual test
107
- // resetModules: false,
108
-
109
- // A path to a custom resolver
110
- // resolver: undefined,
111
-
112
- // Automatically restore mock state between every test
113
- // restoreMocks: false,
114
-
115
- // The root directory that Jest should scan for tests and modules within
116
- // rootDir: undefined,
117
-
118
- // A list of paths to directories that Jest should use to search for files in
119
- // roots: [
120
- // "<rootDir>"
121
- // ],
122
-
123
- // Allows you to use a custom runner instead of Jest's default test runner
124
- // runner: "jest-runner",
125
-
126
- // The paths to modules that run some code to configure or set up the testing environment before each test
127
- setupFiles: [],
128
-
129
- // A list of paths to modules that run some code to configure or set up the testing framework before each test
130
- setupFilesAfterEnv: ['jest-extended/all'],
131
-
132
- // A list of paths to snapshot serializer modules Jest should use for snapshot testing
133
- // snapshotSerializers: [],
134
-
135
- // Options that will be passed to the testEnvironment
136
- // testEnvironmentOptions: {},
137
-
138
- // Adds a location field to test results
139
- // testLocationInResults: false,
140
-
141
- // The glob patterns Jest uses to detect test files
142
- testMatch: ['**/*spec.[j|t]s?(x)'],
143
-
144
- // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
145
- testPathIgnorePatterns: ['/node_modules/', '/build'],
146
-
147
- // The regexp pattern or array of patterns that Jest uses to detect test files
148
- // testRegex: [],
149
-
150
- // This option allows the use of a custom results processor
151
- // testResultsProcessor: undefined,
152
-
153
- // This option allows use of a custom test runner
154
- // testRunner: "jasmine2",
155
-
156
- // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
157
- // testURL: "http://localhost",
158
-
159
- // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
160
- // timers: "real",
161
-
162
- // A map from regular expressions to paths to transformers
163
- transform: {
164
- '^.+\\.ts?$': 'ts-jest'
165
- }
166
-
167
- // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
168
- // transformIgnorePatterns: [
169
- // '**/test/**/*.ts?(x)',
170
- // '**/?(*.)+(spec|test).ts?(x)'
171
- // ]
172
-
173
- // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
174
- // unmockedModulePathPatterns: undefined,
175
-
176
- // Indicates whether each individual test should be reported during the run
177
- // verbose: undefined,
178
-
179
- // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
180
- // watchPathIgnorePatterns: [],
181
-
182
- // Whether to use watchman for file crawling
183
- // watchman: true,
184
- }
@@ -1,9 +0,0 @@
1
- import { RequestClient } from '../request/RequestClient';
2
- /**
3
- * Performs a login authenticate and returns an auth code for the given client.
4
- * @param requestClient - the pre-configured HTTP request client
5
- * @param username - a string representing the username.
6
- * @param password - a string representing the password.
7
- * @param clientId - the client ID to authenticate with.
8
- */
9
- export declare const getAuthCodeForSasjs: (requestClient: RequestClient, username: string, password: string, clientId: string) => Promise<string>;
@@ -1,31 +0,0 @@
1
- import { prefixMessage } from '@sasjs/utils/error'
2
- import { RequestClient } from '../request/RequestClient'
3
-
4
- /**
5
- * Performs a login authenticate and returns an auth code for the given client.
6
- * @param requestClient - the pre-configured HTTP request client
7
- * @param username - a string representing the username.
8
- * @param password - a string representing the password.
9
- * @param clientId - the client ID to authenticate with.
10
- */
11
- export const getAuthCodeForSasjs = async (
12
- requestClient: RequestClient,
13
- username: string,
14
- password: string,
15
- clientId: string
16
- ) => {
17
- const url = '/SASjsApi/auth/authorize'
18
- const data = { username, password, clientId }
19
-
20
- const { code: authCode } = await requestClient
21
- .post<{ code: string }>(url, data, undefined)
22
- .then((res) => res.result)
23
- .catch((err) => {
24
- throw prefixMessage(
25
- err,
26
- 'Error while authenticating with provided username, password and clientId. '
27
- )
28
- })
29
-
30
- return authCode
31
- }
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["ES2018", "DOM", "ES2019.String"],
4
- "target": "es5",
5
- "module": "commonjs",
6
- "declaration": true,
7
- "outDir": "./build",
8
- "strict": true,
9
- "sourceMap": true,
10
- "typeRoots": ["./node_modules/@types", "./src/types/system"]
11
- },
12
- "include": ["src"],
13
- "exclude": ["node_modules"]
14
- }
package/tslint.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": ["tslint:recommended", "tslint-config-prettier"],
3
- "rules": {
4
- "no-string-literal": false,
5
- "forin": false,
6
- "no-console": false,
7
- "max-classes-per-file": false
8
- }
9
- }
package/typedoc.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "out": "docs",
3
- "exclude": ["**/*+(index|.spec|.e2e).ts"],
4
- "excludeExternals": true,
5
- "excludePrivate": true,
6
- "entryPoints": [
7
- "src/SASjs.ts",
8
- "src/SAS9ApiClient.ts",
9
- "src/SASjsApiClient.ts",
10
- "src/SASViyaApiClient.ts",
11
- "src/types"
12
- ]
13
- }