@privy-io/api-base
Advanced tools
Comparing version 0.2.0-beta-20230925233038 to 0.2.0-beta-20230925233833
@@ -1,1 +0,1 @@ | ||
import{z as D}from"zod";var E=(t=>(t.APPLICATION_JSON="application/json",t))(E||{});var u=(e=>(e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",e[e.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",e[e.NOT_MODIFIED=304]="NOT_MODIFIED",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.NOT_AUTHENTICATED=401]="NOT_AUTHENTICATED",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",e[e.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",e[e.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",e[e.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",e[e.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",e[e.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",e[e.BAD_GATEWAY=502]="BAD_GATEWAY",e[e.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",e[e.GATEWAY_TIME_OUT=504]="GATEWAY_TIME_OUT",e[e.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",e))(u||{});import{z as _}from"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=_.object({error:_.string(),cause:_.string().optional(),code:_.nativeEnum(c).optional()});var i=class{#n;#r;#e;#a;#p;#o;#t;#s;constructor({name:t,method:s,path:p,expectedStatusCode:T=200,pathParamsSchema:o,pathQuerySchema:I,bodySchema:l,responseSchema:f}){this.#n=t,this.#r=s,this.#e=p,this.#a=T,this.#p=o,this.#o=I,this.#t=l,this.#s=f}get name(){return this.#n}get method(){return this.#r}get path(){return this.#e}get expectedStatusCode(){return this.#a}parsePathParamsOrThrow(t){return this.#p?.parse(t)}parsePathQueryOrThrow(t){return this.#o?.parse(t)}parseBodyOrThrow(t){return this.#t.parse(t)}parseResponseOrThrow(t,s){let p=this.#s[s];if(!p)throw new Error(`No schema found for status code ${s}`);return p.content["application/json"].schema.parse(t)}static toJSONResponseSchema(t,s){return{content:{"application/json":{schema:t}},description:s}}toSpec(){return{[this.method]:{path:this.#e,request:{body:{content:{"application/json":{schema:this.#t}}}},responses:{[400]:i.toJSONResponseSchema(h,"Invalid Input"),[500]:i.toJSONResponseSchema(h,"Server Error"),...this.#s}}}}constructPath({params:t}){let s=this.path;return t!==void 0?(Object.keys(t).forEach(p=>{let T=t[p];s=s.replace(`:${p}`,`${T}`)}),`${s}`):s}};var r=class extends Error{status;code;constructor(t,s,p){super(s),this.code=p,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},y=class extends r{constructor(t,s){super(400,t,s)}},m=class extends r{constructor(t,s){super(401,t,s)}},O=class extends m{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},N=class extends r{constructor(t,s){super(403,t,s)}},d=class extends r{constructor(t){super(404,t)}},P=class extends r{constructor(t){super(415,t)}},x=class extends r{constructor(t,s){super(422,t,s)}},R=class extends r{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},A=class extends r{constructor(t){super(500,t||"Service unavailable.")}};var g=(o=>(o.GET="get",o.POST="post",o.PATCH="patch",o.DELETE="delete",o.PUT="put",o))(g||{});var S=(s=>(s.HTTP="http:",s.HTTPS="https:",s))(S||{});export{h as APIError,O as AllowlistRejectedError,N as ForbiddenError,r as HttpError,g as HttpMethod,A as InternalServerError,y as InvalidInputError,x as LegacyInvalidInputError,E as MimeType,d as NotFoundError,c as PrivyErrorCode,S as Protocols,i as Route,u as StatusCode,R as TooManyRequestsError,m as UnauthorizedError,P as UnsupportedMediaType,D as z}; | ||
import{z as D}from"zod";var E=(t=>(t.APPLICATION_JSON="application/json",t))(E||{});var y=(e=>(e[e.OK=200]="OK",e[e.CREATED=201]="CREATED",e[e.NO_CONTENT=204]="NO_CONTENT",e[e.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",e[e.MOVED_TEMPORARILY=302]="MOVED_TEMPORARILY",e[e.NOT_MODIFIED=304]="NOT_MODIFIED",e[e.BAD_REQUEST=400]="BAD_REQUEST",e[e.NOT_AUTHENTICATED=401]="NOT_AUTHENTICATED",e[e.FORBIDDEN=403]="FORBIDDEN",e[e.NOT_FOUND=404]="NOT_FOUND",e[e.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",e[e.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",e[e.UNPROCESSABLE_CONTENT=422]="UNPROCESSABLE_CONTENT",e[e.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",e[e.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",e[e.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",e[e.BAD_GATEWAY=502]="BAD_GATEWAY",e[e.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",e[e.GATEWAY_TIME_OUT=504]="GATEWAY_TIME_OUT",e[e.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",e))(y||{});import{z as _}from"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=_.object({error:_.string(),cause:_.string().optional(),code:_.nativeEnum(c).optional()});var i=class{#n;#r;#e;#a;#p;#o;#t;#s;constructor({name:t,method:s,path:p,expectedStatusCode:T=200,pathParamsSchema:o,pathQuerySchema:I,bodySchema:l,responseSchema:f}){this.#n=t,this.#r=s,this.#e=p,this.#a=T,this.#p=o,this.#o=I,this.#t=l,this.#s=f}get name(){return this.#n}get method(){return this.#r}get path(){return this.#e}get expectedStatusCode(){return this.#a}parsePathParamsOrThrow(t){return this.#p?.parse(t)}parsePathQueryOrThrow(t){return this.#o?.parse(t)}parseBodyOrThrow(t){return this.#t.parse(t)}parseResponseOrThrow(t,s){let p=this.#s[s];if(!p)throw new Error(`No schema found for status code ${s}`);return p.content["application/json"].schema.parse(t)}static toJSONResponseSchema(t,s){return{content:{"application/json":{schema:t}},description:s}}toSpec(){return{[this.method]:{path:this.#e,request:{body:{content:{"application/json":{schema:this.#t}}}},responses:{[400]:i.toJSONResponseSchema(h,"Invalid Input"),[500]:i.toJSONResponseSchema(h,"Server Error"),...this.#s}}}}constructPath({params:t}){let s=this.path;return t!==void 0?(Object.keys(t).forEach(p=>{let T=t[p];s=s.replace(`:${p}`,`${T}`)}),`${s}`):s}};var r=class extends Error{status;code;constructor(t,s,p){super(s),this.code=p,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},u=class extends r{constructor(t,s){super(400,t,s)}},m=class extends r{constructor(t,s){super(401,t,s)}},O=class extends m{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},N=class extends r{constructor(t,s){super(403,t,s)}},d=class extends r{constructor(t){super(404,t)}},P=class extends r{constructor(t){super(415,t)}},x=class extends r{constructor(t,s){super(422,t,s)}},R=class extends r{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},A=class extends r{constructor(t){super(500,t||"Service unavailable.")}};var g=(o=>(o.GET="get",o.POST="post",o.PATCH="patch",o.DELETE="delete",o.PUT="put",o))(g||{});var S=(s=>(s.HTTP="http:",s.HTTPS="https:",s))(S||{});export{h as APIError,O as AllowlistRejectedError,N as ForbiddenError,r as HttpError,g as HttpMethod,A as InternalServerError,u as InvalidInputError,x as LegacyInvalidInputError,E as MimeType,d as NotFoundError,c as PrivyErrorCode,S as Protocols,i as Route,y as StatusCode,R as TooManyRequestsError,m as UnauthorizedError,P as UnsupportedMediaType,D as z}; |
@@ -5,2 +5,99 @@ import * as zod 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. */ | ||
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. */ | ||
MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id", | ||
/** The refresh or access token is either not provided or not valid. */ | ||
MISSING_OR_INVALID_TOKEN = "missing_or_invalid_token", | ||
/** The body of the request contains input that is invalid. Check the response body for detailed information. */ | ||
INVALID_DATA = "invalid_data", | ||
/** A form of INVALID_DATA specifically when the user is trying to authenticate and did not match the provided challenge. */ | ||
INVALID_CREDENTIALS = "invalid_credentials", | ||
/** You attempted to link an account that belongs to another user. */ | ||
LINKED_TO_ANOTHER_USER = "linked_to_another_user", | ||
/** This app has an allowlist and the login account was not included. Either disable the allowlist or have the user try again with a different account. */ | ||
ALLOWLIST_REJECTED = "allowlist_rejected", | ||
/** Embedded wallets cannot be unlinked */ | ||
CANNOT_UNLINK_EMBEDDED_WALLET = "cannot_unlink_embedded_wallet", | ||
/** You are unable to unlink an account when there is only one account present. */ | ||
CANNOT_UNLINK_SOLE_ACCOUNT = "cannot_unlink_sole_account", | ||
/** Cannot link another account of this type */ | ||
CANNOT_LINK_MORE_OF_TYPE = "cannot_link_more_of_type", | ||
/** Linked account cannot be found. The account was either invalid or has already been unlinked. */ | ||
LINKED_ACCOUNT_NOT_FOUND = "linked_account_not_found", | ||
/** Too many requests. Please wait to try again. */ | ||
TOO_MANY_REQUESTS = "too_many_requests", | ||
/** Origin was expected and is invalid. */ | ||
INVALID_ORIGIN = "invalid_origin", | ||
/** Origin was expected and is not set. */ | ||
MISSING_ORIGIN = "missing_origin", | ||
/** Refresh token re-use detected. */ | ||
TOKEN_ALREADY_USED = "token_already_used", | ||
/** Attempting to log out of a session that does not exist. */ | ||
ALREADY_LOGGED_OUT = "already_logged_out", | ||
/** The value (phone number, email) that was submitted is not supported. */ | ||
NOT_SUPPORTED = "not_supported", | ||
/** You have previously unsubscribed from the sending email/phone number. */ | ||
USER_UNSUBSCRIBED = "user_unsubscribed", | ||
/** You have reached the maximum number of apps allowed per account. */ | ||
MAX_APPS_REACHED = "max_apps_reached", | ||
/** You are trying to reconstruct an embedded wallet on a device that has been marked as revoked */ | ||
DEVICE_REVOKED = "device_revoked", | ||
/** You attempted to set a password on a wallet with an existing password */ | ||
WALLET_PASSWORD_EXISTS = "wallet_password_exists" | ||
} | ||
type ApiError = { | ||
error: string; | ||
cause?: string; | ||
code?: PrivyErrorCode; | ||
}; | ||
declare class HttpError extends Error { | ||
status: number; | ||
/** Unique Privy error code. The SDK/customers should be able to use this code to programmatically */ | ||
code?: PrivyErrorCode; | ||
constructor(status: number, message: string, code?: PrivyErrorCode); | ||
toString(): string; | ||
} | ||
declare class InvalidInputError extends HttpError { | ||
constructor(message: string, errorCode: PrivyErrorCode); | ||
} | ||
declare class UnauthorizedError extends HttpError { | ||
constructor(message: string, errorCode?: PrivyErrorCode); | ||
} | ||
declare class AllowlistRejectedError extends UnauthorizedError { | ||
/** | ||
* TODO: Changing the default message will cause existing allowlist SDK checks to fail and | ||
* should not be done until we're sure all users are off the version of the SDK that checks for | ||
* that string. | ||
*/ | ||
constructor(message?: string); | ||
} | ||
declare class ForbiddenError extends HttpError { | ||
constructor(message: string, errorCode?: PrivyErrorCode); | ||
} | ||
declare class NotFoundError extends HttpError { | ||
constructor(message: string); | ||
} | ||
declare class UnsupportedMediaType extends HttpError { | ||
constructor(message: string); | ||
} | ||
/** | ||
* @deprecated | ||
* | ||
* Use InvalidInputError moving forward. | ||
* | ||
* In the past, we would occasionally return 422 for invalid input. | ||
*/ | ||
declare class LegacyInvalidInputError extends HttpError { | ||
constructor(message: string, errorCode: PrivyErrorCode); | ||
} | ||
declare class TooManyRequestsError extends HttpError { | ||
constructor(message?: string); | ||
} | ||
declare class InternalServerError extends HttpError { | ||
constructor(message?: string); | ||
} | ||
declare enum HttpMethod { | ||
@@ -228,11 +325,11 @@ GET = "get", | ||
cause: zod.ZodOptional<zod.ZodString>; | ||
code: zod.ZodOptional<zod.ZodNativeEnum<typeof undefined>>; | ||
code: zod.ZodOptional<zod.ZodNativeEnum<typeof PrivyErrorCode>>; | ||
}, "strip", zod.ZodTypeAny, { | ||
error: string; | ||
cause?: string | undefined; | ||
code?: undefined | undefined; | ||
code?: PrivyErrorCode | undefined; | ||
}, { | ||
error: string; | ||
cause?: string | undefined; | ||
code?: undefined | undefined; | ||
code?: PrivyErrorCode | undefined; | ||
}>; | ||
@@ -249,11 +346,11 @@ }; | ||
cause: zod.ZodOptional<zod.ZodString>; | ||
code: zod.ZodOptional<zod.ZodNativeEnum<typeof undefined>>; | ||
code: zod.ZodOptional<zod.ZodNativeEnum<typeof PrivyErrorCode>>; | ||
}, "strip", zod.ZodTypeAny, { | ||
error: string; | ||
cause?: string | undefined; | ||
code?: undefined | undefined; | ||
code?: PrivyErrorCode | undefined; | ||
}, { | ||
error: string; | ||
cause?: string | undefined; | ||
code?: undefined | undefined; | ||
code?: PrivyErrorCode | undefined; | ||
}>; | ||
@@ -299,99 +396,2 @@ }; | ||
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. */ | ||
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. */ | ||
MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id", | ||
/** The refresh or access token is either not provided or not valid. */ | ||
MISSING_OR_INVALID_TOKEN = "missing_or_invalid_token", | ||
/** The body of the request contains input that is invalid. Check the response body for detailed information. */ | ||
INVALID_DATA = "invalid_data", | ||
/** A form of INVALID_DATA specifically when the user is trying to authenticate and did not match the provided challenge. */ | ||
INVALID_CREDENTIALS = "invalid_credentials", | ||
/** You attempted to link an account that belongs to another user. */ | ||
LINKED_TO_ANOTHER_USER = "linked_to_another_user", | ||
/** This app has an allowlist and the login account was not included. Either disable the allowlist or have the user try again with a different account. */ | ||
ALLOWLIST_REJECTED = "allowlist_rejected", | ||
/** Embedded wallets cannot be unlinked */ | ||
CANNOT_UNLINK_EMBEDDED_WALLET = "cannot_unlink_embedded_wallet", | ||
/** You are unable to unlink an account when there is only one account present. */ | ||
CANNOT_UNLINK_SOLE_ACCOUNT = "cannot_unlink_sole_account", | ||
/** Cannot link another account of this type */ | ||
CANNOT_LINK_MORE_OF_TYPE = "cannot_link_more_of_type", | ||
/** Linked account cannot be found. The account was either invalid or has already been unlinked. */ | ||
LINKED_ACCOUNT_NOT_FOUND = "linked_account_not_found", | ||
/** Too many requests. Please wait to try again. */ | ||
TOO_MANY_REQUESTS = "too_many_requests", | ||
/** Origin was expected and is invalid. */ | ||
INVALID_ORIGIN = "invalid_origin", | ||
/** Origin was expected and is not set. */ | ||
MISSING_ORIGIN = "missing_origin", | ||
/** Refresh token re-use detected. */ | ||
TOKEN_ALREADY_USED = "token_already_used", | ||
/** Attempting to log out of a session that does not exist. */ | ||
ALREADY_LOGGED_OUT = "already_logged_out", | ||
/** The value (phone number, email) that was submitted is not supported. */ | ||
NOT_SUPPORTED = "not_supported", | ||
/** You have previously unsubscribed from the sending email/phone number. */ | ||
USER_UNSUBSCRIBED = "user_unsubscribed", | ||
/** You have reached the maximum number of apps allowed per account. */ | ||
MAX_APPS_REACHED = "max_apps_reached", | ||
/** You are trying to reconstruct an embedded wallet on a device that has been marked as revoked */ | ||
DEVICE_REVOKED = "device_revoked", | ||
/** You attempted to set a password on a wallet with an existing password */ | ||
WALLET_PASSWORD_EXISTS = "wallet_password_exists" | ||
} | ||
type ApiError = { | ||
error: string; | ||
cause?: string; | ||
code?: PrivyErrorCode; | ||
}; | ||
declare class HttpError extends Error { | ||
status: number; | ||
/** Unique Privy error code. The SDK/customers should be able to use this code to programmatically */ | ||
code?: PrivyErrorCode; | ||
constructor(status: number, message: string, code?: PrivyErrorCode); | ||
toString(): string; | ||
} | ||
declare class InvalidInputError extends HttpError { | ||
constructor(message: string, errorCode: PrivyErrorCode); | ||
} | ||
declare class UnauthorizedError extends HttpError { | ||
constructor(message: string, errorCode?: PrivyErrorCode); | ||
} | ||
declare class AllowlistRejectedError extends UnauthorizedError { | ||
/** | ||
* TODO: Changing the default message will cause existing allowlist SDK checks to fail and | ||
* should not be done until we're sure all users are off the version of the SDK that checks for | ||
* that string. | ||
*/ | ||
constructor(message?: string); | ||
} | ||
declare class ForbiddenError extends HttpError { | ||
constructor(message: string, errorCode?: PrivyErrorCode); | ||
} | ||
declare class NotFoundError extends HttpError { | ||
constructor(message: string); | ||
} | ||
declare class UnsupportedMediaType extends HttpError { | ||
constructor(message: string); | ||
} | ||
/** | ||
* @deprecated | ||
* | ||
* Use InvalidInputError moving forward. | ||
* | ||
* In the past, we would occasionally return 422 for invalid input. | ||
*/ | ||
declare class LegacyInvalidInputError extends HttpError { | ||
constructor(message: string, errorCode: PrivyErrorCode); | ||
} | ||
declare class TooManyRequestsError extends HttpError { | ||
constructor(message?: string); | ||
} | ||
declare class InternalServerError extends HttpError { | ||
constructor(message?: string); | ||
} | ||
declare enum Protocols { | ||
@@ -398,0 +398,0 @@ HTTP = "http:", |
@@ -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:()=>y,NotFoundError:()=>x,PrivyErrorCode:()=>c,Protocols:()=>D,Route:()=>T,StatusCode:()=>O,TooManyRequestsError:()=>I,UnauthorizedError:()=>m,UnsupportedMediaType:()=>R,z:()=>u.z});module.exports=w(K);var u=require("zod");var y=(e=>(e.APPLICATION_JSON="application/json",e))(y||{});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 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}); |
{ | ||
"name": "@privy-io/api-base", | ||
"version": "0.2.0-beta-20230925233038", | ||
"version": "0.2.0-beta-20230925233833", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "npm": ">=8.0.0 <10.0.0", |
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
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
42571