@geosynk/vertigis-web-sdk 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -113,6 +113,7 @@ my-web-library/
|
|
|
113
113
|
|
|
114
114
|
- **`./start.sh` (or `start.bat`)**: Kills stale port 3000 processes, generates SSL certificates if missing, and runs `npm start`.
|
|
115
115
|
- **`npm start`**: Runs the project in development mode with hot reloading.
|
|
116
|
+
- **`npm run auth:portal`**: Interactive wizard to configure ArcGIS Enterprise Portal / AGOL OAuth authentication and secured web maps.
|
|
116
117
|
- **`npm run build`** (or `./build.sh`): Generates an optimized production bundle in `dist/`.
|
|
117
118
|
- **`npm run cert:gen`**: Regenerates development SSL certificates in `certs/`.
|
|
118
119
|
|
|
@@ -158,8 +159,57 @@ build.bat # Windows
|
|
|
158
159
|
# or: npm run build
|
|
159
160
|
```
|
|
160
161
|
Outputs optimized bundles to `build/`:
|
|
161
|
-
- `build/main.js`
|
|
162
|
-
- `build/<project-name>.js
|
|
162
|
+
- `build/main.js` (standard AMD bundle)
|
|
163
|
+
- `build/<project-name>.js` (named bundle for ArcGIS portal hosting)
|
|
164
|
+
- `build/<project-name>.js.txt` (raw text bundle for script upload workflows)
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### 5. ArcGIS Enterprise & Secured Portal Authentication
|
|
169
|
+
|
|
170
|
+
When referencing secured Web Maps or layers from an ArcGIS Enterprise Portal or private ArcGIS Online organization, applications fail to authenticate or incorrectly fall back to the built-in basic username/password modal if OAuth is unconfigured.
|
|
171
|
+
|
|
172
|
+
This SDK includes an automated configuration wizard that sets up seamless OAuth 2.0 authentication, trusted servers, and callback endpoints.
|
|
173
|
+
|
|
174
|
+
#### Step 1: Portal Application Registration (Prerequisite)
|
|
175
|
+
1. Log in to your ArcGIS Enterprise Portal or ArcGIS Online organization.
|
|
176
|
+
2. Navigate to **Content** > **Add Item** > **An Application** > **Application Configuration**.
|
|
177
|
+
3. Under **Redirect URIs**, add the following development endpoints:
|
|
178
|
+
- `https://localtest.me:3001`
|
|
179
|
+
- `https://localtest.me:3001/oauth_callback.html`
|
|
180
|
+
4. Copy the generated **App ID / Client ID** (e.g., `wXfL4Me24ZkSoALH`).
|
|
181
|
+
|
|
182
|
+
#### Step 2: Run the Automated Portal Configurator
|
|
183
|
+
Run the interactive configurator in your project:
|
|
184
|
+
```bash
|
|
185
|
+
npm run auth:portal
|
|
186
|
+
```
|
|
187
|
+
You will be prompted for:
|
|
188
|
+
- **Portal URL**: Your Enterprise Portal instance (e.g., `https://gis-prod.cimic.com.au/Portal`).
|
|
189
|
+
- **App ID (Client ID)**: The App ID obtained from Step 1.
|
|
190
|
+
- **Account ID**: Organization identifier (e.g., `cimic` or `enterprise`).
|
|
191
|
+
- **Web Map Item ID or URL**: The secured web map to load (e.g., `d7d5b2a4502b49d0934a1fb5bddd9a97`).
|
|
192
|
+
|
|
193
|
+
Or execute directly via non-interactive CLI flags:
|
|
194
|
+
```bash
|
|
195
|
+
npm run auth:portal -- \
|
|
196
|
+
--portal https://gis-prod.cimic.com.au/Portal \
|
|
197
|
+
--app-id wXfL4Me24ZkSoALH \
|
|
198
|
+
--account-id cimic \
|
|
199
|
+
--webmap d7d5b2a4502b49d0934a1fb5bddd9a97
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### Step 3: Start Development Server
|
|
203
|
+
```bash
|
|
204
|
+
npm start
|
|
205
|
+
```
|
|
206
|
+
When accessing `https://localtest.me:3001/`, VertiGIS Web automatically triggers the official ArcGIS Enterprise Portal OAuth popup/redirect flow instead of prompting for basic username/password credentials.
|
|
207
|
+
|
|
208
|
+
#### How It Works Under the Hood
|
|
209
|
+
1. **`app/auth/portal.json`**: Generated with `{ portal, appId, clientId, accountId }` conforming strictly to VertiGIS Web's native schema parser.
|
|
210
|
+
2. **`webpack.config.js` Middleware**: The dev server's `portal-auth-interceptor` automatically intercepts `/viewer/auth/portal.json` and serves `app/auth/portal.json` and `app/oauth_callback.html`.
|
|
211
|
+
3. **`src/auth/index.ts`**: The extension entry point initializes `esriConfig.portalUrl`, registers `esriConfig.request.trustedServers`, and registers `OAuthInfo` in `IdentityManager`.
|
|
212
|
+
4. **Reverting to Defaults**: Run `npm run auth:portal -- --reset` to revert back to public sample ArcGIS Online maps at any time.
|
|
163
213
|
|
|
164
214
|
**Hosting Requirements**:
|
|
165
215
|
- Host over **HTTPS** with a valid SSL certificate.
|
package/package.json
CHANGED
package/scripts/create.js
CHANGED
|
@@ -38,6 +38,7 @@ if (fs.existsSync(customTemplateDir) && fs.existsSync(targetPath)) {
|
|
|
38
38
|
path.join(targetPath, "certs/generate-cert.sh"),
|
|
39
39
|
path.join(targetPath, "start.sh"),
|
|
40
40
|
path.join(targetPath, "build.sh"),
|
|
41
|
+
path.join(targetPath, "scripts/configure-portal.js"),
|
|
41
42
|
];
|
|
42
43
|
for (const exe of executables) {
|
|
43
44
|
if (fs.existsSync(exe)) {
|
|
@@ -79,9 +80,10 @@ if (fs.existsSync(customTemplateDir) && fs.existsSync(targetPath)) {
|
|
|
79
80
|
|
|
80
81
|
pkg.scripts = pkg.scripts || {};
|
|
81
82
|
pkg.scripts["cert:gen"] = "bash ./certs/generate-cert.sh";
|
|
83
|
+
pkg.scripts["auth:portal"] = "node ./scripts/configure-portal.js";
|
|
82
84
|
|
|
83
85
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 4) + "\n", "utf-8");
|
|
84
|
-
console.log("[ENTERPRISE] Added enterprise dependencies
|
|
86
|
+
console.log("[ENTERPRISE] Added enterprise dependencies and auth:portal script to package.json");
|
|
85
87
|
} catch (e) {
|
|
86
88
|
console.warn("[WARN] Failed to merge enterprise package.json dependencies:", e);
|
|
87
89
|
}
|
|
@@ -107,6 +109,7 @@ if (fs.existsSync(customTemplateDir) && fs.existsSync(targetPath)) {
|
|
|
107
109
|
console.log(" - Centralized Design Tokens: src/tokens/ (100% safe fallbacks & color-mix)");
|
|
108
110
|
console.log(" - Dynamic Dark/Light Theme: src/hooks/useIsDarkTheme.ts & src/utils/");
|
|
109
111
|
console.log(" - Anti-God Component: src/components/CustomWidget/ (ErrorBoundary)");
|
|
112
|
+
console.log(" - Portal Auth Config: npm run auth:portal (Enterprise Portal / AGOL OAuth)");
|
|
110
113
|
console.log(" - Development Scripts: start.sh / start.bat, build.sh / build.bat");
|
|
111
114
|
console.log(" - AI Directives: AGENTS.md pre-configured for coding assistants");
|
|
112
115
|
console.log("================================================================================\n");
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import readline from "node:readline";
|
|
8
|
+
|
|
9
|
+
const projRoot = process.cwd();
|
|
10
|
+
const appJsonPath = path.join(projRoot, "app/app.json");
|
|
11
|
+
const portalJsonPath = path.join(projRoot, "app/auth/portal.json");
|
|
12
|
+
const portalConfigPath = path.join(projRoot, "src/auth/portalConfig.json");
|
|
13
|
+
const oauthCallbackPath = path.join(projRoot, "app/oauth_callback.html");
|
|
14
|
+
|
|
15
|
+
const args = process.argv.slice(2);
|
|
16
|
+
|
|
17
|
+
function printHelp() {
|
|
18
|
+
console.log(`
|
|
19
|
+
================================================================================
|
|
20
|
+
VertiGIS Studio Web SDK - Portal Authentication Configurator
|
|
21
|
+
================================================================================
|
|
22
|
+
|
|
23
|
+
Usage:
|
|
24
|
+
npm run auth:portal
|
|
25
|
+
npm run auth:portal -- [options]
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
--portal <url> ArcGIS Enterprise Portal or AGOL URL (e.g. https://gis.company.com/portal)
|
|
29
|
+
--app-id <id> Portal OAuth Application Client ID / App ID
|
|
30
|
+
--account-id <id> Account ID / Org slug (default: derived from hostname or "enterprise")
|
|
31
|
+
--webmap <id-or-url> Web Map Item ID or full Portal URL
|
|
32
|
+
--reset Revert back to public sample ArcGIS Online map and disable portal auth
|
|
33
|
+
-h, --help Show this help message
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
Interactive Mode:
|
|
37
|
+
npm run auth:portal
|
|
38
|
+
|
|
39
|
+
Direct CLI Mode:
|
|
40
|
+
npm run auth:portal -- --portal https://gis.example.com/portal --app-id MyClientId123 --webmap d7d5b2a4502b49d0934a1fb5bddd9a97
|
|
41
|
+
|
|
42
|
+
Reset to Defaults:
|
|
43
|
+
npm run auth:portal -- --reset
|
|
44
|
+
`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getArgValue(flag) {
|
|
48
|
+
const idx = args.indexOf(flag);
|
|
49
|
+
if (idx !== -1 && idx + 1 < args.length) {
|
|
50
|
+
return args[idx + 1];
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function prompt(rl, question, defaultValue = "") {
|
|
56
|
+
return new Promise(resolve => {
|
|
57
|
+
const query = defaultValue ? `${question} [${defaultValue}]: ` : `${question}: `;
|
|
58
|
+
rl.question(query, answer => {
|
|
59
|
+
const trimmed = answer.trim();
|
|
60
|
+
resolve(trimmed || defaultValue);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const DEFAULT_WEBMAP = "https://www.arcgis.com/home/item.html?id=b834a68d7a484c5fb473d4ba90d35e71";
|
|
66
|
+
|
|
67
|
+
async function main() {
|
|
68
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
69
|
+
printHelp();
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (args.includes("--reset")) {
|
|
74
|
+
console.log("\n[AUTH] Resetting to standard ArcGIS Online default configuration...");
|
|
75
|
+
|
|
76
|
+
// 1. Reset portalConfig.json
|
|
77
|
+
if (fs.existsSync(portalConfigPath)) {
|
|
78
|
+
fs.writeFileSync(portalConfigPath, JSON.stringify({
|
|
79
|
+
enabled: false,
|
|
80
|
+
portal: "",
|
|
81
|
+
appId: "",
|
|
82
|
+
clientId: "",
|
|
83
|
+
accountId: "",
|
|
84
|
+
webMap: ""
|
|
85
|
+
}, null, 2) + "\n");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 2. Remove app/auth/portal.json if exists
|
|
89
|
+
if (fs.existsSync(portalJsonPath)) {
|
|
90
|
+
fs.unlinkSync(portalJsonPath);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 3. Reset app/app.json webMap
|
|
94
|
+
if (fs.existsSync(appJsonPath)) {
|
|
95
|
+
const appData = JSON.parse(fs.readFileSync(appJsonPath, "utf-8"));
|
|
96
|
+
if (Array.isArray(appData.items)) {
|
|
97
|
+
const mapItem = appData.items.find(it => it.$type === "map-extension");
|
|
98
|
+
if (mapItem) {
|
|
99
|
+
mapItem.webMap = DEFAULT_WEBMAP;
|
|
100
|
+
fs.writeFileSync(appJsonPath, JSON.stringify(appData, null, 2) + "\n");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
console.log("✔ Reset complete. Project restored to default public ArcGIS Online map.\n");
|
|
106
|
+
process.exit(0);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let portalUrl = getArgValue("--portal");
|
|
110
|
+
let appId = getArgValue("--app-id") || getArgValue("--client-id");
|
|
111
|
+
let accountId = getArgValue("--account-id");
|
|
112
|
+
let webMap = getArgValue("--webmap") || getArgValue("--webMap");
|
|
113
|
+
|
|
114
|
+
// Load existing values as defaults if available
|
|
115
|
+
let existingConfig = {};
|
|
116
|
+
if (fs.existsSync(portalConfigPath)) {
|
|
117
|
+
try {
|
|
118
|
+
existingConfig = JSON.parse(fs.readFileSync(portalConfigPath, "utf-8"));
|
|
119
|
+
} catch {}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!portalUrl || !appId) {
|
|
123
|
+
console.log("\n================================================================================");
|
|
124
|
+
console.log(" VertiGIS Studio Web SDK - Configure ArcGIS Enterprise Portal Authentication");
|
|
125
|
+
console.log("================================================================================\n");
|
|
126
|
+
|
|
127
|
+
const rl = readline.createInterface({
|
|
128
|
+
input: process.stdin,
|
|
129
|
+
output: process.stdout,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
portalUrl = portalUrl || await prompt(
|
|
134
|
+
rl,
|
|
135
|
+
"ArcGIS Enterprise Portal or AGOL URL",
|
|
136
|
+
existingConfig.portal || "https://gis-prod.cimic.com.au/Portal"
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
appId = appId || await prompt(
|
|
140
|
+
rl,
|
|
141
|
+
"Portal OAuth Application App ID (Client ID)",
|
|
142
|
+
existingConfig.appId || ""
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
if (!appId) {
|
|
146
|
+
console.error("\n✖ Error: App ID (Client ID) is required to configure OAuth.");
|
|
147
|
+
rl.close();
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const defaultAccount = existingConfig.accountId || (new URL(portalUrl).hostname.split(".")[0] || "enterprise");
|
|
152
|
+
accountId = accountId || await prompt(
|
|
153
|
+
rl,
|
|
154
|
+
"Account ID (organization identifier)",
|
|
155
|
+
defaultAccount
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
webMap = webMap || await prompt(
|
|
159
|
+
rl,
|
|
160
|
+
"Web Map Item ID or Full URL (leave empty to keep current)",
|
|
161
|
+
existingConfig.webMap || ""
|
|
162
|
+
);
|
|
163
|
+
} finally {
|
|
164
|
+
rl.close();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Clean portal URL (strip trailing slashes)
|
|
169
|
+
portalUrl = portalUrl.trim().replace(/\/+$/, "");
|
|
170
|
+
appId = appId.trim();
|
|
171
|
+
accountId = (accountId || "enterprise").trim();
|
|
172
|
+
webMap = (webMap || "").trim();
|
|
173
|
+
|
|
174
|
+
// 1. Write app/auth/portal.json (required for VertiGIS Studio Web native detection)
|
|
175
|
+
fs.mkdirSync(path.dirname(portalJsonPath), { recursive: true });
|
|
176
|
+
const portalJsonData = {
|
|
177
|
+
portal: portalUrl,
|
|
178
|
+
appId: appId,
|
|
179
|
+
clientId: appId,
|
|
180
|
+
accountId: accountId,
|
|
181
|
+
};
|
|
182
|
+
fs.writeFileSync(portalJsonPath, JSON.stringify(portalJsonData, null, 2) + "\n");
|
|
183
|
+
console.log(`\n✔ Wrote ${path.relative(projRoot, portalJsonPath)}`);
|
|
184
|
+
|
|
185
|
+
// 2. Write src/auth/portalConfig.json (used by SDK runtime initialization)
|
|
186
|
+
fs.mkdirSync(path.dirname(portalConfigPath), { recursive: true });
|
|
187
|
+
const portalConfigData = {
|
|
188
|
+
enabled: true,
|
|
189
|
+
portal: portalUrl,
|
|
190
|
+
appId: appId,
|
|
191
|
+
clientId: appId,
|
|
192
|
+
accountId: accountId,
|
|
193
|
+
webMap: webMap || existingConfig.webMap || "",
|
|
194
|
+
};
|
|
195
|
+
fs.writeFileSync(portalConfigPath, JSON.stringify(portalConfigData, null, 2) + "\n");
|
|
196
|
+
console.log(`✔ Wrote ${path.relative(projRoot, portalConfigPath)}`);
|
|
197
|
+
|
|
198
|
+
// 3. Update app/app.json if webMap was provided
|
|
199
|
+
if (webMap && fs.existsSync(appJsonPath)) {
|
|
200
|
+
try {
|
|
201
|
+
const appData = JSON.parse(fs.readFileSync(appJsonPath, "utf-8"));
|
|
202
|
+
if (Array.isArray(appData.items)) {
|
|
203
|
+
const mapItem = appData.items.find(it => it.$type === "map-extension");
|
|
204
|
+
if (mapItem) {
|
|
205
|
+
// Normalize webMap: if it's just a 32-character GUID, format as full portal item URL if not AGOL
|
|
206
|
+
let targetWebMapUrl = webMap;
|
|
207
|
+
if (/^[0-9a-fA-F]{32}$/.test(webMap)) {
|
|
208
|
+
targetWebMapUrl = `${portalUrl}/home/item.html?id=${webMap}`;
|
|
209
|
+
}
|
|
210
|
+
mapItem.webMap = targetWebMapUrl;
|
|
211
|
+
fs.writeFileSync(appJsonPath, JSON.stringify(appData, null, 2) + "\n");
|
|
212
|
+
console.log(`✔ Updated webMap in ${path.relative(projRoot, appJsonPath)} -> ${targetWebMapUrl}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} catch (e) {
|
|
216
|
+
console.warn("[WARN] Could not update app/app.json:", e);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 4. Ensure oauth_callback.html exists
|
|
221
|
+
if (!fs.existsSync(oauthCallbackPath)) {
|
|
222
|
+
const callbackHtml = `<!DOCTYPE html>
|
|
223
|
+
<html>
|
|
224
|
+
<head>
|
|
225
|
+
<meta charset="utf-8">
|
|
226
|
+
<title>OAuth Callback</title>
|
|
227
|
+
<script>
|
|
228
|
+
function loadHandler() {
|
|
229
|
+
if (opener) {
|
|
230
|
+
if (location.hash && opener.completeOAuth) {
|
|
231
|
+
opener.completeOAuth(location.hash);
|
|
232
|
+
close();
|
|
233
|
+
} else if (location.search) {
|
|
234
|
+
opener.dispatchEvent(new CustomEvent("arcgis:auth:location:search", { detail: location.search }));
|
|
235
|
+
close();
|
|
236
|
+
} else {
|
|
237
|
+
close();
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
close();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
window.addEventListener("load", loadHandler);
|
|
244
|
+
</script>
|
|
245
|
+
</head>
|
|
246
|
+
<body></body>
|
|
247
|
+
</html>\n`;
|
|
248
|
+
fs.writeFileSync(oauthCallbackPath, callbackHtml);
|
|
249
|
+
console.log(`✔ Created ${path.relative(projRoot, oauthCallbackPath)}`);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
console.log("\n================================================================================");
|
|
253
|
+
console.log(" [SUCCESS] ArcGIS Enterprise Portal Authentication Configured!");
|
|
254
|
+
console.log("================================================================================");
|
|
255
|
+
console.log(` - Portal: ${portalUrl}`);
|
|
256
|
+
console.log(` - App ID: ${appId}`);
|
|
257
|
+
console.log(` - Account ID: ${accountId}`);
|
|
258
|
+
if (webMap) {
|
|
259
|
+
console.log(` - Web Map: ${webMap}`);
|
|
260
|
+
}
|
|
261
|
+
console.log("\n IMPORTANT PREREQUISITE in your Portal App Registration:");
|
|
262
|
+
console.log(" Ensure the following Redirect URIs are registered in Portal:");
|
|
263
|
+
console.log(" • https://localtest.me:3001");
|
|
264
|
+
console.log(" • https://localtest.me:3001/oauth_callback.html");
|
|
265
|
+
console.log("\n Next Steps:");
|
|
266
|
+
console.log(" Run: npm start (or ./start.sh)");
|
|
267
|
+
console.log("================================================================================\n");
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
main().catch(err => {
|
|
271
|
+
console.error("✖ Configuration failed:", err);
|
|
272
|
+
process.exit(1);
|
|
273
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import esriConfig from "@arcgis/core/config";
|
|
2
|
+
import esriId from "@arcgis/core/identity/IdentityManager";
|
|
3
|
+
import OAuthInfo from "@arcgis/core/identity/OAuthInfo";
|
|
4
|
+
import portalConfig from "./portalConfig.json";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Initializes ArcGIS Enterprise Portal / AGOL OAuth authentication and trusted servers
|
|
8
|
+
* if a portal is configured. If disabled, maintains default standard unauthenticated behavior.
|
|
9
|
+
*/
|
|
10
|
+
export function initPortalAuth(): void {
|
|
11
|
+
if (!portalConfig || !portalConfig.enabled || !portalConfig.portal || !portalConfig.appId) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { portal, appId } = portalConfig;
|
|
16
|
+
const cleanPortalUrl = portal.replace(/\/+$/, "");
|
|
17
|
+
const portalVariants = Array.from(new Set([cleanPortalUrl, cleanPortalUrl.toLowerCase()]));
|
|
18
|
+
|
|
19
|
+
esriConfig.request.trustedServers = esriConfig.request.trustedServers ?? [];
|
|
20
|
+
for (const url of portalVariants) {
|
|
21
|
+
if (!esriConfig.request.trustedServers.includes(url)) {
|
|
22
|
+
esriConfig.request.trustedServers.push(url);
|
|
23
|
+
}
|
|
24
|
+
const oauthInfo = new OAuthInfo({
|
|
25
|
+
appId,
|
|
26
|
+
portalUrl: url,
|
|
27
|
+
popup: true,
|
|
28
|
+
popupCallbackUrl: "https://localtest.me:3001/oauth_callback.html",
|
|
29
|
+
});
|
|
30
|
+
esriId.registerOAuthInfos([oauthInfo]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
esriConfig.portalUrl = cleanPortalUrl;
|
|
34
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { LibraryRegistry } from "@vertigis/web/config";
|
|
2
2
|
import CustomWidget, { CustomWidgetModel } from "./components/CustomWidget";
|
|
3
|
+
import { initPortalAuth } from "./auth";
|
|
4
|
+
|
|
5
|
+
// Automatically initialize ArcGIS Enterprise Portal OAuth if configured via `npm run auth:portal`
|
|
6
|
+
initPortalAuth();
|
|
3
7
|
|
|
4
8
|
const LAYOUT_NAMESPACE = "custom.foo";
|
|
5
9
|
|