@bytescale/sdk
Advanced tools
Comparing version 3.0.0-alpha.18 to 3.0.0-alpha.19
@@ -0,1 +1,14 @@ | ||
import { BytescaleApiClientConfig } from "../../public/shared"; | ||
export interface BeginAuthSessionParams extends Pick<BytescaleApiClientConfig, "fetchApi" | "cdnUrl" | "apiKey"> { | ||
/** | ||
* Headers to send to your backend API. | ||
* | ||
* IMPORTANT: do not call 'AuthManager.beginAuthSession' or 'AuthManager.endAuthSession' inside this callback, as this will cause a deadlock. | ||
*/ | ||
authHeaders: () => Promise<Record<string, string>>; | ||
/** | ||
* The fully-qualified URL for your backend API's auth endpoint. | ||
*/ | ||
authUrl: string; | ||
} | ||
export interface AuthManagerInterface { | ||
@@ -24,8 +37,4 @@ /** | ||
* 3) The JWT will also be added as a request header via 'authorization-token' to all Bytescale API requests made via this SDK. This allows the user to upload private files and perform administrative operations permitted by the JWT, such as deleting files, etc. | ||
* | ||
* @param authUrl The fully-qualified URL for your backend API's auth endpoint. | ||
* @param authHeaders Headers to send to your backend API. | ||
* IMPORTANT: do not call '*AuthSession' inside this callback, as this will cause a deadlock. | ||
*/ | ||
beginAuthSession: (authUrl: string, authHeaders: () => Promise<Record<string, string>>) => Promise<void>; | ||
beginAuthSession: (params: BeginAuthSessionParams) => Promise<void>; | ||
/** | ||
@@ -32,0 +41,0 @@ * Ends an authenticated Bytescale API and Bytescale CDN session. |
@@ -0,7 +1,7 @@ | ||
import { BeginAuthSessionParams } from "./AuthManagerInterface"; | ||
export interface AuthSession { | ||
accessToken: string | undefined; | ||
accessTokenRefreshHandle: number | undefined; | ||
authHeaders: () => Promise<Record<string, string>>; | ||
authUrl: string; | ||
isActive: boolean; | ||
params: BeginAuthSessionParams; | ||
} |
@@ -1,5 +0,3 @@ | ||
import { AuthManagerInterface } from "../../private/model/AuthManagerInterface"; | ||
import { BaseAPI, BytescaleApiClientConfig } from "../shared/generated"; | ||
export declare class AuthManager extends BaseAPI implements AuthManagerInterface { | ||
private readonly accessTokenUrl; | ||
import { AuthManagerInterface, BeginAuthSessionParams } from "../../private/model/AuthManagerInterface"; | ||
declare class AuthManagerImpl implements AuthManagerInterface { | ||
private readonly authSessionMutex; | ||
@@ -13,7 +11,8 @@ private readonly contentType; | ||
private readonly refreshBeforeExpirySeconds; | ||
constructor(config: BytescaleApiClientConfig); | ||
constructor(); | ||
isAuthSessionActive(): boolean; | ||
beginAuthSession(authUrl: string, authHeaders: () => Promise<Record<string, string>>): Promise<void>; | ||
beginAuthSession(params: BeginAuthSessionParams): Promise<void>; | ||
endAuthSession(): Promise<void>; | ||
private refreshAccessToken; | ||
private getAccessTokenUrl; | ||
private deleteAccessToken; | ||
@@ -23,1 +22,6 @@ private setAccessToken; | ||
} | ||
/** | ||
* Alternative way of implementing a static class (i.e. all methods static). We do this so we can use a interface on the class (interfaces can't define static methods). | ||
*/ | ||
export declare const AuthManager: AuthManagerImpl; | ||
export {}; |
@@ -1,6 +0,11 @@ | ||
import { AuthManagerInterface } from "../../private/model/AuthManagerInterface"; | ||
export declare class AuthManager implements AuthManagerInterface { | ||
beginAuthSession(_authUrl: string, _authHeaders: () => Promise<Record<string, string>>): Promise<void>; | ||
import { AuthManagerInterface, BeginAuthSessionParams } from "../../private/model/AuthManagerInterface"; | ||
declare class AuthManagerImpl implements AuthManagerInterface { | ||
beginAuthSession(_params: BeginAuthSessionParams): Promise<void>; | ||
endAuthSession(): Promise<void>; | ||
isAuthSessionActive(): boolean; | ||
} | ||
/** | ||
* Alternative way of implementing a static class (i.e. all methods static). We do this so we can use a interface on the class (interfaces can't define static methods). | ||
*/ | ||
export declare const AuthManager: AuthManagerImpl; | ||
export {}; |
@@ -48,5 +48,5 @@ import { ErrorResponse } from "./models"; | ||
static getApiUrl(config: BytescaleApiClientConfig): string; | ||
static getCdnUrl(config: BytescaleApiClientConfig): string; | ||
static getFetchApi(config: BytescaleApiClientConfig): FetchAPI; | ||
static getAccountId(config: BytescaleApiClientConfig): string; | ||
static getCdnUrl(config: Pick<BytescaleApiClientConfig, "cdnUrl">): string; | ||
static getFetchApi(config: Pick<BytescaleApiClientConfig, "fetchApi">): FetchAPI; | ||
static getAccountId(config: Pick<BytescaleApiClientConfig, "apiKey">): string; | ||
static validate(config: BytescaleApiClientConfig): void; | ||
@@ -60,7 +60,9 @@ } | ||
constructor(config: BytescaleApiClientConfig); | ||
protected request(context: RequestOpts, initOverrides: RequestInit | InitOverrideFunction | undefined, baseUrlOverride: string | undefined): Promise<Response>; | ||
/** | ||
* Returns a successful response (2**) else throws an error. | ||
*/ | ||
protected doFetch(url: string, init: RequestInit, isBytescaleApi: boolean): Promise<Response>; | ||
static fetch(url: string, init: RequestInit, config: Pick<BytescaleApiClientConfig, "fetchApi"> & { | ||
isBytescaleApi: boolean; | ||
}): Promise<Response>; | ||
protected request(context: RequestOpts, initOverrides: RequestInit | InitOverrideFunction | undefined, baseUrlOverride: string | undefined): Promise<Response>; | ||
protected encodeParam(paramName: string, paramValue: string): string; | ||
@@ -67,0 +69,0 @@ private createFetchParams; |
{ | ||
"name": "@bytescale/sdk", | ||
"version": "3.0.0-alpha.18", | ||
"version": "3.0.0-alpha.19", | ||
"description": "Bytescale JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
18355
853711