@ozura/elements 1.3.1-next.67 → 1.3.1-next.69
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/dist/frame/element-frame.js +7 -4
- package/dist/frame/element-frame.js.map +1 -1
- package/dist/frame/tokenizer-frame.js +5 -6
- package/dist/frame/tokenizer-frame.js.map +1 -1
- package/dist/oz-elements.esm.js +60 -22
- package/dist/oz-elements.esm.js.map +1 -1
- package/dist/oz-elements.umd.js +60 -22
- package/dist/oz-elements.umd.js.map +1 -1
- package/dist/react/index.cjs.js +61 -23
- package/dist/react/index.cjs.js.map +1 -1
- package/dist/react/index.esm.js +61 -23
- package/dist/react/index.esm.js.map +1 -1
- package/dist/react/react/index.d.ts +3 -1
- package/dist/react/sdk/OzVault.d.ts +23 -0
- package/dist/react/types/index.d.ts +19 -1
- package/dist/react/vue/index.d.ts +24 -1
- package/dist/server/sdk/OzVault.d.ts +23 -0
- package/dist/server/types/index.d.ts +19 -1
- package/dist/server/vue/index.d.ts +24 -1
- package/dist/types/sdk/OzVault.d.ts +23 -0
- package/dist/types/types/index.d.ts +19 -1
- package/dist/types/vue/index.d.ts +24 -1
- package/dist/vue/index.cjs.js +68 -23
- package/dist/vue/index.cjs.js.map +1 -1
- package/dist/vue/index.esm.js +68 -23
- package/dist/vue/index.esm.js.map +1 -1
- package/dist/vue/sdk/OzVault.d.ts +23 -0
- package/dist/vue/types/index.d.ts +19 -1
- package/dist/vue/vue/index.d.ts +24 -1
- package/package.json +1 -1
package/dist/react/index.esm.js
CHANGED
|
@@ -1115,7 +1115,7 @@ class OzVault {
|
|
|
1115
1115
|
this.loadErrorTimeoutId = setTimeout(() => {
|
|
1116
1116
|
this.loadErrorTimeoutId = null;
|
|
1117
1117
|
if (!this._destroyed && !this.tokenizerReady) {
|
|
1118
|
-
options.onLoadError();
|
|
1118
|
+
options.onLoadError({ source: 'tokenizer' });
|
|
1119
1119
|
}
|
|
1120
1120
|
}, timeout);
|
|
1121
1121
|
}
|
|
@@ -1248,6 +1248,39 @@ class OzVault {
|
|
|
1248
1248
|
get tokenizeCount() {
|
|
1249
1249
|
return this._tokenizeSuccessCount;
|
|
1250
1250
|
}
|
|
1251
|
+
/**
|
|
1252
|
+
* `true` when every mounted field has reported `complete && valid` via its
|
|
1253
|
+
* last `change` event. `false` if no fields have been created, or if any
|
|
1254
|
+
* field is incomplete or invalid.
|
|
1255
|
+
*
|
|
1256
|
+
* Use this to gate the pay button in vanilla JS integrations without having
|
|
1257
|
+
* to wire up individual `change` event listeners:
|
|
1258
|
+
*
|
|
1259
|
+
* @example
|
|
1260
|
+
* vault.getElement('cardNumber')!.on('change', () => {
|
|
1261
|
+
* payBtn.disabled = !vault.isComplete;
|
|
1262
|
+
* });
|
|
1263
|
+
*/
|
|
1264
|
+
get isComplete() {
|
|
1265
|
+
if (this.elements.size === 0)
|
|
1266
|
+
return false;
|
|
1267
|
+
for (const frameId of this.elements.keys()) {
|
|
1268
|
+
if (this.completionState.get(frameId) !== true)
|
|
1269
|
+
return false;
|
|
1270
|
+
}
|
|
1271
|
+
return true;
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* `true` while a `createToken()` or `createBankToken()` call is in progress
|
|
1275
|
+
* (including the transparent wax-key refresh phase). Use this to keep the pay
|
|
1276
|
+
* button disabled during tokenization to prevent double-submission.
|
|
1277
|
+
*
|
|
1278
|
+
* @example
|
|
1279
|
+
* payBtn.disabled = vault.isTokenizing;
|
|
1280
|
+
*/
|
|
1281
|
+
get isTokenizing() {
|
|
1282
|
+
return this._tokenizing !== null;
|
|
1283
|
+
}
|
|
1251
1284
|
/**
|
|
1252
1285
|
* Creates a new OzElement of the given type. Call `.mount(selector)` on the
|
|
1253
1286
|
* returned element to attach it to the DOM.
|
|
@@ -1330,17 +1363,29 @@ class OzVault {
|
|
|
1330
1363
|
? 'A card tokenization is already in progress. Wait for it to complete before calling createBankToken().'
|
|
1331
1364
|
: 'A bank tokenization is already in progress. Wait for it to complete before calling createBankToken() again.');
|
|
1332
1365
|
}
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1366
|
+
// Validate billing details if provided — billing.firstName/lastName take
|
|
1367
|
+
// precedence over the top-level params (mirrors createToken() behaviour).
|
|
1368
|
+
let normalizedBankBilling;
|
|
1369
|
+
let bankFirstName = ((_a = options.firstName) !== null && _a !== void 0 ? _a : '').trim();
|
|
1370
|
+
let bankLastName = ((_b = options.lastName) !== null && _b !== void 0 ? _b : '').trim();
|
|
1371
|
+
if (options.billing) {
|
|
1372
|
+
const result = validateBilling(options.billing);
|
|
1373
|
+
if (!result.valid) {
|
|
1374
|
+
throw new OzError(`Invalid billing details: ${result.errors.join('; ')}`);
|
|
1375
|
+
}
|
|
1376
|
+
normalizedBankBilling = result.normalized;
|
|
1377
|
+
bankFirstName = normalizedBankBilling.firstName;
|
|
1378
|
+
bankLastName = normalizedBankBilling.lastName;
|
|
1341
1379
|
}
|
|
1342
|
-
|
|
1343
|
-
|
|
1380
|
+
else {
|
|
1381
|
+
if (!bankFirstName)
|
|
1382
|
+
throw new OzError('firstName is required for bank account tokenization.');
|
|
1383
|
+
if (!bankLastName)
|
|
1384
|
+
throw new OzError('lastName is required for bank account tokenization.');
|
|
1385
|
+
if (bankFirstName.length > 50)
|
|
1386
|
+
throw new OzError('firstName must be 50 characters or fewer.');
|
|
1387
|
+
if (bankLastName.length > 50)
|
|
1388
|
+
throw new OzError('lastName must be 50 characters or fewer.');
|
|
1344
1389
|
}
|
|
1345
1390
|
const accountEl = this.bankElementsByType.get('accountNumber');
|
|
1346
1391
|
const routingEl = this.bankElementsByType.get('routingNumber');
|
|
@@ -1366,14 +1411,7 @@ class OzVault {
|
|
|
1366
1411
|
if (this._resetCount === resetCountAtStart)
|
|
1367
1412
|
this._tokenizing = null;
|
|
1368
1413
|
};
|
|
1369
|
-
this.bankTokenizeResolvers.set(requestId, {
|
|
1370
|
-
resolve: (v) => { cleanup(); resolve(v); },
|
|
1371
|
-
reject: (e) => { cleanup(); reject(e); },
|
|
1372
|
-
firstName: options.firstName.trim(),
|
|
1373
|
-
lastName: options.lastName.trim(),
|
|
1374
|
-
readyElements: readyBankElements,
|
|
1375
|
-
fieldCount: readyBankElements.length,
|
|
1376
|
-
});
|
|
1414
|
+
this.bankTokenizeResolvers.set(requestId, Object.assign(Object.assign({ resolve: (v) => { cleanup(); resolve(v); }, reject: (e) => { cleanup(); reject(e); }, firstName: bankFirstName, lastName: bankLastName }, (normalizedBankBilling ? { billing: normalizedBankBilling } : {})), { readyElements: readyBankElements, fieldCount: readyBankElements.length }));
|
|
1377
1415
|
try {
|
|
1378
1416
|
const bankChannels = readyBankElements.map(() => new MessageChannel());
|
|
1379
1417
|
const bankTokenizeStartMs = Date.now();
|
|
@@ -1382,8 +1420,8 @@ class OzVault {
|
|
|
1382
1420
|
requestId,
|
|
1383
1421
|
tokenizationSessionId: this.tokenizationSessionId,
|
|
1384
1422
|
pubKey: (_a = this.pubKey) !== null && _a !== void 0 ? _a : '',
|
|
1385
|
-
firstName:
|
|
1386
|
-
lastName:
|
|
1423
|
+
firstName: bankFirstName,
|
|
1424
|
+
lastName: bankLastName,
|
|
1387
1425
|
fieldCount: readyBankElements.length,
|
|
1388
1426
|
}, bankChannels.map(ch => ch.port1));
|
|
1389
1427
|
this.log('OZ_BANK_TOKENIZE sent', { requestIdPrefix: `${requestId.slice(0, 12)}...`, fieldCount: readyBankElements.length });
|
|
@@ -2105,7 +2143,7 @@ class OzVault {
|
|
|
2105
2143
|
break;
|
|
2106
2144
|
}
|
|
2107
2145
|
const bank = isBankAccountMetadata(msg.bank) ? msg.bank : undefined;
|
|
2108
|
-
pending.resolve(Object.assign({ token }, (bank ? { bank } : {})));
|
|
2146
|
+
pending.resolve(Object.assign(Object.assign({ token }, (bank ? { bank } : {})), (pending.billing ? { billing: pending.billing } : {})));
|
|
2109
2147
|
this.log('bank token received', {
|
|
2110
2148
|
elapsedMs: pending.tokenizeStartMs != null ? Date.now() - pending.tokenizeStartMs : null,
|
|
2111
2149
|
tokenPresent: true,
|
|
@@ -2288,7 +2326,7 @@ function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseU
|
|
|
2288
2326
|
if (loadErrorFired)
|
|
2289
2327
|
return;
|
|
2290
2328
|
loadErrorFired = true;
|
|
2291
|
-
(_a = onLoadErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onLoadErrorRef);
|
|
2329
|
+
(_a = onLoadErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onLoadErrorRef, { source: 'tokenizer' });
|
|
2292
2330
|
};
|
|
2293
2331
|
// AbortController passed to create() so that if this effect's cleanup runs
|
|
2294
2332
|
// while fetchWaxKey is still in-flight (React StrictMode double-invoke or
|