@esri/arcgis-rest-developer-credentials 2.1.1-alpha.1 → 4.8.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.
Files changed (74) hide show
  1. package/dist/bundled/developer-credentials.esm.js +12 -12
  2. package/dist/bundled/developer-credentials.esm.js.map +1 -1
  3. package/dist/bundled/developer-credentials.esm.min.js +4 -4
  4. package/dist/bundled/developer-credentials.esm.min.js.map +1 -1
  5. package/dist/bundled/developer-credentials.umd.js +731 -733
  6. package/dist/bundled/developer-credentials.umd.js.map +1 -1
  7. package/dist/bundled/developer-credentials.umd.min.js +4 -4
  8. package/dist/bundled/developer-credentials.umd.min.js.map +1 -1
  9. package/dist/cjs/createApiKey.js +2 -3
  10. package/dist/cjs/createApiKey.js.map +1 -1
  11. package/dist/cjs/createOAuthApp.js +2 -3
  12. package/dist/cjs/createOAuthApp.js.map +1 -1
  13. package/dist/cjs/getApiKey.js +2 -3
  14. package/dist/cjs/getApiKey.js.map +1 -1
  15. package/dist/cjs/getOAuthApp.js +2 -3
  16. package/dist/cjs/getOAuthApp.js.map +1 -1
  17. package/dist/cjs/index.js +15 -15
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/cjs/invalidateApiKey.js +1 -2
  20. package/dist/cjs/invalidateApiKey.js.map +1 -1
  21. package/dist/cjs/shared/generateApiKeyToken.js +1 -2
  22. package/dist/cjs/shared/generateApiKeyToken.js.map +1 -1
  23. package/dist/cjs/shared/getRegisteredAppInfo.js +2 -3
  24. package/dist/cjs/shared/getRegisteredAppInfo.js.map +1 -1
  25. package/dist/cjs/shared/helpers.js +11 -11
  26. package/dist/cjs/shared/helpers.js.map +1 -1
  27. package/dist/cjs/shared/registerApp.js +2 -3
  28. package/dist/cjs/shared/registerApp.js.map +1 -1
  29. package/dist/cjs/shared/types/apiKeyType.js.map +1 -1
  30. package/dist/cjs/shared/types/appType.js.map +1 -1
  31. package/dist/cjs/shared/types/oAuthType.js.map +1 -1
  32. package/dist/cjs/shared/unregisterApp.js +2 -3
  33. package/dist/cjs/shared/unregisterApp.js.map +1 -1
  34. package/dist/cjs/updateApiKey.js +2 -3
  35. package/dist/cjs/updateApiKey.js.map +1 -1
  36. package/dist/cjs/updateOAuthApp.js +2 -3
  37. package/dist/cjs/updateOAuthApp.js.map +1 -1
  38. package/dist/esm/createApiKey.d.ts +1 -1
  39. package/dist/esm/createApiKey.js +1 -1
  40. package/dist/esm/createApiKey.js.map +1 -1
  41. package/dist/esm/createOAuthApp.d.ts +1 -1
  42. package/dist/esm/createOAuthApp.js +1 -1
  43. package/dist/esm/createOAuthApp.js.map +1 -1
  44. package/dist/esm/getApiKey.d.ts +1 -1
  45. package/dist/esm/getApiKey.js +1 -1
  46. package/dist/esm/getApiKey.js.map +1 -1
  47. package/dist/esm/getOAuthApp.d.ts +1 -1
  48. package/dist/esm/getOAuthApp.js +1 -1
  49. package/dist/esm/getOAuthApp.js.map +1 -1
  50. package/dist/esm/shared/enum/privileges.d.ts +1 -1
  51. package/dist/esm/shared/getRegisteredAppInfo.d.ts +1 -1
  52. package/dist/esm/shared/getRegisteredAppInfo.js +1 -1
  53. package/dist/esm/shared/getRegisteredAppInfo.js.map +1 -1
  54. package/dist/esm/shared/helpers.d.ts +1 -1
  55. package/dist/esm/shared/helpers.js.map +1 -1
  56. package/dist/esm/shared/registerApp.d.ts +1 -1
  57. package/dist/esm/shared/registerApp.js +1 -1
  58. package/dist/esm/shared/registerApp.js.map +1 -1
  59. package/dist/esm/shared/types/apiKeyType.d.ts +4 -4
  60. package/dist/esm/shared/types/apiKeyType.js.map +1 -1
  61. package/dist/esm/shared/types/appType.d.ts +4 -4
  62. package/dist/esm/shared/types/appType.js.map +1 -1
  63. package/dist/esm/shared/types/oAuthType.d.ts +4 -4
  64. package/dist/esm/shared/types/oAuthType.js.map +1 -1
  65. package/dist/esm/shared/unregisterApp.d.ts +1 -1
  66. package/dist/esm/shared/unregisterApp.js +1 -1
  67. package/dist/esm/shared/unregisterApp.js.map +1 -1
  68. package/dist/esm/updateApiKey.d.ts +1 -1
  69. package/dist/esm/updateApiKey.js +1 -1
  70. package/dist/esm/updateApiKey.js.map +1 -1
  71. package/dist/esm/updateOAuthApp.d.ts +1 -1
  72. package/dist/esm/updateOAuthApp.js +1 -1
  73. package/dist/esm/updateOAuthApp.js.map +1 -1
  74. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"createApiKey.js","sourceRoot":"","sources":["../../src/createApiKey.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,iEAMkC;AAMlC,4DAAsD;AAEtD,oDAO6B;AAC7B,8EAAwE;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACI,KAAK,UAAU,YAAY,CAChC,cAAoC;IAEpC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,wBAAwB;IACxB,MAAM,kBAAkB,GAAG,IAAA,sCAAyB,EAAC,cAAc,CAAC,CAAC,CAAC,iFAAiF;IAEvJ,MAAM,iBAAiB,GAA0B;QAC/C,YAAY;QACZ,SAAS;QACT,aAAa;QACb,eAAe;QACf,QAAQ;QACR,OAAO;QACP,YAAY;QACZ,SAAS;QACT,kBAAkB;QAClB,MAAM;QACN,OAAO;QACP,MAAM;QACN,cAAc;QACd,KAAK;KACN,CAAC;IAEF;;OAEG;IACH,MAAM,gBAAgB,iCACpB,IAAI,kCACC,IAAA,uBAAU,EAAC,cAAqB,EAAE,iBAAiB,CAAC,KACvD,IAAI,EAAE,aAAa,OAElB,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE;YACN,CAAC,EAAE,MAAM;SACV,GACF,CAAC;IAEF,MAAM,kBAAkB,GAAG,MAAM,IAAA,+BAAU,EAAC,gBAAgB,CAAC,CAAC;IAE9D;;OAEG;IACH,MAAM,kBAAkB,iCACtB,MAAM,EAAE,kBAAkB,CAAC,EAAE,EAC7B,OAAO,EAAE,UAAU,EAC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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"]}
