BREAKING CHANGE(new TinkUser().getTinkLink()): now expects a tinkLinkOptionsArg

This commit is contained in:
Philipp Kunz 2022-05-12 16:42:36 +02:00
parent 596f4e5398
commit 019197e43c
6 changed files with 30 additions and 6 deletions

3
package-lock.json generated
View File

@ -9,6 +9,7 @@
"version": "2.0.0", "version": "2.0.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartrequest": "^1.1.56" "@pushrocks/smartrequest": "^1.1.56"
}, },
"devDependencies": { "devDependencies": {
@ -3802,7 +3803,6 @@
"version": "2.0.13", "version": "2.0.13",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.13.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.13.tgz",
"integrity": "sha512-s6Wh0BHWMfZ5VYONQwpxOYX1JeC9RKA0O9TxEzfZ6FCw2oNQb2QUPCixT9rsceKwva4+atKRw/RfU+Z7aJDmsA==", "integrity": "sha512-s6Wh0BHWMfZ5VYONQwpxOYX1JeC9RKA0O9TxEzfZ6FCw2oNQb2QUPCixT9rsceKwva4+atKRw/RfU+Z7aJDmsA==",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^3.0.6" "@pushrocks/smartpromise": "^3.0.6"
@ -13785,7 +13785,6 @@
"version": "2.0.13", "version": "2.0.13",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.13.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.13.tgz",
"integrity": "sha512-s6Wh0BHWMfZ5VYONQwpxOYX1JeC9RKA0O9TxEzfZ6FCw2oNQb2QUPCixT9rsceKwva4+atKRw/RfU+Z7aJDmsA==", "integrity": "sha512-s6Wh0BHWMfZ5VYONQwpxOYX1JeC9RKA0O9TxEzfZ6FCw2oNQb2QUPCixT9rsceKwva4+atKRw/RfU+Z7aJDmsA==",
"dev": true,
"requires": { "requires": {
"@pushrocks/smartpromise": "^3.0.6" "@pushrocks/smartpromise": "^3.0.6"
} }

View File

@ -23,6 +23,7 @@
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartrequest": "^1.1.56" "@pushrocks/smartrequest": "^1.1.56"
}, },
"browserslist": [ "browserslist": [

View File

@ -19,12 +19,15 @@ tap.test('should report tink as healthy', async () => {
await expectAsync(tinkTestAccount.getTinkHealthyBoolean()).toBeTrue(); await expectAsync(tinkTestAccount.getTinkHealthyBoolean()).toBeTrue();
}); });
tap.test('should create a tink user', async (toolsArg) => {
await tinkTestAccount.createTinkUser('user_1234_abc');
})
tap.test('should create a valid request', async (toolsArg) => { tap.test('should create a valid request', async (toolsArg) => {
const tinkuser: tink.TinkUser = await tinkTestAccount.getTinkUser('user_1234_abc'); const tinkuser: tink.TinkUser = await tinkTestAccount.getTinkUser('user_1234_abc');
console.log(tinkuser); console.log(tinkuser);
console.log(await tinkuser.getTinkLinkForMarket()); // defaults to 'DE'; console.log(await tinkuser.getTinkLinkForMarket()); // defaults to 'DE';
console.log(await tinkuser.getProviderConsents()); console.log(await tinkuser.getProviderConsents());
await toolsArg.delayFor(10000);
}); });
tap.test('should delete existing users', async () => { tap.test('should delete existing users', async () => {

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@mojoio/tink',
version: '3.0.0',
description: 'an unofficial api abstraction for tink.com'
}

View File

@ -109,13 +109,24 @@ export class TinkUser {
* gets a tink link that can be used by a user to connect accounts * gets a tink link that can be used by a user to connect accounts
* @returns * @returns
*/ */
public async getTinkLinkForMarket(countryIdArg: string = 'DE', redirectUrlArg = 'https://console.tink.com/callback'): Promise<string> { public async getTinkLinkForMarket(linkOptionsArg: {
countryId: string;
redirectUrl: string;
testProviderBool?: boolean;
} = {
countryId: 'DE',
redirectUrl: 'https://console.tink.com/callback',
testProviderBool: true
}): Promise<string> {
if (typeof linkOptionsArg.testProviderBool !== 'boolean') {
linkOptionsArg.testProviderBool = false;
}
const authorizationCode = await this.tinkAccountRef.getUserAuthorizationCode( const authorizationCode = await this.tinkAccountRef.getUserAuthorizationCode(
this.externalUserIdArg, this.externalUserIdArg,
'df05e4b379934cd09963197cc855bfe9', // this is a hardcoded app id for tink link, as recommended by tink.com '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' '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=${redirectUrlArg}&authorization_code=${authorizationCode}&market=${countryIdArg}`; const tinkLinkUrl = `https://link.tink.com/1.0/business-transactions/connect-accounts?client_id=${'teststate'}&redirect_uri=${linkOptionsArg.redirectUrl}&authorization_code=${authorizationCode}&market=${linkOptionsArg.countryId}&test=${linkOptionsArg.testProviderBool}`;
return tinkLinkUrl; return tinkLinkUrl;
} }

View File

@ -1,4 +1,6 @@
// @pushrocks scope // @pushrocks scope
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@pushrocks/smartrequest';
import * as smartpromise from '@pushrocks/smartpromise';
export { smartrequest }; export { smartdelay, smartrequest, smartpromise };