@portal-hq/web 3.12.0 → 3.13.0-alpha.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.
@@ -0,0 +1,89 @@
1
+ import Mpc from '../../../mpc'
2
+ import type {
3
+ NoahGetPayoutChannelsRequest,
4
+ NoahGetPayoutChannelsResponse,
5
+ NoahGetPayoutChannelFormResponse,
6
+ NoahGetPayoutCountriesResponse,
7
+ NoahGetPaymentMethodsResponse,
8
+ NoahGetPayoutQuoteRequest,
9
+ NoahGetPayoutQuoteResponse,
10
+ NoahInitiateKycRequest,
11
+ NoahInitiateKycResponse,
12
+ NoahInitiatePayinRequest,
13
+ NoahInitiatePayinResponse,
14
+ NoahInitiatePayoutRequest,
15
+ NoahInitiatePayoutResponse,
16
+ NoahSimulatePayinRequest,
17
+ NoahSimulatePayinResponse,
18
+ } from '../../../shared/types'
19
+
20
+ /**
21
+ * Noah fiat on/off-ramp API on `portal.ramps.noah`.
22
+ * Each method forwards to the embedded Portal iframe, which calls connect-api.
23
+ */
24
+ export default class Noah {
25
+ private mpc: Mpc
26
+
27
+ constructor({ mpc }: { mpc: Mpc }) {
28
+ this.mpc = mpc
29
+ }
30
+
31
+ /** Start hosted KYC; response includes `hostedUrl` to open in a browser tab. */
32
+ public async initiateKyc(
33
+ data: NoahInitiateKycRequest,
34
+ ): Promise<NoahInitiateKycResponse> {
35
+ return this.mpc.initiateKyc(data)
36
+ }
37
+
38
+ /** Create a pay-in (fiat → crypto) with bank transfer instructions. */
39
+ public async initiatePayin(
40
+ data: NoahInitiatePayinRequest,
41
+ ): Promise<NoahInitiatePayinResponse> {
42
+ return this.mpc.initiatePayin(data)
43
+ }
44
+
45
+ /** Dry-run pay-in pricing / eligibility for a payment method and fiat amount. */
46
+ public async simulatePayin(
47
+ data: NoahSimulatePayinRequest,
48
+ ): Promise<NoahSimulatePayinResponse> {
49
+ return this.mpc.simulatePayin(data)
50
+ }
51
+
52
+ /** Countries supported for fiat payouts. */
53
+ public async getPayoutCountries(): Promise<NoahGetPayoutCountriesResponse> {
54
+ return this.mpc.getPayoutCountries()
55
+ }
56
+
57
+ /** Available payout rails for a country / currency pair. */
58
+ public async getPayoutChannels(
59
+ data: NoahGetPayoutChannelsRequest,
60
+ ): Promise<NoahGetPayoutChannelsResponse> {
61
+ return this.mpc.getPayoutChannels(data)
62
+ }
63
+
64
+ /** Dynamic form schema for a payout channel (recipient fields). */
65
+ public async getPayoutChannelForm(
66
+ channelId: string,
67
+ ): Promise<NoahGetPayoutChannelFormResponse> {
68
+ return this.mpc.getPayoutChannelForm(channelId)
69
+ }
70
+
71
+ /** Quote fees and crypto amount for a payout channel and form payload. */
72
+ public async getPayoutQuote(
73
+ data: NoahGetPayoutQuoteRequest,
74
+ ): Promise<NoahGetPayoutQuoteResponse> {
75
+ return this.mpc.getPayoutQuote(data)
76
+ }
77
+
78
+ /** Start payout execution; may return on-chain deposit `conditions` for crypto legs. */
79
+ public async initiatePayout(
80
+ data: NoahInitiatePayoutRequest,
81
+ ): Promise<NoahInitiatePayoutResponse> {
82
+ return this.mpc.initiatePayout(data)
83
+ }
84
+
85
+ /** Pay-in payment methods available to the customer. */
86
+ public async getPaymentMethods(): Promise<NoahGetPaymentMethodsResponse> {
87
+ return this.mpc.getPaymentMethods()
88
+ }
89
+ }
package/src/mpc/index.ts CHANGED
@@ -65,6 +65,21 @@ import {
65
65
  LifiStatusResponse,
66
66
  LifiStepTransactionRequest,
67
67
  LifiStepTransactionResponse,
68
+ NoahGetPayoutChannelsRequest,
69
+ NoahGetPayoutChannelsResponse,
70
+ NoahGetPayoutChannelFormResponse,
71
+ NoahGetPayoutCountriesResponse,
72
+ NoahGetPaymentMethodsResponse,
73
+ NoahGetPayoutQuoteRequest,
74
+ NoahGetPayoutQuoteResponse,
75
+ NoahInitiateKycRequest,
76
+ NoahInitiateKycResponse,
77
+ NoahInitiatePayinRequest,
78
+ NoahInitiatePayinResponse,
79
+ NoahInitiatePayoutRequest,
80
+ NoahInitiatePayoutResponse,
81
+ NoahSimulatePayinRequest,
82
+ NoahSimulatePayinResponse,
68
83
  ZeroExOptions,
69
84
  ZeroExPriceRequest,
70
85
  ZeroExPriceResponse,
@@ -110,7 +125,7 @@ import {
110
125
  } from '../../hypernative'
111
126
  import { generateTraceId } from '../shared/trace'
112
127
 
113
- const WEB_SDK_VERSION = '3.12.0'
128
+ const WEB_SDK_VERSION = '3.13.0-alpha.0'
114
129
 
115
130
  class Mpc {
116
131
  public iframe?: HTMLIFrameElement
@@ -669,6 +684,105 @@ class Mpc {
669
684
  })
670
685
  }
