@authvia/payment-method-create 0.8.0 → 0.9.0

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/README.md CHANGED
@@ -113,7 +113,7 @@ See `demo.html` in this repo for a full page example.
113
113
  Load the built script after Vue (for example the output of `npm run build:wc`):
114
114
 
115
115
  ```html
116
- <script type="module" src=".https://cdn.authvia.com/web-components/authvia-payment-method-create/authvia-payment-method-create.js"></script>
116
+ <script type="module" src="https://cdn.authvia.com/web-components/authvia-payment-method-create/authvia-payment-method-create.js"></script>
117
117
  ```
118
118
 
119
119
  ### Web component events
@@ -46,19 +46,9 @@ declare class AuthviaPaymentMethodFormElement extends HTMLElement {
46
46
  */
47
47
  private syncContainerThemeTokens;
48
48
  private getComponentProps;
49
- /**
50
- * Resolves the bare API hostname using two sources in priority order:
51
- *
52
- * 1. **Token `iss` claim** — stripped of `https://` prefix and trailing slashes.
53
- * 2. **CDN script URL** (`WC_SCRIPT_URL`) — maps well-known hostname patterns
54
- * (`nonprod`, `dev-authvia`, `authvia`) to the corresponding API host.
55
- *
56
- * Returns an empty string when neither source yields a usable value.
57
- */
58
- private resolveApiHost;
59
49
  /**
60
50
  * Applies resolved API host and Plaid environment to `useHostService`.
61
- * No-op when neither the token `iss` nor the CDN script URL yields a host.
51
+ * Uses `resolveApiHost` from tokenUtils, with `WC_SCRIPT_URL` as the CDN fallback.
62
52
  */
63
53
  private applyHostConfigFromToken;
64
54
  private dispatchCustomEvent;
@@ -17,17 +17,25 @@ export declare const config: {
17
17
  */
18
18
  export declare function getApiEndpoint(path: string): string;
19
19
  /**
20
- * Default `src` for the credit-card loader script (absolute URL). {@link getCdnUrl} does not prefix {@link config.cdnUrl} onto http(s) URLs.
20
+ * Default `src` for the credit-card loader script (absolute URL).
21
+ * {@link getCdnUrl} does not prefix {@link config.cdnUrl} onto http(s) URLs.
21
22
  */
23
+ export declare const CREDIT_CARD_SCRIPT_PATH: string;
22
24
  export declare const DEFAULT_CREDIT_CARD_SCRIPT_PATH: string;
25
+ /** Nonprod CDN URL for the credit-card script. */
26
+ export declare const NONPROD_CREDIT_CARD_SCRIPT_PATH: string;
27
+ /** Production CDN URL for the credit-card script. */
28
+ export declare const PROD_CREDIT_CARD_SCRIPT_URL: string;
23
29
  /**
24
30
  * Resolves the `src` for the authvia-credit-card loader script via {@link getCdnUrl}.
25
- * `VITE_APP_CDN_URL` must be a CDN base (no trailing slash required); the script path defaults to
26
- * {@link DEFAULT_CREDIT_CARD_SCRIPT_PATH} or `VITE_APP_CREDIT_CARD_SCRIPT_PATH` when the file lives elsewhere on the CDN.
27
31
  *
32
+ * Pass the JWT token so the correct CDN environment is selected from its `iss` claim.
33
+ * Falls back to {@link DEFAULT_CREDIT_CARD_SCRIPT_PATH} when `token` is omitted or has no `iss`.
34
+ *
35
+ * @param token - JWT token string (e.g. `props.token`)
28
36
  * @returns A non-empty string suitable for a script element `src`
29
37
  */
30
- export declare function getCreditCardScriptSrc(): string;
38
+ export declare function getCreditCardScriptSrc(token?: string): string;
31
39
  /**
32
40
  * Get CDN URL for assets
33
41
  */
@@ -48,6 +48,18 @@ export declare function isTokenExpired(tokenParam: string, bufferSeconds?: numbe
48
48
  * Returns false if the token cannot be parsed or `scope` is missing.
49
49
  */
50
50
  export declare function hasPaymentMethodsCreateScope(tokenParam: string): boolean;
51
+ /**
52
+ * Derives the API hostname from a JWT's `iss` claim.
53
+ *
54
+ * If `token` contains a valid `iss` claim the hostname portion is returned (scheme and trailing
55
+ * slashes stripped). When the token is absent or malformed, `scriptUrl` is used as a fallback:
56
+ * the URL string is matched against known environment substrings to return the correct hostname.
57
+ * Returns an empty string when neither source yields a value.
58
+ *
59
+ * @param token - JWT token string (e.g. from the `data-token` attribute)
60
+ * @param scriptUrl - Optional script URL used as an environment fallback (e.g. `WC_SCRIPT_URL`)
61
+ */
62
+ export declare function resolveApiHost(token?: string, scriptUrl?: string): string;
51
63
  /**
52
64
  * True when `error` is a normal token validation failure (malformed JWT, missing user claim, etc.).
53
65
  * Used to avoid reporting expected embedder or end-user mistakes to Sentry.