Skip to content

Instantly share code, notes, and snippets.

View stupiduglyfool's full-sized avatar

stupiduglyfool

View GitHub Profile
import * as crypto from 'crypto';
export class CodeVerifier {
challenge: string;
method: string;
verifier: string;
private base64URLEncode(value: Buffer) {
return value.toString('base64')
let authRequestExtras = {
code_challenge: this._verifier.challenge,
code_challenge_method: this._verifier.method
}
let authResponse = this.authorizationHandler.performAuthorizationRequest(this.configuration, new AuthorizationRequest(
clientId, redirectUri, scope, AuthorizationRequest.RESPONSE_TYPE_CODE,
undefined /* state */, authRequestExtras));
let tokenRequestExtras = = { code_verifier: this._verifier.verifier };
@stupiduglyfool
stupiduglyfool / async await consumer example
Created October 17, 2017 09:30
@openid/appauth async/await demo
public async signIn(username?: string) {
if (username) extras['login_hint'] = username;
if (this._config.clientSecret) extras['client_secret'] = this._config.clientSecret;
if (this._verifier) {
extras['code_challenge'] = this._verifier.challenge;
extras['code_challenge_method'] = this._verifier.method;
extras['code_verifier'] = this._verifier.verifier;
}
@stupiduglyfool
stupiduglyfool / electron_request_handler.ts
Created October 17, 2017 09:35
Updated electron request handler demonstrating async/await vs emitter
/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either