1
+ {"version":3,"file":"createApiKey.js","sourceRoot":"","sources":["../../src/createApiKey.ts"],"names":[],"mappings":";AAAA;gBACgB;;AA4DhB,oCA6GC;AAvKD,iEAMkC;AAMlC,4DAAsD;AAEtD,oDAO6B;AAC7B,8EAAwE;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACI,KAAK,UAAU,YAAY,CAChC,cAAoC;IAEpC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,wBAAwB;IACxB,MAAM,kBAAkB,GAAG,IAAA,sCAAyB,EAAC,cAAc,CAAC,CAAC,CAAC,iFAAiF;IAEvJ,MAAM,iBAAiB,GAA0B;QAC/C,YAAY;QACZ,SAAS;QACT,aAAa;QACb,eAAe;QACf,QAAQ;QACR,OAAO;QACP,YAAY;QACZ,SAAS;QACT,kBAAkB;QAClB,MAAM;QACN,OAAO;QACP,MAAM;QACN,cAAc;QACd,KAAK;KACN,CAAC;IAEF;;OAEG;IACH,MAAM,gBAAgB,iCACpB,IAAI,kCACC,IAAA,uBAAU,EAAC,cAAqB,EAAE,iBAAiB,CAAC,KACvD,IAAI,EAAE,aAAa,OAElB,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE;YACN,CAAC,EAAE,MAAM;SACV,GACF,CAAC;IAEF,MAAM,kBAAkB,GAAG,MAAM,IAAA,+BAAU,EAAC,gBAAgB,CAAC,CAAC;IAE9D;;OAEG;IACH,MAAM,kBAAkB,iCACtB,MAAM,EAAE,kBAAkB,CAAC,EAAE,EAC7B,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,CAAC,2BAA2B,CAAC,EAC5C,aAAa,EAAE,cAAc,CAAC,aAAa,IAAI,EAAE,EACjD,UAAU,EAAE,cAAc,CAAC,UAAU,IAClC,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,GAC9C,CAAC;IAEF,MAAM,qBAAqB,GAAG,MAAM,IAAA,4BAAW,EAAC,kBAAkB,CAAC,CAAC;IAEpE;;;;OAIG;IACH,MAAM,IAAA,+BAAU,kCACX,kBAAkB,KACrB,IAAI,kBACF,EAAE,EAAE,kBAAkB,CAAC,EAAE,IACtB,IAAA,sCAAyB,EAAC,cAAc,EAAE,IAAI,CAAC,GAEpD,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH;;OAEG;IACH,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAO,EAAC,qBAAqB,CAAC,MAAM,kCACtD,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH;;OAEG;IACH,MAAM,eAAe,GAAG,MAAM,IAAA,iCAAoB,EAChD,QAAQ,CAAC,EAAE,EACX,IAAA,mCAAsB,EACpB,cAAc,CAAC,cAAc,EAC7B,cAAc,CAAC,cAAc,CAC9B,kCAEI,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,IAEhD,CAAC;IAEF;;OAEG;IACH,MAAM,4BAA4B,GAAG,MAAM,IAAA,8CAAoB,kCAC1D,kBAAkB,KACrB,MAAM,EAAE,QAAQ,CAAC,EAAE,EACnB,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,qDACK,eAAe,GACf,IAAA,kCAAqB,EAAC,4BAA4B,CAAC,KACtD,IAAI,EAAE,QAAQ,IACd;AACJ,CAAC","sourcesContent":["/* 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 @esri/arcgis-rest-request!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"]}
@@ -2,7 +2,7 @@
2
2
  /* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
3
3
  * Apache-2.0 */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.createOAuthApp = void 0;
5
+ exports.createOAuthApp = createOAuthApp;
6
6
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
7
7
  const registerApp_js_1 = require("./shared/registerApp.js");
8
8
  const helpers_js_1 = require("./shared/helpers.js");
@@ -31,7 +31,7 @@ const helpers_js_1 = require("./shared/helpers.js");
31
31
  * });
32
32
  * ```
33
33
  *
34
- * @param requestOptions - Options for {@linkcode createOAuthApp | createOAuthApp()}, including necessary params to register an OAuth app and an {@linkcode ArcGISIdentityManager} authentication session.
34
+ * @param requestOptions - Options for {@linkcode createOAuthApp | createOAuthApp()}, including necessary params to register an OAuth app and an {@linkcode @esri/arcgis-rest-request!ArcGISIdentityManager} authentication session.
35
35
  * @returns A Promise that will resolve to an {@linkcode IOAuthApp} object representing the newly registered OAuth app.
36
36
  */
37
37
  async function createOAuthApp(requestOptions) {
@@ -65,5 +65,4 @@ async function createOAuthApp(requestOptions) {
65
65
  const itemInfo = await (0, arcgis_rest_portal_1.getItem)(registeredAppResponse.itemId, Object.assign(Object.assign({}, baseRequestOptions), { authentication: requestOptions.authentication, params: { f: "json" } }));
66
66
  return Object.assign(Object.assign({}, (0, helpers_js_1.appToOAuthAppProperties)(registeredAppResponse)), { item: itemInfo });
67
67
  }
68
- exports.createOAuthApp = createOAuthApp;
69
68
  //# sourceMappingURL=createOAuthApp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createOAuthApp.js","sourceRoot":"","sources":["../../src/createOAuthApp.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,iEAKk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E,MAAM,EAAE,IACrB,CAAC;IAEH,uCACK,IAAA,oCAAuB,EAAC,qBAAqB,CAAC,KACjD,IAAI,EAAE,QAAQ,IACd;AACJ,CAAC;AA/DD,wCA+DC","sourcesContent":["/* 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"]}
1
+ {"version":3,"file":"createOAuthApp.js","sourceRoot":"","sources":["../../src/createOAuthApp.ts"],"names":[],"mappings":";AAAA;gBACgB;;AA8ChB,wCA+DC;AA3GD,iEAKkC;AAElC,4DAAsD;AAEtD,oDAI6B;AAG7B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,KAAK,UAAU,cAAc,CAClC,cAAqC;IAErC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,wBAAwB;IAExB,MAAM,kBAAkB,GAAG,IAAA,sCAAyB,EAAC,cAAc,CAAC,CAAC;IAErE,MAAM,iBAAiB,GAA0B;QAC/C,YAAY;QACZ,SAAS;QACT,aAAa;QACb,eAAe;QACf,QAAQ;QACR,OAAO;QACP,YAAY;QACZ,SAAS;QACT,kBAAkB;QAClB,MAAM;QACN,OAAO;QACP,MAAM;QACN,cAAc;QACd,KAAK;KACN,CAAC;IAEF,mBAAmB;IACnB,MAAM,gBAAgB,iCACpB,IAAI,kCACC,IAAA,uBAAU,EAAC,cAAqB,EAAE,iBAAiB,CAAC,KACvD,IAAI,EAAE,aAAa,OAElB,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE;YACN,CAAC,EAAE,MAAM;SACV,GACF,CAAC;IAEF,MAAM,kBAAkB,GAAG,MAAM,IAAA,+BAAU,EAAC,gBAAgB,CAAC,CAAC;IAE9D,uBAAuB;IACvB,MAAM,iBAAiB,iCACrB,MAAM,EAAE,kBAAkB,CAAC,EAAE,EAC7B,OAAO,EAAE,UAAU,EACnB,aAAa,EAAE,cAAc,CAAC,aAAa,IAAI,EAAE,EACjD,aAAa,EAAE,EAAE,EACjB,UAAU,EAAE,EAAE,IACX,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,GAC9C,CAAC;IAEF,MAAM,qBAAqB,GAAG,MAAM,IAAA,4BAAW,EAAC,iBAAiB,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAO,EAAC,qBAAqB,CAAC,MAAM,kCACtD,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,uCACK,IAAA,oCAAuB,EAAC,qBAAqB,CAAC,KACjD,IAAI,EAAE,QAAQ,IACd;AACJ,CAAC","sourcesContent":["/* 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 @esri/arcgis-rest-request!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"]}
@@ -2,7 +2,7 @@
2
2
  /* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
3
3
  * Apache-2.0 */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getApiKey = void 0;
5
+ exports.getApiKey = getApiKey;
6
6
  const getRegisteredAppInfo_js_1 = require("./shared/getRegisteredAppInfo.js");
7
7
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
8
8
  const helpers_js_1 = require("./shared/helpers.js");
@@ -28,7 +28,7 @@ const helpers_js_1 = require("./shared/helpers.js");
28
28
  * });
29
29
  * ```
30
30
  *
31
- * @param requestOptions - Options for {@linkcode getApiKey | getApiKey()}, including `itemId` of which API key to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.
31
+ * @param requestOptions - Options for {@linkcode getApiKey | getApiKey()}, including `itemId` of which API key to retrieve and an {@linkcode @esri/arcgis-rest-request!ArcGISIdentityManager} authentication session.
32
32
  * @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing successfully retrieved API key.
33
33
  */
