@esri/arcgis-rest-developer-credentials 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled/developer-credentials.esm.js +178 -178
- package/dist/bundled/developer-credentials.esm.js.map +1 -1
- package/dist/bundled/developer-credentials.esm.min.js +3 -3
- package/dist/bundled/developer-credentials.esm.min.js.map +1 -1
- package/dist/bundled/developer-credentials.umd.js +179 -178
- package/dist/bundled/developer-credentials.umd.js.map +1 -1
- package/dist/bundled/developer-credentials.umd.min.js +3 -3
- package/dist/bundled/developer-credentials.umd.min.js.map +1 -1
- package/dist/cjs/createApiKey.js +29 -10
- package/dist/cjs/createApiKey.js.map +1 -1
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/shared/enum/privileges.js +0 -27
- package/dist/cjs/shared/enum/privileges.js.map +1 -1
- package/dist/cjs/shared/generateApiKeyToken.js +27 -0
- package/dist/cjs/shared/generateApiKeyToken.js.map +1 -0
- package/dist/cjs/shared/helpers.js +73 -16
- package/dist/cjs/shared/helpers.js.map +1 -1
- package/dist/cjs/shared/registerApp.js +0 -4
- package/dist/cjs/shared/registerApp.js.map +1 -1
- package/dist/cjs/shared/types/apiKeyType.js.map +1 -1
- package/dist/cjs/shared/types/appType.js.map +1 -1
- package/dist/cjs/updateApiKey.js +24 -13
- package/dist/cjs/updateApiKey.js.map +1 -1
- package/dist/esm/createApiKey.d.ts +1 -1
- package/dist/esm/createApiKey.js +31 -12
- package/dist/esm/createApiKey.js.map +1 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/shared/enum/privileges.d.ts +2 -23
- package/dist/esm/shared/enum/privileges.js +1 -26
- package/dist/esm/shared/enum/privileges.js.map +1 -1
- package/dist/esm/shared/generateApiKeyToken.d.ts +11 -0
- package/dist/esm/shared/generateApiKeyToken.js +23 -0
- package/dist/esm/shared/generateApiKeyToken.js.map +1 -0
- package/dist/esm/shared/helpers.d.ts +37 -7
- package/dist/esm/shared/helpers.js +68 -14
- package/dist/esm/shared/helpers.js.map +1 -1
- package/dist/esm/shared/registerApp.js +1 -5
- package/dist/esm/shared/registerApp.js.map +1 -1
- package/dist/esm/shared/types/apiKeyType.d.ts +37 -5
- package/dist/esm/shared/types/apiKeyType.js.map +1 -1
- package/dist/esm/shared/types/appType.d.ts +7 -3
- package/dist/esm/shared/types/appType.js.map +1 -1
- package/dist/esm/updateApiKey.js +26 -15
- package/dist/esm/updateApiKey.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/deleteApiKey.js +0 -43
- package/dist/cjs/deleteApiKey.js.map +0 -1
- package/dist/cjs/deleteOAuthApp.js +0 -43
- package/dist/cjs/deleteOAuthApp.js.map +0 -1
- package/dist/esm/deleteApiKey.d.ts +0 -27
- package/dist/esm/deleteApiKey.js +0 -39
- package/dist/esm/deleteApiKey.js.map +0 -1
- package/dist/esm/deleteOAuthApp.d.ts +0 -27
- package/dist/esm/deleteOAuthApp.js +0 -39
- package/dist/esm/deleteOAuthApp.js.map +0 -1
|
@@ -28,7 +28,7 @@ export interface IRegisterAppOptions extends Omit<IRequestOptions, "params"> {
|
|
|
28
28
|
/**
|
|
29
29
|
* Privilege lists. For more info, refer to {@linkcode Privileges}.
|
|
30
30
|
*/
|
|
31
|
-
privileges:
|
|
31
|
+
privileges: Privileges;
|
|
32
32
|
/**
|
|
33
33
|
* {@linkcode IAuthenticationManager} authentication.
|
|
34
34
|
*/
|
|
@@ -61,18 +61,22 @@ export interface IRegisteredAppResponse {
|
|
|
61
61
|
client_secret: string;
|
|
62
62
|
httpReferrers: string[];
|
|
63
63
|
redirect_uris: string[];
|
|
64
|
-
privileges:
|
|
64
|
+
privileges: string[];
|
|
65
65
|
registered: UnixTime;
|
|
66
66
|
modified: UnixTime;
|
|
67
67
|
apnsProdCert: any;
|
|
68
68
|
apnsSandboxCert: any;
|
|
69
69
|
gcmApiKey: any;
|
|
70
70
|
isBeta: boolean;
|
|
71
|
+
customAppLoginShowTriage: boolean;
|
|
72
|
+
isPersonalAPIToken: boolean;
|
|
73
|
+
apiToken1Active: boolean;
|
|
74
|
+
apiToken2Active: boolean;
|
|
71
75
|
}
|
|
72
76
|
/**
|
|
73
77
|
* Return value of {@linkcode registerApp} and {@linkcode getRegisteredAppInfo} representing an app entity.
|
|
74
78
|
*/
|
|
75
|
-
export interface IApp extends Omit<IRegisteredAppResponse, "registered" | "modified" | "apnsProdCert" | "apnsSandboxCert" | "gcmApiKey" | "isBeta"> {
|
|
79
|
+
export interface IApp extends Omit<IRegisteredAppResponse, "registered" | "modified" | "apnsProdCert" | "apnsSandboxCert" | "gcmApiKey" | "isBeta" | "customAppLoginShowTriage"> {
|
|
76
80
|
registered: Date;
|
|
77
81
|
modified: Date;
|
|
78
82
|
}
|
|
@@ -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:
|
|
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"]}
|
package/dist/esm/updateApiKey.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
|
|
2
2
|
* Apache-2.0 */
|
|
3
3
|
import { getRegisteredAppInfo } from "./shared/getRegisteredAppInfo.js";
|
|
4
|
-
import { appToApiKeyProperties, extractBaseRequestOptions,
|
|
5
|
-
import { getItem, getPortalUrl } from "@esri/arcgis-rest-portal";
|
|
4
|
+
import { appToApiKeyProperties, extractBaseRequestOptions, stringifyArrays, generateApiKeyTokens, generateOptionsToSlots, buildExpirationDateParams } from "./shared/helpers.js";
|
|
5
|
+
import { getItem, getPortalUrl, updateItem } from "@esri/arcgis-rest-portal";
|
|
6
6
|
import { appendCustomParams, request } from "@esri/arcgis-rest-request";
|
|
7
7
|
/**
|
|
8
8
|
* Used to update an API key.
|
|
@@ -36,20 +36,21 @@ import { appendCustomParams, request } from "@esri/arcgis-rest-request";
|
|
|
36
36
|
* @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing updated API key.
|
|
37
37
|
*/
|
|
38
38
|
export async function updateApiKey(requestOptions) {
|
|
39
|
-
// privileges validation
|
|
40
|
-
if (requestOptions.privileges &&
|
|
41
|
-
!arePrivilegesValid(requestOptions.privileges)) {
|
|
42
|
-
throw new Error("The `privileges` option contains invalid privileges.");
|
|
43
|
-
}
|
|
44
39
|
requestOptions.httpMethod = "POST";
|
|
45
|
-
// get app
|
|
46
40
|
const baseRequestOptions = extractBaseRequestOptions(requestOptions); // get base requestOptions snapshot
|
|
41
|
+
/**
|
|
42
|
+
* step 1: update expiration dates if provided. Build the object up to avoid overwriting any existing properties.
|
|
43
|
+
*/
|
|
44
|
+
if (requestOptions.apiToken1ExpirationDate ||
|
|
45
|
+
requestOptions.apiToken2ExpirationDate) {
|
|
46
|
+
const updateParams = buildExpirationDateParams(requestOptions);
|
|
47
|
+
await updateItem(Object.assign(Object.assign({}, baseRequestOptions), { item: Object.assign({ id: requestOptions.itemId }, updateParams), authentication: requestOptions.authentication }));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* step 2: update privileges and httpReferrers if provided. Build the object up to avoid overwriting any existing properties.
|
|
51
|
+
*/
|
|
47
52
|
const getAppOption = Object.assign(Object.assign({}, baseRequestOptions), { authentication: requestOptions.authentication, itemId: requestOptions.itemId });
|
|
48
53
|
const appResponse = await getRegisteredAppInfo(getAppOption);
|
|
49
|
-
// appType must be APIKey to continue
|
|
50
|
-
if (appResponse.appType !== "apikey" || !("apiKey" in appResponse)) {
|
|
51
|
-
throw new Error("Item is not an API key.");
|
|
52
|
-
}
|
|
53
54
|
const clientId = appResponse.client_id;
|
|
54
55
|
const options = appendCustomParams(Object.assign(Object.assign({}, appResponse), requestOptions), // object with the custom params to look in
|
|
55
56
|
["privileges", "httpReferrers"] // keys you want copied to the params object
|
|
@@ -60,8 +61,18 @@ export async function updateApiKey(requestOptions) {
|
|
|
60
61
|
const url = getPortalUrl(options) + `/oauth2/apps/${clientId}/update`;
|
|
61
62
|
// Raw response from `/oauth2/apps/${clientId}/update`, apiKey not included because key is same.
|
|
62
63
|
const updateResponse = await request(url, Object.assign(Object.assign({}, options), { authentication: requestOptions.authentication }));
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
/**
|
|
65
|
+
* step 3: get the updated item info to return to the user.
|
|
66
|
+
*/
|
|
67
|
+
const updatedItemInfo = await getItem(requestOptions.itemId, Object.assign(Object.assign({}, baseRequestOptions), { authentication: requestOptions.authentication, params: { f: "json" } }));
|
|
68
|
+
/**
|
|
69
|
+
* step 4: generate tokens if requested
|
|
70
|
+
*/
|
|
71
|
+
const generatedTokens = await generateApiKeyTokens(requestOptions.itemId, generateOptionsToSlots(requestOptions.generateToken1, requestOptions.generateToken2), Object.assign(Object.assign({}, baseRequestOptions), { authentication: requestOptions.authentication }));
|
|
72
|
+
/**
|
|
73
|
+
* step 5: get updated registered app info
|
|
74
|
+
*/
|
|
75
|
+
const updatedRegisteredAppResponse = await getRegisteredAppInfo(Object.assign(Object.assign({}, baseRequestOptions), { itemId: requestOptions.itemId, authentication: requestOptions.authentication }));
|
|
76
|
+
return Object.assign(Object.assign(Object.assign({}, generatedTokens), appToApiKeyProperties(updatedRegisteredAppResponse)), { item: updatedItemInfo });
|
|
66
77
|
}
|
|
67
78
|
//# sourceMappingURL=updateApiKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateApiKey.js","sourceRoot":"","sources":["../../src/updateApiKey.ts"],"names":[],"mappings":"AAAA;gBACgB;AAMhB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"updateApiKey.js","sourceRoot":"","sources":["../../src/updateApiKey.ts"],"names":[],"mappings":"AAAA;gBACgB;AAMhB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,eAAe,EAEf,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAOxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,cAAoC;IAEpC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IACnC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,cAAc,CAAC,CAAC,CAAC,mCAAmC;IAEzG;;OAEG;IACH,IACE,cAAc,CAAC,uBAAuB;QACtC,cAAc,CAAC,uBAAuB,EACtC;QACA,MAAM,YAAY,GAAG,yBAAyB,CAAC,cAAc,CAAC,CAAC;QAC/D,MAAM,UAAU,iCACX,kBAAkB,KACrB,IAAI,kBACF,EAAE,EAAE,cAAc,CAAC,MAAM,IACtB,YAAY,GAEjB,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;KACJ;IAED;;OAEG;IACH,MAAM,YAAY,mCACb,kBAAkB,KACrB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,cAAc,CAAC,MAAM,GAC9B,CAAC;IACF,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC;IACvC,MAAM,OAAO,GAAG,kBAAkB,iCAC3B,WAAW,GAAK,cAAc,GAAI,2CAA2C;IAClF,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,4CAA4C;KAC7E,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC;IAE1B,mHAAmH;IACnH,eAAe,CAAC,OAAO,CAAC,CAAC;IAEzB,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,gBAAgB,QAAQ,SAAS,CAAC;IAEtE,gGAAgG;IAChG,MAAM,cAAc,GAA2B,MAAM,OAAO,CAAC,GAAG,kCAC3D,OAAO,KACV,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH;;OAEG;IACH,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,cAAc,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,oBAAoB,CAChD,cAAc,CAAC,MAAM,EACrB,sBAAsB,CACpB,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,oBAAoB,iCAC1D,kBAAkB,KACrB,MAAM,EAAE,cAAc,CAAC,MAAM,EAC7B,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,qDACK,eAAe,GACf,qBAAqB,CAAC,4BAA4B,CAAC,KACtD,IAAI,EAAE,eAAe,IACrB;AACJ,CAAC","sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport {\n IApiKeyResponse,\n IUpdateApiKeyOptions\n} from \"./shared/types/apiKeyType.js\";\nimport { getRegisteredAppInfo } from \"./shared/getRegisteredAppInfo.js\";\nimport {\n appToApiKeyProperties,\n extractBaseRequestOptions,\n stringifyArrays,\n registeredAppResponseToApp,\n generateApiKeyTokens,\n generateOptionsToSlots,\n buildExpirationDateParams\n} from \"./shared/helpers.js\";\nimport { getItem, getPortalUrl, updateItem } from \"@esri/arcgis-rest-portal\";\nimport { appendCustomParams, request } from \"@esri/arcgis-rest-request\";\nimport {\n IApp,\n IGetAppInfoOptions,\n IRegisteredAppResponse\n} from \"./shared/types/appType.js\";\n\n/**\n * Used to update an API key.\n *\n * Notes about `privileges` and `httpReferrers` options:\n * 1. Provided option will override corresponding old option.\n * 2. Unprovided option will not trigger corresponding option updates.\n *\n * ```js\n * import { updateApiKey, IApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';\n * import { ArcGISIdentityManager } from \"@esri/arcgis-rest-request\";\n *\n * const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({\n * username: \"xyz_usrName\",\n * password: \"xyz_pw\"\n * });\n *\n * updateApiKey({\n * itemId: \"xyz_itemId\",\n * privileges: [Privileges.Geocode],\n * httpReferrers: [], // httpReferrers will be set to be empty\n * authentication: authSession\n * }).then((updatedAPIKey: IApiKeyResponse) => {\n * // => {apiKey: \"xyz_key\", item: {tags: [\"xyz_tag1\", \"xyz_tag2\"], ...}, ...}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode updateApiKey | updateApiKey()}, including `itemId` of which API key to be operated on, optional new `privileges`, optional new `httpReferrers` and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IApiKeyResponse} object representing updated API key.\n */\nexport async function updateApiKey(\n requestOptions: IUpdateApiKeyOptions\n): Promise<IApiKeyResponse> {\n requestOptions.httpMethod = \"POST\";\n const baseRequestOptions = extractBaseRequestOptions(requestOptions); // get base requestOptions snapshot\n\n /**\n * step 1: update expiration dates if provided. Build the object up to avoid overwriting any existing properties.\n */\n if (\n requestOptions.apiToken1ExpirationDate ||\n requestOptions.apiToken2ExpirationDate\n ) {\n const updateParams = buildExpirationDateParams(requestOptions);\n await updateItem({\n ...baseRequestOptions,\n item: {\n id: requestOptions.itemId,\n ...updateParams\n },\n authentication: requestOptions.authentication\n });\n }\n\n /**\n * step 2: update privileges and httpReferrers if provided. Build the object up to avoid overwriting any existing properties.\n */\n const getAppOption: IGetAppInfoOptions = {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n itemId: requestOptions.itemId\n };\n const appResponse = await getRegisteredAppInfo(getAppOption);\n const clientId = appResponse.client_id;\n const options = appendCustomParams(\n { ...appResponse, ...requestOptions }, // object with the custom params to look in\n [\"privileges\", \"httpReferrers\"] // keys you want copied to the params object\n );\n options.params.f = \"json\";\n\n // encode special params value (e.g. array type...) in advance in order to make encodeQueryString() works correctly\n stringifyArrays(options);\n\n const url = getPortalUrl(options) + `/oauth2/apps/${clientId}/update`;\n\n // Raw response from `/oauth2/apps/${clientId}/update`, apiKey not included because key is same.\n const updateResponse: IRegisteredAppResponse = await request(url, {\n ...options,\n authentication: requestOptions.authentication\n });\n\n /**\n * step 3: get the updated item info to return to the user.\n */\n const updatedItemInfo = await getItem(requestOptions.itemId, {\n ...baseRequestOptions,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n /**\n * step 4: generate tokens if requested\n */\n const generatedTokens = await generateApiKeyTokens(\n requestOptions.itemId,\n generateOptionsToSlots(\n requestOptions.generateToken1,\n requestOptions.generateToken2\n ),\n {\n ...baseRequestOptions,\n authentication: requestOptions.authentication\n }\n );\n\n /**\n * step 5: get updated registered app info\n */\n const updatedRegisteredAppResponse = await getRegisteredAppInfo({\n ...baseRequestOptions,\n itemId: requestOptions.itemId,\n authentication: requestOptions.authentication\n });\n\n return {\n ...generatedTokens,\n ...appToApiKeyProperties(updatedRegisteredAppResponse),\n item: updatedItemInfo\n };\n}\n"]}
|
package/package.json
CHANGED
package/dist/cjs/deleteApiKey.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
|
|
3
|
-
* Apache-2.0 */
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.deleteApiKey = void 0;
|
|
6
|
-
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
7
|
-
const helpers_js_1 = require("./shared/helpers.js");
|
|
8
|
-
const getApiKey_js_1 = require("./getApiKey.js");
|
|
9
|
-
/**
|
|
10
|
-
* Used to delete the API Key with given `itemId`.
|
|
11
|
-
*
|
|
12
|
-
* ```js
|
|
13
|
-
* import { deleteApiKey, IDeleteApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';
|
|
14
|
-
* import { ArcGISIdentityManager } from "@esri/arcgis-rest-request";
|
|
15
|
-
*
|
|
16
|
-
* const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({
|
|
17
|
-
* username: "xyz_usrName",
|
|
18
|
-
* password: "xyz_pw"
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* deleteApiKey({
|
|
22
|
-
* itemId: "xyz_itemId",
|
|
23
|
-
* authentication: authSession
|
|
24
|
-
* }).then((deletedApiKey: IDeleteApiKeyResponse) => {
|
|
25
|
-
* // => {itemId: "xyz_itemId", success: true}
|
|
26
|
-
* }).catch(e => {
|
|
27
|
-
* // => an exception object
|
|
28
|
-
* });
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @param requestOptions - Options for {@linkcode deleteApiKey | deleteApiKey()}, including `itemId` of which API key to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.
|
|
32
|
-
* @returns A Promise that will resolve to an {@linkcode IDeleteApiKeyResponse} object representing deletion status.
|
|
33
|
-
*/
|
|
34
|
-
async function deleteApiKey(requestOptions) {
|
|
35
|
-
requestOptions.httpMethod = "POST";
|
|
36
|
-
const baseRequestOptions = (0, helpers_js_1.extractBaseRequestOptions)(requestOptions);
|
|
37
|
-
// validate provided itemId associates with API Key
|
|
38
|
-
await (0, getApiKey_js_1.getApiKey)(Object.assign(Object.assign({}, baseRequestOptions), { itemId: requestOptions.itemId, authentication: requestOptions.authentication }));
|
|
39
|
-
const removeItemResponse = await (0, arcgis_rest_portal_1.removeItem)(Object.assign(Object.assign({}, baseRequestOptions), { id: requestOptions.itemId, authentication: requestOptions.authentication, params: { f: "json" } }));
|
|
40
|
-
return removeItemResponse;
|
|
41
|
-
}
|
|
42
|
-
exports.deleteApiKey = deleteApiKey;
|
|
43
|
-
//# sourceMappingURL=deleteApiKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteApiKey.js","sourceRoot":"","sources":["../../src/deleteApiKey.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,iEAAsD;AAEtD,oDAAgE;AAKhE,iDAA2C;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,YAAY,CAChC,cAAmC;IAEnC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,MAAM,kBAAkB,GAAG,IAAA,sCAAyB,EAAC,cAAc,CAAC,CAAC;IAErE,mDAAmD;IACnD,MAAM,IAAA,wBAAS,kCACV,kBAAkB,KACrB,MAAM,EAAE,cAAc,CAAC,MAAM,EAC7B,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,MAAM,kBAAkB,GAA0B,MAAM,IAAA,+BAAU,kCAC7D,kBAAkB,KACrB,EAAE,EAAE,cAAc,CAAC,MAAM,EACzB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAtBD,oCAsBC","sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { removeItem } from \"@esri/arcgis-rest-portal\";\n\nimport { extractBaseRequestOptions } from \"./shared/helpers.js\";\nimport {\n IDeleteApiKeyOption,\n IDeleteApiKeyResponse\n} from \"./shared/types/apiKeyType.js\";\nimport { getApiKey } from \"./getApiKey.js\";\n\n/**\n * Used to delete the API Key with given `itemId`.\n *\n * ```js\n * import { deleteApiKey, IDeleteApiKeyResponse } 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 * deleteApiKey({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((deletedApiKey: IDeleteApiKeyResponse) => {\n * // => {itemId: \"xyz_itemId\", success: true}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode deleteApiKey | deleteApiKey()}, including `itemId` of which API key to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IDeleteApiKeyResponse} object representing deletion status.\n */\nexport async function deleteApiKey(\n requestOptions: IDeleteApiKeyOption\n): Promise<IDeleteApiKeyResponse> {\n requestOptions.httpMethod = \"POST\";\n\n const baseRequestOptions = extractBaseRequestOptions(requestOptions);\n\n // validate provided itemId associates with API Key\n await getApiKey({\n ...baseRequestOptions,\n itemId: requestOptions.itemId,\n authentication: requestOptions.authentication\n });\n\n const removeItemResponse: IDeleteApiKeyResponse = await removeItem({\n ...baseRequestOptions,\n id: requestOptions.itemId,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n return removeItemResponse;\n}\n"]}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
|
|
3
|
-
* Apache-2.0 */
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.deleteOAuthApp = void 0;
|
|
6
|
-
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
7
|
-
const helpers_js_1 = require("./shared/helpers.js");
|
|
8
|
-
const getOAuthApp_js_1 = require("./getOAuthApp.js");
|
|
9
|
-
/**
|
|
10
|
-
* Used to delete the OAuth2.0 app with given `itemId`.
|
|
11
|
-
*
|
|
12
|
-
* ```js
|
|
13
|
-
* import { deleteOAuthApp, IDeleteOAuthAppResponse } from '@esri/arcgis-rest-developer-credentials';
|
|
14
|
-
* import { ArcGISIdentityManager } from "@esri/arcgis-rest-request";
|
|
15
|
-
*
|
|
16
|
-
* const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({
|
|
17
|
-
* username: "xyz_usrName",
|
|
18
|
-
* password: "xyz_pw"
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* deleteOAuthApp({
|
|
22
|
-
* itemId: "xyz_itemId",
|
|
23
|
-
* authentication: authSession
|
|
24
|
-
* }).then((deletedOAuthApp: IDeleteOAuthAppResponse) => {
|
|
25
|
-
* // => {itemId: "xyz_itemId", success: true}
|
|
26
|
-
* }).catch(e => {
|
|
27
|
-
* // => an exception object
|
|
28
|
-
* });
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @param requestOptions - Options for {@linkcode deleteOAuthApp | deleteOAuthApp()}, including `itemId` of which OAuth app to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.
|
|
32
|
-
* @returns A Promise that will resolve to an {@linkcode IDeleteOAuthAppResponse} object representing deletion status.
|
|
33
|
-
*/
|
|
34
|
-
async function deleteOAuthApp(requestOptions) {
|
|
35
|
-
requestOptions.httpMethod = "POST";
|
|
36
|
-
const baseRequestOptions = (0, helpers_js_1.extractBaseRequestOptions)(requestOptions);
|
|
37
|
-
// validate provided itemId associates with OAuth app
|
|
38
|
-
await (0, getOAuthApp_js_1.getOAuthApp)(Object.assign(Object.assign({}, baseRequestOptions), { itemId: requestOptions.itemId, authentication: requestOptions.authentication }));
|
|
39
|
-
const removeItemResponse = await (0, arcgis_rest_portal_1.removeItem)(Object.assign(Object.assign({}, baseRequestOptions), { id: requestOptions.itemId, authentication: requestOptions.authentication, params: { f: "json" } }));
|
|
40
|
-
return removeItemResponse;
|
|
41
|
-
}
|
|
42
|
-
exports.deleteOAuthApp = deleteOAuthApp;
|
|
43
|
-
//# sourceMappingURL=deleteOAuthApp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteOAuthApp.js","sourceRoot":"","sources":["../../src/deleteOAuthApp.ts"],"names":[],"mappings":";AAAA;gBACgB;;;AAEhB,iEAAsD;AAEtD,oDAAgE;AAKhE,qDAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,cAAc,CAClC,cAAqC;IAErC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,MAAM,kBAAkB,GAAG,IAAA,sCAAyB,EAAC,cAAc,CAAC,CAAC;IAErE,qDAAqD;IACrD,MAAM,IAAA,4BAAW,kCACZ,kBAAkB,KACrB,MAAM,EAAE,cAAc,CAAC,MAAM,EAC7B,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,MAAM,kBAAkB,GAA4B,MAAM,IAAA,+BAAU,kCAC/D,kBAAkB,KACrB,EAAE,EAAE,cAAc,CAAC,MAAM,EACzB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAtBD,wCAsBC","sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { removeItem } from \"@esri/arcgis-rest-portal\";\n\nimport { extractBaseRequestOptions } from \"./shared/helpers.js\";\nimport {\n IDeleteOAuthAppOption,\n IDeleteOAuthAppResponse\n} from \"./shared/types/oAuthType.js\";\nimport { getOAuthApp } from \"./getOAuthApp.js\";\n\n/**\n * Used to delete the OAuth2.0 app with given `itemId`.\n *\n * ```js\n * import { deleteOAuthApp, IDeleteOAuthAppResponse } 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 * deleteOAuthApp({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((deletedOAuthApp: IDeleteOAuthAppResponse) => {\n * // => {itemId: \"xyz_itemId\", success: true}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode deleteOAuthApp | deleteOAuthApp()}, including `itemId` of which OAuth app to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IDeleteOAuthAppResponse} object representing deletion status.\n */\nexport async function deleteOAuthApp(\n requestOptions: IDeleteOAuthAppOption\n): Promise<IDeleteOAuthAppResponse> {\n requestOptions.httpMethod = \"POST\";\n\n const baseRequestOptions = extractBaseRequestOptions(requestOptions);\n\n // validate provided itemId associates with OAuth app\n await getOAuthApp({\n ...baseRequestOptions,\n itemId: requestOptions.itemId,\n authentication: requestOptions.authentication\n });\n\n const removeItemResponse: IDeleteOAuthAppResponse = await removeItem({\n ...baseRequestOptions,\n id: requestOptions.itemId,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n return removeItemResponse;\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { IDeleteApiKeyOption, IDeleteApiKeyResponse } from "./shared/types/apiKeyType.js";
|
|
2
|
-
/**
|
|
3
|
-
* Used to delete the API Key with given `itemId`.
|
|
4
|
-
*
|
|
5
|
-
* ```js
|
|
6
|
-
* import { deleteApiKey, IDeleteApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';
|
|
7
|
-
* import { ArcGISIdentityManager } from "@esri/arcgis-rest-request";
|
|
8
|
-
*
|
|
9
|
-
* const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({
|
|
10
|
-
* username: "xyz_usrName",
|
|
11
|
-
* password: "xyz_pw"
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* deleteApiKey({
|
|
15
|
-
* itemId: "xyz_itemId",
|
|
16
|
-
* authentication: authSession
|
|
17
|
-
* }).then((deletedApiKey: IDeleteApiKeyResponse) => {
|
|
18
|
-
* // => {itemId: "xyz_itemId", success: true}
|
|
19
|
-
* }).catch(e => {
|
|
20
|
-
* // => an exception object
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @param requestOptions - Options for {@linkcode deleteApiKey | deleteApiKey()}, including `itemId` of which API key to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.
|
|
25
|
-
* @returns A Promise that will resolve to an {@linkcode IDeleteApiKeyResponse} object representing deletion status.
|
|
26
|
-
*/
|
|
27
|
-
export declare function deleteApiKey(requestOptions: IDeleteApiKeyOption): Promise<IDeleteApiKeyResponse>;
|
package/dist/esm/deleteApiKey.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
|
|
2
|
-
* Apache-2.0 */
|
|
3
|
-
import { removeItem } from "@esri/arcgis-rest-portal";
|
|
4
|
-
import { extractBaseRequestOptions } from "./shared/helpers.js";
|
|
5
|
-
import { getApiKey } from "./getApiKey.js";
|
|
6
|
-
/**
|
|
7
|
-
* Used to delete the API Key with given `itemId`.
|
|
8
|
-
*
|
|
9
|
-
* ```js
|
|
10
|
-
* import { deleteApiKey, IDeleteApiKeyResponse } from '@esri/arcgis-rest-developer-credentials';
|
|
11
|
-
* import { ArcGISIdentityManager } from "@esri/arcgis-rest-request";
|
|
12
|
-
*
|
|
13
|
-
* const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({
|
|
14
|
-
* username: "xyz_usrName",
|
|
15
|
-
* password: "xyz_pw"
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* deleteApiKey({
|
|
19
|
-
* itemId: "xyz_itemId",
|
|
20
|
-
* authentication: authSession
|
|
21
|
-
* }).then((deletedApiKey: IDeleteApiKeyResponse) => {
|
|
22
|
-
* // => {itemId: "xyz_itemId", success: true}
|
|
23
|
-
* }).catch(e => {
|
|
24
|
-
* // => an exception object
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @param requestOptions - Options for {@linkcode deleteApiKey | deleteApiKey()}, including `itemId` of which API key to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.
|
|
29
|
-
* @returns A Promise that will resolve to an {@linkcode IDeleteApiKeyResponse} object representing deletion status.
|
|
30
|
-
*/
|
|
31
|
-
export async function deleteApiKey(requestOptions) {
|
|
32
|
-
requestOptions.httpMethod = "POST";
|
|
33
|
-
const baseRequestOptions = extractBaseRequestOptions(requestOptions);
|
|
34
|
-
// validate provided itemId associates with API Key
|
|
35
|
-
await getApiKey(Object.assign(Object.assign({}, baseRequestOptions), { itemId: requestOptions.itemId, authentication: requestOptions.authentication }));
|
|
36
|
-
const removeItemResponse = await removeItem(Object.assign(Object.assign({}, baseRequestOptions), { id: requestOptions.itemId, authentication: requestOptions.authentication, params: { f: "json" } }));
|
|
37
|
-
return removeItemResponse;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=deleteApiKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteApiKey.js","sourceRoot":"","sources":["../../src/deleteApiKey.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAKhE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,cAAmC;IAEnC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,cAAc,CAAC,CAAC;IAErE,mDAAmD;IACnD,MAAM,SAAS,iCACV,kBAAkB,KACrB,MAAM,EAAE,cAAc,CAAC,MAAM,EAC7B,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,MAAM,kBAAkB,GAA0B,MAAM,UAAU,iCAC7D,kBAAkB,KACrB,EAAE,EAAE,cAAc,CAAC,MAAM,EACzB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { removeItem } from \"@esri/arcgis-rest-portal\";\n\nimport { extractBaseRequestOptions } from \"./shared/helpers.js\";\nimport {\n IDeleteApiKeyOption,\n IDeleteApiKeyResponse\n} from \"./shared/types/apiKeyType.js\";\nimport { getApiKey } from \"./getApiKey.js\";\n\n/**\n * Used to delete the API Key with given `itemId`.\n *\n * ```js\n * import { deleteApiKey, IDeleteApiKeyResponse } 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 * deleteApiKey({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((deletedApiKey: IDeleteApiKeyResponse) => {\n * // => {itemId: \"xyz_itemId\", success: true}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode deleteApiKey | deleteApiKey()}, including `itemId` of which API key to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IDeleteApiKeyResponse} object representing deletion status.\n */\nexport async function deleteApiKey(\n requestOptions: IDeleteApiKeyOption\n): Promise<IDeleteApiKeyResponse> {\n requestOptions.httpMethod = \"POST\";\n\n const baseRequestOptions = extractBaseRequestOptions(requestOptions);\n\n // validate provided itemId associates with API Key\n await getApiKey({\n ...baseRequestOptions,\n itemId: requestOptions.itemId,\n authentication: requestOptions.authentication\n });\n\n const removeItemResponse: IDeleteApiKeyResponse = await removeItem({\n ...baseRequestOptions,\n id: requestOptions.itemId,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n return removeItemResponse;\n}\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { IDeleteOAuthAppOption, IDeleteOAuthAppResponse } from "./shared/types/oAuthType.js";
|
|
2
|
-
/**
|
|
3
|
-
* Used to delete the OAuth2.0 app with given `itemId`.
|
|
4
|
-
*
|
|
5
|
-
* ```js
|
|
6
|
-
* import { deleteOAuthApp, IDeleteOAuthAppResponse } from '@esri/arcgis-rest-developer-credentials';
|
|
7
|
-
* import { ArcGISIdentityManager } from "@esri/arcgis-rest-request";
|
|
8
|
-
*
|
|
9
|
-
* const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({
|
|
10
|
-
* username: "xyz_usrName",
|
|
11
|
-
* password: "xyz_pw"
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* deleteOAuthApp({
|
|
15
|
-
* itemId: "xyz_itemId",
|
|
16
|
-
* authentication: authSession
|
|
17
|
-
* }).then((deletedOAuthApp: IDeleteOAuthAppResponse) => {
|
|
18
|
-
* // => {itemId: "xyz_itemId", success: true}
|
|
19
|
-
* }).catch(e => {
|
|
20
|
-
* // => an exception object
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @param requestOptions - Options for {@linkcode deleteOAuthApp | deleteOAuthApp()}, including `itemId` of which OAuth app to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.
|
|
25
|
-
* @returns A Promise that will resolve to an {@linkcode IDeleteOAuthAppResponse} object representing deletion status.
|
|
26
|
-
*/
|
|
27
|
-
export declare function deleteOAuthApp(requestOptions: IDeleteOAuthAppOption): Promise<IDeleteOAuthAppResponse>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
|
|
2
|
-
* Apache-2.0 */
|
|
3
|
-
import { removeItem } from "@esri/arcgis-rest-portal";
|
|
4
|
-
import { extractBaseRequestOptions } from "./shared/helpers.js";
|
|
5
|
-
import { getOAuthApp } from "./getOAuthApp.js";
|
|
6
|
-
/**
|
|
7
|
-
* Used to delete the OAuth2.0 app with given `itemId`.
|
|
8
|
-
*
|
|
9
|
-
* ```js
|
|
10
|
-
* import { deleteOAuthApp, IDeleteOAuthAppResponse } from '@esri/arcgis-rest-developer-credentials';
|
|
11
|
-
* import { ArcGISIdentityManager } from "@esri/arcgis-rest-request";
|
|
12
|
-
*
|
|
13
|
-
* const authSession: ArcGISIdentityManager = await ArcGISIdentityManager.signIn({
|
|
14
|
-
* username: "xyz_usrName",
|
|
15
|
-
* password: "xyz_pw"
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* deleteOAuthApp({
|
|
19
|
-
* itemId: "xyz_itemId",
|
|
20
|
-
* authentication: authSession
|
|
21
|
-
* }).then((deletedOAuthApp: IDeleteOAuthAppResponse) => {
|
|
22
|
-
* // => {itemId: "xyz_itemId", success: true}
|
|
23
|
-
* }).catch(e => {
|
|
24
|
-
* // => an exception object
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @param requestOptions - Options for {@linkcode deleteOAuthApp | deleteOAuthApp()}, including `itemId` of which OAuth app to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.
|
|
29
|
-
* @returns A Promise that will resolve to an {@linkcode IDeleteOAuthAppResponse} object representing deletion status.
|
|
30
|
-
*/
|
|
31
|
-
export async function deleteOAuthApp(requestOptions) {
|
|
32
|
-
requestOptions.httpMethod = "POST";
|
|
33
|
-
const baseRequestOptions = extractBaseRequestOptions(requestOptions);
|
|
34
|
-
// validate provided itemId associates with OAuth app
|
|
35
|
-
await getOAuthApp(Object.assign(Object.assign({}, baseRequestOptions), { itemId: requestOptions.itemId, authentication: requestOptions.authentication }));
|
|
36
|
-
const removeItemResponse = await removeItem(Object.assign(Object.assign({}, baseRequestOptions), { id: requestOptions.itemId, authentication: requestOptions.authentication, params: { f: "json" } }));
|
|
37
|
-
return removeItemResponse;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=deleteOAuthApp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deleteOAuthApp.js","sourceRoot":"","sources":["../../src/deleteOAuthApp.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAKhE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,cAAqC;IAErC,cAAc,CAAC,UAAU,GAAG,MAAM,CAAC;IAEnC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,cAAc,CAAC,CAAC;IAErE,qDAAqD;IACrD,MAAM,WAAW,iCACZ,kBAAkB,KACrB,MAAM,EAAE,cAAc,CAAC,MAAM,EAC7B,cAAc,EAAE,cAAc,CAAC,cAAc,IAC7C,CAAC;IAEH,MAAM,kBAAkB,GAA4B,MAAM,UAAU,iCAC/D,kBAAkB,KACrB,EAAE,EAAE,cAAc,CAAC,MAAM,EACzB,cAAc,EAAE,cAAc,CAAC,cAAc,EAC7C,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IACrB,CAAC;IAEH,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.\n * Apache-2.0 */\n\nimport { removeItem } from \"@esri/arcgis-rest-portal\";\n\nimport { extractBaseRequestOptions } from \"./shared/helpers.js\";\nimport {\n IDeleteOAuthAppOption,\n IDeleteOAuthAppResponse\n} from \"./shared/types/oAuthType.js\";\nimport { getOAuthApp } from \"./getOAuthApp.js\";\n\n/**\n * Used to delete the OAuth2.0 app with given `itemId`.\n *\n * ```js\n * import { deleteOAuthApp, IDeleteOAuthAppResponse } 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 * deleteOAuthApp({\n * itemId: \"xyz_itemId\",\n * authentication: authSession\n * }).then((deletedOAuthApp: IDeleteOAuthAppResponse) => {\n * // => {itemId: \"xyz_itemId\", success: true}\n * }).catch(e => {\n * // => an exception object\n * });\n * ```\n *\n * @param requestOptions - Options for {@linkcode deleteOAuthApp | deleteOAuthApp()}, including `itemId` of which OAuth app to be deleted and an {@linkcode ArcGISIdentityManager} authentication session.\n * @returns A Promise that will resolve to an {@linkcode IDeleteOAuthAppResponse} object representing deletion status.\n */\nexport async function deleteOAuthApp(\n requestOptions: IDeleteOAuthAppOption\n): Promise<IDeleteOAuthAppResponse> {\n requestOptions.httpMethod = \"POST\";\n\n const baseRequestOptions = extractBaseRequestOptions(requestOptions);\n\n // validate provided itemId associates with OAuth app\n await getOAuthApp({\n ...baseRequestOptions,\n itemId: requestOptions.itemId,\n authentication: requestOptions.authentication\n });\n\n const removeItemResponse: IDeleteOAuthAppResponse = await removeItem({\n ...baseRequestOptions,\n id: requestOptions.itemId,\n authentication: requestOptions.authentication,\n params: { f: \"json\" }\n });\n\n return removeItemResponse;\n}\n"]}
|