@lucidtech/las-sdk-core
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -6,4 +6,6 @@ import { Credentials } from './credentials'; | ||
constructor(apiEndpoint: string, credentials: Credentials); | ||
getDocument(documentId: string): Promise<any>; | ||
postDocuments(content: string, contentType: string, consentId: string): Promise<any>; | ||
postPredictions(documentId: string, modelName: string): Promise<any>; | ||
getProcesses(): Promise<any>; | ||
postProcesses(stateMachineArn: string, inputData: any): Promise<any>; | ||
@@ -10,0 +12,0 @@ postTasks(activityArn: string): Promise<any>; |
@@ -12,7 +12,10 @@ "use strict"; | ||
} | ||
Client.prototype.getDocument = function (documentId) { | ||
return this.makeGetRequest("/documents/" + documentId); | ||
}; | ||
Client.prototype.postDocuments = function (content, contentType, consentId) { | ||
var body = { | ||
'content': Buffer.from(content).toString('base64'), | ||
'contentType': contentType, | ||
'consentId': consentId | ||
content: Buffer.from(content).toString('base64'), | ||
contentType: contentType, | ||
consentId: consentId, | ||
}; | ||
@@ -23,11 +26,14 @@ return this.makePostRequest('/documents', body); | ||
var body = { | ||
'documentId': documentId, | ||
'modelName': modelName | ||
documentId: documentId, | ||
modelName: modelName, | ||
}; | ||
return this.makePostRequest('/predictions', body); | ||
}; | ||
Client.prototype.getProcesses = function () { | ||
return this.makeGetRequest('/processes'); | ||
}; | ||
Client.prototype.postProcesses = function (stateMachineArn, inputData) { | ||
var body = { | ||
'stateMachineArn': stateMachineArn, | ||
'inputData': inputData | ||
stateMachineArn: stateMachineArn, | ||
inputData: inputData, | ||
}; | ||
@@ -38,3 +44,3 @@ return this.makePostRequest('/processes', body); | ||
var body = { | ||
'activityArn': activityArn | ||
activityArn: activityArn, | ||
}; | ||
@@ -45,3 +51,3 @@ return this.makePostRequest('/tasks', body); | ||
var body = { | ||
'taskResult': taskResult | ||
taskResult: taskResult, | ||
}; | ||
@@ -68,3 +74,3 @@ return this.makePatchRequest("/tasks/" + taskId, body); | ||
var config = { headers: headers }; | ||
var handle = !!body ? function () { return axiosFn(endpoint, body, config); } : function () { return axiosFn(endpoint, config); }; | ||
var handle = body ? function () { return axiosFn(endpoint, body, config); } : function () { return axiosFn(endpoint, config); }; | ||
handle().then(function (response) { | ||
@@ -86,3 +92,3 @@ resolve(response.data); | ||
'X-Api-Key': _this.credentials.apiKey, | ||
'Authorization': "Bearer " + accessToken | ||
Authorization: "Bearer " + accessToken, | ||
}; | ||
@@ -89,0 +95,0 @@ resolve(headers); |
@@ -0,1 +1,2 @@ | ||
import { TokenStorage } from './storage'; | ||
export declare class Token { | ||
@@ -5,2 +6,3 @@ readonly accessToken: string; | ||
readonly refreshToken?: string; | ||
isValid(): boolean; | ||
constructor(accessToken: string, expiration: number, refreshToken?: string); | ||
@@ -11,5 +13,6 @@ } | ||
protected token?: Token; | ||
protected constructor(apiKey: string); | ||
protected storage?: TokenStorage<Token>; | ||
protected constructor(apiKey: string, storage?: TokenStorage<Token>); | ||
getAccessToken(): Promise<string>; | ||
protected abstract getToken(): Promise<Token>; | ||
} |
@@ -9,2 +9,5 @@ "use strict"; | ||
} | ||
Token.prototype.isValid = function () { | ||
return Date.now() < this.expiration; | ||
}; | ||
return Token; | ||
@@ -14,19 +17,27 @@ }()); | ||
var Credentials = /** @class */ (function () { | ||
function Credentials(apiKey) { | ||
function Credentials(apiKey, storage) { | ||
this.apiKey = apiKey; | ||
this.storage = storage; | ||
} | ||
Credentials.prototype.getAccessToken = function () { | ||
var _this = this; | ||
var storage = this.storage; | ||
return new Promise(function (resolve, reject) { | ||
if (!!_this.token && Date.now() < _this.token.expiration) { | ||
resolve(_this.token.accessToken); | ||
var token = _this.token || null; | ||
if (!(token && token.isValid()) && storage) { | ||
token = storage.getPersistentToken(); | ||
} | ||
else { | ||
_this.getToken().then(function (token) { | ||
_this.token = token; | ||
resolve(token.accessToken); | ||
}).catch(function (error) { | ||
reject(error); | ||
}); | ||
if (token && token.isValid()) { | ||
_this.token = token; | ||
return resolve(token.accessToken); | ||
} | ||
_this.getToken().then(function (newToken) { | ||
_this.token = newToken; | ||
if (storage) { | ||
storage.setPersistentToken(newToken); | ||
} | ||
resolve(newToken.accessToken); | ||
}).catch(function (error) { | ||
reject(error); | ||
}); | ||
}); | ||
@@ -33,0 +44,0 @@ }; |
export { Credentials, Token } from './credentials'; | ||
export { Client } from './client'; | ||
export { TokenStorage } from './storage'; |
{ | ||
"name": "@lucidtech/las-sdk-core", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"author": "Lucidtech AS <hello@lucidtech.ai>", | ||
@@ -18,3 +18,3 @@ "maintainers": [ | ||
"upgrade": "npm update", | ||
"lint": "tslint ./src/*" | ||
"lint": "eslint ./src/**/*" | ||
}, | ||
@@ -24,3 +24,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "07f290672ae0472dbab49f98eb659df029b6f12b" | ||
"gitHead": "9ea649e4250883ec0f3b6ab53f05c1c578e683a0" | ||
} |
@@ -1,90 +0,101 @@ | ||
import {getTestClient} from './helpers.spec'; | ||
import {default as uuidv4} from 'uuid/v4'; | ||
import { default as uuidv4 } from 'uuid/v4'; | ||
import { getTestClient } from './helpers.spec'; | ||
test('Testing successful postDocuments', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testContent = uuidv4(); | ||
const testContentType = 'image/jpeg'; | ||
const testConsentId = uuidv4(); | ||
const postDocumentsPromise = client.postDocuments(testContent, testContentType, testConsentId); | ||
await expect(postDocumentsPromise).resolves.toHaveProperty('consentId'); | ||
await expect(postDocumentsPromise).resolves.toHaveProperty('contentType'); | ||
await expect(postDocumentsPromise).resolves.toHaveProperty('documentId'); | ||
const testContent = uuidv4(); | ||
const testContentType = 'image/jpeg'; | ||
const testConsentId = uuidv4(); | ||
const postDocumentsPromise = client.postDocuments(testContent, testContentType, testConsentId); | ||
await expect(postDocumentsPromise).resolves.toHaveProperty('consentId'); | ||
await expect(postDocumentsPromise).resolves.toHaveProperty('contentType'); | ||
await expect(postDocumentsPromise).resolves.toHaveProperty('documentId'); | ||
}); | ||
test('Testing erroneous postDocuments', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testContent = uuidv4(); | ||
const testContentType = 'erroneousContentType'; | ||
const testConsentId = uuidv4(); | ||
const postDocumentsPromise = client.postDocuments(testContent, testContentType, testConsentId); | ||
await expect(postDocumentsPromise).rejects.toBeDefined(); | ||
const testContent = uuidv4(); | ||
const testContentType = 'erroneousContentType'; | ||
const testConsentId = uuidv4(); | ||
const postDocumentsPromise = client.postDocuments(testContent, testContentType, testConsentId); | ||
await expect(postDocumentsPromise).rejects.toBeDefined(); | ||
}); | ||
test('Testing successful postPredictions', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testDocumentId = uuidv4(); | ||
const testModelName = 'invoice'; | ||
const postPredictionsPromise = client.postPredictions(testDocumentId, testModelName); | ||
await expect(postPredictionsPromise).resolves.toHaveProperty('documentId'); | ||
await expect(postPredictionsPromise).resolves.toHaveProperty('predictions'); | ||
const testDocumentId = uuidv4(); | ||
const testModelName = 'invoice'; | ||
const postPredictionsPromise = client.postPredictions(testDocumentId, testModelName); | ||
await expect(postPredictionsPromise).resolves.toHaveProperty('documentId'); | ||
await expect(postPredictionsPromise).resolves.toHaveProperty('predictions'); | ||
}); | ||
test('Testing erroneous postPredictions', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testDocumentId = uuidv4(); | ||
const testModelName = 'erroneousModelName'; | ||
const postPredictionsPromise = client.postPredictions(testDocumentId, testModelName); | ||
await expect(postPredictionsPromise).rejects.toBeDefined(); | ||
const testDocumentId = uuidv4(); | ||
const testModelName = 'erroneousModelName'; | ||
const postPredictionsPromise = client.postPredictions(testDocumentId, testModelName); | ||
await expect(postPredictionsPromise).rejects.toBeDefined(); | ||
}); | ||
test('Testing successful postProcesses', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testStateMachineArn = uuidv4(); | ||
const testInputData = {[uuidv4()]: uuidv4()}; | ||
const postProcessesPromise = client.postProcesses(testStateMachineArn, testInputData); | ||
await expect(postProcessesPromise).resolves.toHaveProperty('executionArn'); | ||
const testStateMachineArn = uuidv4(); | ||
const testInputData = { [uuidv4()]: uuidv4() }; | ||
const postProcessesPromise = client.postProcesses(testStateMachineArn, testInputData); | ||
await expect(postProcessesPromise).resolves.toHaveProperty('executionArn'); | ||
}); | ||
test('Testing erroneous postProcesses', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testStateMachineArn = uuidv4(); | ||
const testInputData = 'ErroneousInputData'; | ||
const postProcessesPromise = client.postProcesses(testStateMachineArn, testInputData); | ||
await expect(postProcessesPromise).rejects.toBeDefined(); | ||
const testStateMachineArn = uuidv4(); | ||
const testInputData = 'ErroneousInputData'; | ||
const postProcessesPromise = client.postProcesses(testStateMachineArn, testInputData); | ||
await expect(postProcessesPromise).rejects.toBeDefined(); | ||
}); | ||
test('Testing successful postTasks', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testActivityArn = uuidv4(); | ||
const postTasksPromise = client.postTasks(testActivityArn); | ||
await expect(postTasksPromise).resolves.toHaveProperty('taskId'); | ||
await expect(postTasksPromise).resolves.toHaveProperty('taskData'); | ||
const testActivityArn = uuidv4(); | ||
const postTasksPromise = client.postTasks(testActivityArn); | ||
await expect(postTasksPromise).resolves.toHaveProperty('taskId'); | ||
await expect(postTasksPromise).resolves.toHaveProperty('taskData'); | ||
}); | ||
test('Testing successful patchTask', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testTaskId = uuidv4(); | ||
const testTaskResult = {[uuidv4()]: uuidv4()}; | ||
const postTasksPromise = client.patchTasks(testTaskId, testTaskResult); | ||
await expect(postTasksPromise).resolves.toHaveProperty('taskId'); | ||
await expect(postTasksPromise).resolves.toHaveProperty('taskData'); | ||
const testTaskId = uuidv4(); | ||
const testTaskResult = { [uuidv4()]: uuidv4() }; | ||
const postTasksPromise = client.patchTasks(testTaskId, testTaskResult); | ||
await expect(postTasksPromise).resolves.toHaveProperty('taskId'); | ||
await expect(postTasksPromise).resolves.toHaveProperty('taskData'); | ||
}); | ||
test('Testing erroneous patchTask', async () => { | ||
const client = getTestClient(); | ||
const client = getTestClient(); | ||
const testTaskId = uuidv4(); | ||
const testTaskResult = 'ErroneousTaskResult'; | ||
const postTasksPromise = client.patchTasks(testTaskId, testTaskResult); | ||
await expect(postTasksPromise).rejects.toBeDefined(); | ||
const testTaskId = uuidv4(); | ||
const testTaskResult = 'ErroneousTaskResult'; | ||
const postTasksPromise = client.patchTasks(testTaskId, testTaskResult); | ||
await expect(postTasksPromise).rejects.toBeDefined(); | ||
}); | ||
test('Testing successful getDocument', async () => { | ||
const client = getTestClient(); | ||
const documentId = uuidv4(); | ||
const getDocumentPromise = client.getDocument(documentId); | ||
await expect(getDocumentPromise).resolves.toHaveProperty('content'); | ||
await expect(getDocumentPromise).resolves.toHaveProperty('consentId'); | ||
await expect(getDocumentPromise).resolves.toHaveProperty('documentId'); | ||
await expect(getDocumentPromise).resolves.toHaveProperty('contentType'); | ||
}); |
@@ -1,106 +0,114 @@ | ||
import axios, {AxiosRequestConfig} from 'axios'; | ||
import {Credentials} from './credentials'; | ||
import axios, { AxiosRequestConfig } from 'axios'; | ||
import { Credentials } from './credentials'; | ||
export class Client { | ||
apiEndpoint: string; | ||
credentials: Credentials; | ||
constructor(apiEndpoint: string, credentials: Credentials) { | ||
this.apiEndpoint = apiEndpoint; | ||
this.credentials = credentials; | ||
this.apiEndpoint = apiEndpoint; | ||
this.credentials = credentials; | ||
} | ||
getDocument(documentId: string) { | ||
return this.makeGetRequest(`/documents/${documentId}`); | ||
} | ||
postDocuments(content: string, contentType: string, consentId: string) { | ||
const body = { | ||
'content': Buffer.from(content).toString('base64'), | ||
'contentType': contentType, | ||
'consentId': consentId | ||
}; | ||
const body = { | ||
content: Buffer.from(content).toString('base64'), | ||
contentType, | ||
consentId, | ||
}; | ||
return this.makePostRequest('/documents', body); | ||
return this.makePostRequest('/documents', body); | ||
} | ||
postPredictions(documentId: string, modelName: string) { | ||
const body = { | ||
'documentId': documentId, | ||
'modelName': modelName | ||
}; | ||
const body = { | ||
documentId, | ||
modelName, | ||
}; | ||
return this.makePostRequest('/predictions', body); | ||
return this.makePostRequest('/predictions', body); | ||
} | ||
getProcesses() { | ||
return this.makeGetRequest('/processes'); | ||
} | ||
postProcesses(stateMachineArn: string, inputData: any) { | ||
const body = { | ||
'stateMachineArn': stateMachineArn, | ||
'inputData': inputData | ||
}; | ||
const body = { | ||
stateMachineArn, | ||
inputData, | ||
}; | ||
return this.makePostRequest('/processes', body); | ||
return this.makePostRequest('/processes', body); | ||
} | ||
postTasks(activityArn: string) { | ||
const body = { | ||
'activityArn': activityArn | ||
}; | ||
const body = { | ||
activityArn, | ||
}; | ||
return this.makePostRequest('/tasks', body); | ||
return this.makePostRequest('/tasks', body); | ||
} | ||
patchTasks(taskId: string, taskResult: any) { | ||
const body = { | ||
'taskResult': taskResult | ||
}; | ||
const body = { | ||
taskResult, | ||
}; | ||
return this.makePatchRequest(`/tasks/${taskId}`, body); | ||
return this.makePatchRequest(`/tasks/${taskId}`, body); | ||
} | ||
makeGetRequest(path: string) { | ||
return this.makeAuthorizedRequest(axios.get, path); | ||
return this.makeAuthorizedRequest(axios.get, path); | ||
} | ||
makeDeleteRequest(path: string) { | ||
return this.makeAuthorizedRequest(axios.delete, path); | ||
return this.makeAuthorizedRequest(axios.delete, path); | ||
} | ||
makePostRequest(path: string, body: any) { | ||
return this.makeAuthorizedRequest(axios.post, path, body); | ||
return this.makeAuthorizedRequest(axios.post, path, body); | ||
} | ||
makePatchRequest(path: string, body: any) { | ||
return this.makeAuthorizedRequest(axios.patch, path, body); | ||
return this.makeAuthorizedRequest(axios.patch, path, body); | ||
} | ||
private makeAuthorizedRequest(axiosFn: (url: string, body?: any, config?: AxiosRequestConfig) => Promise<any>, path: string, body?: any) { | ||
return new Promise<any>((resolve, reject) => { | ||
const endpoint = `${this.apiEndpoint}${path}`; | ||
this.getAuthorizationHeaders().then(headers => { | ||
const config = {headers: headers}; | ||
const handle = !!body ? () => axiosFn(endpoint, body, config) : () => axiosFn(endpoint, config); | ||
return new Promise<any>((resolve, reject) => { | ||
const endpoint = `${this.apiEndpoint}${path}`; | ||
this.getAuthorizationHeaders().then((headers) => { | ||
const config = { headers }; | ||
const handle = body ? () => axiosFn(endpoint, body, config) : () => axiosFn(endpoint, config); | ||
handle().then(response => { | ||
resolve(response.data); | ||
}).catch(error => { | ||
reject(error); | ||
}) | ||
}).catch(error => { | ||
reject(error); | ||
}) | ||
handle().then((response) => { | ||
resolve(response.data); | ||
}).catch((error) => { | ||
reject(error); | ||
}); | ||
}).catch((error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
private getAuthorizationHeaders(): Promise<any> { | ||
return new Promise<any>((resolve, reject) => { | ||
this.credentials.getAccessToken().then(accessToken => { | ||
const headers = { | ||
'X-Api-Key': this.credentials.apiKey, | ||
'Authorization': `Bearer ${accessToken}` | ||
}; | ||
return new Promise<any>((resolve, reject) => { | ||
this.credentials.getAccessToken().then((accessToken) => { | ||
const headers = { | ||
'X-Api-Key': this.credentials.apiKey, | ||
Authorization: `Bearer ${accessToken}`, | ||
}; | ||
resolve(headers); | ||
}).catch(error => { | ||
reject(error); | ||
}); | ||
resolve(headers); | ||
}).catch((error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -1,24 +0,25 @@ | ||
import {TestCredentials, sleep} from "./helpers.spec"; | ||
import { TestCredentials, sleep } from './helpers.spec'; | ||
import { Token } from './credentials'; | ||
test('Testing getAccessToken', async () => { | ||
const testApiKey = 'testApiKey'; | ||
const testAccessToken = 'testAccessToken'; | ||
const testExpiresInSeconds = 1; | ||
const testRefreshToken = 'testRefreshToken'; | ||
const credentials = new TestCredentials(testApiKey, testAccessToken, testExpiresInSeconds, testRefreshToken); | ||
jest.spyOn(credentials, 'getToken'); | ||
const testApiKey = 'testApiKey'; | ||
const testAccessToken = 'testAccessToken'; | ||
const testExpiresInSeconds = 1; | ||
const testRefreshToken = 'testRefreshToken'; | ||
const credentials = new TestCredentials(testApiKey, testAccessToken, testExpiresInSeconds, testRefreshToken); | ||
jest.spyOn(credentials, 'getToken'); | ||
await expect(credentials.getAccessToken()).resolves.toBe(testAccessToken); | ||
expect(credentials.getToken).toHaveBeenCalled(); | ||
jest.clearAllMocks(); | ||
await expect(credentials.getAccessToken()).resolves.toBe(testAccessToken); | ||
expect(credentials.getToken).toHaveBeenCalled(); | ||
jest.clearAllMocks(); | ||
await expect(credentials.getAccessToken()).resolves.toBe(testAccessToken); | ||
expect(credentials.getToken).not.toHaveBeenCalled(); | ||
jest.clearAllMocks(); | ||
await expect(credentials.getAccessToken()).resolves.toBe(testAccessToken); | ||
expect(credentials.getToken).not.toHaveBeenCalled(); | ||
jest.clearAllMocks(); | ||
await sleep(testExpiresInSeconds); | ||
await expect(credentials.getAccessToken()).resolves.toBe(testAccessToken); | ||
expect(credentials.getToken).toHaveBeenCalled(); | ||
jest.clearAllMocks(); | ||
}); | ||
await sleep(testExpiresInSeconds); | ||
await expect(credentials.getAccessToken()).resolves.toBe(testAccessToken); | ||
expect(credentials.getToken).toHaveBeenCalled(); | ||
jest.clearAllMocks(); | ||
}); |
@@ -0,10 +1,19 @@ | ||
import { TokenStorage } from './storage'; | ||
export class Token { | ||
readonly accessToken: string; | ||
readonly expiration: number; | ||
readonly refreshToken?: string; | ||
isValid() { | ||
return Date.now() < this.expiration; | ||
} | ||
constructor(accessToken: string, expiration: number, refreshToken?: string) { | ||
this.accessToken = accessToken; | ||
this.expiration = expiration; | ||
this.refreshToken = refreshToken; | ||
this.accessToken = accessToken; | ||
this.expiration = expiration; | ||
this.refreshToken = refreshToken; | ||
} | ||
@@ -15,21 +24,39 @@ } | ||
readonly apiKey: string; | ||
protected token?: Token; | ||
protected constructor(apiKey: string) { | ||
this.apiKey = apiKey; | ||
protected storage?: TokenStorage<Token>; | ||
protected constructor(apiKey: string, storage?: TokenStorage<Token>) { | ||
this.apiKey = apiKey; | ||
this.storage = storage; | ||
} | ||
getAccessToken(): Promise<string> { | ||
return new Promise<string>((resolve, reject) => { | ||
if (!!this.token && Date.now() < this.token.expiration) { | ||
resolve(this.token.accessToken); | ||
} else { | ||
this.getToken().then(token => { | ||
this.token = token; | ||
resolve(token.accessToken); | ||
}).catch(error => { | ||
reject(error); | ||
}); | ||
} | ||
}) | ||
const { storage } = this; | ||
return new Promise<string>((resolve, reject) => { | ||
let token = this.token || null; | ||
if (!(token && token.isValid()) && storage) { | ||
token = storage.getPersistentToken(); | ||
} | ||
if (token && token.isValid()) { | ||
this.token = token; | ||
return resolve(token.accessToken); | ||
} | ||
this.getToken().then((newToken) => { | ||
this.token = newToken; | ||
if (storage) { | ||
storage.setPersistentToken(newToken); | ||
} | ||
resolve(newToken.accessToken); | ||
}).catch((error) => { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
@@ -39,2 +66,1 @@ | ||
} | ||
@@ -1,21 +0,28 @@ | ||
import {Credentials, Token} from "./credentials"; | ||
import {Client} from "./client"; | ||
import { Credentials, Token } from './credentials'; | ||
import { Client } from './client'; | ||
export class TestCredentials extends Credentials { | ||
testAccessToken: string; | ||
testExpiration: number; | ||
testRefreshToken: string; | ||
constructor(testApiKey: string, testAccessToken: string, testExpiresInSeconds: number, testRefreshToken: string) { | ||
super(testApiKey); | ||
constructor( | ||
testApiKey: string, | ||
testAccessToken: string, | ||
testExpiresInSeconds: number, | ||
testRefreshToken: string, | ||
) { | ||
super(testApiKey); | ||
this.testAccessToken = testAccessToken; | ||
this.testExpiration = Date.now() + 1000 * testExpiresInSeconds; | ||
this.testRefreshToken = testRefreshToken; | ||
this.testAccessToken = testAccessToken; | ||
this.testExpiration = Date.now() + 1000 * testExpiresInSeconds; | ||
this.testRefreshToken = testRefreshToken; | ||
} | ||
getToken(): Promise<Token> { | ||
return new Promise<Token>((resolve, reject) => { | ||
resolve(new Token(this.testAccessToken, this.testExpiration, this.testRefreshToken)); | ||
}); | ||
return new Promise<Token>((resolve, reject) => { | ||
resolve(new Token(this.testAccessToken, this.testExpiration, this.testRefreshToken)); | ||
}); | ||
} | ||
@@ -26,15 +33,15 @@ } | ||
export function sleep(seconds: number) { | ||
return new Promise(resolve => setTimeout(resolve, 1000 * seconds)); | ||
return new Promise((resolve) => setTimeout(resolve, 1000 * seconds)); | ||
} | ||
export function getTestClient() { | ||
const testApiKey = 'testApiKey'; | ||
const testAccessToken = 'testAccessToken'; | ||
const testExpiresInSeconds = 3600; | ||
const testRefreshToken = 'testRefreshToken'; | ||
const credentials = new TestCredentials(testApiKey, testAccessToken, testExpiresInSeconds, testRefreshToken); | ||
const endpoint = 'http://localhost:8080'; | ||
return new Client(endpoint, credentials); | ||
const testApiKey = 'testApiKey'; | ||
const testAccessToken = 'testAccessToken'; | ||
const testExpiresInSeconds = 3600; | ||
const testRefreshToken = 'testRefreshToken'; | ||
const credentials = new TestCredentials(testApiKey, testAccessToken, testExpiresInSeconds, testRefreshToken); | ||
const endpoint = 'http://localhost:8080'; | ||
return new Client(endpoint, credentials); | ||
} | ||
test('Loading helpers', () => {}); | ||
test('Loading core helpers', () => {}); |
@@ -1,2 +0,3 @@ | ||
export {Credentials, Token} from './credentials'; | ||
export {Client} from './client'; | ||
export { Credentials, Token } from './credentials'; | ||
export { Client } from './client'; | ||
export { TokenStorage } from './storage'; |
30615
19
489