34
34
  async function getApiKey(requestOptions) {
@@ -36,5 +36,4 @@ async function getApiKey(requestOptions) {
36
36
  const itemInfo = await (0, arcgis_rest_portal_1.getItem)(requestOptions.itemId, Object.assign(Object.assign({}, (0, helpers_js_1.extractBaseRequestOptions)(requestOptions)), { authentication: requestOptions.authentication }));
37
37
  return Object.assign(Object.assign({}, (0, helpers_js_1.appToApiKeyProperties)(appResponse)), { item: itemInfo });
38
38
  }
39
- exports.getApiKey = getApiKey;
40
39
  //# sourceMappingURL=getApiKey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getApiKey.js","sourceRoot":"","sources":["../../src/getApiKey.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,8EAAwE;AAKxE,iEAAmD;AACnD,oDAG6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,SAAS,CAC7B,cAAiC;IAEjC,MAAM,WAAW,GAAG,MAAM,IAAA,8CAAoB,EAAC,cAAc,CAAC,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAO,EAAC,cAAc,CAAC,MAAM,kCAC/C,IAAA,sCAAyB,EAAC,cAAc,CAAC,KAC5C,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,uCACK,IAAA,kCAAqB,EAAC,WAAW,CAAC,KACrC,IAAI,EAAE,QAAQ,IACd;AACJ,CAAC;AAdD,8BAcC","sourcesContent":["/* 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"]}
1
+ {"version":3,"file":"getApiKey.js","sourceRoot":"","sources":["../../src/getApiKey.ts"],"names":[],"mappings":";AAAA;gBACgB;;AAsChB,8BAcC;AAlDD,8EAAwE;AAKxE,iEAAmD;AACnD,oDAG6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,SAAS,CAC7B,cAAiC;IAEjC,MAAM,WAAW,GAAG,MAAM,IAAA,8CAAoB,EAAC,cAAc,CAAC,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAO,EAAC,cAAc,CAAC,MAAM,kCAC/C,IAAA,sCAAyB,EAAC,cAAc,CAAC,KAC5C,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,uCACK,IAAA,kCAAqB,EAAC,WAAW,CAAC,KACrC,IAAI,EAAE,QAAQ,IACd;AACJ,CAAC","sourcesContent":["/* 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 @esri/arcgis-rest-request!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"]}
@@ -2,7 +2,7 @@
2
2
  /* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
3
3
  * Apache-2.0 */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getOAuthApp = void 0;
5
+ exports.getOAuthApp = getOAuthApp;
6
6
  const getRegisteredAppInfo_js_1 = require("./shared/getRegisteredAppInfo.js");
7
7
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
8
8
  const helpers_js_1 = require("./shared/helpers.js");
@@ -28,7 +28,7 @@ const helpers_js_1 = require("./shared/helpers.js");
28
28
  * });
