@posiwise/app-config-service 0.0.106 → 0.0.108

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.
@@ -1,483 +1,387 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable } from '@angular/core';
3
- import isEmpty from 'lodash/isEmpty';
4
- import merge from 'lodash/merge';
5
- import { BehaviorSubject, of, throwError } from 'rxjs';
6
- import { distinctUntilChanged } from 'rxjs/operators';
7
- import { getDomain } from 'tldts';
8
- import * as i1 from '@angular/common/http';
9
- import * as i2 from '@angular/router';
10
-
11
- // #4218: browser-side decrypt for the window.config payload.
12
- //
13
- // Replaces `AES.decrypt(config, key)` from `crypto-js` (upstream discontinued).
14
- // AES-256-GCM via the WebCrypto Subtle API. The matching Node encrypt lives
15
- // in `config/cicd/window-config-crypto.cjs` and uses the same algorithm +
16
- // payload layout (base64 of IV(12 bytes) || ciphertext || authTag).
17
- //
18
- // Key derivation mirrors the encrypt side: SHA-256 of the key string yields
19
- // the 32-byte AES-256 key, so callers keep passing the same per-boot random
20
- // hex string (or legacy env override) they passed to crypto-js.
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable } from "@angular/core";
3
+ import isEmpty from "lodash/isEmpty";
4
+ import merge from "lodash/merge";
5
+ import { BehaviorSubject, of, throwError } from "rxjs";
6
+ import { distinctUntilChanged } from "rxjs/operators";
7
+ import { getDomain } from "tldts";
8
+ import * as i1 from "@angular/common/http";
9
+ import * as i2 from "@angular/router";
21
10
  const IV_BYTES = 12;
22
11
  function base64ToBytes(base64) {
23
- const binary = atob(base64);
24
- const bytes = new Uint8Array(binary.length);
25
- for (let i = 0; i < binary.length; i++) {
26
- bytes[i] = binary.charCodeAt(i);
27
- }
28
- return bytes;
12
+ const binary = atob(base64);
13
+ const bytes = new Uint8Array(binary.length);
14
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
15
+ return bytes;
29
16
  }
30
17
  async function deriveKey(keyString, usages) {
31
- const material = new TextEncoder().encode(keyString);
32
- const digest = await window.crypto.subtle.digest('SHA-256', material);
33
- return window.crypto.subtle.importKey('raw', digest, { name: 'AES-GCM' }, false, usages);
34
- }
35
- function bytesToBase64(bytes) {
36
- // fromCharCode is required here (not fromCodePoint) — we're mapping
37
- // individual bytes (0-255) to the corresponding Latin-1 characters that
38
- // btoa expects, NOT interpreting them as Unicode code points.
39
- let binary = '';
40
- for (const b of bytes)
41
- binary += String.fromCharCode(b);
42
- return btoa(binary);
43
- }
44
- /**
45
- * Encrypt `plaintext` under `keyString`, returning the same base64 payload
46
- * layout the Node encrypt side produces. Exported for tests + prospective
47
- * browser-only callers; production traffic only uses `decryptWindowConfig`.
48
- */
49
- async function encryptWindowConfig(plaintext, keyString) {
50
- const key = await deriveKey(keyString, ['encrypt']);
51
- const iv = window.crypto.getRandomValues(new Uint8Array(IV_BYTES));
52
- const ciphertext = await window.crypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, new TextEncoder().encode(plaintext));
53
- const payload = new Uint8Array(IV_BYTES + ciphertext.byteLength);
54
- payload.set(iv, 0);
55
- payload.set(new Uint8Array(ciphertext), IV_BYTES);
56
- return bytesToBase64(payload);
18
+ const material = new TextEncoder().encode(keyString);
19
+ const digest = await window.crypto.subtle.digest("SHA-256", material);
20
+ return window.crypto.subtle.importKey("raw", digest, { name: "AES-GCM" }, false, usages);
57
21
  }
