Compare commits

..

6 Commits
main ... v1.0.5

Author SHA1 Message Date
a0fa17fa1d 1.0.5 2022-02-17 11:54:44 +01:00
f5373c8c8d fix(core): update 2022-02-17 11:54:44 +01:00
ee60d6085c 1.0.4 2022-02-15 23:50:37 +01:00
0ab5f2039c fix(core): update 2022-02-15 23:50:37 +01:00
09f470d2f8 1.0.3 2022-02-15 16:51:16 +01:00
19699ada2a fix(core): update 2022-02-15 16:51:16 +01:00
9 changed files with 525 additions and 431 deletions

834
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@mojoio/tink", "name": "@mojoio/tink",
"version": "1.0.2", "version": "1.0.5",
"private": false, "private": false,
"description": "an unofficial api abstraction for tink.com", "description": "an unofficial api abstraction for tink.com",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -14,13 +14,16 @@
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.78", "@gitzone/tsbundle": "^1.0.78",
"@gitzone/tstest": "^1.0.44", "@gitzone/tstest": "^1.0.64",
"@pushrocks/tapbundle": "^3.2.9", "@pushrocks/qenv": "^4.0.10",
"@types/node": "^14.11.2", "@pushrocks/tapbundle": "^4.0.7",
"@types/node": "^17.0.18",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": {}, "dependencies": {
"@pushrocks/smartrequest": "^1.1.56"
},
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
], ],

3
qenv.yml Normal file
View File

@ -0,0 +1,3 @@
required:
- TINK_CLIENT_ID
- TINK_CLIENT_SECRET

26
test/test.nonci.ts Normal file
View File

@ -0,0 +1,26 @@
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
import * as qenv from '@pushrocks/qenv';
const testQenv = new qenv.Qenv('./', './.nogit/');
import * as tink from '../ts/index';
let tinkTestAccount: tink.TinkAccount;
tap.test('should create a valid tink account', async () => {
tinkTestAccount = new tink.TinkAccount(
testQenv.getEnvVarOnDemand('TINK_CLIENT_ID'),
testQenv.getEnvVarOnDemand('TINK_CLIENT_SECRET')
);
expect(tinkTestAccount).toBeInstanceOf(tink.TinkAccount);
});
tap.test('should report tink as healthy', async () => {
await expectAsync(tinkTestAccount.getTinkHealthyBoolean()).toBeTrue();
});
tap.test('should create a valid request', async () => {
await tinkTestAccount.request('', 'POST', '', {});
})
tap.start();

View File

@ -1,8 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as tink from '../ts/index';
tap.test('first test', async () => {
console.log(tink.standardExport);
});
tap.start();

View File

@ -1,3 +1 @@
import * as plugins from './tink.plugins'; export * from './tink.classes.tinkaccount';
export let standardExport = 'Hi there! :) This is an exported string';

View File

@ -0,0 +1,59 @@
import * as plugins from './tink.plugins';
export class TinkAccount {
private clientId: string;
private clientSecret: string;
constructor(clientIdArg: string, clientSecretArg: string) {
this.clientId = clientIdArg;
this.clientSecret = clientSecretArg;
}
public async getTinkHealthyBoolean(): Promise<boolean> {
const response = await plugins.smartrequest.request(
'https://api.tink.com/api/v1/monitoring/healthy',
{}
);
return response.body === 'ok';
}
// the request method for tink respecting platform specific stuff
// e.g. certain headers if needed
public async request(
urlArg: string,
methodArg: 'POST' | 'GET',
scopeArg: string,
payloadArg: any
) {
// check health
if (!(await this.getTinkHealthyBoolean())) {
throw new Error('TINK is not healthy right now. Please try again later.');
} else {
console.log('tink is healthy, continuing...');
}
// lets get an accessToken for the request
const response = await plugins.smartrequest.postFormDataUrlEncoded(
'https://api.tink.com/api/v1/oauth/token',
{},
[
{
key: 'client_id',
content: this.clientId,
},
{
key: 'client_secret',
content: this.clientSecret,
},
{
key: 'grant_type',
content: 'client_credentials',
},
{
key: 'scope',
content: 'user:read',
},
]
);
console.log(response.statusCode);
console.log(response.body);
}
}

View File

@ -0,0 +1 @@
import * as plugins from './tink.plugins';

View File

@ -1,2 +1,6 @@
const removeme = {}; // @pushrocks scope
export { removeme }; import * as smartrequest from '@pushrocks/smartrequest';
export {
smartrequest
}