29
29
  * ```
30
30
  *
31
- * @param requestOptions - Options for {@linkcode getOAuthApp | getOAuthApp()}, including `itemId` of which OAuth app to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.
31
+ * @param requestOptions - Options for {@linkcode getOAuthApp | getOAuthApp()}, including `itemId` of which OAuth app to retrieve and an {@linkcode @esri/arcgis-rest-request!ArcGISIdentityManager} authentication session.
32
32
  * @returns A Promise that will resolve to an {@linkcode IOAuthApp} object representing successfully retrieved OAuth app.
33
33
  */
34
34
  async function getOAuthApp(requestOptions) {
@@ -36,5 +36,4 @@ async function getOAuthApp(requestOptions) {
36
36
  const itemInfo = await (0, arcgis_rest_portal_1.getItem)(requestOptions.itemId, Object.assign(Object.assign({}, (0, helpers_js_1.extractBaseRequestOptions)(requestOptions)), { authentication: requestOptions.authentication }));
37
37
  return Object.assign(Object.assign({}, (0, helpers_js_1.appToOAuthAppProperties)(appResponse)), { item: itemInfo });
38
38
  }
39
- exports.getOAuthApp = getOAuthApp;
40
39
  //# sourceMappingURL=getOAuthApp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getOAuthApp.js","sourceRoot":"","sources":["../../src/getOAuthApp.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,8EAAwE;AACxE,iEAAmD;AACnD,oDAG6B;AAG7B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,WAAW,CAC/B,cAAmC;IAEnC,MAAM,WAAW,GAAG,MAAM,IAAA,8CAAoB,EAAC,cAAc,CAAC,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAO,EAAC,cAAc,CAAC,MAAM,kCAC/C,IAAA,sCAAyB,EAAC,cAAc,CAAC,KAC5C,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,uCACK,IAAA,oCAAuB,EAAC,WAAW,CAAC,KACvC,IAAI,EAAE,QAAQ,IACd;AACJ,CAAC;AAdD,kCAcC","sourcesContent":["/* 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"]}
1
+ {"version":3,"file":"getOAuthApp.js","sourceRoot":"","sources":["../../src/getOAuthApp.ts"],"names":[],"mappings":";AAAA;gBACgB;;AAmChB,kCAcC;AA/CD,8EAAwE;AACxE,iEAAmD;AACnD,oDAG6B;AAG7B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,WAAW,CAC/B,cAAmC;IAEnC,MAAM,WAAW,GAAG,MAAM,IAAA,8CAAoB,EAAC,cAAc,CAAC,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAO,EAAC,cAAc,CAAC,MAAM,kCAC/C,IAAA,sCAAyB,EAAC,cAAc,CAAC,KAC5C,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,uCACK,IAAA,oCAAuB,EAAC,WAAW,CAAC,KACvC,IAAI,EAAE,QAAQ,IACd;AACJ,CAAC","sourcesContent":["/* 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 @esri/arcgis-rest-request!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"]}
package/dist/cjs/index.js CHANGED
@@ -3,19 +3,19 @@
3
3
  * Apache-2.0 */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  const tslib_1 = require("tslib");
6
- (0, tslib_1.__exportStar)(require("./createApiKey.js"), exports);
7
- (0, tslib_1.__exportStar)(require("./updateApiKey.js"), exports);
8
- (0, tslib_1.__exportStar)(require("./getApiKey.js"), exports);
9
- (0, tslib_1.__exportStar)(require("./invalidateApiKey.js"), exports);
10
- (0, tslib_1.__exportStar)(require("./getOAuthApp.js"), exports);
11
- (0, tslib_1.__exportStar)(require("./updateOAuthApp.js"), exports);
12
- (0, tslib_1.__exportStar)(require("./createOAuthApp.js"), exports);
13
- (0, tslib_1.__exportStar)(require("./shared/enum/privileges.js"), exports);
14
- (0, tslib_1.__exportStar)(require("./shared/types/appType.js"), exports);
15
- (0, tslib_1.__exportStar)(require("./shared/types/apiKeyType.js"), exports);
16
- (0, tslib_1.__exportStar)(require("./shared/types/oAuthType.js"), exports);
17
- (0, tslib_1.__exportStar)(require("./shared/getRegisteredAppInfo.js"), exports);
18
- (0, tslib_1.__exportStar)(require("./shared/registerApp.js"), exports);
19
- (0, tslib_1.__exportStar)(require("./shared/unregisterApp.js"), exports);
20
- (0, tslib_1.__exportStar)(require("./shared/helpers.js"), exports);
6
+ tslib_1.__exportStar(require("./createApiKey.js"), exports);
7
+ tslib_1.__exportStar(require("./updateApiKey.js"), exports);
8
+ tslib_1.__exportStar(require("./getApiKey.js"), exports);
9
+ tslib_1.__exportStar(require("./invalidateApiKey.js"), exports);
10
+ tslib_1.__exportStar(require("./getOAuthApp.js"), exports);
11
+ tslib_1.__exportStar(require("./updateOAuthApp.js"), exports);
12
+ tslib_1.__exportStar(require("./createOAuthApp.js"), exports);
13
+ tslib_1.__exportStar(require("./shared/enum/privileges.js"), exports);
14
+ tslib_1.__exportStar(require("./shared/types/appType.js"), exports);
15
+ tslib_1.__exportStar(require("./shared/types/apiKeyType.js"), exports);
16
+ tslib_1.__exportStar(require("./shared/types/oAuthType.js"), exports);
17
+ tslib_1.__exportStar(require("./shared/getRegisteredAppInfo.js"), exports);
18
+ tslib_1.__exportStar(require("./shared/registerApp.js"), exports);
19
+ tslib_1.__exportStar(require("./shared/unregisterApp.js"), exports);
20
+ tslib_1.__exportStar(require("./shared/helpers.js"), exports);
21
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,iEAAkC;AAClC,iEAAkC;AAClC,8DAA+B;AAC/B,qEAAsC;AACtC,gEAAiC;AACjC,mEAAoC;AACpC,mEAAoC;AACpC,2EAA4C;AAC5C,yEAA0C;AAC1C,4EAA6C;AAC7C,2EAA4C;AAC5C,gFAAiD;AACjD,uEAAwC;AACxC,yEAA0C;AAC1C,mEAAoC","sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nexport * from \"./createApiKey.js\";\nexport * from \"./updateApiKey.js\";\nexport * from \"./getApiKey.js\";\nexport * from \"./invalidateApiKey.js\";\nexport * from \"./getOAuthApp.js\";\nexport * from \"./updateOAuthApp.js\";\nexport * from \"./createOAuthApp.js\";\nexport * from \"./shared/enum/privileges.js\";\nexport * from \"./shared/types/appType.js\";\nexport * from \"./shared/types/apiKeyType.js\";\nexport * from \"./shared/types/oAuthType.js\";\nexport * from \"./shared/getRegisteredAppInfo.js\";\nexport * from \"./shared/registerApp.js\";\nexport * from \"./shared/unregisterApp.js\";\nexport * from \"./shared/helpers.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,4DAAkC;AAClC,4DAAkC;AAClC,yDAA+B;AAC/B,gEAAsC;AACtC,2DAAiC;AACjC,8DAAoC;AACpC,8DAAoC;AACpC,sEAA4C;AAC5C,oEAA0C;AAC1C,uEAA6C;AAC7C,sEAA4C;AAC5C,2EAAiD;AACjD,kEAAwC;AACxC,oEAA0C;AAC1C,8DAAoC","sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nexport * from \"./createApiKey.js\";\nexport * from \"./updateApiKey.js\";\nexport * from \"./getApiKey.js\";\nexport * from \"./invalidateApiKey.js\";\nexport * from \"./getOAuthApp.js\";\nexport * from \"./updateOAuthApp.js\";\nexport * from \"./createOAuthApp.js\";\nexport * from \"./shared/enum/privileges.js\";\nexport * from \"./shared/types/appType.js\";\nexport * from \"./shared/types/apiKeyType.js\";\nexport * from \"./shared/types/oAuthType.js\";\nexport * from \"./shared/getRegisteredAppInfo.js\";\nexport * from \"./shared/registerApp.js\";\nexport * from \"./shared/unregisterApp.js\";\nexport * from \"./shared/helpers.js\";\n"]}
@@ -2,7 +2,7 @@
2
2
  /* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
3
3
  * Apache-2.0 */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.invalidateApiKey = void 0;
5
+ exports.invalidateApiKey = invalidateApiKey;
6
6
  const getRegisteredAppInfo_js_1 = require("./shared/getRegisteredAppInfo.js");
7
7
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
8
8
  const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
@@ -42,5 +42,4 @@ async function invalidateApiKey(requestOptions) {
42
42
  params
43
43
  });
44
44
  }
45
- exports.invalidateApiKey = invalidateApiKey;
46
45
  //# sourceMappingURL=invalidateApiKey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"invalidateApiKey.js","sourceRoot":"","sources":["../../src/invalidateApiKey.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAMhB,8EAAwE;AACxE,iEAAwD;AACxD,mEAAoD;AACpD,oDAA6D;AAE7D;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,gBAAgB,CACpC,cAAwC;IAExC,MAAM,MAAM,GAAG,IAAA,iCAAY,EAAC,cAAc,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,GAAG,MAAM,qBAAqB,CAAC;IAE3C,MAAM,OAAO,GAAG,MAAM,IAAA,8CAAoB,EAAC;QACzC,MAAM,EAAE,cAAc,CAAC,MAAM;QAC7B,cAAc,EAAE,cAAc,CAAC,cAAc;KAC9C,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,QAAQ,EAAE,IAAA,mCAAsB,EAAC,cAAc,CAAC,MAAM,CAAC;QACvD,kBAAkB,EAAE,IAAI;QACxB,UAAU,EAAE,oBAAoB;KACjC,CAAC;IAEF,2FAA2F;IAC3F,OAAO,IAAA,6BAAO,EAAC,GAAG,EAAE;QAClB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAvBD,4CAuBC","sourcesContent":["/* 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"]}
1
+ {"version":3,"file":"invalidateApiKey.js","sourceRoot":"","sources":["../../src/invalidateApiKey.ts"],"names":[],"mappings":";AAAA;gBACgB;;AA2BhB,4CAuBC;AA5CD,8EAAwE;AACxE,iEAAwD;AACxD,mEAAoD;AACpD,oDAA6D;AAE7D;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,gBAAgB,CACpC,cAAwC;IAExC,MAAM,MAAM,GAAG,IAAA,iCAAY,EAAC,cAAc,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,GAAG,MAAM,qBAAqB,CAAC;IAE3C,MAAM,OAAO,GAAG,MAAM,IAAA,8CAAoB,EAAC;QACzC,MAAM,EAAE,cAAc,CAAC,MAAM;QAC7B,cAAc,EAAE,cAAc,CAAC,cAAc;KAC9C,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,QAAQ,EAAE,IAAA,mCAAsB,EAAC,cAAc,CAAC,MAAM,CAAC;QACvD,kBAAkB,EAAE,IAAI;QACxB,UAAU,EAAE,oBAAoB;KACjC,CAAC;IAEF,2FAA2F;IAC3F,OAAO,IAAA,6BAAO,EAAC,GAAG,EAAE;QAClB,MAAM;KACP,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* 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"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateApiKeyToken = void 0;
3
+ exports.generateApiKeyToken = generateApiKeyToken;
4
4
  const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
5
5
  const getRegisteredAppInfo_js_1 = require("./getRegisteredAppInfo.js");
6
6
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
@@ -23,5 +23,4 @@ async function generateApiKeyToken(options) {
23
23
  params
24
24
  });
25
25
  }
26
- exports.generateApiKeyToken = generateApiKeyToken;
27
26
  //# sourceMappingURL=generateApiKeyToken.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generateApiKeyToken.js","sourceRoot":"","sources":["../../../src/shared/generateApiKeyToken.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AACnC,uEAAiE;AACjE,iEAAwD;AASjD,KAAK,UAAU,mBAAmB,CACvC,OAAoC;IAEpC,MAAM,MAAM,GAAG,IAAA,iCAAY,EAAC,OAAO,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,GAAG,MAAM,eAAe,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,IAAA,8CAAoB,EAAC;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;IAEF,2FAA2F;IAC3F,OAAO,IAAA,6BAAO,EAAC,GAAG,EAAE;QAClB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAvBD,kDAuBC","sourcesContent":["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"]}
1
+ {"version":3,"file":"generateApiKeyToken.js","sourceRoot":"","sources":["../../../src/shared/generateApiKeyToken.ts"],"names":[],"mappings":";;AAeA,kDAuBC;AAtCD,mEAImC;AACnC,uEAAiE;AACjE,iEAAwD;AASjD,KAAK,UAAU,mBAAmB,CACvC,OAAoC;IAEpC,MAAM,MAAM,GAAG,IAAA,iCAAY,EAAC,OAAO,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,GAAG,MAAM,eAAe,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,IAAA,8CAAoB,EAAC;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;IAEF,2FAA2F;IAC3F,OAAO,IAAA,6BAAO,EAAC,GAAG,EAAE;QAClB,MAAM;KACP,CAAC,CAAC;AACL,CAAC","sourcesContent":["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"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRegisteredAppInfo = void 0;
3
+ exports.getRegisteredAppInfo = getRegisteredAppInfo;
4
4
  /* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
5
5
  * Apache-2.0 */
6
6
  const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
@@ -28,7 +28,7 @@ const helpers_js_1 = require("./helpers.js");
28
28
  * });
29
29
  * ```
30
30
  *
31
- * @param requestOptions - Options for {@linkcode getRegisteredAppInfo | getRegisteredAppInfo()}, including an itemId of which app to retrieve and an {@linkcode ArcGISIdentityManager} authentication session.
31
+ * @param requestOptions - Options for {@linkcode getRegisteredAppInfo | getRegisteredAppInfo()}, including an itemId of which app to retrieve and an {@linkcode @esri/arcgis-rest-request!ArcGISIdentityManager} authentication session.
32
32
  * @returns A Promise that will resolve to an {@linkcode IApp} object representing successfully retrieved app.
33
33
  */
