@privy-io/api-base 0.4.6 → 0.4.7-beta-20240415224541

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -61,7 +61,13 @@ declare enum PrivyErrorCode {
61
61
  /** You have reached the maximum number of denylist entries allowed per app. */
62
62
  MAX_DENYLIST_ENTRIES_REACHED = "max_denylist_entries_reached",
63
63
  /** The user attempted to log in or link a disallowed method. */
64
- DISALLOWED_LOGIN_METHOD = "disallowed_login_method"
64
+ DISALLOWED_LOGIN_METHOD = "disallowed_login_method",
65
+ /** The customer must enforce login methods through the dashboard */
66
+ LEGACY_DASHBOARD_LOGIN_CONFIGURATION = "legacy_dashboard_login_configuration",
67
+ /** Cannot set password on this wallet */
68
+ CANNOT_SET_PASSWORD = "cannot_set_password",
69
+ /** Invalid PKCE parameters */
70
+ INVALID_PKCE_PARAMETERS = "invalid_pkce_parameters"
65
71
  }
66
72
 
67
73
  type ApiErrorType = {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var a in e)u(n,a,{get:e[a],enumerable:!0})},B=(n,e,a,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of M(e))!U.call(n,r)&&r!==a&&u(n,r,{get:()=>e[r],enumerable:!(p=f(e,r))||p.enumerable});return n};var V=n=>B(u({},"__esModule",{value:!0}),n);var k={};b(k,{APIError:()=>h,AllowlistRejectedError:()=>N,ForbiddenError:()=>O,HttpError:()=>o,HttpMethod:()=>l,InternalServerError:()=>P,InvalidInputError:()=>R,LegacyInvalidInputError:()=>I,MimeType:()=>E,NotFoundError:()=>y,PrivyErrorCode:()=>i,Protocols:()=>S,Route:()=>T,StatusCode:()=>d,TooManyRequestsError:()=>x,UnauthorizedError:()=>m,UnsupportedMediaType:()=>A});module.exports=V(k);var E=(e=>(e.APPLICATION_JSON="application/json",e))(E||{});var d=(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))(d||{});var c=require("zod");var i=(s=>(s.OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",s.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",s.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",s.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",s.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",s.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",s.INVALID_DATA="invalid_data",s.INVALID_CREDENTIALS="invalid_credentials",s.INVALID_CAPTCHA="invalid_captcha",s.LINKED_TO_ANOTHER_USER="linked_to_another_user",s.ALLOWLIST_REJECTED="allowlist_rejected",s.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",s.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",s.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",s.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",s.TOO_MANY_REQUESTS="too_many_requests",s.INVALID_ORIGIN="invalid_origin",s.MISSING_ORIGIN="missing_origin",s.INVALID_NATIVE_APP_ID="invalid_native_app_id",s.TOKEN_ALREADY_USED="token_already_used",s.ALREADY_LOGGED_OUT="already_logged_out",s.NOT_SUPPORTED="not_supported",s.USER_UNSUBSCRIBED="user_unsubscribed",s.MAX_APPS_REACHED="max_apps_reached",s.USER_LIMIT_REACHED="max_accounts_reached",s.DEVICE_REVOKED="device_revoked",s.WALLET_PASSWORD_EXISTS="wallet_password_exists",s.OAUTH_STATE_MISMATCH="oauth_state_mismatch",s.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",s.DISALLOWED_LOGIN_METHOD="disallowed_login_method",s))(i||{});var h=c.z.object({error:c.z.string(),cause:c.z.string().optional(),code:c.z.nativeEnum(i).optional()});var T=class{_name;_method;_path;_expectedStatusCode;_pathParamsSchema;_queryParamsSchema;_bodySchema;_responseSchema;constructor({name:e,method:a,path:p,expectedStatusCode:r=200,pathParamsSchema:_,pathQuerySchema:D,bodySchema:g,responseSchema:L}){this._name=e,this._method=a,this._path=p,this._expectedStatusCode=r,this._pathParamsSchema=_,this._queryParamsSchema=D,this._bodySchema=g,this._responseSchema=L}get name(){return this._name}get method(){return this._method}get path(){return this._path}get expectedStatusCode(){return this._expectedStatusCode}parsePathParamsOrThrow(e){return this._pathParamsSchema?.parse(e)}parsePathQueryOrThrow(e){return this._queryParamsSchema?.parse(e)}parseBodyOrThrow(e){return this._bodySchema.parse(e)}parseResponseOrThrow(e,a){let p=this._responseSchema[a];if(!p)throw new Error(`No schema found for status code ${a}`);return p.content["application/json"].schema.parse(e)}static toJSONResponseSchema(e,a){return{content:{"application/json":{schema:e}},description:a}}toSpec(){return{[this.method]:{path:this._path,request:{body:{content:{"application/json":{schema:this._bodySchema}}}},responses:{...this._responseSchema,[400]:T.toJSONResponseSchema(h,"Invalid Input"),[500]:T.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:e}){let a=this.path;return e!==void 0?(Object.keys(e).forEach(p=>{let r=e[p];a=a.replace(`:${p}`,`${r}`)}),`${a}`):a}};var o=class extends Error{status;code;constructor(e,a,p){super(a),this.code=p,this.status=e}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},R=class extends o{constructor(e,a){super(400,e,a)}},m=class extends o{constructor(e,a){super(401,e,a)}},N=class extends m{constructor(e){super(e||"User is not allowed to login to this app.","allowlist_rejected")}},O=class extends o{constructor(e,a){super(403,e,a)}},y=class extends o{constructor(e){super(404,e)}},A=class extends o{constructor(e){super(415,e)}},I=class extends o{constructor(e,a){super(422,e,a)}},x=class extends o{constructor(e){super(429,e||"Too many requests. Please wait to try again.","too_many_requests")}},P=class extends o{constructor(e){super(500,e||"Service unavailable.")}};var l=(_=>(_.GET="get",_.POST="post",_.PATCH="patch",_.DELETE="delete",_.PUT="put",_))(l||{});var S=(a=>(a.HTTP="http:",a.HTTPS="https:",a))(S||{});0&&(module.exports={APIError,AllowlistRejectedError,ForbiddenError,HttpError,HttpMethod,InternalServerError,InvalidInputError,LegacyInvalidInputError,MimeType,NotFoundError,PrivyErrorCode,Protocols,Route,StatusCode,TooManyRequestsError,UnauthorizedError,UnsupportedMediaType});
1
+ "use strict";var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var a in e)u(n,a,{get:e[a],enumerable:!0})},B=(n,e,a,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of M(e))!U.call(n,o)&&o!==a&&u(n,o,{get:()=>e[o],enumerable:!(p=f(e,o))||p.enumerable});return n};var V=n=>B(u({},"__esModule",{value:!0}),n);var k={};b(k,{APIError:()=>h,AllowlistRejectedError:()=>d,ForbiddenError:()=>O,HttpError:()=>_,HttpMethod:()=>S,InternalServerError:()=>P,InvalidInputError:()=>N,LegacyInvalidInputError:()=>y,MimeType:()=>R,NotFoundError:()=>A,PrivyErrorCode:()=>c,Protocols:()=>l,Route:()=>T,StatusCode:()=>E,TooManyRequestsError:()=>x,UnauthorizedError:()=>m,UnsupportedMediaType:()=>I});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 i=require("zod");var c=(s=>(s.OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",s.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",s.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",s.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",s.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",s.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",s.INVALID_DATA="invalid_data",s.INVALID_CREDENTIALS="invalid_credentials",s.INVALID_CAPTCHA="invalid_captcha",s.LINKED_TO_ANOTHER_USER="linked_to_another_user",s.ALLOWLIST_REJECTED="allowlist_rejected",s.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",s.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",s.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",s.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",s.TOO_MANY_REQUESTS="too_many_requests",s.INVALID_ORIGIN="invalid_origin",s.MISSING_ORIGIN="missing_origin",s.INVALID_NATIVE_APP_ID="invalid_native_app_id",s.TOKEN_ALREADY_USED="token_already_used",s.ALREADY_LOGGED_OUT="already_logged_out",s.NOT_SUPPORTED="not_supported",s.USER_UNSUBSCRIBED="user_unsubscribed",s.MAX_APPS_REACHED="max_apps_reached",s.USER_LIMIT_REACHED="max_accounts_reached",s.DEVICE_REVOKED="device_revoked",s.WALLET_PASSWORD_EXISTS="wallet_password_exists",s.OAUTH_STATE_MISMATCH="oauth_state_mismatch",s.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",s.DISALLOWED_LOGIN_METHOD="disallowed_login_method",s.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",s.CANNOT_SET_PASSWORD="cannot_set_password",s.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",s))(c||{});var h=i.z.object({error:i.z.string(),cause:i.z.string().optional(),code:i.z.nativeEnum(c).optional()});var T=class{_name;_method;_path;_expectedStatusCode;_pathParamsSchema;_queryParamsSchema;_bodySchema;_responseSchema;constructor({name:e,method:a,path:p,expectedStatusCode:o=200,pathParamsSchema:r,pathQuerySchema:D,bodySchema:g,responseSchema:L}){this._name=e,this._method=a,this._path=p,this._expectedStatusCode=o,this._pathParamsSchema=r,this._queryParamsSchema=D,this._bodySchema=g,this._responseSchema=L}get name(){return this._name}get method(){return this._method}get path(){return this._path}get expectedStatusCode(){return this._expectedStatusCode}parsePathParamsOrThrow(e){return this._pathParamsSchema?.parse(e)}parsePathQueryOrThrow(e){return this._queryParamsSchema?.parse(e)}parseBodyOrThrow(e){return this._bodySchema.parse(e)}parseResponseOrThrow(e,a){let p=this._responseSchema[a];if(!p)throw new Error(`No schema found for status code ${a}`);return p.content["application/json"].schema.parse(e)}static toJSONResponseSchema(e,a){return{content:{"application/json":{schema:e}},description:a}}toSpec(){return{[this.method]:{path:this._path,request:{body:{content:{"application/json":{schema:this._bodySchema}}}},responses:{...this._responseSchema,[400]:T.toJSONResponseSchema(h,"Invalid Input"),[500]:T.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:e}){let a=this.path;return e!==void 0?(Object.keys(e).forEach(p=>{let o=e[p];a=a.replace(`:${p}`,`${o}`)}),`${a}`):a}};var _=class extends Error{status;code;constructor(e,a,p){super(a),this.code=p,this.status=e}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},N=class extends _{constructor(e,a){super(400,e,a)}},m=class extends _{constructor(e,a){super(401,e,a)}},d=class extends m{constructor(e){super(e||"User is not allowed to login to this app.","allowlist_rejected")}},O=class extends _{constructor(e,a){super(403,e,a)}},A=class extends _{constructor(e){super(404,e)}},I=class extends _{constructor(e){super(415,e)}},y=class extends _{constructor(e,a){super(422,e,a)}},x=class extends _{constructor(e){super(429,e||"Too many requests. Please wait to try again.","too_many_requests")}},P=class extends _{constructor(e){super(500,e||"Service unavailable.")}};var S=(r=>(r.GET="get",r.POST="post",r.PATCH="patch",r.DELETE="delete",r.PUT="put",r))(S||{});var l=(a=>(a.HTTP="http:",a.HTTPS="https:",a))(l||{});0&&(module.exports={APIError,AllowlistRejectedError,ForbiddenError,HttpError,HttpMethod,InternalServerError,InvalidInputError,LegacyInvalidInputError,MimeType,NotFoundError,PrivyErrorCode,Protocols,Route,StatusCode,TooManyRequestsError,UnauthorizedError,UnsupportedMediaType});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var u=(t=>(t.APPLICATION_JSON="application/json",t))(u||{});var E=(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))(E||{});import{z as c}from"zod";var i=(s=>(s.OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",s.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",s.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",s.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",s.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",s.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",s.INVALID_DATA="invalid_data",s.INVALID_CREDENTIALS="invalid_credentials",s.INVALID_CAPTCHA="invalid_captcha",s.LINKED_TO_ANOTHER_USER="linked_to_another_user",s.ALLOWLIST_REJECTED="allowlist_rejected",s.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",s.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",s.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",s.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",s.TOO_MANY_REQUESTS="too_many_requests",s.INVALID_ORIGIN="invalid_origin",s.MISSING_ORIGIN="missing_origin",s.INVALID_NATIVE_APP_ID="invalid_native_app_id",s.TOKEN_ALREADY_USED="token_already_used",s.ALREADY_LOGGED_OUT="already_logged_out",s.NOT_SUPPORTED="not_supported",s.USER_UNSUBSCRIBED="user_unsubscribed",s.MAX_APPS_REACHED="max_apps_reached",s.USER_LIMIT_REACHED="max_accounts_reached",s.DEVICE_REVOKED="device_revoked",s.WALLET_PASSWORD_EXISTS="wallet_password_exists",s.OAUTH_STATE_MISMATCH="oauth_state_mismatch",s.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",s.DISALLOWED_LOGIN_METHOD="disallowed_login_method",s))(i||{});var h=c.object({error:c.string(),cause:c.string().optional(),code:c.nativeEnum(i).optional()});var _=class{_name;_method;_path;_expectedStatusCode;_pathParamsSchema;_queryParamsSchema;_bodySchema;_responseSchema;constructor({name:t,method:a,path:o,expectedStatusCode:T=200,pathParamsSchema:r,pathQuerySchema:P,bodySchema:l,responseSchema:S}){this._name=t,this._method=a,this._path=o,this._expectedStatusCode=T,this._pathParamsSchema=r,this._queryParamsSchema=P,this._bodySchema=l,this._responseSchema=S}get name(){return this._name}get method(){return this._method}get path(){return this._path}get expectedStatusCode(){return this._expectedStatusCode}parsePathParamsOrThrow(t){return this._pathParamsSchema?.parse(t)}parsePathQueryOrThrow(t){return this._queryParamsSchema?.parse(t)}parseBodyOrThrow(t){return this._bodySchema.parse(t)}parseResponseOrThrow(t,a){let o=this._responseSchema[a];if(!o)throw new Error(`No schema found for status code ${a}`);return o.content["application/json"].schema.parse(t)}static toJSONResponseSchema(t,a){return{content:{"application/json":{schema:t}},description:a}}toSpec(){return{[this.method]:{path:this._path,request:{body:{content:{"application/json":{schema:this._bodySchema}}}},responses:{...this._responseSchema,[400]:_.toJSONResponseSchema(h,"Invalid Input"),[500]:_.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:t}){let a=this.path;return t!==void 0?(Object.keys(t).forEach(o=>{let T=t[o];a=a.replace(`:${o}`,`${T}`)}),`${a}`):a}};var n=class extends Error{status;code;constructor(t,a,o){super(a),this.code=o,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},d=class extends n{constructor(t,a){super(400,t,a)}},m=class extends n{constructor(t,a){super(401,t,a)}},R=class extends m{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},N=class extends n{constructor(t,a){super(403,t,a)}},O=class extends n{constructor(t){super(404,t)}},y=class extends n{constructor(t){super(415,t)}},A=class extends n{constructor(t,a){super(422,t,a)}},I=class extends n{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},x=class extends n{constructor(t){super(500,t||"Service unavailable.")}};var D=(r=>(r.GET="get",r.POST="post",r.PATCH="patch",r.DELETE="delete",r.PUT="put",r))(D||{});var g=(a=>(a.HTTP="http:",a.HTTPS="https:",a))(g||{});export{h as APIError,R as AllowlistRejectedError,N as ForbiddenError,n as HttpError,D as HttpMethod,x as InternalServerError,d as InvalidInputError,A as LegacyInvalidInputError,u as MimeType,O as NotFoundError,i as PrivyErrorCode,g as Protocols,_ as Route,E as StatusCode,I as TooManyRequestsError,m as UnauthorizedError,y as UnsupportedMediaType};
1
+ var u=(t=>(t.APPLICATION_JSON="application/json",t))(u||{});var R=(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))(R||{});import{z as i}from"zod";var c=(s=>(s.OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",s.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",s.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",s.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",s.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",s.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",s.INVALID_DATA="invalid_data",s.INVALID_CREDENTIALS="invalid_credentials",s.INVALID_CAPTCHA="invalid_captcha",s.LINKED_TO_ANOTHER_USER="linked_to_another_user",s.ALLOWLIST_REJECTED="allowlist_rejected",s.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",s.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",s.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",s.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",s.TOO_MANY_REQUESTS="too_many_requests",s.INVALID_ORIGIN="invalid_origin",s.MISSING_ORIGIN="missing_origin",s.INVALID_NATIVE_APP_ID="invalid_native_app_id",s.TOKEN_ALREADY_USED="token_already_used",s.ALREADY_LOGGED_OUT="already_logged_out",s.NOT_SUPPORTED="not_supported",s.USER_UNSUBSCRIBED="user_unsubscribed",s.MAX_APPS_REACHED="max_apps_reached",s.USER_LIMIT_REACHED="max_accounts_reached",s.DEVICE_REVOKED="device_revoked",s.WALLET_PASSWORD_EXISTS="wallet_password_exists",s.OAUTH_STATE_MISMATCH="oauth_state_mismatch",s.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",s.DISALLOWED_LOGIN_METHOD="disallowed_login_method",s.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",s.CANNOT_SET_PASSWORD="cannot_set_password",s.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",s))(c||{});var h=i.object({error:i.string(),cause:i.string().optional(),code:i.nativeEnum(c).optional()});var r=class{_name;_method;_path;_expectedStatusCode;_pathParamsSchema;_queryParamsSchema;_bodySchema;_responseSchema;constructor({name:t,method:a,path:_,expectedStatusCode:T=200,pathParamsSchema:o,pathQuerySchema:P,bodySchema:S,responseSchema:l}){this._name=t,this._method=a,this._path=_,this._expectedStatusCode=T,this._pathParamsSchema=o,this._queryParamsSchema=P,this._bodySchema=S,this._responseSchema=l}get name(){return this._name}get method(){return this._method}get path(){return this._path}get expectedStatusCode(){return this._expectedStatusCode}parsePathParamsOrThrow(t){return this._pathParamsSchema?.parse(t)}parsePathQueryOrThrow(t){return this._queryParamsSchema?.parse(t)}parseBodyOrThrow(t){return this._bodySchema.parse(t)}parseResponseOrThrow(t,a){let _=this._responseSchema[a];if(!_)throw new Error(`No schema found for status code ${a}`);return _.content["application/json"].schema.parse(t)}static toJSONResponseSchema(t,a){return{content:{"application/json":{schema:t}},description:a}}toSpec(){return{[this.method]:{path:this._path,request:{body:{content:{"application/json":{schema:this._bodySchema}}}},responses:{...this._responseSchema,[400]:r.toJSONResponseSchema(h,"Invalid Input"),[500]:r.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:t}){let a=this.path;return t!==void 0?(Object.keys(t).forEach(_=>{let T=t[_];a=a.replace(`:${_}`,`${T}`)}),`${a}`):a}};var n=class extends Error{status;code;constructor(t,a,_){super(a),this.code=_,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},E=class extends n{constructor(t,a){super(400,t,a)}},m=class extends n{constructor(t,a){super(401,t,a)}},N=class extends m{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},d=class extends n{constructor(t,a){super(403,t,a)}},O=class extends n{constructor(t){super(404,t)}},A=class extends n{constructor(t){super(415,t)}},I=class extends n{constructor(t,a){super(422,t,a)}},y=class extends n{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},x=class extends n{constructor(t){super(500,t||"Service unavailable.")}};var D=(o=>(o.GET="get",o.POST="post",o.PATCH="patch",o.DELETE="delete",o.PUT="put",o))(D||{});var g=(a=>(a.HTTP="http:",a.HTTPS="https:",a))(g||{});export{h as APIError,N as AllowlistRejectedError,d as ForbiddenError,n as HttpError,D as HttpMethod,x as InternalServerError,E as InvalidInputError,I as LegacyInvalidInputError,u as MimeType,O as NotFoundError,c as PrivyErrorCode,g as Protocols,r as Route,R as StatusCode,y as TooManyRequestsError,m as UnauthorizedError,A as UnsupportedMediaType};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/api-base",
3
- "version": "0.4.6",
3
+ "version": "0.4.7-beta-20240415224541",
4
4
  "engines": {
5
5
  "npm": ">=8.0.0",
6
6
  "node": ">=18.0.0"