Compare commits

..

4 Commits

Author SHA1 Message Date
68a3fcb06f 1.0.9 2022-02-19 11:43:11 +01:00
2433b0d7b2 fix(core): update 2022-02-19 11:43:10 +01:00
570a1cd6b2 1.0.8 2022-02-19 01:37:48 +01:00
9425a85150 fix(core): update 2022-02-19 01:37:47 +01:00
5 changed files with 33 additions and 24 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@mojoio/tink",
"version": "1.0.7",
"version": "1.0.9",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@mojoio/tink",
"version": "1.0.7",
"version": "1.0.9",
"license": "MIT",
"dependencies": {
"@pushrocks/smartrequest": "^1.1.56"

View File

@ -1,6 +1,6 @@
{
"name": "@mojoio/tink",
"version": "1.0.7",
"version": "1.0.9",
"private": false,
"description": "an unofficial api abstraction for tink.com",
"main": "dist_ts/index.js",

View File

@ -19,8 +19,11 @@ tap.test('should report tink as healthy', async () => {
await expectAsync(tinkTestAccount.getTinkHealthyBoolean()).toBeTrue();
});
tap.test('should create a valid request', async () => {
await tinkTestAccount.createTinkUser("user_1234_abc");
tap.test('should create a valid request', async (toolsArg) => {
const tinkuser = await tinkTestAccount.createTinkUser("user_1234_abc");
console.log(await tinkuser.getTinkLink());
process.exit(0);
await toolsArg.delayFor(10000);
})
tap.test('should delete existing users', async () => {

View File

@ -52,7 +52,7 @@ export class TinkAccount {
return clientAccessToken;
}
public async getUserAuthroizationCode(
public async getUserAuthorizationCode(
externalUserIdArg: string,
actorCLientIdArg: string,
scopeArg: string
@ -130,14 +130,6 @@ export class TinkAccount {
return userAccessToken;
}
public async getTinkLinkCode(externalUserIdArg: string) {
const authorizationCode = this.getUserAuthroizationCode(
externalUserIdArg,
'df05e4b379934cd09963197cc855bfe9',
'authorization:read,authorization:grant,credentials:refresh,credentials:read,credentials:write,providers:read,user:read'
);
}
// the request method for tink respecting platform specific stuff
// e.g. certain headers if needed
public async request(optionsArg: {

View File

@ -11,10 +11,10 @@ export class TinkUser {
accessToken,
methodArg: 'POST',
payloadArg: {
"external_user_id": externalUserIdArg,
"market": "GB",
"locale": "en_US"
}
external_user_id: externalUserIdArg,
market: 'DE',
locale: 'en_US',
},
});
const newTinkUser = new TinkUser(tinkaccountArg, response.user_id, response.external_user_id);
@ -26,7 +26,7 @@ export class TinkUser {
public tinkUserId: string;
public externalUserIdArg: string;
public authorizationToken: string
public authorizationToken: string;
constructor(tinkAccountrefArg: TinkAccount, tinkUserIdArg: string, externalUserIdArg: string) {
this.tinkAccountRef = tinkAccountrefArg;
@ -38,14 +38,28 @@ export class TinkUser {
* deletes the user
*/
public async delete() {
const authorizationCode = await this.tinkAccountRef.getUserAuthroizationCode(this.externalUserIdArg, this.tinkAccountRef.clientId, 'user:delete');
const authorizationCode = await this.tinkAccountRef.getUserAuthorizationCode(
this.externalUserIdArg,
this.tinkAccountRef.clientId,
'user:delete'
);
const accessToken = await this.tinkAccountRef.getUserAccessToken(authorizationCode);
const response = await this.tinkAccountRef.request({
methodArg: 'POST',
accessToken,
payloadArg: {},
urlArg: '/api/v1/user/delete'
urlArg: '/api/v1/user/delete',
});
console.log(`successfully deleted user with externalId ${this.externalUserIdArg}`);
}
public async getTinkLink(): Promise<string> {
const authorizationCode = await this.tinkAccountRef.getUserAuthorizationCode(
this.externalUserIdArg,
'df05e4b379934cd09963197cc855bfe9', // this is a hardcoded app id for tink link, as recommended by tink.com
'authorization:read,authorization:grant,credentials:refresh,credentials:read,credentials:write,providers:read,user:read'
);
const tinkLinkUrl = `https://link.tink.com/1.0/business-transactions/connect-accounts?client_id=${'teststate'}&redirect_uri=https://console.tink.com/callback&authorization_code=${authorizationCode}&market=DE`;
return tinkLinkUrl;
}
}