58
- /**
59
- * Decrypt `encrypted` (base64 of IV || ciphertext || authTag) under `keyString`.
60
- * Throws on wrong key, tampered payload, or malformed input — callers must
61
- * catch and route to their error path (the current callsite navigates to
62
- * /error-page and clears window.config).
63
- */
64
22
  async function decryptWindowConfig(encrypted, keyString) {
65
- const payload = base64ToBytes(encrypted);
66
- if (payload.length <= IV_BYTES) {
67
- throw new Error('window.config payload too short');
68
- }
69
- const iv = payload.slice(0, IV_BYTES);
70
- const ciphertext = payload.slice(IV_BYTES);
71
- const key = await deriveKey(keyString, ['decrypt']);
72
- const plaintext = await window.crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, ciphertext);
73
- return new TextDecoder().decode(plaintext);
74
- }
75
-
76
- class AppConfigService {
77
- constructor(api, router) {
78
- this.api = api;
79
- this.router = router;
80
- this.appConfigSubject$ = new BehaviorSubject({
81
- integrations: {
82
- google_api_key: ''
83
- },
84
- social_login_enabled: false, // Default value
85
- oauth_login: null // Default value
86
- });
87
- this.appConfig$ = this.appConfigSubject$.asObservable().pipe(distinctUntilChanged());
88
- }
89
- load(environment) {
90
- return new Promise(resolve => {
91
- // SSR/prerender: no window available. Resolve with environment
92
- // defaults; the client-side hydration leg re-runs this with the
93
- // real window.config injected by server_cicd.js.
94
- if (typeof window === 'undefined') {
95
- // SSR/prerender: emit a shape-complete stub so components
96
- // that read config fields at class-field initializer time
97
- // (e.g. `this.appConfig.crm.source_id`) don't null-deref
98
- // during render. The client-hydration leg re-runs load()
99
- // with the real window.config, replacing every field.
100
- this.appConfigSubject$.next({
101
- ...environment,
102
- url: '/',
103
- domain_id: 0,
104
- crm: { source_id: 0, subscription_id: 0 },
105
- master_subscription: {
106
- subscription_id: 0,
107
- product_id: 0
108
- },
109
- trial: {
110
- crm_source_id: 0,
111
- pdf_source_id: 0,
112
- subscription_id: 0,
113
- product_id: 0
114
- },
115
- freemium: {
116
- crm_source_id: 0,
117
- pdf_source_id: 0,
118
- subscription_id: 0,
119
- product_id: 0
120
- },
121
- cs: {
122
- crm_source_id: 0,
123
- pdf_source_id: 0,
124
- subscription_id: 0,
125
- product_id: 0
126
- },
127
- coming_soon: {
128
- crm_source_id: 0,
129
- pdf_source_id: 0,
130
- subscription_id: 0,
131
- product_id: 0
132
- },
133
- integrations: {
134
- google_api_key: '',
135
- google_analytics: '',
136
- captcha_key_V2: '',
137
- captcha_key_V3: '',
138
- fb_app_id: '',
139
- crisp_code: '',
140
- hubspot_code: '',
141
- drift_code: ''
142
- },
143
- company: {
144
- name: '',
145
- title: '',
146
- email: '',
147
- street: '',
148
- description: '',
149
- keywords: '',
150
- logos: { main: { url: '' } }
151
- },
152
- social: {
153
- youtube_url: '',
154
- linkedin_url: '',
155
- facebook_url: '',
156
- twitter_url: '',
157
- instagram_url: ''
158
- },
159
- color_codes: {},
160
- pages_config: {
161
- ab_tests: [],
162
- resources: {
163
- resources_tagline: '',
164
- resources_image: { url: '' }
165
- },
166
- contact_us: { hubspot: [] },
167
- landing_page: {},
168
- login: {},
169
- register: {},
170
- trial: {},
171
- cs: {},
172
- coming_soon: {},
173
- join: {},
174
- about_us: {}
175
- },
176
- twitter_seo: {},
177
- links: { frontend_link: '' },
178
- main_app_title: '',
179
- main_tos_id: null,
180
- social_login_enabled: false,
181
- oauth_login: null
182
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
183
- });
184
- return resolve(true);
185
- }
186
- // Parse domain using native JavaScript instead of PSL
187
- const domainName = getDomain(window.location.host, { allowPrivateDomains: true }) ||
188
- window.location.host;
189
- if (environment.production) {
190
- // in case of production, the config is rendered from server_cicd.js which
191
- // embeds window.config = config from node
192
- let isTimeout = false; // Store the timeout ID
193
- // Wait for window.config to be available
194
- const waitForConfig = () => {
195
- if (window.config) {
196
- // Clear any pending timeout
197
- isTimeout = true;
198
- // Config is ready, continue with existing logic
199
- of({}).subscribe(async () => {
200
- const { config } = window;
201
- if (!config) {
202
- this.router.navigate(['/error-page'], {
203
- state: {
204
- message: 'Missing window.config during app initialization'
205
- }
206
- });
207
- return resolve(false);
208
- }
209
- // Decrypt configs. The key is injected at runtime by
210
- // server_cicd.js in the same inline script as
211
- // window.config (#4179 — the key no longer ships in
212
- // the JS bundle). environment.metadata_encryption_key
213
- // remains as a transition fallback for consumers whose
214
- // serving layer hasn't been updated yet.
215
- // #4218: decrypt is now AES-256-GCM via WebCrypto
216
- // (previously crypto-js AES-CBC, upstream discontinued).
217
- // subtle.decrypt returns a Promise so the callback is
218
- // async; wrong key / tampered payload / malformed input
219
- // all reject and land in the catch below.
220
- const decryptionKey = window.config_key || environment.metadata_encryption_key;
221
- try {
222
- const plaintext = await decryptWindowConfig(config, decryptionKey);
223
- this.decryptedData = JSON.parse(plaintext);
224
- }
225
- catch {
226
- // Wrong key / tampered payload → route to the
227
- // error page instead of dying inside the subscribe
228
- // with a white screen.
229
- this.decryptedData = null;
230
- }
231
- finally {
232
- // security: never leave the key on the global scope
233
- delete window.config_key;
234
- }
235
- if (isEmpty(this.decryptedData)) {
236
- this.router.navigate(['/error-page'], {
237
- state: { message: 'This domain seems to be misconfigured' }
238
- });
239
- }
240
- else {
241
- this.googleApiKey = this.decryptedData.integrations.google_api_key;
242
- this.decryptedData = { ...environment, ...this.decryptedData };
243
- // security: make sure we clean the config after reading it
244
- delete window.config;
245
- if (this.decryptedData?.social_login_enabled) {
246
- window['oauth_login'] = this.decryptedData['oauth_login'];
247
- }
248
- this.appConfigSubject$.next(this.decryptedData);
249
- window['main_tos_id'] = this.decryptedData?.main_tos_id;
250
- localStorage.setItem('company_title', this.decryptedData?.company?.title);
251
- }
252
- resolve(true);
253
- });
254
- }
255
- else if (!isTimeout) {
256
- // Store the timeout ID so we can clear it later
257
- setTimeout(waitForConfig, 100);
258
- }
259
- };
260
- // Start waiting for config
261
- waitForConfig();
262
- }
263
- else {
264
- this.api
265
- .get(`/main-api/v1/domains/metadata?host_name=${domainName}`)
266
- .subscribe({
267
- next: (data) => {
268
- if (data?.type === 'warning') {
269
- this.router.navigate(['/error-page'], {
270
- state: { message: 'This domain seems to be misconfigured' }
271
- });
272
- }
273
- else {
274
- const config = merge(environment, data);
275
- if (config?.social_login_enabled) {
276
- window['oauth_login'] = config['oauth_login'];
277
- }
278
- this.googleApiKey = config.integrations.google_api_key;
279
- this.appConfigSubject$.next(config);
280
- window['main_tos_id'] = config?.main_tos_id;
281
- localStorage.setItem('company_title', config?.company?.title);
282
- }
283
- resolve(true);
284
- },
285
- error: () => {
286
- return throwError(() => new Error('metadata is not called'));
287
- }
288
- });
289
- }
290
- });
291
- }
292
- getGoogleApiKey() {
293
- return this.googleApiKey;
294
- }
295
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigService, deps: [{ token: i1.HttpClient }, { token: i2.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
296
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigService }); }
23
+ const payload = base64ToBytes(encrypted);
24
+ if (payload.length <= IV_BYTES) throw new Error("window.config payload too short");
25
+ const iv = payload.slice(0, IV_BYTES);
26
+ const ciphertext = payload.slice(IV_BYTES);
27
+ const key = await deriveKey(keyString, ["decrypt"]);
28
+ const plaintext = await window.crypto.subtle.decrypt({
29
+ name: "AES-GCM",
30
+ iv
31
+ }, key, ciphertext);
32
+ return new TextDecoder().decode(plaintext);
297
33
  }
