@authvia/payment-method-create 1.0.7 → 1.0.9

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.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Permitted Authvia API hostnames baked in at library build time.
3
+ * Frozen at module load time.
4
+ */
5
+ export declare const ALLOWED_API_HOSTS: readonly string[];
6
+ /**
7
+ * Map of permitted API hostnames to their HTTPS origins.
8
+ */
9
+ export declare const ALLOWED_BASE_URLS: Readonly<Record<string, string>>;
10
+ /**
11
+ * Returns true when `apiHost` is on the compile-time allowlist.
12
+ *
13
+ * @param apiHost - Hostname to validate (not a full URL)
14
+ */
15
+ export declare function isAllowedApiHost(apiHost: string): boolean;
16
+ /**
17
+ * Validates `apiHost` against the allowlist.
18
+ *
19
+ * @param apiHost - Hostname to validate (not a full URL)
20
+ * @throws {PaymentMethodAPIError} When the hostname is not allowlisted
21
+ */
22
+ export declare function assertAllowedApiHost(apiHost: string): void;
@@ -2,7 +2,7 @@ import { App } from 'vue';
2
2
  import { default as AuthviaPaymentMethodCreate } from '../components/AuthviaPaymentMethodForm.vue';
3
3
  import { AuthviaPaymentMethodFormPluginOptions } from '../types';
4
4
  declare const AuthviaPaymentMethodCreatePlugin: {
5
- install: (app: App, options?: AuthviaPaymentMethodFormPluginOptions) => void;
5
+ install: (app: App, options: AuthviaPaymentMethodFormPluginOptions) => void;
6
6
  };
7
7
  export default AuthviaPaymentMethodCreatePlugin;
8
8
  export { AuthviaPaymentMethodCreatePlugin };
