@jmondi/oauth2-server
Advanced tools
Comparing version 0.2.0-beta.3 to 0.2.0-beta.4
@@ -5,14 +5,3 @@ import { GrantInterface } from "~/grants/abstract/grant.interface"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
export declare type DateIntervalType = string; | ||
export declare class DateInterval { | ||
private readonly interval; | ||
readonly init: number; | ||
readonly ms: number; | ||
constructor(interval: DateIntervalType); | ||
getEndDate(): Date; | ||
getEndTimeMs(): number; | ||
getEndTimeSeconds(): number; | ||
getSeconds(): number; | ||
static getDateEnd(ms: string): Date; | ||
} | ||
import { DateInterval } from "~/utils/date_interval"; | ||
export declare class AuthorizationServer { | ||
@@ -19,0 +8,0 @@ private readonly enabledGrantTypes; |
/// <reference types="node" /> | ||
import { DateInterval } from "~/authorization_server"; | ||
import { OAuthAuthCode } from "~/entities/auth_code.entity"; | ||
@@ -18,2 +17,3 @@ import { OAuthClient } from "~/entities/client.entity"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
import { JwtService } from "~/utils/jwt"; | ||
@@ -20,0 +20,0 @@ export interface ITokenData { |
@@ -1,5 +0,5 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { AuthorizationRequest } from "~/requests/authorization.request"; | ||
import { RequestInterface } from "~/requests/request"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
export declare type GrantIdentifier = "authorization_code" | "client_credentials" | "refresh_token" | "password" | "implicit"; | ||
@@ -6,0 +6,0 @@ export interface GrantInterface { |
@@ -1,2 +0,1 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { AbstractAuthorizedGrant } from "~/grants/abstract/abstract_authorized.grant"; | ||
@@ -7,2 +6,3 @@ import { GrantIdentifier } from "~/grants/abstract/grant.interface"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
export interface IAuthCodePayload { | ||
@@ -9,0 +9,0 @@ client_id: string; |
@@ -1,5 +0,5 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { AbstractGrant } from "~/grants/abstract/abstract.grant"; | ||
import { RequestInterface } from "~/requests/request"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
export declare class ClientCredentialsGrant extends AbstractGrant { | ||
@@ -6,0 +6,0 @@ readonly identifier = "client_credentials"; |
@@ -1,2 +0,1 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { AbstractAuthorizedGrant } from "~/grants/abstract/abstract_authorized.grant"; | ||
@@ -6,2 +5,3 @@ import { AuthorizationRequest } from "~/requests/authorization.request"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
export declare class ImplicitGrant extends AbstractAuthorizedGrant { | ||
@@ -8,0 +8,0 @@ readonly identifier = "implicit"; |
@@ -1,5 +0,5 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { AbstractGrant } from "~/grants/abstract/abstract.grant"; | ||
import { RequestInterface } from "~/requests/request"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
export declare class PasswordGrant extends AbstractGrant { | ||
@@ -6,0 +6,0 @@ readonly identifier = "password"; |
@@ -1,5 +0,5 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { AbstractGrant } from "~/grants/abstract/abstract.grant"; | ||
import { RequestInterface } from "~/requests/request"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
export declare class RefreshTokenGrant extends AbstractGrant { | ||
@@ -6,0 +6,0 @@ readonly identifier = "refresh_token"; |
@@ -31,3 +31,4 @@ export * from "./authorization_server"; | ||
export * from "./utils/base64"; | ||
export * from "./utils/date_interval"; | ||
export * from "./utils/jwt"; | ||
export * from "./utils/time"; |
{ | ||
"version": "0.2.0-beta.3", | ||
"version": "0.2.0-beta.4", | ||
"license": "MIT", | ||
"name": "@jmondi/oauth2-server", | ||
"author": "Jason Raimondi", | ||
"module": "src/index.ts", | ||
"module": "dist/jmondi-oauth2-server.js", | ||
"main": "dist/jmondi-oauth2-server.js", | ||
@@ -8,0 +8,0 @@ "typings": "dist/index.d.ts", |
@@ -1,3 +0,1 @@ | ||
import ms from "ms"; | ||
import { OAuthException } from "~/exceptions/oauth.exception"; | ||
@@ -8,35 +6,4 @@ import { GrantInterface } from "~/grants/abstract/grant.interface"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
export type DateIntervalType = string; | ||
export class DateInterval { | ||
public readonly init: number; | ||
public readonly ms: number; | ||
constructor(private readonly interval: DateIntervalType) { | ||
this.init = Date.now(); | ||
this.ms = ms(interval); | ||
} | ||
getEndDate(): Date { | ||
return new Date(this.getEndTimeMs()); | ||
} | ||
getEndTimeMs(): number { | ||
return this.init + this.ms; | ||
} | ||
getEndTimeSeconds(): number { | ||
return Math.ceil(this.getEndTimeMs() / 1000); | ||
} | ||
getSeconds(): number { | ||
return Math.ceil(this.ms / 1000); | ||
} | ||
static getDateEnd(ms: string) { | ||
return new DateInterval(ms).getEndDate(); | ||
} | ||
} | ||
export class AuthorizationServer { | ||
@@ -43,0 +10,0 @@ private readonly enabledGrantTypes: { [key: string]: GrantInterface } = {}; |
@@ -1,2 +0,1 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { OAuthAuthCode } from "~/entities/auth_code.entity"; | ||
@@ -20,2 +19,3 @@ import { isClientConfidential, OAuthClient } from "~/entities/client.entity"; | ||
import { base64decode } from "~/utils/base64"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
import { JwtService } from "~/utils/jwt"; | ||
@@ -22,0 +22,0 @@ import { getSecondsUntil, roundToSeconds } from "~/utils/time"; |
@@ -1,5 +0,5 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { AuthorizationRequest } from "~/requests/authorization.request"; | ||
import { RequestInterface } from "~/requests/request"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
@@ -6,0 +6,0 @@ export type GrantIdentifier = "authorization_code" | "client_credentials" | "refresh_token" | "password" | "implicit"; |
@@ -1,2 +0,1 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { PlainVerifier } from "~/code_verifiers/plain.verifier"; | ||
@@ -15,2 +14,3 @@ import { S256Verifier } from "~/code_verifiers/s256.verifier"; | ||
import { base64decode } from "~/utils/base64"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
@@ -17,0 +17,0 @@ export interface IAuthCodePayload { |
@@ -1,5 +0,5 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { AbstractGrant } from "~/grants/abstract/abstract.grant"; | ||
import { RequestInterface } from "~/requests/request"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
@@ -6,0 +6,0 @@ export class ClientCredentialsGrant extends AbstractGrant { |
@@ -1,2 +0,1 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { OAuthException } from "~/exceptions/oauth.exception"; | ||
@@ -8,2 +7,3 @@ import { AbstractAuthorizedGrant } from "~/grants/abstract/abstract_authorized.grant"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
import { getSecondsUntil } from "~/utils/time"; | ||
@@ -76,3 +76,6 @@ | ||
if (!finalRedirectUri) { | ||
throw OAuthException.invalidRequest("redirect_uri", "Neither the request nor the client contain a valid refresh token") | ||
throw OAuthException.invalidRequest( | ||
"redirect_uri", | ||
"Neither the request nor the client contain a valid refresh token", | ||
); | ||
} | ||
@@ -79,0 +82,0 @@ |
@@ -1,2 +0,1 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { OAuthClient } from "~/entities/client.entity"; | ||
@@ -8,2 +7,3 @@ import { OAuthUser } from "~/entities/user.entity"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
@@ -10,0 +10,0 @@ export class PasswordGrant extends AbstractGrant { |
@@ -1,2 +0,1 @@ | ||
import { DateInterval } from "~/authorization_server"; | ||
import { OAuthAccessToken } from "~/entities/token.entity"; | ||
@@ -7,2 +6,3 @@ import { OAuthException } from "~/exceptions/oauth.exception"; | ||
import { ResponseInterface } from "~/responses/response"; | ||
import { DateInterval } from "~/utils/date_interval"; | ||
@@ -9,0 +9,0 @@ export class RefreshTokenGrant extends AbstractGrant { |
@@ -35,3 +35,4 @@ /** | ||
export * from "./utils/base64"; | ||
export * from "./utils/date_interval"; | ||
export * from "./utils/jwt"; | ||
export * from "./utils/time"; |
@@ -8,2 +8,2 @@ export function getSecondsUntil(date: Date) { | ||
return Math.ceil(ms / 1000); | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
582206
143
7793
0