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