@spare-technologies/spare-link 0.1.0-beta.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 +66 -0
- package/LICENSE +21 -0
- package/README.md +173 -0
- package/assets/fonts/MetroSans-Bold.otf +0 -0
- package/assets/fonts/MetroSans-Light.otf +0 -0
- package/assets/fonts/MetroSans-Medium.otf +0 -0
- package/assets/fonts/MetroSans-Regular.otf +0 -0
- package/assets/fonts/MetroSans-SemiBold.otf +0 -0
- package/assets/images/altareq_logo_mini.png +0 -0
- package/assets/images/altareq_logo_transparent_bg.png +0 -0
- package/assets/images/altareq_logo_white_bg.png +0 -0
- package/assets/images/spare_logo.png +0 -0
- package/lib/commonjs/core/client/link-api-client.js +297 -0
- package/lib/commonjs/core/client/link-api-client.js.map +1 -0
- package/lib/commonjs/core/errors/payment-api-error.js +35 -0
- package/lib/commonjs/core/errors/payment-api-error.js.map +1 -0
- package/lib/commonjs/core/models/index.js +2 -0
- package/lib/commonjs/core/models/index.js.map +1 -0
- package/lib/commonjs/core/models/link-session-status.js +14 -0
- package/lib/commonjs/core/models/link-session-status.js.map +1 -0
- package/lib/commonjs/core/models/payment-return-params.js +42 -0
- package/lib/commonjs/core/models/payment-return-params.js.map +1 -0
- package/lib/commonjs/core/models/payment-type.js +45 -0
- package/lib/commonjs/core/models/payment-type.js.map +1 -0
- package/lib/commonjs/core/models/wire-mappers.js +277 -0
- package/lib/commonjs/core/models/wire-mappers.js.map +1 -0
- package/lib/commonjs/core/services/consent-presenter.js +150 -0
- package/lib/commonjs/core/services/consent-presenter.js.map +1 -0
- package/lib/commonjs/core/services/execute-resume-if-needed.js +216 -0
- package/lib/commonjs/core/services/execute-resume-if-needed.js.map +1 -0
- package/lib/commonjs/core/services/multi-payment-rules-presenter.js +151 -0
- package/lib/commonjs/core/services/multi-payment-rules-presenter.js.map +1 -0
- package/lib/commonjs/core/services/payment-flow-controller.js +547 -0
- package/lib/commonjs/core/services/payment-flow-controller.js.map +1 -0
- package/lib/commonjs/core/services/payment-flow-state.js +110 -0
- package/lib/commonjs/core/services/payment-flow-state.js.map +1 -0
- package/lib/commonjs/core/services/payment-result-mapper.js +49 -0
- package/lib/commonjs/core/services/payment-result-mapper.js.map +1 -0
- package/lib/commonjs/core/services/pending-session-store.js +6 -0
- package/lib/commonjs/core/services/pending-session-store.js.map +1 -0
- package/lib/commonjs/core/services/presentation-utils.js +11 -0
- package/lib/commonjs/core/services/presentation-utils.js.map +1 -0
- package/lib/commonjs/core/services/redirect-buffer.js +40 -0
- package/lib/commonjs/core/services/redirect-buffer.js.map +1 -0
- package/lib/commonjs/core/services/user-friendly-messages.js +46 -0
- package/lib/commonjs/core/services/user-friendly-messages.js.map +1 -0
- package/lib/commonjs/index.js +294 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/bank-redirect.js +53 -0
- package/lib/commonjs/internal/bank-redirect.js.map +1 -0
- package/lib/commonjs/internal/deep-link-listener.js +39 -0
- package/lib/commonjs/internal/deep-link-listener.js.map +1 -0
- package/lib/commonjs/internal/event-emitter.js +36 -0
- package/lib/commonjs/internal/event-emitter.js.map +1 -0
- package/lib/commonjs/internal/index.js +34 -0
- package/lib/commonjs/internal/index.js.map +1 -0
- package/lib/commonjs/internal/logger.js +67 -0
- package/lib/commonjs/internal/logger.js.map +1 -0
- package/lib/commonjs/internal/redact-uri.js +25 -0
- package/lib/commonjs/internal/redact-uri.js.map +1 -0
- package/lib/commonjs/internal/secure-store-pending-session-store.js +92 -0
- package/lib/commonjs/internal/secure-store-pending-session-store.js.map +1 -0
- package/lib/commonjs/internal/telemetry-collector.js +80 -0
- package/lib/commonjs/internal/telemetry-collector.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/public/constants.js +21 -0
- package/lib/commonjs/public/constants.js.map +1 -0
- package/lib/commonjs/public/index.js +152 -0
- package/lib/commonjs/public/index.js.map +1 -0
- package/lib/commonjs/public/payment-result.js +48 -0
- package/lib/commonjs/public/payment-result.js.map +1 -0
- package/lib/commonjs/public/recovery-result.js +40 -0
- package/lib/commonjs/public/recovery-result.js.map +1 -0
- package/lib/commonjs/public/spare-link-callbacks.js +6 -0
- package/lib/commonjs/public/spare-link-callbacks.js.map +1 -0
- package/lib/commonjs/public/spare-link-config.js +62 -0
- package/lib/commonjs/public/spare-link-config.js.map +1 -0
- package/lib/commonjs/public/spare-link-event.js +120 -0
- package/lib/commonjs/public/spare-link-event.js.map +1 -0
- package/lib/commonjs/public/spare-link-host-api.js +6 -0
- package/lib/commonjs/public/spare-link-host-api.js.map +1 -0
- package/lib/commonjs/public/spare-link-instance.js +285 -0
- package/lib/commonjs/public/spare-link-instance.js.map +1 -0
- package/lib/commonjs/public/spare-link-session.js +26 -0
- package/lib/commonjs/public/spare-link-session.js.map +1 -0
- package/lib/commonjs/public/spare-link.js +31 -0
- package/lib/commonjs/public/spare-link.js.map +1 -0
- package/lib/commonjs/ui/consent/charge-bearer-display.js +99 -0
- package/lib/commonjs/ui/consent/charge-bearer-display.js.map +1 -0
- package/lib/commonjs/ui/consent/consent-accordion.js +94 -0
- package/lib/commonjs/ui/consent/consent-accordion.js.map +1 -0
- package/lib/commonjs/ui/consent/consent-summary-section.js +27 -0
- package/lib/commonjs/ui/consent/consent-summary-section.js.map +1 -0
- package/lib/commonjs/ui/consent/cop-information.js +168 -0
- package/lib/commonjs/ui/consent/cop-information.js.map +1 -0
- package/lib/commonjs/ui/consent/international-payment-summary.js +98 -0
- package/lib/commonjs/ui/consent/international-payment-summary.js.map +1 -0
- package/lib/commonjs/ui/consent/label-value-rows.js +59 -0
- package/lib/commonjs/ui/consent/label-value-rows.js.map +1 -0
- package/lib/commonjs/ui/consent/multi-payment-rules-list.js +130 -0
- package/lib/commonjs/ui/consent/multi-payment-rules-list.js.map +1 -0
- package/lib/commonjs/ui/consent/multi-payment-summary.js +99 -0
- package/lib/commonjs/ui/consent/multi-payment-summary.js.map +1 -0
- package/lib/commonjs/ui/consent/single-payment-summary.js +158 -0
- package/lib/commonjs/ui/consent/single-payment-summary.js.map +1 -0
- package/lib/commonjs/ui/consent/terms-link.js +35 -0
- package/lib/commonjs/ui/consent/terms-link.js.map +1 -0
- package/lib/commonjs/ui/hooks/use-payment-flow-state.js +16 -0
- package/lib/commonjs/ui/hooks/use-payment-flow-state.js.map +1 -0
- package/lib/commonjs/ui/payment-flow-page.js +235 -0
- package/lib/commonjs/ui/payment-flow-page.js.map +1 -0
- package/lib/commonjs/ui/screens/bank-selection-screen.js +215 -0
- package/lib/commonjs/ui/screens/bank-selection-screen.js.map +1 -0
- package/lib/commonjs/ui/screens/consent-details-screen.js +124 -0
- package/lib/commonjs/ui/screens/consent-details-screen.js.map +1 -0
- package/lib/commonjs/ui/screens/index.js +48 -0
- package/lib/commonjs/ui/screens/index.js.map +1 -0
- package/lib/commonjs/ui/screens/mandate-setup-success-screen.js +79 -0
- package/lib/commonjs/ui/screens/mandate-setup-success-screen.js.map +1 -0
- package/lib/commonjs/ui/screens/redirect-handoff-screen.js +42 -0
- package/lib/commonjs/ui/screens/redirect-handoff-screen.js.map +1 -0
- package/lib/commonjs/ui/screens/result-screen.js +83 -0
- package/lib/commonjs/ui/screens/result-screen.js.map +1 -0
- package/lib/commonjs/ui/screens/resume-processing-screen.js +109 -0
- package/lib/commonjs/ui/screens/resume-processing-screen.js.map +1 -0
- package/lib/commonjs/ui/spare-link-host.js +354 -0
- package/lib/commonjs/ui/spare-link-host.js.map +1 -0
- package/lib/commonjs/ui/theme/assets.js +20 -0
- package/lib/commonjs/ui/theme/assets.js.map +1 -0
- package/lib/commonjs/ui/theme/colors.js +36 -0
- package/lib/commonjs/ui/theme/colors.js.map +1 -0
- package/lib/commonjs/ui/theme/fonts.js +29 -0
- package/lib/commonjs/ui/theme/fonts.js.map +1 -0
- package/lib/commonjs/ui/theme/index.js +53 -0
- package/lib/commonjs/ui/theme/index.js.map +1 -0
- package/lib/commonjs/ui/theme/typography.js +76 -0
- package/lib/commonjs/ui/theme/typography.js.map +1 -0
- package/lib/commonjs/ui/widgets/footer.js +144 -0
- package/lib/commonjs/ui/widgets/footer.js.map +1 -0
- package/lib/commonjs/ui/widgets/gradient-spinner.js +172 -0
- package/lib/commonjs/ui/widgets/gradient-spinner.js.map +1 -0
- package/lib/commonjs/ui/widgets/handoff-screen-layout.js +77 -0
- package/lib/commonjs/ui/widgets/handoff-screen-layout.js.map +1 -0
- package/lib/commonjs/ui/widgets/index.js +41 -0
- package/lib/commonjs/ui/widgets/index.js.map +1 -0
- package/lib/commonjs/ui/widgets/layout-w-header.js +106 -0
- package/lib/commonjs/ui/widgets/layout-w-header.js.map +1 -0
- package/lib/commonjs/ui/widgets/modal-dismiss-button.js +47 -0
- package/lib/commonjs/ui/widgets/modal-dismiss-button.js.map +1 -0
- package/lib/commonjs/ui/widgets/stepper.js +124 -0
- package/lib/commonjs/ui/widgets/stepper.js.map +1 -0
- package/lib/commonjs/version.js +14 -0
- package/lib/commonjs/version.js.map +1 -0
- package/lib/module/core/client/link-api-client.js +292 -0
- package/lib/module/core/client/link-api-client.js.map +1 -0
- package/lib/module/core/errors/payment-api-error.js +29 -0
- package/lib/module/core/errors/payment-api-error.js.map +1 -0
- package/lib/module/core/models/index.js +2 -0
- package/lib/module/core/models/index.js.map +1 -0
- package/lib/module/core/models/link-session-status.js +10 -0
- package/lib/module/core/models/link-session-status.js.map +1 -0
- package/lib/module/core/models/payment-return-params.js +37 -0
- package/lib/module/core/models/payment-return-params.js.map +1 -0
- package/lib/module/core/models/payment-type.js +36 -0
- package/lib/module/core/models/payment-type.js.map +1 -0
- package/lib/module/core/models/wire-mappers.js +263 -0
- package/lib/module/core/models/wire-mappers.js.map +1 -0
- package/lib/module/core/services/consent-presenter.js +140 -0
- package/lib/module/core/services/consent-presenter.js.map +1 -0
- package/lib/module/core/services/execute-resume-if-needed.js +211 -0
- package/lib/module/core/services/execute-resume-if-needed.js.map +1 -0
- package/lib/module/core/services/multi-payment-rules-presenter.js +146 -0
- package/lib/module/core/services/multi-payment-rules-presenter.js.map +1 -0
- package/lib/module/core/services/payment-flow-controller.js +544 -0
- package/lib/module/core/services/payment-flow-controller.js.map +1 -0
- package/lib/module/core/services/payment-flow-state.js +106 -0
- package/lib/module/core/services/payment-flow-state.js.map +1 -0
- package/lib/module/core/services/payment-result-mapper.js +45 -0
- package/lib/module/core/services/payment-result-mapper.js.map +1 -0
- package/lib/module/core/services/pending-session-store.js +4 -0
- package/lib/module/core/services/pending-session-store.js.map +1 -0
- package/lib/module/core/services/presentation-utils.js +7 -0
- package/lib/module/core/services/presentation-utils.js.map +1 -0
- package/lib/module/core/services/redirect-buffer.js +33 -0
- package/lib/module/core/services/redirect-buffer.js.map +1 -0
- package/lib/module/core/services/user-friendly-messages.js +42 -0
- package/lib/module/core/services/user-friendly-messages.js.map +1 -0
- package/lib/module/index.js +40 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/bank-redirect.js +49 -0
- package/lib/module/internal/bank-redirect.js.map +1 -0
- package/lib/module/internal/deep-link-listener.js +34 -0
- package/lib/module/internal/deep-link-listener.js.map +1 -0
- package/lib/module/internal/event-emitter.js +32 -0
- package/lib/module/internal/event-emitter.js.map +1 -0
- package/lib/module/internal/index.js +7 -0
- package/lib/module/internal/index.js.map +1 -0
- package/lib/module/internal/logger.js +61 -0
- package/lib/module/internal/logger.js.map +1 -0
- package/lib/module/internal/redact-uri.js +21 -0
- package/lib/module/internal/redact-uri.js.map +1 -0
- package/lib/module/internal/secure-store-pending-session-store.js +88 -0
- package/lib/module/internal/secure-store-pending-session-store.js.map +1 -0
- package/lib/module/internal/telemetry-collector.js +75 -0
- package/lib/module/internal/telemetry-collector.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/public/constants.js +17 -0
- package/lib/module/public/constants.js.map +1 -0
- package/lib/module/public/index.js +11 -0
- package/lib/module/public/index.js.map +1 -0
- package/lib/module/public/payment-result.js +41 -0
- package/lib/module/public/payment-result.js.map +1 -0
- package/lib/module/public/recovery-result.js +34 -0
- package/lib/module/public/recovery-result.js.map +1 -0
- package/lib/module/public/spare-link-callbacks.js +4 -0
- package/lib/module/public/spare-link-callbacks.js.map +1 -0
- package/lib/module/public/spare-link-config.js +54 -0
- package/lib/module/public/spare-link-config.js.map +1 -0
- package/lib/module/public/spare-link-event.js +115 -0
- package/lib/module/public/spare-link-event.js.map +1 -0
- package/lib/module/public/spare-link-host-api.js +4 -0
- package/lib/module/public/spare-link-host-api.js.map +1 -0
- package/lib/module/public/spare-link-instance.js +273 -0
- package/lib/module/public/spare-link-instance.js.map +1 -0
- package/lib/module/public/spare-link-session.js +21 -0
- package/lib/module/public/spare-link-session.js.map +1 -0
- package/lib/module/public/spare-link.js +4 -0
- package/lib/module/public/spare-link.js.map +1 -0
- package/lib/module/ui/consent/charge-bearer-display.js +95 -0
- package/lib/module/ui/consent/charge-bearer-display.js.map +1 -0
- package/lib/module/ui/consent/consent-accordion.js +90 -0
- package/lib/module/ui/consent/consent-accordion.js.map +1 -0
- package/lib/module/ui/consent/consent-summary-section.js +23 -0
- package/lib/module/ui/consent/consent-summary-section.js.map +1 -0
- package/lib/module/ui/consent/cop-information.js +165 -0
- package/lib/module/ui/consent/cop-information.js.map +1 -0
- package/lib/module/ui/consent/international-payment-summary.js +94 -0
- package/lib/module/ui/consent/international-payment-summary.js.map +1 -0
- package/lib/module/ui/consent/label-value-rows.js +55 -0
- package/lib/module/ui/consent/label-value-rows.js.map +1 -0
- package/lib/module/ui/consent/multi-payment-rules-list.js +125 -0
- package/lib/module/ui/consent/multi-payment-rules-list.js.map +1 -0
- package/lib/module/ui/consent/multi-payment-summary.js +95 -0
- package/lib/module/ui/consent/multi-payment-summary.js.map +1 -0
- package/lib/module/ui/consent/single-payment-summary.js +154 -0
- package/lib/module/ui/consent/single-payment-summary.js.map +1 -0
- package/lib/module/ui/consent/terms-link.js +31 -0
- package/lib/module/ui/consent/terms-link.js.map +1 -0
- package/lib/module/ui/hooks/use-payment-flow-state.js +12 -0
- package/lib/module/ui/hooks/use-payment-flow-state.js.map +1 -0
- package/lib/module/ui/payment-flow-page.js +232 -0
- package/lib/module/ui/payment-flow-page.js.map +1 -0
- package/lib/module/ui/screens/bank-selection-screen.js +211 -0
- package/lib/module/ui/screens/bank-selection-screen.js.map +1 -0
- package/lib/module/ui/screens/consent-details-screen.js +120 -0
- package/lib/module/ui/screens/consent-details-screen.js.map +1 -0
- package/lib/module/ui/screens/index.js +9 -0
- package/lib/module/ui/screens/index.js.map +1 -0
- package/lib/module/ui/screens/mandate-setup-success-screen.js +75 -0
- package/lib/module/ui/screens/mandate-setup-success-screen.js.map +1 -0
- package/lib/module/ui/screens/redirect-handoff-screen.js +39 -0
- package/lib/module/ui/screens/redirect-handoff-screen.js.map +1 -0
- package/lib/module/ui/screens/result-screen.js +79 -0
- package/lib/module/ui/screens/result-screen.js.map +1 -0
- package/lib/module/ui/screens/resume-processing-screen.js +105 -0
- package/lib/module/ui/screens/resume-processing-screen.js.map +1 -0
- package/lib/module/ui/spare-link-host.js +350 -0
- package/lib/module/ui/spare-link-host.js.map +1 -0
- package/lib/module/ui/theme/assets.js +16 -0
- package/lib/module/ui/theme/assets.js.map +1 -0
- package/lib/module/ui/theme/colors.js +32 -0
- package/lib/module/ui/theme/colors.js.map +1 -0
- package/lib/module/ui/theme/fonts.js +23 -0
- package/lib/module/ui/theme/fonts.js.map +1 -0
- package/lib/module/ui/theme/index.js +13 -0
- package/lib/module/ui/theme/index.js.map +1 -0
- package/lib/module/ui/theme/typography.js +49 -0
- package/lib/module/ui/theme/typography.js.map +1 -0
- package/lib/module/ui/widgets/footer.js +140 -0
- package/lib/module/ui/widgets/footer.js.map +1 -0
- package/lib/module/ui/widgets/gradient-spinner.js +168 -0
- package/lib/module/ui/widgets/gradient-spinner.js.map +1 -0
- package/lib/module/ui/widgets/handoff-screen-layout.js +73 -0
- package/lib/module/ui/widgets/handoff-screen-layout.js.map +1 -0
- package/lib/module/ui/widgets/index.js +8 -0
- package/lib/module/ui/widgets/index.js.map +1 -0
- package/lib/module/ui/widgets/layout-w-header.js +102 -0
- package/lib/module/ui/widgets/layout-w-header.js.map +1 -0
- package/lib/module/ui/widgets/modal-dismiss-button.js +43 -0
- package/lib/module/ui/widgets/modal-dismiss-button.js.map +1 -0
- package/lib/module/ui/widgets/stepper.js +120 -0
- package/lib/module/ui/widgets/stepper.js.map +1 -0
- package/lib/module/version.js +10 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/commonjs/core/client/link-api-client.d.ts +70 -0
- package/lib/typescript/commonjs/core/client/link-api-client.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/errors/payment-api-error.d.ts +15 -0
- package/lib/typescript/commonjs/core/errors/payment-api-error.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/models/index.d.ts +124 -0
- package/lib/typescript/commonjs/core/models/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/models/link-session-status.d.ts +6 -0
- package/lib/typescript/commonjs/core/models/link-session-status.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/models/payment-return-params.d.ts +15 -0
- package/lib/typescript/commonjs/core/models/payment-return-params.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/models/payment-type.d.ts +18 -0
- package/lib/typescript/commonjs/core/models/payment-type.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/models/wire-mappers.d.ts +19 -0
- package/lib/typescript/commonjs/core/models/wire-mappers.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/consent-presenter.d.ts +67 -0
- package/lib/typescript/commonjs/core/services/consent-presenter.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/execute-resume-if-needed.d.ts +32 -0
- package/lib/typescript/commonjs/core/services/execute-resume-if-needed.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/multi-payment-rules-presenter.d.ts +9 -0
- package/lib/typescript/commonjs/core/services/multi-payment-rules-presenter.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/payment-flow-controller.d.ts +146 -0
- package/lib/typescript/commonjs/core/services/payment-flow-controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/payment-flow-state.d.ts +64 -0
- package/lib/typescript/commonjs/core/services/payment-flow-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/payment-result-mapper.d.ts +5 -0
- package/lib/typescript/commonjs/core/services/payment-result-mapper.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/pending-session-store.d.ts +12 -0
- package/lib/typescript/commonjs/core/services/pending-session-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/presentation-utils.d.ts +5 -0
- package/lib/typescript/commonjs/core/services/presentation-utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/redirect-buffer.d.ts +6 -0
- package/lib/typescript/commonjs/core/services/redirect-buffer.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/services/user-friendly-messages.d.ts +6 -0
- package/lib/typescript/commonjs/core/services/user-friendly-messages.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +19 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/bank-redirect.d.ts +6 -0
- package/lib/typescript/commonjs/internal/bank-redirect.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/deep-link-listener.d.ts +3 -0
- package/lib/typescript/commonjs/internal/deep-link-listener.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/event-emitter.d.ts +13 -0
- package/lib/typescript/commonjs/internal/event-emitter.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/index.d.ts +5 -0
- package/lib/typescript/commonjs/internal/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/logger.d.ts +23 -0
- package/lib/typescript/commonjs/internal/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/redact-uri.d.ts +3 -0
- package/lib/typescript/commonjs/internal/redact-uri.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/secure-store-pending-session-store.d.ts +33 -0
- package/lib/typescript/commonjs/internal/secure-store-pending-session-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/telemetry-collector.d.ts +2 -0
- package/lib/typescript/commonjs/internal/telemetry-collector.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/public/constants.d.ts +12 -0
- package/lib/typescript/commonjs/public/constants.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/index.d.ts +11 -0
- package/lib/typescript/commonjs/public/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/payment-result.d.ts +43 -0
- package/lib/typescript/commonjs/public/payment-result.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/recovery-result.d.ts +36 -0
- package/lib/typescript/commonjs/public/recovery-result.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/spare-link-callbacks.d.ts +14 -0
- package/lib/typescript/commonjs/public/spare-link-callbacks.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/spare-link-config.d.ts +49 -0
- package/lib/typescript/commonjs/public/spare-link-config.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/spare-link-event.d.ts +90 -0
- package/lib/typescript/commonjs/public/spare-link-event.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/spare-link-host-api.d.ts +29 -0
- package/lib/typescript/commonjs/public/spare-link-host-api.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/spare-link-instance.d.ts +89 -0
- package/lib/typescript/commonjs/public/spare-link-instance.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/spare-link-session.d.ts +20 -0
- package/lib/typescript/commonjs/public/spare-link-session.d.ts.map +1 -0
- package/lib/typescript/commonjs/public/spare-link.d.ts +3 -0
- package/lib/typescript/commonjs/public/spare-link.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/charge-bearer-display.d.ts +5 -0
- package/lib/typescript/commonjs/ui/consent/charge-bearer-display.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/consent-accordion.d.ts +10 -0
- package/lib/typescript/commonjs/ui/consent/consent-accordion.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/consent-summary-section.d.ts +6 -0
- package/lib/typescript/commonjs/ui/consent/consent-summary-section.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/cop-information.d.ts +6 -0
- package/lib/typescript/commonjs/ui/consent/cop-information.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/international-payment-summary.d.ts +6 -0
- package/lib/typescript/commonjs/ui/consent/international-payment-summary.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/label-value-rows.d.ts +10 -0
- package/lib/typescript/commonjs/ui/consent/label-value-rows.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/multi-payment-rules-list.d.ts +15 -0
- package/lib/typescript/commonjs/ui/consent/multi-payment-rules-list.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/multi-payment-summary.d.ts +6 -0
- package/lib/typescript/commonjs/ui/consent/multi-payment-summary.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/single-payment-summary.d.ts +6 -0
- package/lib/typescript/commonjs/ui/consent/single-payment-summary.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/consent/terms-link.d.ts +2 -0
- package/lib/typescript/commonjs/ui/consent/terms-link.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/use-payment-flow-state.d.ts +9 -0
- package/lib/typescript/commonjs/ui/hooks/use-payment-flow-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/payment-flow-page.d.ts +20 -0
- package/lib/typescript/commonjs/ui/payment-flow-page.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/bank-selection-screen.d.ts +15 -0
- package/lib/typescript/commonjs/ui/screens/bank-selection-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/consent-details-screen.d.ts +13 -0
- package/lib/typescript/commonjs/ui/screens/consent-details-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/index.d.ts +7 -0
- package/lib/typescript/commonjs/ui/screens/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/mandate-setup-success-screen.d.ts +10 -0
- package/lib/typescript/commonjs/ui/screens/mandate-setup-success-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/redirect-handoff-screen.d.ts +3 -0
- package/lib/typescript/commonjs/ui/screens/redirect-handoff-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/result-screen.d.ts +7 -0
- package/lib/typescript/commonjs/ui/screens/result-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/resume-processing-screen.d.ts +10 -0
- package/lib/typescript/commonjs/ui/screens/resume-processing-screen.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/spare-link-host.d.ts +23 -0
- package/lib/typescript/commonjs/ui/spare-link-host.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/theme/assets.d.ts +15 -0
- package/lib/typescript/commonjs/ui/theme/assets.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/theme/colors.d.ts +31 -0
- package/lib/typescript/commonjs/ui/theme/colors.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/theme/fonts.d.ts +12 -0
- package/lib/typescript/commonjs/ui/theme/fonts.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/theme/index.d.ts +11 -0
- package/lib/typescript/commonjs/ui/theme/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/theme/typography.d.ts +12 -0
- package/lib/typescript/commonjs/ui/theme/typography.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/widgets/footer.d.ts +23 -0
- package/lib/typescript/commonjs/ui/widgets/footer.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/widgets/gradient-spinner.d.ts +13 -0
- package/lib/typescript/commonjs/ui/widgets/gradient-spinner.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/widgets/handoff-screen-layout.d.ts +11 -0
- package/lib/typescript/commonjs/ui/widgets/handoff-screen-layout.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/widgets/index.d.ts +6 -0
- package/lib/typescript/commonjs/ui/widgets/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/widgets/layout-w-header.d.ts +20 -0
- package/lib/typescript/commonjs/ui/widgets/layout-w-header.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/widgets/modal-dismiss-button.d.ts +6 -0
- package/lib/typescript/commonjs/ui/widgets/modal-dismiss-button.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/widgets/stepper.d.ts +15 -0
- package/lib/typescript/commonjs/ui/widgets/stepper.d.ts.map +1 -0
- package/lib/typescript/commonjs/version.d.ts +8 -0
- package/lib/typescript/commonjs/version.d.ts.map +1 -0
- package/lib/typescript/module/core/client/link-api-client.d.ts +70 -0
- package/lib/typescript/module/core/client/link-api-client.d.ts.map +1 -0
- package/lib/typescript/module/core/errors/payment-api-error.d.ts +15 -0
- package/lib/typescript/module/core/errors/payment-api-error.d.ts.map +1 -0
- package/lib/typescript/module/core/models/index.d.ts +124 -0
- package/lib/typescript/module/core/models/index.d.ts.map +1 -0
- package/lib/typescript/module/core/models/link-session-status.d.ts +6 -0
- package/lib/typescript/module/core/models/link-session-status.d.ts.map +1 -0
- package/lib/typescript/module/core/models/payment-return-params.d.ts +15 -0
- package/lib/typescript/module/core/models/payment-return-params.d.ts.map +1 -0
- package/lib/typescript/module/core/models/payment-type.d.ts +18 -0
- package/lib/typescript/module/core/models/payment-type.d.ts.map +1 -0
- package/lib/typescript/module/core/models/wire-mappers.d.ts +19 -0
- package/lib/typescript/module/core/models/wire-mappers.d.ts.map +1 -0
- package/lib/typescript/module/core/services/consent-presenter.d.ts +67 -0
- package/lib/typescript/module/core/services/consent-presenter.d.ts.map +1 -0
- package/lib/typescript/module/core/services/execute-resume-if-needed.d.ts +32 -0
- package/lib/typescript/module/core/services/execute-resume-if-needed.d.ts.map +1 -0
- package/lib/typescript/module/core/services/multi-payment-rules-presenter.d.ts +9 -0
- package/lib/typescript/module/core/services/multi-payment-rules-presenter.d.ts.map +1 -0
- package/lib/typescript/module/core/services/payment-flow-controller.d.ts +146 -0
- package/lib/typescript/module/core/services/payment-flow-controller.d.ts.map +1 -0
- package/lib/typescript/module/core/services/payment-flow-state.d.ts +64 -0
- package/lib/typescript/module/core/services/payment-flow-state.d.ts.map +1 -0
- package/lib/typescript/module/core/services/payment-result-mapper.d.ts +5 -0
- package/lib/typescript/module/core/services/payment-result-mapper.d.ts.map +1 -0
- package/lib/typescript/module/core/services/pending-session-store.d.ts +12 -0
- package/lib/typescript/module/core/services/pending-session-store.d.ts.map +1 -0
- package/lib/typescript/module/core/services/presentation-utils.d.ts +5 -0
- package/lib/typescript/module/core/services/presentation-utils.d.ts.map +1 -0
- package/lib/typescript/module/core/services/redirect-buffer.d.ts +6 -0
- package/lib/typescript/module/core/services/redirect-buffer.d.ts.map +1 -0
- package/lib/typescript/module/core/services/user-friendly-messages.d.ts +6 -0
- package/lib/typescript/module/core/services/user-friendly-messages.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +19 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/internal/bank-redirect.d.ts +6 -0
- package/lib/typescript/module/internal/bank-redirect.d.ts.map +1 -0
- package/lib/typescript/module/internal/deep-link-listener.d.ts +3 -0
- package/lib/typescript/module/internal/deep-link-listener.d.ts.map +1 -0
- package/lib/typescript/module/internal/event-emitter.d.ts +13 -0
- package/lib/typescript/module/internal/event-emitter.d.ts.map +1 -0
- package/lib/typescript/module/internal/index.d.ts +5 -0
- package/lib/typescript/module/internal/index.d.ts.map +1 -0
- package/lib/typescript/module/internal/logger.d.ts +23 -0
- package/lib/typescript/module/internal/logger.d.ts.map +1 -0
- package/lib/typescript/module/internal/redact-uri.d.ts +3 -0
- package/lib/typescript/module/internal/redact-uri.d.ts.map +1 -0
- package/lib/typescript/module/internal/secure-store-pending-session-store.d.ts +33 -0
- package/lib/typescript/module/internal/secure-store-pending-session-store.d.ts.map +1 -0
- package/lib/typescript/module/internal/telemetry-collector.d.ts +2 -0
- package/lib/typescript/module/internal/telemetry-collector.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/public/constants.d.ts +12 -0
- package/lib/typescript/module/public/constants.d.ts.map +1 -0
- package/lib/typescript/module/public/index.d.ts +11 -0
- package/lib/typescript/module/public/index.d.ts.map +1 -0
- package/lib/typescript/module/public/payment-result.d.ts +43 -0
- package/lib/typescript/module/public/payment-result.d.ts.map +1 -0
- package/lib/typescript/module/public/recovery-result.d.ts +36 -0
- package/lib/typescript/module/public/recovery-result.d.ts.map +1 -0
- package/lib/typescript/module/public/spare-link-callbacks.d.ts +14 -0
- package/lib/typescript/module/public/spare-link-callbacks.d.ts.map +1 -0
- package/lib/typescript/module/public/spare-link-config.d.ts +49 -0
- package/lib/typescript/module/public/spare-link-config.d.ts.map +1 -0
- package/lib/typescript/module/public/spare-link-event.d.ts +90 -0
- package/lib/typescript/module/public/spare-link-event.d.ts.map +1 -0
- package/lib/typescript/module/public/spare-link-host-api.d.ts +29 -0
- package/lib/typescript/module/public/spare-link-host-api.d.ts.map +1 -0
- package/lib/typescript/module/public/spare-link-instance.d.ts +89 -0
- package/lib/typescript/module/public/spare-link-instance.d.ts.map +1 -0
- package/lib/typescript/module/public/spare-link-session.d.ts +20 -0
- package/lib/typescript/module/public/spare-link-session.d.ts.map +1 -0
- package/lib/typescript/module/public/spare-link.d.ts +3 -0
- package/lib/typescript/module/public/spare-link.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/charge-bearer-display.d.ts +5 -0
- package/lib/typescript/module/ui/consent/charge-bearer-display.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/consent-accordion.d.ts +10 -0
- package/lib/typescript/module/ui/consent/consent-accordion.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/consent-summary-section.d.ts +6 -0
- package/lib/typescript/module/ui/consent/consent-summary-section.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/cop-information.d.ts +6 -0
- package/lib/typescript/module/ui/consent/cop-information.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/international-payment-summary.d.ts +6 -0
- package/lib/typescript/module/ui/consent/international-payment-summary.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/label-value-rows.d.ts +10 -0
- package/lib/typescript/module/ui/consent/label-value-rows.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/multi-payment-rules-list.d.ts +15 -0
- package/lib/typescript/module/ui/consent/multi-payment-rules-list.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/multi-payment-summary.d.ts +6 -0
- package/lib/typescript/module/ui/consent/multi-payment-summary.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/single-payment-summary.d.ts +6 -0
- package/lib/typescript/module/ui/consent/single-payment-summary.d.ts.map +1 -0
- package/lib/typescript/module/ui/consent/terms-link.d.ts +2 -0
- package/lib/typescript/module/ui/consent/terms-link.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/use-payment-flow-state.d.ts +9 -0
- package/lib/typescript/module/ui/hooks/use-payment-flow-state.d.ts.map +1 -0
- package/lib/typescript/module/ui/payment-flow-page.d.ts +20 -0
- package/lib/typescript/module/ui/payment-flow-page.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/bank-selection-screen.d.ts +15 -0
- package/lib/typescript/module/ui/screens/bank-selection-screen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/consent-details-screen.d.ts +13 -0
- package/lib/typescript/module/ui/screens/consent-details-screen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/index.d.ts +7 -0
- package/lib/typescript/module/ui/screens/index.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/mandate-setup-success-screen.d.ts +10 -0
- package/lib/typescript/module/ui/screens/mandate-setup-success-screen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/redirect-handoff-screen.d.ts +3 -0
- package/lib/typescript/module/ui/screens/redirect-handoff-screen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/result-screen.d.ts +7 -0
- package/lib/typescript/module/ui/screens/result-screen.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/resume-processing-screen.d.ts +10 -0
- package/lib/typescript/module/ui/screens/resume-processing-screen.d.ts.map +1 -0
- package/lib/typescript/module/ui/spare-link-host.d.ts +23 -0
- package/lib/typescript/module/ui/spare-link-host.d.ts.map +1 -0
- package/lib/typescript/module/ui/theme/assets.d.ts +15 -0
- package/lib/typescript/module/ui/theme/assets.d.ts.map +1 -0
- package/lib/typescript/module/ui/theme/colors.d.ts +31 -0
- package/lib/typescript/module/ui/theme/colors.d.ts.map +1 -0
- package/lib/typescript/module/ui/theme/fonts.d.ts +12 -0
- package/lib/typescript/module/ui/theme/fonts.d.ts.map +1 -0
- package/lib/typescript/module/ui/theme/index.d.ts +11 -0
- package/lib/typescript/module/ui/theme/index.d.ts.map +1 -0
- package/lib/typescript/module/ui/theme/typography.d.ts +12 -0
- package/lib/typescript/module/ui/theme/typography.d.ts.map +1 -0
- package/lib/typescript/module/ui/widgets/footer.d.ts +23 -0
- package/lib/typescript/module/ui/widgets/footer.d.ts.map +1 -0
- package/lib/typescript/module/ui/widgets/gradient-spinner.d.ts +13 -0
- package/lib/typescript/module/ui/widgets/gradient-spinner.d.ts.map +1 -0
- package/lib/typescript/module/ui/widgets/handoff-screen-layout.d.ts +11 -0
- package/lib/typescript/module/ui/widgets/handoff-screen-layout.d.ts.map +1 -0
- package/lib/typescript/module/ui/widgets/index.d.ts +6 -0
- package/lib/typescript/module/ui/widgets/index.d.ts.map +1 -0
- package/lib/typescript/module/ui/widgets/layout-w-header.d.ts +20 -0
- package/lib/typescript/module/ui/widgets/layout-w-header.d.ts.map +1 -0
- package/lib/typescript/module/ui/widgets/modal-dismiss-button.d.ts +6 -0
- package/lib/typescript/module/ui/widgets/modal-dismiss-button.d.ts.map +1 -0
- package/lib/typescript/module/ui/widgets/stepper.d.ts +15 -0
- package/lib/typescript/module/ui/widgets/stepper.d.ts.map +1 -0
- package/lib/typescript/module/version.d.ts +8 -0
- package/lib/typescript/module/version.d.ts.map +1 -0
- package/package.json +124 -0
- package/plugins/with-spare-link.js +98 -0
- package/src/core/client/link-api-client.ts +414 -0
- package/src/core/errors/payment-api-error.ts +35 -0
- package/src/core/models/index.ts +139 -0
- package/src/core/models/link-session-status.ts +7 -0
- package/src/core/models/payment-return-params.ts +34 -0
- package/src/core/models/payment-type.ts +54 -0
- package/src/core/models/wire-mappers.ts +315 -0
- package/src/core/services/consent-presenter.ts +213 -0
- package/src/core/services/execute-resume-if-needed.ts +243 -0
- package/src/core/services/multi-payment-rules-presenter.ts +158 -0
- package/src/core/services/payment-flow-controller.ts +607 -0
- package/src/core/services/payment-flow-state.ts +124 -0
- package/src/core/services/payment-result-mapper.ts +41 -0
- package/src/core/services/pending-session-store.ts +12 -0
- package/src/core/services/presentation-utils.ts +4 -0
- package/src/core/services/redirect-buffer.ts +34 -0
- package/src/core/services/user-friendly-messages.ts +39 -0
- package/src/index.ts +115 -0
- package/src/internal/bank-redirect.ts +61 -0
- package/src/internal/deep-link-listener.ts +31 -0
- package/src/internal/event-emitter.ts +42 -0
- package/src/internal/index.ts +4 -0
- package/src/internal/logger.ts +81 -0
- package/src/internal/redact-uri.ts +18 -0
- package/src/internal/secure-store-pending-session-store.ts +131 -0
- package/src/internal/telemetry-collector.ts +90 -0
- package/src/public/constants.ts +14 -0
- package/src/public/index.ts +80 -0
- package/src/public/payment-result.ts +61 -0
- package/src/public/recovery-result.ts +49 -0
- package/src/public/spare-link-callbacks.ts +20 -0
- package/src/public/spare-link-config.ts +87 -0
- package/src/public/spare-link-event.ts +146 -0
- package/src/public/spare-link-host-api.ts +28 -0
- package/src/public/spare-link-instance.ts +289 -0
- package/src/public/spare-link-session.ts +28 -0
- package/src/public/spare-link.ts +2 -0
- package/src/ui/consent/charge-bearer-display.tsx +68 -0
- package/src/ui/consent/consent-accordion.tsx +89 -0
- package/src/ui/consent/consent-summary-section.tsx +19 -0
- package/src/ui/consent/cop-information.tsx +121 -0
- package/src/ui/consent/international-payment-summary.tsx +83 -0
- package/src/ui/consent/label-value-rows.tsx +50 -0
- package/src/ui/consent/multi-payment-rules-list.tsx +138 -0
- package/src/ui/consent/multi-payment-summary.tsx +82 -0
- package/src/ui/consent/single-payment-summary.tsx +123 -0
- package/src/ui/consent/terms-link.tsx +27 -0
- package/src/ui/hooks/use-payment-flow-state.ts +16 -0
- package/src/ui/payment-flow-page.tsx +254 -0
- package/src/ui/screens/bank-selection-screen.tsx +209 -0
- package/src/ui/screens/consent-details-screen.tsx +106 -0
- package/src/ui/screens/index.ts +12 -0
- package/src/ui/screens/mandate-setup-success-screen.tsx +72 -0
- package/src/ui/screens/redirect-handoff-screen.tsx +33 -0
- package/src/ui/screens/result-screen.tsx +71 -0
- package/src/ui/screens/resume-processing-screen.tsx +111 -0
- package/src/ui/spare-link-host.tsx +394 -0
- package/src/ui/theme/assets.ts +17 -0
- package/src/ui/theme/colors.ts +32 -0
- package/src/ui/theme/fonts.ts +25 -0
- package/src/ui/theme/index.ts +11 -0
- package/src/ui/theme/typography.ts +47 -0
- package/src/ui/widgets/footer.tsx +138 -0
- package/src/ui/widgets/gradient-spinner.tsx +156 -0
- package/src/ui/widgets/handoff-screen-layout.tsx +70 -0
- package/src/ui/widgets/index.ts +5 -0
- package/src/ui/widgets/layout-w-header.tsx +89 -0
- package/src/ui/widgets/modal-dismiss-button.tsx +44 -0
- package/src/ui/widgets/stepper.tsx +126 -0
- package/src/version.ts +7 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production `PendingSessionStore` backed by expo-secure-store. Persists a
|
|
3
|
+
* single in-flight payment session so the SDK can recover after cold start.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { PendingSessionRecord } from '../core/models';
|
|
7
|
+
import type { PendingSessionStore } from '../core/services/pending-session-store';
|
|
8
|
+
import { createLogger } from './logger';
|
|
9
|
+
|
|
10
|
+
const log = createLogger('SecureStorePendingSessionStore');
|
|
11
|
+
|
|
12
|
+
const KEYS = {
|
|
13
|
+
sessionId: 'spare_link_session_id',
|
|
14
|
+
bankId: 'spare_link_bank_id',
|
|
15
|
+
authUrl: 'spare_link_auth_url',
|
|
16
|
+
consentAt: 'spare_link_consent_at',
|
|
17
|
+
recoveryAttempts: 'spare_link_recovery_attempts',
|
|
18
|
+
merchantRef: 'spare_link_merchant_ref',
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
export interface SecureStoreModule {
|
|
22
|
+
getItemAsync(key: string): Promise<string | null>;
|
|
23
|
+
setItemAsync(key: string, value: string): Promise<void>;
|
|
24
|
+
deleteItemAsync(key: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function defaultLoader(): Promise<SecureStoreModule> {
|
|
28
|
+
try {
|
|
29
|
+
return (await import('expo-secure-store')) as unknown as SecureStoreModule;
|
|
30
|
+
} catch (err) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`SecureStorePendingSessionStore requires 'expo-secure-store' — install it in your app. (${
|
|
33
|
+
err instanceof Error ? err.message : String(err)
|
|
34
|
+
})`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class SecureStorePendingSessionStore implements PendingSessionStore {
|
|
40
|
+
private secureStore: Promise<SecureStoreModule> | null = null;
|
|
41
|
+
private readonly loader: () => Promise<SecureStoreModule>;
|
|
42
|
+
/**
|
|
43
|
+
* Promise chain serializing every write/clear so a `clear()` racing a
|
|
44
|
+
* partial `save()` can't leave the store in a half-written state.
|
|
45
|
+
*/
|
|
46
|
+
private writeQueue: Promise<void> = Promise.resolve();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param moduleLoader Optional override returning the secure-store module.
|
|
50
|
+
* Defaults to dynamically importing `expo-secure-store`.
|
|
51
|
+
* Tests inject an in-memory fake.
|
|
52
|
+
*/
|
|
53
|
+
constructor(moduleLoader: () => Promise<SecureStoreModule> = defaultLoader) {
|
|
54
|
+
this.loader = moduleLoader;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private get module(): Promise<SecureStoreModule> {
|
|
58
|
+
if (!this.secureStore) this.secureStore = this.loader();
|
|
59
|
+
return this.secureStore;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Serializes write operations so save+clear can't interleave. */
|
|
63
|
+
private enqueueWrite(op: () => Promise<void>): Promise<void> {
|
|
64
|
+
const next = this.writeQueue.then(op, op);
|
|
65
|
+
this.writeQueue = next.catch(() => {
|
|
66
|
+
// Swallow so one failure doesn't poison the queue.
|
|
67
|
+
});
|
|
68
|
+
return next;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
save(record: PendingSessionRecord): Promise<void> {
|
|
72
|
+
return this.enqueueWrite(async () => {
|
|
73
|
+
const s = await this.module;
|
|
74
|
+
await Promise.all([
|
|
75
|
+
s.setItemAsync(KEYS.sessionId, record.sessionId),
|
|
76
|
+
s.setItemAsync(KEYS.bankId, record.selectedBankId),
|
|
77
|
+
s.setItemAsync(KEYS.authUrl, record.authorizationUrl),
|
|
78
|
+
record.consentAt !== undefined
|
|
79
|
+
? s.setItemAsync(KEYS.consentAt, String(record.consentAt))
|
|
80
|
+
: s.deleteItemAsync(KEYS.consentAt),
|
|
81
|
+
s.setItemAsync(KEYS.recoveryAttempts, String(record.recoveryAttempts)),
|
|
82
|
+
record.merchantRef
|
|
83
|
+
? s.setItemAsync(KEYS.merchantRef, record.merchantRef)
|
|
84
|
+
: s.deleteItemAsync(KEYS.merchantRef),
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async load(): Promise<PendingSessionRecord | null> {
|
|
90
|
+
// Wait for any pending writes to settle so we read a consistent snapshot.
|
|
91
|
+
await this.writeQueue.catch(() => undefined);
|
|
92
|
+
const s = await this.module;
|
|
93
|
+
const [sessionId, bankId, authUrl, consentAtRaw, attemptsRaw, merchantRef] = await Promise.all([
|
|
94
|
+
s.getItemAsync(KEYS.sessionId),
|
|
95
|
+
s.getItemAsync(KEYS.bankId),
|
|
96
|
+
s.getItemAsync(KEYS.authUrl),
|
|
97
|
+
s.getItemAsync(KEYS.consentAt),
|
|
98
|
+
s.getItemAsync(KEYS.recoveryAttempts),
|
|
99
|
+
s.getItemAsync(KEYS.merchantRef),
|
|
100
|
+
]);
|
|
101
|
+
if (!sessionId || !bankId || !authUrl) {
|
|
102
|
+
log.fine('load: no pending session found');
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const consentAt = consentAtRaw ? Number(consentAtRaw) : undefined;
|
|
106
|
+
const recoveryAttempts = attemptsRaw ? Number(attemptsRaw) : 0;
|
|
107
|
+
const record: PendingSessionRecord = {
|
|
108
|
+
sessionId,
|
|
109
|
+
selectedBankId: bankId,
|
|
110
|
+
authorizationUrl: authUrl,
|
|
111
|
+
recoveryAttempts: Number.isFinite(recoveryAttempts) ? recoveryAttempts : 0,
|
|
112
|
+
};
|
|
113
|
+
if (consentAt !== undefined && Number.isFinite(consentAt)) record.consentAt = consentAt;
|
|
114
|
+
if (merchantRef) record.merchantRef = merchantRef;
|
|
115
|
+
return record;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
clear(): Promise<void> {
|
|
119
|
+
return this.enqueueWrite(async () => {
|
|
120
|
+
const s = await this.module;
|
|
121
|
+
await Promise.all([
|
|
122
|
+
s.deleteItemAsync(KEYS.sessionId),
|
|
123
|
+
s.deleteItemAsync(KEYS.bankId),
|
|
124
|
+
s.deleteItemAsync(KEYS.authUrl),
|
|
125
|
+
s.deleteItemAsync(KEYS.consentAt),
|
|
126
|
+
s.deleteItemAsync(KEYS.recoveryAttempts),
|
|
127
|
+
s.deleteItemAsync(KEYS.merchantRef),
|
|
128
|
+
]);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort device + geolocation telemetry collector. Each call site catches
|
|
3
|
+
* runtime failures so a permission denial or missing native module degrades
|
|
4
|
+
* to a partial payload instead of throwing.
|
|
5
|
+
*/
|
|
6
|
+
import { Platform } from 'react-native';
|
|
7
|
+
import { SDK_VERSION } from '../version';
|
|
8
|
+
import { createLogger } from './logger';
|
|
9
|
+
|
|
10
|
+
const log = createLogger('TelemetryCollector');
|
|
11
|
+
|
|
12
|
+
const LOCATION_TIMEOUT_MS = 5_000;
|
|
13
|
+
|
|
14
|
+
interface DeviceLike {
|
|
15
|
+
modelName?: string | null;
|
|
16
|
+
osVersion?: string | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface LocationLike {
|
|
20
|
+
requestForegroundPermissionsAsync(): Promise<{ status: 'granted' | 'denied' | 'undetermined' }>;
|
|
21
|
+
getCurrentPositionAsync(opts: { accuracy?: number }): Promise<{
|
|
22
|
+
coords: { latitude: number; longitude: number; accuracy: number | null };
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function loadDevice(): Promise<DeviceLike | null> {
|
|
27
|
+
try {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
29
|
+
return require('expo-device') as DeviceLike;
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function loadLocation(): Promise<LocationLike | null> {
|
|
36
|
+
try {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
38
|
+
return require('expo-location') as LocationLike;
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function collectTelemetry(): Promise<Record<string, unknown>> {
|
|
45
|
+
log.fine('collect: gathering device telemetry');
|
|
46
|
+
const [deviceMod, locationMod] = await Promise.all([loadDevice(), loadLocation()]);
|
|
47
|
+
|
|
48
|
+
const payload: Record<string, unknown> = {
|
|
49
|
+
platform: 'react_native',
|
|
50
|
+
sdk_version: SDK_VERSION,
|
|
51
|
+
os: Platform.OS,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const model = deviceMod?.modelName ?? null;
|
|
55
|
+
const osVersion = deviceMod?.osVersion ?? null;
|
|
56
|
+
if (model && osVersion) {
|
|
57
|
+
payload.device_fingerprint = `${model}_${osVersion}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (locationMod) {
|
|
61
|
+
try {
|
|
62
|
+
const permission = await locationMod.requestForegroundPermissionsAsync();
|
|
63
|
+
if (permission.status === 'granted') {
|
|
64
|
+
const position = await Promise.race<{
|
|
65
|
+
coords: { latitude: number; longitude: number; accuracy: number | null };
|
|
66
|
+
} | null>([
|
|
67
|
+
locationMod.getCurrentPositionAsync({ accuracy: 3 }),
|
|
68
|
+
new Promise((resolve) => setTimeout(() => resolve(null), LOCATION_TIMEOUT_MS)),
|
|
69
|
+
]);
|
|
70
|
+
if (position) {
|
|
71
|
+
payload.geolocation = {
|
|
72
|
+
latitude: position.coords.latitude,
|
|
73
|
+
longitude: position.coords.longitude,
|
|
74
|
+
accuracy_m: position.coords.accuracy,
|
|
75
|
+
};
|
|
76
|
+
} else {
|
|
77
|
+
payload.geolocation = { unavailable: 'timeout' };
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
payload.geolocation = { unavailable: 'permission_denied' };
|
|
81
|
+
}
|
|
82
|
+
} catch (e) {
|
|
83
|
+
log.warning(`collect: geolocation failed — ${e instanceof Error ? e.message : String(e)}`);
|
|
84
|
+
payload.geolocation = { unavailable: 'error' };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
log.fine(`collect: payload keys=${Object.keys(payload).join(',')}`);
|
|
89
|
+
return payload;
|
|
90
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Max non-terminal `resumeIfNeeded` recovery attempts before the SDK gives up
|
|
3
|
+
* and resolves the flow as failed with code `recovery_exhausted`.
|
|
4
|
+
*/
|
|
5
|
+
export const kMaxRecoveryAttempts = 3 as const;
|
|
6
|
+
|
|
7
|
+
/** Default per-request HTTP timeout in milliseconds (15s). */
|
|
8
|
+
export const DEFAULT_REQUEST_TIMEOUT_MS = 15_000 as const;
|
|
9
|
+
|
|
10
|
+
/** How long the SDK waits for a bank callback before auto-failing with `session_timeout`. */
|
|
11
|
+
export const DEFAULT_AWAITING_CALLBACK_TIMEOUT_MS = 5 * 60 * 1000;
|
|
12
|
+
|
|
13
|
+
/** Polling interval while the flow is in awaitingCallback (status endpoint). */
|
|
14
|
+
export const DEFAULT_AWAITING_CALLBACK_POLL_MS = 10_000;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export {
|
|
2
|
+
type PaymentEnvironment,
|
|
3
|
+
type SpareApiTenant,
|
|
4
|
+
type SpareLinkConfig,
|
|
5
|
+
type SpareLinkResumeConfig,
|
|
6
|
+
defaultBaseUrlFor,
|
|
7
|
+
tenantCountryCode,
|
|
8
|
+
resolvedBaseUrl,
|
|
9
|
+
resolvedResumeBaseUrl,
|
|
10
|
+
assertValidConfig,
|
|
11
|
+
} from './spare-link-config';
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
type SpareLinkEvent,
|
|
15
|
+
type SpareLinkEventType,
|
|
16
|
+
type SpareLinkInitialized,
|
|
17
|
+
type SpareLinkSessionLoaded,
|
|
18
|
+
type SpareLinkConsentStarted,
|
|
19
|
+
type SpareLinkRedirectToBank,
|
|
20
|
+
type SpareLinkBankCallbackReceived,
|
|
21
|
+
type SpareLinkSucceeded,
|
|
22
|
+
type SpareLinkFailed,
|
|
23
|
+
type SpareLinkCancelled,
|
|
24
|
+
type SpareLinkAbandoned,
|
|
25
|
+
SPARE_LINK_EVENT_TYPES,
|
|
26
|
+
isSpareLinkEvent,
|
|
27
|
+
SpareLinkEvents,
|
|
28
|
+
} from './spare-link-event';
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
type PaymentStatus,
|
|
32
|
+
type PaymentResult,
|
|
33
|
+
type PaymentSuccess,
|
|
34
|
+
type PaymentCancelled,
|
|
35
|
+
type PaymentFailed,
|
|
36
|
+
type PaymentAbandoned,
|
|
37
|
+
paymentSuccess,
|
|
38
|
+
paymentCancelled,
|
|
39
|
+
paymentFailed,
|
|
40
|
+
paymentAbandoned,
|
|
41
|
+
} from './payment-result';
|
|
42
|
+
|
|
43
|
+
export type {
|
|
44
|
+
SpareLinkCallbacks,
|
|
45
|
+
SpareLinkSuccessCallback,
|
|
46
|
+
SpareLinkExitCallback,
|
|
47
|
+
SpareLinkEventCallback,
|
|
48
|
+
} from './spare-link-callbacks';
|
|
49
|
+
|
|
50
|
+
export type {
|
|
51
|
+
RecoveryResult,
|
|
52
|
+
NoRecoveryReason,
|
|
53
|
+
NoRecoveryNeeded,
|
|
54
|
+
SessionRecovered,
|
|
55
|
+
RecoveryAwaitingUser,
|
|
56
|
+
} from './recovery-result';
|
|
57
|
+
export {
|
|
58
|
+
isSessionRecovered,
|
|
59
|
+
isNoRecoveryNeeded,
|
|
60
|
+
isRecoveryAwaitingUser,
|
|
61
|
+
} from './recovery-result';
|
|
62
|
+
|
|
63
|
+
export { SpareLinkSession } from './spare-link-session';
|
|
64
|
+
export { SpareLink, type SpareLinkOptions } from './spare-link-instance';
|
|
65
|
+
|
|
66
|
+
export {
|
|
67
|
+
kMaxRecoveryAttempts,
|
|
68
|
+
DEFAULT_REQUEST_TIMEOUT_MS,
|
|
69
|
+
DEFAULT_AWAITING_CALLBACK_TIMEOUT_MS,
|
|
70
|
+
DEFAULT_AWAITING_CALLBACK_POLL_MS,
|
|
71
|
+
} from './constants';
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
configureSpareLinkLogging,
|
|
75
|
+
createLogger,
|
|
76
|
+
type SpareLinkLogLevel,
|
|
77
|
+
type SpareLinkLogRecord,
|
|
78
|
+
type SpareLinkLogSink,
|
|
79
|
+
type SpareLinkLogger,
|
|
80
|
+
} from '../internal/logger';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal outcome of a payment flow — narrow on the `status` field.
|
|
3
|
+
*/
|
|
4
|
+
export type PaymentStatus = 'success' | 'cancelled' | 'failed' | 'abandoned';
|
|
5
|
+
|
|
6
|
+
interface PaymentResultBase {
|
|
7
|
+
status: PaymentStatus;
|
|
8
|
+
/** The `link_token` JWS that identifies this payment flow. Mirrors Flutter's `linkToken`. */
|
|
9
|
+
linkToken: string;
|
|
10
|
+
bankId?: string;
|
|
11
|
+
linkSessionId?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
errorCode?: string;
|
|
14
|
+
resolvedAtMs?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Payment completed at the bank. `exchangeCode` may be null when recovered
|
|
18
|
+
* via status polling (the bank delivered the code straight to the merchant
|
|
19
|
+
* backend, bypassing the SDK). */
|
|
20
|
+
export interface PaymentSuccess extends PaymentResultBase {
|
|
21
|
+
status: 'success';
|
|
22
|
+
exchangeCode?: string;
|
|
23
|
+
merchantRef?: string;
|
|
24
|
+
/** API payment type string (e.g. `FixedPeriodicSchedule`), when available. Mirrors Flutter's `paymentType`. */
|
|
25
|
+
paymentType?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PaymentCancelled extends PaymentResultBase {
|
|
29
|
+
status: 'cancelled';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Payment failed. Always has an `errorCode` so merchants can map to UI copy. */
|
|
33
|
+
export interface PaymentFailed extends PaymentResultBase {
|
|
34
|
+
status: 'failed';
|
|
35
|
+
errorCode: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Flow abandoned mid-flight (app killed, host removed the SDK navigator). */
|
|
39
|
+
export interface PaymentAbandoned extends PaymentResultBase {
|
|
40
|
+
status: 'abandoned';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type PaymentResult = PaymentSuccess | PaymentCancelled | PaymentFailed | PaymentAbandoned;
|
|
44
|
+
|
|
45
|
+
// ---- Constructor helpers ---------------------------------------------------
|
|
46
|
+
|
|
47
|
+
export function paymentSuccess(args: Omit<PaymentSuccess, 'status'>): PaymentSuccess {
|
|
48
|
+
return { status: 'success', ...args };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function paymentCancelled(args: Omit<PaymentCancelled, 'status'>): PaymentCancelled {
|
|
52
|
+
return { status: 'cancelled', ...args };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function paymentFailed(args: Omit<PaymentFailed, 'status'>): PaymentFailed {
|
|
56
|
+
return { status: 'failed', ...args };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function paymentAbandoned(args: Omit<PaymentAbandoned, 'status'>): PaymentAbandoned {
|
|
60
|
+
return { status: 'abandoned', ...args };
|
|
61
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PaymentResult } from './payment-result';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Why {@link SpareLink.resumeIfNeeded} did not recover a terminal session.
|
|
5
|
+
* Mirrors Flutter's `NoRecoveryReason`.
|
|
6
|
+
*/
|
|
7
|
+
export type NoRecoveryReason = 'noPendingSession' | 'flowAlreadyActive' | 'persistenceUnavailable';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Outcome of {@link SpareLink.resumeIfNeeded}.
|
|
11
|
+
*
|
|
12
|
+
* Discriminated union aligned with Flutter's sealed `RecoveryResult`.
|
|
13
|
+
*/
|
|
14
|
+
export type RecoveryResult = NoRecoveryNeeded | SessionRecovered | RecoveryAwaitingUser;
|
|
15
|
+
|
|
16
|
+
/** No pending session was recovered. */
|
|
17
|
+
export interface NoRecoveryNeeded {
|
|
18
|
+
readonly kind: 'none';
|
|
19
|
+
readonly reason: NoRecoveryReason;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A pending session was recovered to a terminal {@link PaymentResult}. */
|
|
23
|
+
export interface SessionRecovered {
|
|
24
|
+
readonly kind: 'recovered';
|
|
25
|
+
readonly result: PaymentResult;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A pending session is non-terminal and the SDK opened its recovery UI —
|
|
30
|
+
* the integrator should treat this as in-progress, not "nothing happened".
|
|
31
|
+
* The terminal outcome arrives later via `SpareLink.events` /
|
|
32
|
+
* `spareLink.emitTerminal`, not as a second `resumeIfNeeded` resolution.
|
|
33
|
+
*/
|
|
34
|
+
export interface RecoveryAwaitingUser {
|
|
35
|
+
readonly kind: 'awaitingUser';
|
|
36
|
+
readonly linkToken: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function isSessionRecovered(r: RecoveryResult): r is SessionRecovered {
|
|
40
|
+
return r.kind === 'recovered';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function isNoRecoveryNeeded(r: RecoveryResult): r is NoRecoveryNeeded {
|
|
44
|
+
return r.kind === 'none';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function isRecoveryAwaitingUser(r: RecoveryResult): r is RecoveryAwaitingUser {
|
|
48
|
+
return r.kind === 'awaitingUser';
|
|
49
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PaymentResult } from './payment-result';
|
|
2
|
+
import type { SpareLinkEventType } from './spare-link-event';
|
|
3
|
+
|
|
4
|
+
/** Called on successful payment. Both args may be null when recovered. */
|
|
5
|
+
export type SpareLinkSuccessCallback = (
|
|
6
|
+
exchangeCode: string | undefined,
|
|
7
|
+
linkSessionId: string | undefined,
|
|
8
|
+
) => void;
|
|
9
|
+
|
|
10
|
+
/** Called when the flow resolves to any terminal state (success or failure). */
|
|
11
|
+
export type SpareLinkExitCallback = (result: PaymentResult) => void;
|
|
12
|
+
|
|
13
|
+
/** Called for intermediate lifecycle events (string tag). Best-effort — exceptions are caught. */
|
|
14
|
+
export type SpareLinkEventCallback = (event: SpareLinkEventType) => void;
|
|
15
|
+
|
|
16
|
+
export interface SpareLinkCallbacks {
|
|
17
|
+
onSuccess?: SpareLinkSuccessCallback;
|
|
18
|
+
onExit?: SpareLinkExitCallback;
|
|
19
|
+
onEvent?: SpareLinkEventCallback;
|
|
20
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deployment environment for the Spare Link API.
|
|
3
|
+
*
|
|
4
|
+
* Each value maps to a default base URL
|
|
5
|
+
* the SDK will hit unless `baseUrl` is overridden in {@link SpareLinkConfig}.
|
|
6
|
+
*/
|
|
7
|
+
export type PaymentEnvironment = 'sandbox' | 'production';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_BASE_URLS: Record<PaymentEnvironment, string> = {
|
|
10
|
+
sandbox: 'https://api.sandbox.tryspare.ae',
|
|
11
|
+
production: 'https://api.tryspare.ae',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function defaultBaseUrlFor(env: PaymentEnvironment): string {
|
|
15
|
+
return DEFAULT_BASE_URLS[env];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Spare API tenant — one country per tenant. */
|
|
19
|
+
export type SpareApiTenant = 'ksa' | 'uae' | 'bah';
|
|
20
|
+
|
|
21
|
+
const TENANT_COUNTRY_CODES: Record<SpareApiTenant, string> = {
|
|
22
|
+
ksa: 'KSA',
|
|
23
|
+
uae: 'UAE',
|
|
24
|
+
bah: 'BAH',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function tenantCountryCode(t: SpareApiTenant): string {
|
|
28
|
+
return TENANT_COUNTRY_CODES[t];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Configuration to start a Spare Link payment flow. */
|
|
32
|
+
export interface SpareLinkConfig {
|
|
33
|
+
/** One-time link token minted by the merchant backend via POST /link/token/payment. */
|
|
34
|
+
linkToken: string;
|
|
35
|
+
|
|
36
|
+
/** Target environment (sandbox vs production). */
|
|
37
|
+
environment: PaymentEnvironment;
|
|
38
|
+
|
|
39
|
+
/** Tenant (country). */
|
|
40
|
+
tenant: SpareApiTenant;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Override the base URL. Set only for local dev (e.g. `http://localhost:4000`)
|
|
44
|
+
* — production should rely on the environment-derived default.
|
|
45
|
+
*/
|
|
46
|
+
baseUrl?: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Inject a custom fetch implementation for advanced cases (cert pinning,
|
|
50
|
+
* request logging). Defaults to `globalThis.fetch`.
|
|
51
|
+
*/
|
|
52
|
+
fetch?: typeof fetch;
|
|
53
|
+
|
|
54
|
+
/** Per-request timeout in milliseconds. Defaults to 15000. */
|
|
55
|
+
requestTimeoutMs?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Resolved base URL: explicit `baseUrl` if provided, else the environment default. */
|
|
59
|
+
export function resolvedBaseUrl(config: SpareLinkConfig): string {
|
|
60
|
+
return config.baseUrl ?? defaultBaseUrlFor(config.environment);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Recovery config — like {@link SpareLinkConfig} but without `linkToken`
|
|
65
|
+
* (read from the persisted record).
|
|
66
|
+
*/
|
|
67
|
+
export interface SpareLinkResumeConfig {
|
|
68
|
+
environment: PaymentEnvironment;
|
|
69
|
+
tenant: SpareApiTenant;
|
|
70
|
+
baseUrl?: string;
|
|
71
|
+
fetch?: typeof fetch;
|
|
72
|
+
requestTimeoutMs?: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function resolvedResumeBaseUrl(config: SpareLinkResumeConfig): string {
|
|
76
|
+
return config.baseUrl ?? defaultBaseUrlFor(config.environment);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Throws if a SpareLinkConfig is structurally invalid. */
|
|
80
|
+
export function assertValidConfig(config: SpareLinkConfig): void {
|
|
81
|
+
if (!config.linkToken) {
|
|
82
|
+
throw new Error('SpareLinkConfig: linkToken must not be empty');
|
|
83
|
+
}
|
|
84
|
+
if (config.baseUrl && !/^https?:\/\//.test(config.baseUrl)) {
|
|
85
|
+
throw new Error('SpareLinkConfig: baseUrl must start with http:// or https://');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { PaymentResult } from './payment-result';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Lifecycle events emitted on {@link SpareLink.events}.
|
|
5
|
+
*
|
|
6
|
+
* This is a discriminated union (TypeScript's equivalent to Dart sealed classes).
|
|
7
|
+
* Use a switch on the `type` field for exhaustive handling:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* spareLink.events.subscribe((event) => {
|
|
11
|
+
* switch (event.type) {
|
|
12
|
+
* case 'initialized':
|
|
13
|
+
* console.log('Started flow for', event.linkToken);
|
|
14
|
+
* break;
|
|
15
|
+
* case 'sessionLoaded':
|
|
16
|
+
* console.log('Session loaded', event.linkSessionId);
|
|
17
|
+
* break;
|
|
18
|
+
* case 'succeeded':
|
|
19
|
+
* console.log('Payment succeeded', event.result.exchangeCode);
|
|
20
|
+
* break;
|
|
21
|
+
* // ...
|
|
22
|
+
* }
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type SpareLinkEvent =
|
|
27
|
+
| SpareLinkInitialized
|
|
28
|
+
| SpareLinkSessionLoaded
|
|
29
|
+
| SpareLinkConsentStarted
|
|
30
|
+
| SpareLinkRedirectToBank
|
|
31
|
+
| SpareLinkBankCallbackReceived
|
|
32
|
+
| SpareLinkSucceeded
|
|
33
|
+
| SpareLinkFailed
|
|
34
|
+
| SpareLinkCancelled
|
|
35
|
+
| SpareLinkAbandoned;
|
|
36
|
+
|
|
37
|
+
/** The SDK has started a payment flow. */
|
|
38
|
+
export interface SpareLinkInitialized {
|
|
39
|
+
readonly type: 'initialized';
|
|
40
|
+
readonly linkToken: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The payment session was loaded from the server. */
|
|
44
|
+
export interface SpareLinkSessionLoaded {
|
|
45
|
+
readonly type: 'sessionLoaded';
|
|
46
|
+
readonly linkToken: string;
|
|
47
|
+
/** Server-assigned link session ID when available from the API. */
|
|
48
|
+
readonly linkSessionId?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The user confirmed consent and a consent request was submitted. */
|
|
52
|
+
export interface SpareLinkConsentStarted {
|
|
53
|
+
readonly type: 'consentStarted';
|
|
54
|
+
readonly linkToken: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The user is being redirected to their bank's authorization page. */
|
|
58
|
+
export interface SpareLinkRedirectToBank {
|
|
59
|
+
readonly type: 'redirectToBank';
|
|
60
|
+
readonly linkToken: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The bank has redirected back with a callback URI. */
|
|
64
|
+
export interface SpareLinkBankCallbackReceived {
|
|
65
|
+
readonly type: 'bankCallbackReceived';
|
|
66
|
+
readonly linkToken: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The payment completed successfully and the flow is about to resolve. */
|
|
70
|
+
export interface SpareLinkSucceeded {
|
|
71
|
+
readonly type: 'succeeded';
|
|
72
|
+
readonly result: PaymentResult;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The payment failed and the flow is about to resolve. */
|
|
76
|
+
export interface SpareLinkFailed {
|
|
77
|
+
readonly type: 'failed';
|
|
78
|
+
readonly result: PaymentResult;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The user cancelled the payment and the flow is about to resolve. */
|
|
82
|
+
export interface SpareLinkCancelled {
|
|
83
|
+
readonly type: 'cancelled';
|
|
84
|
+
readonly result: PaymentResult;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The flow was abandoned without an explicit user action. */
|
|
88
|
+
export interface SpareLinkAbandoned {
|
|
89
|
+
readonly type: 'abandoned';
|
|
90
|
+
readonly result: PaymentResult;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** All possible event type strings for type narrowing. */
|
|
94
|
+
export const SPARE_LINK_EVENT_TYPES = [
|
|
95
|
+
'initialized',
|
|
96
|
+
'sessionLoaded',
|
|
97
|
+
'consentStarted',
|
|
98
|
+
'redirectToBank',
|
|
99
|
+
'bankCallbackReceived',
|
|
100
|
+
'succeeded',
|
|
101
|
+
'failed',
|
|
102
|
+
'cancelled',
|
|
103
|
+
'abandoned',
|
|
104
|
+
] as const;
|
|
105
|
+
|
|
106
|
+
export type SpareLinkEventType = (typeof SPARE_LINK_EVENT_TYPES)[number];
|
|
107
|
+
|
|
108
|
+
/** Type guard for SpareLinkEvent. */
|
|
109
|
+
export function isSpareLinkEvent(value: unknown): value is SpareLinkEvent {
|
|
110
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
111
|
+
const type = (value as { type?: unknown }).type;
|
|
112
|
+
return typeof type === 'string' && SPARE_LINK_EVENT_TYPES.includes(type as SpareLinkEventType);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Factory functions for creating events (internal use). */
|
|
116
|
+
export const SpareLinkEvents = {
|
|
117
|
+
initialized(linkToken: string): SpareLinkInitialized {
|
|
118
|
+
return { type: 'initialized', linkToken };
|
|
119
|
+
},
|
|
120
|
+
sessionLoaded(linkToken: string, linkSessionId?: string): SpareLinkSessionLoaded {
|
|
121
|
+
return linkSessionId
|
|
122
|
+
? { type: 'sessionLoaded', linkToken, linkSessionId }
|
|
123
|
+
: { type: 'sessionLoaded', linkToken };
|
|
124
|
+
},
|
|
125
|
+
consentStarted(linkToken: string): SpareLinkConsentStarted {
|
|
126
|
+
return { type: 'consentStarted', linkToken };
|
|
127
|
+
},
|
|
128
|
+
redirectToBank(linkToken: string): SpareLinkRedirectToBank {
|
|
129
|
+
return { type: 'redirectToBank', linkToken };
|
|
130
|
+
},
|
|
131
|
+
bankCallbackReceived(linkToken: string): SpareLinkBankCallbackReceived {
|
|
132
|
+
return { type: 'bankCallbackReceived', linkToken };
|
|
133
|
+
},
|
|
134
|
+
succeeded(result: PaymentResult): SpareLinkSucceeded {
|
|
135
|
+
return { type: 'succeeded', result };
|
|
136
|
+
},
|
|
137
|
+
failed(result: PaymentResult): SpareLinkFailed {
|
|
138
|
+
return { type: 'failed', result };
|
|
139
|
+
},
|
|
140
|
+
cancelled(result: PaymentResult): SpareLinkCancelled {
|
|
141
|
+
return { type: 'cancelled', result };
|
|
142
|
+
},
|
|
143
|
+
abandoned(result: PaymentResult): SpareLinkAbandoned {
|
|
144
|
+
return { type: 'abandoned', result };
|
|
145
|
+
},
|
|
146
|
+
} as const;
|