Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Modular request decorations (and pluggable authentication) #1

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b4ffea1
split http client and request decorators
alekitto Feb 4, 2020
35fbb73
missing import
alekitto Feb 4, 2020
f130693
declare constructor on headers class
alekitto Feb 4, 2020
00dea40
add http basic authenticator
alekitto Feb 5, 2020
24890ce
updated entrypoint + eslint
alekitto Feb 5, 2020
5b719de
missing property
alekitto Feb 5, 2020
b406a18
optionally encode data as form-data for token request
alekitto Feb 5, 2020
12d8f9d
fix tests
alekitto Feb 5, 2020
6ac83c0
missing method declaration
alekitto Feb 5, 2020
64891ac
do not store undefined or empty refresh token
alekitto Feb 5, 2020
130e159
dedupe oauth request composition
alekitto Feb 6, 2020
c511499
token storage method must be protected
alekitto Feb 6, 2020
053d4a2
fix base64 encoding
alekitto Feb 6, 2020
74c3793
refresh token flow can be overridden by extending authenticators
alekitto Feb 6, 2020
fcecaa5
rename requestor to requester
alekitto Feb 9, 2020
1223160
allow passing extra params to buildTokenRequest method
alekitto Feb 9, 2020
a0a648e
use built-in ksort, not the external one
alekitto Feb 9, 2020
35f30f2
fix web requester constructor signature
alekitto Feb 9, 2020
5df19e8
eslint
alekitto Feb 7, 2020
0cc8748
move oauth authenticators to their own namespace
alekitto Feb 16, 2020
5bbe39a
add code grant flow openid connect authenticator
alekitto Feb 17, 2020
7f80459
make code flow constructor public
alekitto Feb 19, 2020
bf93cb9
missing export
alekitto Feb 19, 2020
17c9e8d
remove mergePatch operation from client
alekitto Feb 20, 2020
ecb6f76
do not overwrite content-type in body converter if already set
alekitto Feb 20, 2020
8b7b627
missing method from class declaration
alekitto Feb 20, 2020
908cfda
add proper logout flow for openid connect
alekitto Feb 20, 2020
8ef9d91
missing default keyword
alekitto Feb 20, 2020
e141d3e
export AuthFlowDisplay enum
alekitto Feb 20, 2020
03829b0
configurable post logout redirect uri for openid connect
alekitto Feb 20, 2020
758f782
add state parameter to oidc logout method
alekitto Feb 20, 2020
28740e2
add implicit flow authenticator (to be tested)
alekitto May 11, 2020
7bce1ae
fix implicit flow token refresh
alekitto Jun 14, 2020
9253438
some other fixes to implicit flow handler
alekitto Jun 14, 2020
060efe8
search for error into query params in implicit flow
alekitto Jun 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
/// <reference lib="es2015" />
/// <reference path="lib/Api/Client.d.ts" />
/// <reference path="lib/Api/ClientInterface.d.ts" />
/// <reference path="lib/Api/ContextualClientInterface.d.ts" />
/// <reference path="lib/Exception/HttpException.d.ts" />
/// <reference path="lib/Exception/NotFoundHttpException.d.ts" />
/// <reference path="lib/Exception/NoTokenAvailableException.d.ts" />
/// <reference path="lib/Requestor/Headers.d.ts" />
/// <reference path="lib/Requestor/HttpMessage.d.ts" />
/// <reference path="lib/Requestor/Request.d.ts" />
/// <reference path="lib/Requestor/RequestorInterface.d.ts" />
/// <reference path="lib/Requestor/Response.d.ts" />
/// <reference path="lib/Requestor/WebRequestor.d.ts" />
/// <reference path="lib/Http/Client.d.ts" />
/// <reference path="lib/Http/ClientInterface.d.ts" />
/// <reference path="lib/Requester/Decorator/Authentication/HttpBasicAuthenticator.d.ts" />
/// <reference path="lib/Requester/Decorator/Authentication/OAuth/ClientTokenAuthenticator.d.ts" />
/// <reference path="lib/Requester/Decorator/Authentication/OAuth/TokenPasswordAuthenticator.d.ts" />
/// <reference path="lib/Requester/Decorator/BodyConverterDecorator.d.ts" />
/// <reference path="lib/Requester/Decorator/DecoratorInterface.d.ts" />
/// <reference path="lib/Requester/Decorator/UrlDecorator.d.ts" />
/// <reference path="lib/Requester/Decorator/VersionSetterDecorator.d.ts" />
/// <reference path="lib/Requester/Header/Accept.d.ts" />
/// <reference path="lib/Requester/Header/BaseAccept.d.ts" />
/// <reference path="lib/Requester/Headers.d.ts" />
/// <reference path="lib/Requester/HttpMessage.d.ts" />
/// <reference path="lib/Requester/Request.d.ts" />
/// <reference path="lib/Requester/RequesterInterface.d.ts" />
/// <reference path="lib/Requester/Response.d.ts" />
/// <reference path="lib/Requester/WebRequester.d.ts" />
/// <reference path="lib/Storage/Marshaller/JSONMarshaller.d.ts" />
/// <reference path="lib/Storage/Marshaller/NullMarshaller.d.ts" />
/// <reference path="lib/Storage/AbstractStorage.d.ts" />
Expand Down
72 changes: 13 additions & 59 deletions lib/Api/Client.d.ts
Original file line number Diff line number Diff line change
@@ -1,82 +1,36 @@
import BaseClient from '../Http/Client';
import ClientInterface from './ClientInterface';
import ContextualClientInterface from './ContextualClientInterface';
import Request from "../Requestor/Request";
import Response from '../Requestor/Response';
import RequestorInterface from '../Requestor/RequestorInterface';
import RequesterInterface from '../Requester/RequesterInterface';
import StorageInterface from '../Storage/StorageInterface';
import Response from "../Requester/Response";

