@saasquatch/component-environment 1.0.0-0

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.
@@ -0,0 +1,37 @@
1
+ import { getAppDomain, getTenantAlias } from "./environment";
2
+ import { LOCALE_CONTEXT_NAME } from "./types";
3
+ import { debug as _debug } from "./debug";
4
+ const debug = (...args) => _debug(LOCALE_CONTEXT_NAME, ...args);
5
+ const GET_LOCALE = `
6
+ query {
7
+ viewer {
8
+ ... on User {
9
+ locale
10
+ }
11
+ }
12
+ }
13
+ `;
14
+ export async function fetchLocale() {
15
+ debug("Fetching locale from GraphQL for current user");
16
+ try {
17
+ const result = await fetch(`${getAppDomain()}/api/v1/${getTenantAlias()}/graphql`, {
18
+ method: "POST",
19
+ headers: { "Content-Type": "application/json" },
20
+ body: JSON.stringify({
21
+ query: GET_LOCALE,
22
+ }),
23
+ });
24
+ if (!result.ok) {
25
+ throw new Error("Failed to fetch locale");
26
+ }
27
+ const json = await result.json();
28
+ if (json.errors) {
29
+ throw new Error(JSON.stringify(json.errors, null, 2));
30
+ }
31
+ return json.viewer.locale || undefined;
32
+ }
33
+ catch (e) {
34
+ debug(`Failed to fetch locale for current user`, e.message);
35
+ return undefined;
36
+ }
37
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./types";
2
+ export * from "./environment";
3
+ export * from "./contexts/UserIdentityContext";
4
+ export * from "./contexts/LocaleContext";
5
+ export * from "./contexts/ProgramContext";
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./types";
2
+ export * from "./environment";
3
+ export * from "./contexts/UserIdentityContext";
4
+ export * from "./contexts/LocaleContext";
5
+ export * from "./contexts/ProgramContext";
@@ -0,0 +1 @@
1
+ export declare function startUserContextListenerForLocale(): void;
@@ -0,0 +1,44 @@
1
+ import equal from "@wry/equality";
2
+ import { ContextListener } from "dom-context";
3
+ import { USER_CONTEXT_NAME, LOCALE_CONTEXT_NAME } from "./types";
4
+ import { lazilyStartLocaleContext } from "./contexts/LocaleContext";
5
+ import { lazilyStartUserContext } from "./contexts/UserIdentityContext";
6
+ import { fetchLocale } from "./fetchLocale";
7
+ import { debug as _debug } from "./debug";
8
+ const debug = (...args) => _debug(LOCALE_CONTEXT_NAME, ...args);
9
+ const userContextListenerDiv = (() => {
10
+ const id = "__environment_context_listener";
11
+ let div = document.getElementById(id);
12
+ if (!div) {
13
+ div = document.createElement("div");
14
+ div.id = id;
15
+ document.documentElement.appendChild(div);
16
+ }
17
+ return div;
18
+ })();
19
+ // Listens to user changes and refetches the locale from GraphQL
20
+ const userContextListenerForLocale = new ContextListener({
21
+ contextName: USER_CONTEXT_NAME,
22
+ element: userContextListenerDiv,
23
+ onChange: async (next) => {
24
+ if (next) {
25
+ const userProvider = lazilyStartUserContext();
26
+ if (!equal(userProvider.context, next)) {
27
+ debug("User context changed, refetching locale");
28
+ const locale = await fetchLocale();
29
+ const localeProvider = lazilyStartLocaleContext();
30
+ if (localeProvider.context !== locale) {
31
+ debug(`New value fetched from GraphQL [${locale}]`);
32
+ localeProvider.context =
33
+ locale ||
34
+ window.widgetIdent?.locale ||
35
+ navigator.language.replace("-", "_");
36
+ }
37
+ }
38
+ }
39
+ },
40
+ });
41
+ export function startUserContextListenerForLocale() {
42
+ debug("Starting user context listener for locale updates");
43
+ userContextListenerForLocale.start();
44
+ }
@@ -0,0 +1,147 @@
1
+ import type { ContextProvider } from "dom-context";
2
+ declare global {
3
+ interface Window {
4
+ SquatchPortal?: PortalEnv;
5
+ widgetIdent?: WidgetIdent;
6
+ squatchUserIdentity?: ContextProvider<UserIdentity | undefined>;
7
+ squatchLocale?: ContextProvider<string | undefined>;
8
+ squatchProgramId?: ContextProvider<string | undefined>;
9
+ }
10
+ }
11
+ export declare type UserContextName = "sq:user-identity";
12
+ export declare type LocaleContextName = "sq:locale";
13
+ export declare type ProgramContextName = "sq:program-id";
14
+ export declare const USER_CONTEXT_NAME: UserContextName;
15
+ export declare const LOCALE_CONTEXT_NAME: LocaleContextName;
16
+ export declare const PROGRAM_CONTEXT_NAME: ProgramContextName;
17
+ /**
18
+ * The value stored in the UserContext
19
+ */
20
+ export declare type UserIdentity = {
21
+ id: string;
22
+ accountId: string;
23
+ jwt?: string;
24
+ managedIdentity?: {
25
+ email: string;
26
+ emailVerified: boolean;
27
+ sessionData?: {
28
+ [key: string]: any;
29
+ };
30
+ };
31
+ };
32
+ export declare type UserId = {
33
+ id: string;
34
+ accountId: string;
35
+ };
36
+ export interface DecodedSquatchJWT {
37
+ exp?: number;
38
+ user: {
39
+ accountId: string;
40
+ id: string;
41
+ };
42
+ }
43
+ export interface DecodedWidgetAPIJWT {
44
+ exp?: number;
45
+ sub: string;
46
+ }
47
+ export declare type EngagementMedium = "EMBED" | "POPUP";
48
+ export declare const DEFAULT_MEDIUM: EngagementMedium;
49
+ /**
50
+ * Provided by the SaaSquatch GraphQL backend when a widget is rendered.
51
+ *
52
+ * Source: https://github.com/saasquatch/saasquatch/blob/805e51284f818f8656b6458bcee6181f378819d3/packages/saasquatch-core/app/saasquatch/controllers/api/widget/WidgetApi.java
53
+ *
54
+ */
55
+ export interface WidgetIdent {
56
+ tenantAlias: string;
57
+ appDomain: string;
58
+ token: string;
59
+ userId: string;
60
+ accountId: string;
61
+ locale?: string;
62
+ engagementMedium?: "POPUP" | "EMBED";
63
+ programId?: string;
64
+ env?: string;
65
+ }
66
+ /**
67
+ * Portal env doesn't include User Id
68
+ */
69
+ export declare type PortalEnv = Pick<WidgetIdent, "tenantAlias" | "appDomain" | "programId">;
70
+ /**
71
+ * An interface for interacting with the SaaSquatch Admin Portal.
72
+ *
73
+ * Used for rendering widgets in a preview/demo mode.
74
+ */
75
+ export interface SquatchAdmin {
76
+ /**
77
+ * Provides a way of providing user feedback when a widget is rendered in the SaaSquatch admin portal
78
+ *
79
+ * @param text
80
+ */
81
+ showMessage(text: string): void;
82
+ }
83
+ /**
84
+ * Type for the Javascript environment added by https://github.com/saasquatch/squatch-android
85
+ *
86
+ * Should exist as `window.SquatchAndroid`
87
+ */
88
+ export interface SquatchAndroid {
89
+ /**
90
+ *
91
+ * @param shareLink
92
+ * @param messageLink fallback URL to redirect to if the app is not installed
93
+ */
94
+ shareOnFacebook(shareLink: string, messageLink: string): void;
95
+ /**
96
+ * Shows a native Android toast
97
+ *
98
+ * @param text
99
+ */
100
+ showToast(text: string): void;
101
+ }
102
+ /**
103
+ * An interface provided by Squatch.js V2 for widgets.
104
+ *
105
+ * See: https://github.com/saasquatch/squatch-js/blob/8f2b218c9d55567e0cc12d27d635a5fb545e6842/src/widgets/Widget.ts#L47
106
+ *
107
+ */
108
+ export interface SquatchJS2 {
109
+ /**
110
+ * Opens the current popup widget (if loaded as a popup)
111
+ */
112
+ open?: () => void;
113
+ /**
114
+ * Closes the current popup widget (if loaded as a popup)
115
+ */
116
+ close?: () => void;
117
+ /**
118
+ * DEPRECATED used to update user details from inside the widget.
119
+ *
120
+ * Should no longer be used. Replace with natively using the GraphQL API and re-rendering locally. Will be removed in a future version of Squatch.js
121
+ *
122
+ * @deprecated
123
+ */
124
+ reload(userDetails: {
125
+ email: string;
126
+ firstName: string;
127
+ lastName: string;
128
+ }, jwt: string): void;
129
+ }
130
+ export declare type Environment = EnvironmentSDK["type"];
131
+ export declare type EnvironmentSDK = {
132
+ type: "SquatchJS2";
133
+ api: SquatchJS2;
134
+ widgetIdent: WidgetIdent;
135
+ } | {
136
+ type: "SquatchAndroid";
137
+ android: SquatchAndroid;
138
+ widgetIdent: WidgetIdent;
139
+ } | {
140
+ type: "SquatchPortal";
141
+ env: PortalEnv;
142
+ } | {
143
+ type: "SquatchAdmin";
144
+ adminSDK: SquatchAdmin;
145
+ } | {
146
+ type: "None";
147
+ };
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ export const USER_CONTEXT_NAME = "sq:user-identity";
2
+ export const LOCALE_CONTEXT_NAME = "sq:locale";
3
+ export const PROGRAM_CONTEXT_NAME = "sq:program-id";
4
+ export const DEFAULT_MEDIUM = "EMBED";
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@saasquatch/component-environment",
3
+ "version": "1.0.0-0",
4
+ "description": "Environment and contexts for SaaSquatch components",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "engines": {
12
+ "node": ">=16.15"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/saasquatch/program-tools.git"
17
+ },
18
+ "author": "Johan Venter <johan@saasquatch.com>",
19
+ "license": "ISC",
20
+ "devDependencies": {
21
+ "typescript": "^4.7.3"
22
+ },
23
+ "dependencies": {
24
+ "@wry/equality": "^0.5.2",
25
+ "dom-context": "^1.2.0",
26
+ "jwt-decode": "^3.1.2"
27
+ }
28
+ }
@@ -0,0 +1,50 @@
1
+ import { ContextProvider } from "dom-context";
2
+ import { LOCALE_CONTEXT_NAME } from "../types";
3
+ import { debug as _debug } from "../debug";
4
+
5
+ const debug = (...args: any[]) => _debug(LOCALE_CONTEXT_NAME, ...args);
6
+
7
+ /**
8
+ * Lazily start the locale context provider. If it already exists, the existing provider is
9
+ * returned. This function is safe to call multiple times.
10
+ *
11
+ * @returns The global locale context provider
12
+ */
13
+ export function lazilyStartLocaleContext() {
14
+ let globalProvider = window.squatchLocale;
15
+
16
+ if (!globalProvider) {
17
+ debug("Creating locale context provider");
18
+
19
+ globalProvider = new ContextProvider<string | undefined>({
20
+ element: document.documentElement,
21
+ initialState:
22
+ window.widgetIdent?.locale || navigator.language.replace("-", "_"),
23
+ contextName: LOCALE_CONTEXT_NAME,
24
+ }).start();
25
+
26
+ window.squatchLocale = globalProvider;
27
+ }
28
+
29
+ return globalProvider;
30
+ }
31
+
32
+ /**
33
+ * Overide the globally defined Locale context
34
+ *
35
+ * @param locale the new locale used by the user
36
+ */
37
+ export function setLocale(locale?: string) {
38
+ const globalProvider = lazilyStartLocaleContext();
39
+ if (globalProvider.context !== locale) {
40
+ debug(`Setting locale context value [${locale}]`);
41
+ globalProvider.context = locale;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Get the current value of the locale context
47
+ */
48
+ export function getLocale() {
49
+ return window.squatchLocale?.context;
50
+ }
@@ -0,0 +1,50 @@
1
+ import { ContextProvider } from "dom-context";
2
+ import { PROGRAM_CONTEXT_NAME } from "../types";
3
+ import { debug as _debug } from "../debug";
4
+
5
+ const debug = (...args: any[]) => _debug(PROGRAM_CONTEXT_NAME, ...args);
6
+
7
+ /**
8
+ * Lazily start the program context provider. If it already exists, the existing provider is
9
+ * returned. This function is safe to call multiple times.
10
+ *
11
+ * @returns The global program context provider
12
+ */
13
+ export function lazilyStartProgramContext() {
14
+ let globalProvider = window.squatchProgramId;
15
+
16
+ if (!globalProvider) {
17
+ debug("Creating program context provider");
18
+
19
+ // Lazily creates a global provider
20
+ globalProvider = new ContextProvider<string | undefined>({
21
+ element: document.documentElement,
22
+ initialState: window.widgetIdent?.programId || undefined,
23
+ contextName: PROGRAM_CONTEXT_NAME,
24
+ }).start();
25
+
26
+ window.squatchProgramId = globalProvider;
27
+ }
28
+
29
+ return globalProvider;
30
+ }
31
+
32
+ /**
33
+ * Overide the globally defined Program ID context
34
+ *
35
+ * @param programId the new programID used by the user, or undefined if logged out
36
+ */
37
+ export function setProgramId(programId: string | undefined) {
38
+ const globalProvider = lazilyStartProgramContext();
39
+ if (globalProvider.context !== programId) {
40
+ debug(`Setting program context value [${programId}]`);
41
+ globalProvider.context = programId;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Get the current value of the program context
47
+ */
48
+ export function getProgramId() {
49
+ return window.squatchLocale?.context;
50
+ }
@@ -0,0 +1,164 @@
1
+ import decode from "jwt-decode";
2
+ import { ContextProvider } from "dom-context";
3
+ import { equal } from "@wry/equality";
4
+ import { getEnvironmentSDK } from "../environment";
5
+ import {
6
+ USER_CONTEXT_NAME,
7
+ UserIdentity,
8
+ DecodedSquatchJWT,
9
+ DecodedWidgetAPIJWT,
10
+ } from "../types";
11
+ import { startUserContextListenerForLocale } from "../listeners";
12
+ import { debug as _debug } from "../debug";
13
+
14
+ const debug = (...args: any[]) => _debug(USER_CONTEXT_NAME, ...args);
15
+
16
+ /**
17
+ * Lazily start the user context provider. If it already exists, the existing provider is
18
+ * returned. This function is safe to call multiple times.
19
+ *
20
+ * @returns The global user context provider
21
+ */
22
+ export function lazilyStartUserContext() {
23
+ let globalProvider = window.squatchUserIdentity;
24
+
25
+ if (!globalProvider) {
26
+ debug("Creating user context provider");
27
+
28
+ // Lazily creates a global provider
29
+ globalProvider = new ContextProvider<UserIdentity | undefined>({
30
+ element: document.documentElement,
31
+ initialState: _getInitialValue(),
32
+ contextName: USER_CONTEXT_NAME,
33
+ }).start();
34
+
35
+ window.squatchUserIdentity = globalProvider;
36
+ startUserContextListenerForLocale();
37
+ }
38
+
39
+ return globalProvider;
40
+ }
41
+
42
+ function isDecodedSquatchJWT(decoded: any): decoded is DecodedSquatchJWT {
43
+ return decoded.user && decoded.user.id && decoded.user.accountId;
44
+ }
45
+
46
+ function isDecodedWidgetAPIJWT(decoded: any): decoded is DecodedWidgetAPIJWT {
47
+ return decoded.sub && /.*:.*@.*:users/.test(decoded.sub);
48
+ }
49
+
50
+ /**
51
+ * Extract a user identity from a JWT
52
+ *
53
+ * @param jwt The JWT to extract a user identity from
54
+ * @returns The user identity or undefined if the JWT is not valid
55
+ */
56
+ export function userIdentityFromJwt(jwt?: string): UserIdentity | undefined {
57
+ if (!jwt) return undefined;
58
+
59
+ try {
60
+ const decoded = decode<DecodedSquatchJWT | DecodedWidgetAPIJWT>(jwt);
61
+ const exp = decoded.exp;
62
+
63
+ let userId: string | undefined = undefined;
64
+ let accountId: string | undefined = undefined;
65
+
66
+ if (isDecodedWidgetAPIJWT(decoded)) {
67
+ // Pull the accountId and userId from the subject and Base64-decode them
68
+ // NOTE: This is to support classic theme engine widget token generation
69
+ const matches = decoded.sub.match(/(.*):(.*)@(.*):users/);
70
+ if (matches?.[1]) accountId = atob(matches[1]);
71
+ if (matches?.[2]) userId = atob(matches[2]);
72
+ } else if (isDecodedSquatchJWT(decoded)) {
73
+ accountId = decoded.user.accountId;
74
+ userId = decoded.user.id;
75
+ }
76
+
77
+ if (!userId || !accountId) {
78
+ return undefined;
79
+ }
80
+
81
+ // Check if the JWT has expired
82
+ if (exp && Date.now() >= exp * 1000) {
83
+ return undefined;
84
+ }
85
+
86
+ return {
87
+ id: userId,
88
+ accountId: accountId,
89
+ jwt,
90
+ };
91
+ } catch (e) {
92
+ // Invalid JWT
93
+ return undefined;
94
+ }
95
+ }
96
+
97
+ function _getInitialValue(): UserIdentity | undefined {
98
+ const sdk = getEnvironmentSDK();
99
+ switch (sdk.type) {
100
+ case "SquatchAndroid":
101
+ case "SquatchJS2":
102
+ return {
103
+ id: sdk.widgetIdent.userId,
104
+ accountId: sdk.widgetIdent.accountId,
105
+ jwt: sdk.widgetIdent.token,
106
+ };
107
+ case "SquatchPortal":
108
+ // Portals can have the jwt provided as a URL parameter, so look for that first
109
+ const searchParams = new URLSearchParams(document.location.search);
110
+ if (searchParams.has("jwt")) {
111
+ return userIdentityFromJwt(searchParams.get("jwt")!);
112
+ }
113
+
114
+ // Look for user identity in local storage
115
+ const stored = localStorage.getItem(USER_CONTEXT_NAME);
116
+ if (!stored) return undefined;
117
+ try {
118
+ const potentialUserIdent = JSON.parse(stored) as UserIdentity;
119
+ const identity = userIdentityFromJwt(potentialUserIdent.jwt);
120
+ if (identity) {
121
+ return {
122
+ ...potentialUserIdent, // for any stored managedIdentity fields
123
+ ...identity,
124
+ };
125
+ }
126
+ return undefined;
127
+ } catch (e) {
128
+ // Not valid JSON
129
+ return undefined;
130
+ }
131
+ case "SquatchAdmin":
132
+ case "None":
133
+ // Not logged in for admin portal / none default case
134
+ return undefined;
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Overide the globally defined user context, and persists the user identity in local storage
140
+ *
141
+ * @param identity the new identity of the user, or undefined if logged out
142
+ */
143
+ export function setUserIdentity(identity?: UserIdentity) {
144
+ const globalProvider = lazilyStartUserContext();
145
+
146
+ if (!equal(globalProvider.context, identity)) {
147
+ debug(`Setting user context value [${JSON.stringify(identity)}]`);
148
+ globalProvider.context = identity;
149
+ }
150
+
151
+ // Portals store identity in local storage
152
+ if (identity && getEnvironmentSDK().type === "SquatchPortal") {
153
+ localStorage.setItem(USER_CONTEXT_NAME, JSON.stringify(identity));
154
+ } else if (!identity) {
155
+ localStorage.removeItem(USER_CONTEXT_NAME);
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Get the current value of the user context
161
+ */
162
+ export function getUserIdentity() {
163
+ return window.squatchUserIdentity?.context;
164
+ }
package/src/debug.ts ADDED
@@ -0,0 +1,7 @@
1
+ const debugEnabled = localStorage.getItem("debug");
2
+
3
+ export function debug(ns: string, ...args: any[]) {
4
+ if (debugEnabled) {
5
+ console.debug(`sq:environment:${ns}`, ...args);
6
+ }
7
+ }
@@ -0,0 +1,114 @@
1
+ import {
2
+ Environment,
3
+ EnvironmentSDK,
4
+ EngagementMedium,
5
+ DEFAULT_MEDIUM,
6
+ } from "./types";
7
+
8
+ /**
9
+ * Get the type of environment that this widget is being rendered in
10
+ *
11
+ * Should never return null.
12
+ */
13
+ export function getEnvironment(): Environment {
14
+ return getEnvironmentSDK().type;
15
+ }
16
+
17
+ /**
18
+ * Get the SDK for interacting with the host environment
19
+ */
20
+ export function getEnvironmentSDK(): EnvironmentSDK {
21
+ //@ts-ignore
22
+ if (window["SquatchAndroid"]) {
23
+ return {
24
+ type: "SquatchAndroid",
25
+ //@ts-ignore
26
+ android: window["SquatchAndroid"] as SquatchAndroid,
27
+ //@ts-ignore
28
+ widgetIdent: window["widgetIdent"],
29
+ };
30
+ }
31
+
32
+ //@ts-ignore
33
+ if (window["SquatchPortal"]) {
34
+ return {
35
+ type: "SquatchPortal",
36
+ //@ts-ignore
37
+ env: window["SquatchPortal"],
38
+ };
39
+ }
40
+
41
+ //@ts-ignore
42
+ if (window["SquatchAdmin"]) {
43
+ return {
44
+ type: "SquatchAdmin",
45
+ //@ts-ignore
46
+ adminSDK: window["SquatchAdmin"] as SquatchAdmin,
47
+ };
48
+ }
49
+
50
+ // Vanilla components mutates `widgetIdent` for portal, causing boilerplate to render as SquatchJS2
51
+ if (window["widgetIdent"] && window["widgetIdent"]?.env !== "demo") {
52
+ return {
53
+ type: "SquatchJS2",
54
+ //@ts-ignore
55
+ api: window.frameElement?.["squatchJsApi"],
56
+ //@ts-ignore
57
+ widgetIdent: window["widgetIdent"],
58
+ };
59
+ }
60
+
61
+ return {
62
+ type: "None",
63
+ };
64
+ }
65
+
66
+ export function isDemo() {
67
+ const sdk = getEnvironmentSDK();
68
+ return sdk.type === "None" || sdk.type === "SquatchAdmin";
69
+ }
70
+
71
+ // Fake tenant alias in demo mode
72
+ const FAKE_TENANT = "demo";
73
+
74
+ export function getTenantAlias(): string {
75
+ const sdk = getEnvironmentSDK();
76
+ switch (sdk.type) {
77
+ case "SquatchAndroid":
78
+ case "SquatchJS2":
79
+ return sdk.widgetIdent.tenantAlias;
80
+ case "SquatchAdmin":
81
+ case "None":
82
+ return FAKE_TENANT;
83
+ case "SquatchPortal":
84
+ return sdk.env.tenantAlias;
85
+ }
86
+ }
87
+
88
+ const DEFAULT_DOMAIN = "https://app.referralsaasquatch.com";
89
+ export function getAppDomain(): string {
90
+ const sdk = getEnvironmentSDK();
91
+ switch (sdk.type) {
92
+ case "SquatchAndroid":
93
+ case "SquatchJS2":
94
+ return sdk.widgetIdent.appDomain;
95
+ case "SquatchPortal":
96
+ return sdk.env?.appDomain || DEFAULT_DOMAIN;
97
+ case "SquatchAdmin":
98
+ case "None":
99
+ return DEFAULT_DOMAIN;
100
+ }
101
+ }
102
+
103
+ export function getEngagementMedium(): EngagementMedium {
104
+ const sdk = getEnvironmentSDK();
105
+ switch (sdk.type) {
106
+ case "SquatchJS2":
107
+ return sdk.widgetIdent.engagementMedium || DEFAULT_MEDIUM;
108
+ case "SquatchAndroid":
109
+ case "SquatchPortal":
110
+ case "SquatchAdmin":
111
+ case "None":
112
+ return DEFAULT_MEDIUM;
113
+ }
114
+ }