diff --git a/package-lock.json b/package-lock.json index aa18d75..5e62f22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "2.0.0", "license": "MIT", "dependencies": { + "@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartrequest": "^1.1.56" }, "devDependencies": { @@ -3802,7 +3803,6 @@ "version": "2.0.13", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.13.tgz", "integrity": "sha512-s6Wh0BHWMfZ5VYONQwpxOYX1JeC9RKA0O9TxEzfZ6FCw2oNQb2QUPCixT9rsceKwva4+atKRw/RfU+Z7aJDmsA==", - "dev": true, "license": "MIT", "dependencies": { "@pushrocks/smartpromise": "^3.0.6" @@ -13785,7 +13785,6 @@ "version": "2.0.13", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.13.tgz", "integrity": "sha512-s6Wh0BHWMfZ5VYONQwpxOYX1JeC9RKA0O9TxEzfZ6FCw2oNQb2QUPCixT9rsceKwva4+atKRw/RfU+Z7aJDmsA==", - "dev": true, "requires": { "@pushrocks/smartpromise": "^3.0.6" } diff --git a/package.json b/package.json index 30f06ba..0bf5597 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "tslint-config-prettier": "^1.15.0" }, "dependencies": { + "@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartrequest": "^1.1.56" }, "browserslist": [ diff --git a/test/test.nonci.ts b/test/test.nonci.ts index 4e3fc68..0ea0d55 100644 --- a/test/test.nonci.ts +++ b/test/test.nonci.ts @@ -19,12 +19,15 @@ tap.test('should report tink as healthy', async () => { 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) => { const tinkuser: tink.TinkUser = await tinkTestAccount.getTinkUser('user_1234_abc'); console.log(tinkuser); console.log(await tinkuser.getTinkLinkForMarket()); // defaults to 'DE'; console.log(await tinkuser.getProviderConsents()); - await toolsArg.delayFor(10000); }); tap.test('should delete existing users', async () => { diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts new file mode 100644 index 0000000..7d2e471 --- /dev/null +++ b/ts/00_commitinfo_data.ts @@ -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' +} diff --git a/ts/tink.classes.tinkuser.ts b/ts/tink.classes.tinkuser.ts index 2fe76ae..4316fed 100644 --- a/ts/tink.classes.tinkuser.ts +++ b/ts/tink.classes.tinkuser.ts @@ -109,13 +109,24 @@ export class TinkUser { * gets a tink link that can be used by a user to connect accounts * @returns */ - public async getTinkLinkForMarket(countryIdArg: string = 'DE', redirectUrlArg = 'https://console.tink.com/callback'): Promise { + public async getTinkLinkForMarket(linkOptionsArg: { + countryId: string; + redirectUrl: string; + testProviderBool?: boolean; + } = { + countryId: 'DE', + redirectUrl: 'https://console.tink.com/callback', + testProviderBool: true + }): Promise { + if (typeof linkOptionsArg.testProviderBool !== 'boolean') { + linkOptionsArg.testProviderBool = false; + } 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=${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; } diff --git a/ts/tink.plugins.ts b/ts/tink.plugins.ts index 898aacd..32700b0 100644 --- a/ts/tink.plugins.ts +++ b/ts/tink.plugins.ts @@ -1,4 +1,6 @@ // @pushrocks scope +import * as smartdelay from '@pushrocks/smartdelay'; import * as smartrequest from '@pushrocks/smartrequest'; +import * as smartpromise from '@pushrocks/smartpromise'; -export { smartrequest }; +export { smartdelay, smartrequest, smartpromise };