declare interface ClientConfig {
client_id: string;
client_secret: string;
base_url: string;
version?: string;
}

declare class ContextualClient extends Client implements ContextualClientInterface {
constructor(tokenStorage: StorageInterface, requestor: RequestorInterface, clientTokenStorage: StorageInterface, config: ClientConfig);

/**
* Authenticates user.
*/
authenticate(username: string, password: string): Promise<void>;

/**
* Logs user out.
*/
logout(): Promise<void>;
}

declare class Client implements ClientInterface {
/**
* Token mutex.
*/
protected _tokenMutex: __jymfony.Mutex;

constructor(requestor: RequestorInterface, tokenStorage: StorageInterface, config: ClientConfig);

/**
* @inheritdoc
*/
request<T = any>(method: string, path: string, requestData?: any, headers?: {}): Promise<Response<T>>;

/**
* @inheritdoc
*/
get<T = any>(path: string, headers?: {}): Promise<Response<T>>;

/**
* @inheritdoc
*/
post<T = any>(path: string, requestData?: any, headers?: {}): Promise<Response<T>>;

/**
* @inheritdoc
*/
put<T = any>(path: string, requestData?: any, headers?: {}): Promise<Response<T>>;

/**
* @inheritdoc
*/
patch<T = any>(path: string, requestData?: any, headers?: {}): Promise<Response<T>>;
/**
* @deprecated Api.Client has been deprecated. Please use Http.Client instead.
*/
declare class Client extends BaseClient implements ClientInterface {
constructor(requester: RequesterInterface, tokenStorage: StorageInterface, config: ClientConfig);

/**
* @inheritdoc
*/
mergePatch<T = any>(path: string, requestData?: any, headers?: {}): Promise<Response<T>>;

/**
* @inheritdoc
*/
withContext(tokenStorage: StorageInterface): ContextualClientInterface;

/**
* Filters a response, eventually throwing an error in case response status is not successful.
* Authenticates user.
*/
protected _filterResponse(request: Request, response: Response): void;
authenticate(username: string, password: string): Promise<void>;

/**
* Gets the token for the current api client.
* Logs user out.
*/
protected _getToken(): Promise<string>;
logout(): Promise<void>;
}

export default Client;
Loading