@privy-io/api-base 0.4.3 → 0.4.4-beta-20240209183927

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
@@ -48,6 +48,8 @@ declare enum PrivyErrorCode {
48
48
  USER_UNSUBSCRIBED = "user_unsubscribed",
49
49
  /** You have reached the maximum number of apps allowed per account. */
50
50
  MAX_APPS_REACHED = "max_apps_reached",
51
+ /** You have reached the maximum number of users allowed per app. */
52
+ USER_LIMIT_REACHED = "max_accounts_reached",
51
53
  /** You are trying to reconstruct an embedded wallet on a device that has been marked as revoked */
52
54
  DEVICE_REVOKED = "device_revoked",
53
55
  /** You attempted to set a password on a wallet with an existing password */
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var f=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 r of B(e))!M.call(p,r)&&r!==s&&u(p,r,{get:()=>e[r],enumerable:!(a=f(e,r))||a.enumerable});return p};var V=p=>U(u({},"__esModule",{value:!0}),p);var k={};b(k,{APIError:()=>h,AllowlistRejectedError:()=>O,ForbiddenError:()=>d,HttpError:()=>o,HttpMethod:()=>l,InternalServerError:()=>P,InvalidInputError:()=>N,LegacyInvalidInputError:()=>I,MimeType:()=>E,NotFoundError:()=>y,PrivyErrorCode:()=>i,Protocols:()=>D,Route:()=>_,StatusCode:()=>R,TooManyRequestsError:()=>x,UnauthorizedError:()=>m,UnsupportedMediaType:()=>A});module.exports=V(k);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 c=require("zod");var i=(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.INVALID_CAPTCHA="invalid_captcha",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.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",n.DISALLOWED_LOGIN_METHOD="disallowed_login_method",n))(i||{});var h=c.z.object({error:c.z.string(),cause:c.z.string().optional(),code:c.z.nativeEnum(i).optional()});var _=class{#n;#p;#e;#a;#o;#r;#t;#s;constructor({name:e,method:s,path:a,expectedStatusCode:r=200,pathParamsSchema:T,pathQuerySchema:S,bodySchema:g,responseSchema:L}){this.#n=e,this.#p=s,this.#e=a,this.#a=r,this.#o=T,this.#r=S,this.#t=g,this.#s=L}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#a}parsePathParamsOrThrow(e){return this.#o?.parse(e)}parsePathQueryOrThrow(e){return this.#r?.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]:_.toJSONResponseSchema(h,"Invalid Input"),[500]:_.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:e}){let s=this.path;return e!==void 0?(Object.keys(e).forEach(a=>{let r=e[a];s=s.replace(`:${a}`,`${r}`)}),`${s}`):s}};var o=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 o{constructor(e,s){super(400,e,s)}},m=class extends o{constructor(e,s){super(401,e,s)}},O=class extends m{constructor(e){super(e||"User is not allowed to login to this app.","allowlist_rejected")}},d=class extends o{constructor(e,s){super(403,e,s)}},y=class extends o{constructor(e){super(404,e)}},A=class extends o{constructor(e){super(415,e)}},I=class extends o{constructor(e,s){super(422,e,s)}},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=(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});
1
+ "use strict";var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var U=(p,e)=>{for(var s in e)u(p,s,{get:e[s],enumerable:!0})},b=(p,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of M(e))!B.call(p,r)&&r!==s&&u(p,r,{get:()=>e[r],enumerable:!(a=f(e,r))||a.enumerable});return p};var V=p=>b(u({},"__esModule",{value:!0}),p);var k={};U(k,{APIError:()=>h,AllowlistRejectedError:()=>O,ForbiddenError:()=>d,HttpError:()=>o,HttpMethod:()=>l,InternalServerError:()=>P,InvalidInputError:()=>N,LegacyInvalidInputError:()=>A,MimeType:()=>E,NotFoundError:()=>y,PrivyErrorCode:()=>i,Protocols:()=>D,Route:()=>_,StatusCode:()=>R,TooManyRequestsError:()=>x,UnauthorizedError:()=>m,UnsupportedMediaType:()=>I});module.exports=V(k);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 c=require("zod");var i=(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.INVALID_CAPTCHA="invalid_captcha",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.USER_LIMIT_REACHED="max_accounts_reached",n.DEVICE_REVOKED="device_revoked",n.WALLET_PASSWORD_EXISTS="wallet_password_exists",n.OAUTH_STATE_MISMATCH="oauth_state_mismatch",n.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",n.DISALLOWED_LOGIN_METHOD="disallowed_login_method",n))(i||{});var h=c.z.object({error:c.z.string(),cause:c.z.string().optional(),code:c.z.nativeEnum(i).optional()});var _=class{#n;#p;#e;#a;#o;#r;#t;#s;constructor({name:e,method:s,path:a,expectedStatusCode:r=200,pathParamsSchema:T,pathQuerySchema:S,bodySchema:g,responseSchema:L}){this.#n=e,this.#p=s,this.#e=a,this.#a=r,this.#o=T,this.#r=S,this.#t=g,this.#s=L}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#a}parsePathParamsOrThrow(e){return this.#o?.parse(e)}parsePathQueryOrThrow(e){return this.#r?.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]:_.toJSONResponseSchema(h,"Invalid Input"),[500]:_.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:e}){let s=this.path;return e!==void 0?(Object.keys(e).forEach(a=>{let r=e[a];s=s.replace(`:${a}`,`${r}`)}),`${s}`):s}};var o=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 o{constructor(e,s){super(400,e,s)}},m=class extends o{constructor(e,s){super(401,e,s)}},O=class extends m{constructor(e){super(e||"User is not allowed to login to this app.","allowlist_rejected")}},d=class extends o{constructor(e,s){super(403,e,s)}},y=class extends o{constructor(e){super(404,e)}},I=class extends o{constructor(e){super(415,e)}},A=class extends o{constructor(e,s){super(422,e,s)}},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=(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});
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.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.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 T=class{#n;#p;#e;#a;#o;#r;#t;#s;constructor({name:t,method:n,path:o,expectedStatusCode:_=200,pathParamsSchema:r,pathQuerySchema:P,bodySchema:l,responseSchema:D}){this.#n=t,this.#p=n,this.#e=o,this.#a=_,this.#o=r,this.#r=P,this.#t=l,this.#s=D}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#a}parsePathParamsOrThrow(t){return this.#o?.parse(t)}parsePathQueryOrThrow(t){return this.#r?.parse(t)}parseBodyOrThrow(t){return this.#t.parse(t)}parseResponseOrThrow(t,n){let o=this.#s[n];if(!o)throw new Error(`No schema found for status code ${n}`);return o.content["application/json"].schema.parse(t)}static toJSONResponseSchema(t,n){return{content:{"application/json":{schema:t}},description:n}}toSpec(){return{[this.method]:{path:this.#e,request:{body:{content:{"application/json":{schema:this.#t}}}},responses:{...this.#s,[400]:T.toJSONResponseSchema(h,"Invalid Input"),[500]:T.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:t}){let n=this.path;return t!==void 0?(Object.keys(t).forEach(o=>{let _=t[o];n=n.replace(`:${o}`,`${_}`)}),`${n}`):n}};var p=class extends Error{status;code;constructor(t,n,o){super(n),this.code=o,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},R=class extends p{constructor(t,n){super(400,t,n)}},m=class extends p{constructor(t,n){super(401,t,n)}},N=class extends m{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},O=class extends p{constructor(t,n){super(403,t,n)}},d=class extends p{constructor(t){super(404,t)}},y=class extends p{constructor(t){super(415,t)}},A=class extends p{constructor(t,n){super(422,t,n)}},I=class extends p{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},x=class extends p{constructor(t){super(500,t||"Service unavailable.")}};var S=(r=>(r.GET="get",r.POST="post",r.PATCH="patch",r.DELETE="delete",r.PUT="put",r))(S||{});var g=(n=>(n.HTTP="http:",n.HTTPS="https:",n))(g||{});export{h as APIError,N as AllowlistRejectedError,O as ForbiddenError,p as HttpError,S as HttpMethod,x as InternalServerError,R as InvalidInputError,A as LegacyInvalidInputError,u as MimeType,d as NotFoundError,i as PrivyErrorCode,g as Protocols,T 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 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.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 T=class{#n;#p;#e;#a;#o;#r;#t;#s;constructor({name:t,method:n,path:o,expectedStatusCode:_=200,pathParamsSchema:r,pathQuerySchema:P,bodySchema:l,responseSchema:D}){this.#n=t,this.#p=n,this.#e=o,this.#a=_,this.#o=r,this.#r=P,this.#t=l,this.#s=D}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#a}parsePathParamsOrThrow(t){return this.#o?.parse(t)}parsePathQueryOrThrow(t){return this.#r?.parse(t)}parseBodyOrThrow(t){return this.#t.parse(t)}parseResponseOrThrow(t,n){let o=this.#s[n];if(!o)throw new Error(`No schema found for status code ${n}`);return o.content["application/json"].schema.parse(t)}static toJSONResponseSchema(t,n){return{content:{"application/json":{schema:t}},description:n}}toSpec(){return{[this.method]:{path:this.#e,request:{body:{content:{"application/json":{schema:this.#t}}}},responses:{...this.#s,[400]:T.toJSONResponseSchema(h,"Invalid Input"),[500]:T.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:t}){let n=this.path;return t!==void 0?(Object.keys(t).forEach(o=>{let _=t[o];n=n.replace(`:${o}`,`${_}`)}),`${n}`):n}};var p=class extends Error{status;code;constructor(t,n,o){super(n),this.code=o,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},R=class extends p{constructor(t,n){super(400,t,n)}},m=class extends p{constructor(t,n){super(401,t,n)}},N=class extends m{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},O=class extends p{constructor(t,n){super(403,t,n)}},d=class extends p{constructor(t){super(404,t)}},y=class extends p{constructor(t){super(415,t)}},I=class extends p{constructor(t,n){super(422,t,n)}},A=class extends p{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},x=class extends p{constructor(t){super(500,t||"Service unavailable.")}};var S=(r=>(r.GET="get",r.POST="post",r.PATCH="patch",r.DELETE="delete",r.PUT="put",r))(S||{});var g=(n=>(n.HTTP="http:",n.HTTPS="https:",n))(g||{});export{h as APIError,N as AllowlistRejectedError,O as ForbiddenError,p as HttpError,S as HttpMethod,x as InternalServerError,R as InvalidInputError,I as LegacyInvalidInputError,u as MimeType,d as NotFoundError,i as PrivyErrorCode,g as Protocols,T as Route,E as StatusCode,A as TooManyRequestsError,m as UnauthorizedError,y as UnsupportedMediaType};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/api-base",
3
- "version": "0.4.3",
3
+ "version": "0.4.4-beta-20240209183927",
4
4
  "engines": {
5
5
  "npm": ">=8.0.0",
6
6
  "node": ">=18.0.0 <21"