Skip to content
Snippets Groups Projects
  • Filip Stybel's avatar
    5bb4f4b2
    Nordigen integration - account sync (#457) · 5bb4f4b2
    Filip Stybel authored
    
    * Update gitignore about .idea folder
    
    The .idea folder is generated by IntelliJ IDEA
    
    * Add integration with Nordigen
    
    * Fix linter
    
    * Use longer access to the account
    
    * Move normalizatoin of accounts to the backend side
    
    * Fix possibility to force remove account
    
    * Move normalization of transactions to the backend side
    
    * Fix Settings.js after merge
    
    * fix enableing bank sync
    
    * delete old Settings component
    
    * Use camelCase for nordigen/remove-account call
    
    * WIP refactor
    
    * Fix auto-selecting existing accounts
    
    * Fix unlinking accounts
    
    * Align to backend changes for Nordigen integration
    
    * Fix AnimatedLoading
    
    * Code review changes
    
    * Fix TZ date issue
    
    * rm mobile package
    
    * rm BankSync settings section
    
    * rm console.log
    
    * rm comment
    
    * applies some alignments from code review
    
    * applies some alignments from code review
    
    * Add prefix for nordigen specific functionality
    
    * Use arrow char
    
    * Add prefix for nordigen functionalities
    
    * Fix linter
    
    * Display only open accounts
    
    * Update packages/desktop-client/src/nordigen.js
    
    Co-authored-by: default avatarJed Fox <git@jedfox.com>
    
    * Fix incorrect calc of TZ for endDate
    
    * Improved error checking
    
    * Fix throwing invalid-schema error
    
    * Fix for syncing large batches in Safari
    
    ---------
    
    Co-authored-by: default avatarFilip Stybel <filip.stybel@ynd.co>
    Co-authored-by: default avatarLeon Ebel <24588023+ebelleon@users.noreply.github.com>
    Co-authored-by: default avatarJed Fox <git@jedfox.com>
    Nordigen integration - account sync (#457)
    Filip Stybel authored
    
    * Update gitignore about .idea folder
    
    The .idea folder is generated by IntelliJ IDEA
    
    * Add integration with Nordigen
    
    * Fix linter
    
    * Use longer access to the account
    
    * Move normalizatoin of accounts to the backend side
    
    * Fix possibility to force remove account
    
    * Move normalization of transactions to the backend side
    
    * Fix Settings.js after merge
    
    * fix enableing bank sync
    
    * delete old Settings component
    
    * Use camelCase for nordigen/remove-account call
    
    * WIP refactor
    
    * Fix auto-selecting existing accounts
    
    * Fix unlinking accounts
    
    * Align to backend changes for Nordigen integration
    
    * Fix AnimatedLoading
    
    * Code review changes
    
    * Fix TZ date issue
    
    * rm mobile package
    
    * rm BankSync settings section
    
    * rm console.log
    
    * rm comment
    
    * applies some alignments from code review
    
    * applies some alignments from code review
    
    * Add prefix for nordigen specific functionality
    
    * Use arrow char
    
    * Add prefix for nordigen functionalities
    
    * Fix linter
    
    * Display only open accounts
    
    * Update packages/desktop-client/src/nordigen.js
    
    Co-authored-by: default avatarJed Fox <git@jedfox.com>
    
    * Fix incorrect calc of TZ for endDate
    
    * Improved error checking
    
    * Fix throwing invalid-schema error
    
    * Fix for syncing large batches in Safari
    
    ---------
    
    Co-authored-by: default avatarFilip Stybel <filip.stybel@ynd.co>
    Co-authored-by: default avatarLeon Ebel <24588023+ebelleon@users.noreply.github.com>
    Co-authored-by: default avatarJed Fox <git@jedfox.com>
nordigen.js 1.04 KiB
import { send } from 'loot-core/src/platform/client/fetch';

function _authorize(pushModal, upgradingAccountId, { onSuccess, onClose }) {
  pushModal('nordigen-external-msg', {
    onMoveExternal: async ({ institutionId }) => {
      const accessValidForDays = 30;
      const resp = await send('nordigen-create-web-token', {
        upgradingAccountId,
        institutionId,
        accessValidForDays,
      });

      if (resp.error) return resp;
      const { link, requisitionId } = resp;
      window.Actual.openURLInBrowser(link);

      let { error, data } = await send('nordigen-poll-web-token', {
        upgradingAccountId,
        requisitionId,
      });

      return { error, data };
    },

    onClose,
    onSuccess,
  });
}

export async function authorizeBank(pushModal, { upgradingAccountId } = {}) {
  _authorize(pushModal, upgradingAccountId, {
    onSuccess: async data => {
      pushModal('select-linked-accounts', {
        accounts: data.accounts,
        requisitionId: data.id,
        upgradingAccountId,
      });
    },
  });
}