rebill-web-components-sdk 1.8.3-beta.0 → 1.8.3-beta.1
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/cjs/config-15uQkwgw.js.map +1 -1
- package/dist/cjs/config-DXXQevZh.js.map +1 -1
- package/dist/cjs/index.cjs.js +17 -5
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/collection/api/config.js.map +1 -1
- package/dist/collection/initialize.js +21 -5
- package/dist/collection/initialize.js.map +1 -1
- package/dist/components/config.js.map +1 -1
- package/dist/components/index.js +20 -7
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-DWIgRPXl.js.map +1 -1
- package/dist/esm/config-B8mUEd79.js.map +1 -1
- package/dist/esm/config-BLghMKz-.js.map +1 -1
- package/dist/esm/index.js +20 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/rebill-web-components-sdk/config-BLghMKz-.js.map +1 -1
- package/dist/rebill-web-components-sdk/index.esm.js +20 -7
- package/dist/rebill-web-components-sdk/index.esm.js.map +1 -1
- package/dist/rebill-web-components-sdk/p-B2LDUv1-.js.map +1 -1
- package/dist/types/api/config.d.ts +1 -0
- package/dist/types/initialize.d.ts +8 -5
- package/package.json +1 -1
- package/readme.md +83 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-15uQkwgw.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":["Env"],"mappings":";;;;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;
|
|
1
|
+
{"version":3,"file":"config-15uQkwgw.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":["Env"],"mappings":";;;;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAA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AE;AACd,QAAA,KAAK,EAAE,CAAC,SAAiB,EAAE,UAAkB,EAAE,QAAmB,GAAA,CAAC,KACjE,CAAa,UAAA,EAAA,SAAS,qBAAqB,UAAU,CAAA,UAAA,EAAa,QAAQ,CAAE,CAAA;AAC/E,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,GAAG,EAAE,YAAY;AAClB,KAAA;AACD,IAAA,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,IAAY,KAAK,CAAA,qBAAA,EAAwB,IAAI,CAAE,CAAA;AACtD,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-DXXQevZh.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":["Env"],"mappings":";;;;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;
|
|
1
|
+
{"version":3,"file":"config-DXXQevZh.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":["Env"],"mappings":";;;;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B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,EAAE,UAAkB,EAAE,QAAmB,GAAA,CAAC,KACjE,CAAa,UAAA,EAAA,SAAS,qBAAqB,UAAU,CAAA,UAAA,EAAa,QAAQ,CAAE,CAAA;AAC/E,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,GAAG,EAAE,YAAY;AAClB,KAAA;AACD,IAAA,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,IAAY,KAAK,CAAA,qBAAA,EAAwB,IAAI,CAAE,CAAA;AACtD,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;;;;;"}
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -30,23 +30,25 @@ const configureAssetsURL = (customAssetsURL) => {
|
|
|
30
30
|
* Initialize the Rebill SDK with environment configuration
|
|
31
31
|
*
|
|
32
32
|
* This is OPTIONAL - the SDK works out of the box with production settings.
|
|
33
|
-
* Only call this if you need to use staging or development environments
|
|
33
|
+
* Only call this if you need to use staging or development environments,
|
|
34
|
+
* or if you want to serve assets locally instead of from CDN.
|
|
34
35
|
*
|
|
35
36
|
* @param config - Configuration object for the SDK
|
|
36
37
|
* @example
|
|
37
38
|
* ```typescript
|
|
38
39
|
* import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
39
40
|
*
|
|
40
|
-
* // For staging (optional)
|
|
41
|
+
* // For staging with CDN assets (optional)
|
|
41
42
|
* initializeRebillSDK({
|
|
42
43
|
* environment: 'staging',
|
|
43
44
|
* debug: true
|
|
44
45
|
* });
|
|
45
46
|
*
|
|
46
|
-
* // For
|
|
47
|
+
* // For staging with local assets
|
|
47
48
|
* initializeRebillSDK({
|
|
48
|
-
* environment: '
|
|
49
|
-
* debug: true
|
|
49
|
+
* environment: 'staging',
|
|
50
|
+
* debug: true,
|
|
51
|
+
* assetsUrl: '/sdk/'
|
|
50
52
|
* });
|
|
51
53
|
*
|
|
52
54
|
* // For production (optional - this is the default)
|
|
@@ -64,6 +66,16 @@ const initializeRebillSDK = (config$1 = {}) => {
|
|
|
64
66
|
throw new Error(`Invalid environment "${config$1.environment}". Must be one of: ${validEnvironments.join(', ')}`);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
// Configure assets URL if provided
|
|
70
|
+
if (config$1.assetsUrl) {
|
|
71
|
+
assets.setAssetsURL(config$1.assetsUrl);
|
|
72
|
+
if (config$1.debug !== false) {
|
|
73
|
+
console.log(`📦 Assets URL configured: ${config$1.assetsUrl}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (config$1.debug !== false) {
|
|
77
|
+
console.log(`📦 Using CDN for assets: ${cdn.CDN_ASSETS_URL}`);
|
|
78
|
+
}
|
|
67
79
|
// Initialize the SDK
|
|
68
80
|
config.initializeSDK(config$1);
|
|
69
81
|
// Log initialization success
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["src/initialize.ts","src/index.ts"],"sourcesContent":["/**\n * Rebill SDK Initialization Module\n *\n * This module provides a simple way for host applications to configure\n * the SDK for different environments. By default, the SDK uses production\n * configuration and requires no initialization for client applications.\n */\n\nimport { Environment, initializeSDK, RebillSDKConfig } from './api/config';\n\n// Import CDN configuration\nimport { CDN_ASSETS_URL } from './config/cdn';\n\n// Re-export types for convenience\nexport type { Environment, RebillSDKConfig } from './api/config';\n\n/**\n * Configure assets URL for the SDK\n * This function sets up the assets URL to use CDN by default\n * but allows users to override with their own URL\n */\nexport const configureAssetsURL = (customAssetsURL?: string) => {\n const assetsURL = customAssetsURL || CDN_ASSETS_URL;\n\n // Set the assets URL globally for getAssetPath to use\n if (typeof window !== 'undefined') {\n (window as any).__REBILL_SDK_ASSETS_URL__ = assetsURL;\n }\n\n return assetsURL;\n};\n\n/**\n * Initialize the Rebill SDK with environment configuration\n *\n * This is OPTIONAL - the SDK works out of the box with production settings.\n * Only call this if you need to use staging or development environments.\n *\n * @param config - Configuration object for the SDK\n * @example\n * ```typescript\n * import { initializeRebillSDK } from 'rebill-web-components-sdk';\n *\n * // For staging (optional)\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true\n * });\n *\n * // For
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["src/initialize.ts","src/index.ts"],"sourcesContent":["/**\n * Rebill SDK Initialization Module\n *\n * This module provides a simple way for host applications to configure\n * the SDK for different environments. By default, the SDK uses production\n * configuration and requires no initialization for client applications.\n */\n\nimport { Environment, initializeSDK, RebillSDKConfig } from './api/config';\n\n// Import CDN configuration\nimport { CDN_ASSETS_URL } from './config/cdn';\n\n// Import assets configuration\nimport { setAssetsURL } from './utils/assets';\n\n// Re-export types for convenience\nexport type { Environment, RebillSDKConfig } from './api/config';\n\n// Re-export setAssetsURL for advanced use cases\nexport { setAssetsURL } from './utils/assets';\n\n/**\n * Configure assets URL for the SDK\n * This function sets up the assets URL to use CDN by default\n * but allows users to override with their own URL\n */\nexport const configureAssetsURL = (customAssetsURL?: string) => {\n const assetsURL = customAssetsURL || CDN_ASSETS_URL;\n\n // Set the assets URL globally for getAssetPath to use\n if (typeof window !== 'undefined') {\n (window as any).__REBILL_SDK_ASSETS_URL__ = assetsURL;\n }\n\n return assetsURL;\n};\n\n/**\n * Initialize the Rebill SDK with environment configuration\n *\n * This is OPTIONAL - the SDK works out of the box with production settings.\n * Only call this if you need to use staging or development environments,\n * or if you want to serve assets locally instead of from CDN.\n *\n * @param config - Configuration object for the SDK\n * @example\n * ```typescript\n * import { initializeRebillSDK } from 'rebill-web-components-sdk';\n *\n * // For staging with CDN assets (optional)\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true\n * });\n *\n * // For staging with local assets\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true,\n * assetsUrl: '/sdk/'\n * });\n *\n * // For production (optional - this is the default)\n * initializeRebillSDK({\n * environment: 'production',\n * debug: false\n * });\n * ```\n */\nexport const initializeRebillSDK = (config: RebillSDKConfig = {}) => {\n // Validate environment if provided\n if (config.environment) {\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n if (!validEnvironments.includes(config.environment)) {\n throw new Error(\n `Invalid environment \"${config.environment}\". Must be one of: ${validEnvironments.join(', ')}`,\n );\n }\n }\n\n // Configure assets URL if provided\n if (config.assetsUrl) {\n setAssetsURL(config.assetsUrl);\n if (config.debug !== false) {\n console.log(`📦 Assets URL configured: ${config.assetsUrl}`);\n }\n } else if (config.debug !== false) {\n console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);\n }\n\n // Initialize the SDK\n initializeSDK(config);\n\n // Log initialization success\n if (config.debug !== false) {\n console.log('✅ Rebill SDK initialized successfully');\n }\n};\n\n/**\n * Quick initialization helpers for common scenarios\n */\nexport const RebillSDK = {\n /**\n * Initialize for production environment (optional - this is the default)\n */\n forProduction: (debug: boolean = false) => {\n initializeRebillSDK({ environment: 'production', debug });\n },\n\n /**\n * Initialize for staging environment\n */\n forStaging: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'staging', debug });\n },\n\n /**\n * Initialize for development environment\n */\n forDevelopment: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'development', debug });\n },\n};\n\n// Default export for convenience\nexport default initializeRebillSDK;\n","/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\nexport type * from './components.d.ts';\n\n// Export SDK initialization utilities\nexport {\n initializeRebillSDK,\n RebillSDK,\n type Environment,\n type RebillSDKConfig,\n} from './initialize';\n\n// Export configuration utilities for advanced usage\nexport { getAPIConfig, getCurrentEnvironment, isDebugMode, type APIConfig } from './api/config';\n\n// Export assets utilities\nexport { getAssetURL, setAssetsURL } from './utils/assets';\n\n// Export enhanced defineCustomElements\nexport { defineCustomElementsWithAssets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IAAA,IAAIA,QAAM,CAAC,KAAK,KAAK,KAAK,EAAE;AAC1B,QAAA,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC;;AAExD;AAEA;;AAEG;AACU,MAAA,SAAS,GAAG;AACvB;;AAEG;AACH,IAAA,aAAa,EAAE,CAAC,KAAiB,GAAA,KAAK,KAAI;QACxC,mBAAmB,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;KAC1D;AAED;;AAEG;AACH,IAAA,UAAU,EAAE,CAAC,KAAiB,GAAA,IAAI,KAAI;QACpC,mBAAmB,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;KACvD;AAED;;AAEG;AACH,IAAA,cAAc,EAAE,CAAC,KAAiB,GAAA,IAAI,KAAI;QACxC,mBAAmB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;KAC3D;;;AC3HH;;;;;;;;AAQG;AAIH;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/api/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,8BAA8B;AAC9B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAUhF,MAAM,CAAC,MAAM,UAAU,GAAmC;IACxD,WAAW,EAAE;QACX,OAAO,EAAE,0BAA0B;QACnC,SAAS,EAAE,wBAAwB;QACnC,OAAO,EAAE,KAAK;KACf;IACD,OAAO,EAAE;QACP,OAAO,EAAE,2BAA2B;QACpC,SAAS,EAAE,+CAA+C;QAC1D,OAAO,EAAE,KAAK;KACf;IACD,UAAU,EAAE;QACV,OAAO,EAAE,2BAA2B;QACpC,SAAS,EAAE,8CAA8C;QACzD,OAAO,EAAE,KAAK;KACf;CACF,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot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AAY,EAAE,CAAC,WAAmB,EAAE,EAAE,CAAC,uBAAuB,WAAW,EAAE;QAC3E,aAAa,EAAE,CAAC,WAAmB,EAAE,EAAE,CAAC,yBAAyB,WAAW,EAAE;KAC/E;IACD,QAAQ,EAAE;QACR,mBAAmB,EAAE,kCAAkC;QACvD,GAAG,EAAE,eAAe;KACrB;IACD,QAAQ,EAAE;QACR,UAAU,EAAE,4BAA4B;QACxC,WAAW,EAAE,oBAAoB;QACjC,cAAc,EAAE,0BAA0B;QAC1C,aAAa,EAAE,CAAC,iBAAyB,EAAE,EAAE,CAAC,6BAA6B,iBAAiB,EAAE;KAC/F;IACD,cAAc,EAAE;QACd,KAAK,EAAE,CAAC,SAAiB,EAAE,UAAkB,EAAE,WAAmB,CAAC,EAAE,EAAE,CACrE,aAAa,SAAS,qBAAqB,UAAU,aAAa,QAAQ,EAAE;KAC/E;IACD,KAAK,EAAE;QACL,GAAG,EAAE,YAAY;KAClB;IACD,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,wBAAwB,IAAI,EAAE;KACtD;IACD,SAAS,EAAE;QACT,MAAM,EAAE,uBAAuB;KAChC;IACD,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,kBAAkB;KAC3B;CACO,CAAC","sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"]}
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
import { initializeSDK } from "./api/config";
|
|
9
9
|
// Import CDN configuration
|
|
10
10
|
import { CDN_ASSETS_URL } from "./config/cdn";
|
|
11
|
+
// Import assets configuration
|
|
12
|
+
import { setAssetsURL } from "./utils/assets";
|
|
13
|
+
// Re-export setAssetsURL for advanced use cases
|
|
14
|
+
export { setAssetsURL } from './utils/assets';
|
|
11
15
|
/**
|
|
12
16
|
* Configure assets URL for the SDK
|
|
13
17
|
* This function sets up the assets URL to use CDN by default
|
|
@@ -25,23 +29,25 @@ export const configureAssetsURL = (customAssetsURL) => {
|
|
|
25
29
|
* Initialize the Rebill SDK with environment configuration
|
|
26
30
|
*
|
|
27
31
|
* This is OPTIONAL - the SDK works out of the box with production settings.
|
|
28
|
-
* Only call this if you need to use staging or development environments
|
|
32
|
+
* Only call this if you need to use staging or development environments,
|
|
33
|
+
* or if you want to serve assets locally instead of from CDN.
|
|
29
34
|
*
|
|
30
35
|
* @param config - Configuration object for the SDK
|
|
31
36
|
* @example
|
|
32
37
|
* ```typescript
|
|
33
38
|
* import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
34
39
|
*
|
|
35
|
-
* // For staging (optional)
|
|
40
|
+
* // For staging with CDN assets (optional)
|
|
36
41
|
* initializeRebillSDK({
|
|
37
42
|
* environment: 'staging',
|
|
38
43
|
* debug: true
|
|
39
44
|
* });
|
|
40
45
|
*
|
|
41
|
-
* // For
|
|
46
|
+
* // For staging with local assets
|
|
42
47
|
* initializeRebillSDK({
|
|
43
|
-
* environment: '
|
|
44
|
-
* debug: true
|
|
48
|
+
* environment: 'staging',
|
|
49
|
+
* debug: true,
|
|
50
|
+
* assetsUrl: '/sdk/'
|
|
45
51
|
* });
|
|
46
52
|
*
|
|
47
53
|
* // For production (optional - this is the default)
|
|
@@ -59,6 +65,16 @@ export const initializeRebillSDK = (config = {}) => {
|
|
|
59
65
|
throw new Error(`Invalid environment "${config.environment}". Must be one of: ${validEnvironments.join(', ')}`);
|
|
60
66
|
}
|
|
61
67
|
}
|
|
68
|
+
// Configure assets URL if provided
|
|
69
|
+
if (config.assetsUrl) {
|
|
70
|
+
setAssetsURL(config.assetsUrl);
|
|
71
|
+
if (config.debug !== false) {
|
|
72
|
+
console.log(`📦 Assets URL configured: ${config.assetsUrl}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (config.debug !== false) {
|
|
76
|
+
console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);
|
|
77
|
+
}
|
|
62
78
|
// Initialize the SDK
|
|
63
79
|
initializeSDK(config);
|
|
64
80
|
// Log initialization success
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../src/initialize.ts"],"names":[],"mappings":"A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C;IAED;;OAEG;IACH,cAAc,EAAE,CAAC,QAAiB,IAAI,EAAE,EAAE;QACxC,mBAAmB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF,CAAC;AAEF,iCAAiC;AACjC,eAAe,mBAAmB,CAAC","sourcesContent":["/**\n * Rebill SDK Initialization Module\n *\n * This module provides a simple way for host applications to configure\n * the SDK for different environments. By default, the SDK uses production\n * configuration and requires no initialization for client applications.\n */\n\nimport { Environment, initializeSDK, RebillSDKConfig } from './api/config';\n\n// Import CDN configuration\nimport { CDN_ASSETS_URL } from './config/cdn';\n\n// Import assets configuration\nimport { setAssetsURL } from './utils/assets';\n\n// Re-export types for convenience\nexport type { Environment, RebillSDKConfig } from './api/config';\n\n// Re-export setAssetsURL for advanced use cases\nexport { setAssetsURL } from './utils/assets';\n\n/**\n * Configure assets URL for the SDK\n * This function sets up the assets URL to use CDN by default\n * but allows users to override with their own URL\n */\nexport const configureAssetsURL = (customAssetsURL?: string) => {\n const assetsURL = customAssetsURL || CDN_ASSETS_URL;\n\n // Set the assets URL globally for getAssetPath to use\n if (typeof window !== 'undefined') {\n (window as any).__REBILL_SDK_ASSETS_URL__ = assetsURL;\n }\n\n return assetsURL;\n};\n\n/**\n * Initialize the Rebill SDK with environment configuration\n *\n * This is OPTIONAL - the SDK works out of the box with production settings.\n * Only call this if you need to use staging or development environments,\n * or if you want to serve assets locally instead of from CDN.\n *\n * @param config - Configuration object for the SDK\n * @example\n * ```typescript\n * import { initializeRebillSDK } from 'rebill-web-components-sdk';\n *\n * // For staging with CDN assets (optional)\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true\n * });\n *\n * // For staging with local assets\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true,\n * assetsUrl: '/sdk/'\n * });\n *\n * // For production (optional - this is the default)\n * initializeRebillSDK({\n * environment: 'production',\n * debug: false\n * });\n * ```\n */\nexport const initializeRebillSDK = (config: RebillSDKConfig = {}) => {\n // Validate environment if provided\n if (config.environment) {\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n if (!validEnvironments.includes(config.environment)) {\n throw new Error(\n `Invalid environment \"${config.environment}\". Must be one of: ${validEnvironments.join(', ')}`,\n );\n }\n }\n\n // Configure assets URL if provided\n if (config.assetsUrl) {\n setAssetsURL(config.assetsUrl);\n if (config.debug !== false) {\n console.log(`📦 Assets URL configured: ${config.assetsUrl}`);\n }\n } else if (config.debug !== false) {\n console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);\n }\n\n // Initialize the SDK\n initializeSDK(config);\n\n // Log initialization success\n if (config.debug !== false) {\n console.log('✅ Rebill SDK initialized successfully');\n }\n};\n\n/**\n * Quick initialization helpers for common scenarios\n */\nexport const RebillSDK = {\n /**\n * Initialize for production environment (optional - this is the default)\n */\n forProduction: (debug: boolean = false) => {\n initializeRebillSDK({ environment: 'production', debug });\n },\n\n /**\n * Initialize for staging environment\n */\n forStaging: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'staging', debug });\n },\n\n /**\n * Initialize for development environment\n */\n forDevelopment: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'development', debug });\n },\n};\n\n// Default export for convenience\nexport default initializeRebillSDK;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"config.js","mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;A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E,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,mBAAmB,EAAE,kCAAkC;AACvD,QAAA,GAAG,EAAE,eAAe;AACrB,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,4BAA4B;AACxC,QAAA,WAAW,EAAE,oBAAoB;AACjC,QAAA,cAAc,EAAE,0BAA0B;QAC1C,aAAa,EAAE,CAAC,iBAAyB,KAAK,CAAA,0BAAA,EAA6B,iBAAiB,CAAE,CAAA;AAC/F,KAAA;AACD,IAAA,cAAc,EAAE;AACd,QAAA,KAAK,EAAE,CAAC,SAAiB,EAAE,UAAkB,EAAE,QAAmB,GAAA,CAAC,KACjE,CAAa,UAAA,EAAA,SAAS,qBAAqB,UAAU,CAAA,UAAA,EAAa,QAAQ,CAAE,CAAA;AAC/E,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,GAAG,EAAE,YAAY;AAClB,KAAA;AACD,IAAA,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,IAAY,KAAK,CAAA,qBAAA,EAAwB,IAAI,CAAE,CAAA;AACtD,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;","names":[],"sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"version":3}
|
package/dist/components/index.js
CHANGED
|
@@ -3,7 +3,8 @@ export { a as getAssetPath, r as render, s as setAssetPath, b as setNonce, c as
|
|
|
3
3
|
import { i as initializeSDK } from './config.js';
|
|
4
4
|
export { g as getAPIConfig, a as getCurrentEnvironment, b as isDebugMode } from './config.js';
|
|
5
5
|
import { C as CDN_ASSETS_URL } from './cdn.js';
|
|
6
|
-
|
|
6
|
+
import { s as setAssetsURL } from './assets.js';
|
|
7
|
+
export { g as getAssetURL } from './assets.js';
|
|
7
8
|
export { d as defineCustomElementsWithAssets } from './stencil-wrapper.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -30,23 +31,25 @@ const configureAssetsURL = (customAssetsURL) => {
|
|
|
30
31
|
* Initialize the Rebill SDK with environment configuration
|
|
31
32
|
*
|
|
32
33
|
* This is OPTIONAL - the SDK works out of the box with production settings.
|
|
33
|
-
* Only call this if you need to use staging or development environments
|
|
34
|
+
* Only call this if you need to use staging or development environments,
|
|
35
|
+
* or if you want to serve assets locally instead of from CDN.
|
|
34
36
|
*
|
|
35
37
|
* @param config - Configuration object for the SDK
|
|
36
38
|
* @example
|
|
37
39
|
* ```typescript
|
|
38
40
|
* import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
39
41
|
*
|
|
40
|
-
* // For staging (optional)
|
|
42
|
+
* // For staging with CDN assets (optional)
|
|
41
43
|
* initializeRebillSDK({
|
|
42
44
|
* environment: 'staging',
|
|
43
45
|
* debug: true
|
|
44
46
|
* });
|
|
45
47
|
*
|
|
46
|
-
* // For
|
|
48
|
+
* // For staging with local assets
|
|
47
49
|
* initializeRebillSDK({
|
|
48
|
-
* environment: '
|
|
49
|
-
* debug: true
|
|
50
|
+
* environment: 'staging',
|
|
51
|
+
* debug: true,
|
|
52
|
+
* assetsUrl: '/sdk/'
|
|
50
53
|
* });
|
|
51
54
|
*
|
|
52
55
|
* // For production (optional - this is the default)
|
|
@@ -64,6 +67,16 @@ const initializeRebillSDK = (config = {}) => {
|
|
|
64
67
|
throw new Error(`Invalid environment "${config.environment}". Must be one of: ${validEnvironments.join(', ')}`);
|
|
65
68
|
}
|
|
66
69
|
}
|
|
70
|
+
// Configure assets URL if provided
|
|
71
|
+
if (config.assetsUrl) {
|
|
72
|
+
setAssetsURL(config.assetsUrl);
|
|
73
|
+
if (config.debug !== false) {
|
|
74
|
+
console.log(`📦 Assets URL configured: ${config.assetsUrl}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (config.debug !== false) {
|
|
78
|
+
console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);
|
|
79
|
+
}
|
|
67
80
|
// Initialize the SDK
|
|
68
81
|
initializeSDK(config);
|
|
69
82
|
// Log initialization success
|
|
@@ -108,7 +121,7 @@ const RebillSDK = {
|
|
|
108
121
|
|
|
109
122
|
globalScripts();
|
|
110
123
|
|
|
111
|
-
export { RebillSDK, initializeRebillSDK };
|
|
124
|
+
export { RebillSDK, initializeRebillSDK, setAssetsURL };
|
|
112
125
|
//# sourceMappingURL=index.js.map
|
|
113
126
|
|
|
114
127
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"index.js","mappings":"
|
|
1
|
+
{"file":"index.js","mappings":";;;;;;;;;AAAA;;;;;;AAMG;AAgBH;;;;AAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,eAAwB,KAAI;AAC7D,IAAA,MAAM,SAAS,GAAG,eAAe,IAAI,cAAc;;AAGnD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,QAAA,MAAc,CAAC,yBAAyB,GAAG,SAAS;;AAGvD,IAAA,OAAO,SAAS;AAClB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;MACU,mBAAmB,GAAG,CAAC,MAA0B,GAAA,EAAE,KAAI;;AAElE,IAAA,IAAI,MAAM,CAAC,WAAW,EAAE;QACtB,MAAM,iBAAiB,GAAkB,CAAC,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC;QACjF,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;AACnD,YAAA,MAAM,IAAI,KAAK,CACb,CAAwB,qBAAA,EAAA,MAAM,CAAC,WAAW,CAAA,mBAAA,EAAsB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAC/F;;;;AAKL,IAAA,IAAI,MAAM,CAAC,SAAS,EAAE;AACpB,QAAA,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;AAC9B,QAAA,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;YAC1B,OAAO,CAAC,GAAG,CAAC,CAAA,0BAAA,EAA6B,MAAM,CAAC,SAAS,CAAE,CAAA,CAAC;;;AAEzD,SAAA,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;AACjC,QAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,cAAc,CAAA,CAAE,CAAC;;;IAI3D,aAAa,CAAC,MAAM,CAAC;;AAGrB,IAAA,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;AAC1B,QAAA,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC;;AAExD;AAEA;;AAEG;AACU,MAAA,SAAS,GAAG;AACvB;;AAEG;AACH,IAAA,aAAa,EAAE,CAAC,KAAiB,GAAA,KAAK,KAAI;QACxC,mBAAmB,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;KAC1D;AAED;;AAEG;AACH,IAAA,UAAU,EAAE,CAAC,KAAiB,GAAA,IAAI,KAAI;QACpC,mBAAmB,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;KACvD;AAED;;AAEG;AACH,IAAA,cAAc,EAAE,CAAC,KAAiB,GAAA,IAAI,KAAI;QACxC,mBAAmB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;KAC3D;;;AC3HH;;;;;;;;AAQG;AAIH;;;;;;","names":[],"sources":["src/initialize.ts","src/index.ts"],"sourcesContent":["/**\n * Rebill SDK Initialization Module\n *\n * This module provides a simple way for host applications to configure\n * the SDK for different environments. By default, the SDK uses production\n * configuration and requires no initialization for client applications.\n */\n\nimport { Environment, initializeSDK, RebillSDKConfig } from './api/config';\n\n// Import CDN configuration\nimport { CDN_ASSETS_URL } from './config/cdn';\n\n// Import assets configuration\nimport { setAssetsURL } from './utils/assets';\n\n// Re-export types for convenience\nexport type { Environment, RebillSDKConfig } from './api/config';\n\n// Re-export setAssetsURL for advanced use cases\nexport { setAssetsURL } from './utils/assets';\n\n/**\n * Configure assets URL for the SDK\n * This function sets up the assets URL to use CDN by default\n * but allows users to override with their own URL\n */\nexport const configureAssetsURL = (customAssetsURL?: string) => {\n const assetsURL = customAssetsURL || CDN_ASSETS_URL;\n\n // Set the assets URL globally for getAssetPath to use\n if (typeof window !== 'undefined') {\n (window as any).__REBILL_SDK_ASSETS_URL__ = assetsURL;\n }\n\n return assetsURL;\n};\n\n/**\n * Initialize the Rebill SDK with environment configuration\n *\n * This is OPTIONAL - the SDK works out of the box with production settings.\n * Only call this if you need to use staging or development environments,\n * or if you want to serve assets locally instead of from CDN.\n *\n * @param config - Configuration object for the SDK\n * @example\n * ```typescript\n * import { initializeRebillSDK } from 'rebill-web-components-sdk';\n *\n * // For staging with CDN assets (optional)\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true\n * });\n *\n * // For staging with local assets\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true,\n * assetsUrl: '/sdk/'\n * });\n *\n * // For production (optional - this is the default)\n * initializeRebillSDK({\n * environment: 'production',\n * debug: false\n * });\n * ```\n */\nexport const initializeRebillSDK = (config: RebillSDKConfig = {}) => {\n // Validate environment if provided\n if (config.environment) {\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n if (!validEnvironments.includes(config.environment)) {\n throw new Error(\n `Invalid environment \"${config.environment}\". Must be one of: ${validEnvironments.join(', ')}`,\n );\n }\n }\n\n // Configure assets URL if provided\n if (config.assetsUrl) {\n setAssetsURL(config.assetsUrl);\n if (config.debug !== false) {\n console.log(`📦 Assets URL configured: ${config.assetsUrl}`);\n }\n } else if (config.debug !== false) {\n console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);\n }\n\n // Initialize the SDK\n initializeSDK(config);\n\n // Log initialization success\n if (config.debug !== false) {\n console.log('✅ Rebill SDK initialized successfully');\n }\n};\n\n/**\n * Quick initialization helpers for common scenarios\n */\nexport const RebillSDK = {\n /**\n * Initialize for production environment (optional - this is the default)\n */\n forProduction: (debug: boolean = false) => {\n initializeRebillSDK({ environment: 'production', debug });\n },\n\n /**\n * Initialize for staging environment\n */\n forStaging: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'staging', debug });\n },\n\n /**\n * Initialize for development environment\n */\n forDevelopment: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'development', debug });\n },\n};\n\n// Default export for convenience\nexport default initializeRebillSDK;\n","/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\nexport type * from './components.d.ts';\n\n// Export SDK initialization utilities\nexport {\n initializeRebillSDK,\n RebillSDK,\n type Environment,\n type RebillSDKConfig,\n} from './initialize';\n\n// Export configuration utilities for advanced usage\nexport { getAPIConfig, getCurrentEnvironment, isDebugMode, type APIConfig } from './api/config';\n\n// Export assets utilities\nexport { getAssetURL, setAssetsURL } from './utils/assets';\n\n// Export enhanced defineCustomElements\nexport { defineCustomElementsWithAssets } from './utils/stencil-wrapper';\n\nexport { setAssetPath } from '@stencil/core';\n"],"version":3}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"p-DWIgRPXl.js","mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;
|
|
1
|
+
{"file":"p-DWIgRPXl.js","mappings":";;;AAaO,MAAM,UAAU,GAAmC;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AE,CAAA;AAC/F,KAAA;AACD,IAAA,cAAc,EAAE;AACd,QAAA,KAAK,EAAE,CAAC,SAAiB,EAAE,UAAkB,EAAE,QAAmB,GAAA,CAAC,KACjE,CAAa,UAAA,EAAA,SAAS,qBAAqB,UAAU,CAAA,UAAA,EAAa,QAAQ,CAAE,CAAA;AAC/E,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,GAAG,EAAE,YAAY;AAClB,KAAA;AACD,IAAA,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,IAAY,KAAK,CAAA,qBAAA,EAAwB,IAAI,CAAE,CAAA;AACtD,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;","names":[],"sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"version":3}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-B8mUEd79.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;
|
|
1
|
+
{"version":3,"file":"config-B8mUEd79.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,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,CAAA,qBAAA,EAAwB,IAAI,CAAE,CAAA;AACtD,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-BLghMKz-.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;
|
|
1
|
+
{"version":3,"file":"config-BLghMKz-.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;AASD;AACA,IAAI,YAAY,GAAoB,EAAE;AAEtC;;;AAGG;MACU,aAAa,GAAG,CAAC,MAA0B,GAAA,EAAE,KAAI;AAC5D,IAAA,YAAY,GAAG;QACb,WAAW,EAAE,YAAY;AACzB,QAAA,KAAK,EAAE,KAAK;AACZ,QAAA,GAAG,MAAM;KACV;AAED,IAAA,IAAI,YAAY,CA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AAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { i as initializeSDK } from './config-BLghMKz-.js';
|
|
2
2
|
export { g as getAPIConfig, a as getCurrentEnvironment, b as isDebugMode } from './config-BLghMKz-.js';
|
|
3
3
|
import { C as CDN_ASSETS_URL } from './cdn-D6m0Kscr.js';
|
|
4
|
-
|
|
4
|
+
import { s as setAssetsURL } from './assets-DahMz1Fn.js';
|
|
5
|
+
export { g as getAssetURL } from './assets-DahMz1Fn.js';
|
|
5
6
|
export { d as defineCustomElementsWithAssets } from './stencil-wrapper-Bc--EjRm.js';
|
|
6
7
|
export { a as setAssetPath } from './index-C_sJwcUU.js';
|
|
7
8
|
|
|
@@ -29,23 +30,25 @@ const configureAssetsURL = (customAssetsURL) => {
|
|
|
29
30
|
* Initialize the Rebill SDK with environment configuration
|
|
30
31
|
*
|
|
31
32
|
* This is OPTIONAL - the SDK works out of the box with production settings.
|
|
32
|
-
* Only call this if you need to use staging or development environments
|
|
33
|
+
* Only call this if you need to use staging or development environments,
|
|
34
|
+
* or if you want to serve assets locally instead of from CDN.
|
|
33
35
|
*
|
|
34
36
|
* @param config - Configuration object for the SDK
|
|
35
37
|
* @example
|
|
36
38
|
* ```typescript
|
|
37
39
|
* import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
38
40
|
*
|
|
39
|
-
* // For staging (optional)
|
|
41
|
+
* // For staging with CDN assets (optional)
|
|
40
42
|
* initializeRebillSDK({
|
|
41
43
|
* environment: 'staging',
|
|
42
44
|
* debug: true
|
|
43
45
|
* });
|
|
44
46
|
*
|
|
45
|
-
* // For
|
|
47
|
+
* // For staging with local assets
|
|
46
48
|
* initializeRebillSDK({
|
|
47
|
-
* environment: '
|
|
48
|
-
* debug: true
|
|
49
|
+
* environment: 'staging',
|
|
50
|
+
* debug: true,
|
|
51
|
+
* assetsUrl: '/sdk/'
|
|
49
52
|
* });
|
|
50
53
|
*
|
|
51
54
|
* // For production (optional - this is the default)
|
|
@@ -63,6 +66,16 @@ const initializeRebillSDK = (config = {}) => {
|
|
|
63
66
|
throw new Error(`Invalid environment "${config.environment}". Must be one of: ${validEnvironments.join(', ')}`);
|
|
64
67
|
}
|
|
65
68
|
}
|
|
69
|
+
// Configure assets URL if provided
|
|
70
|
+
if (config.assetsUrl) {
|
|
71
|
+
setAssetsURL(config.assetsUrl);
|
|
72
|
+
if (config.debug !== false) {
|
|
73
|
+
console.log(`📦 Assets URL configured: ${config.assetsUrl}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (config.debug !== false) {
|
|
77
|
+
console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);
|
|
78
|
+
}
|
|
66
79
|
// Initialize the SDK
|
|
67
80
|
initializeSDK(config);
|
|
68
81
|
// Log initialization success
|
|
@@ -105,7 +118,7 @@ const RebillSDK = {
|
|
|
105
118
|
*/
|
|
106
119
|
// Export SDK initialization utilities
|
|
107
120
|
|
|
108
|
-
export { RebillSDK, initializeRebillSDK };
|
|
121
|
+
export { RebillSDK, initializeRebillSDK, setAssetsURL };
|
|
109
122
|
//# sourceMappingURL=index.js.map
|
|
110
123
|
|
|
111
124
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["src/initialize.ts","src/index.ts"],"sourcesContent":["/**\n * Rebill SDK Initialization Module\n *\n * This module provides a simple way for host applications to configure\n * the SDK for different environments. By default, the SDK uses production\n * configuration and requires no initialization for client applications.\n */\n\nimport { Environment, initializeSDK, RebillSDKConfig } from './api/config';\n\n// Import CDN configuration\nimport { CDN_ASSETS_URL } from './config/cdn';\n\n// Re-export types for convenience\nexport type { Environment, RebillSDKConfig } from './api/config';\n\n/**\n * Configure assets URL for the SDK\n * This function sets up the assets URL to use CDN by default\n * but allows users to override with their own URL\n */\nexport const configureAssetsURL = (customAssetsURL?: string) => {\n const assetsURL = customAssetsURL || CDN_ASSETS_URL;\n\n // Set the assets URL globally for getAssetPath to use\n if (typeof window !== 'undefined') {\n (window as any).__REBILL_SDK_ASSETS_URL__ = assetsURL;\n }\n\n return assetsURL;\n};\n\n/**\n * Initialize the Rebill SDK with environment configuration\n *\n * This is OPTIONAL - the SDK works out of the box with production settings.\n * Only call this if you need to use staging or development environments.\n *\n * @param config - Configuration object for the SDK\n * @example\n * ```typescript\n * import { initializeRebillSDK } from 'rebill-web-components-sdk';\n *\n * // For staging (optional)\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true\n * });\n *\n * // For
|
|
1
|
+
{"version":3,"file":"index.js","sources":["src/initialize.ts","src/index.ts"],"sourcesContent":["/**\n * Rebill SDK Initialization Module\n *\n * This module provides a simple way for host applications to configure\n * the SDK for different environments. By default, the SDK uses production\n * configuration and requires no initialization for client applications.\n */\n\nimport { Environment, initializeSDK, RebillSDKConfig } from './api/config';\n\n// Import CDN configuration\nimport { CDN_ASSETS_URL } from './config/cdn';\n\n// Import assets configuration\nimport { setAssetsURL } from './utils/assets';\n\n// Re-export types for convenience\nexport type { Environment, RebillSDKConfig } from './api/config';\n\n// Re-export setAssetsURL for advanced use cases\nexport { setAssetsURL } from './utils/assets';\n\n/**\n * Configure assets URL for the SDK\n * This function sets up the assets URL to use CDN by default\n * but allows users to override with their own URL\n */\nexport const configureAssetsURL = (customAssetsURL?: string) => {\n const assetsURL = customAssetsURL || CDN_ASSETS_URL;\n\n // Set the assets URL globally for getAssetPath to use\n if (typeof window !== 'undefined') {\n (window as any).__REBILL_SDK_ASSETS_URL__ = assetsURL;\n }\n\n return assetsURL;\n};\n\n/**\n * Initialize the Rebill SDK with environment configuration\n *\n * This is OPTIONAL - the SDK works out of the box with production settings.\n * Only call this if you need to use staging or development environments,\n * or if you want to serve assets locally instead of from CDN.\n *\n * @param config - Configuration object for the SDK\n * @example\n * ```typescript\n * import { initializeRebillSDK } from 'rebill-web-components-sdk';\n *\n * // For staging with CDN assets (optional)\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true\n * });\n *\n * // For staging with local assets\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true,\n * assetsUrl: '/sdk/'\n * });\n *\n * // For production (optional - this is the default)\n * initializeRebillSDK({\n * environment: 'production',\n * debug: false\n * });\n * ```\n */\nexport const initializeRebillSDK = (config: RebillSDKConfig = {}) => {\n // Validate environment if provided\n if (config.environment) {\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n if (!validEnvironments.includes(config.environment)) {\n throw new Error(\n `Invalid environment \"${config.environment}\". Must be one of: ${validEnvironments.join(', ')}`,\n );\n }\n }\n\n // Configure assets URL if provided\n if (config.assetsUrl) {\n setAssetsURL(config.assetsUrl);\n if (config.debug !== false) {\n console.log(`📦 Assets URL configured: ${config.assetsUrl}`);\n }\n } else if (config.debug !== false) {\n console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);\n }\n\n // Initialize the SDK\n initializeSDK(config);\n\n // Log initialization success\n if (config.debug !== false) {\n console.log('✅ Rebill SDK initialized successfully');\n }\n};\n\n/**\n * Quick initialization helpers for common scenarios\n */\nexport const RebillSDK = {\n /**\n * Initialize for production environment (optional - this is the default)\n */\n forProduction: (debug: boolean = false) => {\n initializeRebillSDK({ environment: 'production', debug });\n },\n\n /**\n * Initialize for staging environment\n */\n forStaging: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'staging', debug });\n },\n\n /**\n * Initialize for development environment\n */\n forDevelopment: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'development', debug });\n },\n};\n\n// Default export for convenience\nexport default initializeRebillSDK;\n","/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\nexport type * from './components.d.ts';\n\n// Export SDK initialization utilities\nexport {\n initializeRebillSDK,\n RebillSDK,\n type Environment,\n type RebillSDKConfig,\n} from './initialize';\n\n// Export configuration utilities for advanced usage\nexport { getAPIConfig, getCurrentEnvironment, isDebugMode, type APIConfig } from './api/config';\n\n// Export assets utilities\nexport { getAssetURL, setAssetsURL } from './utils/assets';\n\n// Export enhanced defineCustomElements\nexport { defineCustomElementsWithAssets } from './utils/stencil-wrapper';\n\nexport { setAssetPath } from '@stencil/core';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;AAMG;AAgBH;;;;AAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,eAAwB,KAAI;AAC7D,IAAA,MAAM,SAAS,GAAG,eAAe,IAAI,cAAc;;AAGnD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,QAAA,MAAc,CAAC,yBAAyB,GAAG,SAAS;;AAGvD,IAAA,OAAO,SAAS;AAClB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;MACU,mBAAmB,GAAG,CAAC,MAA0B,GAAA,EAAE,KAAI;;AAElE,IAAA,IAAI,MAAM,CAAC,WAAW,EAAE;QACtB,MAAM,iBAAiB,GAAkB,CAAC,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC;QACjF,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;AACnD,YAAA,MAAM,IAAI,KAAK,CACb,CAAwB,qBAAA,EAAA,MAAM,CAAC,WAAW,CAAA,mBAAA,EAAsB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE,CAC/F;;;;AAKL,IAAA,IAAI,MAAM,CAAC,SAAS,EAAE;AACpB,QAAA,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC;AAC9B,QAAA,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;YAC1B,OAAO,CAAC,GAAG,CAAC,CAAA,0BAAA,EAA6B,MAAM,CAAC,SAAS,CAAE,CAAA,CAAC;;;AAEzD,SAAA,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;AACjC,QAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,cAAc,CAAA,CAAE,CAAC;;;IAI3D,aAAa,CAAC,MAAM,CAAC;;AAGrB,IAAA,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;AAC1B,QAAA,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC;;AAExD;AAEA;;AAEG;AACU,MAAA,SAAS,GAAG;AACvB;;AAEG;AACH,IAAA,aAAa,EAAE,CAAC,KAAiB,GAAA,KAAK,KAAI;QACxC,mBAAmB,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;KAC1D;AAED;;AAEG;AACH,IAAA,UAAU,EAAE,CAAC,KAAiB,GAAA,IAAI,KAAI;QACpC,mBAAmB,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;KACvD;AAED;;AAEG;AACH,IAAA,cAAc,EAAE,CAAC,KAAiB,GAAA,IAAI,KAAI;QACxC,mBAAmB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;KAC3D;;;AC3HH;;;;;;;;AAQG;AAIH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-BLghMKz-.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;
|
|
1
|
+
{"version":3,"file":"config-BLghMKz-.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":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R,QAAA,mBAAmB,EAAE,kCAAkC;AACvD,QAAA,GAAG,EAAE,eAAe;AACrB,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,UAAU,EAAE,4BAA4B;AACxC,QAAA,WAAW,EAAE,oBAAoB;AACjC,QAAA,cAAc,EAAE,0BAA0B;QAC1C,aAAa,EAAE,CAAC,iBAAyB,KAAK,CAAA,0BAAA,EAA6B,iBAAiB,CAAE,CAAA;AAC/F,KAAA;AACD,IAAA,cAAc,EAAE;AACd,QAAA,KAAK,EAAE,CAAC,SAAiB,EAAE,UAAkB,EAAE,QAAmB,GAAA,CAAC,KACjE,CAAa,UAAA,EAAA,SAAS,qBAAqB,UAAU,CAAA,UAAA,EAAa,QAAQ,CAAE,CAAA;AAC/E,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,GAAG,EAAE,YAAY;AAClB,KAAA;AACD,IAAA,WAAW,EAAE;QACX,GAAG,EAAE,CAAC,IAAY,KAAK,CAAA,qBAAA,EAAwB,IAAI,CAAE,CAAA;AACtD,KAAA;AACD,IAAA,SAAS,EAAE;AACT,QAAA,MAAM,EAAE,uBAAuB;AAChC,KAAA;AACD,IAAA,GAAG,EAAE;AACH,QAAA,QAAQ,EAAE,MAAM;AAChB,QAAA,MAAM,EAAE,kBAAkB;AAC3B,KAAA;;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { i as initializeSDK } from './config-BLghMKz-.js';
|
|
2
2
|
export { g as getAPIConfig, a as getCurrentEnvironment, b as isDebugMode } from './config-BLghMKz-.js';
|
|
3
3
|
import { C as CDN_ASSETS_URL } from './cdn-D6m0Kscr.js';
|
|
4
|
-
|
|
4
|
+
import { s as setAssetsURL } from './assets-DahMz1Fn.js';
|
|
5
|
+
export { g as getAssetURL } from './assets-DahMz1Fn.js';
|
|
5
6
|
export { d as defineCustomElementsWithAssets } from './stencil-wrapper-Bc--EjRm.js';
|
|
6
7
|
export { a as setAssetPath } from './index-C_sJwcUU.js';
|
|
7
8
|
|
|
@@ -29,23 +30,25 @@ const configureAssetsURL = (customAssetsURL) => {
|
|
|
29
30
|
* Initialize the Rebill SDK with environment configuration
|
|
30
31
|
*
|
|
31
32
|
* This is OPTIONAL - the SDK works out of the box with production settings.
|
|
32
|
-
* Only call this if you need to use staging or development environments
|
|
33
|
+
* Only call this if you need to use staging or development environments,
|
|
34
|
+
* or if you want to serve assets locally instead of from CDN.
|
|
33
35
|
*
|
|
34
36
|
* @param config - Configuration object for the SDK
|
|
35
37
|
* @example
|
|
36
38
|
* ```typescript
|
|
37
39
|
* import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
38
40
|
*
|
|
39
|
-
* // For staging (optional)
|
|
41
|
+
* // For staging with CDN assets (optional)
|
|
40
42
|
* initializeRebillSDK({
|
|
41
43
|
* environment: 'staging',
|
|
42
44
|
* debug: true
|
|
43
45
|
* });
|
|
44
46
|
*
|
|
45
|
-
* // For
|
|
47
|
+
* // For staging with local assets
|
|
46
48
|
* initializeRebillSDK({
|
|
47
|
-
* environment: '
|
|
48
|
-
* debug: true
|
|
49
|
+
* environment: 'staging',
|
|
50
|
+
* debug: true,
|
|
51
|
+
* assetsUrl: '/sdk/'
|
|
49
52
|
* });
|
|
50
53
|
*
|
|
51
54
|
* // For production (optional - this is the default)
|
|
@@ -63,6 +66,16 @@ const initializeRebillSDK = (config = {}) => {
|
|
|
63
66
|
throw new Error(`Invalid environment "${config.environment}". Must be one of: ${validEnvironments.join(', ')}`);
|
|
64
67
|
}
|
|
65
68
|
}
|
|
69
|
+
// Configure assets URL if provided
|
|
70
|
+
if (config.assetsUrl) {
|
|
71
|
+
setAssetsURL(config.assetsUrl);
|
|
72
|
+
if (config.debug !== false) {
|
|
73
|
+
console.log(`📦 Assets URL configured: ${config.assetsUrl}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else if (config.debug !== false) {
|
|
77
|
+
console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);
|
|
78
|
+
}
|
|
66
79
|
// Initialize the SDK
|
|
67
80
|
initializeSDK(config);
|
|
68
81
|
// Log initialization success
|
|
@@ -105,7 +118,7 @@ const RebillSDK = {
|
|
|
105
118
|
*/
|
|
106
119
|
// Export SDK initialization utilities
|
|
107
120
|
|
|
108
|
-
export { RebillSDK, initializeRebillSDK };
|
|
121
|
+
export { RebillSDK, initializeRebillSDK, setAssetsURL };
|
|
109
122
|
//# sourceMappingURL=index.esm.js.map
|
|
110
123
|
|
|
111
124
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["src/initialize.ts","src/index.ts"],"sourcesContent":["/**\n * Rebill SDK Initialization Module\n *\n * This module provides a simple way for host applications to configure\n * the SDK for different environments. By default, the SDK uses production\n * configuration and requires no initialization for client applications.\n */\n\nimport { Environment, initializeSDK, RebillSDKConfig } from './api/config';\n\n// Import CDN configuration\nimport { CDN_ASSETS_URL } from './config/cdn';\n\n// Re-export types for convenience\nexport type { Environment, RebillSDKConfig } from './api/config';\n\n/**\n * Configure assets URL for the SDK\n * This function sets up the assets URL to use CDN by default\n * but allows users to override with their own URL\n */\nexport const configureAssetsURL = (customAssetsURL?: string) => {\n const assetsURL = customAssetsURL || CDN_ASSETS_URL;\n\n // Set the assets URL globally for getAssetPath to use\n if (typeof window !== 'undefined') {\n (window as any).__REBILL_SDK_ASSETS_URL__ = assetsURL;\n }\n\n return assetsURL;\n};\n\n/**\n * Initialize the Rebill SDK with environment configuration\n *\n * This is OPTIONAL - the SDK works out of the box with production settings.\n * Only call this if you need to use staging or development environments.\n *\n * @param config - Configuration object for the SDK\n * @example\n * ```typescript\n * import { initializeRebillSDK } from 'rebill-web-components-sdk';\n *\n * // For staging (optional)\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true\n * });\n *\n * // For
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["src/initialize.ts","src/index.ts"],"sourcesContent":["/**\n * Rebill SDK Initialization Module\n *\n * This module provides a simple way for host applications to configure\n * the SDK for different environments. By default, the SDK uses production\n * configuration and requires no initialization for client applications.\n */\n\nimport { Environment, initializeSDK, RebillSDKConfig } from './api/config';\n\n// Import CDN configuration\nimport { CDN_ASSETS_URL } from './config/cdn';\n\n// Import assets configuration\nimport { setAssetsURL } from './utils/assets';\n\n// Re-export types for convenience\nexport type { Environment, RebillSDKConfig } from './api/config';\n\n// Re-export setAssetsURL for advanced use cases\nexport { setAssetsURL } from './utils/assets';\n\n/**\n * Configure assets URL for the SDK\n * This function sets up the assets URL to use CDN by default\n * but allows users to override with their own URL\n */\nexport const configureAssetsURL = (customAssetsURL?: string) => {\n const assetsURL = customAssetsURL || CDN_ASSETS_URL;\n\n // Set the assets URL globally for getAssetPath to use\n if (typeof window !== 'undefined') {\n (window as any).__REBILL_SDK_ASSETS_URL__ = assetsURL;\n }\n\n return assetsURL;\n};\n\n/**\n * Initialize the Rebill SDK with environment configuration\n *\n * This is OPTIONAL - the SDK works out of the box with production settings.\n * Only call this if you need to use staging or development environments,\n * or if you want to serve assets locally instead of from CDN.\n *\n * @param config - Configuration object for the SDK\n * @example\n * ```typescript\n * import { initializeRebillSDK } from 'rebill-web-components-sdk';\n *\n * // For staging with CDN assets (optional)\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true\n * });\n *\n * // For staging with local assets\n * initializeRebillSDK({\n * environment: 'staging',\n * debug: true,\n * assetsUrl: '/sdk/'\n * });\n *\n * // For production (optional - this is the default)\n * initializeRebillSDK({\n * environment: 'production',\n * debug: false\n * });\n * ```\n */\nexport const initializeRebillSDK = (config: RebillSDKConfig = {}) => {\n // Validate environment if provided\n if (config.environment) {\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n if (!validEnvironments.includes(config.environment)) {\n throw new Error(\n `Invalid environment \"${config.environment}\". Must be one of: ${validEnvironments.join(', ')}`,\n );\n }\n }\n\n // Configure assets URL if provided\n if (config.assetsUrl) {\n setAssetsURL(config.assetsUrl);\n if (config.debug !== false) {\n console.log(`📦 Assets URL configured: ${config.assetsUrl}`);\n }\n } else if (config.debug !== false) {\n console.log(`📦 Using CDN for assets: ${CDN_ASSETS_URL}`);\n }\n\n // Initialize the SDK\n initializeSDK(config);\n\n // Log initialization success\n if (config.debug !== false) {\n console.log('✅ Rebill SDK initialized successfully');\n }\n};\n\n/**\n * Quick initialization helpers for common scenarios\n */\nexport const RebillSDK = {\n /**\n * Initialize for production environment (optional - this is the default)\n */\n forProduction: (debug: boolean = false) => {\n initializeRebillSDK({ environment: 'production', debug });\n },\n\n /**\n * Initialize for staging environment\n */\n forStaging: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'staging', debug });\n },\n\n /**\n * Initialize for development environment\n */\n forDevelopment: (debug: boolean = true) => {\n initializeRebillSDK({ environment: 'development', debug });\n },\n};\n\n// Default export for convenience\nexport default initializeRebillSDK;\n","/**\n * @fileoverview entry point for your component library\n *\n * This is the entry point for your component library. Use this file to export utilities,\n * constants or data structure that accompany your components.\n *\n * DO NOT use this file to export your components. Instead, use the recommended approaches\n * to consume components of this package as outlined in the `README.md`.\n */\n\nexport type * from './components.d.ts';\n\n// Export SDK initialization utilities\nexport {\n initializeRebillSDK,\n RebillSDK,\n type Environment,\n type RebillSDKConfig,\n} from './initialize';\n\n// Export configuration utilities for advanced usage\nexport { getAPIConfig, getCurrentEnvironment, isDebugMode, type APIConfig } from './api/config';\n\n// Export assets utilities\nexport { getAssetURL, setAssetsURL } from './utils/assets';\n\n// Export enhanced defineCustomElements\nexport { defineCustomElementsWithAssets } from './utils/stencil-wrapper';\n\nexport { setAssetPath } from '@stencil/core';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;AAMG;AAgBH;;;;AAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,eAAwB,KAAI;AAC7D,IAAA,MAAM,SAAS,GAAG,eAAe,IAAI,cAAc;;AAGnD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAChC,QAAA,MAAc,CAAC,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AAiB,GAAA,IAAI,KAAI;QACpC,mBAAmB,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;KACvD;AAED;;AAEG;AACH,IAAA,cAAc,EAAE,CAAC,KAAiB,GAAA,IAAI,KAAI;QACxC,mBAAmB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;KAC3D;;;AC3HH;;;;;;;;AAQG;AAIH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p-B2LDUv1-.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;
|
|
1
|
+
{"version":3,"file":"p-B2LDUv1-.js","sources":["src/api/config.ts"],"sourcesContent":["import { Env } from '@stencil/core';\n\n// Re-export CDN configuration\nexport { CDN_ASSETS_URL, CDN_BASE_URL, getPackageVersion } from '../config/cdn';\n\nexport type Environment = 'development' | 'staging' | 'production';\n\nexport interface APIConfig {\n baseURL: string;\n iframeURL: string;\n timeout: number;\n}\n\nexport const API_CONFIG: Record<Environment, APIConfig> = {\n development: {\n baseURL: 'http://localhost:3014/v3',\n iframeURL: 'http://localhost:5173/',\n timeout: 30000,\n },\n staging: {\n baseURL: 'https://api.rebill.dev/v3',\n iframeURL: 'https://sdk-iframe.rebill.dev/v3-1/index.html',\n timeout: 30000,\n },\n production: {\n baseURL: 'https://api.rebill.com/v3',\n iframeURL: 'https://sdk-iframe.rebill.to/v3-1/index.html',\n timeout: 30000,\n },\n};\n\n// Global configuration interface for host applications\nexport interface RebillSDKConfig {\n environment?: Environment;\n debug?: boolean;\n assetsUrl?: string; // Custom assets URL for local serving (e.g., \"/sdk/\"). Defaults to CDN if not provided.\n}\n\n// Global configuration storage\nlet globalConfig: RebillSDKConfig = {};\n\n/**\n * Initialize the SDK with configuration from the host application\n * This should be called before using any SDK functionality\n */\nexport const initializeSDK = (config: RebillSDKConfig = {}) => {\n globalConfig = {\n environment: 'production', // default to production\n debug: false,\n ...config,\n };\n\n if (globalConfig.debug) {\n console.log('🔧 Rebill SDK initialized with config:', globalConfig);\n }\n\n // Note: We don't set globalThis.REBILL_ENV to avoid interfering with StencilJS internal configuration\n // The SDK will use globalConfig.environment directly in getAPIConfig()\n};\n\n/**\n * Get the current API configuration\n * Priority: 1. Global config, 2. globalThis.REBILL_ENV, 3. Stencil Env, 4. production\n */\nexport const getAPIConfig = (): APIConfig => {\n const env =\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'; // Default to production\n\n const validEnvironments: Environment[] = ['development', 'staging', 'production'];\n\n if (!validEnvironments.includes(env as Environment)) {\n console.warn(\n `⚠️ Invalid environment \"${env}\". Using \"production\" as fallback. Valid environments: ${validEnvironments.join(', ')}`,\n );\n return API_CONFIG.production;\n }\n\n const config = API_CONFIG[env as Environment];\n\n if (globalConfig.debug || env === 'development') {\n console.log(`🔧 SDK Config: Using ${env} environment`);\n console.log(`📍 API URL: ${config.baseURL}`);\n console.log(`🖼️ iFrame URL: ${config.iframeURL}`);\n }\n\n return config;\n};\n\n/**\n * Get current environment\n */\nexport const getCurrentEnvironment = (): Environment => {\n return (\n globalConfig.environment ||\n (globalThis as any)?.REBILL_ENV ||\n (Env as any)?.REBILL_ENV ||\n 'production'\n );\n};\n\n/**\n * Check if SDK is in debug mode\n */\nexport const isDebugMode = (): boolean => {\n return globalConfig.debug || false; // Only debug if explicitly enabled\n};\n\nexport const API_ENDPOINTS = {\n auth: {\n login: '/auth/login',\n register: '/auth/register',\n logout: '/auth/logout',\n },\n users: {\n profile: '/users/profile',\n update: '/users/update',\n },\n data: {\n countries: '/data/countries',\n states: (countryCode: string) => `/data/states/${countryCode}`,\n countryCodes: (countryCode: string) => `/data/country-codes/${countryCode}`,\n documentTypes: (countryCode: string) => `/data/identifications/${countryCode}`,\n },\n sessions: {\n updatePaymentMethod: '/sessions/current/payment-method',\n SDK: '/sessions/sdk',\n },\n checkout: {\n apmRequest: '/sessions/checkout/request',\n cardRequest: '/sessions/checkout',\n requiredFields: '/preview/checkout-fields',\n requestStatus: (checkoutRequestId: string) => `sessions/checkout/request/${checkoutRequestId}`,\n },\n discountCoupon: {\n apply: (sessionId: string, couponCode: string, quantity: number = 1) =>\n `/sessions/${sessionId}/price?couponCode=${couponCode}&quantity=${quantity}`,\n },\n cards: {\n bff: '/cards/bff',\n },\n fingerPrint: {\n get: (uuid: string) => `/decidir/fingerprint/${uuid}`,\n },\n customers: {\n exists: '/customers/bff/exists',\n },\n otp: {\n generate: '/otp',\n verify: '/otp/verify-code',\n },\n} as const;\n"],"names":[],"mappings":";;;AAaO,MAAM,UAAU,GAAmC;AACxD,IAAA,WAAW,EAAE;AACX,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,+CAA+C;AAC1D,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;AACD,IAAA,UAAU,EAAE;AACV,QAAA,OAAO,EAAE,2BAA2B;AACpC,QAAA,SAAS,EAAE,8CAA8C;AACzD,QAAA,OAAO,EAAE,KAAK;AACf,KAAA;CACF;AASD;AACA,IAAI,YAAY,GAAoB,EAAE;AAEtC;;;AAGG;MACU,aAAa,GAAG,CAAC,MAA0B,GAAA,EAAE,KAAI;AAC5D,IAAA,YAAY,GAAG;QACb,WAAW,EAAE,YAAY;AACzB,QAAA,KAAK,EAAE,KAAK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@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { RebillSDKConfig } from './api/config';
|
|
9
9
|
export type { Environment, RebillSDKConfig } from './api/config';
|
|
10
|
+
export { setAssetsURL } from './utils/assets';
|
|
10
11
|
/**
|
|
11
12
|
* Configure assets URL for the SDK
|
|
12
13
|
* This function sets up the assets URL to use CDN by default
|
|
@@ -17,23 +18,25 @@ export declare const configureAssetsURL: (customAssetsURL?: string) => string;
|
|
|
17
18
|
* Initialize the Rebill SDK with environment configuration
|
|
18
19
|
*
|
|
19
20
|
* This is OPTIONAL - the SDK works out of the box with production settings.
|
|
20
|
-
* Only call this if you need to use staging or development environments
|
|
21
|
+
* Only call this if you need to use staging or development environments,
|
|
22
|
+
* or if you want to serve assets locally instead of from CDN.
|
|
21
23
|
*
|
|
22
24
|
* @param config - Configuration object for the SDK
|
|
23
25
|
* @example
|
|
24
26
|
* ```typescript
|
|
25
27
|
* import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
26
28
|
*
|
|
27
|
-
* // For staging (optional)
|
|
29
|
+
* // For staging with CDN assets (optional)
|
|
28
30
|
* initializeRebillSDK({
|
|
29
31
|
* environment: 'staging',
|
|
30
32
|
* debug: true
|
|
31
33
|
* });
|
|
32
34
|
*
|
|
33
|
-
* // For
|
|
35
|
+
* // For staging with local assets
|
|
34
36
|
* initializeRebillSDK({
|
|
35
|
-
* environment: '
|
|
36
|
-
* debug: true
|
|
37
|
+
* environment: 'staging',
|
|
38
|
+
* debug: true,
|
|
39
|
+
* assetsUrl: '/sdk/'
|
|
37
40
|
* });
|
|
38
41
|
*
|
|
39
42
|
* // For production (optional - this is the default)
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -75,12 +75,19 @@ The SDK works **out of the box** with production settings. Configuration is **op
|
|
|
75
75
|
```typescript
|
|
76
76
|
import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
77
77
|
|
|
78
|
-
// For staging (optional)
|
|
78
|
+
// For staging with CDN assets (optional)
|
|
79
79
|
initializeRebillSDK({
|
|
80
80
|
environment: 'staging',
|
|
81
81
|
debug: true,
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
// For staging with local assets
|
|
85
|
+
initializeRebillSDK({
|
|
86
|
+
environment: 'staging',
|
|
87
|
+
debug: true,
|
|
88
|
+
assetsUrl: '/sdk/', // Serve assets from local path
|
|
89
|
+
});
|
|
90
|
+
|
|
84
91
|
// For development (optional)
|
|
85
92
|
initializeRebillSDK({
|
|
86
93
|
environment: 'development',
|
|
@@ -187,55 +194,103 @@ npm publish
|
|
|
187
194
|
- **Simplified workflows** with fewer inputs
|
|
188
195
|
- **Consistent versioning** across environments
|
|
189
196
|
|
|
190
|
-
## 🚀 Assets
|
|
197
|
+
## 🚀 Assets Configuration (CDN vs Local)
|
|
191
198
|
|
|
192
|
-
**
|
|
199
|
+
**By default, assets are loaded automatically from CDN. No configuration needed.**
|
|
193
200
|
|
|
194
|
-
|
|
201
|
+
The SDK automatically uses `https://unpkg.com/rebill-web-components-sdk@[version]/assets/` to load icons and animations.
|
|
195
202
|
|
|
196
|
-
###
|
|
203
|
+
### Basic Usage (CDN - No Configuration)
|
|
197
204
|
|
|
198
205
|
```typescript
|
|
206
|
+
import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
199
207
|
import { defineCustomElements } from 'rebill-web-components-sdk/loader';
|
|
200
208
|
|
|
201
|
-
//
|
|
202
|
-
|
|
209
|
+
// Assets load automatically from CDN
|
|
210
|
+
initializeRebillSDK({
|
|
211
|
+
environment: 'staging',
|
|
212
|
+
debug: true,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
defineCustomElements(window);
|
|
203
216
|
```
|
|
204
217
|
|
|
205
|
-
###
|
|
218
|
+
### Using Local Assets
|
|
206
219
|
|
|
207
|
-
####
|
|
220
|
+
#### Option 1: Configure via initializeRebillSDK (Recommended)
|
|
208
221
|
|
|
209
222
|
```typescript
|
|
223
|
+
import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
210
224
|
import { defineCustomElements } from 'rebill-web-components-sdk/loader';
|
|
211
225
|
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
// Usar un CDN personalizado
|
|
219
|
-
defineCustomElements(window, {
|
|
220
|
-
resourcesUrl: 'https://cdn.mi-dominio.com/rebill-web-components-sdk-assets/',
|
|
226
|
+
// Configure local assets
|
|
227
|
+
initializeRebillSDK({
|
|
228
|
+
environment: 'staging',
|
|
229
|
+
debug: true,
|
|
230
|
+
assetsUrl: '/sdk/', // Use local assets from /sdk/ path
|
|
221
231
|
});
|
|
232
|
+
|
|
233
|
+
defineCustomElements(window);
|
|
222
234
|
```
|
|
223
235
|
|
|
224
|
-
|
|
236
|
+
**Important:** When using `assetsUrl`, you must ensure the assets are available at that path. Copy the `assets` folder from `node_modules/rebill-web-components-sdk/dist/assets/` to your public folder.
|
|
237
|
+
|
|
238
|
+
#### Option 2: Using setAssetsURL (Alternative)
|
|
225
239
|
|
|
226
240
|
```typescript
|
|
227
241
|
import { defineCustomElements } from 'rebill-web-components-sdk/loader';
|
|
228
242
|
import { setAssetsURL } from 'rebill-web-components-sdk';
|
|
229
243
|
|
|
230
|
-
//
|
|
231
|
-
setAssetsURL('/
|
|
232
|
-
defineCustomElements();
|
|
244
|
+
// Configure assets before defining elements
|
|
245
|
+
setAssetsURL('/sdk/');
|
|
246
|
+
defineCustomElements(window);
|
|
233
247
|
```
|
|
234
248
|
|
|
235
|
-
###
|
|
249
|
+
### Complete Example - React with Local Assets
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
import { useEffect } from 'react';
|
|
253
|
+
import { initializeRebillSDK } from 'rebill-web-components-sdk';
|
|
254
|
+
import { defineCustomElements } from 'rebill-web-components-sdk/loader';
|
|
255
|
+
|
|
256
|
+
export function useRebillSDK() {
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
const environment = process.env.NEXT_PUBLIC_NODE_ENV as
|
|
259
|
+
| 'development'
|
|
260
|
+
| 'staging'
|
|
261
|
+
| 'production';
|
|
262
|
+
|
|
263
|
+
if (environment === 'development' || environment === 'staging') {
|
|
264
|
+
// Use local assets in development/staging
|
|
265
|
+
initializeRebillSDK({
|
|
266
|
+
environment: 'staging',
|
|
267
|
+
debug: true,
|
|
268
|
+
assetsUrl: '/sdk/', // Serve from /public/sdk/ folder
|
|
269
|
+
});
|
|
270
|
+
} else {
|
|
271
|
+
// Use CDN in production
|
|
272
|
+
initializeRebillSDK({
|
|
273
|
+
environment: 'production',
|
|
274
|
+
debug: false,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
defineCustomElements(window);
|
|
279
|
+
}, []);
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### CDN Benefits
|
|
284
|
+
|
|
285
|
+
- ✅ **Zero configuration** - Works immediately
|
|
286
|
+
- ✅ **Global cache** - Faster asset loading
|
|
287
|
+
- ✅ **Automatic versioning** - Always uses the correct version
|
|
288
|
+
- ✅ **No manual copies** - No need to copy files
|
|
289
|
+
- ✅ **Flexible** - Can override URL when needed
|
|
290
|
+
|
|
291
|
+
### Local Assets Benefits
|
|
236
292
|
|
|
237
|
-
- ✅ **
|
|
238
|
-
- ✅ **
|
|
239
|
-
- ✅ **
|
|
240
|
-
- ✅ **
|
|
241
|
-
- ✅ **Flexible** - Puedes sobrescribir la URL si lo necesitas
|
|
293
|
+
- ✅ **Full control** - Assets served from your domain
|
|
294
|
+
- ✅ **Offline support** - Works without external CDN
|
|
295
|
+
- ✅ **Custom builds** - Can modify assets if needed
|
|
296
|
+
- ✅ **Privacy** - No external requests
|