How to use the @vssue/utils.buildQuery function in @vssue/utils

To help you get started, we’ve selected a few @vssue/utils 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 meteorlxy / vssue / packages / @vssue / api-gitea-v1 / src / index.ts View on Github external
async getAccessToken ({
    code,
  }: {
    code: string
  }): Promise {
    const originalURL = concatURL(this.baseURL, 'login/oauth/access_token')
    const proxyURL = typeof this.proxy === 'function'
      ? this.proxy(originalURL)
      : this.proxy
    /**
     * JSON does not work
     *
     * @see https://github.com/go-gitea/gitea/issues/6624
     */
    const { data } = await this.$http.post(proxyURL, buildQuery({
      'client_id': this.clientId,
      'client_secret': this.clientSecret,
      'code': code,
      'grant_type': 'authorization_code',
      'redirect_uri': window.location.href,
    }), {
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
      },
    })
    return data.access_token
  }
github meteorlxy / vssue / packages / @vssue / api-gitlab-v4 / src / index.ts View on Github external
async handleAuth (): Promise {
    const hash = parseQuery(window.location.hash.slice(1))
    if (!hash.access_token || hash.state !== this.state) {
      return null
    }
    const accessToken = hash.access_token
    delete hash.access_token
    delete hash.token_type
    delete hash.expires_in
    delete hash.state
    const hashString = buildQuery(hash)
    const newHash = hashString ? `#${hashString}` : ''
    const replaceURL = `${getCleanURL(window.location.href)}${window.location.search}${newHash}`
    window.history.replaceState(null, '', replaceURL)
    return accessToken
  }
github meteorlxy / vssue / packages / @vssue / api-bitbucket-v2 / lib / index.js View on Github external
return tslib_1.__generator(this, function (_b) {
                switch (_b.label) {
                    case 0: return [4 /*yield*/, this.$http.post("https://cors-anywhere.herokuapp.com/" + 'https://bitbucket.org/site/oauth2/access_token', buildQuery({
                            grant_type: 'authorization_code',
                            redirect_uri: window.location.href,
                            code: code,
                        }), {
                            headers: {
                                'Content-Type': 'application/x-www-form-urlencoded',
                            },
                            auth: {
                                username: this.clientId,
                                password: this.clientSecret,
                            },
                        })];
                    case 1:
                        response = _b.sent();
                        accessToken = response.data.access_token;
                        return [2 /*return*/, accessToken];
github meteorlxy / vssue / packages / @vssue / api-bitbucket-v2 / src / index.ts View on Github external
async handleAuth (): Promise {
    const hash = parseQuery(window.location.hash.slice(1))
    if (!hash.access_token || hash.state !== this.state) {
      return null
    }
    const accessToken = hash.access_token
    delete hash.access_token
    delete hash.token_type
    delete hash.expires_in
    delete hash.state
    delete hash.scopes
    const hashString = buildQuery(hash)
    const newHash = hashString ? `#${hashString}` : ''
    const replaceURL = `${getCleanURL(window.location.href)}${window.location.search}${newHash}`
    window.history.replaceState(null, '', replaceURL)
    return accessToken
  }