@esri/hub-common 9.12.0 → 9.13.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.
- package/dist/es2017/ArcGISContext.js +280 -0
- package/dist/es2017/ArcGISContext.js.map +1 -0
- package/dist/es2017/index.js +1 -0
- package/dist/es2017/index.js.map +1 -1
- package/dist/es2017/utils/index.js +1 -0
- package/dist/es2017/utils/index.js.map +1 -1
- package/dist/es2017/utils/sessionLocalStorage.js +47 -0
- package/dist/es2017/utils/sessionLocalStorage.js.map +1 -0
- package/dist/esm/ArcGISContext.js +395 -0
- package/dist/esm/ArcGISContext.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/sessionLocalStorage.js +50 -0
- package/dist/esm/utils/sessionLocalStorage.js.map +1 -0
- package/dist/node/ArcGISContext.js +284 -0
- package/dist/node/ArcGISContext.js.map +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/utils/index.js +1 -0
- package/dist/node/utils/index.js.map +1 -1
- package/dist/node/utils/sessionLocalStorage.js +53 -0
- package/dist/node/utils/sessionLocalStorage.js.map +1 -0
- package/dist/types/ArcGISContext.d.ts +148 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +5 -2
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/sessionLocalStorage.d.ts +23 -0
- package/dist/umd/common.umd.js +3171 -2694
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { getSelf } from "@esri/arcgis-rest-portal";
|
|
3
|
+
import { getProp, getWithDefault } from ".";
|
|
4
|
+
/**
|
|
5
|
+
* Hash of Hub API end points so updates
|
|
6
|
+
* are centralized
|
|
7
|
+
*/
|
|
8
|
+
var hubApiEndpoints = {
|
|
9
|
+
domains: "/api/v3/domains",
|
|
10
|
+
search: "/api/v3/datasets",
|
|
11
|
+
discussions: "/api/discussions/v1",
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Application Context Object
|
|
15
|
+
*
|
|
16
|
+
* Abstraction that combines a `UserSession` with
|
|
17
|
+
* the `portal/self` and `user/self` responses to
|
|
18
|
+
* provide a central lookup of platform information.
|
|
19
|
+
*
|
|
20
|
+
* This is a work-in-progress, and will likely expand over time.
|
|
21
|
+
*
|
|
22
|
+
* `ArcGISContext` is used in conjuction with the `arcgis-app-identity`
|
|
23
|
+
* component to orchestrate oAuth.
|
|
24
|
+
*/
|
|
25
|
+
var ArcGISContext = /** @class */ (function () {
|
|
26
|
+
/**
|
|
27
|
+
* Private constructor. Use `ArcGISContext.create(...)` to
|
|
28
|
+
* instantiate an instance
|
|
29
|
+
* @param opts
|
|
30
|
+
*/
|
|
31
|
+
function ArcGISContext(opts) {
|
|
32
|
+
this._portalUrl = "https://www.arcgis.com";
|
|
33
|
+
this._debug = false;
|
|
34
|
+
// Having a unique id makes debugging easier
|
|
35
|
+
this.id = new Date().getTime();
|
|
36
|
+
if (opts.debug) {
|
|
37
|
+
this._debug = opts.debug;
|
|
38
|
+
}
|
|
39
|
+
this.log("ArcGISContext:ctor: Creating " + this.id);
|
|
40
|
+
if (opts.authentication) {
|
|
41
|
+
this._authentication = opts.authentication;
|
|
42
|
+
this._portalUrl = this._authentication.portal.replace("/sharing/rest", "");
|
|
43
|
+
this._hubUrl = getHubApiFromPortalUrl(this._portalUrl);
|
|
44
|
+
}
|
|
45
|
+
else if (opts.portalUrl) {
|
|
46
|
+
this._portalUrl = opts.portalUrl;
|
|
47
|
+
this._hubUrl = getHubApiFromPortalUrl(this._portalUrl);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this._hubUrl = getHubApiFromPortalUrl(this._portalUrl);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Static async Factory
|
|
55
|
+
* @param opts
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
ArcGISContext.create = function (opts) {
|
|
59
|
+
if (opts === void 0) { opts = {}; }
|
|
60
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
+
var ctx;
|
|
62
|
+
return __generator(this, function (_a) {
|
|
63
|
+
switch (_a.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
ctx = new ArcGISContext(opts);
|
|
66
|
+
return [4 /*yield*/, ctx.initialize()];
|
|
67
|
+
case 1:
|
|
68
|
+
_a.sent();
|
|
69
|
+
return [2 /*return*/, ctx];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* If we have a UserSession, fetch portal/self and
|
|
76
|
+
* store that along with current user
|
|
77
|
+
*/
|
|
78
|
+
ArcGISContext.prototype.initialize = function () {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var ps;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (!this._authentication) return [3 /*break*/, 2];
|
|
85
|
+
this.log("ArcGISContext-" + this.id + ": Initializing");
|
|
86
|
+
return [4 /*yield*/, getSelf({ authentication: this._authentication })];
|
|
87
|
+
case 1:
|
|
88
|
+
ps = _a.sent();
|
|
89
|
+
this._portalSelf = ps;
|
|
90
|
+
this._currentUser = ps.user;
|
|
91
|
+
_a.label = 2;
|
|
92
|
+
case 2: return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
// Set authentication after the instance is up and running
|
|
98
|
+
ArcGISContext.prototype.setAuthentication = function (auth) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
this._authentication = auth;
|
|
104
|
+
this._portalUrl = auth.portal.replace("/sharing/rest", "");
|
|
105
|
+
return [4 /*yield*/, this.initialize()];
|
|
106
|
+
case 1:
|
|
107
|
+
_a.sent();
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* @internal
|
|
115
|
+
* Log debugging messages to the console
|
|
116
|
+
* @param message
|
|
117
|
+
*/
|
|
118
|
+
ArcGISContext.prototype.log = function (message) {
|
|
119
|
+
if (this._debug) {
|
|
120
|
+
// tslint:disable-next-line:no-console
|
|
121
|
+
console.info(message);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
Object.defineProperty(ArcGISContext.prototype, "session", {
|
|
125
|
+
/**
|
|
126
|
+
* Return the UserSession if authenticated
|
|
127
|
+
*/
|
|
128
|
+
get: function () {
|
|
129
|
+
return this._authentication;
|
|
130
|
+
},
|
|
131
|
+
enumerable: false,
|
|
132
|
+
configurable: true
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(ArcGISContext.prototype, "isAuthenticated", {
|
|
135
|
+
/**
|
|
136
|
+
* Return boolean indicating if authenticatio is present
|
|
137
|
+
*/
|
|
138
|
+
get: function () {
|
|
139
|
+
return !!this._authentication;
|
|
140
|
+
},
|
|
141
|
+
enumerable: false,
|
|
142
|
+
configurable: true
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(ArcGISContext.prototype, "userRequestOptions", {
|
|
145
|
+
/**
|
|
146
|
+
* Return `IUserRequestOptions`, which is used for REST-JS
|
|
147
|
+
* functions which require authentication information.
|
|
148
|
+
*
|
|
149
|
+
* If context is not authenticated, this function will throw
|
|
150
|
+
*/
|
|
151
|
+
get: function () {
|
|
152
|
+
if (this.isAuthenticated) {
|
|
153
|
+
return {
|
|
154
|
+
authentication: this._authentication,
|
|
155
|
+
portal: this.sharingApiUrl,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
enumerable: false,
|
|
160
|
+
configurable: true
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(ArcGISContext.prototype, "requestOptions", {
|
|
163
|
+
/**
|
|
164
|
+
* Return `IRequestOptions`, which is used by REST-JS functions
|
|
165
|
+
* which *may* use authentication information if provided.
|
|
166
|
+
*
|
|
167
|
+
* If context is not authenticated, this function just returns
|
|
168
|
+
* the `portal` property, which informs REST-JS what Sharing API
|
|
169
|
+
* instance to use (i.e. AGO, Enterprise etc)
|
|
170
|
+
*/
|
|
171
|
+
get: function () {
|
|
172
|
+
var ro = {
|
|
173
|
+
portal: this.sharingApiUrl,
|
|
174
|
+
};
|
|
175
|
+
if (this.isAuthenticated) {
|
|
176
|
+
ro = {
|
|
177
|
+
authentication: this._authentication,
|
|
178
|
+
portal: this.sharingApiUrl,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return ro;
|
|
182
|
+
},
|
|
183
|
+
enumerable: false,
|
|
184
|
+
configurable: true
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(ArcGISContext.prototype, "hubRequestOptions", {
|
|
187
|
+
/**
|
|
188
|
+
* Return a `IHubRequestOptions` object
|
|
189
|
+
*/
|
|
190
|
+
get: function () {
|
|
191
|
+
// We may add more logic around what is returned in some corner cases
|
|
192
|
+
return {
|
|
193
|
+
authentication: this.session,
|
|
194
|
+
isPortal: this.isPortal,
|
|
195
|
+
portalSelf: this.portal,
|
|
196
|
+
hubApiUrl: this.hubUrl,
|
|
197
|
+
};
|
|
198
|
+
},
|
|
199
|
+
enumerable: false,
|
|
200
|
+
configurable: true
|
|
201
|
+
});
|
|
202
|
+
Object.defineProperty(ArcGISContext.prototype, "portalUrl", {
|
|
203
|
+
// ==============================
|
|
204
|
+
// Getters / Computed Properties
|
|
205
|
+
// ==============================
|
|
206
|
+
/**
|
|
207
|
+
* Return the portal url.
|
|
208
|
+
*
|
|
209
|
+
* If authenticated @ ArcGIS Online, it will return
|
|
210
|
+
* the https://org.env.arcgis.com
|
|
211
|
+
*
|
|
212
|
+
* If authenticated @ ArcGIS Enterprise, it will return
|
|
213
|
+
* https://portalHostname, which includes the web adaptor
|
|
214
|
+
*/
|
|
215
|
+
get: function () {
|
|
216
|
+
if (this.isAuthenticated) {
|
|
217
|
+
if (this.isPortal) {
|
|
218
|
+
return "https://" + this._portalSelf.portalHostname;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
return "https://" + this._portalSelf.urlKey + "." + this._portalSelf.customBaseUrl;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
return this._portalUrl;
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
enumerable: false,
|
|
229
|
+
configurable: true
|
|
230
|
+
});
|
|
231
|
+
Object.defineProperty(ArcGISContext.prototype, "sharingApiUrl", {
|
|
232
|
+
/**
|
|
233
|
+
* Returns the url to the sharing api
|
|
234
|
+
* i.e. https://myorg.maps.arcgis.com/sharing/rest
|
|
235
|
+
*/
|
|
236
|
+
get: function () {
|
|
237
|
+
return this.portalUrl + "/sharing/rest";
|
|
238
|
+
},
|
|
239
|
+
enumerable: false,
|
|
240
|
+
configurable: true
|
|
241
|
+
});
|
|
242
|
+
Object.defineProperty(ArcGISContext.prototype, "hubUrl", {
|
|
243
|
+
get: function () {
|
|
244
|
+
return this._hubUrl;
|
|
245
|
+
},
|
|
246
|
+
enumerable: false,
|
|
247
|
+
configurable: true
|
|
248
|
+
});
|
|
249
|
+
Object.defineProperty(ArcGISContext.prototype, "isPortal", {
|
|
250
|
+
/**
|
|
251
|
+
* Returns boolean indicating if the backing system
|
|
252
|
+
* is ArcGIS Enterprise (formerly ArcGIS Portal) or not
|
|
253
|
+
*/
|
|
254
|
+
get: function () {
|
|
255
|
+
return this._portalSelf
|
|
256
|
+
? this._portalSelf.isPortal
|
|
257
|
+
: this._portalUrl.indexOf("arcgis.com") === -1;
|
|
258
|
+
},
|
|
259
|
+
enumerable: false,
|
|
260
|
+
configurable: true
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(ArcGISContext.prototype, "discussionsServiceUrl", {
|
|
263
|
+
// Hub APIs
|
|
264
|
+
// ----------
|
|
265
|
+
// Discussions
|
|
266
|
+
get: function () {
|
|
267
|
+
if (this._hubUrl) {
|
|
268
|
+
return "" + this._hubUrl + hubApiEndpoints.discussions;
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
enumerable: false,
|
|
272
|
+
configurable: true
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(ArcGISContext.prototype, "hubSearchServiceUrl", {
|
|
275
|
+
// Hub Search
|
|
276
|
+
get: function () {
|
|
277
|
+
if (this._hubUrl) {
|
|
278
|
+
return "" + this._hubUrl + hubApiEndpoints.search;
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
enumerable: false,
|
|
282
|
+
configurable: true
|
|
283
|
+
});
|
|
284
|
+
Object.defineProperty(ArcGISContext.prototype, "domainServiceUrl", {
|
|
285
|
+
// Domain
|
|
286
|
+
get: function () {
|
|
287
|
+
if (this._hubUrl) {
|
|
288
|
+
return "" + this._hubUrl + hubApiEndpoints.domains;
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
enumerable: false,
|
|
292
|
+
configurable: true
|
|
293
|
+
});
|
|
294
|
+
Object.defineProperty(ArcGISContext.prototype, "eventsConfig", {
|
|
295
|
+
// Events
|
|
296
|
+
// returns `{serviceId: '3ef..', publicViewId: 'bc3...'}
|
|
297
|
+
get: function () {
|
|
298
|
+
if (this._portalSelf) {
|
|
299
|
+
return getProp(this._portalSelf, "portalProperties.hub.settings.events");
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
enumerable: false,
|
|
303
|
+
configurable: true
|
|
304
|
+
});
|
|
305
|
+
Object.defineProperty(ArcGISContext.prototype, "hubEnabled", {
|
|
306
|
+
/**
|
|
307
|
+
* Returns boolean indicating if the current user
|
|
308
|
+
* belongs to an organization that has licensed
|
|
309
|
+
* ArcGIS Hub
|
|
310
|
+
*/
|
|
311
|
+
get: function () {
|
|
312
|
+
return getWithDefault(this._portalSelf, "portalProperties.hub.enabled", false);
|
|
313
|
+
},
|
|
314
|
+
enumerable: false,
|
|
315
|
+
configurable: true
|
|
316
|
+
});
|
|
317
|
+
Object.defineProperty(ArcGISContext.prototype, "communityOrgId", {
|
|
318
|
+
/**
|
|
319
|
+
* Return Hub Community Org Id, if defined
|
|
320
|
+
*/
|
|
321
|
+
get: function () {
|
|
322
|
+
if (this._portalSelf) {
|
|
323
|
+
return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.orgId");
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
enumerable: false,
|
|
327
|
+
configurable: true
|
|
328
|
+
});
|
|
329
|
+
Object.defineProperty(ArcGISContext.prototype, "communityOrgHostname", {
|
|
330
|
+
get: function () {
|
|
331
|
+
if (this._portalSelf) {
|
|
332
|
+
return getProp(this._portalSelf, "portalProperties.hub.settings.communityOrg.portalHostname");
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
enumerable: false,
|
|
336
|
+
configurable: true
|
|
337
|
+
});
|
|
338
|
+
Object.defineProperty(ArcGISContext.prototype, "communityOrgUrl", {
|
|
339
|
+
get: function () {
|
|
340
|
+
if (this.communityOrgHostname) {
|
|
341
|
+
return "https://" + this.communityOrgHostname;
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
enumerable: false,
|
|
345
|
+
configurable: true
|
|
346
|
+
});
|
|
347
|
+
Object.defineProperty(ArcGISContext.prototype, "helperServices", {
|
|
348
|
+
// Platform API service urls are all in helperServices
|
|
349
|
+
// and not consistent to expose as urls
|
|
350
|
+
get: function () {
|
|
351
|
+
if (this._portalSelf) {
|
|
352
|
+
return this._portalSelf.helperServices;
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
enumerable: false,
|
|
356
|
+
configurable: true
|
|
357
|
+
});
|
|
358
|
+
Object.defineProperty(ArcGISContext.prototype, "currentUser", {
|
|
359
|
+
get: function () {
|
|
360
|
+
return this._currentUser;
|
|
361
|
+
},
|
|
362
|
+
enumerable: false,
|
|
363
|
+
configurable: true
|
|
364
|
+
});
|
|
365
|
+
Object.defineProperty(ArcGISContext.prototype, "portal", {
|
|
366
|
+
get: function () {
|
|
367
|
+
return this._portalSelf;
|
|
368
|
+
},
|
|
369
|
+
enumerable: false,
|
|
370
|
+
configurable: true
|
|
371
|
+
});
|
|
372
|
+
return ArcGISContext;
|
|
373
|
+
}());
|
|
374
|
+
export { ArcGISContext };
|
|
375
|
+
/**
|
|
376
|
+
* Cross-walk from a portalUrl to the corresponding Hub.
|
|
377
|
+
*
|
|
378
|
+
* If the passed url is not recognized, then this will return `undefined`
|
|
379
|
+
* @param portalUrl
|
|
380
|
+
* @returns
|
|
381
|
+
*/
|
|
382
|
+
function getHubApiFromPortalUrl(portalUrl) {
|
|
383
|
+
var result;
|
|
384
|
+
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
385
|
+
result = "https://hubqa.arcgis.com";
|
|
386
|
+
}
|
|
387
|
+
else if (portalUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
388
|
+
result = "https://hubdev.arcgis.com";
|
|
389
|
+
}
|
|
390
|
+
else if (portalUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
391
|
+
result = "https://hub.arcgis.com";
|
|
392
|
+
}
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=ArcGISContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArcGISContext.js","sourceRoot":"","sources":["../../src/ArcGISContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAW,MAAM,0BAA0B,CAAC;AAM5D,OAAO,EAAE,OAAO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kD,CACnD,CAAC;aACH;QACH,CAAC;;;OAAA;IAED,sBAAW,+CAAoB;aAA/B;YACE,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,OAAO,OAAO,CACZ,IAAI,CAAC,WAAW,EAChB,2DAA2D,CAC5D,CAAC;aACH;QACH,CAAC;;;OAAA;IAED,sBAAW,0CAAe;aAA1B;YACE,IAAI,IAAI,CAAC,oBAAoB,EAAE;gBAC7B,OAAO,aAAW,IAAI,CAAC,oBAAsB,CAAC;aAC/C;QACH,CAAC;;;OAAA;IAID,sBAAW,yCAAc;QAFzB,sDAAsD;QACtD,uCAAuC;aACvC;YACE,IAAI,IAAI,CAAC,WAAW,EAAE;gBACpB,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC;aACxC;QACH,CAAC;;;OAAA;IAED,sBAAW,sCAAW;aAAtB;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAED,sBAAW,iCAAM;aAAjB;YACE,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;;;OAAA;IACH,oBAAC;AAAD,CAAC,AAjSD,IAiSC;;AAED;;;;;;GAMG;AACH,SAAS,sBAAsB,CAAC,SAAiB;IAC/C,IAAI,MAAM,CAAC;IAEX,IAAI,SAAS,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QACnD,MAAM,GAAG,0BAA0B,CAAC;KACrC;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE;QAC/D,MAAM,GAAG,2BAA2B,CAAC;KACtC;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;QACtD,MAAM,GAAG,wBAAwB,CAAC;KACnC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./utils";
|
|
|
20
20
|
export * from "./i18n";
|
|
21
21
|
export * from "./request";
|
|
22
22
|
export * from "./surveys";
|
|
23
|
+
export * from "./ArcGISContext";
|
|
23
24
|
import OperationStack from "./OperationStack";
|
|
24
25
|
import OperationError from "./OperationError";
|
|
25
26
|
// Re-exports
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAEhC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAE9C,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC"}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { UserSession } from "@esri/arcgis-rest-auth";
|
|
2
|
+
/**
|
|
3
|
+
* Remove any serialized sessions associated with the passed clientId
|
|
4
|
+
* from a browser's local storage
|
|
5
|
+
* @param clientId oAuth Client Id
|
|
6
|
+
* @param win optional window (used for testing)
|
|
7
|
+
*/
|
|
8
|
+
export function clearSession(clientId,
|
|
9
|
+
/* istanbul ignore next */
|
|
10
|
+
win) {
|
|
11
|
+
if (win === void 0) { win = window; }
|
|
12
|
+
if (win.localStorage) {
|
|
13
|
+
win.localStorage.removeItem("__CONTEXT_" + clientId);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Re-hydrate a UserSession from a browser's local storage.
|
|
18
|
+
* If not found,
|
|
19
|
+
* @param clientId oAuth Client Id
|
|
20
|
+
* @param win optional window (used for testing)
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export function getSession(clientId,
|
|
24
|
+
/* istanbul ignore next */
|
|
25
|
+
win) {
|
|
26
|
+
if (win === void 0) { win = window; }
|
|
27
|
+
var result = null;
|
|
28
|
+
if (win.localStorage) {
|
|
29
|
+
var serializedSession = win.localStorage.getItem("__CONTEXT_" + clientId);
|
|
30
|
+
if (serializedSession) {
|
|
31
|
+
result = UserSession.deserialize(serializedSession);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Serialize a UserSession into a browser's local storage
|
|
38
|
+
* @param clientId oAuth Client Id
|
|
39
|
+
* @param session UserSession
|
|
40
|
+
* @param win optional window (used for testing)
|
|
41
|
+
*/
|
|
42
|
+
export function saveSession(clientId, session,
|
|
43
|
+
/* istanbul ignore next */
|
|
44
|
+
win) {
|
|
45
|
+
if (win === void 0) { win = window; }
|
|
46
|
+
if (win.localStorage) {
|
|
47
|
+
win.localStorage.setItem("__CONTEXT_" + clientId, session.serialize());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=sessionLocalStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionLocalStorage.js","sourceRoot":"","sources":["../../../src/utils/sessionLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,QAAgB;AAChB,0BAA0B;AAC1B,GAAiB;IAAjB,oBAAA,EAAA,YAAiB;IAEjB,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,eAAa,QAAU,CAAC,CAAC;KACtD;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,QAAgB;AAChB,0BAA0B;AAC1B,GAAiB;IAAjB,oBAAA,EAAA,YAAiB;IAEjB,IAAI,MAAM,GAAuB,IAAI,CAAC;IACtC,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,IAAM,iBAAiB,GAAG,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,eAAa,QAAU,CAAC,CAAC;QAC5E,IAAI,iBAAiB,EAAE;YACrB,MAAM,GAAG,WAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;SACrD;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,OAAoB;AACpB,0BAA0B;AAC1B,GAAiB;IAAjB,oBAAA,EAAA,YAAiB;IAEjB,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,eAAa,QAAU,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;KACxE;AACH,CAAC"}
|