Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@privy-io/api-base

Package Overview
Dependencies
Maintainers
8
Versions
144
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.2.0 to 0.3.0-beta-20230928004335

dist/index.mjs

125

dist/index.d.ts

@@ -50,3 +50,3 @@ import * as zod from 'zod';

type ApiError = {
type ApiErrorType = {
error: string;

@@ -147,3 +147,3 @@ cause?: string;

[K in Param]: PathParam;
} : Record<string, never>;
} : Record<string, string>;
type TBaseQuery = {

@@ -169,2 +169,29 @@ [name: string]: string | number | boolean | undefined;

/**
* 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

@@ -199,12 +226,14 @@ *

*
* @template Name - A string that uniquely identifies the route.
* @template Method - The HTTP method (GET, POST, PUT, DELETE, etc.) that the route responds to.
* @template Path - The URL path of the route. It can include path parameters, denoted by a colon prefix (e.g., '/user/:id').
* @template PathParamsType - An object type derived from the path string, where each property is a path parameter and its value is a PathParam type.
* @template PathQueryType - An object type representing the expected structure of the query parameters in the route. It should be a subtype of TBaseQuery.
* @template BodyType - An object type representing the expected structure of the request body. It should be a subtype of TBaseBody.
* @template 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.
* @template ExpectedStatusCode - The expected HTTP status code of the response. It should be a StatusCode. Default is StatusCode.OK.
* @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<Name extends string, Method extends HttpMethod, Path extends string, PathParamsType extends PathParams<Path>, PathQueryType extends TBaseQuery, BodyType extends TBaseBody, ResponseType extends Partial<TBaseResponseStatusCodeMap> & Record<ExpectedStatusCode, TBaseResponse>, ExpectedStatusCode extends StatusCode = StatusCode.OK> {
declare class Route<Path extends string, ExpectedResponseType extends TBaseResponse, T extends IRouteNamedTypes<Path, ExpectedResponseType>> {
#private;

@@ -227,15 +256,15 @@ /**

constructor({ name, method, path, expectedStatusCode, pathParamsSchema, pathQuerySchema, bodySchema, responseSchema, }: {
name: Name;
expectedStatusCode?: ExpectedStatusCode;
method: Method;
name: T['Name'];
expectedStatusCode?: T['ExpectedStatusCode'];
method: T['Method'];
path: Path;
pathParamsSchema: ZodType<PathParamsType>;
pathQuerySchema: ZodType<PathQueryType>;
bodySchema: ZodTypeOrCatch<BodyType>;
pathParamsSchema: ZodType<T['PathParamsType']>;
pathQuerySchema: ZodType<T['PathQueryType']>;
bodySchema: ZodTypeOrCatch<T['BodyType']>;
responseSchema: {
[K in keyof ResponseType]: {
[K in keyof T['ResponseType']]: {
description: string;
content: {
[MimeType.APPLICATION_JSON]: {
schema: ZodType<ResponseType[K]>;
schema: ZodType<T['ResponseType'][K]>;
};

@@ -250,3 +279,3 @@ };

*/
get name(): Name;
get name(): T["Name"];
/**

@@ -256,3 +285,3 @@ * Getter for the HTTP method of the route.

*/
get method(): Method;
get method(): T["Method"];
/**

@@ -267,3 +296,3 @@ * Getter for the path of the route.

*/
get expectedStatusCode(): ExpectedStatusCode;
get expectedStatusCode(): T["ExpectedStatusCode"];
/**

@@ -274,3 +303,3 @@ * Parses the path parameters or throws an error if they are invalid.

*/
parsePathParamsOrThrow(maybePathParams: unknown): PathParamsType;
parsePathParamsOrThrow(maybePathParams: unknown): T["PathParamsType"];
/**

@@ -281,3 +310,3 @@ * Parses the path query or throws an error if it is invalid.

*/
parsePathQueryOrThrow(maybePathQuery: unknown): PathQueryType;
parsePathQueryOrThrow(maybePathQuery: unknown): T["PathQueryType"];
/**

@@ -288,3 +317,3 @@ * Parses the body or throws an error if it is invalid.

*/
parseBodyOrThrow(maybeBody: unknown): BodyType;
parseBodyOrThrow(maybeBody: unknown): T["BodyType"];
/**

@@ -296,3 +325,3 @@ * Parses the response or throws an error if it is invalid.

*/
parseResponseOrThrow(maybeResponse: unknown, statusCode: StatusCode): ResponseType[StatusCode.OK] | ResponseType[StatusCode.CREATED] | ResponseType[StatusCode.NO_CONTENT] | ResponseType[StatusCode.MOVED_PERMANENTLY] | ResponseType[StatusCode.MOVED_TEMPORARILY] | ResponseType[StatusCode.NOT_MODIFIED] | ResponseType[StatusCode.BAD_REQUEST] | ResponseType[StatusCode.NOT_AUTHENTICATED] | ResponseType[StatusCode.FORBIDDEN] | ResponseType[StatusCode.NOT_FOUND] | ResponseType[StatusCode.METHOD_NOT_ALLOWED] | ResponseType[StatusCode.UNSUPPORTED_MEDIA_TYPE] | ResponseType[StatusCode.UNPROCESSABLE_CONTENT] | ResponseType[StatusCode.TOO_MANY_REQUESTS] | ResponseType[StatusCode.INTERNAL_SERVER_ERROR] | ResponseType[StatusCode.NOT_IMPLEMENTED] | ResponseType[StatusCode.BAD_GATEWAY] | ResponseType[StatusCode.SERVICE_UNAVAILABLE] | ResponseType[StatusCode.GATEWAY_TIME_OUT] | ResponseType[StatusCode.HTTP_VERSION_NOT_SUPPORTED];
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];
/**

@@ -324,3 +353,3 @@ * Converts a Zod schema to a JSON response schema.

'application/json': {
schema: ZodTypeOrCatch<BodyType>;
schema: ZodTypeOrCatch<T["BodyType"]>;
};

@@ -330,3 +359,10 @@ };

};
responses: {
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: {

@@ -372,10 +408,3 @@ readonly content: {

};
} & { [K in keyof ResponseType]: {
description: string;
content: {
"application/json": {
schema: ZodType<ResponseType[K], zod.ZodTypeDef, ResponseType[K]>;
};
};
}; };
};
};

@@ -392,16 +421,16 @@ };

constructPath({ params }: {
params: PathParamsType;
params: T['PathParamsType'];
}): string;
}
type AnyRoute = Route<any, any, any, any, any, any, any, any>;
type InferRouteTypes<T> = T extends Route<infer Name, infer Method, infer Path, infer PathParamsType, infer PathQueryType, infer BodyType, infer ResponseType, infer ExpectedStatusCode> ? {
name: Name;
method: Method;
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: PathParamsType;
pathQuery: PathQueryType;
body: BodyType;
response: ResponseType;
expectedStatusCode: ExpectedStatusCode;
expectedResponse: ResponseType[ExpectedStatusCode];
pathParams: RouteType['PathParamsType'];
pathQuery: RouteType['PathQueryType'];
body: RouteType['BodyType'];
response: RouteType['ResponseType'];
expectedStatusCode: RouteType['ExpectedStatusCode'];
expectedResponse: ExpectedResponseType;
} : never;

@@ -469,2 +498,2 @@

export { APIError, AllowlistRejectedError, AnyRoute, ApiError, EndpointSpec, ForbiddenError, HttpError, HttpMethod, InferRouteTypes, InternalServerError, InvalidInputError, LegacyInvalidInputError, MimeType, NotFoundError, OauthResponse, PrivyErrorCode, Protocols, Responses, Route, StatusCode, TooManyRequestsError, UnauthorizedError, UnsupportedMediaType };
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 };

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

"use strict";var E=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var M=(r,e)=>{for(var s in e)E(r,s,{get:e[s],enumerable:!0})},k=(r,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of B(e))!U.call(r,o)&&o!==s&&E(r,o,{get:()=>e[o],enumerable:!(a=b(e,o))||a.enumerable});return r};var w=r=>k(E({},"__esModule",{value:!0}),r);var K={};M(K,{APIError:()=>h,AllowlistRejectedError:()=>d,ForbiddenError:()=>P,HttpError:()=>p,HttpMethod:()=>f,InternalServerError:()=>l,InvalidInputError:()=>N,LegacyInvalidInputError:()=>A,MimeType:()=>u,NotFoundError:()=>x,PrivyErrorCode:()=>c,Protocols:()=>D,Route:()=>T,StatusCode:()=>O,TooManyRequestsError:()=>I,UnauthorizedError:()=>m,UnsupportedMediaType:()=>R,z:()=>y.z});module.exports=w(K);var y=require("zod");var u=(e=>(e.APPLICATION_JSON="application/json",e))(u||{});var O=(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))(O||{});var _=require("zod");var c=(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.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.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))(c||{});var h=_.z.object({error:_.z.string(),cause:_.z.string().optional(),code:_.z.nativeEnum(c).optional()});var T=class{#n;#r;#e;#a;#p;#o;#t;#s;constructor({name:e,method:s,path:a,expectedStatusCode:o=200,pathParamsSchema:i,pathQuerySchema:g,bodySchema:S,responseSchema:L}){this.#n=e,this.#r=s,this.#e=a,this.#a=o,this.#p=i,this.#o=g,this.#t=S,this.#s=L}get name(){return this.#n}get method(){return this.#r}get path(){return this.#e}get expectedStatusCode(){return this.#a}parsePathParamsOrThrow(e){return this.#p?.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:{[400]:T.toJSONResponseSchema(h,"Invalid Input"),[500]:T.toJSONResponseSchema(h,"Server Error"),...this.#s}}}}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 p=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 p{constructor(e,s){super(400,e,s)}},m=class extends p{constructor(e,s){super(401,e,s)}},d=class extends m{constructor(e){super(e||"User is not allowed to login to this app.","allowlist_rejected")}},P=class extends p{constructor(e,s){super(403,e,s)}},x=class extends p{constructor(e){super(404,e)}},R=class extends p{constructor(e){super(415,e)}},A=class extends p{constructor(e,s){super(422,e,s)}},I=class extends p{constructor(e){super(429,e||"Too many requests. Please wait to try again.","too_many_requests")}},l=class extends p{constructor(e){super(500,e||"Service unavailable.")}};var f=(i=>(i.GET="get",i.POST="post",i.PATCH="patch",i.DELETE="delete",i.PUT="put",i))(f||{});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,z});
"use strict";var u=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var M=(p,e)=>{for(var s in e)u(p,s,{get:e[s],enumerable:!0})},k=(p,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of b(e))!U.call(p,a)&&a!==s&&u(p,a,{get:()=>e[a],enumerable:!(r=B(e,a))||r.enumerable});return p};var K=p=>k(u({},"__esModule",{value:!0}),p);var w={};M(w,{APIError:()=>m,AllowlistRejectedError:()=>N,ForbiddenError:()=>O,HttpError:()=>o,HttpMethod:()=>g,InternalServerError:()=>l,InvalidInputError:()=>d,LegacyInvalidInputError:()=>A,MimeType:()=>E,NotFoundError:()=>x,PrivyErrorCode:()=>c,Protocols:()=>f,Route:()=>i,StatusCode:()=>R,TooManyRequestsError:()=>I,UnauthorizedError:()=>h,UnsupportedMediaType:()=>P,z:()=>y.z});module.exports=K(w);var y=require("zod");var E=(e=>(e.APPLICATION_JSON="application/json",e))(E||{});var R=(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))(R||{});var _=require("zod");var c=(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.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.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))(c||{});var m=_.z.object({error:_.z.string(),cause:_.z.string().optional(),code:_.z.nativeEnum(c).optional()});var i=class{#n;#p;#e;#r;#o;#a;#t;#s;constructor({name:e,method:s,path:r,expectedStatusCode:a=200,pathParamsSchema:T,pathQuerySchema:D,bodySchema:S,responseSchema:L}){this.#n=e,this.#p=s,this.#e=r,this.#r=a,this.#o=T,this.#a=D,this.#t=S,this.#s=L}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#r}parsePathParamsOrThrow(e){return this.#o?.parse(e)}parsePathQueryOrThrow(e){return this.#a?.parse(e)}parseBodyOrThrow(e){return this.#t.parse(e)}parseResponseOrThrow(e,s){let r=this.#s[s];if(!r)throw new Error(`No schema found for status code ${s}`);return r.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(r=>{let a=e[r];s=s.replace(`:${r}`,`${a}`)}),`${s}`):s}};var o=class extends Error{status;code;constructor(e,s,r){super(s),this.code=r,this.status=e}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},d=class extends o{constructor(e,s){super(400,e,s)}},h=class extends o{constructor(e,s){super(401,e,s)}},N=class extends h{constructor(e){super(e||"User is not allowed to login to this app.","allowlist_rejected")}},O=class extends o{constructor(e,s){super(403,e,s)}},x=class extends o{constructor(e){super(404,e)}},P=class extends o{constructor(e){super(415,e)}},A=class extends o{constructor(e,s){super(422,e,s)}},I=class extends o{constructor(e){super(429,e||"Too many requests. Please wait to try again.","too_many_requests")}},l=class extends o{constructor(e){super(500,e||"Service unavailable.")}};var g=(T=>(T.GET="get",T.POST="post",T.PATCH="patch",T.DELETE="delete",T.PUT="put",T))(g||{});var f=(s=>(s.HTTP="http:",s.HTTPS="https:",s))(f||{});0&&(module.exports={APIError,AllowlistRejectedError,ForbiddenError,HttpError,HttpMethod,InternalServerError,InvalidInputError,LegacyInvalidInputError,MimeType,NotFoundError,PrivyErrorCode,Protocols,Route,StatusCode,TooManyRequestsError,UnauthorizedError,UnsupportedMediaType,z});
{
"name": "@privy-io/api-base",
"version": "0.2.0",
"version": "0.3.0-beta-20230928004335",
"engines": {

@@ -9,3 +9,3 @@ "npm": ">=8.0.0 <10.0.0",

"main": "./dist/index.js",
"module": "./dist/esm/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",

@@ -16,3 +16,3 @@ "typings": "./dist/index",

"require": "./dist/index.js",
"import": "./dist/esm/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"

@@ -22,3 +22,3 @@ },

"require": "./dist/index.js",
"import": "./dist/esm/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"

@@ -28,3 +28,3 @@ },

"require": "./dist/index.js",
"import": "./dist/esm/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"

@@ -34,3 +34,3 @@ },

"require": "./dist/index.js",
"import": "./dist/esm/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"

@@ -40,3 +40,3 @@ },

"require": "./dist/index.js",
"import": "./dist/esm/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"

@@ -43,0 +43,0 @@ }

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