@transcommerce/cwm-shared 1.1.23 → 1.1.26
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/fesm2022/transcommerce-cwm-shared.mjs +124 -48
- package/fesm2022/transcommerce-cwm-shared.mjs.map +1 -1
- package/lib/factories/msal-interceptor-config.factory.d.ts +1 -1
- package/lib/factories/msal-interceptor-config.factory.d.ts.map +1 -1
- package/lib/factories/msal.guard.config.factory.d.ts +1 -1
- package/lib/factories/msal.guard.config.factory.d.ts.map +1 -1
- package/lib/factories/msal.instance.factory.d.ts +2 -2
- package/lib/factories/msal.instance.factory.d.ts.map +1 -1
- package/lib/services/config.service.d.ts.map +1 -1
- package/lib/services/inventory-api.service.d.ts.map +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +0 -2
- package/public-api.d.ts.map +1 -1
- package/lib/models/window.d.ts +0 -5
- package/lib/models/window.d.ts.map +0 -1
- package/lib/services/auth.service.d.ts +0 -9
- package/lib/services/auth.service.d.ts.map +0 -1
|
@@ -3,7 +3,7 @@ import { Component, Injectable, Pipe, NgModule } from '@angular/core';
|
|
|
3
3
|
import * as i1 from '@angular/router';
|
|
4
4
|
import * as i2 from '@angular/forms';
|
|
5
5
|
import { FormsModule } from '@angular/forms';
|
|
6
|
-
import { InteractionType, PublicClientApplication } from '@azure/msal-browser';
|
|
6
|
+
import { InteractionType, PublicClientApplication, LogLevel } from '@azure/msal-browser';
|
|
7
7
|
import * as i2$1 from '@angular/common/http';
|
|
8
8
|
import { HttpResponseBase, HttpResponse, HttpErrorResponse, HttpHeaders, HttpStatusCode } from '@angular/common/http';
|
|
9
9
|
import { CommonModule } from '@angular/common';
|
|
@@ -113,31 +113,120 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
|
|
|
113
113
|
args: [{ selector: 'cwm-page-not-found', standalone: false, template: "<p>\n Page Not Found\n</p>\n" }]
|
|
114
114
|
}] });
|
|
115
115
|
|
|
116
|
-
function
|
|
116
|
+
function msalGuardConfigFactory() {
|
|
117
117
|
return {
|
|
118
118
|
interactionType: InteractionType.Redirect,
|
|
119
119
|
authRequest: {
|
|
120
120
|
scopes: ['user.read']
|
|
121
|
-
}
|
|
121
|
+
},
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
const isIE = window.navigator.userAgent.indexOf('MSIE ') > -1 || window.navigator.userAgent.indexOf('Trident/') > -1;
|
|
126
|
+
function getAuthConfig() {
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
const wind = window;
|
|
129
|
+
return wind.authConfig;
|
|
130
|
+
}
|
|
131
|
+
// Safe getter for runtime authConfig. Accessing the config at module-eval time
|
|
132
|
+
// can fail if the global `authConfig` script in `index.html` hasn't been injected or
|
|
133
|
+
// loaded yet. This helper reads from window.authConfig (set in index.html) or falls
|
|
134
|
+
// back to the AuthService helper if available, and logs a clear error instead of
|
|
135
|
+
// letting the application throw a TypeError.
|
|
136
|
+
function getAuthConfigSafe() {
|
|
137
|
+
try {
|
|
138
|
+
const winAny = window;
|
|
139
|
+
const cfg = winAny.authConfig ?? (getAuthConfig ? getAuthConfig() : undefined);
|
|
140
|
+
if (!cfg) {
|
|
141
|
+
// Provide a helpful console error and return a minimal object to avoid runtime crashes.
|
|
142
|
+
// The app will still not be authenticated correctly until the real config is available.
|
|
143
|
+
console.error('authConfig is not available on window and AuthService.getAuthConfig() returned no value. Ensure the inline authConfig script in index.html is present and executes before the app bundle., using default cfg:');
|
|
144
|
+
return {
|
|
145
|
+
logLevel: "Info",
|
|
146
|
+
clientId: "af1486e0-a27f-4c8d-8503-0752d90ce72d",
|
|
147
|
+
tenantId: "445012c4-563a-4795-84d0-f7473a3197e0",
|
|
148
|
+
authority: "https://login.microsoft.com/445012c4-563a-4795-84d0-f7473a3197e0",
|
|
149
|
+
scopes: "openid,email,profile",
|
|
150
|
+
redirect_uri: window.location.origin,
|
|
151
|
+
logout_redirect_uri: window.location.origin + '/logout',
|
|
152
|
+
prompt: "login",
|
|
153
|
+
configConnectString: "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=7F0m;Secret=7X8pkinp53tA8d4o2LfGUMHBWo54o68jYUSS7JcOnyQmh2lDXetkJQQJ99BEAC8vTInIcYexAAACAZAC2P1s"
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return cfg;
|
|
157
|
+
}
|
|
158
|
+
catch (e) {
|
|
159
|
+
console.error('Error while reading authConfig, using default cfg:', e);
|
|
160
|
+
return {
|
|
161
|
+
logLevel: "Info",
|
|
162
|
+
clientId: "af1486e0-a27f-4c8d-8503-0752d90ce72d",
|
|
163
|
+
tenantId: "445012c4-563a-4795-84d0-f7473a3197e0",
|
|
164
|
+
authority: "https://login.microsoft.com/445012c4-563a-4795-84d0-f7473a3197e0",
|
|
165
|
+
scopes: "openid,email,profile",
|
|
166
|
+
redirect_uri: window.location.origin,
|
|
167
|
+
logout_redirect_uri: window.location.origin + '/logout',
|
|
168
|
+
prompt: "login",
|
|
169
|
+
configConnectString: "Endpoint=https://cheap-weed-menus-appconfig.azconfig.io;Id=7F0m;Secret=7X8pkinp53tA8d4o2LfGUMHBWo54o68jYUSS7JcOnyQmh2lDXetkJQQJ99BEAC8vTInIcYexAAACAZAC2P1s"
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// -----------------------------------------
|
|
174
|
+
// Runtime factories for MSAL (avoid module-eval-time access to window)
|
|
175
|
+
// -----------------------------------------
|
|
176
|
+
function msalInstanceFactory() {
|
|
177
|
+
const cfg = getAuthConfigSafe();
|
|
126
178
|
return new PublicClientApplication({
|
|
127
179
|
auth: {
|
|
128
|
-
clientId:
|
|
129
|
-
authority:
|
|
130
|
-
redirectUri:
|
|
180
|
+
clientId: cfg.clientId,
|
|
181
|
+
authority: cfg.authority,
|
|
182
|
+
redirectUri: cfg.redirect_uri,
|
|
183
|
+
postLogoutRedirectUri: cfg.redirect_uri,
|
|
184
|
+
},
|
|
185
|
+
cache: {
|
|
186
|
+
cacheLocation: 'localStorage',
|
|
187
|
+
temporaryCacheLocation: 'sessionStorage',
|
|
188
|
+
storeAuthStateInCookie: isIE,
|
|
189
|
+
secureCookies: true,
|
|
190
|
+
cacheMigrationEnabled: true,
|
|
191
|
+
claimsBasedCachingEnabled: true
|
|
192
|
+
},
|
|
193
|
+
system: {
|
|
194
|
+
tokenRenewalOffsetSeconds: 30,
|
|
195
|
+
preventCorsPreflight: false,
|
|
196
|
+
loggerOptions: {
|
|
197
|
+
loggerCallback: {},
|
|
198
|
+
piiLoggingEnabled: true,
|
|
199
|
+
logLevel: LogLevel.Verbose,
|
|
200
|
+
correlationId: "ff88c00e-fd95-49c6-8203-5b2b62a4eb2f",
|
|
201
|
+
},
|
|
202
|
+
windowHashTimeout: 1000,
|
|
203
|
+
iframeHashTimeout: 1000,
|
|
204
|
+
loadFrameTimeout: 1000,
|
|
205
|
+
navigateFrameWait: 1000,
|
|
206
|
+
redirectNavigationTimeout: 1000,
|
|
207
|
+
asyncPopups: false,
|
|
208
|
+
allowRedirectInIframe: false,
|
|
209
|
+
allowNativeBroker: false,
|
|
210
|
+
nativeBrokerHandshakeTimeout: 500,
|
|
211
|
+
pollIntervalMilliseconds: 30,
|
|
212
|
+
},
|
|
213
|
+
telemetry: {
|
|
214
|
+
application: {
|
|
215
|
+
appName: "cwm-digital-menu",
|
|
216
|
+
appVersion: "1.0"
|
|
217
|
+
},
|
|
131
218
|
}
|
|
132
219
|
});
|
|
133
220
|
}
|
|
134
221
|
|
|
135
|
-
function
|
|
136
|
-
const protectedResourceMap = new Map();
|
|
137
|
-
protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read']);
|
|
222
|
+
function msalInterceptorConfigFactory() {
|
|
138
223
|
return {
|
|
139
|
-
interactionType: InteractionType.
|
|
140
|
-
protectedResourceMap
|
|
224
|
+
interactionType: InteractionType.Redirect,
|
|
225
|
+
protectedResourceMap: new Map([
|
|
226
|
+
['https://graph.microsoft.com/v1.0/me', ['user.read']],
|
|
227
|
+
['https://graph.microsoft.com/v1.0/me/photo/$value', ['user.read']],
|
|
228
|
+
[window.location.origin + '/api/inventory?', ["api://" + window.location.hostname + '/inventory.read']]
|
|
229
|
+
])
|
|
141
230
|
};
|
|
142
231
|
}
|
|
143
232
|
|
|
@@ -26902,7 +26991,7 @@ const MockConfig = {
|
|
|
26902
26991
|
},
|
|
26903
26992
|
"footerCarouselSlideConfig": [
|
|
26904
26993
|
{
|
|
26905
|
-
"image": "../../../images/sunday.png",
|
|
26994
|
+
"image": "../../../assets/images/sunday.png",
|
|
26906
26995
|
"title": "CBD Sunday",
|
|
26907
26996
|
"description": "20% off all CBD products & house pre-rolls",
|
|
26908
26997
|
"highlighted": false,
|
|
@@ -26910,7 +26999,7 @@ const MockConfig = {
|
|
|
26910
26999
|
"backgroundColor": "black"
|
|
26911
27000
|
},
|
|
26912
27001
|
{
|
|
26913
|
-
"image": "../../../images/new-monday.jpg",
|
|
27002
|
+
"image": "../../../assets/images/new-monday.jpg",
|
|
26914
27003
|
"title": "Edible Monday",
|
|
26915
27004
|
"description": "10% off edibles",
|
|
26916
27005
|
"highlighted": false,
|
|
@@ -26918,7 +27007,7 @@ const MockConfig = {
|
|
|
26918
27007
|
"backgroundColor": "black"
|
|
26919
27008
|
},
|
|
26920
27009
|
{
|
|
26921
|
-
"image": "../../../images/tuesday.png",
|
|
27010
|
+
"image": "../../../assets/images/tuesday.png",
|
|
26922
27011
|
"title": "Doobie Tuesday",
|
|
26923
27012
|
"description": "10% off all pre-rolls & packs<",
|
|
26924
27013
|
"highlighted": false,
|
|
@@ -26926,7 +27015,7 @@ const MockConfig = {
|
|
|
26926
27015
|
"backgroundColor": "white"
|
|
26927
27016
|
},
|
|
26928
27017
|
{
|
|
26929
|
-
"image": "../../../images/wednesday.png",
|
|
27018
|
+
"image": "../../../assets/images/wednesday.png",
|
|
26930
27019
|
"title": "Weed Crush Wednesday",
|
|
26931
27020
|
"description": "10% off all jar bud",
|
|
26932
27021
|
"highlighted": false,
|
|
@@ -26934,7 +27023,7 @@ const MockConfig = {
|
|
|
26934
27023
|
"backgroundColor": "white"
|
|
26935
27024
|
},
|
|
26936
27025
|
{
|
|
26937
|
-
"image": "../../../images/thursday.png",
|
|
27026
|
+
"image": "../../../assets/images/thursday.png",
|
|
26938
27027
|
"title": "Thirsty Thursday",
|
|
26939
27028
|
"description": "10% off Tinctures, RSO & cartridges",
|
|
26940
27029
|
"highlighted": false,
|
|
@@ -26942,7 +27031,7 @@ const MockConfig = {
|
|
|
26942
27031
|
"backgroundColor": "white"
|
|
26943
27032
|
},
|
|
26944
27033
|
{
|
|
26945
|
-
"image": "../../../images/friday.png",
|
|
27034
|
+
"image": "../../../assets/images/friday.png",
|
|
26946
27035
|
"title": "Fire Friday",
|
|
26947
27036
|
"description": "10% off all jar bud",
|
|
26948
27037
|
"highlighted": false,
|
|
@@ -26950,7 +27039,7 @@ const MockConfig = {
|
|
|
26950
27039
|
"backgroundColor": "white"
|
|
26951
27040
|
},
|
|
26952
27041
|
{
|
|
26953
|
-
"image": "../../../images/saturday.png",
|
|
27042
|
+
"image": "../../../assets/images/saturday.png",
|
|
26954
27043
|
"title": "Shatterday Saturday",
|
|
26955
27044
|
"description": "10% off all concentrate",
|
|
26956
27045
|
"highlighted": false,
|
|
@@ -26975,24 +27064,6 @@ const MockProfile = {
|
|
|
26975
27064
|
"userPrincipalName": "demo@app.cheapweedmenu.com"
|
|
26976
27065
|
};
|
|
26977
27066
|
|
|
26978
|
-
class AuthService {
|
|
26979
|
-
constructor() {
|
|
26980
|
-
}
|
|
26981
|
-
static getAuthConfig() {
|
|
26982
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26983
|
-
const wind = window;
|
|
26984
|
-
return wind.authConfig;
|
|
26985
|
-
}
|
|
26986
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
26987
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
26988
|
-
}
|
|
26989
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: AuthService, decorators: [{
|
|
26990
|
-
type: Injectable,
|
|
26991
|
-
args: [{
|
|
26992
|
-
providedIn: 'root'
|
|
26993
|
-
}]
|
|
26994
|
-
}], ctorParameters: () => [] });
|
|
26995
|
-
|
|
26996
27067
|
/*
|
|
26997
27068
|
The LogService is really just a wrapper around the existing console logging functionality
|
|
26998
27069
|
The three main reasons for using this service are:
|
|
@@ -27099,18 +27170,23 @@ class ConfigService {
|
|
|
27099
27170
|
}
|
|
27100
27171
|
async getConfigurationSettingAsync(key, label) {
|
|
27101
27172
|
this.logService.methodName = "getConfigurationSettingAsync()";
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27173
|
+
let setting = {};
|
|
27174
|
+
this.logService.log("Get Configuration Setting for Key/Label requested", key, label);
|
|
27175
|
+
if (this.mockData || this.configCache != undefined) {
|
|
27176
|
+
if (this.configCache == undefined) {
|
|
27177
|
+
this.configCache = MockConfig;
|
|
27178
|
+
this.logService.log("Configuration Cache was undefined and Mock Data Enabled. Mock Config will be cached and used for this and all subsequent calls", this.configCache);
|
|
27179
|
+
}
|
|
27105
27180
|
setting.key = key;
|
|
27106
|
-
setting.value = JSON.stringify(
|
|
27107
|
-
this.
|
|
27181
|
+
setting.value = JSON.stringify(this.configCache);
|
|
27182
|
+
if (this.mockData)
|
|
27183
|
+
this.logService.log("Mock Data Enabled, Skipping getConfigurationSetting() and using Mock Config from the Configuration Cache", this.configCache);
|
|
27184
|
+
this.logService.log("Configuration Cache was available, skipping getConfigurationSetting() and using Cached Configuration", this.configCache);
|
|
27108
27185
|
}
|
|
27109
|
-
else {
|
|
27110
|
-
this.logService.log("Getting Configuration Setting Key/Label", key, label);
|
|
27186
|
+
else if (this.configCache == undefined) {
|
|
27187
|
+
this.logService.log("Configuration Cache was undefined and Mock Data disabled. Getting Configuration Setting Key/Label. Configuration will be cached and used for this and all subsequent calls", key, label);
|
|
27111
27188
|
setting = await this.configClient.getConfigurationSetting({ key: key, label: label.replace(".", "") });
|
|
27112
27189
|
}
|
|
27113
|
-
this.logService.log("Configuration Setting Key/Value", key, setting.value);
|
|
27114
27190
|
return setting.value;
|
|
27115
27191
|
}
|
|
27116
27192
|
async setConfigurationSettingAsync(templateName, label, setting, contentType = "Text") {
|
|
@@ -27237,11 +27313,11 @@ class InventoryApiService extends BaseApiService {
|
|
|
27237
27313
|
.set('locationId', this.config?.locationId);
|
|
27238
27314
|
}
|
|
27239
27315
|
get apiFullUrl() {
|
|
27240
|
-
return this.apiBaseUrl + this.config
|
|
27316
|
+
return this.apiBaseUrl + (this.config ?? MockConfig.apiConfig).getInventoryApiRoute;
|
|
27241
27317
|
}
|
|
27242
27318
|
async getProductsAsync(companyName) {
|
|
27243
27319
|
this.logService.methodName = "getProductsAsync()";
|
|
27244
|
-
|
|
27320
|
+
let response;
|
|
27245
27321
|
this.configService.mockData = this.useMockData;
|
|
27246
27322
|
this.logService.log("Fetching Configuration for Company", companyName);
|
|
27247
27323
|
this.config = (await this.configService.getConfigAsync(companyName)).apiConfig;
|
|
@@ -27579,5 +27655,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
|
|
|
27579
27655
|
* Generated bundle index. Do not edit.
|
|
27580
27656
|
*/
|
|
27581
27657
|
|
|
27582
|
-
export {
|
|
27658
|
+
export { BaseApiService, CardTypes, Category, ConfigService, Customer, CustomerApiService, CwmSharedModule, DbKeys, ExternalNavigationComponent, InventoryApiService, Justifications, LocalStorageService, LogService, LoggingVerbosity, MockConfig, MockInventoryApiResponse, MockProfile, NamedColors, NavigateToRouteComponent, OnElementStyle, PageNotFoundComponent, Product, Profile, SafeHtmlPipe, TimeSpan, TimeSpanOverflowError, UserTypes, Utilities, decodeToken, doWithLock, isTokenValid, msalGuardConfigFactory, msalInstanceFactory, msalInterceptorConfigFactory, waitFor };
|
|
27583
27659
|
//# sourceMappingURL=transcommerce-cwm-shared.mjs.map
|