@privy-io/api-base 0.3.0 → 0.4.0-beta-20231019033433

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
@@ -1,6 +1,5 @@
1
1
  import * as zod from 'zod';
2
2
  import { ZodType, ZodCatch, z } from 'zod';
3
- export { z } from 'zod';
4
3
 
5
4
  declare enum PrivyErrorCode {
6
5
  /** The Privy app id is either not provided or not valid. Check the developer console to verify you are setting the correct value. */
@@ -44,7 +43,9 @@ declare enum PrivyErrorCode {
44
43
  /** You are trying to reconstruct an embedded wallet on a device that has been marked as revoked */
45
44
  DEVICE_REVOKED = "device_revoked",
46
45
  /** You attempted to set a password on a wallet with an existing password */
47
- WALLET_PASSWORD_EXISTS = "wallet_password_exists"
46
+ WALLET_PASSWORD_EXISTS = "wallet_password_exists",
47
+ /** The user attempted to complete an oauth flow with a different state than started. */
48
+ OAUTH_STATE_MISMATCH = "oauth_state_mismatch"
48
49
  }
49
50
 
50
51
  type ApiErrorType = {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "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});
1
+ "use strict";var u=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var U=(p,e)=>{for(var s in e)u(p,s,{get:e[s],enumerable:!0})},M=(p,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of B(e))!b.call(p,a)&&a!==s&&u(p,a,{get:()=>e[a],enumerable:!(r=L(e,a))||r.enumerable});return p};var k=p=>M(u({},"__esModule",{value:!0}),p);var K={};U(K,{APIError:()=>h,AllowlistRejectedError:()=>O,ForbiddenError:()=>d,HttpError:()=>o,HttpMethod:()=>l,InternalServerError:()=>I,InvalidInputError:()=>R,LegacyInvalidInputError:()=>P,MimeType:()=>E,NotFoundError:()=>N,PrivyErrorCode:()=>c,Protocols:()=>g,Route:()=>i,StatusCode:()=>y,TooManyRequestsError:()=>A,UnauthorizedError:()=>m,UnsupportedMediaType:()=>x});module.exports=k(K);var E=(e=>(e.APPLICATION_JSON="application/json",e))(E||{});var y=(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))(y||{});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.OAUTH_STATE_MISMATCH="oauth_state_mismatch",n))(c||{});var h=_.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:f}){this.#n=e,this.#p=s,this.#e=r,this.#r=a,this.#o=T,this.#a=D,this.#t=S,this.#s=f}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#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(h,"Invalid Input"),[500]:i.toJSONResponseSchema(h,"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}]`:""}`}},R=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)}},N=class extends o{constructor(e){super(404,e)}},x=class extends o{constructor(e){super(415,e)}},P=class extends o{constructor(e,s){super(422,e,s)}},A=class extends o{constructor(e){super(429,e||"Too many requests. Please wait to try again.","too_many_requests")}},I=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 g=(s=>(s.HTTP="http:",s.HTTPS="https:",s))(g||{});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
- import{z as f}from"zod";var u=(t=>(t.APPLICATION_JSON="application/json",t))(u||{});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 m=_.object({error:_.string(),cause:_.string().optional(),code:_.nativeEnum(c).optional()});var T=class{#n;#p;#e;#r;#o;#a;#t;#s;constructor({name:t,method:s,path:o,expectedStatusCode:i=200,pathParamsSchema:a,pathQuerySchema:I,bodySchema:l,responseSchema:g}){this.#n=t,this.#p=s,this.#e=o,this.#r=i,this.#o=a,this.#a=I,this.#t=l,this.#s=g}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#r}parsePathParamsOrThrow(t){return this.#o?.parse(t)}parsePathQueryOrThrow(t){return this.#a?.parse(t)}parseBodyOrThrow(t){return this.#t.parse(t)}parseResponseOrThrow(t,s){let o=this.#s[s];if(!o)throw new Error(`No schema found for status code ${s}`);return o.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:{...this.#s,[400]:T.toJSONResponseSchema(m,"Invalid Input"),[500]:T.toJSONResponseSchema(m,"Server Error")}}}}constructPath({params:t}){let s=this.path;return t!==void 0?(Object.keys(t).forEach(o=>{let i=t[o];s=s.replace(`:${o}`,`${i}`)}),`${s}`):s}};var p=class extends Error{status;code;constructor(t,s,o){super(s),this.code=o,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},E=class extends p{constructor(t,s){super(400,t,s)}},h=class extends p{constructor(t,s){super(401,t,s)}},R=class extends h{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},d=class extends p{constructor(t,s){super(403,t,s)}},N=class extends p{constructor(t){super(404,t)}},O=class extends p{constructor(t){super(415,t)}},x=class extends p{constructor(t,s){super(422,t,s)}},P=class extends p{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},A=class extends p{constructor(t){super(500,t||"Service unavailable.")}};var D=(a=>(a.GET="get",a.POST="post",a.PATCH="patch",a.DELETE="delete",a.PUT="put",a))(D||{});var S=(s=>(s.HTTP="http:",s.HTTPS="https:",s))(S||{});export{m as APIError,R as AllowlistRejectedError,d as ForbiddenError,p as HttpError,D as HttpMethod,A as InternalServerError,E as InvalidInputError,x as LegacyInvalidInputError,u as MimeType,N as NotFoundError,c as PrivyErrorCode,S as Protocols,T as Route,y as StatusCode,P as TooManyRequestsError,h as UnauthorizedError,O as UnsupportedMediaType,f as z};
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 _}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.OAUTH_STATE_MISMATCH="oauth_state_mismatch",n))(c||{});var h=_.object({error:_.string(),cause:_.string().optional(),code:_.nativeEnum(c).optional()});var T=class{#n;#p;#e;#r;#o;#a;#t;#s;constructor({name:t,method:s,path:o,expectedStatusCode:i=200,pathParamsSchema:a,pathQuerySchema:I,bodySchema:l,responseSchema:g}){this.#n=t,this.#p=s,this.#e=o,this.#r=i,this.#o=a,this.#a=I,this.#t=l,this.#s=g}get name(){return this.#n}get method(){return this.#p}get path(){return this.#e}get expectedStatusCode(){return this.#r}parsePathParamsOrThrow(t){return this.#o?.parse(t)}parsePathQueryOrThrow(t){return this.#a?.parse(t)}parseBodyOrThrow(t){return this.#t.parse(t)}parseResponseOrThrow(t,s){let o=this.#s[s];if(!o)throw new Error(`No schema found for status code ${s}`);return o.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:{...this.#s,[400]:T.toJSONResponseSchema(h,"Invalid Input"),[500]:T.toJSONResponseSchema(h,"Server Error")}}}}constructPath({params:t}){let s=this.path;return t!==void 0?(Object.keys(t).forEach(o=>{let i=t[o];s=s.replace(`:${o}`,`${i}`)}),`${s}`):s}};var p=class extends Error{status;code;constructor(t,s,o){super(s),this.code=o,this.status=t}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},y=class extends p{constructor(t,s){super(400,t,s)}},m=class extends p{constructor(t,s){super(401,t,s)}},R=class extends m{constructor(t){super(t||"User is not allowed to login to this app.","allowlist_rejected")}},O=class extends p{constructor(t,s){super(403,t,s)}},d=class extends p{constructor(t){super(404,t)}},N=class extends p{constructor(t){super(415,t)}},x=class extends p{constructor(t,s){super(422,t,s)}},P=class extends p{constructor(t){super(429,t||"Too many requests. Please wait to try again.","too_many_requests")}},A=class extends p{constructor(t){super(500,t||"Service unavailable.")}};var D=(a=>(a.GET="get",a.POST="post",a.PATCH="patch",a.DELETE="delete",a.PUT="put",a))(D||{});var S=(s=>(s.HTTP="http:",s.HTTPS="https:",s))(S||{});export{h as APIError,R as AllowlistRejectedError,O as ForbiddenError,p as HttpError,D as HttpMethod,A as InternalServerError,y as InvalidInputError,x as LegacyInvalidInputError,u as MimeType,d as NotFoundError,c as PrivyErrorCode,S as Protocols,T as Route,E as StatusCode,P as TooManyRequestsError,m as UnauthorizedError,N as UnsupportedMediaType};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privy-io/api-base",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-beta-20231019033433",
4
4
  "engines": {
5
5
  "npm": ">=8.0.0 <10.0.0",
6
6
  "node": ">=18.0.0 <19"
@@ -15,11 +15,6 @@
15
15
  "import": "./dist/index.mjs",
16
16
  "types": "./dist/index.d.ts"
17
17
  },
18
- "./zod": {
19
- "require": "./dist/index.js",
20
- "import": "./dist/index.mjs",
21
- "types": "./dist/index.d.ts"
22
- },
23
18
  "./constants": {
24
19
  "require": "./dist/index.js",
25
20
  "import": "./dist/index.mjs",
@@ -61,4 +56,4 @@
61
56
  "publishConfig": {
62
57
  "access": "public"
63
58
  }
64
- }
59
+ }