@privy-io/js-sdk-core
Advanced tools
Comparing version 0.0.1 to 0.1.1-beta-20230925224215
@@ -1,5 +0,10 @@ | ||
import { InferRouteTypes } from '@privy-io/api-base'; | ||
import { refreshSession } from '@privy-io/core-api'; | ||
import EventEmitter from 'eventemitter3'; | ||
import EventEmitter from "eventemitter3"; | ||
import { InferRouteTypes } from "@privy-io/api-base"; | ||
import { refreshSession } from "@privy-io/public-api"; | ||
interface Storage { | ||
get(key: string): unknown; | ||
put(key: string, value: unknown): void; | ||
del(key: string): void; | ||
getKeys(): string[]; | ||
} | ||
declare class CustomProvider { | ||
@@ -29,4 +34,4 @@ #private; | ||
address: string; | ||
verified_at: number; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
wallet_client: "unknown"; | ||
@@ -39,5 +44,5 @@ chain_id?: string | undefined; | ||
address: string; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
chain_id: "eip155:1"; | ||
chain_type: "ethereum"; | ||
wallet_client: "privy"; | ||
@@ -57,4 +62,4 @@ wallet_client_type: "privy"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -64,4 +69,4 @@ type: "discord_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -72,4 +77,4 @@ type: "github_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -82,4 +87,4 @@ type: "apple_oauth"; | ||
type: "custom_auth"; | ||
verified_at: number; | ||
custom_user_id: string; | ||
verified_at: number; | ||
})[]; | ||
@@ -90,113 +95,6 @@ }; | ||
} | ||
/** | ||
* We support a subset of the provider methods found here: | ||
* | ||
* https://ethereum.org/en/developers/docs/apis/json-rpc/#json-rpc-methods | ||
* | ||
* For now, we're focused on signing-related methods because the iframe (this code) | ||
* is the only place that has access to the private key and thus is the only one | ||
* who can create signatures. All other methods do not need the private key and | ||
* can therefore be implemented by clients of the iframe. | ||
*/ | ||
type Quantity = string | number | bigint; | ||
type UnsignedTransactionRequest = { | ||
from?: string; | ||
to?: string; | ||
nonce?: Quantity; | ||
gasLimit?: Quantity; | ||
gasPrice?: Quantity; | ||
data?: ArrayLike<number> | string; | ||
value?: Quantity; | ||
chainId?: number; | ||
type?: number; | ||
accessList?: Array<{ | ||
address: string; | ||
storageKeys: Array<string>; | ||
}> | Array<[string, Array<string>]> | Record<string, Array<string>>; | ||
maxPriorityFeePerGas?: Quantity; | ||
maxFeePerGas?: Quantity; | ||
}; | ||
interface eth_populateTransactionRequestResponse { | ||
method: 'eth_populateTransactionRequest'; | ||
data: UnsignedTransactionRequest; | ||
} | ||
interface eth_signResponse { | ||
method: 'eth_sign'; | ||
data: string; | ||
} | ||
interface personal_signResponse { | ||
method: 'personal_sign'; | ||
data: string; | ||
} | ||
interface eth_signTransactionResponse { | ||
method: 'eth_signTransaction'; | ||
data: string; | ||
} | ||
interface eth_signTypedData_v4Response { | ||
method: 'eth_signTypedData_v4'; | ||
data: string; | ||
} | ||
type RpcResponseType = eth_signTransactionResponse | eth_populateTransactionRequestResponse | eth_signResponse | personal_signResponse | eth_signTypedData_v4Response; | ||
type PrivyEventType = 'privy:iframe:ready' | 'privy:wallet:create' | 'privy:wallet:connect' | 'privy:wallet:recover' | 'privy:wallet:rpc' | 'privy:wallet:set-recovery-password'; | ||
type IframeReadyResponseDataType = Record<string, never>; | ||
type WalletCreateResponseDataType = { | ||
address: string; | ||
}; | ||
type WalletConnectResponseDataType = { | ||
address: string; | ||
}; | ||
type WalletRecoverResponseDataType = { | ||
address: string; | ||
}; | ||
type WalletSetRecoveryPasswordResponseDataType = { | ||
address: string; | ||
}; | ||
type WalletRpcResponseDataType = { | ||
address: string; | ||
response: RpcResponseType; | ||
}; | ||
declare const PrivyIframeErrorTypes: readonly ["error", "invalid_request_arguments", "wallet_not_on_device", "invalid_recovery_pin", "insufficient_funds"]; | ||
type PrivyIframeErrorTypesType = (typeof PrivyIframeErrorTypes)[number]; | ||
interface PrivyResponseBaseEventType { | ||
id: string; | ||
event: PrivyEventType; | ||
} | ||
interface PrivyErrorResponseEventType extends PrivyResponseBaseEventType { | ||
error: { | ||
type: PrivyIframeErrorTypesType; | ||
message: string; | ||
}; | ||
} | ||
interface IframeReadyResponseEventType extends PrivyResponseBaseEventType { | ||
event: 'privy:iframe:ready'; | ||
data: IframeReadyResponseDataType; | ||
} | ||
interface WalletCreateResponseEventType extends PrivyResponseBaseEventType { | ||
event: 'privy:wallet:create'; | ||
data: WalletCreateResponseDataType; | ||
} | ||
interface WalletConnectResponseEventType extends PrivyResponseBaseEventType { | ||
event: 'privy:wallet:connect'; | ||
data: WalletConnectResponseDataType; | ||
} | ||
interface WalletRecoverResponseEventType extends PrivyResponseBaseEventType { | ||
event: 'privy:wallet:recover'; | ||
data: WalletRecoverResponseDataType; | ||
} | ||
interface WalletSetRecoveryPasswordResponseEventType extends PrivyResponseBaseEventType { | ||
event: 'privy:wallet:set-recovery-password'; | ||
data: WalletSetRecoveryPasswordResponseDataType; | ||
} | ||
interface WalletRpcResponseEventType extends PrivyResponseBaseEventType { | ||
event: 'privy:wallet:rpc'; | ||
data: WalletRpcResponseDataType; | ||
} | ||
type PrivyResponseEvent = IframeReadyResponseEventType | PrivyErrorResponseEventType | WalletCreateResponseEventType | WalletConnectResponseEventType | WalletRecoverResponseEventType | WalletSetRecoveryPasswordResponseEventType | WalletRpcResponseEventType; | ||
type EmbeddedWalletMessagePoster = { | ||
postMessage: (message: any, targetOrigin: string, transfer?: Transferable) => void; | ||
}; | ||
declare enum PrivyErrorCode { | ||
enum PrivyErrorCode { | ||
MISSING_OR_INVALID_PRIVY_APP_ID = "missing_or_invalid_privy_app_id", | ||
@@ -248,3 +146,2 @@ MISSING_OR_INVALID_PRIVY_ACCOUNT_ID = "missing_or_invalid_privy_account_id", | ||
} | ||
type ProviderConnectInfo = { | ||
@@ -278,14 +175,7 @@ chainId: string; | ||
request(request: RequestArguments): Promise<any>; | ||
private handleStatic; | ||
private handleEstimateGas; | ||
private handleSwitchEthereumChain; | ||
private handleIFrameRpc; | ||
private handleJsonRpc; | ||
} | ||
type AuthenticatedUser = InferRouteTypes<typeof refreshSession>['expectedResponse']; | ||
type User$1 = NonNullable<AuthenticatedUser['user']>; | ||
type LinkedAccount = User$1['linked_accounts']; | ||
type PrivyEmbeddedWalletProvider = EmbeddedWalletProvider; | ||
export type AuthenticatedUser = InferRouteTypes<typeof refreshSession>['expectedResponse']; | ||
export type User = NonNullable<AuthenticatedUser['user']>; | ||
export type LinkedAccount = User['linked_accounts']; | ||
export type PrivyEmbeddedWalletProvider = EmbeddedWalletProvider; | ||
declare class Email { | ||
@@ -329,4 +219,4 @@ #private; | ||
address: string; | ||
verified_at: number; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
wallet_client: "unknown"; | ||
@@ -339,5 +229,5 @@ chain_id?: string | undefined; | ||
address: string; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
chain_id: "eip155:1"; | ||
chain_type: "ethereum"; | ||
wallet_client: "privy"; | ||
@@ -357,4 +247,4 @@ wallet_client_type: "privy"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -364,4 +254,4 @@ type: "discord_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -372,4 +262,4 @@ type: "github_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -382,4 +272,4 @@ type: "apple_oauth"; | ||
type: "custom_auth"; | ||
verified_at: number; | ||
custom_user_id: string; | ||
verified_at: number; | ||
})[]; | ||
@@ -401,4 +291,4 @@ }>; | ||
address: string; | ||
verified_at: number; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
wallet_client: "unknown"; | ||
@@ -411,5 +301,5 @@ chain_id?: string | undefined; | ||
address: string; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
chain_id: "eip155:1"; | ||
chain_type: "ethereum"; | ||
wallet_client: "privy"; | ||
@@ -429,4 +319,4 @@ wallet_client_type: "privy"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -436,4 +326,4 @@ type: "discord_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -444,4 +334,4 @@ type: "github_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -454,8 +344,7 @@ type: "apple_oauth"; | ||
type: "custom_auth"; | ||
verified_at: number; | ||
custom_user_id: string; | ||
verified_at: number; | ||
})[]; | ||
}>; | ||
} | ||
declare class Phone { | ||
@@ -499,4 +388,4 @@ #private; | ||
address: string; | ||
verified_at: number; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
wallet_client: "unknown"; | ||
@@ -509,5 +398,5 @@ chain_id?: string | undefined; | ||
address: string; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
chain_id: "eip155:1"; | ||
chain_type: "ethereum"; | ||
wallet_client: "privy"; | ||
@@ -527,4 +416,4 @@ wallet_client_type: "privy"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -534,4 +423,4 @@ type: "discord_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -542,4 +431,4 @@ type: "github_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -552,4 +441,4 @@ type: "apple_oauth"; | ||
type: "custom_auth"; | ||
verified_at: number; | ||
custom_user_id: string; | ||
verified_at: number; | ||
})[]; | ||
@@ -571,4 +460,4 @@ }>; | ||
address: string; | ||
verified_at: number; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
wallet_client: "unknown"; | ||
@@ -581,5 +470,5 @@ chain_id?: string | undefined; | ||
address: string; | ||
chain_type: "ethereum"; | ||
verified_at: number; | ||
chain_id: "eip155:1"; | ||
chain_type: "ethereum"; | ||
wallet_client: "privy"; | ||
@@ -599,4 +488,4 @@ wallet_client_type: "privy"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -606,4 +495,4 @@ type: "discord_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -614,4 +503,4 @@ type: "github_oauth"; | ||
subject: string; | ||
verified_at: number; | ||
username: string | null; | ||
verified_at: number; | ||
} | { | ||
@@ -624,8 +513,7 @@ type: "apple_oauth"; | ||
type: "custom_auth"; | ||
verified_at: number; | ||
custom_user_id: string; | ||
verified_at: number; | ||
})[]; | ||
}>; | ||
} | ||
declare class Auth { | ||
@@ -650,3 +538,2 @@ #private; | ||
} | ||
declare class EmbeddedWallet { | ||
@@ -690,6 +577,5 @@ #private; | ||
*/ | ||
getMessageHandler(): (event: PrivyResponseEvent) => void; | ||
getMessageHandler(): (event: import("src/embedded/types").PrivyResponseEvent) => void; | ||
} | ||
declare class User { | ||
declare class _User1 { | ||
#private; | ||
@@ -701,10 +587,2 @@ /** | ||
} | ||
interface Storage { | ||
get(key: string): unknown; | ||
put(key: string, value: unknown): void; | ||
del(key: string): void; | ||
getKeys(): string[]; | ||
} | ||
/** | ||
@@ -743,4 +621,3 @@ * `PrivyOptions` to setup the `Privy` SDK | ||
} | ||
declare class LocalStorage implements Storage { | ||
export class LocalStorage implements Storage { | ||
get(key: string): any; | ||
@@ -751,4 +628,3 @@ put(key: string, val: unknown): void; | ||
} | ||
declare class InMemoryCache implements Storage { | ||
export class InMemoryCache implements Storage { | ||
_cache: { | ||
@@ -762,3 +638,4 @@ [key: string]: unknown; | ||
} | ||
export default Privy; | ||
export { AuthenticatedUser, InMemoryCache, LinkedAccount, LocalStorage, PrivyEmbeddedWalletProvider, User$1 as User, Privy as default }; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@privy-io/js-sdk-core", | ||
"version": "0.0.1", | ||
"version": "0.1.1-beta-20230925224215", | ||
"description": "Vanilla JS client for the Privy Auth API", | ||
@@ -15,2 +15,3 @@ "keywords": [ | ||
"license": "Apache-2.0", | ||
"source": "./src/index.ts", | ||
"main": "./dist/index.js", | ||
@@ -27,2 +28,10 @@ "module": "./dist/esm/index.js", | ||
}, | ||
"targets": { | ||
"main": { | ||
"isLibrary": true | ||
}, | ||
"module": { | ||
"isLibrary": true | ||
} | ||
}, | ||
"files": [ | ||
@@ -34,7 +43,6 @@ "dist/**/*", | ||
"scripts": { | ||
"build": "npx tsup --clean --minify", | ||
"generate-types": "npx tsup --dts-only", | ||
"build": "npx parcel build", | ||
"clean": "rm -rf dist", | ||
"prepublishOnly": "npm run clean && npm run build", | ||
"dev": "npx tsup --watch", | ||
"dev": "npx parcel watch", | ||
"test": "jest --testMatch \"**/test/unit/**/*.test.ts\"", | ||
@@ -50,7 +58,7 @@ "test:ci": "npm run test", | ||
"@types/text-encoding": "^0.0.37", | ||
"tsup": "^6.2.3" | ||
"parcel": "^2.9.3" | ||
}, | ||
"dependencies": { | ||
"@ethersproject/providers": "^5.7.2", | ||
"@privy-io/core-api": "*", | ||
"@privy-io/public-api": "1.0.1-beta-20230925224215", | ||
"eventemitter3": "^5.0.1", | ||
@@ -57,0 +65,0 @@ "fetch-retry": "^5.0.6", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
407307
9
4526
2
0
3
+ Added@ethersproject/abi@5.7.0(transitive)
+ Added@ethersproject/contracts@5.7.0(transitive)
+ Added@ethersproject/hdnode@5.7.0(transitive)
+ Added@ethersproject/json-wallets@5.7.0(transitive)
+ Added@ethersproject/pbkdf2@5.7.0(transitive)
+ Added@ethersproject/solidity@5.7.0(transitive)
+ Added@ethersproject/units@5.7.0(transitive)
+ Added@ethersproject/wallet@5.7.0(transitive)
+ Added@ethersproject/wordlists@5.7.0(transitive)
+ Added@privy-io/public-api@1.0.1-beta-20230925224215(transitive)
+ Addedaes-js@3.0.0(transitive)
+ Addedethers@5.7.2(transitive)
+ Addedlibphonenumber-js@1.11.15(transitive)
+ Addedscrypt-js@3.0.1(transitive)
- Removed@privy-io/core-api@*