@edgedb/auth-core
Advanced tools
Comparing version 0.3.0-canary.20240731T133111 to 0.3.0-canary.20240731T160442
"use strict"; | ||
// AUTOGENERATED - Run `yarn gen-consts` to re-generate. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -4,0 +3,0 @@ exports.magicLinkProviderName = exports.webAuthnProviderName = exports.emailPasswordProviderName = exports.builtinOAuthProviderNames = void 0; |
@@ -6,10 +6,4 @@ import * as edgedb from "edgedb"; | ||
readonly client: edgedb.Client; | ||
/** @internal */ | ||
readonly baseUrl: string; | ||
protected constructor(client: edgedb.Client, baseUrl: string); | ||
static create(client: edgedb.Client): Promise<Auth>; | ||
/** @internal */ | ||
_get<T = unknown>(path: string, searchParams?: Record<string, string>): Promise<T>; | ||
/** @internal */ | ||
_post<T = unknown>(path: string, body?: object): Promise<T>; | ||
createPKCESession(): Promise<AuthPCKESession>; | ||
@@ -16,0 +10,0 @@ getToken(code: string, verifier: string): Promise<TokenData>; |
@@ -35,3 +35,2 @@ "use strict"; | ||
client; | ||
/** @internal */ | ||
baseUrl; | ||
@@ -48,7 +47,5 @@ constructor(client, baseUrl) { | ||
} | ||
/** @internal */ | ||
async _get(path, searchParams) { | ||
return (0, utils_1.requestGET)(new URL(path, this.baseUrl).href, searchParams); | ||
} | ||
/** @internal */ | ||
async _post(path, body) { | ||
@@ -232,3 +229,2 @@ return (0, utils_1.requestPOST)(new URL(path, this.baseUrl).href, body); | ||
async getProvidersInfo() { | ||
// TODO: cache this data when we have a way to invalidate on config update | ||
try { | ||
@@ -275,30 +271,2 @@ return await this.client.queryRequiredSingle(` | ||
} | ||
// getEmailPasswordSigninFormActionUrl( | ||
// redirectTo: string, | ||
// redirectToOnFailure?: string | ||
// ) { | ||
// const params = new URLSearchParams({ | ||
// provider_name: emailPasswordProviderName, | ||
// challenge: this.challenge, | ||
// redirect_to: redirectTo, | ||
// }); | ||
// if (redirectToOnFailure) { | ||
// params.append("redirect_on_failure", redirectToOnFailure); | ||
// } | ||
// return `${this.auth.baseUrl}/authenticate?${params.toString()}`; | ||
// } | ||
// getEmailPasswordSignupFormActionUrl( | ||
// redirectTo: string, | ||
// redirectToOnFailure?: string | ||
// ) { | ||
// const params = new URLSearchParams({ | ||
// provider_name: emailPasswordProviderName, | ||
// challenge: this.challenge, | ||
// redirect_to: redirectTo, | ||
// }); | ||
// if (redirectToOnFailure) { | ||
// params.append("redirect_on_failure", redirectToOnFailure); | ||
// } | ||
// return `${this.auth.baseUrl}/register?${params.toString()}`; | ||
// } | ||
getHostedUISigninUrl() { | ||
@@ -305,0 +273,0 @@ const url = new URL("ui/signin", this.auth.baseUrl); |
@@ -30,3 +30,2 @@ "use strict"; | ||
function base64UrlToBytes(base64url) { | ||
// Add padding if necessary | ||
let paddedBase64url = base64url; | ||
@@ -33,0 +32,0 @@ const padLength = base64url.length % 4; |
@@ -1,86 +0,60 @@ | ||
/** Base class for all exceptions raised by the auth extension. */ | ||
export declare class EdgeDBAuthError extends Error { | ||
get type(): string; | ||
} | ||
/** Error returned by auth extension could not be decoded into a | ||
* known error class. | ||
*/ | ||
export declare class UnknownError extends EdgeDBAuthError { | ||
get type(): string; | ||
} | ||
/** Base class for all backend auth extension errors. It is not recommended to | ||
* return these errors to the user. | ||
*/ | ||
export declare class BackendError extends EdgeDBAuthError { | ||
get type(): string; | ||
} | ||
/** Base class for all errors arising during normal use of the auth extension. | ||
* These errors are considered safe to return to the user. | ||
*/ | ||
export declare class UserError extends EdgeDBAuthError { | ||
get type(): string; | ||
} | ||
/** Required resource could not be found. */ | ||
export declare class NotFoundError extends EdgeDBAuthError { | ||
get type(): string; | ||
} | ||
/** Error in auth extension configuration. */ | ||
export declare class ConfigurationError extends BackendError { | ||
get type(): string; | ||
} | ||
/** Required configuration is missing. */ | ||
export declare class MissingConfigurationError extends ConfigurationError { | ||
get type(): string; | ||
} | ||
/** Data received from the auth provider is invalid. */ | ||
export declare class MisconfiguredProviderError extends ConfigurationError { | ||
get type(): string; | ||
} | ||
/** Data received from the client is invalid. */ | ||
export declare class InvalidDataError extends UserError { | ||
get type(): string; | ||
} | ||
/** Could not find a matching identity. */ | ||
export declare class NoIdentityFoundError extends UserError { | ||
get type(): string; | ||
} | ||
/** Attempt to register an already registered handle. */ | ||
export declare class UserAlreadyRegisteredError extends UserError { | ||
get type(): string; | ||
} | ||
/** OAuth Provider returned a non-success for some part of the flow. */ | ||
export declare class OAuthProviderFailureError extends UserError { | ||
get type(): string; | ||
} | ||
/** Magic link flow failed. */ | ||
export declare class MagicLinkFailureError extends UserError { | ||
get type(): string; | ||
} | ||
/** Error with email verification. */ | ||
export declare class VerificationError extends UserError { | ||
get type(): string; | ||
} | ||
/** Email verification token has expired. */ | ||
export declare class VerificationTokenExpiredError extends VerificationError { | ||
get type(): string; | ||
} | ||
/** Email verification is required. */ | ||
export declare class VerificationRequiredError extends VerificationError { | ||
get type(): string; | ||
} | ||
/** Error during PKCE flow. */ | ||
export declare class PKCEError extends UserError { | ||
get type(): string; | ||
} | ||
/** Failed to create a valid PKCEChallenge object. */ | ||
export declare class PKCECreationFailedError extends PKCEError { | ||
get type(): string; | ||
} | ||
/** Verifier and challenge do not match. */ | ||
export declare class PKCEVerificationFailedError extends PKCEError { | ||
get type(): string; | ||
} | ||
/** WebAuthn authentication failed. */ | ||
export declare class WebAuthnAuthenticationFailedError extends UserError { | ||
get type(): string; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WebAuthnAuthenticationFailedError = exports.PKCEVerificationFailedError = exports.PKCECreationFailedError = exports.PKCEError = exports.VerificationRequiredError = exports.VerificationTokenExpiredError = exports.VerificationError = exports.MagicLinkFailureError = exports.OAuthProviderFailureError = exports.UserAlreadyRegisteredError = exports.NoIdentityFoundError = exports.InvalidDataError = exports.MisconfiguredProviderError = exports.MissingConfigurationError = exports.ConfigurationError = exports.NotFoundError = exports.UserError = exports.BackendError = exports.UnknownError = exports.EdgeDBAuthError = void 0; | ||
/** Base class for all exceptions raised by the auth extension. */ | ||
class EdgeDBAuthError extends Error { | ||
@@ -11,5 +10,2 @@ get type() { | ||
exports.EdgeDBAuthError = EdgeDBAuthError; | ||
/** Error returned by auth extension could not be decoded into a | ||
* known error class. | ||
*/ | ||
class UnknownError extends EdgeDBAuthError { | ||
@@ -21,5 +17,2 @@ get type() { | ||
exports.UnknownError = UnknownError; | ||
/** Base class for all backend auth extension errors. It is not recommended to | ||
* return these errors to the user. | ||
*/ | ||
class BackendError extends EdgeDBAuthError { | ||
@@ -31,5 +24,2 @@ get type() { | ||
exports.BackendError = BackendError; | ||
/** Base class for all errors arising during normal use of the auth extension. | ||
* These errors are considered safe to return to the user. | ||
*/ | ||
class UserError extends EdgeDBAuthError { | ||
@@ -41,3 +31,2 @@ get type() { | ||
exports.UserError = UserError; | ||
/** Required resource could not be found. */ | ||
class NotFoundError extends EdgeDBAuthError { | ||
@@ -49,3 +38,2 @@ get type() { | ||
exports.NotFoundError = NotFoundError; | ||
/** Error in auth extension configuration. */ | ||
class ConfigurationError extends BackendError { | ||
@@ -57,3 +45,2 @@ get type() { | ||
exports.ConfigurationError = ConfigurationError; | ||
/** Required configuration is missing. */ | ||
class MissingConfigurationError extends ConfigurationError { | ||
@@ -65,3 +52,2 @@ get type() { | ||
exports.MissingConfigurationError = MissingConfigurationError; | ||
/** Data received from the auth provider is invalid. */ | ||
class MisconfiguredProviderError extends ConfigurationError { | ||
@@ -73,3 +59,2 @@ get type() { | ||
exports.MisconfiguredProviderError = MisconfiguredProviderError; | ||
/** Data received from the client is invalid. */ | ||
class InvalidDataError extends UserError { | ||
@@ -81,3 +66,2 @@ get type() { | ||
exports.InvalidDataError = InvalidDataError; | ||
/** Could not find a matching identity. */ | ||
class NoIdentityFoundError extends UserError { | ||
@@ -89,3 +73,2 @@ get type() { | ||
exports.NoIdentityFoundError = NoIdentityFoundError; | ||
/** Attempt to register an already registered handle. */ | ||
class UserAlreadyRegisteredError extends UserError { | ||
@@ -97,3 +80,2 @@ get type() { | ||
exports.UserAlreadyRegisteredError = UserAlreadyRegisteredError; | ||
/** OAuth Provider returned a non-success for some part of the flow. */ | ||
class OAuthProviderFailureError extends UserError { | ||
@@ -105,3 +87,2 @@ get type() { | ||
exports.OAuthProviderFailureError = OAuthProviderFailureError; | ||
/** Magic link flow failed. */ | ||
class MagicLinkFailureError extends UserError { | ||
@@ -113,3 +94,2 @@ get type() { | ||
exports.MagicLinkFailureError = MagicLinkFailureError; | ||
/** Error with email verification. */ | ||
class VerificationError extends UserError { | ||
@@ -121,3 +101,2 @@ get type() { | ||
exports.VerificationError = VerificationError; | ||
/** Email verification token has expired. */ | ||
class VerificationTokenExpiredError extends VerificationError { | ||
@@ -129,3 +108,2 @@ get type() { | ||
exports.VerificationTokenExpiredError = VerificationTokenExpiredError; | ||
/** Email verification is required. */ | ||
class VerificationRequiredError extends VerificationError { | ||
@@ -137,3 +115,2 @@ get type() { | ||
exports.VerificationRequiredError = VerificationRequiredError; | ||
/** Error during PKCE flow. */ | ||
class PKCEError extends UserError { | ||
@@ -145,3 +122,2 @@ get type() { | ||
exports.PKCEError = PKCEError; | ||
/** Failed to create a valid PKCEChallenge object. */ | ||
class PKCECreationFailedError extends PKCEError { | ||
@@ -153,3 +129,2 @@ get type() { | ||
exports.PKCECreationFailedError = PKCECreationFailedError; | ||
/** Verifier and challenge do not match. */ | ||
class PKCEVerificationFailedError extends PKCEError { | ||
@@ -161,3 +136,2 @@ get type() { | ||
exports.PKCEVerificationFailedError = PKCEVerificationFailedError; | ||
/** WebAuthn authentication failed. */ | ||
class WebAuthnAuthenticationFailedError extends UserError { | ||
@@ -164,0 +138,0 @@ get type() { |
{ | ||
"name": "@edgedb/auth-core", | ||
"description": "Core helper library for the EdgeDB Auth extension", | ||
"version": "0.3.0-canary.20240731T133111", | ||
"version": "0.3.0-canary.20240731T160442", | ||
"author": "EdgeDB <info@edgedb.com>", | ||
@@ -30,10 +30,13 @@ "repository": { | ||
"typecheck": "tsc --project tsconfig.json --noEmit", | ||
"test": "jest --detectOpenHandles", | ||
"test": "echo 'No tests. Done.'", | ||
"build": "tsc --project tsconfig.json", | ||
"lint": "eslint --quiet", | ||
"lint:fix": "eslint --fix", | ||
"gen-consts": "node genConsts.js" | ||
}, | ||
"devDependencies": { | ||
"@repo/tsconfig": "*", | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.12.13", | ||
"edgedb": "^1.5.0", | ||
"edgedb": "*", | ||
"jest": "29.7.0", | ||
@@ -40,0 +43,0 @@ "ts-jest": "29.1.4", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38932
7
971
3