@privy-io/api-base 1.4.1 → 1.4.3-beta-20250125011906

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.
@@ -0,0 +1 @@
1
+ "use strict";var r=require("../constants/error-codes.js");class s extends Error{toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(r,s,e,t){super(s),this.code=e,this.status=r,this.responseData=t}}class e extends s{constructor(r,s){super(401,r,s)}}exports.AccountTransferRequiredError=class extends s{constructor(s){super(400,"Account transfer required",r.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED,s),this.data=s}},exports.AllowlistRejectedError=class extends e{constructor(s){super(s||"User is not allowed to login to this app.",r.PrivyErrorCode.ALLOWLIST_REJECTED)}},exports.ForbiddenError=class extends s{constructor(r,s){super(403,r,s)}},exports.HttpError=s,exports.InternalServerError=class extends s{constructor(r){super(500,r||"Service unavailable.")}},exports.InvalidInputError=class extends s{constructor(s,e){super(400,s,e||r.PrivyErrorCode.INVALID_DATA)}},exports.LegacyInvalidInputError=class extends s{constructor(r,s){super(422,r,s)}},exports.NotFoundError=class extends s{constructor(r){super(404,r)}},exports.RequestTimeoutError=class extends s{constructor(r,s){super(408,r,s)}},exports.TooManyRequestsError=class extends s{constructor(s){super(429,s||"Too many requests. Please wait to try again.",r.PrivyErrorCode.TOO_MANY_REQUESTS)}},exports.UnauthorizedError=e,exports.UnsupportedMediaType=class extends s{constructor(r){super(415,r)}};
@@ -0,0 +1 @@
1
+ "use strict";var r=require("./api-error.js");require("../constants/error-codes.js"),exports.AccountTransferRequiredError=r.AccountTransferRequiredError,exports.AllowlistRejectedError=r.AllowlistRejectedError,exports.ForbiddenError=r.ForbiddenError,exports.HttpError=r.HttpError,exports.InternalServerError=r.InternalServerError,exports.InvalidInputError=r.InvalidInputError,exports.LegacyInvalidInputError=r.LegacyInvalidInputError,exports.NotFoundError=r.NotFoundError,exports.RequestTimeoutError=r.RequestTimeoutError,exports.TooManyRequestsError=r.TooManyRequestsError,exports.UnauthorizedError=r.UnauthorizedError,exports.UnsupportedMediaType=r.UnsupportedMediaType;
@@ -0,0 +1 @@
1
+ "use strict";var _,i=((_={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",_.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",_.MISSING_OR_INVALID_PRIVY_CLIENT_ID="missing_or_invalid_privy_client_id",_.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",_.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",_.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",_.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",_.INVALID_DATA="invalid_data",_.INVALID_CREDENTIALS="invalid_credentials",_.INVALID_CAPTCHA="invalid_captcha",_.LINKED_TO_ANOTHER_USER="linked_to_another_user",_.ALLOWLIST_REJECTED="allowlist_rejected",_.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",_.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",_.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",_.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",_.TOO_MANY_REQUESTS="too_many_requests",_.INVALID_ORIGIN="invalid_origin",_.MISSING_ORIGIN="missing_origin",_.INVALID_NATIVE_APP_ID="invalid_native_app_id",_.TOKEN_ALREADY_USED="token_already_used",_.ALREADY_LOGGED_OUT="already_logged_out",_.NOT_SUPPORTED="not_supported",_.USER_UNSUBSCRIBED="user_unsubscribed",_.MAX_APPS_REACHED="max_apps_reached",_.USER_LIMIT_REACHED="max_accounts_reached",_.DEVICE_REVOKED="device_revoked",_.WALLET_PASSWORD_EXISTS="wallet_password_exists",_.OAUTH_STATE_MISMATCH="oauth_state_mismatch",_.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",_.MAX_TEST_ACCOUNTS_REACHED="max_test_accounts_reached",_.DISALLOWED_LOGIN_METHOD="disallowed_login_method",_.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",_.DISALLOWED_RECOVERY_METHOD="disallowed_recovery_method",_.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",_.CANNOT_SET_PASSWORD="cannot_set_password",_.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",_.INVALID_APP_URL_SCHEME_CONFIGURATION="invalid_app_url_scheme_configuration",_.CROSS_APP_CONNECTION_NOT_ALLOWED="cross_app_connection_not_allowed",_.USER_DOES_NOT_EXIST="user_does_not_exist",_.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",_.USER_HAS_NOT_DELEGATED_WALLET="user_has_not_delegated_wallet",_.FEATURE_NOT_ENABLED="feature_not_enabled",_.INSUFFICIENT_FUNDS="insufficient_funds",_.TRANSACTION_BROADCAST_FAILURE="transaction_broadcast_failure",_.INVALID_POLICY_FORMAT="invalid_policy_format",_.POLICY_VIOLATION="policy_violation",_);exports.PrivyErrorCode=i;
@@ -0,0 +1 @@
1
+ "use strict";var r=require("./error-codes.js");exports.PrivyErrorCode=r.PrivyErrorCode;
@@ -0,0 +1 @@
1
+ "use strict";var r=require("./classes/api-error.js"),e=require("./constants/error-codes.js"),o=require("./schemas/error.js");require("zod"),exports.AccountTransferRequiredError=r.AccountTransferRequiredError,exports.AllowlistRejectedError=r.AllowlistRejectedError,exports.ForbiddenError=r.ForbiddenError,exports.HttpError=r.HttpError,exports.InternalServerError=r.InternalServerError,exports.InvalidInputError=r.InvalidInputError,exports.LegacyInvalidInputError=r.LegacyInvalidInputError,exports.NotFoundError=r.NotFoundError,exports.RequestTimeoutError=r.RequestTimeoutError,exports.TooManyRequestsError=r.TooManyRequestsError,exports.UnauthorizedError=r.UnauthorizedError,exports.UnsupportedMediaType=r.UnsupportedMediaType,exports.PrivyErrorCode=e.PrivyErrorCode,exports.APIError=o.APIError;
@@ -0,0 +1 @@
1
+ "use strict";var r=require("zod"),o=require("../constants/error-codes.js");const e=r.z.object({error:r.z.string(),cause:r.z.string().optional(),code:r.z.nativeEnum(o.PrivyErrorCode).optional()});exports.APIError=e;
@@ -0,0 +1 @@
1
+ "use strict";var r=require("./error.js");require("zod"),require("../constants/error-codes.js"),exports.APIError=r.APIError;
@@ -0,0 +1,196 @@
1
+ import { z } from 'zod';
2
+
3
+ declare enum PrivyErrorCode {
4
+ /** The user's OAuth account is suspended and is not allowed. */
5
+ OAUTH_ACCOUNT_SUSPENDED = "oauth_account_suspended",
6
+ /** The Privy app id is either not provided or not valid. Check the developer dashboard to verify you are setting the correct value. */
7
+ MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id",
8
+ /** The Privy app client id is either not provided or not valid. Check the developer dashboard to verify you are setting the correct value. */
9
+ MISSING_OR_INVALID_PRIVY_CLIENT_ID = "missing_or_invalid_privy_client_id",
10
+ /** The Privy account id is either not provided or not valid. Check the developer dashboard to verify you are setting the correct value. */
11
+ MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id",
12
+ /** The refresh or access token is either not provided or not valid. */
13
+ MISSING_OR_INVALID_TOKEN = "missing_or_invalid_token",
14
+ /** The user does not have a valid MFA connected */
15
+ MISSING_OR_INVALID_MFA = "missing_or_invalid_mfa",
16
+ /** The MFA Token provided has expired */
17
+ EXPIRED_OR_INVALID_MFA_TOKEN = "expired_or_invalid_mfa_token",
18
+ /** The body of the request contains input that is invalid. Check the response body for detailed information. */
19
+ INVALID_DATA = "invalid_data",
20
+ /** A form of INVALID_DATA specifically when the user is trying to authenticate and did not match the provided challenge. */
21
+ INVALID_CREDENTIALS = "invalid_credentials",
22
+ /** When the user is trying to authenticate and did provide a valid CAPTCHA token. */
23
+ INVALID_CAPTCHA = "invalid_captcha",
24
+ /** You attempted to link an account that belongs to another user. */
25
+ LINKED_TO_ANOTHER_USER = "linked_to_another_user",
26
+ /** 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. */
27
+ ALLOWLIST_REJECTED = "allowlist_rejected",
28
+ /** Embedded wallets cannot be unlinked */
29
+ CANNOT_UNLINK_EMBEDDED_WALLET = "cannot_unlink_embedded_wallet",
30
+ /** You are unable to unlink an account when there is only one account present. */
31
+ CANNOT_UNLINK_SOLE_ACCOUNT = "cannot_unlink_sole_account",
32
+ /** Cannot link another account of this type */
33
+ CANNOT_LINK_MORE_OF_TYPE = "cannot_link_more_of_type",
34
+ /** Linked account cannot be found. The account was either invalid or has already been unlinked. */
35
+ LINKED_ACCOUNT_NOT_FOUND = "linked_account_not_found",
36
+ /** Too many requests. Please wait to try again. */
37
+ TOO_MANY_REQUESTS = "too_many_requests",
38
+ /** Origin was expected and is invalid. */
39
+ INVALID_ORIGIN = "invalid_origin",
40
+ /** Origin was expected and is not set. */
41
+ MISSING_ORIGIN = "missing_origin",
42
+ /** Native App ID was expected and is invalid. */
43
+ INVALID_NATIVE_APP_ID = "invalid_native_app_id",
44
+ /** Refresh token re-use detected. */
45
+ TOKEN_ALREADY_USED = "token_already_used",
46
+ /** Attempting to log out of a session that does not exist. */
47
+ ALREADY_LOGGED_OUT = "already_logged_out",
48
+ /** The value (phone number, email) that was submitted is not supported. */
49
+ NOT_SUPPORTED = "not_supported",
50
+ /** You have previously unsubscribed from the sending email/phone number. */
51
+ USER_UNSUBSCRIBED = "user_unsubscribed",
52
+ /** You have reached the maximum number of apps allowed per account. */
53
+ MAX_APPS_REACHED = "max_apps_reached",
54
+ /** You have reached the maximum number of users allowed per app. */
55
+ USER_LIMIT_REACHED = "max_accounts_reached",
56
+ /** You are trying to reconstruct an embedded wallet on a device that has been marked as revoked */
57
+ DEVICE_REVOKED = "device_revoked",
58
+ /** You attempted to set a password on a wallet with an existing password */
59
+ WALLET_PASSWORD_EXISTS = "wallet_password_exists",
60
+ /** The user attempted to complete an oauth flow with a different state than started. */
61
+ OAUTH_STATE_MISMATCH = "oauth_state_mismatch",
62
+ /** You have reached the maximum number of denylist entries allowed per app. */
63
+ MAX_DENYLIST_ENTRIES_REACHED = "max_denylist_entries_reached",
64
+ /** You have reached the maximum number of test account entries allowed per app. */
65
+ MAX_TEST_ACCOUNTS_REACHED = "max_test_accounts_reached",
66
+ /** The user attempted to log in or link a disallowed method. */
67
+ DISALLOWED_LOGIN_METHOD = "disallowed_login_method",
68
+ /** The user attempted to log in with an email address with a + in it, but the app is configured to disallow this */
69
+ DISALLOWED_PLUS_EMAIL = "disallowed_plus_email",
70
+ /** The user attempted to recover their embedded wallet via a disallowed method. */
71
+ DISALLOWED_RECOVERY_METHOD = "disallowed_recovery_method",
72
+ /** The customer must enforce login methods through the dashboard */
73
+ LEGACY_DASHBOARD_LOGIN_CONFIGURATION = "legacy_dashboard_login_configuration",
74
+ /** Cannot set password on this wallet */
75
+ CANNOT_SET_PASSWORD = "cannot_set_password",
76
+ /** Invalid PKCE parameters */
77
+ INVALID_PKCE_PARAMETERS = "invalid_pkce_parameters",
78
+ /** Invalid app url scheme configuration */
79
+ INVALID_APP_URL_SCHEME_CONFIGURATION = "invalid_app_url_scheme_configuration",
80
+ /** This app is not permitted to provider to target app */
81
+ CROSS_APP_CONNECTION_NOT_ALLOWED = "cross_app_connection_not_allowed",
82
+ /** There is no user with this login method */
83
+ USER_DOES_NOT_EXIST = "user_does_not_exist",
84
+ ACCOUNT_TRANSFER_REQUIRED = "account_transfer_required",
85
+ /** The user has not consented to delegated actions for this wallet */
86
+ USER_HAS_NOT_DELEGATED_WALLET = "user_has_not_delegated_wallet",
87
+ /** This feature is not enabled on the app */
88
+ FEATURE_NOT_ENABLED = "feature_not_enabled",
89
+ /** Wallet has insufficent funds for transaction */
90
+ INSUFFICIENT_FUNDS = "insufficient_funds",
91
+ /** Transaction broadcast failure */
92
+ TRANSACTION_BROADCAST_FAILURE = "transaction_broadcast_failure",
93
+ /** Invalid policy format */
94
+ INVALID_POLICY_FORMAT = "invalid_policy_format",
95
+ /** Policy violation */
96
+ POLICY_VIOLATION = "policy_violation"
97
+ }
98
+
99
+ type ApiErrorType = {
100
+ error: string;
101
+ cause?: string;
102
+ code?: PrivyErrorCode;
103
+ data?: Record<string, any>;
104
+ };
105
+ declare class HttpError extends Error {
106
+ status: number;
107
+ /** Unique Privy error code. The SDK/customers should be able to use this code to programmatically */
108
+ code?: PrivyErrorCode;
109
+ responseData?: Record<string, any>;
110
+ constructor(status: number, message: string, code?: PrivyErrorCode, responseData?: Record<string, any>);
111
+ toString(): string;
112
+ }
113
+ declare class InvalidInputError extends HttpError {
114
+ constructor(message: string, errorCode?: PrivyErrorCode);
115
+ }
116
+ declare class UnauthorizedError extends HttpError {
117
+ constructor(message: string, errorCode?: PrivyErrorCode);
118
+ }
119
+ declare class AllowlistRejectedError extends UnauthorizedError {
120
+ /**
121
+ * TODO: Changing the default message will cause existing allowlist SDK checks to fail and
122
+ * should not be done until we're sure all users are off the version of the SDK that checks for
123
+ * that string.
124
+ */
125
+ constructor(message?: string);
126
+ }
127
+ declare class ForbiddenError extends HttpError {
128
+ constructor(message: string, errorCode?: PrivyErrorCode);
129
+ }
130
+ declare class NotFoundError extends HttpError {
131
+ constructor(message: string);
132
+ }
133
+ declare class RequestTimeoutError extends HttpError {
134
+ constructor(message: string, errorCode?: PrivyErrorCode);
135
+ }
136
+ declare class UnsupportedMediaType extends HttpError {
137
+ constructor(message: string);
138
+ }
139
+ /**
140
+ * @deprecated
141
+ *
142
+ * Use InvalidInputError moving forward.
143
+ *
144
+ * In the past, we would occasionally return 422 for invalid input.
145
+ */
146
+ declare class LegacyInvalidInputError extends HttpError {
147
+ constructor(message: string, errorCode: PrivyErrorCode);
148
+ }
149
+ declare class TooManyRequestsError extends HttpError {
150
+ constructor(message?: string);
151
+ }
152
+ declare class InternalServerError extends HttpError {
153
+ constructor(message?: string);
154
+ }
155
+ declare class AccountTransferRequiredError extends HttpError {
156
+ data: {
157
+ nonce: string;
158
+ subject: string;
159
+ otherUser: {
160
+ embeddedWalletAddress: string | null;
161
+ farcasterEmbeddedAddress?: string;
162
+ oAuthUserInfo?: Record<string, any>;
163
+ };
164
+ account: {
165
+ displayName: string | null;
166
+ };
167
+ };
168
+ constructor(data: {
169
+ nonce: string;
170
+ subject: string;
171
+ otherUser: {
172
+ embeddedWalletAddress: string | null;
173
+ farcasterEmbeddedAddress?: string;
174
+ oAuthUserInfo?: Record<string, any>;
175
+ };
176
+ account: {
177
+ displayName: string | null;
178
+ };
179
+ });
180
+ }
181
+
182
+ declare const APIError: z.ZodObject<{
183
+ error: z.ZodString;
184
+ cause: z.ZodOptional<z.ZodString>;
185
+ code: z.ZodOptional<z.ZodNativeEnum<typeof PrivyErrorCode>>;
186
+ }, "strip", z.ZodTypeAny, {
187
+ error: string;
188
+ cause?: string | undefined;
189
+ code?: PrivyErrorCode | undefined;
190
+ }, {
191
+ error: string;
192
+ cause?: string | undefined;
193
+ code?: PrivyErrorCode | undefined;
194
+ }>;
195
+
196
+ export { APIError, AccountTransferRequiredError, AllowlistRejectedError, type ApiErrorType, ForbiddenError, HttpError, InternalServerError, InvalidInputError, LegacyInvalidInputError, NotFoundError, PrivyErrorCode, RequestTimeoutError, TooManyRequestsError, UnauthorizedError, UnsupportedMediaType };
@@ -61,6 +61,8 @@ declare enum PrivyErrorCode {
61
61
  OAUTH_STATE_MISMATCH = "oauth_state_mismatch",
62
62
  /** You have reached the maximum number of denylist entries allowed per app. */
63
63
  MAX_DENYLIST_ENTRIES_REACHED = "max_denylist_entries_reached",
64
+ /** You have reached the maximum number of test account entries allowed per app. */
65
+ MAX_TEST_ACCOUNTS_REACHED = "max_test_accounts_reached",
64
66
  /** The user attempted to log in or link a disallowed method. */
65
67
  DISALLOWED_LOGIN_METHOD = "disallowed_login_method",
66
68
  /** The user attempted to log in with an email address with a + in it, but the app is configured to disallow this */
@@ -87,7 +89,11 @@ declare enum PrivyErrorCode {
87
89
  /** Wallet has insufficent funds for transaction */
88
90
  INSUFFICIENT_FUNDS = "insufficient_funds",
89
91
  /** Transaction broadcast failure */
90
- TRANSACTION_BROADCAST_FAILURE = "transaction_broadcast_failure"
92
+ TRANSACTION_BROADCAST_FAILURE = "transaction_broadcast_failure",
93
+ /** Invalid policy format */
94
+ INVALID_POLICY_FORMAT = "invalid_policy_format",
95
+ /** Policy violation */
96
+ POLICY_VIOLATION = "policy_violation"
91
97
  }
92
98
 
93
99
  type ApiErrorType = {
@@ -187,4 +193,4 @@ declare const APIError: z.ZodObject<{
187
193
  code?: PrivyErrorCode | undefined;
188
194
  }>;
189
195
 
190
- export { APIError, AccountTransferRequiredError, AllowlistRejectedError, ApiErrorType, ForbiddenError, HttpError, InternalServerError, InvalidInputError, LegacyInvalidInputError, NotFoundError, PrivyErrorCode, RequestTimeoutError, TooManyRequestsError, UnauthorizedError, UnsupportedMediaType };
196
+ export { APIError, AccountTransferRequiredError, AllowlistRejectedError, type ApiErrorType, ForbiddenError, HttpError, InternalServerError, InvalidInputError, LegacyInvalidInputError, NotFoundError, PrivyErrorCode, RequestTimeoutError, TooManyRequestsError, UnauthorizedError, UnsupportedMediaType };
@@ -0,0 +1 @@
1
+ import{PrivyErrorCode as s}from"../constants/error-codes.mjs";class t extends Error{toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}constructor(s,t,e,r){super(t),this.code=e,this.status=s,this.responseData=r}}class e extends t{constructor(t,e){super(400,t,e||s.INVALID_DATA)}}class r extends t{constructor(s,t){super(401,s,t)}}class c extends r{constructor(t){super(t||"User is not allowed to login to this app.",s.ALLOWLIST_REJECTED)}}class o extends t{constructor(s,t){super(403,s,t)}}class n extends t{constructor(s){super(404,s)}}class a extends t{constructor(s,t){super(408,s,t)}}class u extends t{constructor(s){super(415,s)}}class i extends t{constructor(s,t){super(422,s,t)}}class l extends t{constructor(t){super(429,t||"Too many requests. Please wait to try again.",s.TOO_MANY_REQUESTS)}}class d extends t{constructor(s){super(500,s||"Service unavailable.")}}class p extends t{constructor(t){super(400,"Account transfer required",s.ACCOUNT_TRANSFER_REQUIRED,t),this.data=t}}export{p as AccountTransferRequiredError,c as AllowlistRejectedError,o as ForbiddenError,t as HttpError,d as InternalServerError,e as InvalidInputError,i as LegacyInvalidInputError,n as NotFoundError,a as RequestTimeoutError,l as TooManyRequestsError,r as UnauthorizedError,u as UnsupportedMediaType};
@@ -0,0 +1 @@
1
+ export{AccountTransferRequiredError,AllowlistRejectedError,ForbiddenError,HttpError,InternalServerError,InvalidInputError,LegacyInvalidInputError,NotFoundError,RequestTimeoutError,TooManyRequestsError,UnauthorizedError,UnsupportedMediaType}from"./api-error.mjs";import"../constants/error-codes.mjs";
@@ -0,0 +1 @@
1
+ var _,I=((_={}).OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",_.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",_.MISSING_OR_INVALID_PRIVY_CLIENT_ID="missing_or_invalid_privy_client_id",_.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",_.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",_.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",_.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",_.INVALID_DATA="invalid_data",_.INVALID_CREDENTIALS="invalid_credentials",_.INVALID_CAPTCHA="invalid_captcha",_.LINKED_TO_ANOTHER_USER="linked_to_another_user",_.ALLOWLIST_REJECTED="allowlist_rejected",_.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",_.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",_.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",_.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",_.TOO_MANY_REQUESTS="too_many_requests",_.INVALID_ORIGIN="invalid_origin",_.MISSING_ORIGIN="missing_origin",_.INVALID_NATIVE_APP_ID="invalid_native_app_id",_.TOKEN_ALREADY_USED="token_already_used",_.ALREADY_LOGGED_OUT="already_logged_out",_.NOT_SUPPORTED="not_supported",_.USER_UNSUBSCRIBED="user_unsubscribed",_.MAX_APPS_REACHED="max_apps_reached",_.USER_LIMIT_REACHED="max_accounts_reached",_.DEVICE_REVOKED="device_revoked",_.WALLET_PASSWORD_EXISTS="wallet_password_exists",_.OAUTH_STATE_MISMATCH="oauth_state_mismatch",_.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",_.MAX_TEST_ACCOUNTS_REACHED="max_test_accounts_reached",_.DISALLOWED_LOGIN_METHOD="disallowed_login_method",_.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",_.DISALLOWED_RECOVERY_METHOD="disallowed_recovery_method",_.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",_.CANNOT_SET_PASSWORD="cannot_set_password",_.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",_.INVALID_APP_URL_SCHEME_CONFIGURATION="invalid_app_url_scheme_configuration",_.CROSS_APP_CONNECTION_NOT_ALLOWED="cross_app_connection_not_allowed",_.USER_DOES_NOT_EXIST="user_does_not_exist",_.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",_.USER_HAS_NOT_DELEGATED_WALLET="user_has_not_delegated_wallet",_.FEATURE_NOT_ENABLED="feature_not_enabled",_.INSUFFICIENT_FUNDS="insufficient_funds",_.TRANSACTION_BROADCAST_FAILURE="transaction_broadcast_failure",_.INVALID_POLICY_FORMAT="invalid_policy_format",_.POLICY_VIOLATION="policy_violation",_);export{I as PrivyErrorCode};
@@ -0,0 +1 @@
1
+ export{PrivyErrorCode}from"./error-codes.mjs";
@@ -0,0 +1 @@
1
+ export{AccountTransferRequiredError,AllowlistRejectedError,ForbiddenError,HttpError,InternalServerError,InvalidInputError,LegacyInvalidInputError,NotFoundError,RequestTimeoutError,TooManyRequestsError,UnauthorizedError,UnsupportedMediaType}from"./classes/api-error.mjs";export{PrivyErrorCode}from"./constants/error-codes.mjs";export{APIError}from"./schemas/error.mjs";import"zod";
@@ -0,0 +1 @@
1
+ import{z as o}from"zod";import{PrivyErrorCode as r}from"../constants/error-codes.mjs";const t=o.object({error:o.string(),cause:o.string().optional(),code:o.nativeEnum(r).optional()});export{t as APIError};
@@ -0,0 +1 @@
1
+ export{APIError}from"./error.mjs";import"zod";import"../constants/error-codes.mjs";
package/package.json CHANGED
@@ -1,53 +1,55 @@
1
1
  {
2
2
  "name": "@privy-io/api-base",
3
- "version": "1.4.1",
3
+ "version": "1.4.3-beta-20250125011906",
4
4
  "exports": {
5
5
  ".": {
6
- "require": "./dist/index.js",
7
- "import": "./dist/index.mjs",
8
- "types": "./dist/index.d.ts"
9
- },
10
- "./constants": {
11
- "require": "./dist/index.js",
12
- "import": "./dist/index.mjs",
13
- "types": "./dist/index.d.ts"
14
- },
15
- "./constants/*": {
16
- "require": "./dist/index.js",
17
- "import": "./dist/index.mjs",
18
- "types": "./dist/index.d.ts"
19
- },
20
- "./classes": {
21
- "require": "./dist/index.js",
22
- "import": "./dist/index.mjs",
23
- "types": "./dist/index.d.ts"
6
+ "require": {
7
+ "types": "./dist/dts/index.d.ts",
8
+ "default": "./dist/cjs/index.js"
9
+ },
10
+ "import": {
11
+ "types": "./dist/dts/index.d.mts",
12
+ "default": "./dist/esm/index.mjs"
13
+ }
24
14
  }
25
15
  },
26
- "main": "./dist/index.js",
27
- "module": "./dist/index.mjs",
28
- "types": "./dist/index.d.ts",
29
- "typings": "./dist/index",
16
+ "main": "./dist/cjs/index.js",
17
+ "module": "./dist/esm/index.mjs",
18
+ "types": "./dist/dts/index.d.ts",
19
+ "typings": "./dist/dts/index",
30
20
  "files": [
31
21
  "dist/**/*",
32
22
  "LICENSE",
33
23
  "README.md"
34
24
  ],
35
25
  "scripts": {
36
- "build": "npx tsup --clean --minify",
37
- "check-types": "npx tsc --noEmit",
26
+ "build": "rollup --config rollup.types.mjs && rollup --config rollup.build.mjs",
27
+ "check-types": "tsc --noEmit",
38
28
  "clean": "rm -rf dist .turbo",
39
- "dev": "npx tsup --watch",
40
- "format": "eslint ./**/*.ts --fix",
41
- "lint": "eslint ./**/*.ts",
42
- "test": "jest --testMatch \"**/test/**/*.test.ts\""
29
+ "d//": "To parallelize types and code build output rollup recommends running multiple instances",
30
+ "dev": "concurrently --prefix=none \"rollup --config rollup.types.mjs --watch\" \"rollup --config rollup.dev.mjs --watch\"",
31
+ "format": "eslint src --fix",
32
+ "lint": "eslint src",
33
+ "test": "jest"
43
34
  },
44
35
  "dependencies": {
45
36
  "zod": "^3.21.4"
46
37
  },
47
38
  "devDependencies": {
39
+ "@privy-io/build-config": "*",
48
40
  "@privy-io/eslint-config-custom": "*",
49
41
  "@privy-io/tsconfig": "*",
50
- "tsup": "^6.2.3",
42
+ "@rollup/plugin-node-resolve": "^15.3.0",
43
+ "@rollup/plugin-replace": "^6.0.1",
44
+ "@rollup/plugin-swc": "^0.4.0",
45
+ "@rollup/plugin-terser": "^0.4.4",
46
+ "@rollup/plugin-typescript": "^11.1.6",
47
+ "@swc/core": "^1.10.0",
48
+ "@swc/plugin-styled-components": "^6.0.1",
49
+ "glob": "^10.3.12",
50
+ "rollup": "^4.28.0",
51
+ "rollup-plugin-copy": "^3.5.0",
52
+ "rollup-plugin-dts": "^6.1.1",
51
53
  "typescript": "~5.5.3"
52
54
  },
53
55
  "engines": {
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var N=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var m=(t,s)=>{for(var e in s)N(t,e,{get:s[e],enumerable:!0})},x=(t,s,e,A)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of d(s))!g.call(t,a)&&a!==e&&N(t,a,{get:()=>s[a],enumerable:!(A=E(s,a))||A.enumerable});return t};var U=t=>x(N({},"__esModule",{value:!0}),t);var h={};m(h,{APIError:()=>f,AccountTransferRequiredError:()=>L,AllowlistRejectedError:()=>o,ForbiddenError:()=>u,HttpError:()=>n,InternalServerError:()=>R,InvalidInputError:()=>l,LegacyInvalidInputError:()=>T,NotFoundError:()=>p,PrivyErrorCode:()=>c,RequestTimeoutError:()=>D,TooManyRequestsError:()=>S,UnauthorizedError:()=>I,UnsupportedMediaType:()=>O});module.exports=U(h);var c=(_=>(_.OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",_.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",_.MISSING_OR_INVALID_PRIVY_CLIENT_ID="missing_or_invalid_privy_client_id",_.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",_.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",_.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",_.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",_.INVALID_DATA="invalid_data",_.INVALID_CREDENTIALS="invalid_credentials",_.INVALID_CAPTCHA="invalid_captcha",_.LINKED_TO_ANOTHER_USER="linked_to_another_user",_.ALLOWLIST_REJECTED="allowlist_rejected",_.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",_.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",_.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",_.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",_.TOO_MANY_REQUESTS="too_many_requests",_.INVALID_ORIGIN="invalid_origin",_.MISSING_ORIGIN="missing_origin",_.INVALID_NATIVE_APP_ID="invalid_native_app_id",_.TOKEN_ALREADY_USED="token_already_used",_.ALREADY_LOGGED_OUT="already_logged_out",_.NOT_SUPPORTED="not_supported",_.USER_UNSUBSCRIBED="user_unsubscribed",_.MAX_APPS_REACHED="max_apps_reached",_.USER_LIMIT_REACHED="max_accounts_reached",_.DEVICE_REVOKED="device_revoked",_.WALLET_PASSWORD_EXISTS="wallet_password_exists",_.OAUTH_STATE_MISMATCH="oauth_state_mismatch",_.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",_.DISALLOWED_LOGIN_METHOD="disallowed_login_method",_.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",_.DISALLOWED_RECOVERY_METHOD="disallowed_recovery_method",_.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",_.CANNOT_SET_PASSWORD="cannot_set_password",_.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",_.INVALID_APP_URL_SCHEME_CONFIGURATION="invalid_app_url_scheme_configuration",_.CROSS_APP_CONNECTION_NOT_ALLOWED="cross_app_connection_not_allowed",_.USER_DOES_NOT_EXIST="user_does_not_exist",_.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",_.USER_HAS_NOT_DELEGATED_WALLET="user_has_not_delegated_wallet",_.FEATURE_NOT_ENABLED="feature_not_enabled",_.INSUFFICIENT_FUNDS="insufficient_funds",_.TRANSACTION_BROADCAST_FAILURE="transaction_broadcast_failure",_))(c||{});var n=class extends Error{status;code;responseData;constructor(s,e,A,a){super(e),this.code=A,this.status=s,this.responseData=a}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},l=class extends n{constructor(s,e){super(400,s,e||"invalid_data")}},I=class extends n{constructor(s,e){super(401,s,e)}},o=class extends I{constructor(s){super(s||"User is not allowed to login to this app.","allowlist_rejected")}},u=class extends n{constructor(s,e){super(403,s,e)}},p=class extends n{constructor(s){super(404,s)}},D=class extends n{constructor(s,e){super(408,s,e)}},O=class extends n{constructor(s){super(415,s)}},T=class extends n{constructor(s,e){super(422,s,e)}},S=class extends n{constructor(s){super(429,s||"Too many requests. Please wait to try again.","too_many_requests")}},R=class extends n{constructor(s){super(500,s||"Service unavailable.")}},L=class extends n{constructor(e){super(400,"Account transfer required","account_transfer_required",e);this.data=e}};var i=require("zod");var f=i.z.object({error:i.z.string(),cause:i.z.string().optional(),code:i.z.nativeEnum(c).optional()});0&&(module.exports={APIError,AccountTransferRequiredError,AllowlistRejectedError,ForbiddenError,HttpError,InternalServerError,InvalidInputError,LegacyInvalidInputError,NotFoundError,PrivyErrorCode,RequestTimeoutError,TooManyRequestsError,UnauthorizedError,UnsupportedMediaType});
package/dist/index.mjs DELETED
@@ -1 +0,0 @@
1
- var a=(_=>(_.OAUTH_ACCOUNT_SUSPENDED="oauth_account_suspended",_.MISSING_OR_INVALID_PRIVY_APP_ID="missing_or_invalid_privy_app_id",_.MISSING_OR_INVALID_PRIVY_CLIENT_ID="missing_or_invalid_privy_client_id",_.MISSING_OR_INVALID_PRIVY_ACCOUNT_ID="missing_or_invalid_privy_account_id",_.MISSING_OR_INVALID_TOKEN="missing_or_invalid_token",_.MISSING_OR_INVALID_MFA="missing_or_invalid_mfa",_.EXPIRED_OR_INVALID_MFA_TOKEN="expired_or_invalid_mfa_token",_.INVALID_DATA="invalid_data",_.INVALID_CREDENTIALS="invalid_credentials",_.INVALID_CAPTCHA="invalid_captcha",_.LINKED_TO_ANOTHER_USER="linked_to_another_user",_.ALLOWLIST_REJECTED="allowlist_rejected",_.CANNOT_UNLINK_EMBEDDED_WALLET="cannot_unlink_embedded_wallet",_.CANNOT_UNLINK_SOLE_ACCOUNT="cannot_unlink_sole_account",_.CANNOT_LINK_MORE_OF_TYPE="cannot_link_more_of_type",_.LINKED_ACCOUNT_NOT_FOUND="linked_account_not_found",_.TOO_MANY_REQUESTS="too_many_requests",_.INVALID_ORIGIN="invalid_origin",_.MISSING_ORIGIN="missing_origin",_.INVALID_NATIVE_APP_ID="invalid_native_app_id",_.TOKEN_ALREADY_USED="token_already_used",_.ALREADY_LOGGED_OUT="already_logged_out",_.NOT_SUPPORTED="not_supported",_.USER_UNSUBSCRIBED="user_unsubscribed",_.MAX_APPS_REACHED="max_apps_reached",_.USER_LIMIT_REACHED="max_accounts_reached",_.DEVICE_REVOKED="device_revoked",_.WALLET_PASSWORD_EXISTS="wallet_password_exists",_.OAUTH_STATE_MISMATCH="oauth_state_mismatch",_.MAX_DENYLIST_ENTRIES_REACHED="max_denylist_entries_reached",_.DISALLOWED_LOGIN_METHOD="disallowed_login_method",_.DISALLOWED_PLUS_EMAIL="disallowed_plus_email",_.DISALLOWED_RECOVERY_METHOD="disallowed_recovery_method",_.LEGACY_DASHBOARD_LOGIN_CONFIGURATION="legacy_dashboard_login_configuration",_.CANNOT_SET_PASSWORD="cannot_set_password",_.INVALID_PKCE_PARAMETERS="invalid_pkce_parameters",_.INVALID_APP_URL_SCHEME_CONFIGURATION="invalid_app_url_scheme_configuration",_.CROSS_APP_CONNECTION_NOT_ALLOWED="cross_app_connection_not_allowed",_.USER_DOES_NOT_EXIST="user_does_not_exist",_.ACCOUNT_TRANSFER_REQUIRED="account_transfer_required",_.USER_HAS_NOT_DELEGATED_WALLET="user_has_not_delegated_wallet",_.FEATURE_NOT_ENABLED="feature_not_enabled",_.INSUFFICIENT_FUNDS="insufficient_funds",_.TRANSACTION_BROADCAST_FAILURE="transaction_broadcast_failure",_))(a||{});var e=class extends Error{status;code;responseData;constructor(s,t,S,R){super(t),this.code=S,this.status=s,this.responseData=R}toString(){return`${this.constructor.name}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},A=class extends e{constructor(s,t){super(400,s,t||"invalid_data")}},i=class extends e{constructor(s,t){super(401,s,t)}},I=class extends i{constructor(s){super(s||"User is not allowed to login to this app.","allowlist_rejected")}},N=class extends e{constructor(s,t){super(403,s,t)}},l=class extends e{constructor(s){super(404,s)}},o=class extends e{constructor(s,t){super(408,s,t)}},u=class extends e{constructor(s){super(415,s)}},p=class extends e{constructor(s,t){super(422,s,t)}},D=class extends e{constructor(s){super(429,s||"Too many requests. Please wait to try again.","too_many_requests")}},O=class extends e{constructor(s){super(500,s||"Service unavailable.")}},T=class extends e{constructor(t){super(400,"Account transfer required","account_transfer_required",t);this.data=t}};import{z as c}from"zod";var V=c.object({error:c.string(),cause:c.string().optional(),code:c.nativeEnum(a).optional()});export{V as APIError,T as AccountTransferRequiredError,I as AllowlistRejectedError,N as ForbiddenError,e as HttpError,O as InternalServerError,A as InvalidInputError,p as LegacyInvalidInputError,l as NotFoundError,a as PrivyErrorCode,o as RequestTimeoutError,D as TooManyRequestsError,i as UnauthorizedError,u as UnsupportedMediaType};