New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@privy-io/api-base

Package Overview
Dependencies
Maintainers
8
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@privy-io/api-base - npm Package Compare versions

Comparing version 0.5.0-beta-20231102205435 to 1.0.0-beta-20240417214736

395

dist/index.d.ts

@@ -1,8 +0,9 @@

import * as zod from 'zod';
import { ZodType, ZodCatch, z } from 'zod';
import { z } from 'zod';
declare enum PrivyErrorCode {
/** The Privy app id is either not provided or not valid. Check the developer console to verify you are setting the correct value. */
/** The user's OAuth account is suspended and is not allowed. */
OAUTH_ACCOUNT_SUSPENDED = "oauth_account_suspended",
/** The Privy app id is either not provided or not valid. Check the developer dashboard to verify you are setting the correct value. */
MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
/** The Privy account id is either not provided or not valid. Check the developer console to verify you are setting the correct value. */
/** The Privy account id is either not provided or not valid. Check the developer dashboard to verify you are setting the correct value. */
MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id",

@@ -19,2 +20,4 @@ /** The refresh or access token is either not provided or not valid. */

INVALID_CREDENTIALS = "invalid_credentials",
/** When the user is trying to authenticate and did provide a valid CAPTCHA token. */
INVALID_CAPTCHA = "invalid_captcha",
/** You attempted to link an account that belongs to another user. */

@@ -50,2 +53,4 @@ LINKED_TO_ANOTHER_USER = "linked_to_another_user",

MAX_APPS_REACHED = "max_apps_reached",
/** You have reached the maximum number of users allowed per app. */
USER_LIMIT_REACHED = "max_accounts_reached",
/** You are trying to reconstruct an embedded wallet on a device that has been marked as revoked */

@@ -56,3 +61,15 @@ DEVICE_REVOKED = "device_revoked",

/** The user attempted to complete an oauth flow with a different state than started. */
OAUTH_STATE_MISMATCH = "oauth_state_mismatch"
OAUTH_STATE_MISMATCH = "oauth_state_mismatch",
/** You have reached the maximum number of denylist entries allowed per app. */
MAX_DENYLIST_ENTRIES_REACHED = "max_denylist_entries_reached",
/** The user attempted to log in or link a disallowed method. */
DISALLOWED_LOGIN_METHOD = "disallowed_login_method",
/** The user attempted to recover their embedded wallet via a disallowed method. */
DISALLOWED_RECOVERY_METHOD = "disallowed_recovery_method",
/** The customer must enforce login methods through the dashboard */
LEGACY_DASHBOARD_LOGIN_CONFIGURATION = "legacy_dashboard_login_configuration",
/** Cannot set password on this wallet */
CANNOT_SET_PASSWORD = "cannot_set_password",
/** Invalid PKCE parameters */
INVALID_PKCE_PARAMETERS = "invalid_pkce_parameters"
}

@@ -112,368 +129,2 @@