671
686
 
687
+ /**
688
+ * Noah ramp: postMessage bridge to the Portal iframe (connect-api).
689
+ * Application code should call `portal.ramps.noah` instead of Mpc directly.
690
+ */
691
+ public async initiateKyc(
692
+ data: NoahInitiateKycRequest,
693
+ ): Promise<NoahInitiateKycResponse> {
694
+ return this.handleRequestToIframeAndPost({
695
+ methodMessage: 'portal:noah:initiateKyc',
696
+ errorMessage: 'portal:noah:initiateKycError',
697
+ resultMessage: 'portal:noah:initiateKycResult',
698
+ data,
699
+ })
700
+ }
701
+
702
+ public async initiatePayin(
703
+ data: NoahInitiatePayinRequest,
704
+ ): Promise<NoahInitiatePayinResponse> {
705
+ return this.handleRequestToIframeAndPost({
706
+ methodMessage: 'portal:noah:initiatePayin',
707
+ errorMessage: 'portal:noah:initiatePayinError',
708
+ resultMessage: 'portal:noah:initiatePayinResult',
709
+ data,
710
+ })
711
+ }
712
+
713
+ public async simulatePayin(
714
+ data: NoahSimulatePayinRequest,
715
+ ): Promise<NoahSimulatePayinResponse> {
716
+ return this.handleRequestToIframeAndPost({
717
+ methodMessage: 'portal:noah:simulatePayin',
718
+ errorMessage: 'portal:noah:simulatePayinError',
719
+ resultMessage: 'portal:noah:simulatePayinResult',
720
+ data,
721
+ })
722
+ }
723
+
724
+ public async getPayoutCountries(): Promise<NoahGetPayoutCountriesResponse> {
725
+ return this.handleRequestToIframeAndPost({
726
+ methodMessage: 'portal:noah:getPayoutCountries',
727
+ errorMessage: 'portal:noah:getPayoutCountriesError',
728
+ resultMessage: 'portal:noah:getPayoutCountriesResult',
729
+ data: {},
730
+ })
731
+ }
732
+
733
+ public async getPayoutChannels(
734
+ data: NoahGetPayoutChannelsRequest,
735
+ ): Promise<NoahGetPayoutChannelsResponse> {
736
+ return this.handleRequestToIframeAndPost({
737
+ methodMessage: 'portal:noah:getPayoutChannels',
738
+ errorMessage: 'portal:noah:getPayoutChannelsError',
739
+ resultMessage: 'portal:noah:getPayoutChannelsResult',
740
+ data,
741
+ })
742
+ }
743
+
744
+ public async getPayoutChannelForm(
745
+ channelId: string,
746
+ ): Promise<NoahGetPayoutChannelFormResponse> {
747
+ return this.handleRequestToIframeAndPost({
748
+ methodMessage: 'portal:noah:getPayoutChannelForm',
749
+ errorMessage: 'portal:noah:getPayoutChannelFormError',
750
+ resultMessage: 'portal:noah:getPayoutChannelFormResult',
751
+ data: channelId,
752
+ })
753
+ }
754
+
755
+ public async getPayoutQuote(
756
+ data: NoahGetPayoutQuoteRequest,
757
+ ): Promise<NoahGetPayoutQuoteResponse> {
758
+ return this.handleRequestToIframeAndPost({
759
+ methodMessage: 'portal:noah:getPayoutQuote',
760
+ errorMessage: 'portal:noah:getPayoutQuoteError',
761
+ resultMessage: 'portal:noah:getPayoutQuoteResult',
762
+ data,
763
+ })
764
+ }
765
+
766
+ public async initiatePayout(
767
+ data: NoahInitiatePayoutRequest,
768
+ ): Promise<NoahInitiatePayoutResponse> {
769
+ return this.handleRequestToIframeAndPost({
770
+ methodMessage: 'portal:noah:initiatePayout',
771
+ errorMessage: 'portal:noah:initiatePayoutError',
772
+ resultMessage: 'portal:noah:initiatePayoutResult',
773
+ data,
774
+ })
775
+ }
776
+
777
+ public async getPaymentMethods(): Promise<NoahGetPaymentMethodsResponse> {
778
+ return this.handleRequestToIframeAndPost({
779
+ methodMessage: 'portal:noah:getPaymentMethods',
780
+ errorMessage: 'portal:noah:getPaymentMethodsError',
781
+ resultMessage: 'portal:noah:getPaymentMethodsResult',
782
+ data: {},
783
+ })
784
+ }
785
+
672
786
  public async getSwapsQuoteV2(
673
787
  data: ZeroExQuoteRequest,
674
788
  options?: ZeroExOptions,
@@ -16,6 +16,7 @@ export * from './api'
16
16
  export * from './yieldxyz'
17
17
  export * from './zero-x'
18
18
  export * from './lifi'
19
+ export * from './noah'
19
20
  export * from './hypernative'
20
21
  export * from './blockaid'
21
22
 
@@ -0,0 +1,150 @@
1
+ export interface PortalApiSuccessEnvelope<T> {
2
+ data: T
3
+ metadata?: Record<string, unknown>
4
+ }
5
+
6
+ export interface NoahInitiateKycRequest {
7
+ returnUrl: string
8
+ fiatOptions?: { fiatCurrencyCode: string }[]
9
+ customerType?: 'Individual' | 'Business'
10
+ metadata?: Record<string, unknown>
11
+ form?: Record<string, unknown>
12
+ }
13
+
14
+ export interface NoahInitiateKycResponseData {
15
+ hostedUrl: string
16
+ }
17
+
18
+ export type NoahInitiateKycResponse =
19
+ PortalApiSuccessEnvelope<NoahInitiateKycResponseData>
20
+
21
+ export interface NoahInitiatePayinRequest {
22
+ fiatCurrency: string
23
+ cryptoCurrency: string
24
+ network: string
25
+ destinationAddress: string
26
+ }
27
+
28
+ export interface NoahInitiatePayinResponseData {
29
+ payinId: string
30
+ bankDetails: Record<string, unknown>
31
+ }
32
+
33
+ export type NoahInitiatePayinResponse =
34
+ PortalApiSuccessEnvelope<NoahInitiatePayinResponseData>
35
+
36
+ export interface NoahSimulatePayinRequest {
37
+ paymentMethodId: string
38
+ fiatAmount: string
39
+ fiatCurrency: string
40
+ }
41
+
42
+ export type NoahSimulatePayinResponseData = Record<string, unknown>
43
+
44
+ export type NoahSimulatePayinResponse =
45
+ PortalApiSuccessEnvelope<NoahSimulatePayinResponseData>
46
+
47
+ export interface NoahGetPayoutCountriesResponseData {
48
+ countries: unknown
49
+ }
50
+
51
+ export type NoahGetPayoutCountriesResponse =
52
+ PortalApiSuccessEnvelope<NoahGetPayoutCountriesResponseData>
53
+
54
+ export interface NoahGetPayoutChannelsRequest {
55
+ country: string
56
+ cryptoCurrency: string
57
+ fiatCurrency: string
58
+ fiatAmount?: string
59
+ }
60
+
61
+ /** GET …/payouts/channels — body shape is provider-specific (array or object). */
62
+ export type NoahGetPayoutChannelsResponseData = unknown
63
+
64
+ export type NoahGetPayoutChannelsResponse =
65
+ PortalApiSuccessEnvelope<NoahGetPayoutChannelsResponseData>
66
+
67
+ export type NoahGetPayoutChannelFormResponseData = unknown
68
+
69
+ export type NoahGetPayoutChannelFormResponse =
70
+ PortalApiSuccessEnvelope<NoahGetPayoutChannelFormResponseData>
71
+
72
+ export interface NoahGetPayoutQuoteRequest {
73
+ channelId: string
74
+ cryptoCurrency: string
75
+ fiatAmount: string
76
+ form?: Record<string, unknown>
77
+ fiatCurrency?: string
78
+ paymentMethodId?: string
79
+ }
80
+
81
+ export interface NoahGetPayoutQuoteResponseData {
82
+ payoutId: string
83
+ formSessionId: string
84
+ cryptoAmountEstimate: string
85
+ totalFee: string
86
+ nextStep?: unknown
87
+ }
88
+
89
+ export type NoahGetPayoutQuoteResponse =
90
+ PortalApiSuccessEnvelope<NoahGetPayoutQuoteResponseData>
91
+
92
+ /**
93
+ * Single row inside Noah `AmountConditions` (PascalCase from API) or camelCase variants.
94
+ * Aligns with connect-api Noah / on-chain deposit trigger payloads.
95
+ */
96
+ export interface NoahAmountConditionRow {
97
+ ComparisonOperator?: string
98
+ Value?: string
99
+ comparisonOperator?: string
100
+ value?: string
101
+ }
102
+
103
+ /** One condition block: amount rules + network (Noah payout deposit shape). */
104
+ export interface NoahPayoutConditionBlock {
105
+ AmountConditions?: NoahAmountConditionRow[]
106
+ amountConditions?: NoahAmountConditionRow[]
107
+ Network?: string
108
+ network?: string
109
+ }
110
+
111
+ /** Supported Solana CAIP-2 IDs for payout deposit flows. */
112
+ export type NoahSolanaCaipId =
113
+ | 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1'
114
+ | 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'
115
+
116
+ export interface NoahSingleOnchainDepositSourceTriggerInput {
117
+ Type: 'SingleOnchainDepositSourceTriggerInput'
118
+ Conditions: {
119
+ AmountConditions: { ComparisonOperator: string; Value: string }[]
120
+ Network: string
121
+ }[]
122
+ SourceAddress: string
123
+ Expiry: string
124
+ Nonce: string
125
+ }
126
+
127
+ export interface NoahInitiatePayoutRequest {
128
+ payoutId: string
129
+ sourceAddress: string
130
+ expiry: string
131
+ nonce: string
132
+ network: string
133
+ trigger?: NoahSingleOnchainDepositSourceTriggerInput
134
+ }
135
+
136
+ export interface NoahInitiatePayoutResponseData {
137
+ destinationAddress: string | null
138
+ conditions: unknown
139
+ }
140
+
141
+ export type NoahInitiatePayoutResponse =
142
+ PortalApiSuccessEnvelope<NoahInitiatePayoutResponseData>
143
+
144
+ export interface NoahGetPaymentMethodsResponseData {
145
+ paymentMethods: unknown
146
+ pageToken?: unknown
147
+ }
148
+
149
+ export type NoahGetPaymentMethodsResponse =
150
+ PortalApiSuccessEnvelope<NoahGetPaymentMethodsResponseData>
package/tsconfig.json CHANGED
@@ -23,6 +23,7 @@
23
23
  "types.d.ts",
24
24
  "yieldxyz-types.d.ts",
25
25
  "lifi-types.d.ts",
26
+ "noah-types.d.ts",
26
27
  "hypernative.d.ts",
27
28
  "zero-x.d.ts"
28
29
  ],