34
34
  async function getRegisteredAppInfo(requestOptions) {
@@ -39,5 +39,4 @@ async function getRegisteredAppInfo(requestOptions) {
39
39
  const registeredAppResponse = await (0, arcgis_rest_request_1.request)(url, Object.assign(Object.assign({}, requestOptions), { params: { f: "json" } }));
40
40
  return (0, helpers_js_1.registeredAppResponseToApp)(registeredAppResponse);
41
41
  }
42
- exports.getRegisteredAppInfo = getRegisteredAppInfo;
43
42
  //# sourceMappingURL=getRegisteredAppInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getRegisteredAppInfo.js","sourceRoot":"","sources":["../../../src/shared/getRegisteredAppInfo.ts"],"names":[],"mappings":";;;AAAA;gBACgB;AAChB,mEAAoD;AACpD,iEAAwD;AAOxD,6CAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,oBAAoB,CACxC,cAAkC;IAElC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;IACnE,MAAM,GAAG,GACP,IAAA,iCAAY,EAAC,cAAc,CAAC;QAC5B,kBAAkB,QAAQ,UAAU,cAAc,CAAC,MAAM,oBAAoB,CAAC;IAChF,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,MAAM,qBAAqB,GAA2B,MAAM,IAAA,6BAAO,EAAC,GAAG,kCAClE,cAAc,KACjB,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,OAAO,IAAA,uCAA0B,EAAC,qBAAqB,CAAC,CAAC;AAC3D,CAAC;AAfD,oDAeC","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"]}
1
+ {"version":3,"file":"getRegisteredAppInfo.js","sourceRoot":"","sources":["../../../src/shared/getRegisteredAppInfo.ts"],"names":[],"mappings":";;AAqCA,oDAeC;AApDD;gBACgB;AAChB,mEAAoD;AACpD,iEAAwD;AAOxD,6CAA0D;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,oBAAoB,CACxC,cAAkC;IAElC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;IACnE,MAAM,GAAG,GACP,IAAA,iCAAY,EAAC,cAAc,CAAC;QAC5B,kBAAkB,QAAQ,UAAU,cAAc,CAAC,MAAM,oBAAoB,CAAC;IAChF,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,MAAM,qBAAqB,GAA2B,MAAM,IAAA,6BAAO,EAAC,GAAG,kCAClE,cAAc,KACjB,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,OAAO,IAAA,uCAA0B,EAAC,qBAAqB,CAAC,CAAC;AAC3D,CAAC","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 @esri/arcgis-rest-request!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"]}
@@ -1,6 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildExpirationDateParams = exports.generateOptionsToSlots = exports.generateApiKeyTokens = exports.slotForInvalidationKey = exports.slotForKey = exports.filterKeys = exports.extractBaseRequestOptions = exports.appToOAuthAppProperties = exports.appToApiKeyProperties = exports.registeredAppResponseToApp = exports.stringifyArrays = void 0;
3
+ exports.stringifyArrays = void 0;
4
+ exports.registeredAppResponseToApp = registeredAppResponseToApp;
5
+ exports.appToApiKeyProperties = appToApiKeyProperties;
6
+ exports.appToOAuthAppProperties = appToOAuthAppProperties;
7
+ exports.extractBaseRequestOptions = extractBaseRequestOptions;
8
+ exports.filterKeys = filterKeys;
9
+ exports.slotForKey = slotForKey;
10
+ exports.slotForInvalidationKey = slotForInvalidationKey;
11
+ exports.generateApiKeyTokens = generateApiKeyTokens;
12
+ exports.generateOptionsToSlots = generateOptionsToSlots;
13
+ exports.buildExpirationDateParams = buildExpirationDateParams;
4
14
  const generateApiKeyToken_js_1 = require("./generateApiKeyToken.js");
5
15
  /**
6
16
  * @internal
@@ -40,7 +50,6 @@ function registeredAppResponseToApp(response) {
40
50
  return obj;
41
51
  }, {});
42
52
  }
43
- exports.registeredAppResponseToApp = registeredAppResponseToApp;
44
53
  /**
45
54
  * @internal
46
55
  * Used to convert {@linkcode IApp} to {@linkcode IApiKeyInfo} only if `appType` is "apikey".
@@ -53,7 +62,6 @@ function appToApiKeyProperties(response) {
53
62
  delete response.apiKey;
54
63
  return response;
55
64
  }
56
- exports.appToApiKeyProperties = appToApiKeyProperties;
57
65
  /**
58
66
  * @internal
59
67
  * Used to convert {@linkcode IApp} to {@linkcode IOAuthAppInfo}.
@@ -69,7 +77,6 @@ function appToOAuthAppProperties(response) {
69
77
  delete response.apiToken2Active;
70
78
  return response;
71
79
  }
72
- exports.appToOAuthAppProperties = appToOAuthAppProperties;
73
80
  /**
74
81
  * @internal
75
82
  * Used to extract base request options from a hybrid option and exclude `params` and `authentication`.
@@ -88,7 +95,6 @@ function extractBaseRequestOptions(options) {
88
95
  ];
89
96
  return filterKeys(options, requestOptionsProperties);
90
97
  }
91
- exports.extractBaseRequestOptions = extractBaseRequestOptions;
92
98
  /**
93
99
  * @internal
94
100
  * Used to create a new object including only specified keys from another object.
@@ -101,7 +107,6 @@ function filterKeys(object, includedKeys) {
101
107
  return obj;
102
108
  }, {});
103
109
  }
104
- exports.filterKeys = filterKeys;
105
110
  /**
106
111
  * 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.
107
112
  */
@@ -112,7 +117,6 @@ function slotForKey(key) {
112
117
  }
113
118
  return undefined;
114
119
  }
115
- exports.slotForKey = slotForKey;
116
120
  /**
117
121
  * @internal
118
122
  * Used to determine which slot to invalidate a key in given a number or a full or patial key.
@@ -129,7 +133,6 @@ function slotForInvalidationKey(param) {
129
133
  return fullKeySlot;
130
134
  }
131
135
  }
132
- exports.slotForInvalidationKey = slotForInvalidationKey;
133
136
  /**
134
137
  * @internal
135
138
  * Used to generate tokens in slot 1 and/or 2 of an API key.
@@ -146,7 +149,6 @@ function generateApiKeyTokens(itemId, slots, requestOptions) {
146
149
  }, {});
147
150
  });
148
151
  }
149
- exports.generateApiKeyTokens = generateApiKeyTokens;
150
152
  /**
151
153
  * @internal
152
154
  * Convert boolean flags to an array of slots for {@linkcode generateApiKeyTokens}.
@@ -161,7 +163,6 @@ function generateOptionsToSlots(generateToken1, generateToken2) {
161
163
  }
162
164
  return slots;
163
165
  }
164
- exports.generateOptionsToSlots = generateOptionsToSlots;
165
166
  /**
166
167
  * @internal
167
168
  * Build params for updating expiration dates
@@ -184,5 +185,4 @@ function buildExpirationDateParams(requestOptions, fillDefaults) {
184
185
  }
185
186
  return updateparams;
186
187
  }
187
- exports.buildExpirationDateParams = buildExpirationDateParams;
188
188
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/shared/helpers.ts"],"names":[],"mappings":";;;AAOA,qEAA+D;AAE/D;;;GAGG;AACI,MAAM,eAAe,GAAG,CAAC,cAA+B,EAAE,EAAE;IACjE,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACtD,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;QAC3B,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE;YACtC,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SACpD;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAPW,QAAA,eAAe,mBAO1B;AAEF;;;GAGG;AACH,SAAgB,0BAA0B,CACxC,QAAgC;IAEhC,MAAM,WAAW,GAAG;QAClB,cAAc;QACd,iBAAiB;QACjB,WAAW;QACX,QAAQ;QACR,0BAA0B;KAC3B,CAAC;IACF,MAAM,QAAQ,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAE5C,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SAC3C,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAG,EAAE,EAAE;QACxB,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,CAAE,QAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;SAC7C;aAAM;YACL,GAAG,CAAC,GAAG,CAAC,GAAI,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se, 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"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/shared/helpers.ts"],"names":[],"mappings":";;;AA0BA,gEAsBC;AAMD,sDAQC;AAMD,0DAWC;AAMD,8DAgBC;AAMD,gCAaC;AAKD,gCAQC;AAMD,wDAaC;AAUD,oDAqBC;AAMD,wDAYC;AAmBD,8DA0BC;AA/OD,qEAA+D;AAE/D;;;GAGG;AACI,MAAM,eAAe,GAAG,CAAC,cAA+B,EAAE,EAAE;IACjE,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAA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,cAAuB,EACvB,cAAuB;IAEvB,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,IAAI,cAAc,EAAE,CAAC;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,IAAI,cAAc,EAAE,CAAC;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAeD;;;GAGG;AACH,SAAgB,yBAAyB,CACvC,cAGC,EACD,YAAsB;IAEtB,MAAM,YAAY,GAAQ,EAAE,CAAC;IAC7B,IAAI,cAAc,CAAC,uBAAuB,EAAE,CAAC;QAC3C,YAAY,CAAC,uBAAuB;YAClC,cAAc,CAAC,uBAAuB,CAAC;IAC3C,CAAC;IAED,IAAI,cAAc,CAAC,uBAAuB,EAAE,CAAC;QAC3C,YAAY,CAAC,uBAAuB;YAClC,cAAc,CAAC,uBAAuB,CAAC;IAC3C,CAAC;IAED,IAAI,YAAY,IAAI,CAAC,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAC1D,YAAY,CAAC,uBAAuB,GAAG,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,YAAY,IAAI,CAAC,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAC1D,YAAY,CAAC,uBAAuB,GAAG,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["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"]}
@@ -2,7 +2,7 @@
2
2
  /* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
3
3
  * Apache-2.0 */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.registerApp = void 0;