declare enum HttpMethod {
GET = "get",
POST = "post",
PATCH = "patch",
DELETE = "delete",
PUT = "put"
}
declare enum MimeType {
APPLICATION_JSON = "application/json"
}
declare enum StatusCode {
OK = 200,
CREATED = 201,
NO_CONTENT = 204,
MOVED_PERMANENTLY = 301,
MOVED_TEMPORARILY = 302,
NOT_MODIFIED = 304,
BAD_REQUEST = 400,
NOT_AUTHENTICATED = 401,
FORBIDDEN = 403,
NOT_FOUND = 404,
METHOD_NOT_ALLOWED = 405,
UNSUPPORTED_MEDIA_TYPE = 415,
UNPROCESSABLE_CONTENT = 422,
TOO_MANY_REQUESTS = 429,
INTERNAL_SERVER_ERROR = 500,
NOT_IMPLEMENTED = 501,
BAD_GATEWAY = 502,
SERVICE_UNAVAILABLE = 503,
GATEWAY_TIME_OUT = 504,
HTTP_VERSION_NOT_SUPPORTED = 505
}
type PathParam = string | number;
/**
* PathParams is a recursive type that parses a path string and creates an object type
* where each property is a path parameter and its value is a PathParam type.
*/
type PathParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
[K in Param | keyof PathParams<Rest>]: PathParam;
} : T extends `${infer _Start}:${infer Param}` ? {
[K in Param]: PathParam;
} : Record<string, string>;
type TBaseQuery = {
[name: string]: string | number | boolean | undefined;
};
type TBaseBody = unknown;
type TBaseResponse = unknown | ArrayBuffer;
/**
* TBaseResponseStatusCodeMap is a type that maps each StatusCode to a TBaseResponse.
* It is used to define the expected response type for each possible HTTP status code.
* @template K - A key that extends StatusCode.
*/
type TBaseResponseStatusCodeMap = {
[K in StatusCode]: TBaseResponse;
};
/**
* ZodTypeOrCatch is a type that can either be a ZodCatch of a ZodType or a ZodType itself.
* It is used to define the type of a value that can either be a valid ZodType or a ZodCatch, which represents an error.
* @template T - The type that the ZodType or ZodCatch is expected to validate.
*/
type ZodTypeOrCatch<T> = ZodCatch<ZodType<T>> | ZodType<T>;
/**
* IRouteNamedTypes is an interface that defines the types for a route.
* It includes the expected response type, the name of the route, the HTTP method, the path,
* the type of path parameters, the type of query parameters, the type of the body,
* the type of the response, and the expected status code.
*
* @template Name - A string that uniquely identifies the route.
* @template Path - The URL path of the route. It can include path parameters, denoted by a colon prefix (e.g., '/user/:id').
* @template ExpectedResponseType - An object type representing the expected structure of the response. It should be a subtype of TBaseResponse.
* @template ExpectedStatusCode - The expected HTTP status code of the response. It should be a StatusCode. Default is StatusCode.OK.
*/
interface IRouteNamedTypes<Path extends string, ExpectedResponseType extends TBaseResponse, ExpectedStatusCode extends StatusCode = StatusCode.OK> {
Name: string;
Method: HttpMethod;
PathParamsType: PathParams<Path>;
PathQueryType: TBaseQuery;
BodyType: TBaseBody;
ResponseType: Partial<TBaseResponseStatusCodeMap> & Record<ExpectedStatusCode, ExpectedResponseType>;
ExpectedStatusCode: ExpectedStatusCode;
}
/**
* BaseRouteType is a type alias for IRouteNamedTypes with default parameters.
* It represents a basic route type with a string name, string path, TBaseResponse as the expected response type,
* and StatusCode.OK as the expected status code.
* This type is used as a default in the `Route` class.
*/
type BaseRouteType = IRouteNamedTypes<string, TBaseResponse, StatusCode.OK>;
/**
* Sample Usage
*
* @example
* const route = new Route({
* name: 'Test',
* method: HttpMethod.GET,
* path: '/test/:id/:s',
* pathParamsSchema: z.object({
* id: z.string(),
* s: z.string()
* }),
* pathQuerySchema: z.object({
* name: z.string()
* }),
* bodySchema: z.object({
* name: z.string()
* }),
* responseSchema: {
* [StatusCode.OK]: Route.toJSONResponseSchema(z.object({
* name: z.string()
* }), 'OK')),
* }
* });
*/
/**
* The Route class is a blueprint for defining HTTP routes in an application.
* It encapsulates all the necessary details about a route such as its name, HTTP method, path, and expected response.
* It also includes schemas for validating path parameters, query parameters, request body, and response.
*
* @property {string} Path - The URL path of the route. It can include path parameters, denoted by a colon prefix (e.g., '/user/:id').
* @property {ExpectedResponseType} ExpectedResponseType - An object type representing the expected structure of the response. It should be a subtype of TBaseResponse.
* @template T - An object that includes the following properties:
* @property {string} T.Name - A string that uniquely identifies the route.
* @property {HttpMethod} T.Method - The HTTP method (GET, POST, PUT, DELETE, etc.) that the route responds to.
* @property {Object} T.PathParamsType - An object type derived from the path string, where each property is a path parameter and its value is a PathParam type.
* @property {Object} T.PathQueryType - An object type representing the expected structure of the query parameters in the route. It should be a subtype of TBaseQuery.
* @property {Object} T.BodyType - An object type representing the expected structure of the request body. It should be a subtype of TBaseBody.
* @property {Object} T.ResponseType - An object type representing the expected structure of the response. It should be a subtype of TBaseResponseStatusCodeMap and a record of ExpectedStatusCode to TBaseResponse.
* @property {StatusCode} T.ExpectedStatusCode - The expected HTTP status code of the response. Default is StatusCode.OK.
*/
declare class Route<Path extends string, ExpectedResponseType extends TBaseResponse, T extends IRouteNamedTypes<Path, ExpectedResponseType>> {
#private;
/**
* Constructs a new instance of the Route class.
*
* @param {Name} params.name - The name of the route.
* @param {Method} params.method - The HTTP method of the route.
* @param {Path} params.path - The path of the route.
* @param {ExpectedStatusCode} [params.expectedStatusCode=StatusCode.OK] - The expected status code of the route.
* @param {ZodType<PathParamsType>} params.pathParamsSchema - The schema for the path parameters.
* @param {ZodType<PathQueryType>} params.pathQuerySchema - The schema for the query parameters.
* @param {ZodTypeOrCatch<BodyType>} params.bodySchema - The schema for the request body.
* @param {Object} params.responseSchema - The schema for the response.
* @param {string} params.responseSchema[K].description - The description of the response.
* @param {Object} params.responseSchema[K].content - The content of the response.
* @param {ZodType<ResponseType[K]>} params.responseSchema[K].content[MimeType.APPLICATION_JSON].schema - The schema for the response content.
*/
constructor({ name, method, path, expectedStatusCode, pathParamsSchema, pathQuerySchema, bodySchema, responseSchema, }: {
name: T['Name'];
expectedStatusCode?: T['ExpectedStatusCode'];
method: T['Method'];
path: Path;
pathParamsSchema: ZodType<T['PathParamsType']>;
pathQuerySchema: ZodType<T['PathQueryType']>;
bodySchema: ZodTypeOrCatch<T['BodyType']>;
responseSchema: {
[K in keyof T['ResponseType']]: {
description: string;
content: {
[MimeType.APPLICATION_JSON]: {
schema: ZodType<T['ResponseType'][K]>;
};
};
};
};
});
/**
* Getter for the name of the route.
* @returns {Name} The name of the route.
*/
get name(): T["Name"];
/**
* Getter for the HTTP method of the route.
* @returns {Method} The HTTP method of the route.
*/
get method(): T["Method"];
/**
* Getter for the path of the route.
* @returns {Path} The path of the route.
*/
get path(): Path;
/**
* Getter for the expected status code of the route.
* @returns {ExpectedStatusCode} The expected status code of the route.
*/
get expectedStatusCode(): T["ExpectedStatusCode"];
/**
* Parses the path parameters or throws an error if they are invalid.
* @param {unknown} maybePathParams - The path parameters to parse.
* @returns {PathParamsType} The parsed path parameters.
*/
parsePathParamsOrThrow(maybePathParams: unknown): T["PathParamsType"];
/**
* Parses the path query or throws an error if it is invalid.
* @param {unknown} maybePathQuery - The path query to parse.
* @returns {PathQueryType} The parsed path query.
*/
parsePathQueryOrThrow(maybePathQuery: unknown): T["PathQueryType"];
/**
* Parses the body or throws an error if it is invalid.
* @param {unknown} maybeBody - The body to parse.
* @returns {BodyType} The parsed body.
*/
parseBodyOrThrow(maybeBody: unknown): T["BodyType"];
/**
* Parses the response or throws an error if it is invalid.
* @param {unknown} maybeResponse - The response to parse.
* @param {StatusCode} statusCode - The status code of the response.
* @returns {ResponseType} The parsed response.
*/
parseResponseOrThrow(maybeResponse: unknown, statusCode: StatusCode): T["ResponseType"][StatusCode.OK] | T["ResponseType"][StatusCode.CREATED] | T["ResponseType"][StatusCode.NO_CONTENT] | T["ResponseType"][StatusCode.MOVED_PERMANENTLY] | T["ResponseType"][StatusCode.MOVED_TEMPORARILY] | T["ResponseType"][StatusCode.NOT_MODIFIED] | T["ResponseType"][StatusCode.BAD_REQUEST] | T["ResponseType"][StatusCode.NOT_AUTHENTICATED] | T["ResponseType"][StatusCode.FORBIDDEN] | T["ResponseType"][StatusCode.NOT_FOUND] | T["ResponseType"][StatusCode.METHOD_NOT_ALLOWED] | T["ResponseType"][StatusCode.UNSUPPORTED_MEDIA_TYPE] | T["ResponseType"][StatusCode.UNPROCESSABLE_CONTENT] | T["ResponseType"][StatusCode.TOO_MANY_REQUESTS] | T["ResponseType"][StatusCode.INTERNAL_SERVER_ERROR] | T["ResponseType"][StatusCode.NOT_IMPLEMENTED] | T["ResponseType"][StatusCode.BAD_GATEWAY] | T["ResponseType"][StatusCode.SERVICE_UNAVAILABLE] | T["ResponseType"][StatusCode.GATEWAY_TIME_OUT] | T["ResponseType"][StatusCode.HTTP_VERSION_NOT_SUPPORTED];
/**
* Converts a Zod schema to a JSON response schema.
* @template T - The type that the Zod schema validates.
* @param {T} schema - The Zod schema to convert.
* @param {string} description - The description of the response.
* @returns {Object} The JSON response schema.
*/
static toJSONResponseSchema<T extends ZodType<unknown>>(schema: T, description: string): {
readonly content: {
readonly 'application/json': {
readonly schema: T;
};
};
readonly description: string;
};
/**
* Converts the route to a specification.
* @returns {Object} The specification of the route.
*/
toSpec(): {
[x: string]: {
path: Path;
request: {
body: {
content: {
'application/json': {
schema: ZodTypeOrCatch<T["BodyType"]>;
};
};
};
};
responses: (T["ResponseType"] extends infer T_1 ? { [K in keyof T_1]: {
description: string;
content: {
"application/json": {
schema: ZodType<T["ResponseType"][K], zod.ZodTypeDef, T["ResponseType"][K]>;
};
};
}; } : never) & {
400: {
readonly content: {
readonly 'application/json': {
readonly schema: zod.ZodObject<{
error: zod.ZodString;
cause: zod.ZodOptional<zod.ZodString>;
code: zod.ZodOptional<zod.ZodNativeEnum<typeof PrivyErrorCode>>;
}, "strip", zod.ZodTypeAny, {
error: string;
cause?: string | undefined;
code?: PrivyErrorCode | undefined;
}, {
error: string;
cause?: string | undefined;
code?: PrivyErrorCode | undefined;
}>;
};
};
readonly description: string;
};
500: {
readonly content: {
readonly 'application/json': {
readonly schema: zod.ZodObject<{
error: zod.ZodString;
cause: zod.ZodOptional<zod.ZodString>;
code: zod.ZodOptional<zod.ZodNativeEnum<typeof PrivyErrorCode>>;
}, "strip", zod.ZodTypeAny, {
error: string;
cause?: string | undefined;
code?: PrivyErrorCode | undefined;
}, {
error: string;
cause?: string | undefined;
code?: PrivyErrorCode | undefined;
}>;
};
};
readonly description: string;
};
};
};
};
/**
* Constructs the full path of the route by replacing path parameters with their actual values.
* This method does not take into account any query parameters.
*
* @param {Object} params - An object containing the path parameters.
* @param {PathParamsType} params.params - The path parameters.
* @returns {string} The constructed path.
*/
constructPath({ params }: {
params: T['PathParamsType'];
}): string;
}
type AnyRoute = Route<string, any, BaseRouteType>;
type InferRouteTypes<T> = T extends Route<infer Path, infer ExpectedResponseType, infer RouteType> ? {
name: RouteType['Name'];
method: RouteType['Method'];
path: Path;
pathParams: RouteType['PathParamsType'];
pathQuery: RouteType['PathQueryType'];
body: RouteType['BodyType'];
response: RouteType['ResponseType'];
expectedStatusCode: RouteType['ExpectedStatusCode'];
expectedResponse: ExpectedResponseType;
} : never;
declare enum Protocols {
HTTP = "http:",
HTTPS = "https:"
}
type ZodContent = {
content: {
'application/json': {
schema: z.ZodTypeAny;
};
};
};
type OauthResponse = {
description: string;
} & ZodContent;
type Endpoint<K extends StatusCode> = {
path: string;
request: {
body: ZodContent;
};
responses: Record<K, OauthResponse>;
};
/**
* This is mostly a subset/copy of the `RouteConfig`
* from `@asteasolutions/zod-to-openapi`
* We need to create the type manually to do some TS magic
* so that `Responses<T>` below works properly
*
* Without Passing `K` explicitly from the top level down to the key
* of the `responses` property, typescript can't correctly infer
* the type of `EndpointSpec[string]['responses'][number]`
* and the whole type breaks
*
* To test this, try updating the definition of `EndpointSpec`
* remove the generics and see what happens to the `Responses` type
*/
type EndpointSpec<K extends StatusCode> = Record<string, Endpoint<K>>;
type ValueOf<T> = T[keyof T];
/**
* @description Extracts all possible response types from an EndpointSpec object
* @example
* const spec = { ... } as const satisfies EndpointSpec
* type ApiResponse = Responses<typeof spec>
*/
type Responses<T extends EndpointSpec<K>, K extends StatusCode = StatusCode.OK> = z.infer<ValueOf<ValueOf<T>['responses']>['content']['application/json']['schema']>;
declare const APIError: z.ZodObject<{

@@ -493,2 +144,2 @@ error: z.ZodString;

export { APIError, AllowlistRejectedError, AnyRoute, ApiErrorType, BaseRouteType, EndpointSpec, ForbiddenError, HttpError, HttpMethod, IRouteNamedTypes, InferRouteTypes, InternalServerError, InvalidInputError, LegacyInvalidInputError, MimeType, NotFoundError, OauthResponse, PrivyErrorCode, Protocols, Responses, Route, StatusCode, TooManyRequestsError, UnauthorizedError, UnsupportedMediaType };
export { APIError, AllowlistRejectedError, ApiErrorType, ForbiddenError, HttpError, InternalServerError, InvalidInputError, LegacyInvalidInputError, NotFoundError, PrivyErrorCode, TooManyRequestsError, UnauthorizedError, UnsupportedMediaType };

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";var u=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var b=(p,e)=>{for(var s in e)u(p,s,{get:e[s],enumerable:!0})},U=(p,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of B(e))!M.call(p,o)&&o!==s&&u(p,o,{get:()=>e[o],enumerable:!(a=L(e,o))||a.enumerable});return p};var V=p=>U(u({},"__esModule",{value:!0}),p);var k={};b(k,{APIError:()=>m,AllowlistRejectedError:()=>y,ForbiddenError:()=>O,HttpError:()=>r,HttpMethod:()=>l,InternalServerError:()=>P,InvalidInputError:()=>N,LegacyInvalidInputError:()=>A,MimeType:()=>R,NotFoundError:()=>d,PrivyErrorCode:()=>_,Protocols:()=>D,Route:()=>i,StatusCode:()=>E,TooManyRequestsError:()=>I,UnauthorizedError:()=>h,UnsupportedMediaType:()=>x});module.exports=V(k);var R=(e=>(e.APPLICATION_JSON="application/json",e))(R||{});var E=(t=>(t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.NOT_AUTHENTICATED=401]="NOT_AUTHENTICATED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIME_OUT=504]="GATEWAY_TIME_OUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t))(E||{});var c=require("zod");var _=(n=>(n.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",n.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",n.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",n.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",n.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",n.INVALID_DATA="invalid_data",n.INVALID_CREDENTIALS="invalid_credentials",n.LINKED_TO_ANOTHER_USER="linked_to_another_user",n.ALLOWLIST_REJECTED="allowlist_rejected",n.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",n.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",n.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",n.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",n.TOO_MANY_REQUESTS="too_many_requests",n.INVALID_ORIGIN="invalid_origin",n.MISSING_ORIGIN="missing_origin",n.INVALID_NATIVE_APP_ID="invalid_native_app_id",n.TOKEN_ALREADY_USED="token_already_used",n.ALREADY_LOGGED_OUT="already_logged_out",n.NOT_SUPPORTED="not_supported",n.USER_UNSUBSCRIBED="user_unsubscribed",n.MAX_APPS_REACHED="max_apps_reached",n.DEVICE_REVOKED="device_revoked",n.WALLET_PASSWORD_EXISTS="wallet_password_exists",n.OAUTH_STATE_MISMATCH="oauth_state_mismatch",n))(_||{});var m=c.z.object({error:c.z.string(),cause:c.z.string().optional(),code:c.z.nativeEnum(_).optional()});var i=class{#n;#p;#e;#a;#r;#o;#t;#s;constructor({name:e,method:s,path:a,expectedStatusCode:o=200,pathParamsSchema:T,pathQuerySchema:g,bodySchema:S,responseSchema:f}){this.#n=e,this.#p=s,this.#e=a,this.#a=o,this.#r=T,this.#o=g,this.#t=S,this.#s=f}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#a}parsePathParamsOrThrow(e){return this.#r?.parse(e)}parsePathQueryOrThrow(e){return this.#o?.parse(e)}parseBodyOrThrow(e){return this.#t.parse(e)}parseResponseOrThrow(e,s){let a=this.#s[s];if(!a)throw new Error(`No schema found for status code ${s}`);return a.content["application/json"].schema.parse(e)}static toJSONResponseSchema(e,s){return{content:{"application/json":{schema:e}},description:s}}toSpec(){return{[this.method]:{path:this.#e,request:{body:{content:{"application/json":{schema:this.#t}}}},responses:{...this.#s,[400]:i.toJSONResponseSchema(m,"Invalid Input"),[500]:i.toJSONResponseSchema(m,"Server Error")}}}}constructPath({params:e}){let s=this.path;return e!==void 0?(Object.keys(e).forEach(a=>{let o=e[a];s=s.replace(`:${a}`,`${o}`)}),`${s}`):s}};var r=class extends Error{status;code;constructor(e,s,a){super(s),this.code=a,this.status=e}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},N=class extends r{constructor(e,s){super(400,e,s)}},h=class extends r{constructor(e,s){super(401,e,s)}},y=class extends h{constructor(e){super(e||"User is not allowed to login to this app.","allowlist_rejected")}},O=class extends r{constructor(e,s){super(403,e,s)}},d=class extends r{constructor(e){super(404,e)}},x=class extends r{constructor(e){super(415,e)}},A=class extends r{constructor(e,s){super(422,e,s)}},I=class extends r{constructor(e){super(429,e||"Too many requests. Please wait to try again.","too_many_requests")}},P=class extends r{constructor(e){super(500,e||"Service unavailable.")}};var l=(T=>(T.GET="get",T.POST="post",T.PATCH="patch",T.DELETE="delete",T.PUT="put",T))(l||{});var D=(s=>(s.HTTP="http:",s.HTTPS="https:",s))(D||{});0&&(module.exports={APIError,AllowlistRejectedError,ForbiddenError,HttpError,HttpMethod,InternalServerError,InvalidInputError,LegacyInvalidInputError,MimeType,NotFoundError,PrivyErrorCode,Protocols,Route,StatusCode,TooManyRequestsError,UnauthorizedError,UnsupportedMediaType});
"use strict";var I=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var x=(s,t)=>{for(var e in t)I(s,e,{get:t[e],enumerable:!0})},R=(s,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of m(t))!E.call(s,a)&&a!==e&&I(s,a,{get:()=>t[a],enumerable:!(o=L(t,a))||o.enumerable});return s};var d=s=>R(I({},"__esModule",{value:!0}),s);var U={};x(U,{APIError:()=>g,AllowlistRejectedError:()=>p,ForbiddenError:()=>u,HttpError:()=>n,InternalServerError:()=>S,InvalidInputError:()=>N,LegacyInvalidInputError:()=>D,NotFoundError:()=>O,PrivyErrorCode:()=>c,TooManyRequestsError:()=>T,UnauthorizedError:()=>A,UnsupportedMediaType:()=>l});module.exports=d(U);var c=(_=>(_.OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",_.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",_.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",_.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",_.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",_.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",_.INVALID_DATA="invalid_data",_.INVALID_CREDENTIALS="invalid_credentials",_.INVALID_CAPTCHA="invalid_captcha",_.LINKED_TO_ANOTHER_USER="linked_to_another_user",_.ALLOWLIST_REJECTED="allowlist_rejected",_.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",_.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",_.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",_.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",_.TOO_MANY_REQUESTS="too_many_requests",_.INVALID_ORIGIN="invalid_origin",_.MISSING_ORIGIN="missing_origin",_.INVALID_NATIVE_APP_ID="invalid_native_app_id",_.TOKEN_ALREADY_USED="token_already_used",_.ALREADY_LOGGED_OUT="already_logged_out",_.NOT_SUPPORTED="not_supported",_.USER_UNSUBSCRIBED="user_unsubscribed",_.MAX_APPS_REACHED="max_apps_reached",_.USER_LIMIT_REACHED="max_accounts_reached",_.DEVICE_REVOKED="device_revoked",_.WALLET_PASSWORD_EXISTS="wallet_password_exists",_.OAUTH_STATE_MISMATCH="oauth_state_mismatch",_.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",_.DISALLOWED_LOGIN_METHOD="disallowed_login_method",_.DISALLOWED_RECOVERY_METHOD="disallowed_recovery_method",_.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",_.CANNOT_SET_PASSWORD="cannot_set_password",_.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",_))(c||{});var n=class extends Error{status;code;constructor(t,e,o){super(e),this.code=o,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},N=class extends n{constructor(t,e){super(400,t,e)}},A=class extends n{constructor(t,e){super(401,t,e)}},p=class extends A{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},u=class extends n{constructor(t,e){super(403,t,e)}},O=class extends n{constructor(t){super(404,t)}},l=class extends n{constructor(t){super(415,t)}},D=class extends n{constructor(t,e){super(422,t,e)}},T=class extends n{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},S=class extends n{constructor(t){super(500,t||"Service unavailable.")}};var i=require("zod");var g=i.z.object({error:i.z.string(),cause:i.z.string().optional(),code:i.z.nativeEnum(c).optional()});0&&(module.exports={APIError,AllowlistRejectedError,ForbiddenError,HttpError,InternalServerError,InvalidInputError,LegacyInvalidInputError,NotFoundError,PrivyErrorCode,TooManyRequestsError,UnauthorizedError,UnsupportedMediaType});
{
"name": "@privy-io/api-base",
"version": "0.5.0-beta-20231102205435",
"version": "1.0.0-beta-20240417214736",
"engines": {
"npm": ">=8.0.0 <10.0.0",
"node": ">=18.0.0 <19"
"npm": ">=8.0.0",
"node": ">=18.0.0"
},

@@ -36,7 +36,8 @@ "main": "./dist/index.js",

"build": "npx tsup --clean --minify",
"prepublishOnly": "npm run clean && npm run build",
"clean": "rm -rf dist .turbo",
"dev": "npx tsup --watch",
"lint": "eslint ./**/*.ts && npx tsc --noEmit",
"format": "eslint ./**/*.ts --fix"
"format": "eslint ./**/*.ts --fix",
"test": "jest --testMatch \"**/test/**/*.test.ts\"",
"test:ci": "npm run test"
},

@@ -43,0 +44,0 @@ "dependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc