webs-sdk 0.10.1 β†’ 0.10.3

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/index.d.ts CHANGED
@@ -1,33 +1,34 @@
1
- import NetworkingClass from './libraries/networking';
2
- import AuthManagerClass from './libraries/auth';
3
- import I18nManagerClass from './libraries/i18n';
4
- import StorageClass from './libraries/storage';
5
- import UtilsClass from './libraries/utils';
6
- import AndromedaClass from './libraries/andromeda';
7
- import ContentManagerClass from './libraries/content';
8
- import SessionClass from './libraries/session';
9
- import MixPanelClass from './libraries/mixpanel';
10
- import AudioClass from './libraries/audio';
11
- import CorporateAuthManagerClass from './libraries/corp_auth';
12
- import LegalManagerClass from './libraries/legal';
13
- import CalypsoManager from './libraries/calypso';
14
- import UserManagerClass from './libraries/user';
15
- declare const WebsSDK: {
16
- Networking: NetworkingClass;
17
- AuthManager: AuthManagerClass;
18
- I18nManager: I18nManagerClass;
19
- Storage: StorageClass;
20
- Utils: UtilsClass;
21
- Andromeda: AndromedaClass;
22
- ContentManager: ContentManagerClass;
23
- Session: SessionClass;
24
- MixPanel: MixPanelClass;
25
- Audio: AudioClass;
26
- CorporateAuthManager: CorporateAuthManagerClass;
27
- Legal: LegalManagerClass;
28
- Calypso: CalypsoManager;
29
- User: UserManagerClass;
30
- Config: import("./config").Config;
31
- };
32
- export default WebsSDK;
1
+ import NetworkingClass from './libraries/networking';
2
+ import AuthManagerClass from './libraries/auth';
3
+ import I18nManagerClass from './libraries/i18n';
4
+ import StorageClass from './libraries/storage';
5
+ import UtilsClass from './libraries/utils';
6
+ import AndromedaClass from './libraries/andromeda';
7
+ import ContentManagerClass from './libraries/content';
8
+ import SessionClass from './libraries/session';
9
+ import MixPanelClass from './libraries/mixpanel';
10
+ import AudioClass from './libraries/audio';
11
+ import CorporateAuthManagerClass from './libraries/corp_auth';
12
+ import LegalManagerClass from './libraries/legal';
13
+ import CalypsoManager from './libraries/calypso';
14
+ import UserManagerClass from './libraries/user';
15
+
16
+ declare const WebsSDK: {
17
+ Networking: NetworkingClass;
18
+ AuthManager: AuthManagerClass;
19
+ I18nManager: I18nManagerClass;
20
+ Storage: StorageClass;
21
+ Utils: UtilsClass;
22
+ Andromeda: AndromedaClass;
23
+ ContentManager: ContentManagerClass;
24
+ Session: SessionClass;
25
+ MixPanel: MixPanelClass;
26
+ Audio: AudioClass;
27
+ CorporateAuthManager: CorporateAuthManagerClass;
28
+ Legal: LegalManagerClass;
29
+ Calypso: CalypsoManager;
30
+ User: UserManagerClass;
31
+ Config: import("./config").Config;
32
+ };
33
+ export default WebsSDK;
33
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,wBAAwB,CAAC;AACrD,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,mBAAmB,MAAM,qBAAqB,CAAC;AACtD,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,yBAAyB,MAAM,uBAAuB,CAAC;AAC9D,OAAO,iBAAiB,MAAM,mBAAmB,CAAC;AAClD,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAGhD,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;CAgBZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,wBAAwB,CAAC;AACrD,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,mBAAmB,MAAM,qBAAqB,CAAC;AACtD,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,yBAAyB,MAAM,uBAAuB,CAAC;AAC9D,OAAO,iBAAiB,MAAM,mBAAmB,CAAC;AAClD,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAGjD,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;CAeZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/dist/index.js CHANGED
@@ -1,39 +1,37 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const networking_1 = __importDefault(require("./libraries/networking"));
7
- const auth_1 = __importDefault(require("./libraries/auth"));
8
- const i18n_1 = __importDefault(require("./libraries/i18n"));
9
- const storage_1 = __importDefault(require("./libraries/storage"));
10
- const utils_1 = __importDefault(require("./libraries/utils"));
11
- const andromeda_1 = __importDefault(require("./libraries/andromeda"));
12
- const content_1 = __importDefault(require("./libraries/content"));
13
- const session_1 = __importDefault(require("./libraries/session"));
14
- const mixpanel_1 = __importDefault(require("./libraries/mixpanel"));
15
- const audio_1 = __importDefault(require("./libraries/audio"));
16
- const corp_auth_1 = __importDefault(require("./libraries/corp_auth"));
17
- const legal_1 = __importDefault(require("./libraries/legal"));
18
- const calypso_1 = __importDefault(require("./libraries/calypso"));
19
- const user_1 = __importDefault(require("./libraries/user"));
20
- const config_1 = __importDefault(require("./config"));
21
- const WebsSDK = {
22
- Networking: new networking_1.default(),
23
- AuthManager: new auth_1.default(),
24
- I18nManager: new i18n_1.default(),
25
- Storage: new storage_1.default(),
26
- Utils: new utils_1.default(),
27
- Andromeda: new andromeda_1.default(),
28
- ContentManager: new content_1.default(),
29
- Session: new session_1.default(),
30
- MixPanel: new mixpanel_1.default(),
31
- Audio: new audio_1.default(),
32
- CorporateAuthManager: new corp_auth_1.default(),
33
- Legal: new legal_1.default(),
34
- Calypso: new calypso_1.default(),
35
- User: new user_1.default(),
36
- Config: config_1.default
37
- };
38
- exports.default = WebsSDK;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const networking_1 = __importDefault(require("./libraries/networking"));
7
+ const auth_1 = __importDefault(require("./libraries/auth"));
8
+ const i18n_1 = __importDefault(require("./libraries/i18n"));
9
+ const storage_1 = __importDefault(require("./libraries/storage"));
10
+ const utils_1 = __importDefault(require("./libraries/utils"));
11
+ const andromeda_1 = __importDefault(require("./libraries/andromeda"));
12
+ const content_1 = __importDefault(require("./libraries/content"));
13
+ const session_1 = __importDefault(require("./libraries/session"));
14
+ const mixpanel_1 = __importDefault(require("./libraries/mixpanel"));
15
+ const audio_1 = __importDefault(require("./libraries/audio"));
16
+ const corp_auth_1 = __importDefault(require("./libraries/corp_auth"));
17
+ const legal_1 = __importDefault(require("./libraries/legal"));
18
+ const calypso_1 = __importDefault(require("./libraries/calypso"));
19
+ const config_1 = __importDefault(require("./config"));
20
+ const WebsSDK = {
21
+ Networking: new networking_1.default(),
22
+ AuthManager: new auth_1.default(),
23
+ I18nManager: new i18n_1.default(),
24
+ Storage: new storage_1.default(),
25
+ Utils: new utils_1.default(),
26
+ Andromeda: new andromeda_1.default(),
27
+ ContentManager: new content_1.default(),
28
+ Session: new session_1.default(),
29
+ MixPanel: new mixpanel_1.default(),
30
+ Audio: new audio_1.default(),
31
+ CorporateAuthManager: new corp_auth_1.default(),
32
+ Legal: new legal_1.default(),
33
+ Calypso: new calypso_1.default(),
34
+ Config: config_1.default
35
+ };
36
+ exports.default = WebsSDK;
39
37
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,wEAAqD;AACrD,4DAAgD;AAChD,4DAAgD;AAChD,kEAA+C;AAC/C,8DAA2C;AAC3C,sEAAmD;AACnD,kEAAsD;AACtD,kEAA+C;AAC/C,oEAAiD;AACjD,8DAA2C;AAC3C,sEAA8D;AAC9D,8DAAkD;AAClD,kEAAiD;AACjD,4DAAgD;AAChD,sDAA8B;AAE9B,MAAM,OAAO,GAAG;IACZ,UAAU,EAAE,IAAI,oBAAe,EAAE;IACjC,WAAW,EAAE,IAAI,cAAgB,EAAE;IACnC,WAAW,EAAE,IAAI,cAAgB,EAAE;IACnC,OAAO,EAAE,IAAI,iBAAY,EAAE;IAC3B,KAAK,EAAE,IAAI,eAAU,EAAE;IACvB,SAAS,EAAE,IAAI,mBAAc,EAAE;IAC/B,cAAc,EAAE,IAAI,iBAAmB,EAAE;IACzC,OAAO,EAAE,IAAI,iBAAY,EAAE;IAC3B,QAAQ,EAAE,IAAI,kBAAa,EAAE;IAC7B,KAAK,EAAE,IAAI,eAAU,EAAE;IACvB,oBAAoB,EAAE,IAAI,mBAAyB,EAAE;IACrD,KAAK,EAAE,IAAI,eAAiB,EAAE;IAC9B,OAAO,EAAE,IAAI,iBAAc,EAAE;IAC7B,IAAI,EAAE,IAAI,cAAgB,EAAE;IAC5B,MAAM,EAAE,gBAAM;CACjB,CAAC;AAEF,kBAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,wEAAqD;AACrD,4DAAgD;AAChD,4DAAgD;AAChD,kEAA+C;AAC/C,8DAA2C;AAC3C,sEAAmD;AACnD,kEAAsD;AACtD,kEAA+C;AAC/C,oEAAiD;AACjD,8DAA2C;AAC3C,sEAA8D;AAC9D,8DAAkD;AAClD,kEAAiD;AACjD,sDAA8B;AAE9B,MAAM,OAAO,GAAG;IACZ,UAAU,EAAE,IAAI,oBAAe,EAAE;IACjC,WAAW,EAAE,IAAI,cAAgB,EAAE;IACnC,WAAW,EAAE,IAAI,cAAgB,EAAE;IACnC,OAAO,EAAE,IAAI,iBAAY,EAAE;IAC3B,KAAK,EAAE,IAAI,eAAU,EAAE;IACvB,SAAS,EAAE,IAAI,mBAAc,EAAE;IAC/B,cAAc,EAAE,IAAI,iBAAmB,EAAE;IACzC,OAAO,EAAE,IAAI,iBAAY,EAAE;IAC3B,QAAQ,EAAE,IAAI,kBAAa,EAAE;IAC7B,KAAK,EAAE,IAAI,eAAU,EAAE;IACvB,oBAAoB,EAAE,IAAI,mBAAyB,EAAE;IACrD,KAAK,EAAE,IAAI,eAAiB,EAAE;IAC9B,OAAO,EAAE,IAAI,iBAAc,EAAE;IAC7B,MAAM,EAAE,gBAAM;CACjB,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -1,193 +1,193 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Andromeda = void 0;
7
- const index_1 = __importDefault(require("../index"));
8
- const config_1 = __importDefault(require("../config"));
9
- class Andromeda {
10
- constructor() {
11
- this.backendBaseUrl = config_1.default.backendBaseUrl;
12
- this.init();
13
- }
14
- async init() {
15
- console.debug("Andromeda init");
16
- }
17
- async getWebsiteMetadatabyHostname(hostname, existingCookie) {
18
- var _a;
19
- console.debug("Andromeda getWebsiteMetadatabyHostname called with hostname:", hostname);
20
- if (existingCookie) {
21
- try {
22
- const websiteDataFromCookie = JSON.parse(decodeURIComponent(existingCookie));
23
- console.log('🎯 WebsiteData leído desde cookie existente:', websiteDataFromCookie === null || websiteDataFromCookie === void 0 ? void 0 : websiteDataFromCookie.web_id);
24
- if ((websiteDataFromCookie === null || websiteDataFromCookie === void 0 ? void 0 : websiteDataFromCookie.hostname) === hostname) {
25
- return {
26
- status: 'success',
27
- websiteData: websiteDataFromCookie,
28
- cookies: []
29
- };
30
- }
31
- else {
32
- console.log('⚠️ Hostname mismatch en websiteDataFlag cookie [', websiteDataFromCookie === null || websiteDataFromCookie === void 0 ? void 0 : websiteDataFromCookie.hostname, ' vs ', hostname, '], obteniendo nuevo websiteData desde WebSDK');
33
- }
34
- }
35
- catch (error) {
36
- console.error('❌ Error parsing websiteData desde cookie:', error);
37
- }
38
- }
39
- console.log('πŸ”„ Cookie websiteDataFlag no existe, obteniendo websiteData desde backend');
40
- const websiteDataResult = await this._fetchWebsiteMetadatabyHostname(hostname);
41
- if (!websiteDataResult) {
42
- return {
43
- status: 'error',
44
- errorKey: 'server-error',
45
- error: 'No response from backend'
46
- };
47
- }
48
- const cookies = [];
49
- if (websiteDataResult.status === 'success' && ((_a = websiteDataResult.data) === null || _a === void 0 ? void 0 : _a.web_id)) {
50
- const websiteData = websiteDataResult.data;
51
- websiteData.hostname = hostname;
52
- console.log('βœ… WebsiteData obtenido desde backend, creando cookie');
53
- cookies.push({
54
- name: 'websiteDataFlag',
55
- value: JSON.stringify(websiteData),
56
- options: {
57
- path: '/',
58
- maxAge: 60 * 60,
59
- sameSite: 'lax',
60
- secure: process.env.NODE_ENV === 'production',
61
- httpOnly: false
62
- }
63
- });
64
- return {
65
- status: 'success',
66
- websiteData: websiteData,
67
- cookies: cookies
68
- };
69
- }
70
- else {
71
- console.log('❌ No se pudo obtener websiteData vÑlido desde backend');
72
- if (existingCookie) {
73
- console.log('πŸ—‘οΈ Limpiando cookie websiteDataFlag existente');
74
- cookies.push({
75
- name: 'websiteDataFlag',
76
- value: '',
77
- options: {
78
- path: '/',
79
- maxAge: 0,
80
- sameSite: 'lax',
81
- secure: false,
82
- httpOnly: false,
83
- expires: new Date(0)
84
- }
85
- });
86
- }
87
- return {
88
- status: 'error',
89
- errorKey: websiteDataResult.errorKey,
90
- error: websiteDataResult.error,
91
- cookies: cookies
92
- };
93
- }
94
- }
95
- async _fetchWebsiteMetadatabyHostname(hostname) {
96
- var _a, _b, _c, _d, _e;
97
- console.debug("Andromeda _fetchWebsiteMetadatabyHostname called with hostname:", hostname);
98
- if (!hostname) {
99
- console.warn("hostname es requerido");
100
- return {
101
- status: 'error',
102
- errorKey: 'invalidData',
103
- error: 'Required fields: hostname'
104
- };
105
- }
106
- try {
107
- const formData = new URLSearchParams();
108
- formData.append('hostname', hostname);
109
- console.log("baseurl: ", this.backendBaseUrl);
110
- const result = await index_1.default.Networking.request(`${this.backendBaseUrl}/auth/get-website-metadata-by-hostname`, { hostname });
111
- console.log("_fetchWebsiteMetadatabyHostname response:", JSON.stringify(result, null, 2));
112
- if (!((_a = result.data) === null || _a === void 0 ? void 0 : _a.web_id)) {
113
- if (((_c = (_b = result.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.code) && ((_e = (_d = result.data) === null || _d === void 0 ? void 0 : _d.error) === null || _e === void 0 ? void 0 : _e.desc)) {
114
- return {
115
- status: 'error',
116
- errorKey: result.data.error.code,
117
- error: result.data.error.desc
118
- };
119
- }
120
- return {
121
- status: 'error',
122
- errorKey: 'no-website-data',
123
- error: 'No website data found in server response'
124
- };
125
- }
126
- return {
127
- status: 'success',
128
- data: result.data
129
- };
130
- }
131
- catch (error) {
132
- return {
133
- status: 'error',
134
- errorKey: 'server-error',
135
- error: "Server communication error"
136
- };
137
- }
138
- }
139
- async getWebsiteConfig(webId, merchantId) {
140
- var _a, _b, _c, _d, _e, _f;
141
- console.debug("Andromeda getWebsiteConfig called with webId:", webId, "and merchantId:", merchantId);
142
- if (!webId) {
143
- console.warn("webId es requerido");
144
- return {
145
- status: 'error',
146
- errorKey: 'invalidData',
147
- error: 'Required fields: webId'
148
- };
149
- }
150
- try {
151
- const apiData = await index_1.default.Networking.request(`${this.backendBaseUrl}/config/get`, { web_id: webId, merchant_id: merchantId });
152
- console.log("getWebsiteConfig response:", JSON.stringify(apiData, null, 2));
153
- if (!apiData.data) {
154
- let errorKey = 'no-website-config';
155
- let errorReason = 'No website config found in server response';
156
- if ((_b = (_a = apiData === null || apiData === void 0 ? void 0 : apiData.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.id) {
157
- errorKey = apiData.data.error.id;
158
- }
159
- else if ((_d = (_c = apiData === null || apiData === void 0 ? void 0 : apiData.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) {
160
- errorKey = apiData.data.error.code;
161
- }
162
- else if (apiData === null || apiData === void 0 ? void 0 : apiData.code) {
163
- errorKey = apiData.code;
164
- }
165
- if ((_f = (_e = apiData === null || apiData === void 0 ? void 0 : apiData.data) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.reason) {
166
- errorReason = apiData.data.error.reason;
167
- }
168
- else if (apiData === null || apiData === void 0 ? void 0 : apiData.msg) {
169
- errorReason = apiData.msg;
170
- }
171
- return {
172
- status: 'error',
173
- errorKey: errorKey,
174
- error: errorReason
175
- };
176
- }
177
- return {
178
- status: 'success',
179
- data: apiData.data
180
- };
181
- }
182
- catch (error) {
183
- return {
184
- status: 'error',
185
- errorKey: 'server-error',
186
- error: "Server communication error"
187
- };
188
- }
189
- }
190
- }
191
- exports.Andromeda = Andromeda;
192
- exports.default = Andromeda;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Andromeda = void 0;
7
+ const index_1 = __importDefault(require("../index"));
8
+ const config_1 = __importDefault(require("../config"));
9
+ class Andromeda {
10
+ constructor() {
11
+ this.backendBaseUrl = config_1.default.backendBaseUrl;
12
+ this.init();
13
+ }
14
+ async init() {
15
+ console.debug("Andromeda init");
16
+ }
17
+ async getWebsiteMetadatabyHostname(hostname, existingCookie) {
18
+ var _a;
19
+ console.debug("Andromeda getWebsiteMetadatabyHostname called with hostname:", hostname);
20
+ if (existingCookie) {
21
+ try {
22
+ const websiteDataFromCookie = JSON.parse(decodeURIComponent(existingCookie));
23
+ console.log('🎯 WebsiteData leído desde cookie existente:', websiteDataFromCookie === null || websiteDataFromCookie === void 0 ? void 0 : websiteDataFromCookie.web_id);
24
+ if ((websiteDataFromCookie === null || websiteDataFromCookie === void 0 ? void 0 : websiteDataFromCookie.hostname) === hostname) {
25
+ return {
26
+ status: 'success',
27
+ websiteData: websiteDataFromCookie,
28
+ cookies: []
29
+ };
30
+ }
31
+ else {
32
+ console.log('⚠️ Hostname mismatch en websiteDataFlag cookie [', websiteDataFromCookie === null || websiteDataFromCookie === void 0 ? void 0 : websiteDataFromCookie.hostname, ' vs ', hostname, '], obteniendo nuevo websiteData desde WebSDK');
33
+ }
34
+ }
35
+ catch (error) {
36
+ console.error('❌ Error parsing websiteData desde cookie:', error);
37
+ }
38
+ }
39
+ console.log('πŸ”„ Cookie websiteDataFlag no existe, obteniendo websiteData desde backend');
40
+ const websiteDataResult = await this._fetchWebsiteMetadatabyHostname(hostname);
41
+ if (!websiteDataResult) {
42
+ return {
43
+ status: 'error',
44
+ errorKey: 'server-error',
45
+ error: 'No response from backend'
46
+ };
47
+ }
48
+ const cookies = [];
49
+ if (websiteDataResult.status === 'success' && ((_a = websiteDataResult.data) === null || _a === void 0 ? void 0 : _a.web_id)) {
50
+ const websiteData = websiteDataResult.data;
51
+ websiteData.hostname = hostname;
52
+ console.log('βœ… WebsiteData obtenido desde backend, creando cookie');
53
+ cookies.push({
54
+ name: 'websiteDataFlag',
55
+ value: JSON.stringify(websiteData),
56
+ options: {
57
+ path: '/',
58
+ maxAge: 60 * 60,
59
+ sameSite: 'lax',
60
+ secure: process.env.NODE_ENV === 'production',
61
+ httpOnly: false
62
+ }
63
+ });
64
+ return {
65
+ status: 'success',
66
+ websiteData: websiteData,
67
+ cookies: cookies
68
+ };
69
+ }
70
+ else {
71
+ console.log('❌ No se pudo obtener websiteData vÑlido desde backend');
72
+ if (existingCookie) {
73
+ console.log('πŸ—‘οΈ Limpiando cookie websiteDataFlag existente');
74
+ cookies.push({
75
+ name: 'websiteDataFlag',
76
+ value: '',
77
+ options: {
78
+ path: '/',
79
+ maxAge: 0,
80
+ sameSite: 'lax',
81
+ secure: false,
82
+ httpOnly: false,
83
+ expires: new Date(0)
84
+ }
85
+ });
86
+ }
87
+ return {
88
+ status: 'error',
89
+ errorKey: websiteDataResult.errorKey,
90
+ error: websiteDataResult.error,
91
+ cookies: cookies
92
+ };
93
+ }
94
+ }
95
+ async _fetchWebsiteMetadatabyHostname(hostname) {
96
+ var _a, _b, _c, _d, _e;
97
+ console.debug("Andromeda _fetchWebsiteMetadatabyHostname called with hostname:", hostname);
98
+ if (!hostname) {
99
+ console.warn("hostname es requerido");
100
+ return {
101
+ status: 'error',
102
+ errorKey: 'invalidData',
103
+ error: 'Required fields: hostname'
104
+ };
105
+ }
106
+ try {
107
+ const formData = new URLSearchParams();
108
+ formData.append('hostname', hostname);
109
+ console.log("baseurl: ", this.backendBaseUrl);
110
+ const result = await index_1.default.Networking.request(`${this.backendBaseUrl}/auth/get-website-metadata-by-hostname`, { hostname });
111
+ console.log("_fetchWebsiteMetadatabyHostname response:", JSON.stringify(result, null, 2));
112
+ if (!((_a = result.data) === null || _a === void 0 ? void 0 : _a.web_id)) {
113
+ if (((_c = (_b = result.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.code) && ((_e = (_d = result.data) === null || _d === void 0 ? void 0 : _d.error) === null || _e === void 0 ? void 0 : _e.desc)) {
114
+ return {
115
+ status: 'error',
116
+ errorKey: result.data.error.code,
117
+ error: result.data.error.desc
118
+ };
119
+ }
120
+ return {
121
+ status: 'error',
122
+ errorKey: 'no-website-data',
123
+ error: 'No website data found in server response'
124
+ };
125
+ }
126
+ return {
127
+ status: 'success',
128
+ data: result.data
129
+ };
130
+ }
131
+ catch (error) {
132
+ return {
133
+ status: 'error',
134
+ errorKey: 'server-error',
135
+ error: "Server communication error"
136
+ };
137
+ }
138
+ }
139
+ async getWebsiteConfig(webId, merchantId) {
140
+ var _a, _b, _c, _d, _e, _f;
141
+ console.debug("Andromeda getWebsiteConfig called with webId:", webId, "and merchantId:", merchantId);
142
+ if (!webId) {
143
+ console.warn("webId es requerido");
144
+ return {
145
+ status: 'error',
146
+ errorKey: 'invalidData',
147
+ error: 'Required fields: webId'
148
+ };
149
+ }
150
+ try {
151
+ const apiData = await index_1.default.Networking.request(`${this.backendBaseUrl}/config/get`, { web_id: webId, merchant_id: merchantId });
152
+ console.log("getWebsiteConfig response:", JSON.stringify(apiData, null, 2));
153
+ if (!apiData.data) {
154
+ let errorKey = 'no-website-config';
155
+ let errorReason = 'No website config found in server response';
156
+ if ((_b = (_a = apiData === null || apiData === void 0 ? void 0 : apiData.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.id) {
157
+ errorKey = apiData.data.error.id;
158
+ }
159
+ else if ((_d = (_c = apiData === null || apiData === void 0 ? void 0 : apiData.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) {
160
+ errorKey = apiData.data.error.code;
161
+ }
162
+ else if (apiData === null || apiData === void 0 ? void 0 : apiData.code) {
163
+ errorKey = apiData.code;
164
+ }
165
+ if ((_f = (_e = apiData === null || apiData === void 0 ? void 0 : apiData.data) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.reason) {
166
+ errorReason = apiData.data.error.reason;
167
+ }
168
+ else if (apiData === null || apiData === void 0 ? void 0 : apiData.msg) {
169
+ errorReason = apiData.msg;
170
+ }
171
+ return {
172
+ status: 'error',
173
+ errorKey: errorKey,
174
+ error: errorReason
175
+ };
176
+ }
177
+ return {
178
+ status: 'success',
179
+ data: apiData.data
180
+ };
181
+ }
182
+ catch (error) {
183
+ return {
184
+ status: 'error',
185
+ errorKey: 'server-error',
186
+ error: "Server communication error"
187
+ };
188
+ }
189
+ }
190
+ }
191
+ exports.Andromeda = Andromeda;
192
+ exports.default = Andromeda;
193
193
  //# sourceMappingURL=andromeda.js.map