298
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigService, decorators: [{
299
- type: Injectable
300
- }], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.Router }] });
301
-
302
- class AppConfigServiceStub extends AppConfigService {
303
- constructor() {
304
- super(...arguments);
305
- this.commonConfigFields = {
306
- join_message: null,
307
- product_id: 1,
308
- image: {
309
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_image-default_shard_2022-02-17-newimg-power.png'
310
- },
311
- image2: {
312
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_image2-default_shard_2022-02-17-white-label-2b.png'
313
- },
314
- image_bg: {
315
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_image_bg-default_shard_2022-02-17-banner-bg.jpg'
316
- },
317
- image_bg2: {
318
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_image_bg2-default_shard_2022-02-17-contact-us-bg.jpg'
319
- },
320
- video_url: 'https://www.youtube.com/embed/R7Vk219zbhA',
321
- book_demo_url: null,
322
- source_id: null,
323
- pdf_source_id: null,
324
- pdf_image: {
325
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_pdf_image-default_shard_2022-02-21-downloadpdfbook.png'
326
- },
327
- pdf_download_text: "The rise of SaaS billings in today's marketplace means there has never been a more important time for MSPs to optimise cloud contract management. Download our best practice tips to manage your client contracts efficiently and with zero revenue leakage.",
328
- cta_iframe: '"\\u003ciframe src=\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\"\\u003e\\u003c/iframe\\u003e"',
329
- cs_cta_iframe: '"\\u003ciframe src=\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\"\\u003e\\u003c/iframe\\u003e"',
330
- trial_cta_iframe: '"\\u003ciframe src=\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\"\\u003e\\u003c/iframe\\u003e"'
331
- };
332
- this.config = {
333
- links: {
334
- frontend_link: 'https://www.dev.posiwise.com',
335
- socket_link: 'wss://main-websocket.dev.posiwise.com/',
336
- main_api: 'https://api-gateway.dev.posiwise.com/main-api/v1/',
337
- products_api: 'https://api-gateway.dev.posiwise.com/products-api/v1/',
338
- integrations_api: 'https://api-gateway.dev.posiwise.com/integrations-api/v1/',
339
- cloudolive_api: 'https://api-gateway.dev.posiwise.com/cloudolive-api/v1/',
340
- // Dedicated WS host for the Brain chat push socket (#45). main-api
341
- // surfaces it as `links.mcp_socket_link`, sourced from
342
- // `endpoints.brain_api.websocket_url`.
343
- mcp_socket_link: 'https://brain-api-websocket.dev.posiwise.com/brain-api/v1/'
344
- },
345
- url: '/',
346
- company: {
347
- number: '55 732 191 094',
348
- name: 'PosiWise',
349
- keywords: 'Innovation,Technology,ProofOfConcet,MVP,Business,Demo,Website,MobileApp,API',
350
- street: 'Rue des Hirondelles 15 - 1000 Brussels - Belgium',
351
- city: 'Brussels',
352
- city_code: '1000',
353
- state: 'Belgium',
354
- phone_number: '+32 (0)478 68 21 00',
355
- description: 'PosiWise - Creating positive changes in the world through innovation and wise investments.',
356
- email: 'info@posiwise.com',
357
- website: 'https://www.posiwise.com',
358
- blog_product_key: 'Dashboard_Demo1',
359
- logos: {
360
- header_squared_main: {
361
- url: null,
362
- version_200x200: {
363
- url: null
364
- },
365
- version_100x100: {
366
- url: null
367
- },
368
- version_50x50: {
369
- url: null
370
- }
371
- },
372
- header_squared_dark: {
373
- url: null,
374
- version_200x200: {
375
- url: null
376
- },
377
- version_100x100: {
378
- url: null
379
- },
380
- version_50x50: {
381
- url: null
382
- }
383
- },
384
- header_squared_contrast: {
385
- url: null,
386
- version_200x200: {
387
- url: null
388
- },
389
- version_100x100: {
390
- url: null
391
- },
392
- version_50x50: {
393
- url: null
394
- }
395
- },
396
- main: {
397
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/logo_main-default_shard_2022-02-17-logo_main_dark-default_shard_2022-02-13-logo_text_big.png'
398
- },
399
- main_dark: {
400
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/logo_main_dark-default_shard_2022-02-17-logo_main_dark-default_shard_2022-02-13-logo_text_big__1_.png',
401
- version_100x100: {
402
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/version_100x100_logo_main_dark-default_shard_2022-02-17-logo_main_dark-default_shard_2022-02-13-logo_text_big__1_.png'
403
- }
404
- },
405
- main_contrast: {
406
- url: 'https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/logo_main_contrast-default_shard_2022-02-17-logo_main_dark-default_shard_2022-02-13-logo_text_big__1_.png'
407
- }
408
- }
409
- },
410
- main_app_title: 'PosiWise - Creating positive changes in the world through innovation and wise investments.',
411
- favicon_path: 'favicon.ico',
412
- twitter_seo: { card: 'summary', site: '@posiwise', creator: '@posiwise' },
413
- color_codes: {
414
- first: '#f006c4',
415
- second: '#0fed28',
416
- third: '#fe8c14',
417
- titles: '#45d292',
418
- text: '#222',
419
- tabs_bg: '#0ceedd',
420
- tabs_text: '#FFFFFF',
421
- sidebar_bg: '#212529',
422
- sidebar_text: '#f70917'
423
- },
424
- social: {
425
- linkedin_url: 'https://www.linkedin.com',
426
- twitter_url: 'https://twitter.com',
427
- facebook_url: 'https://www.facebook.com',
428
- youtube_url: 'https://www.youtube.com/embed/5eV0uXjRxRs'
429
- },
430
- can_register_through_main_page: true,
431
- is_product_domain: true,
432
- social_login_enabled: true,
433
- main_tos_id: 1,
434
- crm: { subscription_id: 1, source_id: 1, product_id: 7 },
435
- master_subscription: { subscription_id: 1, product_id: 7 },
436
- signup_config: {
437
- coming_soon: {
438
- ...this.commonConfigFields
439
- },
440
- freemium: {
441
- ...this.commonConfigFields
442
- },
443
- trial: {
444
- ...this.commonConfigFields
445
- }
446
- },
447
- integrations: {
448
- sentry_config: { dsn: '' },
449
- drift_code: '',
450
- fb_app_id: '',
451
- captcha_key: '',
452
- captcha_key_V2: '',
453
- google_analytics: '',
454
- google_api_key: ''
455
- },
456
- oauth_login: {
457
- google: {
458
- client_id: ''
459
- },
460
- facebook: { client_id: '' },
461
- linkedin: { client_id: '' }
462
- }
463
- };
464
- }
465
- load() {
466
- return new Promise(resolve => {
467
- this.appConfigSubject$.next(this.config);
468
- resolve(true);
469
- });
470
- }
471
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigServiceStub, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
472
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigServiceStub }); }
473
- }
474
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigServiceStub, decorators: [{
475
- type: Injectable
476
- }] });
477
-
478
- /**
479
- * Generated bundle index. Do not edit.
480
- */
481
-
34
+ var AppConfigService = class AppConfigService {
35
+ constructor(api, router) {
36
+ this.api = api;
37
+ this.router = router;
38
+ this.appConfigSubject$ = new BehaviorSubject({
39
+ integrations: { google_api_key: "" },
40
+ social_login_enabled: false,
41
+ oauth_login: null
42
+ });
43
+ this.appConfig$ = this.appConfigSubject$.asObservable().pipe(distinctUntilChanged());
44
+ }
45
+ load(environment) {
46
+ return new Promise((resolve) => {
47
+ if (typeof window === "undefined") {
48
+ this.appConfigSubject$.next({
49
+ ...environment,
50
+ url: "/",
51
+ domain_id: 0,
52
+ crm: {
53
+ source_id: 0,
54
+ subscription_id: 0
55
+ },
56
+ master_subscription: {
57
+ subscription_id: 0,
58
+ product_id: 0
59
+ },
60
+ trial: {
61
+ crm_source_id: 0,
62
+ pdf_source_id: 0,
63
+ subscription_id: 0,
64
+ product_id: 0
65
+ },
66
+ freemium: {
67
+ crm_source_id: 0,
68
+ pdf_source_id: 0,
69
+ subscription_id: 0,
70
+ product_id: 0
71
+ },
72
+ cs: {
73
+ crm_source_id: 0,
74
+ pdf_source_id: 0,
75
+ subscription_id: 0,
76
+ product_id: 0
77
+ },
78
+ coming_soon: {
79
+ crm_source_id: 0,
80
+ pdf_source_id: 0,
81
+ subscription_id: 0,
82
+ product_id: 0
83
+ },
84
+ integrations: {
85
+ google_api_key: "",
86
+ google_analytics: "",
87
+ captcha_key_V2: "",
88
+ captcha_key_V3: "",
89
+ fb_app_id: "",
90
+ crisp_code: "",
91
+ hubspot_code: "",
92
+ drift_code: ""
93
+ },
94
+ company: {
95
+ name: "",
96
+ title: "",
97
+ email: "",
98
+ street: "",
99
+ description: "",
100
+ keywords: "",
101
+ logos: { main: { url: "" } }
102
+ },
103
+ social: {
104
+ youtube_url: "",
105
+ linkedin_url: "",
106
+ facebook_url: "",
107
+ twitter_url: "",
108
+ instagram_url: ""
109
+ },
110
+ color_codes: {},
111
+ pages_config: {
112
+ ab_tests: [],
113
+ resources: {
114
+ resources_tagline: "",
115
+ resources_image: { url: "" }
116
+ },
117
+ contact_us: { hubspot: [] },
118
+ landing_page: {},
119
+ login: {},
120
+ register: {},
121
+ trial: {},
122
+ cs: {},
123
+ coming_soon: {},
124
+ join: {},
125
+ about_us: {}
126
+ },
127
+ twitter_seo: {},
128
+ links: { frontend_link: "" },
129
+ main_app_title: "",
130
+ main_tos_id: null,
131
+ social_login_enabled: false,
132
+ oauth_login: null
133
+ });
134
+ return resolve(true);
135
+ }
136
+ const domainName = getDomain(window.location.host, { allowPrivateDomains: true }) || window.location.host;
137
+ if (environment.production) {
138
+ let isTimeout = false;
139
+ const waitForConfig = () => {
140
+ if (window.config) {
141
+ isTimeout = true;
142
+ of({}).subscribe(async () => {
143
+ const { config } = window;
144
+ if (!config) {
145
+ this.router.navigate(["/error-page"], { state: { message: "Missing window.config during app initialization" } });
146
+ return resolve(false);
147
+ }
148
+ const decryptionKey = window.config_key || environment.metadata_encryption_key;
149
+ try {
150
+ const plaintext = await decryptWindowConfig(config, decryptionKey);
151
+ this.decryptedData = JSON.parse(plaintext);
152
+ } catch {
153
+ this.decryptedData = null;
154
+ } finally {
155
+ delete window.config_key;
156
+ }
157
+ if (isEmpty(this.decryptedData)) this.router.navigate(["/error-page"], { state: { message: "This domain seems to be misconfigured" } });
158
+ else {
159
+ this.googleApiKey = this.decryptedData.integrations.google_api_key;
160
+ this.decryptedData = {
161
+ ...environment,
162
+ ...this.decryptedData
163
+ };
164
+ delete window.config;
165
+ if (this.decryptedData?.social_login_enabled) window["oauth_login"] = this.decryptedData["oauth_login"];
166
+ this.appConfigSubject$.next(this.decryptedData);
167
+ window["main_tos_id"] = this.decryptedData?.main_tos_id;
168
+ localStorage.setItem("company_title", this.decryptedData?.company?.title);
169
+ }
170
+ resolve(true);
171
+ });
172
+ } else if (!isTimeout) setTimeout(waitForConfig, 100);
173
+ };
174
+ waitForConfig();
175
+ } else this.api.get(`/main-api/v1/domains/metadata?host_name=${domainName}`).subscribe({
176
+ next: (data) => {
177
+ if (data?.type === "warning") this.router.navigate(["/error-page"], { state: { message: "This domain seems to be misconfigured" } });
178
+ else {
179
+ const config = merge(environment, data);
180
+ if (config?.social_login_enabled) window["oauth_login"] = config["oauth_login"];
181
+ this.googleApiKey = config.integrations.google_api_key;
182
+ this.appConfigSubject$.next(config);
183
+ window["main_tos_id"] = config?.main_tos_id;
184
+ localStorage.setItem("company_title", config?.company?.title);
185
+ }
186
+ resolve(true);
187
+ },
188
+ error: () => {
189
+ return throwError(() => /* @__PURE__ */ new Error("metadata is not called"));
190
+ }
191
+ });
192
+ });
193
+ }
194
+ getGoogleApiKey() {
195
+ return this.googleApiKey;
196
+ }
197
+ static {
198
+ this.ɵfac = i0.ɵɵngDeclareFactory({
199
+ minVersion: "12.0.0",
200
+ version: "22.2.0",
201
+ ngImport: i0,
202
+ type: AppConfigService,
203
+ deps: [{ token: i1.HttpClient }, { token: i2.Router }],
204
+ target: i0.ɵɵFactoryTarget.Injectable
205
+ });
206
+ }
207
+ static {
208
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
209
+ minVersion: "12.0.0",
210
+ version: "22.2.0",
211
+ ngImport: i0,
212
+ type: AppConfigService
213
+ });
214
+ }
215
+ };
216
+ i0.ɵɵngDeclareClassMetadata({
217
+ minVersion: "12.0.0",
218
+ version: "22.2.0",
219
+ ngImport: i0,
220
+ type: AppConfigService,
221
+ decorators: [{ type: Injectable }],
222
+ ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.Router }]
223
+ });
224
+ var AppConfigServiceStub = class AppConfigServiceStub extends AppConfigService {
225
+ constructor() {
226
+ super(...arguments);
227
+ this.commonConfigFields = {
228
+ join_message: null,
229
+ product_id: 1,
230
+ image: { url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_image-default_shard_2022-02-17-newimg-power.png" },
231
+ image2: { url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_image2-default_shard_2022-02-17-white-label-2b.png" },
232
+ image_bg: { url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_image_bg-default_shard_2022-02-17-banner-bg.jpg" },
233
+ image_bg2: { url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_image_bg2-default_shard_2022-02-17-contact-us-bg.jpg" },
234
+ video_url: "https://www.youtube.com/embed/R7Vk219zbhA",
235
+ book_demo_url: null,
236
+ source_id: null,
237
+ pdf_source_id: null,
238
+ pdf_image: { url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/cs_pdf_image-default_shard_2022-02-21-downloadpdfbook.png" },
239
+ pdf_download_text: "The rise of SaaS billings in today's marketplace means there has never been a more important time for MSPs to optimise cloud contract management. Download our best practice tips to manage your client contracts efficiently and with zero revenue leakage.",
240
+ cta_iframe: "\"\\u003ciframe src=\\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\\"\\u003e\\u003c/iframe\\u003e\"",
241
+ cs_cta_iframe: "\"\\u003ciframe src=\\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\\"\\u003e\\u003c/iframe\\u003e\"",
242
+ trial_cta_iframe: "\"\\u003ciframe src=\\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\\"\\u003e\\u003c/iframe\\u003e\""
243
+ };
244
+ this.config = {
245
+ links: {
246
+ frontend_link: "https://www.dev.posiwise.com",
247
+ socket_link: "wss://main-websocket.dev.posiwise.com/",
248
+ main_api: "https://api-gateway.dev.posiwise.com/main-api/v1/",
249
+ products_api: "https://api-gateway.dev.posiwise.com/products-api/v1/",
250
+ integrations_api: "https://api-gateway.dev.posiwise.com/integrations-api/v1/",
251
+ cloudolive_api: "https://api-gateway.dev.posiwise.com/cloudolive-api/v1/",
252
+ mcp_socket_link: "https://brain-api-websocket.dev.posiwise.com/brain-api/v1/"
253
+ },
254
+ url: "/",
255
+ company: {
256
+ number: "55 732 191 094",
257
+ name: "PosiWise",
258
+ keywords: "Innovation,Technology,ProofOfConcet,MVP,Business,Demo,Website,MobileApp,API",
259
+ street: "Rue des Hirondelles 15 - 1000 Brussels - Belgium",
260
+ city: "Brussels",
261
+ city_code: "1000",
262
+ state: "Belgium",
263
+ phone_number: "+32 (0)478 68 21 00",
264
+ description: "PosiWise - Creating positive changes in the world through innovation and wise investments.",
265
+ email: "info@posiwise.com",
266
+ website: "https://www.posiwise.com",
267
+ blog_product_key: "Dashboard_Demo1",
268
+ logos: {
269
+ header_squared_main: {
270
+ url: null,
271
+ version_200x200: { url: null },
272
+ version_100x100: { url: null },
273
+ version_50x50: { url: null }
274
+ },
275
+ header_squared_dark: {
276
+ url: null,
277
+ version_200x200: { url: null },
278
+ version_100x100: { url: null },
279
+ version_50x50: { url: null }
280
+ },
281
+ header_squared_contrast: {
282
+ url: null,
283
+ version_200x200: { url: null },
284
+ version_100x100: { url: null },
285
+ version_50x50: { url: null }
286
+ },
287
+ main: { url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/logo_main-default_shard_2022-02-17-logo_main_dark-default_shard_2022-02-13-logo_text_big.png" },
288
+ main_dark: {
289
+ url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/logo_main_dark-default_shard_2022-02-17-logo_main_dark-default_shard_2022-02-13-logo_text_big__1_.png",
290
+ version_100x100: { url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/version_100x100_logo_main_dark-default_shard_2022-02-17-logo_main_dark-default_shard_2022-02-13-logo_text_big__1_.png" }
291
+ },
292
+ main_contrast: { url: "https://posiwise-dev.s3.us-east-2.amazonaws.com/dev/public/default_shard/domain_pictures/3/logo_main_contrast-default_shard_2022-02-17-logo_main_dark-default_shard_2022-02-13-logo_text_big__1_.png" }
293
+ }
294
+ },
295
+ main_app_title: "PosiWise - Creating positive changes in the world through innovation and wise investments.",
296
+ favicon_path: "favicon.ico",
297
+ twitter_seo: {
298
+ card: "summary",
299
+ site: "@posiwise",
300
+ creator: "@posiwise"
301
+ },
302
+ color_codes: {
303
+ first: "#f006c4",
304
+ second: "#0fed28",
305
+ third: "#fe8c14",
306
+ titles: "#45d292",
307
+ text: "#222",
308
+ tabs_bg: "#0ceedd",
309
+ tabs_text: "#FFFFFF",
310
+ sidebar_bg: "#212529",
311
+ sidebar_text: "#f70917"
312
+ },
313
+ social: {
314
+ linkedin_url: "https://www.linkedin.com",
315
+ twitter_url: "https://twitter.com",
316
+ facebook_url: "https://www.facebook.com",
317
+ youtube_url: "https://www.youtube.com/embed/5eV0uXjRxRs"
318
+ },
319
+ can_register_through_main_page: true,
320
+ is_product_domain: true,
321
+ social_login_enabled: true,
322
+ main_tos_id: 1,
323
+ crm: {
324
+ subscription_id: 1,
325
+ source_id: 1,
326
+ product_id: 7
327
+ },
328
+ master_subscription: {
329
+ subscription_id: 1,
330
+ product_id: 7
331
+ },
332
+ signup_config: {
333
+ coming_soon: { ...this.commonConfigFields },
334
+ freemium: { ...this.commonConfigFields },
335
+ trial: { ...this.commonConfigFields }
336
+ },
337
+ integrations: {
338
+ sentry_config: { dsn: "" },
339
+ drift_code: "",
340
+ fb_app_id: "",
341
+ captcha_key: "",
342
+ captcha_key_V2: "",
343
+ google_analytics: "",
344
+ google_api_key: ""
345
+ },
346
+ oauth_login: {
347
+ google: { client_id: "" },
348
+ facebook: { client_id: "" },
349
+ linkedin: { client_id: "" }
350
+ }
351
+ };
352
+ }
353
+ load() {
354
+ return new Promise((resolve) => {
355
+ this.appConfigSubject$.next(this.config);
356
+ resolve(true);
357
+ });
358
+ }
359
+ static {
360
+ this.ɵfac = i0.ɵɵngDeclareFactory({
361
+ minVersion: "12.0.0",
362
+ version: "22.2.0",
363
+ ngImport: i0,
364
+ type: AppConfigServiceStub,
365
+ deps: null,
366
+ target: i0.ɵɵFactoryTarget.Injectable
367
+ });
368
+ }
369
+ static {
370
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
371
+ minVersion: "12.0.0",
372
+ version: "22.2.0",
373
+ ngImport: i0,
374
+ type: AppConfigServiceStub
375
+ });
376
+ }
377
+ };
378
+ i0.ɵɵngDeclareClassMetadata({
379
+ minVersion: "12.0.0",
380
+ version: "22.2.0",
381
+ ngImport: i0,
382
+ type: AppConfigServiceStub,
383
+ decorators: [{ type: Injectable }]
384
+ });
482
385
  export { AppConfigService, AppConfigServiceStub };
483
- //# sourceMappingURL=posiwise-app-config-service.mjs.map
386
+
387
+ //# sourceMappingURL=posiwise-app-config-service.mjs.map