@esri/arcgis-rest-developer-credentials 2.0.0 → 2.1.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/bundled/developer-credentials.esm.js +94 -22
- package/dist/bundled/developer-credentials.esm.js.map +1 -1
- package/dist/bundled/developer-credentials.esm.min.js +2 -2
- package/dist/bundled/developer-credentials.esm.min.js.map +1 -1
- package/dist/bundled/developer-credentials.umd.js +95 -21
- package/dist/bundled/developer-credentials.umd.js.map +1 -1
- package/dist/bundled/developer-credentials.umd.min.js +2 -2
- package/dist/bundled/developer-credentials.umd.min.js.map +1 -1
- package/dist/cjs/createApiKey.js +8 -2
- package/dist/cjs/createApiKey.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/invalidateApiKey.js +46 -0
- package/dist/cjs/invalidateApiKey.js.map +1 -0
- package/dist/cjs/shared/generateApiKeyToken.js +1 -1
- package/dist/cjs/shared/generateApiKeyToken.js.map +1 -1
- package/dist/cjs/shared/helpers.js +24 -3
- package/dist/cjs/shared/helpers.js.map +1 -1
- package/dist/cjs/shared/registerApp.js +1 -1
- package/dist/cjs/shared/registerApp.js.map +1 -1
- package/dist/cjs/shared/types/apiKeyType.js.map +1 -1
- package/dist/cjs/updateApiKey.js +22 -14
- package/dist/cjs/updateApiKey.js.map +1 -1
- package/dist/esm/createApiKey.d.ts +8 -2
- package/dist/esm/createApiKey.js +8 -2
- package/dist/esm/createApiKey.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/invalidateApiKey.d.ts +18 -0
- package/dist/esm/invalidateApiKey.js +42 -0
- package/dist/esm/invalidateApiKey.js.map +1 -0
- package/dist/esm/shared/generateApiKeyToken.js +1 -1
- package/dist/esm/shared/generateApiKeyToken.js.map +1 -1
- package/dist/esm/shared/helpers.d.ts +7 -2
- package/dist/esm/shared/helpers.js +22 -2
- package/dist/esm/shared/helpers.js.map +1 -1
- package/dist/esm/shared/registerApp.d.ts +1 -1
- package/dist/esm/shared/registerApp.js +1 -1
- package/dist/esm/shared/registerApp.js.map +1 -1
- package/dist/esm/shared/types/apiKeyType.d.ts +17 -0
- package/dist/esm/shared/types/apiKeyType.js.map +1 -1
- package/dist/esm/updateApiKey.d.ts +8 -2
- package/dist/esm/updateApiKey.js +22 -14
- package/dist/esm/updateApiKey.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
2
|
* @esri/arcgis-rest-developer-credentials - v2.0.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2025 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Wed Feb 26 2025 22:10:42 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
import { getPortalUrl, createItem, updateItem, getItem } from '@esri/arcgis-rest-portal';
|
|
7
7
|
import { request, appendCustomParams } from '@esri/arcgis-rest-request';
|
|
@@ -56,8 +56,8 @@ async function generateApiKeyToken(options) {
|
|
|
56
56
|
regenerateApiToken: true,
|
|
57
57
|
grant_type: "client_credentials"
|
|
58
58
|
};
|
|
59
|
+
// authentication is not being passed to the request because client_secret acts as the auth
|
|
59
60
|
return request(url, {
|
|
60
|
-
authentication: options.authentication,
|
|
61
61
|
params
|
|
62
62
|
});
|
|
63
63
|
}
|
|
@@ -157,10 +157,30 @@ function filterKeys(object, includedKeys) {
|
|
|
157
157
|
}, {});
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
|
-
* Used to determine if a generated key is in slot 1 or slot 2 key.
|
|
160
|
+
* Used to determine if a generated key is in slot 1 or slot 2 key. The full API key should be passed. `undefined` will be returned if the proper slot could not be identified.
|
|
161
161
|
*/
|
|
162
162
|
function slotForKey(key) {
|
|
163
|
-
|
|
163
|
+
const slot = parseInt(key.substring(key.length - 10, key.length - 9));
|
|
164
|
+
if (slot === 1 || slot === 2) {
|
|
165
|
+
return slot;
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @internal
|
|
171
|
+
* Used to determine which slot to invalidate a key in given a number or a full or patial key.
|
|
172
|
+
*/
|
|
173
|
+
function slotForInvalidationKey(param) {
|
|
174
|
+
if (param === 1 || param === 2) {
|
|
175
|
+
return param;
|
|
176
|
+
}
|
|
177
|
+
if (typeof param !== "string") {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
const fullKeySlot = slotForKey(param);
|
|
181
|
+
if (fullKeySlot) {
|
|
182
|
+
return fullKeySlot;
|
|
183
|
+
}
|
|
164
184
|
}
|
|
165
185
|
/**
|
|
166
186
|
* @internal
|
|
@@ -241,7 +261,7 @@ function buildExpirationDateParams(requestOptions, fillDefaults) {
|
|
|
241
261
|
* appType: "multiple",
|
|
242
262
|
* redirect_uris: ["http://localhost:3000/"],
|
|
243
263
|
* httpReferrers: ["http://localhost:3000/"],
|
|
244
|
-
* privileges: [
|
|
264
|
+
* privileges: ["premium:user:geocode:temporary", Privileges.FeatureReport],
|
|
245
265
|
* authentication: authSession
|
|
246
266
|
* }).then((registeredApp: IApp) => {
|
|
247
267
|
* // => {client_id: "xyz_id", client_secret: "xyz_secret", ...}
|
|
@@ -285,14 +305,20 @@ async function registerApp(requestOptions) {
|
|
|
285
305
|
* password: "xyz_pw"
|
|
286
306
|
* });
|
|
287
307
|
*
|
|
308
|
+
* const threeDaysFromToday = new Date();
|
|
309
|
+
* threeDaysFromToday.setDate(threeDaysFromToday.getDate() + 3);
|
|
310
|
+
* threeDaysFromToday.setHours(23, 59, 59, 999);
|
|
311
|
+
*
|
|
288
312
|
* createApiKey({
|
|
289
313
|
* title: "xyz_title",
|
|
290
314
|
* description: "xyz_desc",
|
|
291
315
|
* tags: ["xyz_tag1", "xyz_tag2"],
|
|
292
316
|
* privileges: ["premium:user:networkanalysis:routing"],
|
|
293
|
-
* authentication: authSession
|
|
317
|
+
* authentication: authSession,
|
|
318
|
+
* generateToken1: true, // optional,generate a new token
|
|
319
|
+
* apiToken1ExpirationDate: threeDaysFromToday // optional, update expiration date
|
|
294
320
|
* }).then((registeredAPIKey: IApiKeyResponse) => {
|
|
295
|
-
* // => {
|
|
321
|
+
* // => {accessToken1: "xyz_key", item: {tags: ["xyz_tag1", "xyz_tag2"], ...}, ...}
|
|
296
322
|
* }).catch(e => {
|
|
297
323
|
* // => an exception object
|
|
298
324
|
* });
|
|
@@ -372,13 +398,19 @@ async function createApiKey(requestOptions) {
|
|
|
372
398
|
* password: "xyz_pw"
|
|
373
399
|
* });
|
|
374
400
|
*
|
|
401
|
+
* const threeDaysFromToday = new Date();
|
|
402
|
+
* threeDaysFromToday.setDate(threeDaysFromToday.getDate() + 3);
|
|
403
|
+
* threeDaysFromToday.setHours(23, 59, 59, 999);
|
|
404
|
+
*
|
|
375
405
|
* updateApiKey({
|
|
376
406
|
* itemId: "xyz_itemId",
|
|
377
|
-
* privileges: [
|
|
407
|
+
* privileges: ["premium:user:geocode:temporary"],
|
|
378
408
|
* httpReferrers: [], // httpReferrers will be set to be empty
|
|
379
409
|
* authentication: authSession
|
|
410
|
+
* generateToken1: true, // optional,generate a new token
|
|
411
|
+
* apiToken1ExpirationDate: threeDaysFromToday // optional, update expiration date
|
|
380
412
|
* }).then((updatedAPIKey: IApiKeyResponse) => {
|
|
381
|
-
* // => {
|
|
413
|
+
* // => {accessToken1: "xyz_key", item: {tags: ["xyz_tag1", "xyz_tag2"], ...}, ...}
|
|
382
414
|
* }).catch(e => {
|
|
383
415
|
* // => an exception object
|
|
384
416
|
* });
|
|
@@ -401,18 +433,20 @@ async function updateApiKey(requestOptions) {
|
|
|
401
433
|
/**
|
|
402
434
|
* step 2: update privileges and httpReferrers if provided. Build the object up to avoid overwriting any existing properties.
|
|
403
435
|
*/
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
436
|
+
if (requestOptions.privileges || requestOptions.httpReferrers) {
|
|
437
|
+
const getAppOption = Object.assign(Object.assign({}, baseRequestOptions), { authentication: requestOptions.authentication, itemId: requestOptions.itemId });
|
|
438
|
+
const appResponse = await getRegisteredAppInfo(getAppOption);
|
|
439
|
+
const clientId = appResponse.client_id;
|
|
440
|
+
const options = appendCustomParams(Object.assign(Object.assign({}, appResponse), requestOptions), // object with the custom params to look in
|
|
441
|
+
["privileges", "httpReferrers"] // keys you want copied to the params object
|
|
442
|
+
);
|
|
443
|
+
options.params.f = "json";
|
|
444
|
+
// encode special params value (e.g. array type...) in advance in order to make encodeQueryString() works correctly
|
|
445
|
+
stringifyArrays(options);
|
|
446
|
+
const url = getPortalUrl(options) + `/oauth2/apps/${clientId}/update`;
|
|
447
|
+
// Raw response from `/oauth2/apps/${clientId}/update`, apiKey not included because key is same.
|
|
448
|
+
await request(url, Object.assign(Object.assign({}, options), { authentication: requestOptions.authentication }));
|
|
449
|
+
}
|
|
416
450
|
/**
|
|
417
451
|
* step 3: get the updated item info to return to the user.
|
|
418
452
|
*/
|
|
@@ -461,6 +495,44 @@ async function getApiKey(requestOptions) {
|
|
|
461
495
|
return Object.assign(Object.assign({}, appToApiKeyProperties(appResponse)), { item: itemInfo });
|
|
462
496
|
}
|
|
463
497
|
|
|
498
|
+
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
|
|
499
|
+
* Apache-2.0 */
|
|
500
|
+
/**
|
|
501
|
+
* Used to invalidate an API key.
|
|
502
|
+
*
|
|
503
|
+
* ```js
|
|
504
|
+
* import { invalidateApiKey } from "@esri/arcgis-rest-developer-credentials";
|
|
505
|
+
*
|
|
506
|
+
* invalidateApiKey({
|
|
507
|
+
* itemId: ITEM_ID,
|
|
508
|
+
* authentication,
|
|
509
|
+
* apiKey: 1, // invalidate the key in slot 1
|
|
510
|
+
* }).then((response) => {
|
|
511
|
+
* // => {success: true}
|
|
512
|
+
* }).catch(e => {
|
|
513
|
+
* // => an exception object
|
|
514
|
+
* });
|
|
515
|
+
*/
|
|
516
|
+
async function invalidateApiKey(requestOptions) {
|
|
517
|
+
const portal = getPortalUrl(requestOptions);
|
|
518
|
+
const url = `${portal}/oauth2/revokeToken`;
|
|
519
|
+
const appInfo = await getRegisteredAppInfo({
|
|
520
|
+
itemId: requestOptions.itemId,
|
|
521
|
+
authentication: requestOptions.authentication
|
|
522
|
+
});
|
|
523
|
+
const params = {
|
|
524
|
+
client_id: appInfo.client_id,
|
|
525
|
+
client_secret: appInfo.client_secret,
|
|
526
|
+
apiToken: slotForInvalidationKey(requestOptions.apiKey),
|
|
527
|
+
regenerateApiToken: true,
|
|
528
|
+
grant_type: "client_credentials"
|
|
529
|
+
};
|
|
530
|
+
// authentication is not being passed to the request because client_secret acts as the auth
|
|
531
|
+
return request(url, {
|
|
532
|
+
params
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
464
536
|
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
|
|
465
537
|
* Apache-2.0 */
|
|
466
538
|
/**
|
|
@@ -650,5 +722,5 @@ async function unregisterApp(requestOptions) {
|
|
|
650
722
|
return unregisterAppResponse;
|
|
651
723
|
}
|
|
652
724
|
|
|
653
|
-
export { appToApiKeyProperties, appToOAuthAppProperties, buildExpirationDateParams, createApiKey, createOAuthApp, extractBaseRequestOptions, filterKeys, generateApiKeyTokens, generateOptionsToSlots, getApiKey, getOAuthApp, getRegisteredAppInfo, registerApp, registeredAppResponseToApp, slotForKey, stringifyArrays, unregisterApp, updateApiKey, updateOAuthApp };
|
|
725
|
+
export { appToApiKeyProperties, appToOAuthAppProperties, buildExpirationDateParams, createApiKey, createOAuthApp, extractBaseRequestOptions, filterKeys, generateApiKeyTokens, generateOptionsToSlots, getApiKey, getOAuthApp, getRegisteredAppInfo, invalidateApiKey, registerApp, registeredAppResponseToApp, slotForInvalidationKey, slotForKey, stringifyArrays, unregisterApp, updateApiKey, updateOAuthApp };
|
|
654
726
|
//# sourceMappingURL=developer-credentials.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"developer-credentials.esm.js","sources":["../../src/shared/getRegisteredAppInfo.ts","../../src/shared/generateApiKeyToken.ts","../../src/shared/helpers.ts","../../src/shared/registerApp.ts","../../src/createApiKey.ts","../../src/updateApiKey.ts","../../src/getApiKey.ts","../../src/getOAuthApp.ts","../../src/updateOAuthApp.ts","../../src/createOAuthApp.ts","../../src/shared/unregisterApp.ts"],"sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\n\nimport {\n IRegisteredAppResponse,\n IGetAppInfoOptions,\n IApp\n} from \"./types/appType.js\";\nimport { registeredAppResponseToApp } from \"./helpers.js\";\n\n/**\n * Used to retrieve registered app info. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/registered-app-info.htm) for more information.\n *\n * ```js\n * import { getRegisteredAppInfo, IApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * getRegisteredAppInfo({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((registeredApp: IApp) => {\n * // => {client_id: \"xyz_id\", client_secret: \"xyz_secret\", ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode getRegisteredAppInfo | getRegisteredAppInfo()}, including an itemId of which app to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApp} object representing successfully retrieved app.\n */\nexport async function getRegisteredAppInfo(\n requestOptions: IGetAppInfoOptions\n): Promise<IApp> {\n const userName = await requestOptions.authentication.getUsername();\n const url =\n getPortalUrl(requestOptions) +\n `/content/users/${userName}/items/${requestOptions.itemId}/registeredAppInfo`;\n requestOptions.httpMethod = \"POST\";\n\n const registeredAppResponse: IRegisteredAppResponse = await request(url, {\n ...requestOptions,\n params: { f: \"json\" }\n });\n\n return registeredAppResponseToApp(registeredAppResponse);\n}\n","import {\n request,\n IRequestOptions,\n IAuthenticationManager\n} from \"@esri/arcgis-rest-request\";\nimport { getRegisteredAppInfo } from \"./getRegisteredAppInfo.js\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\n\nexport interface IGenerateApiKeyTokenOptions extends IRequestOptions {\n itemId: string;\n apiKey: 1 | 2;\n portal?: string;\n authentication: IAuthenticationManager;\n}\n\nexport async function generateApiKeyToken(\n options: IGenerateApiKeyTokenOptions\n): Promise<{ access_token: string; expires_in: number }> {\n const portal = getPortalUrl(options);\n const url = `${portal}/oauth2/token`;\n\n const appInfo = await getRegisteredAppInfo({\n itemId: options.itemId,\n authentication: options.authentication\n });\n\n const params = {\n client_id: appInfo.client_id,\n client_secret: appInfo.client_secret,\n apiToken: options.apiKey,\n regenerateApiToken: true,\n grant_type: \"client_credentials\"\n };\n\n return request(url, {\n authentication: options.authentication,\n params\n });\n}\n","import {\n IRequestOptions,\n IAuthenticationManager\n} from \"@esri/arcgis-rest-request\";\nimport { IRegisteredAppResponse, IApp } from \"./types/appType.js\";\nimport { IApiKeyInfo } from \"./types/apiKeyType.js\";\nimport { IOAuthAppInfo } from \"./types/oAuthType.js\";\nimport { generateApiKeyToken } from \"./generateApiKeyToken.js\";\n\n/**\n * @internal\n * Encode special params value (e.g. array type...) in advance in order to make {@linkcode encodeParam} works correctly. Usage is case by case.\n */\nexport const stringifyArrays = (requestOptions: IRequestOptions) => {\n Object.entries(requestOptions.params).forEach((entry) => {\n const [key, value] = entry;\n if (value.constructor.name === \"Array\") {\n requestOptions.params[key] = JSON.stringify(value);\n }\n });\n};\n\n/**\n * @internal\n * Used to convert {@linkcode IRegisteredAppResponse} to {@linkcode IApp}.\n */\nexport function registeredAppResponseToApp(\n response: IRegisteredAppResponse\n): IApp {\n const omittedKeys = [\n \"apnsProdCert\",\n \"apnsSandboxCert\",\n \"gcmApiKey\",\n \"isBeta\",\n \"customAppLoginShowTriage\"\n ];\n const dateKeys = [\"modified\", \"registered\"];\n\n return Object.keys(response)\n .filter((key) => !omittedKeys.includes(key))\n .reduce((obj: any, key) => {\n if (dateKeys.includes(key)) {\n obj[key] = new Date((response as any)[key]);\n } else {\n obj[key] = (response as any)[key];\n }\n return obj;\n }, {});\n}\n\n/**\n * @internal\n * Used to convert {@linkcode IApp} to {@linkcode IApiKeyInfo} only if `appType` is \"apikey\".\n */\nexport function appToApiKeyProperties(response: IApp): IApiKeyInfo {\n delete response.client_secret;\n delete response.redirect_uris;\n delete response.appType;\n delete (response as any).customAppLoginShowTriage;\n delete response.apiKey;\n\n return response as IApiKeyInfo;\n}\n\n/**\n * @internal\n * Used to convert {@linkcode IApp} to {@linkcode IOAuthAppInfo}.\n */\nexport function appToOAuthAppProperties(response: IApp): IOAuthAppInfo {\n delete response.appType;\n delete response.httpReferrers;\n delete response.privileges;\n delete response.apiKey;\n delete (response as any).customAppLoginShowTriage;\n delete response.isPersonalAPIToken;\n delete response.apiToken1Active;\n delete response.apiToken2Active;\n\n return response as IOAuthAppInfo;\n}\n\n/**\n * @internal\n * Used to extract base request options from a hybrid option and exclude `params` and `authentication`.\n */\nexport function extractBaseRequestOptions<T extends IRequestOptions>(\n options: T\n): Partial<IRequestOptions> {\n const requestOptionsProperties: Array<keyof T> = [\n \"credentials\",\n \"headers\",\n \"hideToken\",\n \"httpMethod\",\n \"maxUrlLength\",\n \"portal\",\n \"rawResponse\",\n \"signal\",\n \"suppressWarnings\"\n ];\n\n return filterKeys(options, requestOptionsProperties);\n}\n\n/**\n * @internal\n * Used to create a new object including only specified keys from another object.\n */\nexport function filterKeys<T extends object>(\n object: T,\n includedKeys: Array<keyof T>\n): any {\n return includedKeys.reduce(\n (obj: { [key: string | number | symbol]: any }, ele) => {\n if (ele in object) {\n obj[ele] = object[ele];\n }\n return obj;\n },\n {}\n );\n}\n\n/**\n * Used to determine if a generated key is in slot 1 or slot 2 key.\n */\nexport function slotForKey(key: string) {\n return parseInt(key.substring(key.length - 10, key.length - 9));\n}\n\ninterface IGenerateApiKeyTokenOptions extends IRequestOptions {\n authentication: IAuthenticationManager;\n}\n\n/**\n * @internal\n * Used to generate tokens in slot 1 and/or 2 of an API key.\n */\nexport function generateApiKeyTokens(\n itemId: string,\n slots: Array<1 | 2>,\n requestOptions: IGenerateApiKeyTokenOptions\n) {\n return Promise.all(\n slots.map((slot) => {\n return generateApiKeyToken({\n itemId,\n apiKey: slot,\n ...requestOptions\n });\n })\n ).then((responses) => {\n return responses\n .map((responses) => responses.access_token)\n .reduce((obj, token, index) => {\n obj[`accessToken${slotForKey(token)}`] = token;\n return obj;\n }, {} as { [key: string]: string });\n });\n}\n\n/**\n * @internal\n * Convert boolean flags to an array of slots for {@linkcode generateApiKeyTokens}.\n */\nexport function generateOptionsToSlots(\n generateToken1: boolean,\n generateToken2: boolean\n): Array<1 | 2> {\n const slots: Array<1 | 2> = [];\n if (generateToken1) {\n slots.push(1);\n }\n if (generateToken2) {\n slots.push(2);\n }\n return slots;\n}\n\ntype expirationDateParams =\n | {\n apiToken1ExpirationDate: Date | -1;\n apiToken2ExpirationDate: Date | -1;\n }\n | {\n apiToken1ExpirationDate: Date | -1;\n }\n | {\n apiToken2ExpirationDate: Date | -1;\n }\n | {};\n\n/**\n * @internal\n * Build params for updating expiration dates\n */\nexport function buildExpirationDateParams(\n requestOptions: {\n apiToken1ExpirationDate?: Date;\n apiToken2ExpirationDate?: Date;\n },\n fillDefaults?: boolean\n): expirationDateParams {\n const updateparams: any = {};\n if (requestOptions.apiToken1ExpirationDate) {\n updateparams.apiToken1ExpirationDate =\n requestOptions.apiToken1ExpirationDate;\n }\n\n if (requestOptions.apiToken2ExpirationDate) {\n updateparams.apiToken2ExpirationDate =\n requestOptions.apiToken2ExpirationDate;\n }\n\n if (fillDefaults && !updateparams.apiToken1ExpirationDate) {\n updateparams.apiToken1ExpirationDate = -1;\n }\n\n if (fillDefaults && !updateparams.apiToken2ExpirationDate) {\n updateparams.apiToken2ExpirationDate = -1;\n }\n return updateparams;\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\nimport {\n IApp,\n IRegisterAppOptions,\n IRegisteredAppResponse\n} from \"./types/appType.js\";\nimport { stringifyArrays, registeredAppResponseToApp } from \"./helpers.js\";\n\n/**\n * Used to register an app. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/register-app.htm) for more information.\n *\n * Accepted app types:\n * - apikey\n * - multiple\n * - browser\n * - server\n * - native\n *\n * ```js\n * import { registerApp, IApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * registerApp({\n * itemId: \"xyz_itemId\",\n * appType: \"multiple\",\n * redirect_uris: [\"http://localhost:3000/\"],\n * httpReferrers: [\"http://localhost:3000/\"],\n * privileges: [Privileges.Geocode, Privileges.FeatureReport],\n * authentication: authSession\n * }).then((registeredApp: IApp) => {\n * // => {client_id: \"xyz_id\", client_secret: \"xyz_secret\", ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode registerApp | registerApp()}, including necessary params to register an app and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApp} object representing the newly registered app.\n */\nexport async function registerApp(\n requestOptions: IRegisterAppOptions\n): Promise<IApp> {\n // build params\n const options = appendCustomParams(requestOptions, [\n \"itemId\",\n \"appType\",\n \"redirect_uris\",\n \"httpReferrers\",\n \"privileges\"\n ]);\n // encode special params value (e.g. array type...) in advance in order to make encodeQueryString() works correctly\n stringifyArrays(options);\n\n const url = getPortalUrl(options) + \"/oauth2/registerApp\";\n options.httpMethod = \"POST\";\n options.params.f = \"json\";\n\n const registeredAppResponse: IRegisteredAppResponse = await request(\n url,\n options\n );\n\n return registeredAppResponseToApp(registeredAppResponse);\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n ICreateItemOptions,\n createItem,\n getItem,\n IItemAdd,\n updateItem\n} from \"@esri/arcgis-rest-portal\";\nimport {\n IApiKeyResponse,\n ICreateApiKeyOptions\n} from \"./shared/types/apiKeyType.js\";\n\nimport { registerApp } from \"./shared/registerApp.js\";\nimport { IRegisterAppOptions } from \"./shared/types/appType.js\";\nimport {\n appToApiKeyProperties,\n filterKeys,\n extractBaseRequestOptions,\n generateApiKeyTokens,\n generateOptionsToSlots,\n buildExpirationDateParams\n} from \"./shared/helpers.js\";\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\n\n/**\n * Used to register an API key. See the [security and authentication](https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/) for more information about API key.\n *\n * ```js\n * import { createApiKey, IApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * createApiKey({\n * title: \"xyz_title\",\n * description: \"xyz_desc\",\n * tags: [\"xyz_tag1\", \"xyz_tag2\"],\n * privileges: [\"premium:user:networkanalysis:routing\"],\n * authentication: authSession\n * }).then((registeredAPIKey: IApiKeyResponse) => {\n * // => {apiKey: \"xyz_key\", item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode createApiKey | createApiKey()}, including necessary params to register an API key and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing the newly registered API key.\n */\nexport async function createApiKey(\n requestOptions: ICreateApiKeyOptions\n): Promise<IApiKeyResponse> {\n requestOptions.httpMethod = \"POST\";\n\n // filter param buckets:\n const baseRequestOptions = extractBaseRequestOptions(requestOptions); // snapshot of basic IRequestOptions before customized params being built into it\n\n const itemAddProperties: Array<keyof IItemAdd> = [\n \"categories\",\n \"culture\",\n \"description\",\n \"documentation\",\n \"extent\",\n \"owner\",\n \"properties\",\n \"snippet\",\n \"spatialReference\",\n \"tags\",\n \"title\",\n \"type\",\n \"typeKeywords\",\n \"url\"\n ];\n\n /**\n * step 1: create item\n */\n const createItemOption: ICreateItemOptions = {\n item: {\n ...filterKeys(requestOptions as any, itemAddProperties),\n type: \"Application\"\n },\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: {\n f: \"json\"\n }\n };\n\n const createItemResponse = await createItem(createItemOption);\n\n /**\n * getRegisteredAppInfoRoute\n */\n const registerAppOptions: IRegisterAppOptions = {\n itemId: createItemResponse.id,\n appType: \"multiple\",\n redirect_uris: [\"urn:ietf:wg:oauth:2.0:oob\"],\n httpReferrers: requestOptions.httpReferrers || [],\n privileges: requestOptions.privileges,\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n };\n\n const registeredAppResponse = await registerApp(registerAppOptions);\n\n /**\n * step 3: update item with desired expiration dates\n * you cannot set the expiration date propierties until you\n * regiester the app so this has to be a seperate step\n */\n await updateItem({\n ...baseRequestOptions,\n item: {\n id: createItemResponse.id,\n ...buildExpirationDateParams(requestOptions, true)\n },\n authentication: requestOptions.authentication\n });\n\n /*\n * step 4: get item info\n */\n const itemInfo = await getItem(registeredAppResponse.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n /**\n * step 5: generate tokens if requested\n */\n const generatedTokens = await generateApiKeyTokens(\n itemInfo.id,\n generateOptionsToSlots(\n requestOptions.generateToken1,\n requestOptions.generateToken2\n ),\n {\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n }\n );\n\n /**\n * step 6: get registered app info to get updated active key status\n */\n const updatedRegisteredAppResponse = await getRegisteredAppInfo({\n ...baseRequestOptions,\n itemId: itemInfo.id,\n authentication: requestOptions.authentication\n });\n\n return {\n ...generatedTokens,\n ...appToApiKeyProperties(updatedRegisteredAppResponse),\n item: itemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n IApiKeyResponse,\n IUpdateApiKeyOptions\n} from \"./shared/types/apiKeyType.js\";\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\nimport {\n appToApiKeyProperties,\n extractBaseRequestOptions,\n stringifyArrays,\n registeredAppResponseToApp,\n generateApiKeyTokens,\n generateOptionsToSlots,\n buildExpirationDateParams\n} from \"./shared/helpers.js\";\nimport { getItem, getPortalUrl, updateItem } from \"@esri/arcgis-rest-portal\";\nimport { appendCustomParams, request } from \"@esri/arcgis-rest-request\";\nimport {\n IApp,\n IGetAppInfoOptions,\n IRegisteredAppResponse\n} from \"./shared/types/appType.js\";\n\n/**\n * Used to update an API key.\n *\n * Notes about `privileges` and `httpReferrers` options:\n * 1. Provided option will override corresponding old option.\n * 2. Unprovided option will not trigger corresponding option updates.\n *\n * ```js\n * import { updateApiKey, IApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * updateApiKey({\n * itemId: \"xyz_itemId\",\n * privileges: [Privileges.Geocode],\n * httpReferrers: [], // httpReferrers will be set to be empty\n * authentication: authSession\n * }).then((updatedAPIKey: IApiKeyResponse) => {\n * // => {apiKey: \"xyz_key\", item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode updateApiKey | updateApiKey()}, including `itemId` of which API key to be operated on, optional new `privileges`, optional new `httpReferrers` and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing updated API key.\n */\nexport async function updateApiKey(\n requestOptions: IUpdateApiKeyOptions\n): Promise<IApiKeyResponse> {\n requestOptions.httpMethod = \"POST\";\n const baseRequestOptions = extractBaseRequestOptions(requestOptions); // get base requestOptions snapshot\n\n /**\n * step 1: update expiration dates if provided. Build the object up to avoid overwriting any existing properties.\n */\n if (\n requestOptions.apiToken1ExpirationDate ||\n requestOptions.apiToken2ExpirationDate\n ) {\n const updateParams = buildExpirationDateParams(requestOptions);\n await updateItem({\n ...baseRequestOptions,\n item: {\n id: requestOptions.itemId,\n ...updateParams\n },\n authentication: requestOptions.authentication\n });\n }\n\n /**\n * step 2: update privileges and httpReferrers if provided. Build the object up to avoid overwriting any existing properties.\n */\n const getAppOption: IGetAppInfoOptions = {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n itemId: requestOptions.itemId\n };\n const appResponse = await getRegisteredAppInfo(getAppOption);\n const clientId = appResponse.client_id;\n const options = appendCustomParams(\n { ...appResponse, ...requestOptions }, // object with the custom params to look in\n [\"privileges\", \"httpReferrers\"] // keys you want copied to the params object\n );\n options.params.f = \"json\";\n\n // encode special params value (e.g. array type...) in advance in order to make encodeQueryString() works correctly\n stringifyArrays(options);\n\n const url = getPortalUrl(options) + `/oauth2/apps/${clientId}/update`;\n\n // Raw response from `/oauth2/apps/${clientId}/update`, apiKey not included because key is same.\n const updateResponse: IRegisteredAppResponse = await request(url, {\n ...options,\n authentication: requestOptions.authentication\n });\n\n /**\n * step 3: get the updated item info to return to the user.\n */\n const updatedItemInfo = await getItem(requestOptions.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n /**\n * step 4: generate tokens if requested\n */\n const generatedTokens = await generateApiKeyTokens(\n requestOptions.itemId,\n generateOptionsToSlots(\n requestOptions.generateToken1,\n requestOptions.generateToken2\n ),\n {\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n }\n );\n\n /**\n * step 5: get updated registered app info\n */\n const updatedRegisteredAppResponse = await getRegisteredAppInfo({\n ...baseRequestOptions,\n itemId: requestOptions.itemId,\n authentication: requestOptions.authentication\n });\n\n return {\n ...generatedTokens,\n ...appToApiKeyProperties(updatedRegisteredAppResponse),\n item: updatedItemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\nimport {\n IApiKeyResponse,\n IGetApiKeyOptions\n} from \"./shared/types/apiKeyType.js\";\nimport { getItem } from \"@esri/arcgis-rest-portal\";\nimport {\n appToApiKeyProperties,\n extractBaseRequestOptions\n} from \"./shared/helpers.js\";\n\n/**\n * Used to retrieve the API key with given `itemId`. See the [security and authentication](https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/) for more information about API key.\n *\n * ```js\n * import { getApiKey, IApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * getApiKey({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((retrievedAPIKey: IApiKeyResponse) => {\n * // => {apiKey: \"xyz_key\", item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode getApiKey | getApiKey()}, including `itemId` of which API key to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing successfully retrieved API key.\n */\nexport async function getApiKey(\n requestOptions: IGetApiKeyOptions\n): Promise<IApiKeyResponse> {\n const appResponse = await getRegisteredAppInfo(requestOptions);\n\n const itemInfo = await getItem(requestOptions.itemId, {\n ...extractBaseRequestOptions(requestOptions),\n authentication: requestOptions.authentication\n });\n\n return {\n ...appToApiKeyProperties(appResponse),\n item: itemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\nimport { getItem } from \"@esri/arcgis-rest-portal\";\nimport {\n appToOAuthAppProperties,\n extractBaseRequestOptions\n} from \"./shared/helpers.js\";\nimport { IGetOAuthAppOptions, IOAuthApp } from \"./shared/types/oAuthType.js\";\n\n/**\n * Used to retrieve the OAuth2.0 app with given `itemId`. See the [OAuth2.0](https://developers.arcgis.com/documentation/mapping-apis-and-services/security/oauth-2.0/) for more information.\n *\n * ```js\n * import { getOAuthApp, IOAuthApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * getOAuthApp({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((retrievedOAuthApp: IOAuthApp) => {\n * // => {redirect_uris: [\"http://localhost:3000/\"], item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode getOAuthApp | getOAuthApp()}, including `itemId` of which OAuth app to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IOAuthApp} object representing successfully retrieved OAuth app.\n */\nexport async function getOAuthApp(\n requestOptions: IGetOAuthAppOptions\n): Promise<IOAuthApp> {\n const appResponse = await getRegisteredAppInfo(requestOptions);\n\n const itemInfo = await getItem(requestOptions.itemId, {\n ...extractBaseRequestOptions(requestOptions),\n authentication: requestOptions.authentication\n });\n\n return {\n ...appToOAuthAppProperties(appResponse),\n item: itemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n extractBaseRequestOptions,\n stringifyArrays,\n registeredAppResponseToApp,\n appToOAuthAppProperties\n} from \"./shared/helpers.js\";\nimport { getItem, getPortalUrl } from \"@esri/arcgis-rest-portal\";\nimport { appendCustomParams, request } from \"@esri/arcgis-rest-request\";\nimport {\n IApp,\n IGetAppInfoOptions,\n IRegisteredAppResponse\n} from \"./shared/types/appType.js\";\nimport { IOAuthApp, IUpdateOAuthOptions } from \"./shared/types/oAuthType.js\";\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\n\n/**\n * Used to update an OAuth2.0 app.\n *\n * Notes about `redirect_uris` options:\n * 1. Provided option will override corresponding old option.\n * 2. Unprovided option will not trigger corresponding option updates.\n *\n * ```js\n * import { updateOAuthApp, IOAuthApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * updateOAuthApp({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((updatedOAuthApp: IOAuthApp) => {\n * // => This OAuth app will be not be updated because its redirect_uris is not provided.\n * // => {redirect_uris: [\"http://localhost:3000/\"], item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode updateOAuthApp | updateOAuthApp()}, including `itemId` of which OAuth app to be operated on, optional new `redirect_uris` and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IOAuthApp} object representing updated OAuth app.\n */\nexport async function updateOAuthApp(\n requestOptions: IUpdateOAuthOptions\n): Promise<IOAuthApp> {\n requestOptions.httpMethod = \"POST\";\n\n // get app\n const baseRequestOptions = extractBaseRequestOptions(requestOptions); // get base requestOptions snapshot\n const getAppOption: IGetAppInfoOptions = {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n itemId: requestOptions.itemId\n };\n\n const appResponse = await getRegisteredAppInfo(getAppOption);\n\n if (appResponse.appType === \"apikey\") {\n throw new Error(\"Item is not an OAuth 2.0 app.\");\n }\n\n const clientId = appResponse.client_id;\n const options = appendCustomParams({ ...appResponse, ...requestOptions }, [\n \"redirect_uris\"\n ]);\n options.params.f = \"json\";\n options.params.appType = \"multiple\";\n\n // encode special params value (e.g. array type...) in advance in order to make encodeQueryString() works correctly\n stringifyArrays(options);\n\n const url = getPortalUrl(options) + `/oauth2/apps/${clientId}/update`;\n\n // Raw response from `/oauth2/apps/${clientId}/update`.\n const updateResponse: IRegisteredAppResponse = await request(url, {\n ...options,\n authentication: requestOptions.authentication\n });\n\n const app: IApp = registeredAppResponseToApp(updateResponse);\n\n const itemInfo = await getItem(requestOptions.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n return {\n ...appToOAuthAppProperties(app),\n item: itemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n ICreateItemOptions,\n createItem,\n getItem,\n IItemAdd\n} from \"@esri/arcgis-rest-portal\";\n\nimport { registerApp } from \"./shared/registerApp.js\";\nimport { IRegisterAppOptions } from \"./shared/types/appType.js\";\nimport {\n filterKeys,\n extractBaseRequestOptions,\n appToOAuthAppProperties\n} from \"./shared/helpers.js\";\nimport { ICreateOAuthAppOption, IOAuthApp } from \"./shared/types/oAuthType.js\";\n\n/**\n * Used to register an OAuth2.0 app. See the [OAuth2.0](https://developers.arcgis.com/documentation/mapping-apis-and-services/security/oauth-2.0/) for more information.\n *\n * ```js\n * import { createOAuthApp, IOAuthApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * createOAuthApp({\n * title: \"xyz_title\",\n * description: \"xyz_desc\",\n * tags: [\"xyz_tag1\", \"xyz_tag2\"],\n * redirect_uris: [\"http://localhost:3000/\"],\n * authentication: authSession\n * }).then((registeredOAuthApp: IOAuthApp) => {\n * // => {redirect_uris: [\"http://localhost:3000/\"], item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode createOAuthApp | createOAuthApp()}, including necessary params to register an OAuth app and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IOAuthApp} object representing the newly registered OAuth app.\n */\nexport async function createOAuthApp(\n requestOptions: ICreateOAuthAppOption\n): Promise<IOAuthApp> {\n requestOptions.httpMethod = \"POST\";\n\n // filter param buckets:\n\n const baseRequestOptions = extractBaseRequestOptions(requestOptions);\n\n const itemAddProperties: Array<keyof IItemAdd> = [\n \"categories\",\n \"culture\",\n \"description\",\n \"documentation\",\n \"extent\",\n \"owner\",\n \"properties\",\n \"snippet\",\n \"spatialReference\",\n \"tags\",\n \"title\",\n \"type\",\n \"typeKeywords\",\n \"url\"\n ];\n\n // step 1: add item\n const createItemOption: ICreateItemOptions = {\n item: {\n ...filterKeys(requestOptions as any, itemAddProperties),\n type: \"Application\"\n },\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: {\n f: \"json\"\n }\n };\n\n const createItemResponse = await createItem(createItemOption);\n\n // step 2: register app\n const registerAppOption: IRegisterAppOptions = {\n itemId: createItemResponse.id,\n appType: \"multiple\",\n redirect_uris: requestOptions.redirect_uris || [],\n httpReferrers: [],\n privileges: [],\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n };\n\n const registeredAppResponse = await registerApp(registerAppOption);\n const itemInfo = await getItem(registeredAppResponse.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n return {\n ...appToOAuthAppProperties(registeredAppResponse),\n item: itemInfo\n };\n}\n","import {\n IGetAppInfoOptions,\n IUnregisterAppOptions,\n IUnregisterAppResponse\n} from \"./types/appType.js\";\nimport { extractBaseRequestOptions } from \"./helpers.js\";\nimport { getRegisteredAppInfo } from \"./getRegisteredAppInfo.js\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\nimport { request } from \"@esri/arcgis-rest-request\";\n\n/**\n * Used to unregister the app with given `itemId`. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/unregister-app.htm) for more information.\n *\n * ```js\n * import { unregisterApp, IUnregisterAppResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * unregisterApp({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((unregisteredApp: IUnregisterAppResponse) => {\n * // => {itemId: \"xyz_itemId\", success: true}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode unregisterApp | unregisterApp()}, including `itemId` of which app to be un-registered and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IUnregisterAppResponse} object representing un-registration status.\n */\nexport async function unregisterApp(\n requestOptions: IUnregisterAppOptions\n): Promise<IUnregisterAppResponse> {\n requestOptions.httpMethod = \"POST\";\n\n // get app\n const baseRequestOptions = extractBaseRequestOptions(requestOptions);\n const getAppOption: IGetAppInfoOptions = {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n itemId: requestOptions.itemId\n };\n\n const appResponse = await getRegisteredAppInfo(getAppOption);\n\n const clientId = appResponse.client_id;\n\n const url =\n getPortalUrl(requestOptions) + `/oauth2/apps/${clientId}/unregister`;\n\n const unregisterAppResponse: IUnregisterAppResponse = await request(url, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n return unregisterAppResponse;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,eAAe,oBAAoB,CACxC,cAAkC;IAElC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;IACnE,MAAM,GAAG,GACP,YAAY,CAAC,cAAc,CAAC;QAC5B,kBAAkB,QAAQ,UAAU,cAAc,CAAC,MAAM,oBAAoB,CAAC;IAChF,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,MAAM,qBAAqB,GAA2B,MAAM,OAAO,CAAC,GAAG,kCAClE,cAAc,KACjB,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,OAAO,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;AAC3D;;ACrCO,eAAe,mBAAmB,CACvC,OAAoC;IAEpC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,GAAG,MAAM,eAAe,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC;QACzC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,QAAQ,EAAE,OAAO,CAAC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AE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,uCACK,uBAAuB,CAAC,qBAAqB,CAAC,KACjD,IAAI,EAAE,QAAQ,IACd;AACJ;;ACpGA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,eAAe,aAAa,CACjC,cAAqC;IAErC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;;IAGnC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,cAAc,CAAC,CAAC;IACrE,MAAM,YAAY,mCACb,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,cAAc,CAAC,MAAM,GAC9B,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAE7D,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC;IAEvC,MAAM,GAAG,GACP,YAAY,CAAC,cAAc,CAAC,GAAG,gBAAgB,QAAQ,aAAa,CAAC;IAEvE,MAAM,qBAAqB,GAA2B,MAAM,OAAO,CAAC,GAAG,kCAClE,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IACH,OAAO,qBAAqB,CAAC;AAC/B;;;;"}
|
|
1
|
+
{"version":3,"file":"developer-credentials.esm.js","sources":["../../src/shared/getRegisteredAppInfo.ts","../../src/shared/generateApiKeyToken.ts","../../src/shared/helpers.ts","../../src/shared/registerApp.ts","../../src/createApiKey.ts","../../src/updateApiKey.ts","../../src/getApiKey.ts","../../src/invalidateApiKey.ts","../../src/getOAuthApp.ts","../../src/updateOAuthApp.ts","../../src/createOAuthApp.ts","../../src/shared/unregisterApp.ts"],"sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\n\nimport {\n IRegisteredAppResponse,\n IGetAppInfoOptions,\n IApp\n} from \"./types/appType.js\";\nimport { registeredAppResponseToApp } from \"./helpers.js\";\n\n/**\n * Used to retrieve registered app info. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/registered-app-info.htm) for more information.\n *\n * ```js\n * import { getRegisteredAppInfo, IApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * getRegisteredAppInfo({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((registeredApp: IApp) => {\n * // => {client_id: \"xyz_id\", client_secret: \"xyz_secret\", ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode getRegisteredAppInfo | getRegisteredAppInfo()}, including an itemId of which app to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApp} object representing successfully retrieved app.\n */\nexport async function getRegisteredAppInfo(\n requestOptions: IGetAppInfoOptions\n): Promise<IApp> {\n const userName = await requestOptions.authentication.getUsername();\n const url =\n getPortalUrl(requestOptions) +\n `/content/users/${userName}/items/${requestOptions.itemId}/registeredAppInfo`;\n requestOptions.httpMethod = \"POST\";\n\n const registeredAppResponse: IRegisteredAppResponse = await request(url, {\n ...requestOptions,\n params: { f: \"json\" }\n });\n\n return registeredAppResponseToApp(registeredAppResponse);\n}\n","import {\n request,\n IRequestOptions,\n IAuthenticationManager\n} from \"@esri/arcgis-rest-request\";\nimport { getRegisteredAppInfo } from \"./getRegisteredAppInfo.js\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\n\nexport interface IGenerateApiKeyTokenOptions extends IRequestOptions {\n itemId: string;\n apiKey: 1 | 2;\n portal?: string;\n authentication: IAuthenticationManager;\n}\n\nexport async function generateApiKeyToken(\n options: IGenerateApiKeyTokenOptions\n): Promise<{ access_token: string; expires_in: number }> {\n const portal = getPortalUrl(options);\n const url = `${portal}/oauth2/token`;\n\n const appInfo = await getRegisteredAppInfo({\n itemId: options.itemId,\n authentication: options.authentication\n });\n\n const params = {\n client_id: appInfo.client_id,\n client_secret: appInfo.client_secret,\n apiToken: options.apiKey,\n regenerateApiToken: true,\n grant_type: \"client_credentials\"\n };\n\n // authentication is not being passed to the request because client_secret acts as the auth\n return request(url, {\n params\n });\n}\n","import {\n IRequestOptions,\n IAuthenticationManager\n} from \"@esri/arcgis-rest-request\";\nimport { IRegisteredAppResponse, IApp } from \"./types/appType.js\";\nimport { IApiKeyInfo } from \"./types/apiKeyType.js\";\nimport { IOAuthAppInfo } from \"./types/oAuthType.js\";\nimport { generateApiKeyToken } from \"./generateApiKeyToken.js\";\n\n/**\n * @internal\n * Encode special params value (e.g. array type...) in advance in order to make {@linkcode encodeParam} works correctly. Usage is case by case.\n */\nexport const stringifyArrays = (requestOptions: IRequestOptions) => {\n Object.entries(requestOptions.params).forEach((entry) => {\n const [key, value] = entry;\n if (value.constructor.name === \"Array\") {\n requestOptions.params[key] = JSON.stringify(value);\n }\n });\n};\n\n/**\n * @internal\n * Used to convert {@linkcode IRegisteredAppResponse} to {@linkcode IApp}.\n */\nexport function registeredAppResponseToApp(\n response: IRegisteredAppResponse\n): IApp {\n const omittedKeys = [\n \"apnsProdCert\",\n \"apnsSandboxCert\",\n \"gcmApiKey\",\n \"isBeta\",\n \"customAppLoginShowTriage\"\n ];\n const dateKeys = [\"modified\", \"registered\"];\n\n return Object.keys(response)\n .filter((key) => !omittedKeys.includes(key))\n .reduce((obj: any, key) => {\n if (dateKeys.includes(key)) {\n obj[key] = new Date((response as any)[key]);\n } else {\n obj[key] = (response as any)[key];\n }\n return obj;\n }, {});\n}\n\n/**\n * @internal\n * Used to convert {@linkcode IApp} to {@linkcode IApiKeyInfo} only if `appType` is \"apikey\".\n */\nexport function appToApiKeyProperties(response: IApp): IApiKeyInfo {\n delete response.client_secret;\n delete response.redirect_uris;\n delete response.appType;\n delete (response as any).customAppLoginShowTriage;\n delete response.apiKey;\n\n return response as IApiKeyInfo;\n}\n\n/**\n * @internal\n * Used to convert {@linkcode IApp} to {@linkcode IOAuthAppInfo}.\n */\nexport function appToOAuthAppProperties(response: IApp): IOAuthAppInfo {\n delete response.appType;\n delete response.httpReferrers;\n delete response.privileges;\n delete response.apiKey;\n delete (response as any).customAppLoginShowTriage;\n delete response.isPersonalAPIToken;\n delete response.apiToken1Active;\n delete response.apiToken2Active;\n\n return response as IOAuthAppInfo;\n}\n\n/**\n * @internal\n * Used to extract base request options from a hybrid option and exclude `params` and `authentication`.\n */\nexport function extractBaseRequestOptions<T extends IRequestOptions>(\n options: T\n): Partial<IRequestOptions> {\n const requestOptionsProperties: Array<keyof T> = [\n \"credentials\",\n \"headers\",\n \"hideToken\",\n \"httpMethod\",\n \"maxUrlLength\",\n \"portal\",\n \"rawResponse\",\n \"signal\",\n \"suppressWarnings\"\n ];\n\n return filterKeys(options, requestOptionsProperties);\n}\n\n/**\n * @internal\n * Used to create a new object including only specified keys from another object.\n */\nexport function filterKeys<T extends object>(\n object: T,\n includedKeys: Array<keyof T>\n): any {\n return includedKeys.reduce(\n (obj: { [key: string | number | symbol]: any }, ele) => {\n if (ele in object) {\n obj[ele] = object[ele];\n }\n return obj;\n },\n {}\n );\n}\n\n/**\n * Used to determine if a generated key is in slot 1 or slot 2 key. The full API key should be passed. `undefined` will be returned if the proper slot could not be identified.\n */\nexport function slotForKey(key: string) {\n const slot = parseInt(key.substring(key.length - 10, key.length - 9));\n\n if (slot === 1 || slot === 2) {\n return slot;\n }\n\n return undefined;\n}\n\n/**\n * @internal\n * Used to determine which slot to invalidate a key in given a number or a full or patial key.\n */\nexport function slotForInvalidationKey(param: string | 1 | 2) {\n if (param === 1 || param === 2) {\n return param;\n }\n\n if (typeof param !== \"string\") {\n return undefined;\n }\n\n const fullKeySlot = slotForKey(param);\n if (fullKeySlot) {\n return fullKeySlot;\n }\n}\n\ninterface IGenerateApiKeyTokenOptions extends IRequestOptions {\n authentication: IAuthenticationManager;\n}\n\n/**\n * @internal\n * Used to generate tokens in slot 1 and/or 2 of an API key.\n */\nexport function generateApiKeyTokens(\n itemId: string,\n slots: Array<1 | 2>,\n requestOptions: IGenerateApiKeyTokenOptions\n) {\n return Promise.all(\n slots.map((slot) => {\n return generateApiKeyToken({\n itemId,\n apiKey: slot,\n ...requestOptions\n });\n })\n ).then((responses) => {\n return responses\n .map((responses) => responses.access_token)\n .reduce((obj, token, index) => {\n obj[`accessToken${slotForKey(token)}`] = token;\n return obj;\n }, {} as { [key: string]: string });\n });\n}\n\n/**\n * @internal\n * Convert boolean flags to an array of slots for {@linkcode generateApiKeyTokens}.\n */\nexport function generateOptionsToSlots(\n generateToken1: boolean,\n generateToken2: boolean\n): Array<1 | 2> {\n const slots: Array<1 | 2> = [];\n if (generateToken1) {\n slots.push(1);\n }\n if (generateToken2) {\n slots.push(2);\n }\n return slots;\n}\n\ntype expirationDateParams =\n | {\n apiToken1ExpirationDate: Date | -1;\n apiToken2ExpirationDate: Date | -1;\n }\n | {\n apiToken1ExpirationDate: Date | -1;\n }\n | {\n apiToken2ExpirationDate: Date | -1;\n }\n | {};\n\n/**\n * @internal\n * Build params for updating expiration dates\n */\nexport function buildExpirationDateParams(\n requestOptions: {\n apiToken1ExpirationDate?: Date;\n apiToken2ExpirationDate?: Date;\n },\n fillDefaults?: boolean\n): expirationDateParams {\n const updateparams: any = {};\n if (requestOptions.apiToken1ExpirationDate) {\n updateparams.apiToken1ExpirationDate =\n requestOptions.apiToken1ExpirationDate;\n }\n\n if (requestOptions.apiToken2ExpirationDate) {\n updateparams.apiToken2ExpirationDate =\n requestOptions.apiToken2ExpirationDate;\n }\n\n if (fillDefaults && !updateparams.apiToken1ExpirationDate) {\n updateparams.apiToken1ExpirationDate = -1;\n }\n\n if (fillDefaults && !updateparams.apiToken2ExpirationDate) {\n updateparams.apiToken2ExpirationDate = -1;\n }\n return updateparams;\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { request, appendCustomParams } from \"@esri/arcgis-rest-request\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\nimport {\n IApp,\n IRegisterAppOptions,\n IRegisteredAppResponse\n} from \"./types/appType.js\";\nimport { stringifyArrays, registeredAppResponseToApp } from \"./helpers.js\";\n\n/**\n * Used to register an app. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/register-app.htm) for more information.\n *\n * Accepted app types:\n * - apikey\n * - multiple\n * - browser\n * - server\n * - native\n *\n * ```js\n * import { registerApp, IApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * registerApp({\n * itemId: \"xyz_itemId\",\n * appType: \"multiple\",\n * redirect_uris: [\"http://localhost:3000/\"],\n * httpReferrers: [\"http://localhost:3000/\"],\n * privileges: [\"premium:user:geocode:temporary\", Privileges.FeatureReport],\n * authentication: authSession\n * }).then((registeredApp: IApp) => {\n * // => {client_id: \"xyz_id\", client_secret: \"xyz_secret\", ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode registerApp | registerApp()}, including necessary params to register an app and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApp} object representing the newly registered app.\n */\nexport async function registerApp(\n requestOptions: IRegisterAppOptions\n): Promise<IApp> {\n // build params\n const options = appendCustomParams(requestOptions, [\n \"itemId\",\n \"appType\",\n \"redirect_uris\",\n \"httpReferrers\",\n \"privileges\"\n ]);\n // encode special params value (e.g. array type...) in advance in order to make encodeQueryString() works correctly\n stringifyArrays(options);\n\n const url = getPortalUrl(options) + \"/oauth2/registerApp\";\n options.httpMethod = \"POST\";\n options.params.f = \"json\";\n\n const registeredAppResponse: IRegisteredAppResponse = await request(\n url,\n options\n );\n\n return registeredAppResponseToApp(registeredAppResponse);\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n ICreateItemOptions,\n createItem,\n getItem,\n IItemAdd,\n updateItem\n} from \"@esri/arcgis-rest-portal\";\nimport {\n IApiKeyResponse,\n ICreateApiKeyOptions\n} from \"./shared/types/apiKeyType.js\";\n\nimport { registerApp } from \"./shared/registerApp.js\";\nimport { IRegisterAppOptions } from \"./shared/types/appType.js\";\nimport {\n appToApiKeyProperties,\n filterKeys,\n extractBaseRequestOptions,\n generateApiKeyTokens,\n generateOptionsToSlots,\n buildExpirationDateParams\n} from \"./shared/helpers.js\";\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\n\n/**\n * Used to register an API key. See the [security and authentication](https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/) for more information about API key.\n *\n * ```js\n * import { createApiKey, IApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * const threeDaysFromToday = new Date();\n * threeDaysFromToday.setDate(threeDaysFromToday.getDate() + 3);\n * threeDaysFromToday.setHours(23, 59, 59, 999);\n *\n * createApiKey({\n * title: \"xyz_title\",\n * description: \"xyz_desc\",\n * tags: [\"xyz_tag1\", \"xyz_tag2\"],\n * privileges: [\"premium:user:networkanalysis:routing\"],\n * authentication: authSession,\n * generateToken1: true, // optional,generate a new token\n * apiToken1ExpirationDate: threeDaysFromToday // optional, update expiration date\n * }).then((registeredAPIKey: IApiKeyResponse) => {\n * // => {accessToken1: \"xyz_key\", item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode createApiKey | createApiKey()}, including necessary params to register an API key and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing the newly registered API key.\n */\nexport async function createApiKey(\n requestOptions: ICreateApiKeyOptions\n): Promise<IApiKeyResponse> {\n requestOptions.httpMethod = \"POST\";\n\n // filter param buckets:\n const baseRequestOptions = extractBaseRequestOptions(requestOptions); // snapshot of basic IRequestOptions before customized params being built into it\n\n const itemAddProperties: Array<keyof IItemAdd> = [\n \"categories\",\n \"culture\",\n \"description\",\n \"documentation\",\n \"extent\",\n \"owner\",\n \"properties\",\n \"snippet\",\n \"spatialReference\",\n \"tags\",\n \"title\",\n \"type\",\n \"typeKeywords\",\n \"url\"\n ];\n\n /**\n * step 1: create item\n */\n const createItemOption: ICreateItemOptions = {\n item: {\n ...filterKeys(requestOptions as any, itemAddProperties),\n type: \"Application\"\n },\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: {\n f: \"json\"\n }\n };\n\n const createItemResponse = await createItem(createItemOption);\n\n /**\n * getRegisteredAppInfoRoute\n */\n const registerAppOptions: IRegisterAppOptions = {\n itemId: createItemResponse.id,\n appType: \"multiple\",\n redirect_uris: [\"urn:ietf:wg:oauth:2.0:oob\"],\n httpReferrers: requestOptions.httpReferrers || [],\n privileges: requestOptions.privileges,\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n };\n\n const registeredAppResponse = await registerApp(registerAppOptions);\n\n /**\n * step 3: update item with desired expiration dates\n * you cannot set the expiration date propierties until you\n * regiester the app so this has to be a seperate step\n */\n await updateItem({\n ...baseRequestOptions,\n item: {\n id: createItemResponse.id,\n ...buildExpirationDateParams(requestOptions, true)\n },\n authentication: requestOptions.authentication\n });\n\n /*\n * step 4: get item info\n */\n const itemInfo = await getItem(registeredAppResponse.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n /**\n * step 5: generate tokens if requested\n */\n const generatedTokens = await generateApiKeyTokens(\n itemInfo.id,\n generateOptionsToSlots(\n requestOptions.generateToken1,\n requestOptions.generateToken2\n ),\n {\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n }\n );\n\n /**\n * step 6: get registered app info to get updated active key status\n */\n const updatedRegisteredAppResponse = await getRegisteredAppInfo({\n ...baseRequestOptions,\n itemId: itemInfo.id,\n authentication: requestOptions.authentication\n });\n\n return {\n ...generatedTokens,\n ...appToApiKeyProperties(updatedRegisteredAppResponse),\n item: itemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n IApiKeyResponse,\n IUpdateApiKeyOptions\n} from \"./shared/types/apiKeyType.js\";\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\nimport {\n appToApiKeyProperties,\n extractBaseRequestOptions,\n stringifyArrays,\n registeredAppResponseToApp,\n generateApiKeyTokens,\n generateOptionsToSlots,\n buildExpirationDateParams\n} from \"./shared/helpers.js\";\nimport { getItem, getPortalUrl, updateItem } from \"@esri/arcgis-rest-portal\";\nimport { appendCustomParams, request } from \"@esri/arcgis-rest-request\";\nimport {\n IApp,\n IGetAppInfoOptions,\n IRegisteredAppResponse\n} from \"./shared/types/appType.js\";\n\n/**\n * Used to update an API key.\n *\n * Notes about `privileges` and `httpReferrers` options:\n * 1. Provided option will override corresponding old option.\n * 2. Unprovided option will not trigger corresponding option updates.\n *\n * ```js\n * import { updateApiKey, IApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * const threeDaysFromToday = new Date();\n * threeDaysFromToday.setDate(threeDaysFromToday.getDate() + 3);\n * threeDaysFromToday.setHours(23, 59, 59, 999);\n *\n * updateApiKey({\n * itemId: \"xyz_itemId\",\n * privileges: [\"premium:user:geocode:temporary\"],\n * httpReferrers: [], // httpReferrers will be set to be empty\n * authentication: authSession\n * generateToken1: true, // optional,generate a new token\n * apiToken1ExpirationDate: threeDaysFromToday // optional, update expiration date\n * }).then((updatedAPIKey: IApiKeyResponse) => {\n * // => {accessToken1: \"xyz_key\", item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode updateApiKey | updateApiKey()}, including `itemId` of which API key to be operated on, optional new `privileges`, optional new `httpReferrers` and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing updated API key.\n */\nexport async function updateApiKey(\n requestOptions: IUpdateApiKeyOptions\n): Promise<IApiKeyResponse> {\n requestOptions.httpMethod = \"POST\";\n const baseRequestOptions = extractBaseRequestOptions(requestOptions); // get base requestOptions snapshot\n\n /**\n * step 1: update expiration dates if provided. Build the object up to avoid overwriting any existing properties.\n */\n if (\n requestOptions.apiToken1ExpirationDate ||\n requestOptions.apiToken2ExpirationDate\n ) {\n const updateParams = buildExpirationDateParams(requestOptions);\n await updateItem({\n ...baseRequestOptions,\n item: {\n id: requestOptions.itemId,\n ...updateParams\n },\n authentication: requestOptions.authentication\n });\n }\n\n /**\n * step 2: update privileges and httpReferrers if provided. Build the object up to avoid overwriting any existing properties.\n */\n if (requestOptions.privileges || requestOptions.httpReferrers) {\n const getAppOption: IGetAppInfoOptions = {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n itemId: requestOptions.itemId\n };\n const appResponse = await getRegisteredAppInfo(getAppOption);\n const clientId = appResponse.client_id;\n const options = appendCustomParams(\n { ...appResponse, ...requestOptions }, // object with the custom params to look in\n [\"privileges\", \"httpReferrers\"] // keys you want copied to the params object\n );\n options.params.f = \"json\";\n\n // encode special params value (e.g. array type...) in advance in order to make encodeQueryString() works correctly\n stringifyArrays(options);\n\n const url = getPortalUrl(options) + `/oauth2/apps/${clientId}/update`;\n\n // Raw response from `/oauth2/apps/${clientId}/update`, apiKey not included because key is same.\n const updateResponse: IRegisteredAppResponse = await request(url, {\n ...options,\n authentication: requestOptions.authentication\n });\n }\n\n /**\n * step 3: get the updated item info to return to the user.\n */\n const updatedItemInfo = await getItem(requestOptions.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n /**\n * step 4: generate tokens if requested\n */\n const generatedTokens = await generateApiKeyTokens(\n requestOptions.itemId,\n generateOptionsToSlots(\n requestOptions.generateToken1,\n requestOptions.generateToken2\n ),\n {\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n }\n );\n\n /**\n * step 5: get updated registered app info\n */\n const updatedRegisteredAppResponse = await getRegisteredAppInfo({\n ...baseRequestOptions,\n itemId: requestOptions.itemId,\n authentication: requestOptions.authentication\n });\n\n return {\n ...generatedTokens,\n ...appToApiKeyProperties(updatedRegisteredAppResponse),\n item: updatedItemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\nimport {\n IApiKeyResponse,\n IGetApiKeyOptions\n} from \"./shared/types/apiKeyType.js\";\nimport { getItem } from \"@esri/arcgis-rest-portal\";\nimport {\n appToApiKeyProperties,\n extractBaseRequestOptions\n} from \"./shared/helpers.js\";\n\n/**\n * Used to retrieve the API key with given `itemId`. See the [security and authentication](https://developers.arcgis.com/documentation/mapping-apis-and-services/security/api-keys/) for more information about API key.\n *\n * ```js\n * import { getApiKey, IApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * getApiKey({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((retrievedAPIKey: IApiKeyResponse) => {\n * // => {apiKey: \"xyz_key\", item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode getApiKey | getApiKey()}, including `itemId` of which API key to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing successfully retrieved API key.\n */\nexport async function getApiKey(\n requestOptions: IGetApiKeyOptions\n): Promise<IApiKeyResponse> {\n const appResponse = await getRegisteredAppInfo(requestOptions);\n\n const itemInfo = await getItem(requestOptions.itemId, {\n ...extractBaseRequestOptions(requestOptions),\n authentication: requestOptions.authentication\n });\n\n return {\n ...appToApiKeyProperties(appResponse),\n item: itemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n IInvalidateApiKeyOptions,\n IInvalidateApiKeyResponse\n} from \"./shared/types/apiKeyType.js\";\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\nimport { request } from \"@esri/arcgis-rest-request\";\nimport { slotForInvalidationKey } from \"./shared/helpers.js\";\n\n/**\n * Used to invalidate an API key.\n *\n * ```js\n * import { invalidateApiKey } from \"@esri/arcgis-rest-developer-credentials\";\n *\n * invalidateApiKey({\n * itemId: ITEM_ID,\n * authentication,\n * apiKey: 1, // invalidate the key in slot 1\n * }).then((response) => {\n * // => {success: true}\n * }).catch(e => {\n * // => an exception object\n * });\n */\nexport async function invalidateApiKey(\n requestOptions: IInvalidateApiKeyOptions\n): Promise<IInvalidateApiKeyResponse> {\n const portal = getPortalUrl(requestOptions);\n const url = `${portal}/oauth2/revokeToken`;\n\n const appInfo = await getRegisteredAppInfo({\n itemId: requestOptions.itemId,\n authentication: requestOptions.authentication\n });\n\n const params = {\n client_id: appInfo.client_id,\n client_secret: appInfo.client_secret,\n apiToken: slotForInvalidationKey(requestOptions.apiKey),\n regenerateApiToken: true,\n grant_type: \"client_credentials\"\n };\n\n // authentication is not being passed to the request because client_secret acts as the auth\n return request(url, {\n params\n });\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\nimport { getItem } from \"@esri/arcgis-rest-portal\";\nimport {\n appToOAuthAppProperties,\n extractBaseRequestOptions\n} from \"./shared/helpers.js\";\nimport { IGetOAuthAppOptions, IOAuthApp } from \"./shared/types/oAuthType.js\";\n\n/**\n * Used to retrieve the OAuth2.0 app with given `itemId`. See the [OAuth2.0](https://developers.arcgis.com/documentation/mapping-apis-and-services/security/oauth-2.0/) for more information.\n *\n * ```js\n * import { getOAuthApp, IOAuthApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * getOAuthApp({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((retrievedOAuthApp: IOAuthApp) => {\n * // => {redirect_uris: [\"http://localhost:3000/\"], item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode getOAuthApp | getOAuthApp()}, including `itemId` of which OAuth app to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IOAuthApp} object representing successfully retrieved OAuth app.\n */\nexport async function getOAuthApp(\n requestOptions: IGetOAuthAppOptions\n): Promise<IOAuthApp> {\n const appResponse = await getRegisteredAppInfo(requestOptions);\n\n const itemInfo = await getItem(requestOptions.itemId, {\n ...extractBaseRequestOptions(requestOptions),\n authentication: requestOptions.authentication\n });\n\n return {\n ...appToOAuthAppProperties(appResponse),\n item: itemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n extractBaseRequestOptions,\n stringifyArrays,\n registeredAppResponseToApp,\n appToOAuthAppProperties\n} from \"./shared/helpers.js\";\nimport { getItem, getPortalUrl } from \"@esri/arcgis-rest-portal\";\nimport { appendCustomParams, request } from \"@esri/arcgis-rest-request\";\nimport {\n IApp,\n IGetAppInfoOptions,\n IRegisteredAppResponse\n} from \"./shared/types/appType.js\";\nimport { IOAuthApp, IUpdateOAuthOptions } from \"./shared/types/oAuthType.js\";\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\n\n/**\n * Used to update an OAuth2.0 app.\n *\n * Notes about `redirect_uris` options:\n * 1. Provided option will override corresponding old option.\n * 2. Unprovided option will not trigger corresponding option updates.\n *\n * ```js\n * import { updateOAuthApp, IOAuthApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * updateOAuthApp({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((updatedOAuthApp: IOAuthApp) => {\n * // => This OAuth app will be not be updated because its redirect_uris is not provided.\n * // => {redirect_uris: [\"http://localhost:3000/\"], item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode updateOAuthApp | updateOAuthApp()}, including `itemId` of which OAuth app to be operated on, optional new `redirect_uris` and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IOAuthApp} object representing updated OAuth app.\n */\nexport async function updateOAuthApp(\n requestOptions: IUpdateOAuthOptions\n): Promise<IOAuthApp> {\n requestOptions.httpMethod = \"POST\";\n\n // get app\n const baseRequestOptions = extractBaseRequestOptions(requestOptions); // get base requestOptions snapshot\n const getAppOption: IGetAppInfoOptions = {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n itemId: requestOptions.itemId\n };\n\n const appResponse = await getRegisteredAppInfo(getAppOption);\n\n if (appResponse.appType === \"apikey\") {\n throw new Error(\"Item is not an OAuth 2.0 app.\");\n }\n\n const clientId = appResponse.client_id;\n const options = appendCustomParams({ ...appResponse, ...requestOptions }, [\n \"redirect_uris\"\n ]);\n options.params.f = \"json\";\n options.params.appType = \"multiple\";\n\n // encode special params value (e.g. array type...) in advance in order to make encodeQueryString() works correctly\n stringifyArrays(options);\n\n const url = getPortalUrl(options) + `/oauth2/apps/${clientId}/update`;\n\n // Raw response from `/oauth2/apps/${clientId}/update`.\n const updateResponse: IRegisteredAppResponse = await request(url, {\n ...options,\n authentication: requestOptions.authentication\n });\n\n const app: IApp = registeredAppResponseToApp(updateResponse);\n\n const itemInfo = await getItem(requestOptions.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n return {\n ...appToOAuthAppProperties(app),\n item: itemInfo\n };\n}\n","/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n ICreateItemOptions,\n createItem,\n getItem,\n IItemAdd\n} from \"@esri/arcgis-rest-portal\";\n\nimport { registerApp } from \"./shared/registerApp.js\";\nimport { IRegisterAppOptions } from \"./shared/types/appType.js\";\nimport {\n filterKeys,\n extractBaseRequestOptions,\n appToOAuthAppProperties\n} from \"./shared/helpers.js\";\nimport { ICreateOAuthAppOption, IOAuthApp } from \"./shared/types/oAuthType.js\";\n\n/**\n * Used to register an OAuth2.0 app. See the [OAuth2.0](https://developers.arcgis.com/documentation/mapping-apis-and-services/security/oauth-2.0/) for more information.\n *\n * ```js\n * import { createOAuthApp, IOAuthApp } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * createOAuthApp({\n * title: \"xyz_title\",\n * description: \"xyz_desc\",\n * tags: [\"xyz_tag1\", \"xyz_tag2\"],\n * redirect_uris: [\"http://localhost:3000/\"],\n * authentication: authSession\n * }).then((registeredOAuthApp: IOAuthApp) => {\n * // => {redirect_uris: [\"http://localhost:3000/\"], item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode createOAuthApp | createOAuthApp()}, including necessary params to register an OAuth app and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IOAuthApp} object representing the newly registered OAuth app.\n */\nexport async function createOAuthApp(\n requestOptions: ICreateOAuthAppOption\n): Promise<IOAuthApp> {\n requestOptions.httpMethod = \"POST\";\n\n // filter param buckets:\n\n const baseRequestOptions = extractBaseRequestOptions(requestOptions);\n\n const itemAddProperties: Array<keyof IItemAdd> = [\n \"categories\",\n \"culture\",\n \"description\",\n \"documentation\",\n \"extent\",\n \"owner\",\n \"properties\",\n \"snippet\",\n \"spatialReference\",\n \"tags\",\n \"title\",\n \"type\",\n \"typeKeywords\",\n \"url\"\n ];\n\n // step 1: add item\n const createItemOption: ICreateItemOptions = {\n item: {\n ...filterKeys(requestOptions as any, itemAddProperties),\n type: \"Application\"\n },\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: {\n f: \"json\"\n }\n };\n\n const createItemResponse = await createItem(createItemOption);\n\n // step 2: register app\n const registerAppOption: IRegisterAppOptions = {\n itemId: createItemResponse.id,\n appType: \"multiple\",\n redirect_uris: requestOptions.redirect_uris || [],\n httpReferrers: [],\n privileges: [],\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n };\n\n const registeredAppResponse = await registerApp(registerAppOption);\n const itemInfo = await getItem(registeredAppResponse.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n return {\n ...appToOAuthAppProperties(registeredAppResponse),\n item: itemInfo\n };\n}\n","import {\n IGetAppInfoOptions,\n IUnregisterAppOptions,\n IUnregisterAppResponse\n} from \"./types/appType.js\";\nimport { extractBaseRequestOptions } from \"./helpers.js\";\nimport { getRegisteredAppInfo } from \"./getRegisteredAppInfo.js\";\nimport { getPortalUrl } from \"@esri/arcgis-rest-portal\";\nimport { request } from \"@esri/arcgis-rest-request\";\n\n/**\n * Used to unregister the app with given `itemId`. See the [REST Documentation](https://developers.arcgis.com/rest/users-groups-and-items/unregister-app.htm) for more information.\n *\n * ```js\n * import { unregisterApp, IUnregisterAppResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * unregisterApp({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((unregisteredApp: IUnregisterAppResponse) => {\n * // => {itemId: \"xyz_itemId\", success: true}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode unregisterApp | unregisterApp()}, including `itemId` of which app to be un-registered and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IUnregisterAppResponse} object representing un-registration status.\n */\nexport async function unregisterApp(\n requestOptions: IUnregisterAppOptions\n): Promise<IUnregisterAppResponse> {\n requestOptions.httpMethod = \"POST\";\n\n // get app\n const baseRequestOptions = extractBaseRequestOptions(requestOptions);\n const getAppOption: IGetAppInfoOptions = {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n itemId: requestOptions.itemId\n };\n\n const appResponse = await getRegisteredAppInfo(getAppOption);\n\n const clientId = appResponse.client_id;\n\n const url =\n getPortalUrl(requestOptions) + `/oauth2/apps/${clientId}/unregister`;\n\n const unregisterAppResponse: IUnregisterAppResponse = await request(url, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n return unregisterAppResponse;\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,eAAe,oBAAoB,CACxC,cAAkC;IAElC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;IACnE,MAAM,GAAG,GACP,YAAY,CAAC,cAAc,CAAC;QAC5B,kBAAkB,QAAQ,UAAU,cAAc,CAAC,MAAM,oBAAoB,CAAC;IAChF,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,MAAM,qBAAqB,GAA2B,MAAM,OAAO,CAAC,GAAG,kCAClE,cAAc,KACjB,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,OAAO,0BAA0B,CAAC,qBAAqB,CAAC,CAAC;AAC3D;;ACrCO,eAAe,mBAAmB,CACvC,OAAoC;IAEpC,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,GAAG,MAAM,eAAe,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC;QACzC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,QAAQ,EAAE,OAAO,CAAC,MAAM;QACxB,kBAAkB,EAAE,IAAI;QACxB,UAAU,EAAE,oBAAoB;KACjC,CAAC;;IAGF,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM;KACP,CAAC,CAAC;AACL;;AC7BA;;;;MAIa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AG,yBAAyB,CAAC,cAAc,CAAC,CAAC;IACrE,MAAM,YAAY,mCACb,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,cAAc,CAAC,MAAM,GAC9B,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAE7D,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC;IAEvC,MAAM,GAAG,GACP,YAAY,CAAC,cAAc,CAAC,GAAG,gBAAgB,QAAQ,aAAa,CAAC;IAEvE,MAAM,qBAAqB,GAA2B,MAAM,OAAO,CAAC,GAAG,kCAClE,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IACH,OAAO,qBAAqB,CAAC;AAC/B;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
2
|
* @esri/arcgis-rest-developer-credentials - v2.0.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2025 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Wed Feb 26 2025 22:10:42 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
|
-
import{getPortalUrl as t,createItem as e,updateItem as i,getItem as
|
|
6
|
+
import{getPortalUrl as t,createItem as e,updateItem as i,getItem as n}from"@esri/arcgis-rest-portal";import{request as a,appendCustomParams as s}from"@esri/arcgis-rest-request";async function c(e){const i=await e.authentication.getUsername(),n=t(e)+`/content/users/${i}/items/${e.itemId}/registeredAppInfo`;e.httpMethod="POST";return r(await a(n,Object.assign(Object.assign({},e),{params:{f:"json"}})))}const o=t=>{Object.entries(t.params).forEach((e=>{const[i,n]=e;"Array"===n.constructor.name&&(t.params[i]=JSON.stringify(n))}))};function r(t){const e=["apnsProdCert","apnsSandboxCert","gcmApiKey","isBeta","customAppLoginShowTriage"],i=["modified","registered"];return Object.keys(t).filter((t=>!e.includes(t))).reduce(((e,n)=>(i.includes(n)?e[n]=new Date(t[n]):e[n]=t[n],e)),{})}function p(t){return delete t.client_secret,delete t.redirect_uris,delete t.appType,delete t.customAppLoginShowTriage,delete t.apiKey,t}function u(t){return delete t.appType,delete t.httpReferrers,delete t.privileges,delete t.apiKey,delete t.customAppLoginShowTriage,delete t.isPersonalAPIToken,delete t.apiToken1Active,delete t.apiToken2Active,t}function g(t){return h(t,["credentials","headers","hideToken","httpMethod","maxUrlLength","portal","rawResponse","signal","suppressWarnings"])}function h(t,e){return e.reduce(((e,i)=>(i in t&&(e[i]=t[i]),e)),{})}function d(t){const e=parseInt(t.substring(t.length-10,t.length-9));if(1===e||2===e)return e}function j(t){if(1===t||2===t)return t;if("string"!=typeof t)return;const e=d(t);return e||void 0}function O(e,i,n){return Promise.all(i.map((i=>async function(e){const i=`${t(e)}/oauth2/token`,n=await c({itemId:e.itemId,authentication:e.authentication}),s={client_id:n.client_id,client_secret:n.client_secret,apiToken:e.apiKey,regenerateApiToken:!0,grant_type:"client_credentials"};return a(i,{params:s})}(Object.assign({itemId:e,apiKey:i},n))))).then((t=>t.map((t=>t.access_token)).reduce(((t,e,i)=>(t[`accessToken${d(e)}`]=e,t)),{})))}function b(t,e){const i=[];return t&&i.push(1),e&&i.push(2),i}function m(t,e){const i={};return t.apiToken1ExpirationDate&&(i.apiToken1ExpirationDate=t.apiToken1ExpirationDate),t.apiToken2ExpirationDate&&(i.apiToken2ExpirationDate=t.apiToken2ExpirationDate),e&&!i.apiToken1ExpirationDate&&(i.apiToken1ExpirationDate=-1),e&&!i.apiToken2ExpirationDate&&(i.apiToken2ExpirationDate=-1),i}async function l(e){const i=s(e,["itemId","appType","redirect_uris","httpReferrers","privileges"]);o(i);const n=t(i)+"/oauth2/registerApp";i.httpMethod="POST",i.params.f="json";return r(await a(n,i))}async function f(t){t.httpMethod="POST";const a=g(t),s=Object.assign(Object.assign({item:Object.assign(Object.assign({},h(t,["categories","culture","description","documentation","extent","owner","properties","snippet","spatialReference","tags","title","type","typeKeywords","url"])),{type:"Application"})},a),{authentication:t.authentication,params:{f:"json"}}),o=await e(s),r=Object.assign(Object.assign({itemId:o.id,appType:"multiple",redirect_uris:["urn:ietf:wg:oauth:2.0:oob"],httpReferrers:t.httpReferrers||[],privileges:t.privileges},a),{authentication:t.authentication}),u=await l(r);await i(Object.assign(Object.assign({},a),{item:Object.assign({id:o.id},m(t,!0)),authentication:t.authentication}));const d=await n(u.itemId,Object.assign(Object.assign({},a),{authentication:t.authentication,params:{f:"json"}})),j=await O(d.id,b(t.generateToken1,t.generateToken2),Object.assign(Object.assign({},a),{authentication:t.authentication})),f=await c(Object.assign(Object.assign({},a),{itemId:d.id,authentication:t.authentication}));return Object.assign(Object.assign(Object.assign({},j),p(f)),{item:d})}async function T(e){e.httpMethod="POST";const r=g(e);if(e.apiToken1ExpirationDate||e.apiToken2ExpirationDate){const t=m(e);await i(Object.assign(Object.assign({},r),{item:Object.assign({id:e.itemId},t),authentication:e.authentication}))}if(e.privileges||e.httpReferrers){const i=Object.assign(Object.assign({},r),{authentication:e.authentication,itemId:e.itemId}),n=await c(i),p=n.client_id,u=s(Object.assign(Object.assign({},n),e),["privileges","httpReferrers"]);u.params.f="json",o(u);const g=t(u)+`/oauth2/apps/${p}/update`;await a(g,Object.assign(Object.assign({},u),{authentication:e.authentication}))}const u=await n(e.itemId,Object.assign(Object.assign({},r),{authentication:e.authentication,params:{f:"json"}})),h=await O(e.itemId,b(e.generateToken1,e.generateToken2),Object.assign(Object.assign({},r),{authentication:e.authentication})),d=await c(Object.assign(Object.assign({},r),{itemId:e.itemId,authentication:e.authentication}));return Object.assign(Object.assign(Object.assign({},h),p(d)),{item:u})}async function w(t){const e=await c(t),i=await n(t.itemId,Object.assign(Object.assign({},g(t)),{authentication:t.authentication}));return Object.assign(Object.assign({},p(e)),{item:i})}async function y(e){const i=`${t(e)}/oauth2/revokeToken`,n=await c({itemId:e.itemId,authentication:e.authentication}),s={client_id:n.client_id,client_secret:n.client_secret,apiToken:j(e.apiKey),regenerateApiToken:!0,grant_type:"client_credentials"};return a(i,{params:s})}async function k(t){const e=await c(t),i=await n(t.itemId,Object.assign(Object.assign({},g(t)),{authentication:t.authentication}));return Object.assign(Object.assign({},u(e)),{item:i})}async function I(e){e.httpMethod="POST";const i=g(e),p=Object.assign(Object.assign({},i),{authentication:e.authentication,itemId:e.itemId}),h=await c(p);if("apikey"===h.appType)throw new Error("Item is not an OAuth 2.0 app.");const d=h.client_id,j=s(Object.assign(Object.assign({},h),e),["redirect_uris"]);j.params.f="json",j.params.appType="multiple",o(j);const O=t(j)+`/oauth2/apps/${d}/update`,b=r(await a(O,Object.assign(Object.assign({},j),{authentication:e.authentication}))),m=await n(e.itemId,Object.assign(Object.assign({},i),{authentication:e.authentication,params:{f:"json"}}));return Object.assign(Object.assign({},u(b)),{item:m})}async function _(t){t.httpMethod="POST";const i=g(t),a=Object.assign(Object.assign({item:Object.assign(Object.assign({},h(t,["categories","culture","description","documentation","extent","owner","properties","snippet","spatialReference","tags","title","type","typeKeywords","url"])),{type:"Application"})},i),{authentication:t.authentication,params:{f:"json"}}),s=await e(a),c=Object.assign(Object.assign({itemId:s.id,appType:"multiple",redirect_uris:t.redirect_uris||[],httpReferrers:[],privileges:[]},i),{authentication:t.authentication}),o=await l(c),r=await n(o.itemId,Object.assign(Object.assign({},i),{authentication:t.authentication,params:{f:"json"}}));return Object.assign(Object.assign({},u(o)),{item:r})}async function x(e){e.httpMethod="POST";const i=g(e),n=Object.assign(Object.assign({},i),{authentication:e.authentication,itemId:e.itemId}),s=(await c(n)).client_id,o=t(e)+`/oauth2/apps/${s}/unregister`;return await a(o,Object.assign(Object.assign({},i),{authentication:e.authentication,params:{f:"json"}}))}export{p as appToApiKeyProperties,u as appToOAuthAppProperties,m as buildExpirationDateParams,f as createApiKey,_ as createOAuthApp,g as extractBaseRequestOptions,h as filterKeys,O as generateApiKeyTokens,b as generateOptionsToSlots,w as getApiKey,k as getOAuthApp,c as getRegisteredAppInfo,y as invalidateApiKey,l as registerApp,r as registeredAppResponseToApp,j as slotForInvalidationKey,d as slotForKey,o as stringifyArrays,x as unregisterApp,T as updateApiKey,I as updateOAuthApp};
|
|
7
7
|
//# sourceMappingURL=developer-credentials.esm.min.js.map
|