@cranberry-money/shared-services 1.12.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +240 -0
- package/README.md +464 -190
- package/dist/api/functional-client.d.ts +66 -0
- package/dist/api/functional-client.d.ts.map +1 -0
- package/dist/api/functional-client.js +165 -0
- package/dist/auth/functional/auth-operations.d.ts +116 -0
- package/dist/auth/functional/auth-operations.d.ts.map +1 -0
- package/dist/auth/functional/auth-operations.js +246 -0
- package/dist/auth/functional/auth-state.d.ts +38 -0
- package/dist/auth/functional/auth-state.d.ts.map +1 -0
- package/dist/auth/functional/auth-state.js +87 -0
- package/dist/auth/functional/token-storage.d.ts +44 -0
- package/dist/auth/functional/token-storage.d.ts.map +1 -0
- package/dist/auth/functional/token-storage.js +178 -0
- package/dist/auth/react/AuthProvider.d.ts +92 -0
- package/dist/auth/react/AuthProvider.d.ts.map +1 -0
- package/dist/auth/react/AuthProvider.js +207 -0
- package/dist/index.d.ts +25 -34
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +114 -40
- package/dist/integration/blueberry-integration.d.ts +21 -0
- package/dist/integration/blueberry-integration.d.ts.map +1 -0
- package/dist/integration/blueberry-integration.js +109 -0
- package/dist/integration/index.d.ts +8 -0
- package/dist/integration/index.d.ts.map +1 -0
- package/dist/integration/index.js +18 -0
- package/dist/services/accounts.d.ts +220 -0
- package/dist/services/accounts.d.ts.map +1 -0
- package/dist/services/accounts.js +175 -0
- package/dist/services/banks.d.ts +123 -0
- package/dist/services/banks.d.ts.map +1 -0
- package/dist/services/banks.js +151 -0
- package/dist/services/cash-accounts.d.ts +112 -0
- package/dist/services/cash-accounts.d.ts.map +1 -0
- package/dist/services/cash-accounts.js +222 -0
- package/dist/services/documents.d.ts +143 -0
- package/dist/services/documents.d.ts.map +1 -0
- package/dist/services/documents.js +253 -0
- package/dist/services/factories/account-factory.d.ts +16 -0
- package/dist/services/factories/account-factory.d.ts.map +1 -0
- package/dist/services/factories/account-factory.js +79 -0
- package/dist/services/factories/auth-factory.d.ts +23 -0
- package/dist/services/factories/auth-factory.d.ts.map +1 -0
- package/dist/services/factories/auth-factory.js +75 -0
- package/dist/services/factories/bank-factory.d.ts +16 -0
- package/dist/services/factories/bank-factory.d.ts.map +1 -0
- package/dist/services/factories/bank-factory.js +72 -0
- package/dist/services/factories/cash-account-factory.d.ts +16 -0
- package/dist/services/factories/cash-account-factory.d.ts.map +1 -0
- package/dist/services/factories/cash-account-factory.js +74 -0
- package/dist/services/factories/document-factory.d.ts +16 -0
- package/dist/services/factories/document-factory.d.ts.map +1 -0
- package/dist/services/factories/document-factory.js +85 -0
- package/dist/services/factories/index.d.ts +21 -0
- package/dist/services/factories/index.d.ts.map +1 -0
- package/dist/services/factories/index.js +40 -0
- package/dist/services/factories/instrument-factory.d.ts +16 -0
- package/dist/services/factories/instrument-factory.d.ts.map +1 -0
- package/dist/services/factories/instrument-factory.js +68 -0
- package/dist/services/factories/master-factory.d.ts +74 -0
- package/dist/services/factories/master-factory.d.ts.map +1 -0
- package/dist/services/factories/master-factory.js +183 -0
- package/dist/services/factories/portfolio-factory.d.ts +16 -0
- package/dist/services/factories/portfolio-factory.d.ts.map +1 -0
- package/dist/services/factories/portfolio-factory.js +74 -0
- package/dist/services/factories/portfolio-template-factory.d.ts +16 -0
- package/dist/services/factories/portfolio-template-factory.d.ts.map +1 -0
- package/dist/services/factories/portfolio-template-factory.js +76 -0
- package/dist/services/factories/reference-data-factory.d.ts +16 -0
- package/dist/services/factories/reference-data-factory.d.ts.map +1 -0
- package/dist/services/factories/reference-data-factory.js +86 -0
- package/dist/services/factories/tax-residency-factory.d.ts +16 -0
- package/dist/services/factories/tax-residency-factory.d.ts.map +1 -0
- package/dist/services/factories/tax-residency-factory.js +73 -0
- package/dist/services/factories/trade-factory.d.ts +16 -0
- package/dist/services/factories/trade-factory.d.ts.map +1 -0
- package/dist/services/factories/trade-factory.js +79 -0
- package/dist/services/factories/types.d.ts +250 -0
- package/dist/services/factories/types.d.ts.map +1 -0
- package/dist/services/factories/types.js +32 -0
- package/dist/services/factories/withdrawal-factory.d.ts +16 -0
- package/dist/services/factories/withdrawal-factory.d.ts.map +1 -0
- package/dist/services/factories/withdrawal-factory.js +78 -0
- package/dist/services/instruments.d.ts +138 -0
- package/dist/services/instruments.d.ts.map +1 -0
- package/dist/services/instruments.js +178 -0
- package/dist/services/portfolio-templates.d.ts +142 -0
- package/dist/services/portfolio-templates.d.ts.map +1 -0
- package/dist/services/portfolio-templates.js +201 -0
- package/dist/services/portfolios.d.ts +161 -0
- package/dist/services/portfolios.d.ts.map +1 -0
- package/dist/services/portfolios.js +144 -0
- package/dist/services/reference-data.d.ts +185 -0
- package/dist/services/reference-data.d.ts.map +1 -0
- package/dist/services/reference-data.js +245 -0
- package/dist/services/tax-residencies.d.ts +83 -0
- package/dist/services/tax-residencies.d.ts.map +1 -0
- package/dist/services/tax-residencies.js +179 -0
- package/dist/services/trades.d.ts +190 -0
- package/dist/services/trades.d.ts.map +1 -0
- package/dist/services/trades.js +207 -0
- package/dist/services/withdrawals.d.ts +236 -0
- package/dist/services/withdrawals.d.ts.map +1 -0
- package/dist/services/withdrawals.js +345 -0
- package/package.json +43 -16
- package/dist/adapters/MobileApiClient.d.ts +0 -68
- package/dist/adapters/MobileApiClient.d.ts.map +0 -1
- package/dist/adapters/MobileApiClient.js +0 -240
- package/dist/adapters/MobileTokenStorage.d.ts +0 -43
- package/dist/adapters/MobileTokenStorage.d.ts.map +0 -1
- package/dist/adapters/MobileTokenStorage.js +0 -128
- package/dist/adapters/WebApiClient.d.ts +0 -28
- package/dist/adapters/WebApiClient.d.ts.map +0 -1
- package/dist/adapters/WebApiClient.js +0 -119
- package/dist/adapters/WebTokenStorage.d.ts +0 -38
- package/dist/adapters/WebTokenStorage.d.ts.map +0 -1
- package/dist/adapters/WebTokenStorage.js +0 -86
- package/dist/api/apiClient.d.ts +0 -31
- package/dist/api/apiClient.d.ts.map +0 -1
- package/dist/api/apiClient.js +0 -49
- package/dist/api/types.d.ts +0 -51
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -4
- package/dist/auth/AuthManager.d.ts +0 -81
- package/dist/auth/AuthManager.d.ts.map +0 -1
- package/dist/auth/AuthManager.js +0 -223
- package/dist/auth/createAuthManager.d.ts +0 -63
- package/dist/auth/createAuthManager.d.ts.map +0 -1
- package/dist/auth/createAuthManager.js +0 -103
- package/dist/auth/useAuthManager.d.ts +0 -66
- package/dist/auth/useAuthManager.d.ts.map +0 -1
- package/dist/auth/useAuthManager.js +0 -133
- package/dist/core/BaseApiClient.d.ts +0 -82
- package/dist/core/BaseApiClient.d.ts.map +0 -1
- package/dist/core/BaseApiClient.js +0 -89
- package/dist/core/TokenStorage.d.ts +0 -45
- package/dist/core/TokenStorage.d.ts.map +0 -1
- package/dist/core/TokenStorage.js +0 -23
- package/dist/query/QueryClient.d.ts +0 -82
- package/dist/query/QueryClient.d.ts.map +0 -1
- package/dist/query/QueryClient.js +0 -136
- package/dist/query/useAuth.d.ts +0 -64
- package/dist/query/useAuth.d.ts.map +0 -1
- package/dist/query/useAuth.js +0 -144
- package/dist/query/usePortfolios.d.ts +0 -79
- package/dist/query/usePortfolios.d.ts.map +0 -1
- package/dist/query/usePortfolios.js +0 -172
- package/dist/services/AuthService.d.ts +0 -75
- package/dist/services/AuthService.d.ts.map +0 -1
- package/dist/services/AuthService.js +0 -83
- package/dist/services/BaseService.d.ts +0 -48
- package/dist/services/BaseService.d.ts.map +0 -1
- package/dist/services/BaseService.js +0 -51
- package/dist/services/PortfolioService.d.ts +0 -100
- package/dist/services/PortfolioService.d.ts.map +0 -1
- package/dist/services/PortfolioService.js +0 -68
- package/dist/services/accounts/constants.d.ts +0 -24
- package/dist/services/accounts/constants.d.ts.map +0 -1
- package/dist/services/accounts/constants.js +0 -30
- package/dist/services/accounts/index.d.ts +0 -7
- package/dist/services/accounts/index.d.ts.map +0 -1
- package/dist/services/accounts/index.js +0 -6
- package/dist/services/accounts/service.d.ts +0 -11
- package/dist/services/accounts/service.d.ts.map +0 -1
- package/dist/services/accounts/service.js +0 -19
- package/dist/services/accounts/types.d.ts +0 -15
- package/dist/services/accounts/types.d.ts.map +0 -1
- package/dist/services/accounts/types.js +0 -4
- package/dist/services/auth/constants.d.ts +0 -30
- package/dist/services/auth/constants.d.ts.map +0 -1
- package/dist/services/auth/constants.js +0 -37
- package/dist/services/auth/index.d.ts +0 -8
- package/dist/services/auth/index.d.ts.map +0 -1
- package/dist/services/auth/index.js +0 -7
- package/dist/services/auth/service.d.ts +0 -8
- package/dist/services/auth/service.d.ts.map +0 -1
- package/dist/services/auth/service.js +0 -23
- package/dist/services/auth/types.d.ts +0 -38
- package/dist/services/auth/types.d.ts.map +0 -1
- package/dist/services/auth/types.js +0 -1
- package/dist/services/auth/utils.d.ts +0 -46
- package/dist/services/auth/utils.d.ts.map +0 -1
- package/dist/services/auth/utils.js +0 -113
- package/dist/services/banks/constants.d.ts +0 -47
- package/dist/services/banks/constants.d.ts.map +0 -1
- package/dist/services/banks/constants.js +0 -98
- package/dist/services/banks/index.d.ts +0 -8
- package/dist/services/banks/index.d.ts.map +0 -1
- package/dist/services/banks/index.js +0 -7
- package/dist/services/banks/service.d.ts +0 -9
- package/dist/services/banks/service.d.ts.map +0 -1
- package/dist/services/banks/service.js +0 -38
- package/dist/services/banks/types.d.ts +0 -36
- package/dist/services/banks/types.d.ts.map +0 -1
- package/dist/services/banks/types.js +0 -4
- package/dist/services/cash_accounts/constants.d.ts +0 -7
- package/dist/services/cash_accounts/constants.d.ts.map +0 -1
- package/dist/services/cash_accounts/constants.js +0 -7
- package/dist/services/cash_accounts/index.d.ts +0 -5
- package/dist/services/cash_accounts/index.d.ts.map +0 -1
- package/dist/services/cash_accounts/index.js +0 -6
- package/dist/services/cash_accounts/service.d.ts +0 -8
- package/dist/services/cash_accounts/service.d.ts.map +0 -1
- package/dist/services/cash_accounts/service.js +0 -32
- package/dist/services/cash_accounts/transactions/constants.d.ts +0 -18
- package/dist/services/cash_accounts/transactions/constants.d.ts.map +0 -1
- package/dist/services/cash_accounts/transactions/constants.js +0 -25
- package/dist/services/cash_accounts/transactions/index.d.ts +0 -5
- package/dist/services/cash_accounts/transactions/index.d.ts.map +0 -1
- package/dist/services/cash_accounts/transactions/index.js +0 -6
- package/dist/services/cash_accounts/transactions/service.d.ts +0 -13
- package/dist/services/cash_accounts/transactions/service.d.ts.map +0 -1
- package/dist/services/cash_accounts/transactions/service.js +0 -75
- package/dist/services/cash_accounts/transactions/types.d.ts +0 -38
- package/dist/services/cash_accounts/transactions/types.d.ts.map +0 -1
- package/dist/services/cash_accounts/transactions/types.js +0 -11
- package/dist/services/cash_accounts/types.d.ts +0 -24
- package/dist/services/cash_accounts/types.d.ts.map +0 -1
- package/dist/services/cash_accounts/types.js +0 -4
- package/dist/services/countries/constants.d.ts +0 -9
- package/dist/services/countries/constants.d.ts.map +0 -1
- package/dist/services/countries/constants.js +0 -10
- package/dist/services/countries/index.d.ts +0 -5
- package/dist/services/countries/index.d.ts.map +0 -1
- package/dist/services/countries/index.js +0 -6
- package/dist/services/countries/service.d.ts +0 -18
- package/dist/services/countries/service.d.ts.map +0 -1
- package/dist/services/countries/service.js +0 -32
- package/dist/services/countries/types.d.ts +0 -24
- package/dist/services/countries/types.d.ts.map +0 -1
- package/dist/services/countries/types.js +0 -1
- package/dist/services/countries/utils.d.ts +0 -38
- package/dist/services/countries/utils.d.ts.map +0 -1
- package/dist/services/countries/utils.js +0 -62
- package/dist/services/documents/constants.d.ts +0 -55
- package/dist/services/documents/constants.d.ts.map +0 -1
- package/dist/services/documents/constants.js +0 -50
- package/dist/services/documents/index.d.ts +0 -6
- package/dist/services/documents/index.d.ts.map +0 -1
- package/dist/services/documents/index.js +0 -6
- package/dist/services/documents/service.d.ts +0 -50
- package/dist/services/documents/service.d.ts.map +0 -1
- package/dist/services/documents/service.js +0 -116
- package/dist/services/documents/types.d.ts +0 -47
- package/dist/services/documents/types.d.ts.map +0 -1
- package/dist/services/documents/types.js +0 -1
- package/dist/services/documents/utils.d.ts +0 -26
- package/dist/services/documents/utils.d.ts.map +0 -1
- package/dist/services/documents/utils.js +0 -37
- package/dist/services/industries/constants.d.ts +0 -8
- package/dist/services/industries/constants.d.ts.map +0 -1
- package/dist/services/industries/constants.js +0 -9
- package/dist/services/industries/index.d.ts +0 -6
- package/dist/services/industries/index.d.ts.map +0 -1
- package/dist/services/industries/index.js +0 -6
- package/dist/services/industries/service.d.ts +0 -18
- package/dist/services/industries/service.d.ts.map +0 -1
- package/dist/services/industries/service.js +0 -43
- package/dist/services/industries/types.d.ts +0 -21
- package/dist/services/industries/types.d.ts.map +0 -1
- package/dist/services/industries/types.js +0 -1
- package/dist/services/industries/utils.d.ts +0 -47
- package/dist/services/industries/utils.d.ts.map +0 -1
- package/dist/services/industries/utils.js +0 -86
- package/dist/services/instruments/constants.d.ts +0 -38
- package/dist/services/instruments/constants.d.ts.map +0 -1
- package/dist/services/instruments/constants.js +0 -36
- package/dist/services/instruments/index.d.ts +0 -5
- package/dist/services/instruments/index.d.ts.map +0 -1
- package/dist/services/instruments/index.js +0 -6
- package/dist/services/instruments/service.d.ts +0 -54
- package/dist/services/instruments/service.d.ts.map +0 -1
- package/dist/services/instruments/service.js +0 -106
- package/dist/services/instruments/types.d.ts +0 -83
- package/dist/services/instruments/types.d.ts.map +0 -1
- package/dist/services/instruments/types.js +0 -1
- package/dist/services/instruments/utils.d.ts +0 -50
- package/dist/services/instruments/utils.d.ts.map +0 -1
- package/dist/services/instruments/utils.js +0 -111
- package/dist/services/portfolio_templates/constants.d.ts +0 -8
- package/dist/services/portfolio_templates/constants.d.ts.map +0 -1
- package/dist/services/portfolio_templates/constants.js +0 -8
- package/dist/services/portfolio_templates/index.d.ts +0 -5
- package/dist/services/portfolio_templates/index.d.ts.map +0 -1
- package/dist/services/portfolio_templates/index.js +0 -5
- package/dist/services/portfolio_templates/service.d.ts +0 -6
- package/dist/services/portfolio_templates/service.d.ts.map +0 -1
- package/dist/services/portfolio_templates/service.js +0 -14
- package/dist/services/portfolio_templates/types.d.ts +0 -49
- package/dist/services/portfolio_templates/types.d.ts.map +0 -1
- package/dist/services/portfolio_templates/types.js +0 -1
- package/dist/services/portfolio_templates/utils.d.ts +0 -8
- package/dist/services/portfolio_templates/utils.d.ts.map +0 -1
- package/dist/services/portfolio_templates/utils.js +0 -13
- package/dist/services/portfolios/allocations/index.d.ts +0 -7
- package/dist/services/portfolios/allocations/index.d.ts.map +0 -1
- package/dist/services/portfolios/allocations/index.js +0 -6
- package/dist/services/portfolios/allocations/service.d.ts +0 -6
- package/dist/services/portfolios/allocations/service.d.ts.map +0 -1
- package/dist/services/portfolios/allocations/service.js +0 -19
- package/dist/services/portfolios/allocations/types.d.ts +0 -17
- package/dist/services/portfolios/allocations/types.d.ts.map +0 -1
- package/dist/services/portfolios/allocations/types.js +0 -4
- package/dist/services/portfolios/allocations/utils.d.ts +0 -3
- package/dist/services/portfolios/allocations/utils.d.ts.map +0 -1
- package/dist/services/portfolios/allocations/utils.js +0 -7
- package/dist/services/portfolios/constants.d.ts +0 -45
- package/dist/services/portfolios/constants.d.ts.map +0 -1
- package/dist/services/portfolios/constants.js +0 -57
- package/dist/services/portfolios/holdings/index.d.ts +0 -7
- package/dist/services/portfolios/holdings/index.d.ts.map +0 -1
- package/dist/services/portfolios/holdings/index.js +0 -6
- package/dist/services/portfolios/holdings/service.d.ts +0 -10
- package/dist/services/portfolios/holdings/service.d.ts.map +0 -1
- package/dist/services/portfolios/holdings/service.js +0 -53
- package/dist/services/portfolios/holdings/types.d.ts +0 -42
- package/dist/services/portfolios/holdings/types.d.ts.map +0 -1
- package/dist/services/portfolios/holdings/types.js +0 -4
- package/dist/services/portfolios/holdings/utils.d.ts +0 -8
- package/dist/services/portfolios/holdings/utils.d.ts.map +0 -1
- package/dist/services/portfolios/holdings/utils.js +0 -82
- package/dist/services/portfolios/index.d.ts +0 -10
- package/dist/services/portfolios/index.d.ts.map +0 -1
- package/dist/services/portfolios/index.js +0 -10
- package/dist/services/portfolios/service.d.ts +0 -7
- package/dist/services/portfolios/service.d.ts.map +0 -1
- package/dist/services/portfolios/service.js +0 -19
- package/dist/services/portfolios/types.d.ts +0 -29
- package/dist/services/portfolios/types.d.ts.map +0 -1
- package/dist/services/portfolios/types.js +0 -1
- package/dist/services/portfolios/utils.d.ts +0 -5
- package/dist/services/portfolios/utils.d.ts.map +0 -1
- package/dist/services/portfolios/utils.js +0 -26
- package/dist/services/sectors/constants.d.ts +0 -7
- package/dist/services/sectors/constants.d.ts.map +0 -1
- package/dist/services/sectors/constants.js +0 -7
- package/dist/services/sectors/index.d.ts +0 -6
- package/dist/services/sectors/index.d.ts.map +0 -1
- package/dist/services/sectors/index.js +0 -6
- package/dist/services/sectors/service.d.ts +0 -14
- package/dist/services/sectors/service.d.ts.map +0 -1
- package/dist/services/sectors/service.js +0 -32
- package/dist/services/sectors/types.d.ts +0 -19
- package/dist/services/sectors/types.d.ts.map +0 -1
- package/dist/services/sectors/types.js +0 -1
- package/dist/services/sectors/utils.d.ts +0 -31
- package/dist/services/sectors/utils.d.ts.map +0 -1
- package/dist/services/sectors/utils.js +0 -54
- package/dist/services/stock_exchanges/constants.d.ts +0 -7
- package/dist/services/stock_exchanges/constants.d.ts.map +0 -1
- package/dist/services/stock_exchanges/constants.js +0 -7
- package/dist/services/stock_exchanges/index.d.ts +0 -6
- package/dist/services/stock_exchanges/index.d.ts.map +0 -1
- package/dist/services/stock_exchanges/index.js +0 -6
- package/dist/services/stock_exchanges/service.d.ts +0 -4
- package/dist/services/stock_exchanges/service.d.ts.map +0 -1
- package/dist/services/stock_exchanges/service.js +0 -26
- package/dist/services/stock_exchanges/types.d.ts +0 -28
- package/dist/services/stock_exchanges/types.d.ts.map +0 -1
- package/dist/services/stock_exchanges/types.js +0 -1
- package/dist/services/stock_exchanges/utils.d.ts +0 -8
- package/dist/services/stock_exchanges/utils.d.ts.map +0 -1
- package/dist/services/stock_exchanges/utils.js +0 -37
- package/dist/services/tax_residencies/constants.d.ts +0 -7
- package/dist/services/tax_residencies/constants.d.ts.map +0 -1
- package/dist/services/tax_residencies/constants.js +0 -7
- package/dist/services/tax_residencies/index.d.ts +0 -10
- package/dist/services/tax_residencies/index.d.ts.map +0 -1
- package/dist/services/tax_residencies/index.js +0 -11
- package/dist/services/tax_residencies/service.d.ts +0 -6
- package/dist/services/tax_residencies/service.d.ts.map +0 -1
- package/dist/services/tax_residencies/service.js +0 -20
- package/dist/services/tax_residencies/types.d.ts +0 -26
- package/dist/services/tax_residencies/types.d.ts.map +0 -1
- package/dist/services/tax_residencies/types.js +0 -4
- package/dist/services/tax_residencies/utils.d.ts +0 -9
- package/dist/services/tax_residencies/utils.d.ts.map +0 -1
- package/dist/services/tax_residencies/utils.js +0 -19
- package/dist/services/trades/constants.d.ts +0 -47
- package/dist/services/trades/constants.d.ts.map +0 -1
- package/dist/services/trades/constants.js +0 -61
- package/dist/services/trades/index.d.ts +0 -4
- package/dist/services/trades/index.d.ts.map +0 -1
- package/dist/services/trades/index.js +0 -12
- package/dist/services/trades/service.d.ts +0 -19
- package/dist/services/trades/service.d.ts.map +0 -1
- package/dist/services/trades/service.js +0 -177
- package/dist/services/trades/types.d.ts +0 -114
- package/dist/services/trades/types.d.ts.map +0 -1
- package/dist/services/trades/types.js +0 -1
- package/dist/services/users/constants.d.ts +0 -7
- package/dist/services/users/constants.d.ts.map +0 -1
- package/dist/services/users/constants.js +0 -8
- package/dist/services/users/index.d.ts +0 -9
- package/dist/services/users/index.d.ts.map +0 -1
- package/dist/services/users/index.js +0 -9
- package/dist/services/users/investment_preferences/constants.d.ts +0 -7
- package/dist/services/users/investment_preferences/constants.d.ts.map +0 -1
- package/dist/services/users/investment_preferences/constants.js +0 -7
- package/dist/services/users/investment_preferences/index.d.ts +0 -7
- package/dist/services/users/investment_preferences/index.d.ts.map +0 -1
- package/dist/services/users/investment_preferences/index.js +0 -6
- package/dist/services/users/investment_preferences/service.d.ts +0 -5
- package/dist/services/users/investment_preferences/service.d.ts.map +0 -1
- package/dist/services/users/investment_preferences/service.js +0 -12
- package/dist/services/users/investment_preferences/types.d.ts +0 -23
- package/dist/services/users/investment_preferences/types.d.ts.map +0 -1
- package/dist/services/users/investment_preferences/types.js +0 -1
- package/dist/services/users/service.d.ts +0 -6
- package/dist/services/users/service.d.ts.map +0 -1
- package/dist/services/users/service.js +0 -15
- package/dist/services/users/types.d.ts +0 -32
- package/dist/services/users/types.d.ts.map +0 -1
- package/dist/services/users/types.js +0 -1
- package/dist/services/users/utils.d.ts +0 -2
- package/dist/services/users/utils.d.ts.map +0 -1
- package/dist/services/users/utils.js +0 -6
- package/dist/services/withdrawals/constants.d.ts +0 -67
- package/dist/services/withdrawals/constants.d.ts.map +0 -1
- package/dist/services/withdrawals/constants.js +0 -91
- package/dist/services/withdrawals/index.d.ts +0 -6
- package/dist/services/withdrawals/index.d.ts.map +0 -1
- package/dist/services/withdrawals/index.js +0 -7
- package/dist/services/withdrawals/service.d.ts +0 -4
- package/dist/services/withdrawals/service.d.ts.map +0 -1
- package/dist/services/withdrawals/service.js +0 -5
- package/dist/services/withdrawals/types.d.ts +0 -81
- package/dist/services/withdrawals/types.d.ts.map +0 -1
- package/dist/services/withdrawals/types.js +0 -1
- package/dist/services/withdrawals/utils.d.ts +0 -20
- package/dist/services/withdrawals/utils.d.ts.map +0 -1
- package/dist/services/withdrawals/utils.js +0 -110
- package/dist/services/withdrawals/withdrawal_liquidations/index.d.ts +0 -3
- package/dist/services/withdrawals/withdrawal_liquidations/index.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_liquidations/index.js +0 -2
- package/dist/services/withdrawals/withdrawal_liquidations/service.d.ts +0 -8
- package/dist/services/withdrawals/withdrawal_liquidations/service.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_liquidations/service.js +0 -68
- package/dist/services/withdrawals/withdrawal_liquidations/types.d.ts +0 -2
- package/dist/services/withdrawals/withdrawal_liquidations/types.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_liquidations/types.js +0 -1
- package/dist/services/withdrawals/withdrawal_requests/index.d.ts +0 -3
- package/dist/services/withdrawals/withdrawal_requests/index.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_requests/index.js +0 -2
- package/dist/services/withdrawals/withdrawal_requests/service.d.ts +0 -7
- package/dist/services/withdrawals/withdrawal_requests/service.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_requests/service.js +0 -55
- package/dist/services/withdrawals/withdrawal_requests/types.d.ts +0 -2
- package/dist/services/withdrawals/withdrawal_requests/types.d.ts.map +0 -1
- package/dist/services/withdrawals/withdrawal_requests/types.js +0 -1
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mobile-specific API client implementation
|
|
3
|
-
*
|
|
4
|
-
* This implementation is designed for React Native environments
|
|
5
|
-
* and includes mobile-specific features like network state awareness,
|
|
6
|
-
* offline capability, and retry logic.
|
|
7
|
-
*/
|
|
8
|
-
import { HTTP_HEADER_CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON } from '@cranberry-money/shared-constants';
|
|
9
|
-
import { BaseApiClient } from '../core/BaseApiClient';
|
|
10
|
-
export class MobileApiClient extends BaseApiClient {
|
|
11
|
-
constructor(config) {
|
|
12
|
-
super({
|
|
13
|
-
...config,
|
|
14
|
-
defaultHeaders: {
|
|
15
|
-
[HTTP_HEADER_CONTENT_TYPE]: CONTENT_TYPE_APPLICATION_JSON,
|
|
16
|
-
...config.defaultHeaders,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
this.offlineQueue = [];
|
|
20
|
-
this.isOnline = true;
|
|
21
|
-
this.retryAttempts = config.retryAttempts || 3;
|
|
22
|
-
this.retryDelay = config.retryDelay || 1000;
|
|
23
|
-
this.offlineQueueEnabled = config.offlineQueueEnabled || false;
|
|
24
|
-
}
|
|
25
|
-
async request(config) {
|
|
26
|
-
// Check if we're offline and should queue the request
|
|
27
|
-
if (!this.isOnline && this.offlineQueueEnabled) {
|
|
28
|
-
return this.queueRequest(config);
|
|
29
|
-
}
|
|
30
|
-
return this.executeRequest(config);
|
|
31
|
-
}
|
|
32
|
-
async executeRequest(config, attempt = 1) {
|
|
33
|
-
const url = this.buildUrl(config.url);
|
|
34
|
-
const headers = await this.buildHeaders(config.headers);
|
|
35
|
-
// Build fetch options
|
|
36
|
-
const fetchOptions = {
|
|
37
|
-
method: config.method || 'GET',
|
|
38
|
-
headers,
|
|
39
|
-
signal: config.timeout ? AbortSignal.timeout(config.timeout) : undefined,
|
|
40
|
-
};
|
|
41
|
-
// Add body for non-GET requests
|
|
42
|
-
if (config.data && config.method !== 'GET') {
|
|
43
|
-
if (headers[HTTP_HEADER_CONTENT_TYPE] === CONTENT_TYPE_APPLICATION_JSON) {
|
|
44
|
-
fetchOptions.body = JSON.stringify(config.data);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
fetchOptions.body = config.data;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Add query parameters for GET requests
|
|
51
|
-
const requestUrl = config.params && config.method === 'GET'
|
|
52
|
-
? `${url}?${new URLSearchParams(config.params).toString()}`
|
|
53
|
-
: url;
|
|
54
|
-
try {
|
|
55
|
-
const response = await fetch(requestUrl, fetchOptions);
|
|
56
|
-
// Handle non-2xx responses
|
|
57
|
-
if (!response.ok) {
|
|
58
|
-
const errorData = await this.parseResponseData(response);
|
|
59
|
-
// Handle authentication errors
|
|
60
|
-
if (response.status === 401) {
|
|
61
|
-
const refreshed = await this.handleTokenRefresh();
|
|
62
|
-
if (refreshed && attempt === 1) {
|
|
63
|
-
// Retry once with new token
|
|
64
|
-
return this.executeRequest(config, attempt + 1);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
throw this.createError(response.statusText || 'Request failed', response.status, 'HTTP_ERROR', errorData);
|
|
68
|
-
}
|
|
69
|
-
const data = await this.parseResponseData(response);
|
|
70
|
-
return {
|
|
71
|
-
data,
|
|
72
|
-
status: response.status,
|
|
73
|
-
statusText: response.statusText,
|
|
74
|
-
headers: this.parseResponseHeaders(response.headers),
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
// Handle network errors with retry logic
|
|
79
|
-
if (this.shouldRetry(error, attempt)) {
|
|
80
|
-
await this.delay(this.retryDelay * attempt); // Exponential backoff
|
|
81
|
-
return this.executeRequest(config, attempt + 1);
|
|
82
|
-
}
|
|
83
|
-
// Handle different error types
|
|
84
|
-
if (error instanceof TypeError && error.message.includes('fetch')) {
|
|
85
|
-
throw this.createError('Network error', 0, 'NETWORK_ERROR');
|
|
86
|
-
}
|
|
87
|
-
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
88
|
-
throw this.createError('Request timeout', 0, 'TIMEOUT_ERROR');
|
|
89
|
-
}
|
|
90
|
-
// Re-throw API errors
|
|
91
|
-
if (this.isApiError(error)) {
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
// Handle unexpected errors
|
|
95
|
-
throw this.createError(error instanceof Error ? error.message : 'Unknown error', 0, 'UNEXPECTED_ERROR');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Queue request for when back online
|
|
100
|
-
*/
|
|
101
|
-
async queueRequest(config) {
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
this.offlineQueue.push({
|
|
104
|
-
...config,
|
|
105
|
-
resolve: resolve,
|
|
106
|
-
reject,
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Process offline queue when back online
|
|
112
|
-
*/
|
|
113
|
-
async syncWhenOnline() {
|
|
114
|
-
if (!this.isOnline || this.offlineQueue.length === 0)
|
|
115
|
-
return;
|
|
116
|
-
const queue = [...this.offlineQueue];
|
|
117
|
-
this.offlineQueue = [];
|
|
118
|
-
for (const request of queue) {
|
|
119
|
-
try {
|
|
120
|
-
const response = await this.executeRequest(request);
|
|
121
|
-
request.resolve(response);
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
request.reject(error);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Enable offline mode
|
|
130
|
-
*/
|
|
131
|
-
enableOfflineMode() {
|
|
132
|
-
this.isOnline = false;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Enable online mode and sync queue
|
|
136
|
-
*/
|
|
137
|
-
async enableOnlineMode() {
|
|
138
|
-
this.isOnline = true;
|
|
139
|
-
if (this.offlineQueueEnabled) {
|
|
140
|
-
await this.syncWhenOnline();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Set network state
|
|
145
|
-
*/
|
|
146
|
-
setNetworkState(isOnline) {
|
|
147
|
-
const wasOffline = !this.isOnline;
|
|
148
|
-
this.isOnline = isOnline;
|
|
149
|
-
if (wasOffline && isOnline && this.offlineQueueEnabled) {
|
|
150
|
-
// Process queue when coming back online
|
|
151
|
-
this.syncWhenOnline().catch(console.error);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Parse response data based on content type
|
|
156
|
-
*/
|
|
157
|
-
async parseResponseData(response) {
|
|
158
|
-
const contentType = response.headers.get('content-type') || '';
|
|
159
|
-
if (contentType.includes('application/json')) {
|
|
160
|
-
return response.json();
|
|
161
|
-
}
|
|
162
|
-
if (contentType.includes('text/')) {
|
|
163
|
-
return response.text();
|
|
164
|
-
}
|
|
165
|
-
// For other content types, return as blob
|
|
166
|
-
return response.blob();
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Convert Headers to plain object
|
|
170
|
-
*/
|
|
171
|
-
parseResponseHeaders(headers) {
|
|
172
|
-
const headerObj = {};
|
|
173
|
-
headers.forEach((value, key) => {
|
|
174
|
-
headerObj[key] = value;
|
|
175
|
-
});
|
|
176
|
-
return headerObj;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Check if error is an API error
|
|
180
|
-
*/
|
|
181
|
-
isApiError(error) {
|
|
182
|
-
return typeof error === 'object' &&
|
|
183
|
-
error !== null &&
|
|
184
|
-
'message' in error &&
|
|
185
|
-
'status' in error;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Determine if request should be retried
|
|
189
|
-
*/
|
|
190
|
-
shouldRetry(error, attempt) {
|
|
191
|
-
if (attempt >= this.retryAttempts)
|
|
192
|
-
return false;
|
|
193
|
-
// Retry on network errors
|
|
194
|
-
if (error instanceof TypeError && error.message.includes('fetch')) {
|
|
195
|
-
return true;
|
|
196
|
-
}
|
|
197
|
-
// Retry on timeout errors
|
|
198
|
-
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
// Retry on certain HTTP status codes
|
|
202
|
-
if (this.isApiError(error)) {
|
|
203
|
-
const status = error.status;
|
|
204
|
-
return status === 429 || (status !== undefined && status >= 500); // Rate limit or server errors
|
|
205
|
-
}
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Handle token refresh for mobile (secure storage based)
|
|
210
|
-
*/
|
|
211
|
-
async handleTokenRefresh() {
|
|
212
|
-
if (!this.tokenStorage)
|
|
213
|
-
return false;
|
|
214
|
-
try {
|
|
215
|
-
const tokens = await this.tokenStorage.retrieveTokens();
|
|
216
|
-
if (!tokens?.refresh)
|
|
217
|
-
return false;
|
|
218
|
-
const response = await this.request({
|
|
219
|
-
url: '/auth/refresh',
|
|
220
|
-
method: 'POST',
|
|
221
|
-
data: { refresh: tokens.refresh },
|
|
222
|
-
});
|
|
223
|
-
if (response.status === 200 && response.data) {
|
|
224
|
-
const newTokens = response.data;
|
|
225
|
-
await this.tokenStorage.storeTokens(newTokens);
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Utility delay function
|
|
236
|
-
*/
|
|
237
|
-
delay(ms) {
|
|
238
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
239
|
-
}
|
|
240
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mobile-specific token storage using secure storage
|
|
3
|
-
*
|
|
4
|
-
* This implementation uses platform-secure storage mechanisms
|
|
5
|
-
* like iOS Keychain and Android Keystore via React Native libraries.
|
|
6
|
-
*
|
|
7
|
-
* For Expo: Uses Expo SecureStore
|
|
8
|
-
* For bare React Native: Would use @react-native-async-storage/async-storage
|
|
9
|
-
* with encryption or react-native-keychain
|
|
10
|
-
*/
|
|
11
|
-
import { BaseTokenStorage, type TokenPair } from '../core/TokenStorage';
|
|
12
|
-
export declare class MobileTokenStorage extends BaseTokenStorage {
|
|
13
|
-
private secureStore;
|
|
14
|
-
constructor(secureStore: SecureStoreInterface);
|
|
15
|
-
storeTokens(tokens: TokenPair): Promise<void>;
|
|
16
|
-
retrieveTokens(): Promise<TokenPair | null>;
|
|
17
|
-
clearTokens(): Promise<void>;
|
|
18
|
-
hasTokens(): Promise<boolean>;
|
|
19
|
-
/**
|
|
20
|
-
* Check if secure storage is available
|
|
21
|
-
*/
|
|
22
|
-
isAvailable(): Promise<boolean>;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Interface for secure storage implementations
|
|
26
|
-
* This abstracts the specific secure storage library being used
|
|
27
|
-
*/
|
|
28
|
-
export interface SecureStoreInterface {
|
|
29
|
-
setItemAsync(key: string, value: string): Promise<void>;
|
|
30
|
-
getItemAsync(key: string): Promise<string | null>;
|
|
31
|
-
deleteItemAsync(key: string): Promise<void>;
|
|
32
|
-
isAvailableAsync?(): Promise<boolean>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Factory function to create MobileTokenStorage with different backends
|
|
36
|
-
*/
|
|
37
|
-
export declare const createMobileTokenStorage: (secureStore: SecureStoreInterface) => MobileTokenStorage;
|
|
38
|
-
/**
|
|
39
|
-
* Expo SecureStore adapter
|
|
40
|
-
* Usage: createMobileTokenStorage(createExpoSecureStoreAdapter())
|
|
41
|
-
*/
|
|
42
|
-
export declare const createExpoSecureStoreAdapter: () => SecureStoreInterface;
|
|
43
|
-
//# sourceMappingURL=MobileTokenStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MobileTokenStorage.d.ts","sourceRoot":"","sources":["../../src/adapters/MobileTokenStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAQxE,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,OAAO,CAAC,WAAW,CAAuB;gBAE9B,WAAW,EAAE,oBAAoB;IAKvC,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAe7C,cAAc,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IA0B3C,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAanC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAStC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,gBAAgB,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,aAAa,oBAAoB,KAAG,kBAE5E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,QAAO,oBAsB/C,CAAC"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mobile-specific token storage using secure storage
|
|
3
|
-
*
|
|
4
|
-
* This implementation uses platform-secure storage mechanisms
|
|
5
|
-
* like iOS Keychain and Android Keystore via React Native libraries.
|
|
6
|
-
*
|
|
7
|
-
* For Expo: Uses Expo SecureStore
|
|
8
|
-
* For bare React Native: Would use @react-native-async-storage/async-storage
|
|
9
|
-
* with encryption or react-native-keychain
|
|
10
|
-
*/
|
|
11
|
-
import { BaseTokenStorage } from '../core/TokenStorage';
|
|
12
|
-
// Keys for secure storage
|
|
13
|
-
const STORAGE_KEYS = {
|
|
14
|
-
ACCESS_TOKEN: 'myportfolio_access_token',
|
|
15
|
-
REFRESH_TOKEN: 'myportfolio_refresh_token',
|
|
16
|
-
};
|
|
17
|
-
export class MobileTokenStorage extends BaseTokenStorage {
|
|
18
|
-
constructor(secureStore) {
|
|
19
|
-
super();
|
|
20
|
-
this.secureStore = secureStore;
|
|
21
|
-
}
|
|
22
|
-
async storeTokens(tokens) {
|
|
23
|
-
if (!this.validateTokens(tokens)) {
|
|
24
|
-
throw new Error('Invalid token format');
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
await Promise.all([
|
|
28
|
-
this.secureStore.setItemAsync(STORAGE_KEYS.ACCESS_TOKEN, tokens.access),
|
|
29
|
-
this.secureStore.setItemAsync(STORAGE_KEYS.REFRESH_TOKEN, tokens.refresh),
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
throw new Error(`Failed to store tokens: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async retrieveTokens() {
|
|
37
|
-
try {
|
|
38
|
-
const [access, refresh] = await Promise.all([
|
|
39
|
-
this.secureStore.getItemAsync(STORAGE_KEYS.ACCESS_TOKEN),
|
|
40
|
-
this.secureStore.getItemAsync(STORAGE_KEYS.REFRESH_TOKEN),
|
|
41
|
-
]);
|
|
42
|
-
if (!access || !refresh) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const tokens = { access, refresh };
|
|
46
|
-
if (!this.validateTokens(tokens)) {
|
|
47
|
-
// Clear invalid tokens
|
|
48
|
-
await this.clearTokens();
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return tokens;
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
console.error('Failed to retrieve tokens:', error);
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
async clearTokens() {
|
|
59
|
-
try {
|
|
60
|
-
await Promise.all([
|
|
61
|
-
this.secureStore.deleteItemAsync(STORAGE_KEYS.ACCESS_TOKEN),
|
|
62
|
-
this.secureStore.deleteItemAsync(STORAGE_KEYS.REFRESH_TOKEN),
|
|
63
|
-
]);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
console.error('Failed to clear tokens:', error);
|
|
67
|
-
// Don't throw - clearing should be idempotent
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async hasTokens() {
|
|
71
|
-
try {
|
|
72
|
-
const [access, refresh] = await Promise.all([
|
|
73
|
-
this.secureStore.getItemAsync(STORAGE_KEYS.ACCESS_TOKEN),
|
|
74
|
-
this.secureStore.getItemAsync(STORAGE_KEYS.REFRESH_TOKEN),
|
|
75
|
-
]);
|
|
76
|
-
return !!(access && refresh);
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Check if secure storage is available
|
|
84
|
-
*/
|
|
85
|
-
async isAvailable() {
|
|
86
|
-
try {
|
|
87
|
-
// Try to perform a simple operation to check availability
|
|
88
|
-
await this.secureStore.isAvailableAsync?.();
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Factory function to create MobileTokenStorage with different backends
|
|
98
|
-
*/
|
|
99
|
-
export const createMobileTokenStorage = (secureStore) => {
|
|
100
|
-
return new MobileTokenStorage(secureStore);
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Expo SecureStore adapter
|
|
104
|
-
* Usage: createMobileTokenStorage(createExpoSecureStoreAdapter())
|
|
105
|
-
*/
|
|
106
|
-
export const createExpoSecureStoreAdapter = () => {
|
|
107
|
-
// This would be implemented when actually using Expo
|
|
108
|
-
// For now, return a mock implementation for type checking
|
|
109
|
-
return {
|
|
110
|
-
async setItemAsync(key, value) {
|
|
111
|
-
// In real implementation: await ExpoSecureStore.setItemAsync(key, value);
|
|
112
|
-
console.log(`Mock: Storing ${key} = ${value}`);
|
|
113
|
-
},
|
|
114
|
-
async getItemAsync(key) {
|
|
115
|
-
// In real implementation: return await ExpoSecureStore.getItemAsync(key);
|
|
116
|
-
console.log(`Mock: Retrieving ${key}`);
|
|
117
|
-
return null;
|
|
118
|
-
},
|
|
119
|
-
async deleteItemAsync(key) {
|
|
120
|
-
// In real implementation: await ExpoSecureStore.deleteItemAsync(key);
|
|
121
|
-
console.log(`Mock: Deleting ${key}`);
|
|
122
|
-
},
|
|
123
|
-
async isAvailableAsync() {
|
|
124
|
-
// In real implementation: return await ExpoSecureStore.isAvailableAsync();
|
|
125
|
-
return true;
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web-specific API client implementation using fetch or axios
|
|
3
|
-
*
|
|
4
|
-
* This implementation is designed for web browsers and supports
|
|
5
|
-
* cookie-based authentication with proper CORS handling.
|
|
6
|
-
*/
|
|
7
|
-
import { BaseApiClient, type RequestConfig, type ApiResponse, type ApiClientConfig } from '../core/BaseApiClient';
|
|
8
|
-
export declare class WebApiClient extends BaseApiClient {
|
|
9
|
-
constructor(config: ApiClientConfig);
|
|
10
|
-
request<T = unknown>(config: RequestConfig): Promise<ApiResponse<T>>;
|
|
11
|
-
/**
|
|
12
|
-
* Parse response data based on content type
|
|
13
|
-
*/
|
|
14
|
-
private parseResponseData;
|
|
15
|
-
/**
|
|
16
|
-
* Convert Headers to plain object
|
|
17
|
-
*/
|
|
18
|
-
private parseResponseHeaders;
|
|
19
|
-
/**
|
|
20
|
-
* Check if error is an API error
|
|
21
|
-
*/
|
|
22
|
-
private isApiError;
|
|
23
|
-
/**
|
|
24
|
-
* Handle token refresh for web (cookie-based)
|
|
25
|
-
*/
|
|
26
|
-
protected handleTokenRefresh(): Promise<boolean>;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=WebApiClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebApiClient.d.ts","sourceRoot":"","sources":["../../src/adapters/WebApiClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAElH,qBAAa,YAAa,SAAQ,aAAa;gBACjC,MAAM,EAAE,eAAe;IAU7B,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAoE1E;;OAEG;YACW,iBAAiB;IAe/B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;OAEG;IACH,OAAO,CAAC,UAAU;IAOlB;;OAEG;cACa,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;CAcvD"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web-specific API client implementation using fetch or axios
|
|
3
|
-
*
|
|
4
|
-
* This implementation is designed for web browsers and supports
|
|
5
|
-
* cookie-based authentication with proper CORS handling.
|
|
6
|
-
*/
|
|
7
|
-
import { HTTP_HEADER_CONTENT_TYPE, CONTENT_TYPE_APPLICATION_JSON } from '@cranberry-money/shared-constants';
|
|
8
|
-
import { BaseApiClient } from '../core/BaseApiClient';
|
|
9
|
-
export class WebApiClient extends BaseApiClient {
|
|
10
|
-
constructor(config) {
|
|
11
|
-
super({
|
|
12
|
-
...config,
|
|
13
|
-
defaultHeaders: {
|
|
14
|
-
[HTTP_HEADER_CONTENT_TYPE]: CONTENT_TYPE_APPLICATION_JSON,
|
|
15
|
-
...config.defaultHeaders,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async request(config) {
|
|
20
|
-
const url = this.buildUrl(config.url);
|
|
21
|
-
const headers = await this.buildHeaders(config.headers);
|
|
22
|
-
// Build fetch options
|
|
23
|
-
const fetchOptions = {
|
|
24
|
-
method: config.method || 'GET',
|
|
25
|
-
headers,
|
|
26
|
-
credentials: this.withCredentials ? 'include' : 'omit',
|
|
27
|
-
};
|
|
28
|
-
// Add body for non-GET requests
|
|
29
|
-
if (config.data && config.method !== 'GET') {
|
|
30
|
-
if (headers[HTTP_HEADER_CONTENT_TYPE] === CONTENT_TYPE_APPLICATION_JSON) {
|
|
31
|
-
fetchOptions.body = JSON.stringify(config.data);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
fetchOptions.body = config.data;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Add query parameters for GET requests
|
|
38
|
-
const requestUrl = config.params && config.method === 'GET'
|
|
39
|
-
? `${url}?${new URLSearchParams(config.params).toString()}`
|
|
40
|
-
: url;
|
|
41
|
-
try {
|
|
42
|
-
const response = await fetch(requestUrl, fetchOptions);
|
|
43
|
-
// Handle non-2xx responses
|
|
44
|
-
if (!response.ok) {
|
|
45
|
-
const errorData = await this.parseResponseData(response);
|
|
46
|
-
throw this.createError(response.statusText || 'Request failed', response.status, 'HTTP_ERROR', errorData);
|
|
47
|
-
}
|
|
48
|
-
const data = await this.parseResponseData(response);
|
|
49
|
-
return {
|
|
50
|
-
data,
|
|
51
|
-
status: response.status,
|
|
52
|
-
statusText: response.statusText,
|
|
53
|
-
headers: this.parseResponseHeaders(response.headers),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
// Handle network errors
|
|
58
|
-
if (error instanceof TypeError && error.message.includes('fetch')) {
|
|
59
|
-
throw this.createError('Network error', 0, 'NETWORK_ERROR');
|
|
60
|
-
}
|
|
61
|
-
// Re-throw API errors
|
|
62
|
-
if (this.isApiError(error)) {
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
// Handle unexpected errors
|
|
66
|
-
throw this.createError(error instanceof Error ? error.message : 'Unknown error', 0, 'UNEXPECTED_ERROR');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Parse response data based on content type
|
|
71
|
-
*/
|
|
72
|
-
async parseResponseData(response) {
|
|
73
|
-
const contentType = response.headers.get('content-type') || '';
|
|
74
|
-
if (contentType.includes('application/json')) {
|
|
75
|
-
return response.json();
|
|
76
|
-
}
|
|
77
|
-
if (contentType.includes('text/')) {
|
|
78
|
-
return response.text();
|
|
79
|
-
}
|
|
80
|
-
// For other content types, return as blob
|
|
81
|
-
return response.blob();
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Convert Headers to plain object
|
|
85
|
-
*/
|
|
86
|
-
parseResponseHeaders(headers) {
|
|
87
|
-
const headerObj = {};
|
|
88
|
-
headers.forEach((value, key) => {
|
|
89
|
-
headerObj[key] = value;
|
|
90
|
-
});
|
|
91
|
-
return headerObj;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Check if error is an API error
|
|
95
|
-
*/
|
|
96
|
-
isApiError(error) {
|
|
97
|
-
return typeof error === 'object' &&
|
|
98
|
-
error !== null &&
|
|
99
|
-
'message' in error &&
|
|
100
|
-
'status' in error;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Handle token refresh for web (cookie-based)
|
|
104
|
-
*/
|
|
105
|
-
async handleTokenRefresh() {
|
|
106
|
-
try {
|
|
107
|
-
// For cookie-based auth, make a request to refresh endpoint
|
|
108
|
-
// The server will set new cookies automatically
|
|
109
|
-
const response = await this.request({
|
|
110
|
-
url: '/auth/refresh',
|
|
111
|
-
method: 'POST',
|
|
112
|
-
});
|
|
113
|
-
return response.status === 200;
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web-specific token storage using HTTP-only cookies
|
|
3
|
-
*
|
|
4
|
-
* This implementation relies on the backend to set HTTP-only cookies
|
|
5
|
-
* and doesn't directly manage tokens on the client side for security.
|
|
6
|
-
*
|
|
7
|
-
* For web applications using cookie-based authentication, the tokens
|
|
8
|
-
* are automatically included in requests via browser cookie handling.
|
|
9
|
-
*/
|
|
10
|
-
import { BaseTokenStorage, type TokenPair } from '../core/TokenStorage';
|
|
11
|
-
export declare class WebTokenStorage extends BaseTokenStorage {
|
|
12
|
-
/**
|
|
13
|
-
* For cookie-based auth, tokens are managed by the browser/server
|
|
14
|
-
* This method would typically not store anything client-side
|
|
15
|
-
*/
|
|
16
|
-
storeTokens(tokens: TokenPair): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* For cookie-based auth, we can't directly access HTTP-only cookies
|
|
19
|
-
* This method checks if authentication cookies likely exist
|
|
20
|
-
*/
|
|
21
|
-
retrieveTokens(): Promise<TokenPair | null>;
|
|
22
|
-
/**
|
|
23
|
-
* Clear authentication state
|
|
24
|
-
* In cookie systems, this would typically call a logout endpoint
|
|
25
|
-
*/
|
|
26
|
-
clearTokens(): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Check authentication status
|
|
29
|
-
* In cookie systems, this would check if auth cookies exist
|
|
30
|
-
*/
|
|
31
|
-
hasTokens(): Promise<boolean>;
|
|
32
|
-
/**
|
|
33
|
-
* Check if authentication cookies exist
|
|
34
|
-
* This is a web-specific method for cookie-based auth
|
|
35
|
-
*/
|
|
36
|
-
hasCookies(): boolean;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=WebTokenStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebTokenStorage.d.ts","sourceRoot":"","sources":["../../src/adapters/WebTokenStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAExE,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnD;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAuBjD;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAUlC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAYnC;;;OAGG;IACH,UAAU,IAAI,OAAO;CAOtB"}
|