@basis-theory/web-elements 3.0.0-beta.4 → 3.0.0-beta.5
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/.vite/manifest.json +22 -11
- package/dist/basis-theory-sdk.es.js +1 -1
- package/dist/basis-theory-sdk.umd.js +1 -1
- package/dist/basis-theory-sdk.umd.js.map +1 -1
- package/dist/{create-card-B5zEHyRg.js → create-card-CB_YcP_4.js} +10 -6
- package/dist/create-card-CB_YcP_4.js.map +1 -0
- package/dist/create-card-display-kBupMJwe.js +280 -0
- package/dist/create-card-display-kBupMJwe.js.map +1 -0
- package/dist/{create-copy-button-DrAz8g0m.js → create-copy-button-2XtKTEo3.js} +5 -2
- package/dist/create-copy-button-2XtKTEo3.js.map +1 -0
- package/dist/{index-BOedIhUN.js → index-Dyy7tm5Z.js} +325 -108
- package/dist/index-Dyy7tm5Z.js.map +1 -0
- package/dist/index.d.ts +1119 -0
- package/dist/loader/basis-theory.min.js +1 -1
- package/dist/sri.json +9 -9
- package/dist/stats.html +1 -1
- package/package.json +12 -12
- package/dist/api-client/src/api-client.d.ts +0 -11
- package/dist/api-client/src/api-client.d.ts.map +0 -1
- package/dist/api-client/src/bin-lookup-transform.d.ts +0 -35
- package/dist/api-client/src/bin-lookup-transform.d.ts.map +0 -1
- package/dist/api-client/src/http-client.d.ts +0 -24
- package/dist/api-client/src/http-client.d.ts.map +0 -1
- package/dist/api-client/src/index.d.ts +0 -9
- package/dist/api-client/src/index.d.ts.map +0 -1
- package/dist/api-client/src/services/sessions.d.ts +0 -19
- package/dist/api-client/src/services/sessions.d.ts.map +0 -1
- package/dist/api-client/src/services/token-intents.d.ts +0 -17
- package/dist/api-client/src/services/token-intents.d.ts.map +0 -1
- package/dist/api-client/src/services/tokens.d.ts +0 -19
- package/dist/api-client/src/services/tokens.d.ts.map +0 -1
- package/dist/api-client/src/types.d.ts +0 -421
- package/dist/api-client/src/types.d.ts.map +0 -1
- package/dist/create-card-B5zEHyRg.js.map +0 -1
- package/dist/create-copy-button-DrAz8g0m.js.map +0 -1
- package/dist/index-BOedIhUN.js.map +0 -1
- package/dist/postmessage/src/client.d.ts +0 -7
- package/dist/postmessage/src/client.d.ts.map +0 -1
- package/dist/postmessage/src/event-map.d.ts +0 -139
- package/dist/postmessage/src/event-map.d.ts.map +0 -1
- package/dist/postmessage/src/index.d.ts +0 -9
- package/dist/postmessage/src/index.d.ts.map +0 -1
- package/dist/postmessage/src/server.d.ts +0 -11
- package/dist/postmessage/src/server.d.ts.map +0 -1
- package/dist/postmessage/src/types.d.ts +0 -75
- package/dist/postmessage/src/types.d.ts.map +0 -1
- package/dist/shared/src/api-url-resolver.d.ts +0 -22
- package/dist/shared/src/api-url-resolver.d.ts.map +0 -1
- package/dist/shared/src/debug-logger.d.ts +0 -16
- package/dist/shared/src/debug-logger.d.ts.map +0 -1
- package/dist/shared/src/deep-sanitization.d.ts +0 -24
- package/dist/shared/src/deep-sanitization.d.ts.map +0 -1
- package/dist/shared/src/errors.d.ts +0 -93
- package/dist/shared/src/errors.d.ts.map +0 -1
- package/dist/shared/src/generate-id.d.ts +0 -13
- package/dist/shared/src/generate-id.d.ts.map +0 -1
- package/dist/shared/src/index.d.ts +0 -14
- package/dist/shared/src/index.d.ts.map +0 -1
- package/dist/shared/src/logger-context.d.ts +0 -25
- package/dist/shared/src/logger-context.d.ts.map +0 -1
- package/dist/shared/src/proxy-validation.d.ts +0 -93
- package/dist/shared/src/proxy-validation.d.ts.map +0 -1
- package/dist/web-elements/src/BasisTheory.d.ts +0 -47
- package/dist/web-elements/src/BasisTheory.d.ts.map +0 -1
- package/dist/web-elements/src/basis-theory.d.ts +0 -85
- package/dist/web-elements/src/basis-theory.d.ts.map +0 -1
- package/dist/web-elements/src/elements/create-card-number.d.ts +0 -15
- package/dist/web-elements/src/elements/create-card-number.d.ts.map +0 -1
- package/dist/web-elements/src/elements/create-card.d.ts +0 -50
- package/dist/web-elements/src/elements/create-card.d.ts.map +0 -1
- package/dist/web-elements/src/elements/create-copy-button.d.ts +0 -19
- package/dist/web-elements/src/elements/create-copy-button.d.ts.map +0 -1
- package/dist/web-elements/src/elements/create-cvv.d.ts +0 -11
- package/dist/web-elements/src/elements/create-cvv.d.ts.map +0 -1
- package/dist/web-elements/src/elements/create-expiry.d.ts +0 -11
- package/dist/web-elements/src/elements/create-expiry.d.ts.map +0 -1
- package/dist/web-elements/src/elements/create-text.d.ts +0 -14
- package/dist/web-elements/src/elements/create-text.d.ts.map +0 -1
- package/dist/web-elements/src/index.d.ts +0 -27
- package/dist/web-elements/src/index.d.ts.map +0 -1
- package/dist/web-elements/src/mounter/create-mounter.d.ts +0 -11
- package/dist/web-elements/src/mounter/create-mounter.d.ts.map +0 -1
- package/dist/web-elements/src/theme/default-theme.d.ts +0 -22
- package/dist/web-elements/src/theme/default-theme.d.ts.map +0 -1
- package/dist/web-elements/src/theme/inject-theme-dark.d.ts +0 -13
- package/dist/web-elements/src/theme/inject-theme-dark.d.ts.map +0 -1
- package/dist/web-elements/src/theme/inject-theme.d.ts +0 -20
- package/dist/web-elements/src/theme/inject-theme.d.ts.map +0 -1
- package/dist/web-elements/src/types/events.d.ts +0 -165
- package/dist/web-elements/src/types/events.d.ts.map +0 -1
- package/dist/web-elements/src/types/theme.d.ts +0 -91
- package/dist/web-elements/src/types/theme.d.ts.map +0 -1
- package/dist/web-elements/src/types.d.ts +0 -667
- package/dist/web-elements/src/types.d.ts.map +0 -1
- package/dist/web-elements/src/utils/create-event-dispatcher.d.ts +0 -47
- package/dist/web-elements/src/utils/create-event-dispatcher.d.ts.map +0 -1
- package/dist/web-elements/src/utils/create-iframe.d.ts +0 -10
- package/dist/web-elements/src/utils/create-iframe.d.ts.map +0 -1
- package/dist/web-elements/src/utils/resolve-element-references.d.ts +0 -20
- package/dist/web-elements/src/utils/resolve-element-references.d.ts.map +0 -1
- package/dist/web-elements/src/utils/validate-element-options.d.ts +0 -11
- package/dist/web-elements/src/utils/validate-element-options.d.ts.map +0 -1
- package/dist/web-elements/src/utils/validate-sdk-config.d.ts +0 -15
- package/dist/web-elements/src/utils/validate-sdk-config.d.ts.map +0 -1
- package/dist/web-elements/src/utils/warn-unknown-keys.d.ts +0 -15
- package/dist/web-elements/src/utils/warn-unknown-keys.d.ts.map +0 -1
- package/dist/web-elements/src/version.d.ts +0 -25
- package/dist/web-elements/src/version.d.ts.map +0 -1
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-Safe Event Map
|
|
3
|
-
*
|
|
4
|
-
* Provides compile-time guarantees for event names and payloads.
|
|
5
|
-
* Based on TypeScript event emitter best practices.
|
|
6
|
-
*
|
|
7
|
-
* Pattern: Event Map with Discriminated Unions
|
|
8
|
-
* Benefits:
|
|
9
|
-
* - Compile-time validation of event names
|
|
10
|
-
* - Type-safe payload inference
|
|
11
|
-
* - Self-documenting contracts
|
|
12
|
-
* - IDE autocomplete support
|
|
13
|
-
*/
|
|
14
|
-
import type { ElementEvent } from './types';
|
|
15
|
-
/**
|
|
16
|
-
* Validation error structure
|
|
17
|
-
*/
|
|
18
|
-
export interface ValidationError {
|
|
19
|
-
/** Machine-readable error code */
|
|
20
|
-
code: string;
|
|
21
|
-
/** Human-readable error message */
|
|
22
|
-
message: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Change event payload (base for all elements)
|
|
26
|
-
*/
|
|
27
|
-
export interface ChangeEventPayload {
|
|
28
|
-
/** Whether the current value is valid */
|
|
29
|
-
isValid: boolean;
|
|
30
|
-
/** Whether the input is empty */
|
|
31
|
-
isEmpty: boolean;
|
|
32
|
-
/** Validation error (null if valid) */
|
|
33
|
-
error: ValidationError | null;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Card number specific change payload
|
|
37
|
-
* Extends base with card brand detection metadata
|
|
38
|
-
*/
|
|
39
|
-
export interface CardNumberChangePayload extends ChangeEventPayload {
|
|
40
|
-
/** Detected card brand (Visa, Mastercard, etc.) */
|
|
41
|
-
cardBrand?: string;
|
|
42
|
-
/** Last 4 digits (PCI-safe, for display) */
|
|
43
|
-
last4?: string | null;
|
|
44
|
-
/** BIN (Bank Identification Number) - first 6-8 digits */
|
|
45
|
-
bin?: string | null;
|
|
46
|
-
/** CVV lengths for detected brand (for coordinating with CVV element) */
|
|
47
|
-
cvvLengths?: number[] | null;
|
|
48
|
-
/** All brands that could potentially match */
|
|
49
|
-
potentialBrands?: string[];
|
|
50
|
-
/** Match confidence (0-1, higher = more confident) */
|
|
51
|
-
matchStrength?: number;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Card element specific change payload (unified card element)
|
|
55
|
-
* Extends base with unified card state for all 3 sub-fields
|
|
56
|
-
*/
|
|
57
|
-
export interface CardElementChangePayload extends ChangeEventPayload {
|
|
58
|
-
/** Detected card brand (Visa, Mastercard, etc.) */
|
|
59
|
-
cardBrand?: string;
|
|
60
|
-
/** Last 4 digits (PCI-safe, for display) */
|
|
61
|
-
last4?: string | null;
|
|
62
|
-
/** BIN (Bank Identification Number) - first 6-8 digits */
|
|
63
|
-
bin?: string | null;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Error event payload
|
|
67
|
-
*/
|
|
68
|
-
export interface ErrorEventPayload {
|
|
69
|
-
/** Machine-readable error code */
|
|
70
|
-
code: string;
|
|
71
|
-
/** Human-readable error message */
|
|
72
|
-
message: string;
|
|
73
|
-
/** HTTP status code (for API errors) */
|
|
74
|
-
status?: number;
|
|
75
|
-
/** Field-level validation errors from API */
|
|
76
|
-
validationErrors?: Record<string, string[]>;
|
|
77
|
-
/** Additional error context */
|
|
78
|
-
metadata?: {
|
|
79
|
-
/** Error source (e.g., 'tokenize', 'mount') */
|
|
80
|
-
source?: string;
|
|
81
|
-
/** Number of retry attempts */
|
|
82
|
-
retryCount?: number;
|
|
83
|
-
/** Full API response body (for debugging) */
|
|
84
|
-
body?: unknown;
|
|
85
|
-
/** Original error object */
|
|
86
|
-
originalError?: Error;
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Event Map - Central contract for all PostMessage events
|
|
91
|
-
*
|
|
92
|
-
* Maps event names to their payload types for compile-time safety.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* // Type-safe subscription
|
|
97
|
-
* client.subscribe<'EVENT_READY'>('EVENT_READY', (payload) => {
|
|
98
|
-
* // payload is inferred as { elementType: string }
|
|
99
|
-
* });
|
|
100
|
-
*
|
|
101
|
-
* // Type-safe broadcast
|
|
102
|
-
* server.broadcast<'EVENT_ERROR'>('EVENT_ERROR', {
|
|
103
|
-
* code: 'API_ERROR',
|
|
104
|
-
* message: 'Failed to tokenize'
|
|
105
|
-
* });
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
export interface PostMessageEventMap {
|
|
109
|
-
EVENT_READY: {
|
|
110
|
-
elementType: string;
|
|
111
|
-
};
|
|
112
|
-
EVENT_VALUE_CHANGED: ChangeEventPayload | CardNumberChangePayload | CardElementChangePayload;
|
|
113
|
-
EVENT_FOCUS: Record<string, never>;
|
|
114
|
-
EVENT_BLUR: Record<string, never>;
|
|
115
|
-
EVENT_ERROR: ErrorEventPayload;
|
|
116
|
-
/** Iframe document height (e.g. card number co-badge dropdown) — parent may resize iframe */
|
|
117
|
-
EVENT_CONTENT_HEIGHT: {
|
|
118
|
-
heightPx: number;
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Extract payload type from event name
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```typescript
|
|
126
|
-
* type ReadyPayload = EventPayload<'EVENT_READY'>;
|
|
127
|
-
* // Result: { elementType: string }
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
export type EventPayload<T extends ElementEvent> = T extends keyof PostMessageEventMap ? PostMessageEventMap[T] : never;
|
|
131
|
-
/**
|
|
132
|
-
* Type-safe event listener function
|
|
133
|
-
*/
|
|
134
|
-
export type EventListener<T extends ElementEvent> = (payload: EventPayload<T>) => void;
|
|
135
|
-
/**
|
|
136
|
-
* Type guard to check if event name is valid
|
|
137
|
-
*/
|
|
138
|
-
export declare const isValidEvent: (event: string) => event is ElementEvent;
|
|
139
|
-
//# sourceMappingURL=event-map.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-map.d.ts","sourceRoot":"","sources":["../../../../postmessage/src/event-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IAEb,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IAEjB,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IAEjB,uCAAuC;IACvC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAE7B,8CAA8C;IAC9C,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAE3B,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,mDAAmD;IACnD,SA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BAAmB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,YAAY,IAAI,CAClD,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KACrB,IAAI,CAAC;AAEV;;GAEG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,YAUrD,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @basis-theory-elements/postmessage
|
|
3
|
-
* Production-ready PostMessage protocol for secure cross-iframe communication
|
|
4
|
-
*/
|
|
5
|
-
export * from './client';
|
|
6
|
-
export * from './server';
|
|
7
|
-
export * from './types';
|
|
8
|
-
export * from './event-map';
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../postmessage/src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PostMessage Server (Iframe Side)
|
|
3
|
-
* Production-ready server for handling requests from parent
|
|
4
|
-
*/
|
|
5
|
-
import type { PostMessageServer } from './types';
|
|
6
|
-
export interface PostMessageServerConfig {
|
|
7
|
-
allowedOrigins: string[];
|
|
8
|
-
debug?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const createPostMessageServer: (config: PostMessageServerConfig) => PostMessageServer;
|
|
11
|
-
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../postmessage/src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAIV,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,uBAAuB,GAClC,QAAQ,uBAAuB,KAC9B,iBA6NF,CAAC"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PostMessage Module Types
|
|
3
|
-
* Production-ready type definitions for secure cross-iframe communication
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Message types using semantic prefixes
|
|
7
|
-
* EVENT_* = iframe → parent, CMD_* = parent → iframe, RESPONSE_* = follows request
|
|
8
|
-
*/
|
|
9
|
-
export type ElementEvent = 'EVENT_READY' | 'EVENT_MASK_READY' | 'EVENT_VALUE_CHANGED' | 'EVENT_NETWORK_CHANGED' | 'EVENT_CONTENT_HEIGHT' | 'EVENT_FOCUS' | 'EVENT_BLUR' | 'EVENT_ERROR' | 'EVENT_COPY';
|
|
10
|
-
export type ElementCommand = 'CMD_SET_CONFIG' | 'CMD_UPDATE_CONFIG' | 'CMD_SET_VALUE' | 'CMD_SET_VALUE_REF' | 'CMD_FOCUS' | 'CMD_BLUR' | 'CMD_CLEAR' | 'CMD_SET_NETWORK' | 'CMD_TOKENIZE' | 'CMD_TOKENS_ENCRYPT' | 'CMD_VALIDATE';
|
|
11
|
-
export type ElementResponse = 'RESPONSE_CONFIG_OK' | 'RESPONSE_CONFIG_ERROR' | 'RESPONSE_TOKEN_OK' | 'RESPONSE_TOKEN_ERROR' | 'RESPONSE_VALIDATION';
|
|
12
|
-
export type SystemMessage = 'SYS_PING' | 'SYS_PONG' | 'SYS_ACK';
|
|
13
|
-
export type MessageType = ElementEvent | ElementCommand | ElementResponse | SystemMessage;
|
|
14
|
-
export interface RetryConfig {
|
|
15
|
-
maxRetries: number;
|
|
16
|
-
initialDelay: number;
|
|
17
|
-
maxDelay: number;
|
|
18
|
-
backoffFactor: number;
|
|
19
|
-
}
|
|
20
|
-
export interface PostMessageConfig {
|
|
21
|
-
targetOrigin: string;
|
|
22
|
-
timeout?: number;
|
|
23
|
-
retries?: number | RetryConfig;
|
|
24
|
-
debug?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface PostMessageRequest<T = any> {
|
|
27
|
-
type: MessageType | string;
|
|
28
|
-
nonce: string;
|
|
29
|
-
timestamp: number;
|
|
30
|
-
payload?: T;
|
|
31
|
-
}
|
|
32
|
-
export interface PostMessageResponse<T = any> {
|
|
33
|
-
type: MessageType | string;
|
|
34
|
-
nonce: string;
|
|
35
|
-
timestamp: number;
|
|
36
|
-
payload?: T;
|
|
37
|
-
error?: PostMessageError;
|
|
38
|
-
}
|
|
39
|
-
export type TimeoutReason = 'timeout' | 'blocked' | 'origin_mismatch' | 'network';
|
|
40
|
-
export interface PostMessageError {
|
|
41
|
-
code: string;
|
|
42
|
-
message: string;
|
|
43
|
-
reason?: TimeoutReason;
|
|
44
|
-
status?: number;
|
|
45
|
-
statusCode?: number;
|
|
46
|
-
validationErrors?: Record<string, string[]>;
|
|
47
|
-
body?: any;
|
|
48
|
-
retryCount?: number;
|
|
49
|
-
details?: Record<string, unknown>;
|
|
50
|
-
}
|
|
51
|
-
export interface PendingRequest<T = any> {
|
|
52
|
-
resolve: (value: T) => void;
|
|
53
|
-
reject: (error: Error) => void;
|
|
54
|
-
timeout: NodeJS.Timeout;
|
|
55
|
-
timestamp: number;
|
|
56
|
-
}
|
|
57
|
-
export type MessageHandler<TRequest = any, TResponse = any> = (payload: TRequest) => Promise<TResponse> | TResponse;
|
|
58
|
-
export interface SendRequestOptions {
|
|
59
|
-
/** Override retries for this request (0 disables retries) */
|
|
60
|
-
retries?: number;
|
|
61
|
-
}
|
|
62
|
-
export interface PostMessageClient {
|
|
63
|
-
sendRequest<TResponse = any, TRequest = any>(type: string, payload?: TRequest, options?: SendRequestOptions): Promise<TResponse>;
|
|
64
|
-
ping(timeout?: number): Promise<number>;
|
|
65
|
-
subscribe(type: string, callback: (payload: any) => void): () => void;
|
|
66
|
-
destroy(): void;
|
|
67
|
-
getPendingCount(): number;
|
|
68
|
-
}
|
|
69
|
-
export interface PostMessageServer {
|
|
70
|
-
handle<TRequest = any, TResponse = any>(type: string, handler: MessageHandler<TRequest, TResponse>): void;
|
|
71
|
-
broadcast(type: string, payload?: any): void;
|
|
72
|
-
destroy(): void;
|
|
73
|
-
getHandlerCount(): number;
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../postmessage/src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,kBAAkB,GAClB,qBAAqB,GACrB,uBAAuB,GACvB,sBAAsB,GACtB,aAAa,GACb,YAAY,GACZ,aAAa,GACb,YAAY,CAAC;AAEjB,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,mBAAmB,GACnB,eAAe,GACf,mBAAmB,GACnB,WAAW,GACX,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,cAAc,GACd,oBAAoB,GACpB,cAAc,CAAC;AAEnB,MAAM,MAAM,eAAe,GACvB,oBAAoB,GACpB,uBAAuB,GACvB,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAEhE,MAAM,MAAM,WAAW,GACnB,YAAY,GACZ,cAAc,GACd,eAAe,GACf,aAAa,CAAC;AAElB,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,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across SDK and Elements packages
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Get default API base URL
|
|
9
|
-
*
|
|
10
|
-
* If user provides apiBaseUrl, use it.
|
|
11
|
-
* Otherwise auto-detect based on environment:
|
|
12
|
-
* - localhost or dev → https://js.flock-dev.com/api
|
|
13
|
-
* - uat → https://js.btsandbox.com/api
|
|
14
|
-
* - prod → https://js.basistheory.com/api
|
|
15
|
-
*
|
|
16
|
-
* @param userProvidedUrl - Optional user-provided API URL
|
|
17
|
-
* @param enforceOrigin - If true, throws error for unauthorized origins (default: false)
|
|
18
|
-
* SDK: false (runs on customer domains)
|
|
19
|
-
* Elements: true (must run on BasisTheory domains)
|
|
20
|
-
*/
|
|
21
|
-
export declare const getDefaultApiBaseUrl: (userProvidedUrl?: string, enforceOrigin?: boolean) => string;
|
|
22
|
-
//# sourceMappingURL=api-url-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-url-resolver.d.ts","sourceRoot":"","sources":["../../../../shared/src/api-url-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAC/B,kBAAkB,MAAM,EACxB,uBAAqB,KACpB,MAkCF,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Universal Debug Logger
|
|
3
|
-
* PCI-compliant logging that never exposes sensitive data
|
|
4
|
-
*
|
|
5
|
-
* FR-005: Deep Logger Sanitization
|
|
6
|
-
* - Recursively sanitizes nested objects/arrays
|
|
7
|
-
* - Masks PANs to first 6 + last 4
|
|
8
|
-
* - Redacts CVV/PIN/passwords completely
|
|
9
|
-
* - Handles circular references
|
|
10
|
-
*/
|
|
11
|
-
export type DebugLogger = (action: string, metadata?: Record<string, unknown>) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Create a debug logger for a specific package
|
|
14
|
-
*/
|
|
15
|
-
export declare const createDebugLogger: (packageName: string, enabled: boolean) => DebugLogger;
|
|
16
|
-
//# sourceMappingURL=debug-logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug-logger.d.ts","sourceRoot":"","sources":["../../../../shared/src/debug-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,IAAI,CAAC;AAiDV;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,aAAa,MAAM,EACnB,SAAS,OAAO,KACf,WAUF,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FR-005: Deep Logger Sanitization
|
|
3
|
-
* PCI-DSS Requirement 3.2 - Never Store Sensitive Authentication Data
|
|
4
|
-
*
|
|
5
|
-
* Recursively sanitizes objects to prevent PAN/CVV leakage in logs.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Check if a field name matches PAN patterns
|
|
9
|
-
*/
|
|
10
|
-
export declare const isPANField: (key: string) => boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Check if a field name matches redact patterns
|
|
13
|
-
*/
|
|
14
|
-
export declare const isRedactField: (key: string) => boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Deep sanitize an unknown value
|
|
17
|
-
*
|
|
18
|
-
* @param data - Data to sanitize
|
|
19
|
-
* @param depth - Current recursion depth (max 5)
|
|
20
|
-
* @param visited - WeakSet to track visited objects (circular reference detection)
|
|
21
|
-
* @returns Sanitized data
|
|
22
|
-
*/
|
|
23
|
-
export declare const sanitizeDeep: (data: unknown, depth?: number, ancestors?: WeakSet<object>) => unknown;
|
|
24
|
-
//# sourceMappingURL=deep-sanitization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deep-sanitization.d.ts","sourceRoot":"","sources":["../../../../shared/src/deep-sanitization.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,OAExC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,OAE3C,CAAC;AAgFF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,OAAO,EACb,cAAS,EACT,2BAAiC,KAChC,OAgEF,CAAC"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BasisTheory Structured Error Types
|
|
3
|
-
*
|
|
4
|
-
* Functional error factories for consistent error handling across SDK, Elements, and API Client.
|
|
5
|
-
*/
|
|
6
|
-
export interface BasisTheoryErrorType extends Error {
|
|
7
|
-
readonly code: string;
|
|
8
|
-
readonly details?: Record<string, any>;
|
|
9
|
-
toJSON: () => {
|
|
10
|
-
name: string;
|
|
11
|
-
code: string;
|
|
12
|
-
message: string;
|
|
13
|
-
details?: Record<string, any>;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Base BasisTheoryError factory
|
|
18
|
-
* Creates error objects with consistent structure
|
|
19
|
-
*/
|
|
20
|
-
export declare const createBasisTheoryError: (code: string, message: string, details?: Record<string, any>) => BasisTheoryErrorType;
|
|
21
|
-
/**
|
|
22
|
-
* BasisTheoryError - Generic base error
|
|
23
|
-
*/
|
|
24
|
-
export declare const BasisTheoryError: (code: string, message: string, details?: Record<string, any>) => BasisTheoryErrorType;
|
|
25
|
-
/**
|
|
26
|
-
* ValidationError - Input validation failures
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* throw ValidationError('Card number is invalid', 'cardNumber', {
|
|
30
|
-
* received: '1234',
|
|
31
|
-
* expected: '13-19 digits'
|
|
32
|
-
* });
|
|
33
|
-
*/
|
|
34
|
-
export interface ValidationErrorType extends BasisTheoryErrorType {
|
|
35
|
-
readonly field?: string;
|
|
36
|
-
}
|
|
37
|
-
export declare const ValidationError: (message: string, field?: string, details?: Record<string, any>) => ValidationErrorType;
|
|
38
|
-
/**
|
|
39
|
-
* CoordinatorError - Errors from coordinator iframe operations
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* throw CoordinatorError('Tokenization failed', {
|
|
43
|
-
* operation: 'tokenize',
|
|
44
|
-
* elementId: 'card-123'
|
|
45
|
-
* });
|
|
46
|
-
*/
|
|
47
|
-
export declare const CoordinatorError: (message: string, details?: Record<string, any>) => BasisTheoryErrorType;
|
|
48
|
-
/**
|
|
49
|
-
* ElementError - Errors from element iframe operations
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* throw ElementError('Element not mounted', 'card-number-123', {
|
|
53
|
-
* reason: 'mount() was never called'
|
|
54
|
-
* });
|
|
55
|
-
*/
|
|
56
|
-
export interface ElementErrorType extends BasisTheoryErrorType {
|
|
57
|
-
readonly elementId?: string;
|
|
58
|
-
}
|
|
59
|
-
export declare const ElementError: (message: string, elementId?: string, details?: Record<string, any>) => ElementErrorType;
|
|
60
|
-
/**
|
|
61
|
-
* NetworkError - HTTP/Network-related errors
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* throw NetworkError('API request failed', 500, {
|
|
65
|
-
* url: 'https://api.basistheory.com/tokens',
|
|
66
|
-
* method: 'POST'
|
|
67
|
-
* });
|
|
68
|
-
*/
|
|
69
|
-
export interface NetworkErrorType extends BasisTheoryErrorType {
|
|
70
|
-
readonly statusCode?: number;
|
|
71
|
-
}
|
|
72
|
-
export declare const NetworkError: (message: string, statusCode?: number, details?: Record<string, any>) => NetworkErrorType;
|
|
73
|
-
/**
|
|
74
|
-
* ConfigurationError - SDK/Element configuration errors
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* throw ConfigurationError('Invalid API key', {
|
|
78
|
-
* provided: 'key_test_invalid',
|
|
79
|
-
* expected: 'key_test_* or key_live_*'
|
|
80
|
-
* });
|
|
81
|
-
*/
|
|
82
|
-
export declare const ConfigurationError: (message: string, details?: Record<string, any>) => BasisTheoryErrorType;
|
|
83
|
-
/**
|
|
84
|
-
* EncryptionError - Client-side encryption errors
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* throw EncryptionError('JWE encryption failed', 'ENCRYPTION_FAILED', {
|
|
88
|
-
* algorithm: 'ECDH-ES',
|
|
89
|
-
* keyId: 'key_123'
|
|
90
|
-
* });
|
|
91
|
-
*/
|
|
92
|
-
export declare const EncryptionError: (message: string, code?: string, details?: Record<string, any>) => BasisTheoryErrorType;
|
|
93
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../shared/src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,oBAAqB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,MAAM,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,CAAC;CACH;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,EACZ,SAAS,MAAM,EACf,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC5B,oBAoBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,MAAM,EACZ,SAAS,MAAM,EACf,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC5B,oBAIF,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAo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17+, all modern browsers)
|
|
5
|
-
* Falls back to Math.random() for older environments (rare)
|
|
6
|
-
*
|
|
7
|
-
* Format: Standard UUID v4 (e.g., "550e8400-e29b-41d4-a716-446655440000")
|
|
8
|
-
*
|
|
9
|
-
* Note: This utility is rarely needed as the coordinator generates element IDs
|
|
10
|
-
* via CMD_REGISTER_ELEMENT using crypto.randomUUID() directly.
|
|
11
|
-
*/
|
|
12
|
-
export declare const generateId: () => string;
|
|
13
|
-
//# sourceMappingURL=generate-id.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-id.d.ts","sourceRoot":"","sources":["../../../../shared/src/generate-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,QAAO,MAuB7B,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @basis-theory-elements/shared
|
|
3
|
-
* Shared utilities for all BasisTheory Elements packages
|
|
4
|
-
*/
|
|
5
|
-
export { createDebugLogger } from './debug-logger';
|
|
6
|
-
export type { DebugLogger } from './debug-logger';
|
|
7
|
-
export { sanitizeDeep } from './deep-sanitization';
|
|
8
|
-
export { getDefaultApiBaseUrl } from './api-url-resolver';
|
|
9
|
-
export { generateId } from './generate-id';
|
|
10
|
-
export { configureLogger, getLogger, log } from './logger-context';
|
|
11
|
-
export { BasisTheoryError, ValidationError, CoordinatorError, ElementError, NetworkError, ConfigurationError, EncryptionError, } from './errors';
|
|
12
|
-
export type { BasisTheoryErrorType, ValidationErrorType, ElementErrorType, NetworkErrorType, } from './errors';
|
|
13
|
-
export { ALLOWED_METHODS, ALLOWED_PROXY_SCHEMES, FORBIDDEN_PROXY_HEADERS, validateProxyHeaders, validateProxyTarget, validateProxyOptions, } from './proxy-validation';
|
|
14
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../shared/src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,eAAe,GAChB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared Logger Context
|
|
3
|
-
*
|
|
4
|
-
* Provides a global logger instance that can be controlled by the coordinator.
|
|
5
|
-
* Elements import this and use the shared logger without passing it around.
|
|
6
|
-
*/
|
|
7
|
-
import { type DebugLogger } from './debug-logger';
|
|
8
|
-
/**
|
|
9
|
-
* Configure the global logger (called by coordinator on init)
|
|
10
|
-
*
|
|
11
|
-
* @param packageName - Package name for log prefix
|
|
12
|
-
* @param enabled - Whether debug logging is enabled
|
|
13
|
-
*/
|
|
14
|
-
export declare const configureLogger: (packageName: string, enabled: boolean) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Get the current logger instance
|
|
17
|
-
*
|
|
18
|
-
* Elements use this to get the shared logger
|
|
19
|
-
*/
|
|
20
|
-
export declare const getLogger: () => DebugLogger;
|
|
21
|
-
/**
|
|
22
|
-
* Convenience: Log directly without getting logger first
|
|
23
|
-
*/
|
|
24
|
-
export declare const log: (action: string, metadata?: Record<string, unknown>) => void;
|
|
25
|
-
//# sourceMappingURL=logger-context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger-context.d.ts","sourceRoot":"","sources":["../../../../shared/src/logger-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAOrE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,aAAa,MAAM,EACnB,SAAS,OAAO,KACf,IAEF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,QAAO,WAA2B,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,GAAG,GACd,QAAQ,MAAM,EACd,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACjC,IAEF,CAAC"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Proxy Request Validation
|
|
3
|
-
*
|
|
4
|
-
* Shared validation utilities for proxy requests across SDK and Coordinator.
|
|
5
|
-
* Ensures consistent security controls and validation behavior.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Security: Allowed URL schemes for proxy requests
|
|
9
|
-
*
|
|
10
|
-
* Only HTTPS are permitted to prevent:
|
|
11
|
-
* - javascript: XSS attacks
|
|
12
|
-
* - file:// local file access
|
|
13
|
-
* - data: data exfiltration
|
|
14
|
-
* - Other dangerous schemes
|
|
15
|
-
*/
|
|
16
|
-
export declare const ALLOWED_PROXY_SCHEMES: Set<string>;
|
|
17
|
-
/**
|
|
18
|
-
* Allowed HTTP methods for proxy requests
|
|
19
|
-
*/
|
|
20
|
-
export declare const ALLOWED_METHODS: Set<string>;
|
|
21
|
-
/**
|
|
22
|
-
* Security: Headers that could enable request smuggling or bypass controls
|
|
23
|
-
*
|
|
24
|
-
* These headers are blocked to prevent various attack vectors:
|
|
25
|
-
*
|
|
26
|
-
* Request Smuggling Prevention:
|
|
27
|
-
* - host: Prevents host header injection attacks
|
|
28
|
-
* - content-length: Prevents content-length manipulation for request smuggling
|
|
29
|
-
* - transfer-encoding: Prevents TE.CL and CL.TE smuggling attacks
|
|
30
|
-
* - te: Transfer-Encoding negotiation header used in smuggling
|
|
31
|
-
* - trailer: Used with chunked encoding, potential smuggling vector
|
|
32
|
-
*
|
|
33
|
-
* Connection Manipulation Prevention:
|
|
34
|
-
* - connection: Prevents hop-by-hop header manipulation
|
|
35
|
-
* - upgrade: Prevents protocol upgrade attacks (e.g., WebSocket hijacking)
|
|
36
|
-
* - keep-alive: Prevents connection persistence manipulation
|
|
37
|
-
* - proxy-connection: Non-standard proxy connection header
|
|
38
|
-
*
|
|
39
|
-
* Proxy Bypass Prevention:
|
|
40
|
-
* - via: Prevents proxy chain manipulation
|
|
41
|
-
* - proxy-authorization: Prevents authentication to intermediate proxies
|
|
42
|
-
*
|
|
43
|
-
* BasisTheory Credential Protection:
|
|
44
|
-
* - bt-api-key: Prevents API key override/leakage
|
|
45
|
-
* - bt-proxy-key: Prevents proxy key override/leakage
|
|
46
|
-
* - bt-idempotency-key: Prevents idempotency key manipulation
|
|
47
|
-
*/
|
|
48
|
-
export declare const FORBIDDEN_PROXY_HEADERS: Set<string>;
|
|
49
|
-
/**
|
|
50
|
-
* Validate that headers don't contain forbidden values
|
|
51
|
-
*
|
|
52
|
-
* @param headers - Headers object to validate
|
|
53
|
-
* @throws ValidationError if a forbidden header is found
|
|
54
|
-
*/
|
|
55
|
-
export declare const validateProxyHeaders: (headers?: Record<string, string>) => void;
|
|
56
|
-
/**
|
|
57
|
-
* Validate proxy request options (url XOR proxyKey)
|
|
58
|
-
*
|
|
59
|
-
* Ensures exactly one of `url` or `proxyKey` is provided.
|
|
60
|
-
* - `url`: Ephemeral proxy - destination URL provided at request time
|
|
61
|
-
* - `proxyKey`: Pre-configured proxy - uses server-side proxy configuration
|
|
62
|
-
*
|
|
63
|
-
* When `url` is provided, also validates:
|
|
64
|
-
* - URL is well-formed
|
|
65
|
-
* - URL scheme is https: only (prevents javascript:, file://, http:, etc.)
|
|
66
|
-
* - No userinfo (username/password) in URL
|
|
67
|
-
* - No private/internal IP addresses (SSRF prevention)
|
|
68
|
-
* - No blocked hostnames (cloud metadata, localhost, etc.)
|
|
69
|
-
*
|
|
70
|
-
* @param url - Destination URL (optional)
|
|
71
|
-
* @param proxyKey - Pre-configured proxy key (optional)
|
|
72
|
-
* @throws ValidationError if neither or both are provided, or if URL is invalid
|
|
73
|
-
*/
|
|
74
|
-
export declare const validateProxyTarget: (url?: string, proxyKey?: string) => void;
|
|
75
|
-
/**
|
|
76
|
-
* Validate complete proxy request options
|
|
77
|
-
*
|
|
78
|
-
* Performs all proxy validation:
|
|
79
|
-
* 1. Validates options is a plain object (if provided)
|
|
80
|
-
* 2. Validates url XOR proxyKey requirement
|
|
81
|
-
* 3. Validates headers don't contain forbidden values
|
|
82
|
-
* 4. When `method` is present, validates it is an allowed HTTP verb
|
|
83
|
-
*
|
|
84
|
-
* @param options - Proxy request options
|
|
85
|
-
* @throws ValidationError on validation failure
|
|
86
|
-
*/
|
|
87
|
-
export declare const validateProxyOptions: (options?: {
|
|
88
|
-
url?: string;
|
|
89
|
-
proxyKey?: string;
|
|
90
|
-
headers?: Record<string, string>;
|
|
91
|
-
method?: string;
|
|
92
|
-
}) => void;
|
|
93
|
-
//# sourceMappingURL=proxy-validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-validation.d.ts","sourceRoot":"","sources":["../../../../shared/src/proxy-validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,aAAsB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,eAAe,aAM1B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,uBAAuB,aA2BlC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC/B,IAmBF,CAAC;AAyRF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,MAAM,EACZ,WAAW,MAAM,KAChB,IAeF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAC/B,UAAU;IACR,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,KACA,IAcF,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @basis-theory/web-elements
|
|
3
|
-
* Main SDK factory function
|
|
4
|
-
*/
|
|
5
|
-
import type { BasisTheorySDK, SDKOptions } from './types';
|
|
6
|
-
/**
|
|
7
|
-
* Queued command from loader
|
|
8
|
-
* Commands are queued before SDK loads, then replayed
|
|
9
|
-
*/
|
|
10
|
-
interface QueuedCommand {
|
|
11
|
-
method: 'createElement' | 'tokenize' | 'updateThemeMode';
|
|
12
|
-
args: any[];
|
|
13
|
-
resolve: (result: any) => void;
|
|
14
|
-
reject: (error: Error) => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Creates a BasisTheory SDK instance
|
|
18
|
-
* Factory function (no class, pure functional approach)
|
|
19
|
-
*
|
|
20
|
-
* @param apiKey - Your Basis Theory public API key (starts with 'pk_')
|
|
21
|
-
* @param options - SDK configuration options
|
|
22
|
-
* @param queuedCommands - Optional: Commands queued by loader before SDK loaded
|
|
23
|
-
* @returns SDK instance with methods to create and tokenize elements
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* import BasisTheory from '@basis-theory/web-elements';
|
|
28
|
-
*
|
|
29
|
-
* const bt = BasisTheory('pk_test_YOUR_API_KEY');
|
|
30
|
-
*
|
|
31
|
-
* const cardNumber = bt.createElement('cardNumber', {
|
|
32
|
-
* placeholder: '4111 1111 1111 1111'
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* await cardNumber.mount('#card-number');
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
declare const BasisTheory: (apiKey: string, options?: SDKOptions, queuedCommands?: QueuedCommand[]) => BasisTheorySDK;
|
|
39
|
-
declare global {
|
|
40
|
-
interface Window {
|
|
41
|
-
BasisTheory?: typeof BasisTheory;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
export default BasisTheory;
|
|
45
|
-
export { BasisTheory };
|
|
46
|
-
export type { BasisTheorySDK, CardElement, ChangeEventDetail, Element, ElementOptions, ElementType, ErrorEventDetail, EventListener, EventType, ProxyRequestOptions, ProxyResponse, ReadyEventDetail, SDKOptions, TokenizeInput, TokenizeResult, } from './types';
|
|
47
|
-
//# sourceMappingURL=BasisTheory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BasisTheory.d.ts","sourceRoot":"","sources":["../../../src/BasisTheory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,OAAO,KAAK,EACV,cAAc,EAUd,UAAU,EAQX,MAAM,SAAS,CAAC;AAMjB;;;GAGG;AACH,UAAU,aAAa;IACrB,MAAM,EAAE,eAAe,GAAG,UAAU,GAAG,iBAAiB,CAAC;IACzD,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,QAAA,MAAM,WAAW,GACf,QAAQ,MAAM,EACd,UAAS,UAAe,EACxB,iBAAiB,aAAa,EAAE,KAC/B,cAg+BF,CAAC;AAMF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,WAAW,CAAC,EAAE,OAAO,WAAW,CAAC;KAClC;CACF;AAgBD,eAAe,WAAW,CAAC;AAG3B,OAAO,EAAE,WAAW,EAAE,CAAC;AAGvB,YAAY,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC"}
|