Skip to content

Commit

Permalink
Revert "provide functions updated (#16)" (#17)
Browse files Browse the repository at this point in the history
This reverts commit bda4ab7.
  • Loading branch information
mrpachara authored Jun 7, 2023
1 parent bda4ab7 commit 2c66b0b
Show file tree
Hide file tree
Showing 24 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import {
NonRegisteredExtractorError,
RefreshTokenExpiredError,
RefreshTokenNotFoundError,
} from '../errors';
} from './errors';
import { Oauth2Client } from './oauth2.client';
import { AccessTokenStorage, AccessTokenStorageFactory } from '../storage';
import { AccessTokenStorage, AccessTokenStorageFactory } from './storage';
import {
AccessTokenFullConfig,
AccessTokenInfo,
Expand All @@ -38,7 +38,7 @@ import {
Provided,
StandardGrantsParams,
StoredAccessTokenResponse,
} from '../types';
} from './types';
import { RefreshTokenService } from './refresh-token.service';

const latencyTime = 2 * 5 * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import {
} from '@angular/core';
import { Observable } from 'rxjs';

import { configAccessToken, configRefreshToken } from './functions';
import {
AccessTokenService,
Oauth2Client,
RefreshTokenService,
} from './services';
import { ACCESS_TOKEN_SERVICES, RENEW_ACCESS_TOKEN_SOURCE } from './tokens';
import {
AccessTokenConfig,
Expand All @@ -22,6 +16,10 @@ import {
AccessTokenResponseExtractor,
AccessTokenResponseExtractorInfo,
} from './types';
import { RefreshTokenService } from './refresh-token.service';
import { configAccessToken, configRefreshToken } from './functions';
import { AccessTokenService } from './access-token.service';
import { Oauth2Client } from './oauth2.client';

export function provideAccessToken(
config: AccessTokenConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import {
makeEnvironmentProviders,
} from '@angular/core';

import { AuthorizationCodeConfig, AuthorizationCodeFullConfig } from './types';
import { configAuthorizationCode } from './functions';
import { AuthorizationCodeService, Oauth2Client } from './services';

import { AuthorizationCodeService } from './authorization-code.service';
import { Oauth2Client } from './oauth2.client';
import { AUTHORIZATION_CODE_SERVICES } from './tokens';
import { AuthorizationCodeConfig, AuthorizationCodeFullConfig } from './types';

export function provideAuthorizationCode(
config: AuthorizationCodeConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
makeEnvironmentProviders,
} from '@angular/core';

import { JwkConfig, JwkFullConfig } from './types';
import { configJwk } from './functions';
import { JwkService } from './services';
import { JwkService } from './jwk.service';
import { JWK_SERVICES, JWT_INITIALIZED_STATE, JWT_VERIFIERS } from './tokens';
import { JwkConfig, JwkFullConfig } from './types';

import { JwtEcdsaVerifier } from './jwt-verifiers/jwt-ecdsa.verifier';
import { JwtHmacVerifier } from './jwt-verifiers/jwt-hmac.verifier';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import {
Type,
makeEnvironmentProviders,
} from '@angular/core';

import { JwtVerifier } from '@mrpachara/ngx-oauth2-access-token';
import { JWT_VERIFIERS } from './tokens';
import { JwtVerifier } from './types';

export function provideJwtVerifiers(
...verifiers: (Type<JwtVerifier> | InjectionToken<JwtVerifier>)[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export function provideKeyValuePairStorage(
version: bigint,
...features: KeyValuepairStorageFeatures[]
): EnvironmentProviders {
const providerFeatures = features.filter(
const selfProviders = features.filter(
(feature): feature is KeyValuepairStorageProviderFeature =>
feature.kind ===
KeyValuepairStorageFeatureKind.KeyValuepairStorageProviderFeature,
);

if (providerFeatures.length > 1) {
if (selfProviders.length > 1) {
throw new Error(
'Only one accessTokenProvider feature allowed for AuthorizationCode!',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import {
} from '@angular/core';

import { configOauth2Client } from './functions';
import { Oauth2Client } from './services';
import { OATUTH2_CLIENTS, OAUTH2_CLIENT_ERROR_TRANSFORMER } from './tokens';
import {
Oauth2ClientConfig,
Oauth2ClientErrorTransformer,
Oauth2ClientFullConfig,
} from './types';
import { OATUTH2_CLIENTS, OAUTH2_CLIENT_ERROR_TRANSFORMER } from './tokens';

import { Oauth2Client } from './oauth2.client';

export function provideOauth2Client(
config: Oauth2ClientConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ export function withStateActionHandler<I extends StateActionInfo>(
};
}

type MyActionInfo = StateActionInfo<
'my_action',
{ a: string; b: number; c?: boolean }
>;

withStateActionHandler<MyActionInfo>(
'my_action',
() => async (accessTokenResponse, stateData) => {
console.log(accessTokenResponse);
stateData.action.data;
},
);

export type StateActionErrorHandlerFeature =
StateActionFeature<StateActionFeatureKind.StateActionErrorHandlerFeature>;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { InjectionToken } from '@angular/core';
import { Observable } from 'rxjs';

import { AccessTokenResponse } from '../types';
import { AccessTokenService } from '../services/access-token.service';
import { AccessTokenService } from '../access-token.service';
import { AuthorizationCodeService } from '../authorization-code.service';

export const ACCESS_TOKEN_SERVICES = new InjectionToken<AccessTokenService[]>(
Expand Down
7 changes: 6 additions & 1 deletion projects/mrpachara/ngx-oauth2-access-token/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export * from './lib/functions';
// TODO: may be removed. Storage may use internally.
export * from './lib/storage';

export * from './lib/services';
export * from './lib/oauth2.client';
export * from './lib/access-token.service';
export * from './lib/authorization-code.service';
export * from './lib/refresh-token.service';
export * from './lib/id-token.service';
export * from './lib/jwk.service';

// TODO: removed
// export * from './lib/jwt-verifiers/jwt-hmac.verifier';
Expand Down

0 comments on commit 2c66b0b

Please sign in to comment.