How to use the form-urlencoded.default function in form-urlencoded

To help you get started, we’ve selected a few form-urlencoded examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gaaiatinc / hapi-openid-connect / lib / userinfo / index.js View on Github external
function get_redirect_to_signin_with_error(query_error_message, redirect_descriptor) {
            let query_atring_obj = redirect_descriptor || {
                error: query_error_message
            };

            if (typeof query_atring_obj.redirect_uri === "string") {
                query_atring_obj.redirect_uri = decodeURIComponent(encodeUrl(query_atring_obj.redirect_uri));
            }

            return URL.format(user_info_endpoint.user_authentication_url + "?" + FormURLEncoder(query_atring_obj));
        }
github gaaiatinc / hapi-openid-connect / lib / authorization / index.js View on Github external
await __verify_client_registration_entries(authorization_request);
        /**
             * Now that the client_id and redirect_uri are verified, we validate the
             * authorization request and we can redirect with errors if any is found.
             */
        let processing_tasks = [__validate_authorization_request, authorization_endpoint.authorization_request_registrar_module.post_authorization_request];

        try {
            const authorization_request_id = await promiseSequencer(processing_tasks, authorization_request);
            /**
             * Everything is good to proceed for End-User authentication & consent:
             */
            let temp_redirect_uri = user_info_endpoint.user_authentication_url + "?authorization_request_id=" + encodeURIComponent(authorization_request_id);
            return h.redirect(temp_redirect_uri).takeover();
        } catch (auth_validation_error) {
            let temp_redirect_uri = authorization_request.redirect_uri + "?" + FormURLEncoder(auth_validation_error);
            return h.redirect(temp_redirect_uri).takeover();
        }
    } catch (client_validation_error) {
        let error_html = "<html><head></head> <body>  " + JSON.stringify(client_validation_error, null, 4) + "  </body> </html>";
        return h
            .response(error_html)
            .code(401)
            .type("text/html");
    }
}
github gaaiatinc / hapi-openid-connect / lib / userinfo / index.js View on Github external
._id
                            .toString()
                    };

                    authorization_request_record.granted = true;
                    authorization_request_record.subject = user_account_id;

                    try {
                        await authorization_endpoint
                            .authorization_request_registrar_module
                            .put_authorization_request(authorization_request_record);

                        redirect_uri = URL.format(authorization_request_record.redirect_uri + "?" + FormURLEncoder(redirect_query_params));
                        return h.redirect(redirect_uri).takeover();;
                    } catch (err) {
                        redirect_uri = URL.format(authorization_request_record.redirect_uri + "?" + FormURLEncoder({error: "authorization request expired"}));
                        return h.redirect(redirect_uri).takeover();;
                    }
                } catch (err) {
                    redirect_uri = get_redirect_to_signin_with_error("Authorization request ID not found");
                    return h.redirect(redirect_uri).takeover();;
                }
            } else if (get_sanitized_redirect_uri(request.query["redirect_uri"])) {
                redirect_uri = get_sanitized_redirect_uri(request.query["redirect_uri"]);

                return h.redirect(redirect_uri).takeover();;
            } else {
                let reply_obj = {
                    status: "success",
                    status_code: 200,
                    status_message: "Signin successful"
                };
github Dwolla / dwolla-v2-node / src / dwolla / Token.js View on Github external
function getUrl(token, suppliedPath, suppliedQuery) {
  var url;
  if (typeof suppliedPath === "object") {
    url = suppliedPath._links.self.href;
  } else if (suppliedPath.indexOf(token.client.apiUrl) === 0) {
    url = suppliedPath;
  } else if (suppliedPath.indexOf("/") === 0) {
    url = [token.client.apiUrl, suppliedPath].join("");
  } else {
    url = [
      token.client.apiUrl,
      suppliedPath.replace(/^https?:\/\/[^\/]*\//, "")
    ].join("/");
  }
  var query = formurlencoded(rejectEmptyKeys(suppliedQuery || {}));
  return query ? [url, query].join("?") : url;
}
github Dwolla / dwolla-v2-node / src / dwolla / Auth.js View on Github external
function requestToken(client, params) {
  return fetch(client.tokenUrl, {
    method: "POST",
    headers: {
      "content-type": "application/x-www-form-urlencoded",
      "user-agent": require("../../src/dwolla/userAgent")
    },
    body: formurlencoded(
      assign(
        {
          client_id: client.id,
          client_secret: client.secret
        },
        params
      )
    )
  })
    .then(toJson)
    .then(handleTokenResponse.bind(null, client))
    .then(performOnGrantCallback.bind(null, client));
}
github Dwolla / dwolla-v2-node / src / dwolla / Auth.js View on Github external
function query(client, opts) {
  return formurlencoded(
    rejectEmptyKeys({
      response_type: "code",
      client_id: client.id,
      redirect_uri: opts.redirect_uri,
      scope: opts.scope,
      state: opts.state,
      verified_account: opts.verified_account,
      dwolla_landing: opts.dwolla_landing
    })
  );
}
github OfficeDev / Office-Add-in-NodeJS-SSO / Complete / routes / authRoute.js View on Github external
client_id: process.env.CLIENT_ID,
      client_secret: process.env.CLIENT_SECRET,
      grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
      assertion: jwt,
      requested_token_use: 'on_behalf_of',
      scope: ['Files.Read.All'].join(' ')
    };

    const stsDomain = 'https://login.microsoftonline.com';
    const tenant = 'common';
    const tokenURLSegment = 'oauth2/v2.0/token';

    try {
      const tokenResponse = await fetch(`${stsDomain}/${tenant}/${tokenURLSegment}`, {
        method: 'POST',
        body: form(formParams),
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/x-www-form-urlencoded'
        }
      });
      const json = await tokenResponse.json();
    
      res.send(json);
    }
    catch(error) {
      res.status(500).send(error);
    }
  }
});

form-urlencoded

Return an object as an 'x-www-form-urlencoded' string

MIT
Latest version published 6 months ago

Package Health Score

66 / 100
Full package analysis