5
+ exports.registerApp = registerApp;
6
6
  const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
7
7
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
8
8
  const helpers_js_1 = require("./helpers.js");
@@ -39,7 +39,7 @@ const helpers_js_1 = require("./helpers.js");
39
39
  * });
40
40
  * ```
41
41
  *
42
- * @param requestOptions - Options for {@linkcode registerApp | registerApp()}, including necessary params to register an app and an {@linkcode ArcGISIdentityManager} authentication session.
42
+ * @param requestOptions - Options for {@linkcode registerApp | registerApp()}, including necessary params to register an app and an {@linkcode @esri/arcgis-rest-request!ArcGISIdentityManager} authentication session.
43
43
  * @returns A Promise that will resolve to an {@linkcode IApp} object representing the newly registered app.
44
44
  */
45
45
  async function registerApp(requestOptions) {
@@ -59,5 +59,4 @@ async function registerApp(requestOptions) {
59
59
  const registeredAppResponse = await (0, arcgis_rest_request_1.request)(url, options);
60
60
  return (0, helpers_js_1.registeredAppResponseToApp)(registeredAppResponse);
61
61
  }
62
- exports.registerApp = registerApp;
63
62
  //# sourceMappingURL=registerApp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerApp.js","sourceRoot":"","sources":["../../../src/shared/registerApp.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,mEAAwE;AACxE,iEAAwD;AAMxD,6CAA2E;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACI,KAAK,UAAU,WAAW,CAC/B,cAAmC;IAEnC,eAAe;IACf,MAAM,OAAO,GAAG,IAAA,wCAAkB,EAAC,cAAc,EAAE;QACjD,QAAQ;QACR,SAAS;QACT,eAAe;QACf,eAAe;QACf,YAAY;KACb,CAAC,CAAC;IACH,mHAAmH;IACnH,IAAA,4BAAe,EAAC,OAAO,CAAC,CAAC;IAEzB,MAAM,GAAG,GAAG,IAAA,iCAAY,EAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC;IAC1D,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC;IAC5B,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC;IAE1B,MAAM,qBAAqB,GAA2B,MAAM,IAAA,6BAAO,EACjE,GAAG,EACH,OAAO,CACR,CAAC;IAEF,OAAO,IAAA,uCAA0B,EAAC,qBAAqB,CAAC,CAAC;AAC3D,CAAC;AAxBD,kCAwBC","sourcesContent":["/* 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"]}
1
+ {"version":3,"file":"registerApp.js","sourceRoot":"","sources":["../../../src/shared/registerApp.ts"],"names":[],"mappings":";AAAA;gBACgB;;AA+ChB,kCAwBC;AArED,mEAAwE;AACxE,iEAAwD;AAMxD,6CAA2E;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACI,KAAK,UAAU,WAAW,CAC/B,cAAmC;IAEnC,eAAe;IACf,MAAM,OAAO,GAAG,IAAA,wCAAkB,EAAC,cAAc,EAAE;QACjD,QAAQ;QACR,SAAS;QACT,eAAe;QACf,eAAe;QACf,YAAY;KACb,CAAC,CAAC;IACH,mHAAmH;IACnH,IAAA,4BAAe,EAAC,OAAO,CAAC,CAAC;IAEzB,MAAM,GAAG,GAAG,IAAA,iCAAY,EAAC,OAAO,CAAC,GAAG,qBAAqB,CAAC;IAC1D,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC;IAC5B,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC;IAE1B,MAAM,qBAAqB,GAA2B,MAAM,IAAA,6BAAO,EACjE,GAAG,EACH,OAAO,CACR,CAAC;IAEF,OAAO,IAAA,uCAA0B,EAAC,qBAAqB,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/* 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 @esri/arcgis-rest-request!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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"apiKeyType.js","sourceRoot":"","sources":["../../../../src/shared/types/apiKeyType.ts"],"names":[],"mappings":"","sourcesContent":["import {\n IAuthenticationManager,\n IRequestOptions,\n ISpatialReference\n} from \"@esri/arcgis-rest-request\";\nimport { IRegisterAppOptions, IApp } from \"./appType.js\";\nimport { Privileges } from \"../enum/privileges.js\";\nimport { IItem } from \"@esri/arcgis-rest-portal\";\n\n/**\n * Options to register an API Key.\n */\nexport interface ICreateApiKeyOptions\n extends Omit<\n IRegisterAppOptions,\n \"itemId\" | \"redirect_uris\" | \"appType\" | \"httpReferrers\"\n > {\n httpReferrers?: string[];\n title: string;\n owner?: string;\n typeKeywords?: string[];\n description?: string;\n snippet?: string;\n documentation?: string;\n extent?: number[][];\n categories?: string[];\n spatialReference?: ISpatialReference;\n culture?: string;\n properties?: any;\n url?: string;\n tags?: string[];\n /**\n * Expiration date of the access token in slot 1 of this API Key.\n */\n apiToken1ExpirationDate?: Date;\n /**\n * Expiration date of the access token in slot 2 of this API Key.\n */\n apiToken2ExpirationDate?: Date;\n /**\n * Generate a new access token in slot 1 of this API. Will override and invalidate any existing token.\n */\n generateToken1?: boolean;\n /**\n * Generate a new access token in slot 2 of this API. Will override and invalidate any existing token.\n */\n generateToken2?: boolean;\n}\n\n/**\n * Options to retrieve an API Key.\n */\nexport interface IGetApiKeyOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which API key to be retrieved.\n */\n itemId: string;\n}\n\n/**\n * Represent only the API key related properties from {@linkcode IApp}.\n */\nexport interface IApiKeyInfo\n extends Omit<IApp, \"client_secret\" | \"redirect_uris\" | \"appType\"> {}\n\n/**\n * Return value of {@linkcode createApiKey}, {@linkcode getApiKey}, {@linkcode updateApiKey} representing an API Key entity. `accessToken1`/`accessToken2` properties are only available when `generateToken1`/`generateToken2` are `true`.\n */\nexport interface IApiKeyResponse extends IApiKeyInfo {\n /**\n * Represent item info attached to this API Key.\n */\n item: IItem;\n accessToken1?: null | string;\n accessToken2?: null | string;\n}\n\n/**\n * Options to update an API Key.\n */\nexport interface IUpdateApiKeyOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which API key will be updated.\n */\n itemId: string;\n /**\n * Override previous `httpReferrers` if this value is provided.\n */\n httpReferrers?: string[];\n /**\n * Override previous `privileges` if this value is provided.\n */\n privileges?: string[];\n /**\n * Expiration date of the access token in slot 1 of this API Key.\n */\n apiToken1ExpirationDate?: Date;\n /**\n * Expiration date of the access token in slot 2 of this API Key.\n */\n apiToken2ExpirationDate?: Date;\n /**\n * Generate a new access token in slot 1 of this API. Will override and invalidate any existing token.\n */\n generateToken1?: boolean;\n /**\n * Generate a new access token in slot 2 of this API. Will override and invalidate any existing token.\n */\n generateToken2?: boolean;\n}\n\n/**\n * Options to delete an API key.\n */\nexport interface IDeleteApiKeyOption extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which API key to be removed.\n */\n itemId: string;\n}\n\n/**\n * Response of API key deletion.\n */\nexport interface IDeleteApiKeyResponse {\n /**\n * itemId of which API key has been removed.\n */\n itemId: string;\n success: boolean;\n}\n\nexport interface IInvalidateApiKeyOptions\n extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of the item of the API key to be revoked.\n */\n itemId: string;\n /**\n * The API key to be revoked. The full or partial API key or the slot number (1 or 2) can be provided.\n */\n apiKey?: string | 1 | 2;\n}\n\nexport interface IInvalidateApiKeyResponse {\n success: boolean;\n}\n"]}
1
+ {"version":3,"file":"apiKeyType.js","sourceRoot":"","sources":["../../../../src/shared/types/apiKeyType.ts"],"names":[],"mappings":"","sourcesContent":["import {\n IAuthenticationManager,\n IRequestOptions,\n ISpatialReference\n} from \"@esri/arcgis-rest-request\";\nimport { IRegisterAppOptions, IApp } from \"./appType.js\";\nimport { Privileges } from \"../enum/privileges.js\";\nimport { IItem } from \"@esri/arcgis-rest-portal\";\n\n/**\n * Options to register an API Key.\n */\nexport interface ICreateApiKeyOptions\n extends Omit<\n IRegisterAppOptions,\n \"itemId\" | \"redirect_uris\" | \"appType\" | \"httpReferrers\"\n > {\n httpReferrers?: string[];\n title: string;\n owner?: string;\n typeKeywords?: string[];\n description?: string;\n snippet?: string;\n documentation?: string;\n extent?: number[][];\n categories?: string[];\n spatialReference?: ISpatialReference;\n culture?: string;\n properties?: any;\n url?: string;\n tags?: string[];\n /**\n * Expiration date of the access token in slot 1 of this API Key.\n */\n apiToken1ExpirationDate?: Date;\n /**\n * Expiration date of the access token in slot 2 of this API Key.\n */\n apiToken2ExpirationDate?: Date;\n /**\n * Generate a new access token in slot 1 of this API. Will override and invalidate any existing token.\n */\n generateToken1?: boolean;\n /**\n * Generate a new access token in slot 2 of this API. Will override and invalidate any existing token.\n */\n generateToken2?: boolean;\n}\n\n/**\n * Options to retrieve an API Key.\n */\nexport interface IGetApiKeyOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which API key to be retrieved.\n */\n itemId: string;\n}\n\n/**\n * Represent only the API key related properties from {@linkcode IApp}.\n */\nexport interface IApiKeyInfo\n extends Omit<IApp, \"client_secret\" | \"redirect_uris\" | \"appType\"> {}\n\n/**\n * Return value of {@linkcode createApiKey}, {@linkcode getApiKey}, {@linkcode updateApiKey} representing an API Key entity. `accessToken1`/`accessToken2` properties are only available when `generateToken1`/`generateToken2` are `true`.\n */\nexport interface IApiKeyResponse extends IApiKeyInfo {\n /**\n * Represent item info attached to this API Key.\n */\n item: IItem;\n accessToken1?: null | string;\n accessToken2?: null | string;\n}\n\n/**\n * Options to update an API Key.\n */\nexport interface IUpdateApiKeyOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which API key will be updated.\n */\n itemId: string;\n /**\n * Override previous `httpReferrers` if this value is provided.\n */\n httpReferrers?: string[];\n /**\n * Override previous `privileges` if this value is provided.\n */\n privileges?: string[];\n /**\n * Expiration date of the access token in slot 1 of this API Key.\n */\n apiToken1ExpirationDate?: Date;\n /**\n * Expiration date of the access token in slot 2 of this API Key.\n */\n apiToken2ExpirationDate?: Date;\n /**\n * Generate a new access token in slot 1 of this API. Will override and invalidate any existing token.\n */\n generateToken1?: boolean;\n /**\n * Generate a new access token in slot 2 of this API. Will override and invalidate any existing token.\n */\n generateToken2?: boolean;\n}\n\n/**\n * Options to delete an API key.\n */\nexport interface IDeleteApiKeyOption extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which API key to be removed.\n */\n itemId: string;\n}\n\n/**\n * Response of API key deletion.\n */\nexport interface IDeleteApiKeyResponse {\n /**\n * itemId of which API key has been removed.\n */\n itemId: string;\n success: boolean;\n}\n\nexport interface IInvalidateApiKeyOptions\n extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of the item of the API key to be revoked.\n */\n itemId: string;\n /**\n * The API key to be revoked. The full or partial API key or the slot number (1 or 2) can be provided.\n */\n apiKey?: string | 1 | 2;\n}\n\nexport interface IInvalidateApiKeyResponse {\n success: boolean;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"appType.js","sourceRoot":"","sources":["../../../../src/shared/types/appType.ts"],"names":[],"mappings":"","sourcesContent":["import {\n IRequestOptions,\n IAuthenticationManager\n} from \"@esri/arcgis-rest-request\";\nimport { UnixTime } from \"@esri/arcgis-rest-portal\";\nimport { Privileges } from \"../enum/privileges.js\";\n\n/**\n * Accepted app types.\n */\nexport type AppType = \"apikey\" | \"browser\" | \"native\" | \"server\" | \"multiple\";\n\n/**\n * Options to register an app.\n */\nexport interface IRegisterAppOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * itemId that the newly registered app will be based on.\n */\n itemId: string;\n /**\n * App types. For more info, refer to {@linkcode AppType}.\n */\n appType: AppType;\n /**\n * Redirect URIs set for this app.\n */\n redirect_uris: string[];\n /**\n * Http Referrers set for this app.\n */\n httpReferrers: string[];\n /**\n * Privilege lists. For more info, refer to {@linkcode Privileges}.\n */\n privileges: Privileges;\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n}\n\n/**\n * Options to retrieve an app.\n */\nexport interface IGetAppInfoOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which app to be retrieved.\n */\n itemId: string;\n}\n\n/**\n * Raw response of app related endpoints calls.\n */\nexport interface IRegisteredAppResponse {\n itemId: string;\n /**\n * Only to be present if appType is apikey\n */\n apiKey?: string;\n appType: AppType;\n client_id: string;\n client_secret: string;\n httpReferrers: string[];\n redirect_uris: string[];\n privileges: string[];\n registered: UnixTime;\n modified: UnixTime;\n apnsProdCert: any;\n apnsSandboxCert: any;\n gcmApiKey: any;\n isBeta: boolean;\n customAppLoginShowTriage: boolean;\n isPersonalAPIToken: boolean;\n apiToken1Active: boolean;\n apiToken2Active: boolean;\n}\n\n/**\n * Return value of {@linkcode registerApp} and {@linkcode getRegisteredAppInfo} representing an app entity.\n */\nexport interface IApp\n extends Omit<\n IRegisteredAppResponse,\n | \"registered\"\n | \"modified\"\n | \"apnsProdCert\"\n | \"apnsSandboxCert\"\n | \"gcmApiKey\"\n | \"isBeta\"\n | \"customAppLoginShowTriage\"\n > {\n registered: Date;\n modified: Date;\n}\n\n/**\n * Options to unregister an app.\n */\nexport interface IUnregisterAppOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which app to be unregistered.\n */\n itemId: string;\n}\n\n/**\n * Response of app un-registration.\n */\nexport interface IUnregisterAppResponse {\n success: true | false;\n /**\n * itemId of which app has been unregistered.\n */\n itemId: string;\n}\n"]}
1
+ {"version":3,"file":"appType.js","sourceRoot":"","sources":["../../../../src/shared/types/appType.ts"],"names":[],"mappings":"","sourcesContent":["import {\n IRequestOptions,\n IAuthenticationManager\n} from \"@esri/arcgis-rest-request\";\nimport { UnixTime } from \"@esri/arcgis-rest-portal\";\nimport { Privileges } from \"../enum/privileges.js\";\n\n/**\n * Accepted app types.\n */\nexport type AppType = \"apikey\" | \"browser\" | \"native\" | \"server\" | \"multiple\";\n\n/**\n * Options to register an app.\n */\nexport interface IRegisterAppOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * itemId that the newly registered app will be based on.\n */\n itemId: string;\n /**\n * App types. For more info, refer to {@linkcode AppType}.\n */\n appType: AppType;\n /**\n * Redirect URIs set for this app.\n */\n redirect_uris: string[];\n /**\n * Http Referrers set for this app.\n */\n httpReferrers: string[];\n /**\n * Privilege lists. For more info, refer to {@linkcode Privileges}.\n */\n privileges: Privileges;\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n}\n\n/**\n * Options to retrieve an app.\n */\nexport interface IGetAppInfoOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which app to be retrieved.\n */\n itemId: string;\n}\n\n/**\n * Raw response of app related endpoints calls.\n */\nexport interface IRegisteredAppResponse {\n itemId: string;\n /**\n * Only to be present if appType is apikey\n */\n apiKey?: string;\n appType: AppType;\n client_id: string;\n client_secret: string;\n httpReferrers: string[];\n redirect_uris: string[];\n privileges: string[];\n registered: UnixTime;\n modified: UnixTime;\n apnsProdCert: any;\n apnsSandboxCert: any;\n gcmApiKey: any;\n isBeta: boolean;\n customAppLoginShowTriage: boolean;\n isPersonalAPIToken: boolean;\n apiToken1Active: boolean;\n apiToken2Active: boolean;\n}\n\n/**\n * Return value of {@linkcode registerApp} and {@linkcode getRegisteredAppInfo} representing an app entity.\n */\nexport interface IApp\n extends Omit<\n IRegisteredAppResponse,\n | \"registered\"\n | \"modified\"\n | \"apnsProdCert\"\n | \"apnsSandboxCert\"\n | \"gcmApiKey\"\n | \"isBeta\"\n | \"customAppLoginShowTriage\"\n > {\n registered: Date;\n modified: Date;\n}\n\n/**\n * Options to unregister an app.\n */\nexport interface IUnregisterAppOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which app to be unregistered.\n */\n itemId: string;\n}\n\n/**\n * Response of app un-registration.\n */\nexport interface IUnregisterAppResponse {\n success: true | false;\n /**\n * itemId of which app has been unregistered.\n */\n itemId: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"oAuthType.js","sourceRoot":"","sources":["../../../../src/shared/types/oAuthType.ts"],"names":[],"mappings":"","sourcesContent":["import { IItem } from \"@esri/arcgis-rest-portal\";\nimport {\n IAuthenticationManager,\n IRequestOptions,\n ISpatialReference\n} from \"@esri/arcgis-rest-request\";\n\n/**\n * Options to register an OAuth2.0 app.\n */\nexport interface ICreateOAuthAppOption extends Omit<IRequestOptions, \"params\"> {\n /**\n * Redirect URIs set for this OAuth2.0 app.\n */\n redirect_uris?: string[];\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n title: string;\n owner?: string;\n typeKeywords?: string[];\n description?: string;\n snippet?: string;\n documentation?: string;\n extent?: number[][];\n categories?: string[];\n spatialReference?: ISpatialReference;\n culture?: string;\n properties?: any;\n url?: string;\n tags?: string[];\n}\n\n/**\n * Options to retrieve an OAuth2.0 app.\n */\nexport interface IGetOAuthAppOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which OAuth2.0 app to be retrieved.\n */\n itemId: string;\n}\n\n/**\n * Options to update an OAuth2.0 app.\n */\nexport interface IUpdateOAuthOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which OAuth2.0 app to be updated.\n */\n itemId: string;\n /**\n * Override previous `redirect_uris` if this value is provided.\n */\n redirect_uris?: string[];\n}\n\n/**\n * Represent only the OAuth2.0 app related properties from {@linkcode IApp}.\n */\nexport interface IOAuthAppInfo {\n itemId: string;\n client_id: string;\n client_secret: string;\n redirect_uris: string[];\n registered: Date;\n modified: Date;\n}\n\n/**\n * Return value of {@linkcode createOAuthApp}, {@linkcode getOAuthApp}, {@linkcode updateOAuthApp} representing an OAuth2.0 app entity.\n */\nexport interface IOAuthApp extends IOAuthAppInfo {\n /**\n * Represent item info attached to this OAuth2.0 app.\n */\n item: IItem;\n}\n\n/**\n * Options to delete an OAuth2.0 app.\n */\nexport interface IDeleteOAuthAppOption extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which OAuth2.0 app to be removed.\n */\n itemId: string;\n}\n\n/**\n * Response of OAuth2.0 app deletion.\n */\nexport interface IDeleteOAuthAppResponse {\n /**\n * itemId of which OAuth2.0 app has been removed.\n */\n itemId: string;\n success: boolean;\n}\n"]}
1
+ {"version":3,"file":"oAuthType.js","sourceRoot":"","sources":["../../../../src/shared/types/oAuthType.ts"],"names":[],"mappings":"","sourcesContent":["import { IItem } from \"@esri/arcgis-rest-portal\";\nimport {\n IAuthenticationManager,\n IRequestOptions,\n ISpatialReference\n} from \"@esri/arcgis-rest-request\";\n\n/**\n * Options to register an OAuth2.0 app.\n */\nexport interface ICreateOAuthAppOption extends Omit<IRequestOptions, \"params\"> {\n /**\n * Redirect URIs set for this OAuth2.0 app.\n */\n redirect_uris?: string[];\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n title: string;\n owner?: string;\n typeKeywords?: string[];\n description?: string;\n snippet?: string;\n documentation?: string;\n extent?: number[][];\n categories?: string[];\n spatialReference?: ISpatialReference;\n culture?: string;\n properties?: any;\n url?: string;\n tags?: string[];\n}\n\n/**\n * Options to retrieve an OAuth2.0 app.\n */\nexport interface IGetOAuthAppOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which OAuth2.0 app to be retrieved.\n */\n itemId: string;\n}\n\n/**\n * Options to update an OAuth2.0 app.\n */\nexport interface IUpdateOAuthOptions extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which OAuth2.0 app to be updated.\n */\n itemId: string;\n /**\n * Override previous `redirect_uris` if this value is provided.\n */\n redirect_uris?: string[];\n}\n\n/**\n * Represent only the OAuth2.0 app related properties from {@linkcode IApp}.\n */\nexport interface IOAuthAppInfo {\n itemId: string;\n client_id: string;\n client_secret: string;\n redirect_uris: string[];\n registered: Date;\n modified: Date;\n}\n\n/**\n * Return value of {@linkcode createOAuthApp}, {@linkcode getOAuthApp}, {@linkcode updateOAuthApp} representing an OAuth2.0 app entity.\n */\nexport interface IOAuthApp extends IOAuthAppInfo {\n /**\n * Represent item info attached to this OAuth2.0 app.\n */\n item: IItem;\n}\n\n/**\n * Options to delete an OAuth2.0 app.\n */\nexport interface IDeleteOAuthAppOption extends Omit<IRequestOptions, \"params\"> {\n /**\n * {@linkcode @esri/arcgis-rest-request!IAuthenticationManager} authentication.\n */\n authentication: IAuthenticationManager;\n /**\n * itemId of which OAuth2.0 app to be removed.\n */\n itemId: string;\n}\n\n/**\n * Response of OAuth2.0 app deletion.\n */\nexport interface IDeleteOAuthAppResponse {\n /**\n * itemId of which OAuth2.0 app has been removed.\n */\n itemId: string;\n success: boolean;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unregisterApp = void 0;
3
+ exports.unregisterApp = unregisterApp;
4
4
  const helpers_js_1 = require("./helpers.js");
5
5
  const getRegisteredAppInfo_js_1 = require("./getRegisteredAppInfo.js");
6
6
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
@@ -27,7 +27,7 @@ const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
27
27
  * });
28
28
  * ```
29
29
  *
30
- * @param requestOptions - Options for {@linkcode unregisterApp | unregisterApp()}, including `itemId` of which app to be un-registered and an {@linkcode ArcGISIdentityManager} authentication session.
30
+ * @param requestOptions - Options for {@linkcode unregisterApp | unregisterApp()}, including `itemId` of which app to be un-registered and an {@linkcode @esri/arcgis-rest-request!ArcGISIdentityManager} authentication session.
31
31
  * @returns A Promise that will resolve to an {@linkcode IUnregisterAppResponse} object representing un-registration status.
32
32
  */
33
33
  async function unregisterApp(requestOptions) {
@@ -41,5 +41,4 @@ async function unregisterApp(requestOptions) {
41
41
  const unregisterAppResponse = await (0, arcgis_rest_request_1.request)(url, Object.assign(Object.assign({}, baseRequestOptions), { authentication: requestOptions.authentication, params: { f: "json" } }));
42
42
  return unregisterAppResponse;
43
43
  }
44
- exports.unregisterApp = unregisterApp;
45
44
  //# sourceMappingURL=unregisterApp.js.map