@posiwise/app-config-service 0.0.102 → 0.0.104
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,415 +1,387 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { Injectable } from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.router = router;
|
|
17
|
-
this.appConfigSubject$ = new BehaviorSubject({
|
|
18
|
-
integrations: {
|
|
19
|
-
google_api_key: ''
|
|
20
|
-
},
|
|
21
|
-
social_login_enabled: false, // Default value
|
|
22
|
-
oauth_login: null // Default value
|
|
23
|
-
});
|
|
24
|
-
this.appConfig$ = this.appConfigSubject$.asObservable().pipe(distinctUntilChanged());
|
|
25
|
-
}
|
|
26
|
-
load(environment) {
|
|
27
|
-
return new Promise(resolve => {
|
|
28
|
-
// SSR/prerender: no window available. Resolve with environment
|
|
29
|
-
// defaults; the client-side hydration leg re-runs this with the
|
|
30
|
-
// real window.config injected by server_cicd.js.
|
|
31
|
-
if (typeof window === 'undefined') {
|
|
32
|
-
// SSR/prerender: emit a shape-complete stub so components
|
|
33
|
-
// that read config fields at class-field initializer time
|
|
34
|
-
// (e.g. `this.appConfig.crm.source_id`) don't null-deref
|
|
35
|
-
// during render. The client-hydration leg re-runs load()
|
|
36
|
-
// with the real window.config, replacing every field.
|
|
37
|
-
this.appConfigSubject$.next({
|
|
38
|
-
...environment,
|
|
39
|
-
url: '/',
|
|
40
|
-
domain_id: 0,
|
|
41
|
-
crm: { source_id: 0, subscription_id: 0 },
|
|
42
|
-
master_subscription: {
|
|
43
|
-
subscription_id: 0,
|
|
44
|
-
product_id: 0
|
|
45
|
-
},
|
|
46
|
-
trial: {
|
|
47
|
-
crm_source_id: 0,
|
|
48
|
-
pdf_source_id: 0,
|
|
49
|
-
subscription_id: 0,
|
|
50
|
-
product_id: 0
|
|
51
|
-
},
|
|
52
|
-
freemium: {
|
|
53
|
-
crm_source_id: 0,
|
|
54
|
-
pdf_source_id: 0,
|
|
55
|
-
subscription_id: 0,
|
|
56
|
-
product_id: 0
|
|
57
|
-
},
|
|
58
|
-
cs: {
|
|
59
|
-
crm_source_id: 0,
|
|
60
|
-
pdf_source_id: 0,
|
|
61
|
-
subscription_id: 0,
|
|
62
|
-
product_id: 0
|
|
63
|
-
},
|
|
64
|
-
coming_soon: {
|
|
65
|
-
crm_source_id: 0,
|
|
66
|
-
pdf_source_id: 0,
|
|
67
|
-
subscription_id: 0,
|
|
68
|
-
product_id: 0
|
|
69
|
-
},
|
|
70
|
-
integrations: {
|
|
71
|
-
google_api_key: '',
|
|
72
|
-
google_analytics: '',
|
|
73
|
-
captcha_key_V2: '',
|
|
74
|
-
captcha_key_V3: '',
|
|
75
|
-
fb_app_id: '',
|
|
76
|
-
crisp_code: '',
|
|
77
|
-
hubspot_code: '',
|
|
78
|
-
drift_code: ''
|
|
79
|
-
},
|
|
80
|
-
company: {
|
|
81
|
-
name: '',
|
|
82
|
-
title: '',
|
|
83
|
-
email: '',
|
|
84
|
-
street: '',
|
|
85
|
-
description: '',
|
|
86
|
-
keywords: '',
|
|
87
|
-
logos: { main: { url: '' } }
|
|
88
|
-
},
|
|
89
|
-
social: {
|
|
90
|
-
youtube_url: '',
|
|
91
|
-
linkedin_url: '',
|
|
92
|
-
facebook_url: '',
|
|
93
|
-
twitter_url: '',
|
|
94
|
-
instagram_url: ''
|
|
95
|
-
},
|
|
96
|
-
color_codes: {},
|
|
97
|
-
pages_config: {
|
|
98
|
-
ab_tests: [],
|
|
99
|
-
resources: {
|
|
100
|
-
resources_tagline: '',
|
|
101
|
-
resources_image: { url: '' }
|
|
102
|
-
},
|
|
103
|
-
contact_us: { hubspot: [] },
|
|
104
|
-
landing_page: {},
|
|
105
|
-
login: {},
|
|
106
|
-
register: {},
|
|
107
|
-
trial: {},
|
|
108
|
-
cs: {},
|
|
109
|
-
coming_soon: {},
|
|
110
|
-
join: {},
|
|
111
|
-
about_us: {}
|
|
112
|
-
},
|
|
113
|
-
twitter_seo: {},
|
|
114
|
-
links: { frontend_link: '' },
|
|
115
|
-
main_app_title: '',
|
|
116
|
-
main_tos_id: null,
|
|
117
|
-
social_login_enabled: false,
|
|
118
|
-
oauth_login: null
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
-
});
|
|
121
|
-
return resolve(true);
|
|
122
|
-
}
|
|
123
|
-
// Parse domain using native JavaScript instead of PSL
|
|
124
|
-
const domainName = getDomain(window.location.host, { allowPrivateDomains: true }) ||
|
|
125
|
-
window.location.host;
|
|
126
|
-
if (environment.production) {
|
|
127
|
-
// in case of production, the config is rendered from server_cicd.js which
|
|
128
|
-
// embeds window.config = config from node
|
|
129
|
-
let isTimeout = false; // Store the timeout ID
|
|
130
|
-
// Wait for window.config to be available
|
|
131
|
-
const waitForConfig = () => {
|
|
132
|
-
if (window.config) {
|
|
133
|
-
// Clear any pending timeout
|
|
134
|
-
isTimeout = true;
|
|
135
|
-
// Config is ready, continue with existing logic
|
|
136
|
-
of({}).subscribe(() => {
|
|
137
|
-
const { config } = window;
|
|
138
|
-
if (!config) {
|
|
139
|
-
this.router.navigate(['/error-page'], {
|
|
140
|
-
state: {
|
|
141
|
-
message: 'Missing window.config during app initialization'
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
return resolve(false);
|
|
145
|
-
}
|
|
146
|
-
// Decrypt configs. The key is injected at runtime by
|
|
147
|
-
// server_cicd.js in the same inline script as
|
|
148
|
-
// window.config (#4179 — the key no longer ships in
|
|
149
|
-
// the JS bundle). environment.metadata_encryption_key
|
|
150
|
-
// remains as a transition fallback for consumers whose
|
|
151
|
-
// serving layer hasn't been updated yet.
|
|
152
|
-
const decryptionKey = window.config_key || environment.metadata_encryption_key;
|
|
153
|
-
try {
|
|
154
|
-
const bytes = AES.decrypt(config, decryptionKey);
|
|
155
|
-
this.decryptedData = JSON.parse(bytes.toString(Utf8));
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// Wrong/missing key yields garbage bytes → JSON.parse
|
|
159
|
-
// throws. Route to the error page instead of dying
|
|
160
|
-
// inside the subscribe with a white screen.
|
|
161
|
-
this.decryptedData = null;
|
|
162
|
-
}
|
|
163
|
-
finally {
|
|
164
|
-
// security: never leave the key on the global scope
|
|
165
|
-
delete window.config_key;
|
|
166
|
-
}
|
|
167
|
-
if (isEmpty(this.decryptedData)) {
|
|
168
|
-
this.router.navigate(['/error-page'], {
|
|
169
|
-
state: { message: 'This domain seems to be misconfigured' }
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
this.googleApiKey = this.decryptedData.integrations.google_api_key;
|
|
174
|
-
this.decryptedData = { ...environment, ...this.decryptedData };
|
|
175
|
-
// security: make sure we clean the config after reading it
|
|
176
|
-
delete window.config;
|
|
177
|
-
if (this.decryptedData?.social_login_enabled) {
|
|
178
|
-
window['oauth_login'] = this.decryptedData['oauth_login'];
|
|
179
|
-
}
|
|
180
|
-
this.appConfigSubject$.next(this.decryptedData);
|
|
181
|
-
window['main_tos_id'] = this.decryptedData?.main_tos_id;
|
|
182
|
-
localStorage.setItem('company_title', this.decryptedData?.company?.title);
|
|
183
|
-
}
|
|
184
|
-
resolve(true);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
else if (!isTimeout) {
|
|
188
|
-
// Store the timeout ID so we can clear it later
|
|
189
|
-
setTimeout(waitForConfig, 100);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
// Start waiting for config
|
|
193
|
-
waitForConfig();
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
this.api
|
|
197
|
-
.get(`/main-api/v1/domains/metadata?host_name=${domainName}`)
|
|
198
|
-
.subscribe({
|
|
199
|
-
next: (data) => {
|
|
200
|
-
if (data?.type === 'warning') {
|
|
201
|
-
this.router.navigate(['/error-page'], {
|
|
202
|
-
state: { message: 'This domain seems to be misconfigured' }
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
const config = merge(environment, data);
|
|
207
|
-
if (config?.social_login_enabled) {
|
|
208
|
-
window['oauth_login'] = config['oauth_login'];
|
|
209
|
-
}
|
|
210
|
-
this.googleApiKey = config.integrations.google_api_key;
|
|
211
|
-
this.appConfigSubject$.next(config);
|
|
212
|
-
window['main_tos_id'] = config?.main_tos_id;
|
|
213
|
-
localStorage.setItem('company_title', config?.company?.title);
|
|
214
|
-
}
|
|
215
|
-
resolve(true);
|
|
216
|
-
},
|
|
217
|
-
error: () => {
|
|
218
|
-
return throwError(() => new Error('metadata is not called'));
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
getGoogleApiKey() {
|
|
225
|
-
return this.googleApiKey;
|
|
226
|
-
}
|
|
227
|
-
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 }); }
|
|
228
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigService }); }
|
|
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
|
+
const IV_BYTES = 12;
|
|
11
|
+
function base64ToBytes(base64) {
|
|
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;
|
|
229
16
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
class AppConfigServiceStub extends AppConfigService {
|
|
235
|
-
constructor() {
|
|
236
|
-
super(...arguments);
|
|
237
|
-
this.commonConfigFields = {
|
|
238
|
-
join_message: null,
|
|
239
|
-
product_id: 1,
|
|
240
|
-
image: {
|
|
241
|
-
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'
|
|
242
|
-
},
|
|
243
|
-
image2: {
|
|
244
|
-
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'
|
|
245
|
-
},
|
|
246
|
-
image_bg: {
|
|
247
|
-
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'
|
|
248
|
-
},
|
|
249
|
-
image_bg2: {
|
|
250
|
-
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'
|
|
251
|
-
},
|
|
252
|
-
video_url: 'https://www.youtube.com/embed/R7Vk219zbhA',
|
|
253
|
-
book_demo_url: null,
|
|
254
|
-
source_id: null,
|
|
255
|
-
pdf_source_id: null,
|
|
256
|
-
pdf_image: {
|
|
257
|
-
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'
|
|
258
|
-
},
|
|
259
|
-
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.",
|
|
260
|
-
cta_iframe: '"\\u003ciframe src=\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\"\\u003e\\u003c/iframe\\u003e"',
|
|
261
|
-
cs_cta_iframe: '"\\u003ciframe src=\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\"\\u003e\\u003c/iframe\\u003e"',
|
|
262
|
-
trial_cta_iframe: '"\\u003ciframe src=\\"https://my.upflowy.com/0jx-cloudolive?mode=standalone\\"\\u003e\\u003c/iframe\\u003e"'
|
|
263
|
-
};
|
|
264
|
-
this.config = {
|
|
265
|
-
links: {
|
|
266
|
-
frontend_link: 'https://www.dev.posiwise.com',
|
|
267
|
-
socket_link: 'wss://main-websocket.dev.posiwise.com/',
|
|
268
|
-
main_api: 'https://api-gateway.dev.posiwise.com/main-api/v1/',
|
|
269
|
-
products_api: 'https://api-gateway.dev.posiwise.com/products-api/v1/',
|
|
270
|
-
integrations_api: 'https://api-gateway.dev.posiwise.com/integrations-api/v1/',
|
|
271
|
-
cloudolive_api: 'https://api-gateway.dev.posiwise.com/cloudolive-api/v1/',
|
|
272
|
-
// Dedicated WS host for the Brain chat push socket (#45). main-api
|
|
273
|
-
// surfaces it as `links.mcp_socket_link`, sourced from
|
|
274
|
-
// `endpoints.brain_api.websocket_url`.
|
|
275
|
-
mcp_socket_link: 'https://brain-api-websocket.dev.posiwise.com/brain-api/v1/'
|
|
276
|
-
},
|
|
277
|
-
url: '/',
|
|
278
|
-
company: {
|
|
279
|
-
number: '55 732 191 094',
|
|
280
|
-
name: 'PosiWise',
|
|
281
|
-
keywords: 'Innovation,Technology,ProofOfConcet,MVP,Business,Demo,Website,MobileApp,API',
|
|
282
|
-
street: 'Rue des Hirondelles 15 - 1000 Brussels - Belgium',
|
|
283
|
-
city: 'Brussels',
|
|
284
|
-
city_code: '1000',
|
|
285
|
-
state: 'Belgium',
|
|
286
|
-
phone_number: '+32 (0)478 68 21 00',
|
|
287
|
-
description: 'PosiWise - Creating positive changes in the world through innovation and wise investments.',
|
|
288
|
-
email: 'info@posiwise.com',
|
|
289
|
-
website: 'https://www.posiwise.com',
|
|
290
|
-
blog_product_key: 'Dashboard_Demo1',
|
|
291
|
-
logos: {
|
|
292
|
-
header_squared_main: {
|
|
293
|
-
url: null,
|
|
294
|
-
version_200x200: {
|
|
295
|
-
url: null
|
|
296
|
-
},
|
|
297
|
-
version_100x100: {
|
|
298
|
-
url: null
|
|
299
|
-
},
|
|
300
|
-
version_50x50: {
|
|
301
|
-
url: null
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
header_squared_dark: {
|
|
305
|
-
url: null,
|
|
306
|
-
version_200x200: {
|
|
307
|
-
url: null
|
|
308
|
-
},
|
|
309
|
-
version_100x100: {
|
|
310
|
-
url: null
|
|
311
|
-
},
|
|
312
|
-
version_50x50: {
|
|
313
|
-
url: null
|
|
314
|
-
}
|
|
315
|
-
},
|
|
316
|
-
header_squared_contrast: {
|
|
317
|
-
url: null,
|
|
318
|
-
version_200x200: {
|
|
319
|
-
url: null
|
|
320
|
-
},
|
|
321
|
-
version_100x100: {
|
|
322
|
-
url: null
|
|
323
|
-
},
|
|
324
|
-
version_50x50: {
|
|
325
|
-
url: null
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
main: {
|
|
329
|
-
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'
|
|
330
|
-
},
|
|
331
|
-
main_dark: {
|
|
332
|
-
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',
|
|
333
|
-
version_100x100: {
|
|
334
|
-
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'
|
|
335
|
-
}
|
|
336
|
-
},
|
|
337
|
-
main_contrast: {
|
|
338
|
-
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'
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
main_app_title: 'PosiWise - Creating positive changes in the world through innovation and wise investments.',
|
|
343
|
-
favicon_path: 'favicon.ico',
|
|
344
|
-
twitter_seo: { card: 'summary', site: '@posiwise', creator: '@posiwise' },
|
|
345
|
-
color_codes: {
|
|
346
|
-
first: '#f006c4',
|
|
347
|
-
second: '#0fed28',
|
|
348
|
-
third: '#fe8c14',
|
|
349
|
-
titles: '#45d292',
|
|
350
|
-
text: '#222',
|
|
351
|
-
tabs_bg: '#0ceedd',
|
|
352
|
-
tabs_text: '#FFFFFF',
|
|
353
|
-
sidebar_bg: '#212529',
|
|
354
|
-
sidebar_text: '#f70917'
|
|
355
|
-
},
|
|
356
|
-
social: {
|
|
357
|
-
linkedin_url: 'https://www.linkedin.com',
|
|
358
|
-
twitter_url: 'https://twitter.com',
|
|
359
|
-
facebook_url: 'https://www.facebook.com',
|
|
360
|
-
youtube_url: 'https://www.youtube.com/embed/5eV0uXjRxRs'
|
|
361
|
-
},
|
|
362
|
-
can_register_through_main_page: true,
|
|
363
|
-
is_product_domain: true,
|
|
364
|
-
social_login_enabled: true,
|
|
365
|
-
main_tos_id: 1,
|
|
366
|
-
crm: { subscription_id: 1, source_id: 1, product_id: 7 },
|
|
367
|
-
master_subscription: { subscription_id: 1, product_id: 7 },
|
|
368
|
-
signup_config: {
|
|
369
|
-
coming_soon: {
|
|
370
|
-
...this.commonConfigFields
|
|
371
|
-
},
|
|
372
|
-
freemium: {
|
|
373
|
-
...this.commonConfigFields
|
|
374
|
-
},
|
|
375
|
-
trial: {
|
|
376
|
-
...this.commonConfigFields
|
|
377
|
-
}
|
|
378
|
-
},
|
|
379
|
-
integrations: {
|
|
380
|
-
sentry_config: { dsn: '' },
|
|
381
|
-
drift_code: '',
|
|
382
|
-
fb_app_id: '',
|
|
383
|
-
captcha_key: '',
|
|
384
|
-
captcha_key_V2: '',
|
|
385
|
-
google_analytics: '',
|
|
386
|
-
google_api_key: ''
|
|
387
|
-
},
|
|
388
|
-
oauth_login: {
|
|
389
|
-
google: {
|
|
390
|
-
client_id: ''
|
|
391
|
-
},
|
|
392
|
-
facebook: { client_id: '' },
|
|
393
|
-
linkedin: { client_id: '' }
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
load() {
|
|
398
|
-
return new Promise(resolve => {
|
|
399
|
-
this.appConfigSubject$.next(this.config);
|
|
400
|
-
resolve(true);
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigServiceStub, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
404
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AppConfigServiceStub }); }
|
|
17
|
+
async function deriveKey(keyString, usages) {
|
|
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);
|
|
405
21
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
22
|
+
async function decryptWindowConfig(encrypted, keyString) {
|
|
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);
|
|
33
|
+
}
|
|
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
|
+
});
|
|
414
385
|
export { AppConfigService, AppConfigServiceStub };
|
|
415
|
-
|
|
386
|
+
|
|
387
|
+
//# sourceMappingURL=posiwise-app-config-service.mjs.map
|