Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c10678b17 | |||
eb61d1abbf | |||
a0fa17fa1d | |||
f5373c8c8d | |||
ee60d6085c | |||
0ab5f2039c |
96
package-lock.json
generated
96
package-lock.json
generated
@ -1,22 +1,22 @@
|
||||
{
|
||||
"name": "@mojoio/tink",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.6",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@mojoio/tink",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.6",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartrequest": "^1.1.52"
|
||||
"@pushrocks/smartrequest": "^1.1.56"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsbundle": "^1.0.78",
|
||||
"@gitzone/tstest": "^1.0.64",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/tapbundle": "^4.0.3",
|
||||
"@pushrocks/tapbundle": "^4.0.7",
|
||||
"@types/node": "^17.0.18",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
@ -2465,9 +2465,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/smartexpect": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpect/-/smartexpect-1.0.11.tgz",
|
||||
"integrity": "sha512-LpNkDbOtEX+kFbFD8E7u+BV1XXEoicKv+7SeUSJcSXrakwgCe+MAUe8TffWax7YBZ4PGLYEpLpdRzCX67PjsdQ==",
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpect/-/smartexpect-1.0.12.tgz",
|
||||
"integrity": "sha512-uZJ5OPr3ei14/Ovs2JRmKd7WixR0XGVVREkJ5xIsxKhqU/nm2spUbVLYjNBaKxDGCHjTAmdq8AV5Ola8F3Ia7w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@ -2778,14 +2778,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/smartrequest": {
|
||||
"version": "1.1.52",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.52.tgz",
|
||||
"integrity": "sha512-ctQvj/o3UQ3thK3TejflOh0wNSvPgmli4hiTPgXiUlHZyJEnkoRiRB+cmtJHDWngO/l83kwxWHQPrseNBYRN6Q==",
|
||||
"version": "1.1.56",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.56.tgz",
|
||||
"integrity": "sha512-iF6bApmTgd3ZvRK8OHa77UFg8nVZxS1Y6iL8VfHpWOXdSlQZcXo/WbvwxYtu0+wkERAfFtCTGrrLAPGsFm9lhw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": "^3.1.5",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smarturl": "^2.0.1",
|
||||
"agentkeepalive": "^4.1.4",
|
||||
"agentkeepalive": "^4.2.0",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
@ -2908,16 +2908,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/smarttime": {
|
||||
"version": "3.0.43",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.43.tgz",
|
||||
"integrity": "sha512-d+/2G9gkDNlG6bfBNISMTK1bQnOekt6xu4xiDLPG492aFwTaexASjn2+4OKB3oMa9hNONLcDVvhD+Nywwi74Rw==",
|
||||
"version": "3.0.45",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.45.tgz",
|
||||
"integrity": "sha512-3E/92Qmq7h2SpaA1TcVmWD02forTNQqEPE7xpk2dv/ussr/qb3WiM/c/D7Oe4lLuPxit0aJrcZlbtQs0H79uRg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^5.0.0",
|
||||
"@pushrocks/lik": "^5.0.4",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"croner": "^4.0.69",
|
||||
"croner": "^4.0.86",
|
||||
"dayjs": "^1.10.7",
|
||||
"is-nan": "^1.3.2",
|
||||
"pretty-ms": "^7.0.1"
|
||||
@ -3025,18 +3025,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/tapbundle": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-4.0.3.tgz",
|
||||
"integrity": "sha512-MC5iO8+FTKOeFLgOcnSgJsD466LKMNiVPgPCxpxRhONWX2XmRnqsci3Bc8lD3VphfebICPbKr2bMgvO62wtp4w==",
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-4.0.7.tgz",
|
||||
"integrity": "sha512-ggm022doMy45+H66lYIOluEITAxm1VRqywd+4eK47FivvDaO06N+g/6eWcsav4KoB0n4QG71dAGxe4iS/8OpeQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@open-wc/testing-helpers": "^2.0.3",
|
||||
"@open-wc/testing-helpers": "^2.0.4",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"@pushrocks/smartexpect": "^1.0.11",
|
||||
"@pushrocks/smartexpect": "^1.0.12",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smarttime": "^3.0.43"
|
||||
"@pushrocks/smarttime": "^3.0.45"
|
||||
}
|
||||
},
|
||||
"node_modules/@pushrocks/webrequest": {
|
||||
@ -5539,9 +5539,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/croner": {
|
||||
"version": "4.0.83",
|
||||
"resolved": "https://verdaccio.lossless.one/croner/-/croner-4.0.83.tgz",
|
||||
"integrity": "sha512-uLsbJM6o1Q4g/+MYiyJlM+zkCWhLQBmu5v5nue58v7DVlfCWUVqj0JCmCipWtJxglBKDGMvsJj2DJMMWH/5E3A==",
|
||||
"version": "4.1.95",
|
||||
"resolved": "https://verdaccio.lossless.one/croner/-/croner-4.1.95.tgz",
|
||||
"integrity": "sha512-pFO5eKG2l+ku9F9zn1l/rRVKILiRNMjz51cMs12m36EOFKTDplP5wasxKpMkV4ar+M8Eulc7Ke+z1ecdKD5Bdw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
@ -17508,9 +17508,9 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartexpect": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpect/-/smartexpect-1.0.11.tgz",
|
||||
"integrity": "sha512-LpNkDbOtEX+kFbFD8E7u+BV1XXEoicKv+7SeUSJcSXrakwgCe+MAUe8TffWax7YBZ4PGLYEpLpdRzCX67PjsdQ==",
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexpect/-/smartexpect-1.0.12.tgz",
|
||||
"integrity": "sha512-uZJ5OPr3ei14/Ovs2JRmKd7WixR0XGVVREkJ5xIsxKhqU/nm2spUbVLYjNBaKxDGCHjTAmdq8AV5Ola8F3Ia7w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
@ -17802,13 +17802,13 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartrequest": {
|
||||
"version": "1.1.52",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.52.tgz",
|
||||
"integrity": "sha512-ctQvj/o3UQ3thK3TejflOh0wNSvPgmli4hiTPgXiUlHZyJEnkoRiRB+cmtJHDWngO/l83kwxWHQPrseNBYRN6Q==",
|
||||
"version": "1.1.56",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.56.tgz",
|
||||
"integrity": "sha512-iF6bApmTgd3ZvRK8OHa77UFg8nVZxS1Y6iL8VfHpWOXdSlQZcXo/WbvwxYtu0+wkERAfFtCTGrrLAPGsFm9lhw==",
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^3.1.5",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smarturl": "^2.0.1",
|
||||
"agentkeepalive": "^4.1.4",
|
||||
"agentkeepalive": "^4.2.0",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
},
|
||||
@ -17927,15 +17927,15 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smarttime": {
|
||||
"version": "3.0.43",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.43.tgz",
|
||||
"integrity": "sha512-d+/2G9gkDNlG6bfBNISMTK1bQnOekt6xu4xiDLPG492aFwTaexASjn2+4OKB3oMa9hNONLcDVvhD+Nywwi74Rw==",
|
||||
"version": "3.0.45",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.45.tgz",
|
||||
"integrity": "sha512-3E/92Qmq7h2SpaA1TcVmWD02forTNQqEPE7xpk2dv/ussr/qb3WiM/c/D7Oe4lLuPxit0aJrcZlbtQs0H79uRg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/lik": "^5.0.0",
|
||||
"@pushrocks/lik": "^5.0.4",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"croner": "^4.0.69",
|
||||
"croner": "^4.0.86",
|
||||
"dayjs": "^1.10.7",
|
||||
"is-nan": "^1.3.2",
|
||||
"pretty-ms": "^7.0.1"
|
||||
@ -18028,17 +18028,17 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/tapbundle": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-4.0.3.tgz",
|
||||
"integrity": "sha512-MC5iO8+FTKOeFLgOcnSgJsD466LKMNiVPgPCxpxRhONWX2XmRnqsci3Bc8lD3VphfebICPbKr2bMgvO62wtp4w==",
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-4.0.7.tgz",
|
||||
"integrity": "sha512-ggm022doMy45+H66lYIOluEITAxm1VRqywd+4eK47FivvDaO06N+g/6eWcsav4KoB0n4QG71dAGxe4iS/8OpeQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@open-wc/testing-helpers": "^2.0.3",
|
||||
"@open-wc/testing-helpers": "^2.0.4",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"@pushrocks/smartexpect": "^1.0.11",
|
||||
"@pushrocks/smartexpect": "^1.0.12",
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smarttime": "^3.0.43"
|
||||
"@pushrocks/smarttime": "^3.0.45"
|
||||
}
|
||||
},
|
||||
"@pushrocks/webrequest": {
|
||||
@ -19976,9 +19976,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"croner": {
|
||||
"version": "4.0.83",
|
||||
"resolved": "https://verdaccio.lossless.one/croner/-/croner-4.0.83.tgz",
|
||||
"integrity": "sha512-uLsbJM6o1Q4g/+MYiyJlM+zkCWhLQBmu5v5nue58v7DVlfCWUVqj0JCmCipWtJxglBKDGMvsJj2DJMMWH/5E3A==",
|
||||
"version": "4.1.95",
|
||||
"resolved": "https://verdaccio.lossless.one/croner/-/croner-4.1.95.tgz",
|
||||
"integrity": "sha512-pFO5eKG2l+ku9F9zn1l/rRVKILiRNMjz51cMs12m36EOFKTDplP5wasxKpMkV4ar+M8Eulc7Ke+z1ecdKD5Bdw==",
|
||||
"dev": true
|
||||
},
|
||||
"cross-spawn": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mojoio/tink",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.6",
|
||||
"private": false,
|
||||
"description": "an unofficial api abstraction for tink.com",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -16,13 +16,13 @@
|
||||
"@gitzone/tsbundle": "^1.0.78",
|
||||
"@gitzone/tstest": "^1.0.64",
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/tapbundle": "^4.0.3",
|
||||
"@pushrocks/tapbundle": "^4.0.7",
|
||||
"@types/node": "^17.0.18",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartrequest": "^1.1.52"
|
||||
"@pushrocks/smartrequest": "^1.1.56"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
|
@ -7,6 +7,16 @@ import * as tink from '../ts/index';
|
||||
|
||||
let tinkTestAccount: tink.TinkAccount;
|
||||
|
||||
tap.preTask('should delete existing users', async () => {
|
||||
const preTinkAccount = tinkTestAccount = new tink.TinkAccount(
|
||||
testQenv.getEnvVarOnDemand('TINK_CLIENT_ID'),
|
||||
testQenv.getEnvVarOnDemand('TINK_CLIENT_SECRET')
|
||||
);
|
||||
expect(tinkTestAccount).toBeInstanceOf(tink.TinkAccount);
|
||||
const tinkUser = new tink.TinkUser(preTinkAccount, null, 'user_1234_abc');
|
||||
await tinkUser.delete();
|
||||
})
|
||||
|
||||
tap.test('should create a valid tink account', async () => {
|
||||
tinkTestAccount = new tink.TinkAccount(
|
||||
testQenv.getEnvVarOnDemand('TINK_CLIENT_ID'),
|
||||
@ -20,7 +30,7 @@ tap.test('should report tink as healthy', async () => {
|
||||
});
|
||||
|
||||
tap.test('should create a valid request', async () => {
|
||||
await tinkTestAccount.request('', 'POST', '', {});
|
||||
await tinkTestAccount.createTinkUser("user_1234_abc");
|
||||
})
|
||||
|
||||
tap.start();
|
@ -1 +1,2 @@
|
||||
export * from './tink.classes.tinkaccount';
|
||||
export * from './tink.classes.tinkuser';
|
@ -1,61 +1,82 @@
|
||||
import * as plugins from './tink.plugins';
|
||||
|
||||
import { TinkUser } from './tink.classes.tinkuser'
|
||||
|
||||
export class TinkAccount {
|
||||
private clientId: string;
|
||||
private clientSecret: string;
|
||||
|
||||
private apiBaseUrl: string = 'https://api.tink.com';
|
||||
|
||||
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', {
|
||||
|
||||
});
|
||||
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) {
|
||||
public async request(optionsArg: {
|
||||
urlArg: string,
|
||||
methodArg: 'POST' | 'GET',
|
||||
scopeArg: string,
|
||||
payloadArg: any,
|
||||
externalUserId: string
|
||||
}) {
|
||||
// check health
|
||||
if (!(await this.getTinkHealthyBoolean())) {
|
||||
throw new Error('TINK is not healthy tight now. Please try again later.');
|
||||
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.postFormData('https://api.tink.com/api/v1/oauth/token', {
|
||||
const response = await plugins.smartrequest.postFormDataUrlEncoded(
|
||||
`${this.apiBaseUrl}/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: optionsArg.scopeArg,
|
||||
},
|
||||
]
|
||||
);
|
||||
if (response.statusCode !== 200) {
|
||||
throw new Error('there was an error aquiring an access token.');
|
||||
}
|
||||
const accessToken = response.body.access_token;
|
||||
|
||||
const response2 = await plugins.smartrequest.request(`${this.apiBaseUrl}${optionsArg.urlArg}`, {
|
||||
headers: {
|
||||
'content-type': 'multipart/form-data'
|
||||
}
|
||||
}, [
|
||||
{
|
||||
name: 'client_id',
|
||||
type: 'string',
|
||||
payload: this.clientId,
|
||||
contentType: 'text/plain'
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
{
|
||||
name: 'client_secret',
|
||||
type: 'string',
|
||||
payload: this.clientSecret,
|
||||
contentType: 'text/plain'
|
||||
},
|
||||
{
|
||||
name: 'grant_type',
|
||||
type: 'string',
|
||||
payload: 'client_credentials',
|
||||
contentType: 'text/plain'
|
||||
},
|
||||
{
|
||||
name: 'scope',
|
||||
type: 'string',
|
||||
payload: 'user:create',
|
||||
contentType: 'text/plain'
|
||||
}
|
||||
]);
|
||||
console.log(response.statusCode);
|
||||
console.log(response.body);
|
||||
};
|
||||
}
|
||||
method: optionsArg.methodArg,
|
||||
requestBody: JSON.stringify(optionsArg.payloadArg)
|
||||
})
|
||||
console.log(response2.statusCode);
|
||||
return response2.body;
|
||||
}
|
||||
|
||||
public async createTinkUser(externalUserIdArg: string) {
|
||||
const tinkuser = await TinkUser.createNewTinkUser(this, externalUserIdArg);
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,53 @@
|
||||
import * as plugins from './tink.plugins';
|
||||
import * as plugins from './tink.plugins';
|
||||
|
||||
import { TinkAccount } from './tink.classes.tinkaccount';
|
||||
|
||||
export class TinkUser {
|
||||
// STATIC
|
||||
public static async createNewTinkUser (tinkaccountArg: TinkAccount, externalUserIdArg: string) {
|
||||
const response = await tinkaccountArg.request({
|
||||
externalUserId: null,
|
||||
urlArg: '/api/v1/user/create',
|
||||
methodArg: 'POST',
|
||||
scopeArg: 'user:create',
|
||||
payloadArg: {
|
||||
"external_user_id": externalUserIdArg,
|
||||
"market": "GB",
|
||||
"locale": "en_US"
|
||||
}
|
||||
});
|
||||
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
public tinkAccountRef: TinkAccount;
|
||||
public tinkUserId: string;
|
||||
public externalUserIdArg: string;
|
||||
|
||||
public authorizationToken: string
|
||||
|
||||
constructor(tinkAccountrefArg: TinkAccount, tinkUserIdArg: string, externalUserIdArg: string) {
|
||||
this.tinkAccountRef = tinkAccountrefArg;
|
||||
this.tinkUserId = tinkUserIdArg;
|
||||
this.externalUserIdArg = externalUserIdArg;
|
||||
}
|
||||
|
||||
public async authorize() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes the user
|
||||
*/
|
||||
public async delete() {
|
||||
const response = await this.tinkAccountRef.request({
|
||||
externalUserId: this.externalUserIdArg,
|
||||
methodArg: 'POST',
|
||||
payloadArg: {},
|
||||
scopeArg: 'user:delete',
|
||||
urlArg: '/api/v1/user/delete'
|
||||
});
|
||||
console.log(response);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user