@ozura/elements 1.1.0 → 1.2.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/README.md +1340 -1338
- package/dist/frame/element-frame.html +22 -22
- package/dist/frame/tokenizer-frame.html +11 -11
- package/dist/oz-elements.esm.js +262 -243
- package/dist/oz-elements.esm.js.map +1 -1
- package/dist/oz-elements.umd.js +263 -243
- package/dist/oz-elements.umd.js.map +1 -1
- package/dist/react/index.cjs.js +138 -112
- package/dist/react/index.cjs.js.map +1 -1
- package/dist/react/index.esm.js +137 -112
- package/dist/react/index.esm.js.map +1 -1
- package/dist/react/react/index.d.ts +50 -29
- package/dist/react/sdk/OzVault.d.ts +6 -5
- package/dist/react/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/react/sdk/index.d.ts +6 -26
- package/dist/react/server/index.d.ts +126 -74
- package/dist/react/types/index.d.ts +56 -31
- package/dist/server/index.cjs.js +165 -76
- package/dist/server/index.cjs.js.map +1 -1
- package/dist/server/index.esm.js +164 -77
- package/dist/server/index.esm.js.map +1 -1
- package/dist/server/sdk/OzVault.d.ts +6 -5
- package/dist/server/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/server/sdk/index.d.ts +6 -26
- package/dist/server/server/index.d.ts +126 -74
- package/dist/server/types/index.d.ts +56 -31
- package/dist/types/sdk/OzVault.d.ts +6 -5
- package/dist/types/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/types/sdk/index.d.ts +6 -26
- package/dist/types/server/index.d.ts +126 -74
- package/dist/types/types/index.d.ts +56 -31
- package/package.json +1 -1
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
export { OzVault } from './OzVault';
|
|
2
2
|
export { OzElement } from './OzElement';
|
|
3
3
|
export { OzError, normalizeVaultError, normalizeBankVaultError, normalizeCardSaleError } from './errors';
|
|
4
|
+
export { createSessionFetcher } from './createSessionFetcher';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
+
* @deprecated Use `sessionUrl` on `VaultOptions` / `OzElementsProps` instead —
|
|
7
|
+
* it calls `createSessionFetcher` internally and requires no extra code.
|
|
6
8
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* error through its normal error path.
|
|
10
|
-
*
|
|
11
|
-
* Each call enforces a 10-second per-attempt timeout. On a pure network-level
|
|
12
|
-
* failure (connection refused, DNS failure, etc.) the call is retried once after
|
|
13
|
-
* 750ms before throwing. HTTP errors (4xx/5xx) are never retried — they indicate
|
|
14
|
-
* an endpoint misconfiguration or an invalid key, not a transient failure.
|
|
15
|
-
*
|
|
16
|
-
* The mint endpoint is typically the one-line `createMintWaxHandler` / `createMintWaxMiddleware`
|
|
17
|
-
* from `@ozura/elements/server`.
|
|
18
|
-
*
|
|
19
|
-
* @param mintUrl - Absolute or relative URL of your wax-key mint endpoint, e.g. `'/api/mint-wax'`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* // Vanilla JS
|
|
23
|
-
* const vault = await OzVault.create({
|
|
24
|
-
* pubKey: 'pk_live_...',
|
|
25
|
-
* fetchWaxKey: createFetchWaxKey('/api/mint-wax'),
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* // React
|
|
30
|
-
* <OzElements pubKey="pk_live_..." fetchWaxKey={createFetchWaxKey('/api/mint-wax')}>
|
|
9
|
+
* For custom request logic (auth headers etc.), use `createSessionFetcher` or
|
|
10
|
+
* write a `getSessionKey` callback inline.
|
|
31
11
|
*/
|
|
32
|
-
export
|
|
12
|
+
export { createSessionFetcher as createFetchWaxKey } from './createSessionFetcher';
|
|
33
13
|
export type { OzErrorCode } from './errors';
|
|
34
14
|
export type { ElementType, BankElementType, ElementOptions, ElementStyleConfig, ElementStyle, ElementChangeEvent, VaultOptions, TokenizeOptions, BankTokenizeOptions, TokenResponse, BankTokenResponse, CardMetadata, BankAccountMetadata, FontSource, CssFontSource, CustomFontSource, BillingDetails, BillingAddress, CardSaleRequest, CardSaleResponseData, CardSaleApiResponse, Appearance, AppearanceVariables, OzTheme, TransactionQueryParams, TransactionQueryPagination, TransactionQueryResponse, TransactionType, CardTransactionType, AchTransactionType, CryptoTransactionType, TransactionBase, CardTransactionData, AchTransactionData, CryptoTransactionData, TransactionData, } from '../types';
|
|
@@ -38,12 +38,12 @@ export interface OzuraConfig {
|
|
|
38
38
|
* Required for `cardSale()`. Tokenize-only integrations can omit this.
|
|
39
39
|
*/
|
|
40
40
|
apiKey?: string;
|
|
41
|
-
/** Vault API key — used for `
|
|
41
|
+
/** Vault API key — used for `createSession()` and `revokeSession()`. Always required. */
|
|
42
42
|
vaultKey: string;
|
|
43
43
|
/** Ozura Pay API base URL. Defaults to staging. */
|
|
44
44
|
apiUrl?: string;
|
|
45
45
|
/**
|
|
46
|
-
* Ozura Vault base URL. Used for `
|
|
46
|
+
* Ozura Vault base URL. Used for `createSession` and `revokeSession`.
|
|
47
47
|
* Defaults to the build-time vault URL (staging or production).
|
|
48
48
|
*/
|
|
49
49
|
vaultUrl?: string;
|
|
@@ -58,41 +58,81 @@ export declare class OzuraError extends Error {
|
|
|
58
58
|
readonly retryAfter?: number;
|
|
59
59
|
constructor(message: string, statusCode: number, raw?: string, retryAfter?: number);
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Result of {@link Ozura.createSession} / {@link Ozura.mintWaxKey}.
|
|
63
|
+
*/
|
|
64
|
+
export interface CreateSessionResult {
|
|
65
|
+
/** Session key — the SDK transmits this on every tokenize call. */
|
|
66
|
+
sessionKey: string;
|
|
67
|
+
/** Seconds until the session expires. Typically 1800 (30 min). */
|
|
65
68
|
expiresInSeconds: number;
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
|
-
* Options for {@link Ozura.mintWaxKey}.
|
|
71
|
+
* Options for {@link Ozura.createSession} / {@link Ozura.mintWaxKey}.
|
|
69
72
|
*/
|
|
70
|
-
export interface
|
|
73
|
+
export interface CreateSessionOptions {
|
|
71
74
|
/**
|
|
72
|
-
* SDK-generated session UUID forwarded from the `
|
|
73
|
-
* Stored by the vault for correlation and audit
|
|
75
|
+
* SDK-generated session UUID forwarded from the `getSessionKey` /
|
|
76
|
+
* `fetchWaxKey` callback. Stored by the vault for correlation and audit.
|
|
74
77
|
*/
|
|
75
|
-
|
|
78
|
+
sessionId?: string;
|
|
76
79
|
/**
|
|
77
|
-
* Maximum number of
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
+
* Maximum number of card submissions this session accepts before the SDK
|
|
81
|
+
* automatically refreshes it. Keep this in sync with `sessionLimit` in
|
|
82
|
+
* `VaultOptions` so the client can proactively refresh without a user-
|
|
83
|
+
* visible delay.
|
|
80
84
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
85
|
+
* Pass `null` to remove the cap entirely (the vault will accept unlimited
|
|
86
|
+
* tokenize calls until the session TTL elapses). Only do this for flows
|
|
87
|
+
* where the same session genuinely needs more than 3 submissions.
|
|
84
88
|
*
|
|
85
89
|
* @default 3
|
|
86
90
|
*/
|
|
87
|
-
|
|
91
|
+
sessionLimit?: number | null;
|
|
88
92
|
/**
|
|
89
|
-
* Maximum number of proxy calls this
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
* Maximum number of proxy calls this session accepts.
|
|
94
|
+
* Only relevant if you use vault proxy endpoints directly.
|
|
95
|
+
* Pass `null` to remove the proxy cap.
|
|
96
|
+
*/
|
|
97
|
+
maxProxyCalls?: number | null;
|
|
98
|
+
/**
|
|
99
|
+
* Your internal order or checkout ID. Stored alongside the session in the
|
|
100
|
+
* vault audit log so you can correlate vault events with your own records.
|
|
101
|
+
*/
|
|
102
|
+
orderId?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Your internal customer ID. Stored in the vault audit log for correlation.
|
|
105
|
+
*/
|
|
106
|
+
customerId?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Your internal cart or basket ID. Stored in the vault audit log for correlation.
|
|
95
109
|
*/
|
|
110
|
+
cartId?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Arbitrary key/value metadata (string values only) stored with the session
|
|
113
|
+
* in the vault audit log. Max 16 keys, 64-char keys, 256-char values.
|
|
114
|
+
*/
|
|
115
|
+
metadata?: Record<string, string>;
|
|
116
|
+
/**
|
|
117
|
+
* Session lifetime in seconds (60–1800). Defaults to 1800 (30 minutes).
|
|
118
|
+
* Only set this if your checkout flow is shorter than 30 minutes and you want
|
|
119
|
+
* the session to expire sooner as a defense-in-depth measure.
|
|
120
|
+
*/
|
|
121
|
+
ttlSeconds?: number;
|
|
122
|
+
}
|
|
123
|
+
/** @deprecated Use {@link CreateSessionResult} instead. */
|
|
124
|
+
export interface MintWaxKeyResult {
|
|
125
|
+
/** @deprecated Use `sessionKey` from {@link CreateSessionResult} instead. */
|
|
126
|
+
waxKey: string;
|
|
127
|
+
/** Seconds until the session expires. Typically 1800 (30 min). */
|
|
128
|
+
expiresInSeconds: number;
|
|
129
|
+
}
|
|
130
|
+
/** @deprecated Use {@link CreateSessionOptions} instead. */
|
|
131
|
+
export interface MintWaxKeyOptions {
|
|
132
|
+
/** @deprecated Use `sessionId` from {@link CreateSessionOptions} instead. */
|
|
133
|
+
tokenizationSessionId?: string;
|
|
134
|
+
/** @deprecated Use `sessionLimit` from {@link CreateSessionOptions} instead. */
|
|
135
|
+
maxTokenizeCalls?: number;
|
|
96
136
|
maxProxyCalls?: number;
|
|
97
137
|
}
|
|
98
138
|
export interface CardSaleInput {
|
|
@@ -155,48 +195,52 @@ export declare class Ozura {
|
|
|
155
195
|
*/
|
|
156
196
|
listTransactions(input?: ListTransactionsInput): Promise<ListTransactionsResult>;
|
|
157
197
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* Call this server-side to implement the `fetchWaxKey` callback required by
|
|
161
|
-
* `OzVault.create()` on the frontend. The wax key replaces the vault secret
|
|
162
|
-
* on every browser tokenize call — the secret never leaves your server.
|
|
198
|
+
* Creates a short-lived payment session key from the vault.
|
|
163
199
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* `VaultOptions.maxTokenizeCalls` so the SDK can proactively refresh before
|
|
168
|
-
* hitting the limit rather than waiting for a rejection.
|
|
200
|
+
* Call this from your session endpoint (created with `createSessionMiddleware`
|
|
201
|
+
* or `createSessionHandler`) to issue a key that the frontend SDK will use for
|
|
202
|
+
* tokenization. The vault secret never leaves your server.
|
|
169
203
|
*
|
|
170
|
-
* **
|
|
171
|
-
*
|
|
172
|
-
*
|
|
204
|
+
* **Use limits:** each session key accepts up to `sessionLimit` (default 3)
|
|
205
|
+
* card submissions. After that the SDK automatically fetches a new session.
|
|
206
|
+
* Set `sessionLimit` to the same value in `VaultOptions` / `OzElementsProps`
|
|
207
|
+
* so the client can refresh proactively before hitting the limit.
|
|
173
208
|
*
|
|
174
209
|
* @example
|
|
175
|
-
* // Next.js
|
|
210
|
+
* // Manual route (Next.js App Router)
|
|
176
211
|
* export async function POST(req: Request) {
|
|
177
212
|
* const { sessionId } = await req.json();
|
|
178
|
-
* const {
|
|
179
|
-
*
|
|
180
|
-
* maxTokenizeCalls: 3,
|
|
181
|
-
* });
|
|
182
|
-
* return Response.json({ waxKey });
|
|
213
|
+
* const { sessionKey } = await ozura.createSession({ sessionId });
|
|
214
|
+
* return Response.json({ sessionKey });
|
|
183
215
|
* }
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* // One-liner with createSessionMiddleware (Express)
|
|
219
|
+
* app.post('/api/oz-session', createSessionMiddleware(ozura));
|
|
184
220
|
*/
|
|
185
|
-
|
|
221
|
+
createSession(options?: CreateSessionOptions): Promise<CreateSessionResult>;
|
|
186
222
|
/**
|
|
187
|
-
*
|
|
223
|
+
* Revokes a payment session key.
|
|
188
224
|
*
|
|
189
|
-
* Best-effort: never throws. Call this when the user's
|
|
190
|
-
* complete, cancelled, or
|
|
191
|
-
* vault TTL (30 min) elapses.
|
|
225
|
+
* Best-effort: never throws. Call this when the user's checkout ends (payment
|
|
226
|
+
* complete, cancelled, or abandoned) to close the key's exposure window before
|
|
227
|
+
* the vault TTL (30 min) elapses.
|
|
192
228
|
*
|
|
193
229
|
* - 200 = revoked successfully.
|
|
194
230
|
* - 404 = key already expired or not found — treated as success.
|
|
195
|
-
* - 503 = Redis error; the
|
|
231
|
+
* - 503 = Redis error; the key may still be valid. Retry if needed.
|
|
196
232
|
*
|
|
197
233
|
* @example
|
|
198
234
|
* // After a successful card sale:
|
|
199
|
-
* await ozura.
|
|
235
|
+
* await ozura.revokeSession(sessionKey);
|
|
236
|
+
*/
|
|
237
|
+
revokeSession(sessionKey: string): Promise<void>;
|
|
238
|
+
/**
|
|
239
|
+
* @deprecated Use {@link createSession} instead.
|
|
240
|
+
*/
|
|
241
|
+
mintWaxKey(options?: MintWaxKeyOptions): Promise<MintWaxKeyResult>;
|
|
242
|
+
/**
|
|
243
|
+
* @deprecated Use {@link revokeSession} instead.
|
|
200
244
|
*/
|
|
201
245
|
revokeWaxKey(waxKey: string): Promise<void>;
|
|
202
246
|
/**
|
|
@@ -214,7 +258,7 @@ export declare class Ozura {
|
|
|
214
258
|
*/
|
|
215
259
|
private parseApiJson;
|
|
216
260
|
}
|
|
217
|
-
/** Minimal response shape required by {@link
|
|
261
|
+
/** Minimal response shape required by {@link createSessionMiddleware}. */
|
|
218
262
|
interface NodeLikeResponse {
|
|
219
263
|
json(data: unknown): void;
|
|
220
264
|
status(code: number): NodeLikeResponse;
|
|
@@ -222,52 +266,60 @@ interface NodeLikeResponse {
|
|
|
222
266
|
setHeader?(name: string, value: string | number): void;
|
|
223
267
|
}
|
|
224
268
|
/**
|
|
225
|
-
* Creates a ready-to-use Fetch API route handler for
|
|
269
|
+
* Creates a ready-to-use Fetch API route handler for payment session creation.
|
|
226
270
|
*
|
|
227
271
|
* Drop-in for Next.js App Router, Cloudflare Workers, Vercel Edge, and any
|
|
228
272
|
* runtime built on the standard Web API `Request` / `Response`.
|
|
229
273
|
*
|
|
230
|
-
* The handler reads `sessionId`
|
|
231
|
-
*
|
|
274
|
+
* The handler reads `sessionId` from the JSON request body, calls
|
|
275
|
+
* `ozura.createSession()`, and returns `{ sessionKey }`.
|
|
232
276
|
* On error it returns `{ error }` with an appropriate HTTP status.
|
|
233
277
|
*
|
|
234
|
-
*
|
|
235
|
-
* // app/api/mint-wax/route.ts (Next.js App Router)
|
|
236
|
-
* import { Ozura, createMintWaxHandler } from '@ozura/elements/server';
|
|
278
|
+
* Pair with `sessionUrl` on the frontend — no other configuration needed.
|
|
237
279
|
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* vaultKey: process.env.VAULT_API_KEY!,
|
|
242
|
-
* });
|
|
280
|
+
* @example
|
|
281
|
+
* // app/api/oz-session/route.ts (Next.js App Router)
|
|
282
|
+
* import { Ozura, createSessionHandler } from '@ozura/elements/server';
|
|
243
283
|
*
|
|
244
|
-
*
|
|
284
|
+
* const ozura = new Ozura({ vaultKey: process.env.VAULT_API_KEY! });
|
|
285
|
+
* export const POST = createSessionHandler(ozura);
|
|
245
286
|
*/
|
|
246
|
-
export declare function
|
|
287
|
+
export declare function createSessionHandler(ozura: Ozura): (req: Request) => Promise<Response>;
|
|
247
288
|
/**
|
|
248
|
-
* Creates a ready-to-use Express / Connect middleware for
|
|
289
|
+
* Creates a ready-to-use Express / Connect middleware for payment session creation.
|
|
249
290
|
*
|
|
250
291
|
* Requires `express.json()` (or equivalent body-parser) to be registered
|
|
251
292
|
* before this middleware so `req.body` is available.
|
|
252
293
|
*
|
|
253
|
-
* The middleware reads `sessionId`
|
|
254
|
-
* `
|
|
294
|
+
* The middleware reads `sessionId` from `req.body`, calls
|
|
295
|
+
* `ozura.createSession()`, and sends `{ sessionKey }`.
|
|
255
296
|
* On error it sends `{ error }` with an appropriate HTTP status.
|
|
256
297
|
*
|
|
298
|
+
* Pair with `sessionUrl` on the frontend — no other configuration needed.
|
|
299
|
+
*
|
|
257
300
|
* @example
|
|
258
301
|
* // Express
|
|
259
302
|
* import express from 'express';
|
|
260
|
-
* import { Ozura,
|
|
303
|
+
* import { Ozura, createSessionMiddleware } from '@ozura/elements/server';
|
|
261
304
|
*
|
|
262
|
-
* const ozura = new Ozura({
|
|
263
|
-
* merchantId: process.env.MERCHANT_ID!,
|
|
264
|
-
* apiKey: process.env.MERCHANT_API_KEY!,
|
|
265
|
-
* vaultKey: process.env.VAULT_API_KEY!,
|
|
266
|
-
* });
|
|
305
|
+
* const ozura = new Ozura({ vaultKey: process.env.VAULT_API_KEY! });
|
|
267
306
|
*
|
|
268
307
|
* const app = express();
|
|
269
308
|
* app.use(express.json());
|
|
270
|
-
* app.post('/api/
|
|
309
|
+
* app.post('/api/oz-session', createSessionMiddleware(ozura));
|
|
310
|
+
*/
|
|
311
|
+
export declare function createSessionMiddleware(ozura: Ozura): (req: {
|
|
312
|
+
body?: unknown;
|
|
313
|
+
headers?: unknown;
|
|
314
|
+
}, res: NodeLikeResponse) => Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* @deprecated Use {@link createSessionHandler} instead.
|
|
317
|
+
* Returns `{ waxKey }` for backward compatibility with old `createFetchWaxKey` backends.
|
|
318
|
+
*/
|
|
319
|
+
export declare function createMintWaxHandler(ozura: Ozura): (req: Request) => Promise<Response>;
|
|
320
|
+
/**
|
|
321
|
+
* @deprecated Use {@link createSessionMiddleware} instead.
|
|
322
|
+
* Sends `{ waxKey }` for backward compatibility with old `createFetchWaxKey` clients.
|
|
271
323
|
*/
|
|
272
324
|
export declare function createMintWaxMiddleware(ozura: Ozura): (req: {
|
|
273
325
|
body?: unknown;
|
|
@@ -156,35 +156,49 @@ export interface VaultOptions {
|
|
|
156
156
|
* Sent as the `X-Pub-Key` header on tokenize requests. */
|
|
157
157
|
pubKey: string;
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* wax key from the vault using your vault secret and return it here.
|
|
159
|
+
* URL of your backend session endpoint. The simplest way to connect the SDK
|
|
160
|
+
* to your server — just pass the path and the SDK handles everything else.
|
|
162
161
|
*
|
|
163
|
-
* The
|
|
164
|
-
*
|
|
165
|
-
* never leaves your server.
|
|
162
|
+
* The endpoint should be created with `createSessionMiddleware` or
|
|
163
|
+
* `createSessionHandler` from `@ozura/elements/server`.
|
|
166
164
|
*
|
|
167
|
-
* **Server-side (recommended):** Use `ozura.mintWaxKey()` from `@ozura/elements/server`:
|
|
168
165
|
* @example
|
|
169
|
-
* //
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* //
|
|
173
|
-
*
|
|
166
|
+
* // Backend (Express)
|
|
167
|
+
* app.post('/api/oz-session', createSessionMiddleware(ozura));
|
|
168
|
+
*
|
|
169
|
+
* // Frontend
|
|
170
|
+
* OzVault.create({ pubKey: 'pk_live_...', sessionUrl: '/api/oz-session' })
|
|
171
|
+
*/
|
|
172
|
+
sessionUrl?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Custom async function to obtain a session key from your backend.
|
|
175
|
+
* Use this when you need custom headers, auth tokens, or request logic that
|
|
176
|
+
* `sessionUrl` cannot provide.
|
|
177
|
+
*
|
|
178
|
+
* Receives an SDK-generated session UUID; your implementation passes it to
|
|
179
|
+
* your backend, which calls `ozura.createSession()` and returns the key.
|
|
180
|
+
*
|
|
181
|
+
* For the common case, prefer `sessionUrl` — it wraps this automatically.
|
|
174
182
|
*
|
|
175
|
-
* **Client-side (fetchWaxKey callback):**
|
|
176
183
|
* @example
|
|
177
|
-
*
|
|
178
|
-
* const res = await fetch('/api/
|
|
184
|
+
* getSessionKey: async (sessionId) => {
|
|
185
|
+
* const res = await fetch('/api/oz-session', {
|
|
179
186
|
* method: 'POST',
|
|
180
|
-
* headers: { 'Content-Type': 'application/json' },
|
|
187
|
+
* headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` },
|
|
181
188
|
* body: JSON.stringify({ sessionId }),
|
|
182
189
|
* });
|
|
183
|
-
* const {
|
|
184
|
-
* return
|
|
190
|
+
* const { sessionKey } = await res.json();
|
|
191
|
+
* return sessionKey;
|
|
185
192
|
* }
|
|
186
193
|
*/
|
|
187
|
-
|
|
194
|
+
getSessionKey?: (sessionId: string) => Promise<string>;
|
|
195
|
+
/**
|
|
196
|
+
* @deprecated Use `sessionUrl` or `getSessionKey` instead.
|
|
197
|
+
*
|
|
198
|
+
* Legacy callback name. Equivalent to `getSessionKey` — both are supported
|
|
199
|
+
* and work identically. `fetchWaxKey` will be removed in a future major version.
|
|
200
|
+
*/
|
|
201
|
+
fetchWaxKey?: (tokenizationSessionId: string) => Promise<string>;
|
|
188
202
|
/** Base URL where the Ozura frame HTML/JS assets are served from.
|
|
189
203
|
* Defaults to the production CDN. Override for local development. */
|
|
190
204
|
frameBaseUrl?: string;
|
|
@@ -211,25 +225,36 @@ export interface VaultOptions {
|
|
|
211
225
|
* Only takes effect when `onLoadError` is also provided — setting this without `onLoadError` has no effect. */
|
|
212
226
|
loadTimeoutMs?: number;
|
|
213
227
|
/**
|
|
214
|
-
* Called when the SDK silently
|
|
215
|
-
*
|
|
216
|
-
* promise stays pending until the refresh completes
|
|
217
|
-
* Use this to show a loading indicator while the
|
|
228
|
+
* Called when the SDK silently refreshes the payment session mid-checkout
|
|
229
|
+
* (e.g. after the session is consumed or expires). The `createToken()` /
|
|
230
|
+
* `createBankToken()` promise stays pending until the refresh completes.
|
|
231
|
+
* Use this to show a loading indicator while the refresh is in progress.
|
|
232
|
+
*/
|
|
233
|
+
onSessionRefresh?: () => void;
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated Use `onSessionRefresh` instead.
|
|
218
236
|
*/
|
|
219
237
|
onWaxRefresh?: () => void;
|
|
220
238
|
/**
|
|
221
|
-
* Maximum number of
|
|
222
|
-
*
|
|
223
|
-
*
|
|
239
|
+
* Maximum number of card submissions allowed per session before the SDK
|
|
240
|
+
* automatically refreshes the session in the background. Defaults to `3`.
|
|
241
|
+
*
|
|
242
|
+
* Must match the `sessionLimit` (or `maxTokenizeCalls`) passed to
|
|
243
|
+
* `ozura.createSession()` on your server. Both default to `3` so you only
|
|
244
|
+
* need this if you override the server-side value.
|
|
224
245
|
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* sync the reactive refresh path still catches consumption errors; this is
|
|
229
|
-
* purely an optimisation.
|
|
246
|
+
* Pass `null` to disable the proactive refresh cap entirely (unlimited
|
|
247
|
+
* tokenizations per session). Only use this when your server-side
|
|
248
|
+
* `createSession()` also passes `sessionLimit: null`.
|
|
230
249
|
*
|
|
231
250
|
* @default 3
|
|
232
251
|
*/
|
|
252
|
+
sessionLimit?: number | null;
|
|
253
|
+
/**
|
|
254
|
+
* @deprecated Use `sessionLimit` instead.
|
|
255
|
+
* Maximum number of tokenize calls per session. Equivalent to `sessionLimit`.
|
|
256
|
+
* @default 3
|
|
257
|
+
*/
|
|
233
258
|
maxTokenizeCalls?: number;
|
|
234
259
|
/**
|
|
235
260
|
* Called once when the tokenizer iframe has loaded and is ready to accept
|