@@ -0,0 +1,20 @@
1
+ export declare class AuthviaPaymentMethodFormElement extends HTMLElement {
2
+ private app;
3
+ private shadow;
4
+ private container;
5
+ private vuetify;
6
+ private readonly vueLoader;
7
+ private readonly stylesheetManager;
8
+ private readonly bundledMdiUrl;
9
+ private readonly hasReportedMissingDependencies;
10
+ constructor();
11
+ static get observedAttributes(): string[];
12
+ connectedCallback(): void;
13
+ disconnectedCallback(): void;
14
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
15
+ private initializeComponent;
16
+ private mountComponent;
17
+ private dispatchCustomEvent;
18
+ private refreshVuetifyOverrideStyles;
19
+ }
20
+ export declare function registerAuthviaPaymentMethodFormElement(): void;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Applies API host and Plaid environment from build-time `VITE_APP_API_BASE_URL`.
3
+ */
4
+ export declare function applyBuildTimeHostConfig(): void;
@@ -0,0 +1,12 @@
1
+ import { StylesheetDependency } from './types';
2
+ export declare const TAG_NAME: string;
3
+ export declare const DEPENDENCY_TIMEOUT_MS: number;
4
+ export declare const MIN_VERSIONS: Readonly<{
5
+ vue: string;
6
+ vuetifyCss: string;
7
+ mdiCss: string;
8
+ }>;
9
+ export declare const STYLESHEET_DEPENDENCIES: StylesheetDependency[];
10
+ export declare const OBSERVED_ATTRIBUTES: string[];
11
+ /** Copied from :root or ancestors onto the host so embedders can theme the shadow tree. */
12
+ export declare const HOST_CSS_VARIABLES: readonly string[];
@@ -0,0 +1,2 @@
1
+ import { DependencyRegistry } from './types';
2
+ export declare function getDependencyRegistry(): DependencyRegistry;
@@ -0,0 +1,11 @@
1
+ import { AuthviaPaymentMethodFormProps } from '../../types';
2
+ /** Integration helper for programmatic usage */
3
+ export declare function createEmbeddedPaymentMethodForm(config: {
4
+ container: HTMLElement;
5
+ props?: Partial<AuthviaPaymentMethodFormProps>;
6
+ onEvents?: Record<string, (e: Event) => void>;
7
+ }): {
8
+ element: HTMLElement;
9
+ updateProps: (newProps: Partial<AuthviaPaymentMethodFormProps>) => void;
10
+ destroy: () => void;
11
+ };
@@ -0,0 +1,6 @@
1
+ import { WebComponentStylesheetManager } from './stylesheetManager';
2
+ import { WebComponentVueLoader } from './vueRuntimeLoader';
3
+ /**
4
+ * Validates Vue runtime and stylesheet dependencies before mount.
5
+ */
6
+ export declare function ensureWebComponentDependencies(vueLoader: WebComponentVueLoader, stylesheetManager: WebComponentStylesheetManager): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { AuthviaPaymentMethodFormElement } from './AuthviaPaymentMethodFormElement';
2
+ import { createEmbeddedPaymentMethodForm } from './embeddedFormHelper';
3
+ export { AuthviaPaymentMethodFormElement, createEmbeddedPaymentMethodForm };
4
+ export default AuthviaPaymentMethodFormElement;
@@ -0,0 +1,12 @@
1
+ import { AuthviaPaymentMethodFormProps } from '../../types';
2
+ export type ParsedWebComponentProps = AuthviaPaymentMethodFormProps & {
3
+ achOnline?: boolean;
4
+ };
5
+ /**
6
+ * Maps `data-*` attributes on the custom element to Vue component props (without event handlers).
7
+ */
8
+ export declare function parseElementProps(element: HTMLElement): ParsedWebComponentProps;
9
+ /**
10
+ * Dialog overlays mount under the mount container; sync theme tokens there for teleports.
11
+ */
12
+ export declare function syncContainerThemeTokens(container: HTMLDivElement, props: Pick<AuthviaPaymentMethodFormProps, 'color' | 'borderRadius'>): void;
@@ -0,0 +1,7 @@
1
+ import { MissingDependencyDetail } from './types';
2
+ /**
3
+ * Reports missing dependency init failures to Sentry once per element lifecycle.
4
+ */
5
+ export declare function reportMissingDependenciesToSentry(missing: MissingDependencyDetail[], hasReported: {
6
+ value: boolean;
7
+ }): void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Compares semver strings; returns 1 if left > right, -1 if left < right, 0 if equal.
3
+ */
4
+ export declare function compareSemver(leftVersion: string, rightVersion: string): number;
5
+ export declare function isVersionSatisfied(currentVersion: string | undefined, minimumVersion: string): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Injects bundled component styles into the shadow root.
3
+ */
4
+ export declare function injectComponentStyles(shadow: ShadowRoot): void;
5
+ export declare function getVuetifyOverrideCss(element: HTMLElement): string;
6
+ export declare function injectVuetifyOverrideStyles(shadow: ShadowRoot, css: string): void;
7
+ /**
8
+ * Copy CSS variables from document :root and host ancestors onto the host element.
9
+ */
10
+ export declare function copyCssVariablesFromRoot(host: HTMLElement): void;
@@ -0,0 +1,20 @@
1
+ import { StylesheetDependency } from './types';
2
+ /**
3
+ * Resolves and injects Vuetify/MDI stylesheets into the shadow root.
4
+ */
5
+ export declare class WebComponentStylesheetManager {
6
+ private readonly dependencyObservers;
7
+ private readonly shadow;
8
+ private readonly bundledMdiUrl;
9
+ private readonly hasBundledMdi;
10
+ constructor(shadow: ShadowRoot, bundledMdiUrl: string | null, hasBundledMdi: boolean);
11
+ cleanup(): void;
12
+ ensureStylesheetDependency(dependency: StylesheetDependency): Promise<boolean>;
13
+ private findParentStylesheet;
14
+ private observeStylesheet;
15
+ private injectStylesheetFromHref;
16
+ private insertStylesheetElement;
17
+ private parseVersionFromHref;
18
+ private injectBundledMdi;
19
+ private removeDependencyObserver;
20
+ }
@@ -0,0 +1,38 @@
1
+ export type VueRuntime = typeof import('vue');
2
+ export type DependencyKey = 'vue-runtime' | 'vuetify-css' | 'mdi-css';
3
+ export interface StylesheetDependency {
4
+ key: Extract<DependencyKey, 'vuetify-css' | 'mdi-css'>;
5
+ label: string;
6
+ minVersion: string;
7
+ selector: string;
8
+ hint: string;
9
+ }
10
+ export interface StylesheetMatch {
11
+ href: string;
12
+ version?: string;
13
+ }
14
+ export interface MissingDependencyDetail {
15
+ dependency: DependencyKey;
16
+ label: string;
17
+ minimumVersion: string;
18
+ hint: string;
19
+ }
20
+ export type DependencyRegistry = Record<Extract<DependencyKey, 'vuetify-css' | 'mdi-css'>, {
21
+ status: 'pending' | 'ready' | 'missing';
22
+ href?: string;
23
+ version?: string;
24
+ }>;
25
+ declare global {
26
+ interface Window {
27
+ __AUTHVIA_DEPENDENCY_REGISTRY__?: DependencyRegistry;
28
+ __AUTHVIA_WEB_COMPONENT_CSS__?: string;
29
+ Vue?: VueRuntime;
30
+ }
31
+ interface GlobalThis {
32
+ Vue?: VueRuntime;
33
+ }
34
+ }
35
+ export declare class MissingDependencyError extends Error {
36
+ readonly missing: MissingDependencyDetail[];
37
+ constructor(missing: MissingDependencyDetail[]);
38
+ }
@@ -0,0 +1,13 @@
1
+ import { MissingDependencyDetail, VueRuntime } from './types';
2
+ /**
3
+ * Loads Vue from global scope with polling fallback.
4
+ */
5
+ export declare class WebComponentVueLoader {
6
+ vueRuntime: VueRuntime | null;
7
+ load(): Promise<VueRuntime | null>;
8
+ validateOrCollectMissing(): MissingDependencyDetail | null;
9
+ private getGlobalVueRuntime;
10
+ private waitForGlobalVueRuntime;
11
+ }
12
+ export declare function logMissingDependency(detail: MissingDependencyDetail): void;
13
+ export declare function handleMissingDependencies(element: HTMLElement, missing: MissingDependencyDetail[]): void;
@@ -266,7 +266,7 @@ export interface PaymentMethodConfigItem {
266
266
  /**
267
267
  * Options for `AuthviaPaymentMethodFormPlugin` via `app.use(plugin, options)`.
268
268
  * Use when embedding in another Vue app so host config does not depend on this package's `import.meta.env`.
269
- * CDN and web-component-specific setup remain in `src/entry/web-component.ts`.
269
+ * CDN and web-component-specific setup remain in `src/entry/web-component/index.ts`.
270
270
  */
271
271
  export interface AuthviaPaymentMethodFormPluginOptions {
272
272
  apiBaseURL: string;
@@ -1,9 +1,10 @@
1
1
  export declare const config: {
2
- apiBaseUrl: string;
2
+ readonly apiBaseUrl: string;
3
3
  apiVersion: string;
4
4
  enableLogging: boolean;
5
5
  enableDebug: boolean;
6
6
  cdnUrl: string;
7
+ readonly plaidEnv: string;
7
8
  enableAnalytics: boolean;
8
9
  enableErrorReporting: boolean;
9
10
  enablePerformanceMonitoring: boolean;
@@ -26,11 +27,9 @@ export declare const DEFAULT_CREDIT_CARD_SCRIPT_PATH: string;
26
27
  /**
27
28
  * Resolves the `src` for the authvia-credit-card loader via {@link getCdnUrl} and `VITE_APP_CDN_URL`.
28
29
  *
29
- * Does not read the JWT `iss` claim. Older builds picked dev / nonprod / prod CDN hosts from the
30
- * token at runtime because we had no env variable to control the credit-card CDN path. We now set
31
- * `VITE_APP_CDN_URL` (and {@link CREDIT_CARD_WC_VERSION}) per deploy so each bundle targets one CDN.
32
- * API and Plaid hosts still follow the token via `resolveApiHost` in the web-component entry; publish
33
- * separate create-widget builds (or CDN bases) when partners need both API environments from one page.
30
+ * CDN and API hosts are fixed at build time via `VITE_APP_CDN_URL` and `VITE_APP_API_BASE_URL`
31
+ * (see `vite.config.wc.ts`). Load the dev, integration, or production CDN bundle that matches
32
+ * your environment. Vue plugin embeds pass `apiBaseURL` via `app.use(..., options)`.
34
33
  *
35
34
  * @returns A non-empty string suitable for a script element `src`
36
35
  */
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Returns true when `selector` matches an element on the event path.
3
+ * Uses composedPath so listeners on `document` work inside open Shadow DOM hosts.
4
+ */
5
+ export declare function isEventInside(event: Event, selector: string): boolean;
@@ -28,5 +28,6 @@ export declare const ErrorCodes: {
28
28
  readonly INVALID_TOKEN: "INVALID_TOKEN";
29
29
  readonly PERMISSION_DENIED: "PERMISSION_DENIED";
30
30
  readonly NOT_FOUND: "NOT_FOUND";
31
+ readonly ENDPOINT_NOT_FOUND: "ENDPOINT_NOT_FOUND";
31
32
  readonly SERVER_ERROR: "SERVER_ERROR";
32
33
  };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Normalizes an API base URL or hostname to a bare hostname for {@link useHostService.api}.
3
+ *
4
+ * Accepts values such as `https://api.authvia-nonprod.com/` or `api.authvia-nonprod.com`.
5
+ */
6
+ export declare function normalizeApiHost(apiBaseUrl: string): string;
@@ -13,15 +13,6 @@ export interface TokenPayload {
13
13
  'https://authvia.com/uuid'?: string;
14
14
  [key: string]: unknown;
15
15
  }
16
- /**
17
- * CDN URL of this script, captured while the module first executes so
18
- * `document.currentScript` is still live. Used as a fallback when the token
19
- * has no `iss` claim to derive the API environment from the serving hostname.
20
- *
21
- * Falls back to scanning `document.scripts` for the `authvia-payment-method-create`
22
- * entry (necessary for ES modules where `currentScript` is always `null`).
23
- */
24
- export declare const WC_SCRIPT_URL: string;
25
16
  /**
26
17
  * Parses a JWT and returns its payload (no signature verification).
27
18
  *
@@ -57,18 +48,6 @@ export declare function isTokenExpired(tokenParam: string, bufferSeconds?: numbe
57
48
  * Returns false if the token cannot be parsed or `scope` is missing.
58
49
  */
59
50
  export declare function hasPaymentMethodsCreateScope(tokenParam: string): boolean;
60
- /**
61
- * Derives the API hostname from a JWT's `iss` claim.
62
- *
63
- * If `token` contains a valid `iss` claim the hostname portion is returned (scheme and trailing
64
- * slashes stripped). When the token is absent or malformed, `scriptUrl` is used as a fallback:
65
- * the URL string is matched against known environment substrings to return the correct hostname.
66
- * Returns an empty string when neither source yields a value.
67
- *
68
- * @param token - JWT token string (e.g. from the `data-token` attribute)
69
- * @param scriptUrl - Optional script URL used as an environment fallback (e.g. `WC_SCRIPT_URL`)
70
- */
71
- export declare function resolveApiHost(token?: string, scriptUrl?: string): string;
72
51
  /**
73
52
  * True when `error` is a normal token validation failure (malformed JWT, missing user claim, etc.).
74
53
  * Used to avoid reporting expected embedder or end-user mistakes to Sentry.
@@ -1,6 +1,6 @@
1
- export * from '../entry/index'
1
+ export * from '../entry/vue-plugin'
2
2
  export {}
3
- import AuthviaPaymentMethodCreate from '../entry/index'
3
+ import AuthviaPaymentMethodCreate from '../entry/vue-plugin'
4
4
  export default AuthviaPaymentMethodCreate
5
- export * from '../entry/index'
5
+ export * from '../entry/vue-plugin'
6
6
  export {}