@onramper/onramper-react-native 1.2.2 → 1.3.1
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 +249 -0
- package/README.md +64 -4
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/arm64-apple-ios.swiftinterface +110 -4
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/OnramperSDK.framework/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/DWARF/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/OnramperSDK.yml +3562 -2684
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +110 -4
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/Modules/OnramperSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +110 -4
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/OnramperSDK.framework/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/DWARF/OnramperSDK +0 -0
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/OnramperSDK.yml +3562 -2684
- package/ios/Frameworks/OnramperSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/OnramperSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/OnramperSDK.yml +3525 -2651
- package/ios/HybridOnramperCheckoutButton.swift +77 -3
- package/ios/HybridOnramperNitro.swift +142 -78
- package/ios/OnramperSDKBridge.swift +19 -2
- package/ios/PreparedIntentRegistry.swift +124 -6
- package/ios/SDKLogRelay.swift +41 -0
- package/lib/commonjs/CheckoutButton.js +34 -0
- package/lib/commonjs/CheckoutButton.js.map +1 -0
- package/lib/commonjs/OnramperClient.js +81 -12
- package/lib/commonjs/OnramperClient.js.map +1 -1
- package/lib/commonjs/errors.js +19 -5
- package/lib/commonjs/errors.js.map +1 -1
- package/lib/commonjs/generated/OnramperCheckoutButtonConfig.json +1 -0
- package/lib/module/CheckoutButton.js +30 -0
- package/lib/module/CheckoutButton.js.map +1 -0
- package/lib/module/OnramperClient.js +81 -12
- package/lib/module/OnramperClient.js.map +1 -1
- package/lib/module/errors.js +19 -5
- package/lib/module/errors.js.map +1 -1
- package/lib/module/generated/OnramperCheckoutButtonConfig.json +1 -0
- package/lib/typescript/commonjs/src/CheckoutButton.d.ts +20 -0
- package/lib/typescript/commonjs/src/CheckoutButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/OnramperClient.d.ts +10 -1
- package/lib/typescript/commonjs/src/OnramperClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/errors.d.ts +6 -1
- package/lib/typescript/commonjs/src/errors.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/events.d.ts +10 -0
- package/lib/typescript/commonjs/src/events.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/OnramperCheckoutButton.nitro.d.ts +6 -0
- package/lib/typescript/commonjs/src/specs/OnramperCheckoutButton.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/specs/OnramperNitro.nitro.d.ts +4 -0
- package/lib/typescript/commonjs/src/specs/OnramperNitro.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +32 -3
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/CheckoutButton.d.ts +20 -0
- package/lib/typescript/module/src/CheckoutButton.d.ts.map +1 -0
- package/lib/typescript/module/src/OnramperClient.d.ts +10 -1
- package/lib/typescript/module/src/OnramperClient.d.ts.map +1 -1
- package/lib/typescript/module/src/errors.d.ts +6 -1
- package/lib/typescript/module/src/errors.d.ts.map +1 -1
- package/lib/typescript/module/src/events.d.ts +10 -0
- package/lib/typescript/module/src/events.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/OnramperCheckoutButton.nitro.d.ts +6 -0
- package/lib/typescript/module/src/specs/OnramperCheckoutButton.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/specs/OnramperNitro.nitro.d.ts +4 -0
- package/lib/typescript/module/src/specs/OnramperNitro.nitro.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +32 -3
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/nitrogen/generated/ios/OnramperReactNative-Swift-Cxx-Bridge.cpp +11 -3
- package/nitrogen/generated/ios/OnramperReactNative-Swift-Cxx-Bridge.hpp +44 -7
- package/nitrogen/generated/ios/c++/HybridOnramperCheckoutButtonSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridOnramperNitroSpecSwift.hpp +11 -2
- package/nitrogen/generated/ios/c++/views/HybridOnramperCheckoutButtonComponent.mm +5 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +5 -5
- package/nitrogen/generated/ios/swift/HybridOnramperCheckoutButtonSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridOnramperCheckoutButtonSpec_cxx.swift +32 -0
- package/nitrogen/generated/ios/swift/HybridOnramperNitroSpec.swift +2 -1
- package/nitrogen/generated/ios/swift/HybridOnramperNitroSpec_cxx.swift +32 -11
- package/nitrogen/generated/ios/swift/OnramperNitroConfig.swift +16 -6
- package/nitrogen/generated/shared/c++/HybridOnramperCheckoutButtonSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridOnramperCheckoutButtonSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/HybridOnramperNitroSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridOnramperNitroSpec.hpp +3 -2
- package/nitrogen/generated/shared/c++/OnramperNitroConfig.hpp +10 -2
- package/nitrogen/generated/shared/c++/views/HybridOnramperCheckoutButtonComponent.cpp +11 -0
- package/nitrogen/generated/shared/c++/views/HybridOnramperCheckoutButtonComponent.hpp +3 -2
- package/nitrogen/generated/shared/json/OnramperCheckoutButtonConfig.json +1 -0
- package/package.json +5 -2
- package/src/CheckoutButton.ts +28 -0
- package/src/OnramperClient.ts +82 -9
- package/src/errors.ts +29 -6
- package/src/events.ts +5 -0
- package/src/generated/OnramperCheckoutButtonConfig.json +1 -0
- package/src/index.ts +3 -0
- package/src/specs/OnramperCheckoutButton.nitro.ts +6 -0
- package/src/specs/OnramperNitro.nitro.ts +5 -0
- package/src/types.ts +36 -3
package/src/errors.ts
CHANGED
|
@@ -8,6 +8,9 @@ export type OnramperErrorCode =
|
|
|
8
8
|
| 'networkError'
|
|
9
9
|
| 'decodingError'
|
|
10
10
|
| 'timeout'
|
|
11
|
+
| 'paymentFailed'
|
|
12
|
+
| 'providerFailed'
|
|
13
|
+
| 'applePayNotConfigured'
|
|
11
14
|
| 'requirementNotSatisfied'
|
|
12
15
|
| 'amountOutOfRange'
|
|
13
16
|
| 'oidcFlowCancelled'
|
|
@@ -26,42 +29,62 @@ export type OnramperErrorCode =
|
|
|
26
29
|
| 'deviceBlocked'
|
|
27
30
|
| 'securityStorageFailed'
|
|
28
31
|
| 'securityTrustFailed'
|
|
29
|
-
//
|
|
32
|
+
// Wrapper lifecycle and platform codes
|
|
30
33
|
| 'platformUnsupported'
|
|
31
34
|
| 'intentInvalidated'
|
|
32
35
|
| 'intentAlreadyConsumed'
|
|
33
36
|
| 'clientAlreadyConfigured'
|
|
37
|
+
| 'clientDestroyed'
|
|
34
38
|
| 'sessionExpirationHandlerFailed';
|
|
35
39
|
|
|
36
40
|
export interface OnramperErrorPayload {
|
|
37
41
|
code: OnramperErrorCode;
|
|
38
42
|
message: string;
|
|
43
|
+
/** Customer-facing SDK copy; optional for backwards-compatible payload construction. */
|
|
44
|
+
userMessage?: string;
|
|
45
|
+
supportCode?: string;
|
|
39
46
|
info?: Record<string, unknown>;
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
export class OnramperError extends Error implements OnramperErrorPayload {
|
|
43
50
|
readonly code: OnramperErrorCode;
|
|
51
|
+
readonly userMessage: string;
|
|
52
|
+
readonly supportCode: string;
|
|
44
53
|
readonly info?: Record<string, unknown>;
|
|
45
54
|
|
|
46
55
|
constructor(payload: OnramperErrorPayload) {
|
|
47
56
|
super(payload.message);
|
|
48
57
|
this.name = 'OnramperError';
|
|
49
58
|
this.code = payload.code;
|
|
59
|
+
this.userMessage = payload.userMessage ?? 'Something went wrong. Please try again.';
|
|
60
|
+
this.supportCode = payload.supportCode ?? payload.code;
|
|
50
61
|
this.info = payload.info;
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
static from(value: unknown): OnramperError {
|
|
54
65
|
if (value instanceof OnramperError) return value;
|
|
66
|
+
// Nitro transports Swift exceptions as message-only JS Errors. Our native
|
|
67
|
+
// bridge encodes SDK errors explicitly so Promise rejections retain the
|
|
68
|
+
// same fields as failed events, without consulting unrelated client state.
|
|
69
|
+
const message = value instanceof Error ? value.message : typeof value === 'string' ? value : undefined;
|
|
70
|
+
if (message?.startsWith('ONRAMPER_ERROR:')) {
|
|
71
|
+
try {
|
|
72
|
+
const payload = JSON.parse(message.slice('ONRAMPER_ERROR:'.length));
|
|
73
|
+
if (payload && typeof payload.code === 'string' && typeof payload.message === 'string') {
|
|
74
|
+
return OnramperError.from(payload);
|
|
75
|
+
}
|
|
76
|
+
} catch {
|
|
77
|
+
// A malformed/non-SDK error falls back to the ordinary error path.
|
|
78
|
+
}
|
|
79
|
+
}
|
|
55
80
|
if (value && typeof value === 'object') {
|
|
56
|
-
|
|
57
|
-
// `{ code, message, info? }` object. Thrown promise rejections surface
|
|
58
|
-
// as a JS Error with just a message; we default the code in that case
|
|
59
|
-
// (the structured error is also available on `client.state` / lastError).
|
|
60
|
-
const v = value as { code?: string; message?: string; info?: Record<string, unknown> };
|
|
81
|
+
const v = value as Partial<OnramperErrorPayload>;
|
|
61
82
|
return new OnramperError({
|
|
62
83
|
code: (v.code ?? 'unrecoverable') as OnramperErrorCode,
|
|
63
84
|
message: v.message ?? 'Unknown error',
|
|
64
85
|
info: v.info,
|
|
86
|
+
userMessage: typeof v.userMessage === 'string' ? v.userMessage : undefined,
|
|
87
|
+
supportCode: typeof v.supportCode === 'string' ? v.supportCode : undefined,
|
|
65
88
|
});
|
|
66
89
|
}
|
|
67
90
|
return new OnramperError({ code: 'unrecoverable', message: String(value) });
|
package/src/events.ts
CHANGED
|
@@ -16,6 +16,11 @@ export type CheckoutEvent =
|
|
|
16
16
|
| { type: 'providerReady' }
|
|
17
17
|
| { type: 'paymentAuthorized' }
|
|
18
18
|
| { type: 'paymentProcessing' }
|
|
19
|
+
/** Accepted but not settled; use currentTransactionId to track the payment. */
|
|
20
|
+
| { type: 'paymentPending' }
|
|
21
|
+
| { type: 'challengeStarted' }
|
|
22
|
+
| { type: 'challengeCompleted' }
|
|
23
|
+
| { type: 'customerOnboardingRequired' }
|
|
19
24
|
| { type: 'paymentCancelled' }
|
|
20
25
|
| { type: 'providerError'; reason: string };
|
|
21
26
|
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,12 @@ import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-nativ
|
|
|
5
5
|
// UIHostingController. iOS-only (Android is a platformUnsupported stub).
|
|
6
6
|
export interface OnramperCheckoutButtonProps extends HybridViewProps {
|
|
7
7
|
intentHandle: string;
|
|
8
|
+
/**
|
|
9
|
+
* Called with the hosted SwiftUI content's height (points) whenever it changes —
|
|
10
|
+
* e.g. when ToS text appears under the Buy button. React Native can't measure
|
|
11
|
+
* the SwiftUI content itself, so the JS wrapper applies this as `height`.
|
|
12
|
+
*/
|
|
13
|
+
onContentHeightChange?: (height: number) => void;
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
export interface OnramperCheckoutButtonMethods extends HybridViewMethods {}
|
|
@@ -8,6 +8,8 @@ export interface OnramperNitroConfig {
|
|
|
8
8
|
environment: string; // 'development' | 'production'
|
|
9
9
|
theme: string; // 'system' | 'light' | 'dark'
|
|
10
10
|
logLevel: string; // 'off' | 'error' | 'info' | 'debug'
|
|
11
|
+
isEventLoggingEnabled: boolean;
|
|
12
|
+
isEventConsoleLoggingEnabled: boolean;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
// Mirrors OnramperSDK.SessionCredentials. Named with a Nitro prefix to avoid a
|
|
@@ -34,6 +36,8 @@ export interface PreparedIntentResult {
|
|
|
34
36
|
* them back into the fully-typed `OnramperState`/`CheckoutEvent` unions.
|
|
35
37
|
*/
|
|
36
38
|
export interface OnramperNitro extends HybridObject<{ ios: 'swift' }> {
|
|
39
|
+
// Compiled native SDK version, readable before configure/initialize.
|
|
40
|
+
readonly sdkVersion: string;
|
|
37
41
|
configure(config: OnramperNitroConfig): Promise<void>;
|
|
38
42
|
initialize(sessionId: string, sessionToken: string): Promise<void>;
|
|
39
43
|
reset(): Promise<void>;
|
|
@@ -50,6 +54,7 @@ export interface OnramperNitro extends HybridObject<{ ios: 'swift' }> {
|
|
|
50
54
|
cancelPreparedIntent(intentHandle: string): Promise<void>;
|
|
51
55
|
|
|
52
56
|
// Single native callback per stream; the JS wrapper fans out to multiple listeners.
|
|
57
|
+
setLogListener(onLog: (recordJson: string) => void): void;
|
|
53
58
|
setStateListener(onState: (stateJson: string) => void): void;
|
|
54
59
|
setEventListener(onEvent: (eventJson: string) => void): void;
|
|
55
60
|
// Mirrors OnramperSDK.$currentTransactionId. `undefined` represents native nil.
|
package/src/types.ts
CHANGED
|
@@ -5,6 +5,16 @@ import type { OnramperErrorPayload } from './errors';
|
|
|
5
5
|
|
|
6
6
|
export type OnramperEnvironment = 'development' | 'production';
|
|
7
7
|
export type OnramperLogLevel = 'off' | 'error' | 'info' | 'debug';
|
|
8
|
+
/** A sanitized native SDK diagnostic. Timestamp is Unix milliseconds. */
|
|
9
|
+
export interface OnramperLogRecord {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
level: OnramperLogLevel;
|
|
12
|
+
category: string;
|
|
13
|
+
event: string;
|
|
14
|
+
context: Record<string, string>;
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
export type OnramperTheme = 'system' | 'light' | 'dark';
|
|
9
19
|
|
|
10
20
|
export type TransactionType = 'buy' | 'sell';
|
|
@@ -20,12 +30,16 @@ export interface OnramperConfiguration {
|
|
|
20
30
|
environment: OnramperEnvironment;
|
|
21
31
|
theme?: OnramperTheme;
|
|
22
32
|
logLevel?: OnramperLogLevel;
|
|
33
|
+
/** Receives native records in JS; system Console output is preserved. Off unless logLevel enables it. */
|
|
34
|
+
logHandler?: (record: OnramperLogRecord) => void;
|
|
35
|
+
/** Opt-in provider-event telemetry to the BFF. Defaults to false. */
|
|
36
|
+
isEventLoggingEnabled?: boolean;
|
|
37
|
+
/** Emit provider events at info even when logLevel is lower. Defaults to false. */
|
|
38
|
+
isEventConsoleLoggingEnabled?: boolean;
|
|
23
39
|
/**
|
|
24
40
|
* Called by the SDK when the session token expires and needs to be re-issued.
|
|
25
41
|
*
|
|
26
|
-
* May be synchronous or async
|
|
27
|
-
* round-trip (`onSessionExpired` → `provideSessionCredentials`) so Promises
|
|
28
|
-
* are awaited normally. Throw or reject to signal that no fresh credentials
|
|
42
|
+
* May be synchronous or async; the Nitro bridge awaits the callback directly. Throw or reject to signal that no fresh credentials
|
|
29
43
|
* are available; the SDK will surface `userTokenRefreshFailed`.
|
|
30
44
|
*/
|
|
31
45
|
onSessionExpired: () => SessionCredentials | Promise<SessionCredentials>;
|
|
@@ -67,6 +81,23 @@ export interface QuoteResponse {
|
|
|
67
81
|
networkFee: number;
|
|
68
82
|
transactionFee: number;
|
|
69
83
|
recommendations?: string[];
|
|
84
|
+
providerContext?: Record<string, ProviderJSONValue>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** JSON values used in provider-specific quote metadata (including booleans and limits). */
|
|
88
|
+
export type ProviderJSONValue =
|
|
89
|
+
| string
|
|
90
|
+
| number
|
|
91
|
+
| boolean
|
|
92
|
+
| null
|
|
93
|
+
| ProviderJSONValue[]
|
|
94
|
+
| { [key: string]: ProviderJSONValue };
|
|
95
|
+
|
|
96
|
+
export interface PaymentDisclosure {
|
|
97
|
+
code: string;
|
|
98
|
+
version: string;
|
|
99
|
+
contentMarkdown: string;
|
|
100
|
+
contentHtml: string;
|
|
70
101
|
}
|
|
71
102
|
|
|
72
103
|
// Mirrors Swift `OnramperUserPrefill`. Values you already know about the user,
|
|
@@ -111,6 +142,7 @@ export interface HeadlessCheckoutData {
|
|
|
111
142
|
checkoutPaymentType: CheckoutPaymentType;
|
|
112
143
|
url: string;
|
|
113
144
|
renderType: RenderType;
|
|
145
|
+
providerBootstrap?: { framesBaseUrl?: string };
|
|
114
146
|
}
|
|
115
147
|
|
|
116
148
|
export interface CheckoutFinalizeResponse {
|
|
@@ -181,6 +213,7 @@ export type OnramperState =
|
|
|
181
213
|
| { kind: 'readyToCheckout' }
|
|
182
214
|
| { kind: 'finalizing' }
|
|
183
215
|
| { kind: 'rendering'; url: string; renderType: RenderType; paymentType: CheckoutPaymentType }
|
|
216
|
+
| { kind: 'paymentPending' }
|
|
184
217
|
| { kind: 'completed' }
|
|
185
218
|
| { kind: 'failed'; error: OnramperErrorPayload };
|
|
186
219
|
|