@ozura/elements 1.3.1-next.75 → 1.3.1-next.77
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 +17 -5
- package/dist/oz-elements.esm.js.map +1 -1
- package/dist/oz-elements.umd.js +17 -5
- package/dist/oz-elements.umd.js.map +1 -1
- package/dist/react/index.cjs.js +17 -5
- package/dist/react/index.cjs.js.map +1 -1
- package/dist/react/index.esm.js +17 -5
- package/dist/react/index.esm.js.map +1 -1
- package/dist/react/react/index.d.ts +1 -1
- package/dist/react/sdk/OzVault.d.ts +2 -0
- package/dist/react/types/index.d.ts +7 -4
- package/dist/react/vue/index.d.ts +1 -1
- package/dist/server/sdk/OzVault.d.ts +2 -0
- package/dist/server/types/index.d.ts +7 -4
- package/dist/server/vue/index.d.ts +1 -1
- package/dist/types/sdk/OzVault.d.ts +2 -0
- package/dist/types/types/index.d.ts +7 -4
- package/dist/types/vue/index.d.ts +1 -1
- package/dist/vue/index.cjs.js +17 -5
- package/dist/vue/index.cjs.js.map +1 -1
- package/dist/vue/index.esm.js +17 -5
- package/dist/vue/index.esm.js.map +1 -1
- package/dist/vue/sdk/OzVault.d.ts +2 -0
- package/dist/vue/types/index.d.ts +7 -4
- package/dist/vue/utils/cardUtils.d.ts +51 -0
- package/dist/vue/vue/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { CardBrand } from '../utils/cardUtils';
|
|
2
|
+
export type { CardBrand } from '../utils/cardUtils';
|
|
1
3
|
export interface ElementStyle {
|
|
2
4
|
color?: string;
|
|
3
5
|
fontSize?: string;
|
|
@@ -99,12 +101,13 @@ export interface FieldState {
|
|
|
99
101
|
/** Present when valid is false and the field has been touched. */
|
|
100
102
|
error?: string;
|
|
101
103
|
/** Card brand — cardNumber field only. */
|
|
102
|
-
cardBrand?:
|
|
104
|
+
cardBrand?: CardBrand;
|
|
103
105
|
}
|
|
104
106
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
107
|
+
* Latest state of each field, keyed by element type. Keys are optional because a
|
|
108
|
+
* given form may not create every field (e.g. a card-only form has no bank keys);
|
|
109
|
+
* access with `?.`. At runtime, every field that has been created is present —
|
|
110
|
+
* from creation onward, starting at the default until its first change.
|
|
108
111
|
*/
|
|
109
112
|
export type FieldStatesSnapshot = Partial<Record<ElementType | BankElementType, FieldState>>;
|
|
110
113
|
export type ElementType = 'cardNumber' | 'cvv' | 'expirationDate';
|
|
@@ -371,4 +371,4 @@ export declare const OzBankRoutingNumber: import("vue").DefineComponent<{
|
|
|
371
371
|
placeholder: string;
|
|
372
372
|
disabled: boolean;
|
|
373
373
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
374
|
-
export type { ElementChangeEvent, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, Appearance, FontSource, FieldState, FieldStatesSnapshot, } from '../types';
|
|
374
|
+
export type { ElementChangeEvent, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, Appearance, FontSource, FieldState, FieldStatesSnapshot, CardBrand, } from '../types';
|
|
@@ -132,6 +132,8 @@ export declare class OzVault {
|
|
|
132
132
|
get isBankComplete(): boolean;
|
|
133
133
|
/** True iff the set is non-empty and every element has reported complete-and-valid. */
|
|
134
134
|
private allComplete;
|
|
135
|
+
/** The state a field reports before its first change event (and after reset/reload). */
|
|
136
|
+
private makeDefaultFieldState;
|
|
135
137
|
/**
|
|
136
138
|
* Snapshot of every created field's latest state, keyed by element type.
|
|
137
139
|
* Card and bank fields are combined (their type keys never collide). Useful for
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { CardBrand } from '../utils/cardUtils';
|
|
2
|
+
export type { CardBrand } from '../utils/cardUtils';
|
|
1
3
|
export interface ElementStyle {
|
|
2
4
|
color?: string;
|
|
3
5
|
fontSize?: string;
|
|
@@ -99,12 +101,13 @@ export interface FieldState {
|
|
|
99
101
|
/** Present when valid is false and the field has been touched. */
|
|
100
102
|
error?: string;
|
|
101
103
|
/** Card brand — cardNumber field only. */
|
|
102
|
-
cardBrand?:
|
|
104
|
+
cardBrand?: CardBrand;
|
|
103
105
|
}
|
|
104
106
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
107
|
+
* Latest state of each field, keyed by element type. Keys are optional because a
|
|
108
|
+
* given form may not create every field (e.g. a card-only form has no bank keys);
|
|
109
|
+
* access with `?.`. At runtime, every field that has been created is present —
|
|
110
|
+
* from creation onward, starting at the default until its first change.
|
|
108
111
|
*/
|
|
109
112
|
export type FieldStatesSnapshot = Partial<Record<ElementType | BankElementType, FieldState>>;
|
|
110
113
|
export type ElementType = 'cardNumber' | 'cvv' | 'expirationDate';
|
|
@@ -371,4 +371,4 @@ export declare const OzBankRoutingNumber: import("vue").DefineComponent<{
|
|
|
371
371
|
placeholder: string;
|
|
372
372
|
disabled: boolean;
|
|
373
373
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
374
|
-
export type { ElementChangeEvent, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, Appearance, FontSource, FieldState, FieldStatesSnapshot, } from '../types';
|
|
374
|
+
export type { ElementChangeEvent, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, Appearance, FontSource, FieldState, FieldStatesSnapshot, CardBrand, } from '../types';
|
|
@@ -132,6 +132,8 @@ export declare class OzVault {
|
|
|
132
132
|
get isBankComplete(): boolean;
|
|
133
133
|
/** True iff the set is non-empty and every element has reported complete-and-valid. */
|
|
134
134
|
private allComplete;
|
|
135
|
+
/** The state a field reports before its first change event (and after reset/reload). */
|
|
136
|
+
private makeDefaultFieldState;
|
|
135
137
|
/**
|
|
136
138
|
* Snapshot of every created field's latest state, keyed by element type.
|
|
137
139
|
* Card and bank fields are combined (their type keys never collide). Useful for
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { CardBrand } from '../utils/cardUtils';
|
|
2
|
+
export type { CardBrand } from '../utils/cardUtils';
|
|
1
3
|
export interface ElementStyle {
|
|
2
4
|
color?: string;
|
|
3
5
|
fontSize?: string;
|
|
@@ -99,12 +101,13 @@ export interface FieldState {
|
|
|
99
101
|
/** Present when valid is false and the field has been touched. */
|
|
100
102
|
error?: string;
|
|
101
103
|
/** Card brand — cardNumber field only. */
|
|
102
|
-
cardBrand?:
|
|
104
|
+
cardBrand?: CardBrand;
|
|
103
105
|
}
|
|
104
106
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
107
|
+
* Latest state of each field, keyed by element type. Keys are optional because a
|
|
108
|
+
* given form may not create every field (e.g. a card-only form has no bank keys);
|
|
109
|
+
* access with `?.`. At runtime, every field that has been created is present —
|
|
110
|
+
* from creation onward, starting at the default until its first change.
|
|
108
111
|
*/
|
|
109
112
|
export type FieldStatesSnapshot = Partial<Record<ElementType | BankElementType, FieldState>>;
|
|
110
113
|
export type ElementType = 'cardNumber' | 'cvv' | 'expirationDate';
|
|
@@ -371,4 +371,4 @@ export declare const OzBankRoutingNumber: import("vue").DefineComponent<{
|
|
|
371
371
|
placeholder: string;
|
|
372
372
|
disabled: boolean;
|
|
373
373
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
374
|
-
export type { ElementChangeEvent, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, Appearance, FontSource, FieldState, FieldStatesSnapshot, } from '../types';
|
|
374
|
+
export type { ElementChangeEvent, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, Appearance, FontSource, FieldState, FieldStatesSnapshot, CardBrand, } from '../types';
|
package/dist/vue/index.cjs.js
CHANGED
|
@@ -1283,6 +1283,10 @@ class OzVault {
|
|
|
1283
1283
|
return false;
|
|
1284
1284
|
return els.every(el => this.completionState.get(el.frameId) === true);
|
|
1285
1285
|
}
|
|
1286
|
+
/** The state a field reports before its first change event (and after reset/reload). */
|
|
1287
|
+
makeDefaultFieldState() {
|
|
1288
|
+
return { empty: true, complete: false, valid: false };
|
|
1289
|
+
}
|
|
1286
1290
|
/**
|
|
1287
1291
|
* Snapshot of every created field's latest state, keyed by element type.
|
|
1288
1292
|
* Card and bank fields are combined (their type keys never collide). Useful for
|
|
@@ -1294,10 +1298,10 @@ class OzVault {
|
|
|
1294
1298
|
var _a, _b;
|
|
1295
1299
|
const snapshot = {};
|
|
1296
1300
|
for (const [type, el] of this.elementsByType) {
|
|
1297
|
-
snapshot[type] = Object.assign({}, ((_a = this.fieldStates.get(el.frameId)) !== null && _a !== void 0 ? _a :
|
|
1301
|
+
snapshot[type] = Object.assign({}, ((_a = this.fieldStates.get(el.frameId)) !== null && _a !== void 0 ? _a : this.makeDefaultFieldState()));
|
|
1298
1302
|
}
|
|
1299
1303
|
for (const [type, el] of this.bankElementsByType) {
|
|
1300
|
-
snapshot[type] = Object.assign({}, ((_b = this.fieldStates.get(el.frameId)) !== null && _b !== void 0 ? _b :
|
|
1304
|
+
snapshot[type] = Object.assign({}, ((_b = this.fieldStates.get(el.frameId)) !== null && _b !== void 0 ? _b : this.makeDefaultFieldState()));
|
|
1301
1305
|
}
|
|
1302
1306
|
return snapshot;
|
|
1303
1307
|
}
|
|
@@ -1365,7 +1369,7 @@ class OzVault {
|
|
|
1365
1369
|
}, this._debug);
|
|
1366
1370
|
this.elements.set(el.frameId, el);
|
|
1367
1371
|
typeMap.set(type, el);
|
|
1368
|
-
this.fieldStates.set(el.frameId,
|
|
1372
|
+
this.fieldStates.set(el.frameId, this.makeDefaultFieldState());
|
|
1369
1373
|
return el;
|
|
1370
1374
|
}
|
|
1371
1375
|
/**
|
|
@@ -1667,7 +1671,7 @@ class OzVault {
|
|
|
1667
1671
|
}
|
|
1668
1672
|
// Mirror for field states: every created field returns to its default.
|
|
1669
1673
|
for (const frameId of this.fieldStates.keys()) {
|
|
1670
|
-
this.fieldStates.set(frameId,
|
|
1674
|
+
this.fieldStates.set(frameId, this.makeDefaultFieldState());
|
|
1671
1675
|
}
|
|
1672
1676
|
// NOTE: _tokenizeSuccessCount is intentionally NOT reset.
|
|
1673
1677
|
// It reflects real server-side wax key budget consumption. Zeroing it
|
|
@@ -1878,6 +1882,10 @@ class OzVault {
|
|
|
1878
1882
|
// the previous session and justCompleted never fires, breaking auto-advance.
|
|
1879
1883
|
if (msg.type === 'OZ_FRAME_READY') {
|
|
1880
1884
|
this.completionState.set(frameId, false);
|
|
1885
|
+
// Mirror the completion reset: a reloaded iframe starts empty, so the
|
|
1886
|
+
// field state must return to default rather than serving pre-reload data
|
|
1887
|
+
// (e.g. a stale card brand) until the next OZ_CHANGE arrives.
|
|
1888
|
+
this.fieldStates.set(frameId, this.makeDefaultFieldState());
|
|
1881
1889
|
if (msg.__ozVersion !== PROTOCOL_VERSION) {
|
|
1882
1890
|
console.warn(`[OzVault] Protocol version mismatch on element frame "${frameId}" — ` +
|
|
1883
1891
|
`SDK expects v${PROTOCOL_VERSION}, frame reported v${typeof msg.__ozVersion === 'number' ? msg.__ozVersion : '(none)'}. ` +
|
|
@@ -1919,9 +1927,13 @@ class OzVault {
|
|
|
1919
1927
|
var _a, _b, _c;
|
|
1920
1928
|
const complete = msg.complete;
|
|
1921
1929
|
const valid = msg.valid;
|
|
1930
|
+
// Narrow rather than blind-cast: a malformed/legacy frame that omits `empty`
|
|
1931
|
+
// must not write `undefined` into the public FieldState contract.
|
|
1932
|
+
const empty = typeof msg.empty === 'boolean' ? msg.empty : true;
|
|
1922
1933
|
const wasComplete = (_a = this.completionState.get(el.frameId)) !== null && _a !== void 0 ? _a : false;
|
|
1923
1934
|
this.completionState.set(el.frameId, complete && valid);
|
|
1924
|
-
this.fieldStates.set(el.frameId, Object.assign(Object.assign({ empty
|
|
1935
|
+
this.fieldStates.set(el.frameId, Object.assign(Object.assign({ empty,
|
|
1936
|
+
complete,
|
|
1925
1937
|
valid }, (typeof msg.error === 'string' ? { error: msg.error } : {})), (typeof msg.cardBrand === 'string' ? { cardBrand: msg.cardBrand } : {})));
|
|
1926
1938
|
// Require valid too — avoids advancing at 13 digits for unknown-brand cards
|
|
1927
1939
|
// where isComplete() fires before the user has finished typing.
|