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