@privy-io/api-base 0.4.4 → 0.4.5-beta-20240226143107
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 +10 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import * as zod from 'zod';
|
|
|
2
2
|
import { ZodType, ZodCatch, z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare enum PrivyErrorCode {
|
|
5
|
+
/** The user's OAuth account is suspended and is not allowed. */
|
|
6
|
+
OAUTH_ACCOUNT_SUSPENDED = "oauth_account_suspended",
|
|
5
7
|
/** The Privy app id is either not provided or not valid. Check the developer dashboard to verify you are setting the correct value. */
|
|
6
8
|
MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
|
|
7
9
|
/** The Privy account id is either not provided or not valid. Check the developer dashboard to verify you are setting the correct value. */
|
|
@@ -247,7 +249,14 @@ type BaseRouteType = IRouteNamedTypes<string, TBaseResponse, StatusCode.OK>;
|
|
|
247
249
|
* @property {StatusCode} T.ExpectedStatusCode - The expected HTTP status code of the response. Default is StatusCode.OK.
|
|
248
250
|
*/
|
|
249
251
|
declare class Route<Path extends string, ExpectedResponseType extends TBaseResponse, T extends IRouteNamedTypes<Path, ExpectedResponseType>> {
|
|
250
|
-
|
|
252
|
+
private _name;
|
|
253
|
+
private _method;
|
|
254
|
+
private _path;
|
|
255
|
+
private _expectedStatusCode;
|
|
256
|
+
private _pathParamsSchema;
|
|
257
|
+
private _queryParamsSchema;
|
|
258
|
+
private _bodySchema;
|
|
259
|
+
private _responseSchema;
|
|
251
260
|
/**
|
|
252
261
|
* Constructs a new instance of the Route class.
|
|
253
262
|
*
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var
|
|
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});
|
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.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
|
|
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};
|