Versions

  • v8

    10/31/2024
    Open: Version
    Changes from v7 to v8
    +2
    -2
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import type { Context } from "npm:hono";

    /**
    ⦚ 4 unchanged lines ⦚
    options: IOAuth2Options,
    c: Context,
    ) {
    const { portal, clientId, expiration, redirectUri, state }: IOAuth2Options = {
    ...{ portal: "https://arcgis.com/sharing/rest", expiration: 20160 },
    ⦚ 167 unchanged lines ⦚
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import type { Context, TypedResponse } from "npm:hono";

    /**
    ⦚ 4 unchanged lines ⦚
    options: IOAuth2Options,
    c: Context,
    ): TypedResponse<unknown, 301, "redirect"> {
    const { portal, clientId, expiration, redirectUri, state }: IOAuth2Options = {
    ...{ portal: "https://arcgis.com/sharing/rest", expiration: 20160 },
    ⦚ 167 unchanged lines ⦚
  • v7

    10/31/2024
    Open: Version
    Changes from v6 to v7
    +1
    -1
    ⦚ 27 unchanged lines ⦚
    const url = `${portal}/oauth2/authorize?${encodeQueryString(queryParams)}`;

    c.redirect(url);
    }

    ⦚ 148 unchanged lines ⦚
    ⦚ 27 unchanged lines ⦚
    const url = `${portal}/oauth2/authorize?${encodeQueryString(queryParams)}`;

    return c.redirect(url, 301);
    }

    ⦚ 148 unchanged lines ⦚
  • v6

    10/31/2024
    Open: Version
    Changes from v5 to v6
    +149
    -1
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import { encodeQueryString } from "npm:@esri/arcgis-rest-request/dist/esm/utils/encode-query-string.js";
    import type { Context } from "npm:hono";

    /**
    ⦚ 24 unchanged lines ⦚

    c.redirect(url);
    }
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import type { Context } from "npm:hono";

    /**
    ⦚ 24 unchanged lines ⦚

    c.redirect(url);
    }

    /* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
    * Apache-2.0 */

    /**
    * Encodes keys and parameters for use in a URL's query string.
    *
    * @param key Parameter's key
    * @param value Parameter's value
    * @returns Query string with key and value pairs separated by "&"
    */
    export function encodeParam(key: string, value: any): string {
    // For array of arrays, repeat key=value for each element of containing array
    if (Array.isArray(value) && value[0] && Array.isArray(value[0])) {
    return value
    .map((arrayElem: string) => encodeParam(key, arrayElem))
    .join("&");
    }

    return encodeURIComponent(key) + "=" + encodeURIComponent(value);
    }

    /**
    * Encodes the passed object as a query string.
    *
    * @param params An object to be encoded.
    * @returns An encoded query string.
  • v5

    10/31/2024
    Open: Version
    Changes from v4 to v5
    +4
    -1
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import { encodeQueryString } from "npm:@esri/arcgis-rest-request/dist/esm/utils/encode-query-string.js";
    import type { Context } from "npm:hono";

    /** */
    export function authorize(
    options: IOAuth2Options,
    ⦚ 22 unchanged lines ⦚
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import { encodeQueryString } from "npm:@esri/arcgis-rest-request/dist/esm/utils/encode-query-string.js";
    import type { Context } from "npm:hono";

    /**
    * Copy of https://github.com/Esri/arcgis-rest-js/blob/bfd7ce977d9879077e92fabfc491240d8f230844/packages/arcgis-rest-request/src/ArcGISIdentityManager.ts#L760
    * for use with Hono instead of Express
    */
    export function authorize(
    options: IOAuth2Options,
    ⦚ 22 unchanged lines ⦚
  • v4

    10/31/2024
    Open: Version
    Changes from v3 to v4
    +1
    -5
    ⦚ 25 unchanged lines ⦚
    const url = `${portal}/oauth2/authorize?${encodeQueryString(queryParams)}`;

    response.writeHead(301, {
    Location: url,
    });

    response.end();
    }
    ⦚ 25 unchanged lines ⦚
    const url = `${portal}/oauth2/authorize?${encodeQueryString(queryParams)}`;

    c.redirect(url);
    }
  • v3

    10/31/2024
    Open: Version
    Changes from v2 to v3
    +1
    -0
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import type { Context } from "npm:hono";

    /** */
    ⦚ 28 unchanged lines ⦚
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import { encodeQueryString } from "npm:@esri/arcgis-rest-request/dist/esm/utils/encode-query-string.js";
    import type { Context } from "npm:hono";

    /** */
    ⦚ 28 unchanged lines ⦚
  • v2

    10/31/2024
    Open: Version
    Changes from v1 to v2
    +23
    -26
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import type { Context } from "npm:hono";

    /**
    *
    */
    export function authorize(
    options: IOAuth2Options,
    response: http.ServerResponse
    ) {
    const { portal, clientId, expiration, redirectUri, state }: IOAuth2Options =
    {
    ...{ portal: "https://arcgis.com/sharing/rest", expiration: 20160 },
    ...options
    };

    const queryParams: any = {
    client_id: clientId,
    expiration,
    response_type: "code",
    redirect_uri: redirectUri
    };

    if (state) {
    queryParams.state = state;
    }

    const url = `${portal}/oauth2/authorize?${encodeQueryString(queryParams)}`;

    response.writeHead(301, {
    Location: url
    });

    response.end();
    }
    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import type { Context } from "npm:hono";

    /** */
    export function authorize(
    options: IOAuth2Options,
    c: Context,
    ) {
    const { portal, clientId, expiration, redirectUri, state }: IOAuth2Options = {
    ...{ portal: "https://arcgis.com/sharing/rest", expiration: 20160 },
    ...options,
    };

    const queryParams: any = {
    client_id: clientId,
    expiration,
    response_type: "code",
    redirect_uri: redirectUri,
    };

    if (state) {
    queryParams.state = state;
    }

    const url = `${portal}/oauth2/authorize?${encodeQueryString(queryParams)}`;

    response.writeHead(301, {
    Location: url,
    });

    response.end();
    }
  • v1

    10/31/2024
    Open: Version
    Changes from v0 to v1
    +35
    -0

    import type { IOAuth2Options } from "npm:@esri/arcgis-rest-request";
    import type { Context } from "npm:hono";

    /**
    *
    */
    export function authorize(
    options: IOAuth2Options,
    response: http.ServerResponse
    ) {
    const { portal, clientId, expiration, redirectUri, state }: IOAuth2Options =
    {
    ...{ portal: "https://arcgis.com/sharing/rest", expiration: 20160 },
    ...options
    };

    const queryParams: any = {
    client_id: clientId,
    expiration,
    response_type: "code",
    redirect_uri: redirectUri
    };

    if (state) {
    queryParams.state = state;
    }

    const url = `${portal}/oauth2/authorize?${encodeQueryString(queryParams)}`;

    response.writeHead(301, {
    Location: url
    });

    response.end();
    }
  • v0

    10/31/2024
    Open: Version
    +0
    -0


Updated: October 31, 2024