@ozura/elements 1.2.4-next.56 → 1.2.4-next.58

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.
@@ -1035,7 +1035,7 @@ const DEFAULT_FRAME_BASE_URL = "https://lively-hill-097170c0f.4.azurestaticapps.
1035
1035
  * @example
1036
1036
  * // Recommended — pass sessionUrl and let the SDK call your backend automatically
1037
1037
  * const vault = await OzVault.create({
1038
- * pubKey: 'pk_prod_...', // or 'pk_test_...' for test mode
1038
+ * pubKey: 'pk_prod_...', // omit for test vault keys; required for production
1039
1039
  * sessionUrl: '/api/oz-session', // backend endpoint that calls ozura.createSession()
1040
1040
  * });
1041
1041
  * const cardNum = vault.createElement('cardNumber');
@@ -1143,8 +1143,15 @@ class OzVault {
1143
1143
  * @throws {OzError} if the session fetch fails, times out, or returns an empty string.
1144
1144
  */
1145
1145
  static async create(options, signal) {
1146
- if (!options.pubKey || !options.pubKey.trim()) {
1147
- throw new OzError('pubKey is required in options. Obtain your public key from the Ozura admin.');
1146
+ // pubKey is optional — test vault keys (from a Test project on the vault)
1147
+ // do not require a pub key. Production keys do. If provided, it must be
1148
+ // non-empty after trimming; if omitted entirely, warn but continue.
1149
+ if (options.pubKey !== undefined && !options.pubKey.trim()) {
1150
+ throw new OzError('pubKey must be a non-empty string. Omit the option entirely to use a test vault key.');
1151
+ }
1152
+ if (options.pubKey === undefined) {
1153
+ console.warn('[OzVault] pubKey not provided — this only works with a test vault key from a Test project on the vault. ' +
1154
+ 'For production, set pubKey to your pk_live_... or pk_prod_... value.');
1148
1155
  }
1149
1156
  // Normalize the session callback. Priority: sessionUrl > getSessionKey > fetchWaxKey (deprecated).
1150
1157
  // This allows merchants to use the clean new API without touching legacy code.
@@ -1353,6 +1360,7 @@ class OzVault {
1353
1360
  const requestId = `req-${uuid()}`;
1354
1361
  this.log('createBankToken() called');
1355
1362
  return new Promise((resolve, reject) => {
1363
+ var _a;
1356
1364
  const resetCountAtStart = this._resetCount;
1357
1365
  const cleanup = () => {
1358
1366
  if (this._resetCount === resetCountAtStart)
@@ -1373,7 +1381,7 @@ class OzVault {
1373
1381
  type: 'OZ_BANK_TOKENIZE',
1374
1382
  requestId,
1375
1383
  tokenizationSessionId: this.tokenizationSessionId,
1376
- pubKey: this.pubKey,
1384
+ pubKey: (_a = this.pubKey) !== null && _a !== void 0 ? _a : '',
1377
1385
  firstName: options.firstName.trim(),
1378
1386
  lastName: options.lastName.trim(),
1379
1387
  fieldCount: readyBankElements.length,
@@ -1472,6 +1480,7 @@ class OzVault {
1472
1480
  billingPresent: Boolean(options.billing),
1473
1481
  });
1474
1482
  return new Promise((resolve, reject) => {
1483
+ var _a;
1475
1484
  // Capture the reset generation so cleanup() only zeros _tokenizing when it
1476
1485
  // still belongs to this invocation — not a newer one that started after a reset.
1477
1486
  const resetCountAtStart = this._resetCount;
@@ -1496,7 +1505,7 @@ class OzVault {
1496
1505
  type: 'OZ_TOKENIZE',
1497
1506
  requestId,
1498
1507
  tokenizationSessionId: this.tokenizationSessionId,
1499
- pubKey: this.pubKey,
1508
+ pubKey: (_a = this.pubKey) !== null && _a !== void 0 ? _a : '',
1500
1509
  firstName,
1501
1510
  lastName,
1502
1511
  fieldCount: readyElements.length,
@@ -1944,6 +1953,7 @@ class OzVault {
1944
1953
  if (willRefresh) {
1945
1954
  const resetCountAtRetry = this._resetCount;
1946
1955
  this.refreshWaxKey().then(() => {
1956
+ var _a;
1947
1957
  if (this._destroyed) {
1948
1958
  pending.reject(new OzError('Vault destroyed during wax key refresh.'));
1949
1959
  return;
@@ -1976,7 +1986,7 @@ class OzVault {
1976
1986
  type: 'OZ_TOKENIZE',
1977
1987
  requestId: newRequestId,
1978
1988
  tokenizationSessionId: this.tokenizationSessionId,
1979
- pubKey: this.pubKey,
1989
+ pubKey: (_a = this.pubKey) !== null && _a !== void 0 ? _a : '',
1980
1990
  firstName: pending.firstName,
1981
1991
  lastName: pending.lastName,
1982
1992
  fieldCount: pending.fieldCount,
@@ -2020,6 +2030,7 @@ class OzVault {
2020
2030
  if (this.isRefreshableAuthError(errorCode, raw) && !bankPending.retried && this._storedFetchWaxKey) {
2021
2031
  const resetCountAtRetry = this._resetCount;
2022
2032
  this.refreshWaxKey().then(() => {
2033
+ var _a;
2023
2034
  if (this._destroyed) {
2024
2035
  bankPending.reject(new OzError('Vault destroyed during wax key refresh.'));
2025
2036
  return;
@@ -2042,7 +2053,7 @@ class OzVault {
2042
2053
  type: 'OZ_BANK_TOKENIZE',
2043
2054
  requestId: newRequestId,
2044
2055
  tokenizationSessionId: this.tokenizationSessionId,
2045
- pubKey: this.pubKey,
2056
+ pubKey: (_a = this.pubKey) !== null && _a !== void 0 ? _a : '',
2046
2057
  firstName: bankPending.firstName,
2047
2058
  lastName: bankPending.lastName,
2048
2059
  fieldCount: bankPending.fieldCount,