Skip to content

Commit

Permalink
init commit for wallet services plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1995 committed Jan 16, 2024
1 parent e40fd51 commit ad0bcd3
Show file tree
Hide file tree
Showing 13 changed files with 1,506 additions and 861 deletions.
1,911 changes: 1,055 additions & 856 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion packages/base/src/core/IWeb3Auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SafeEventEmitter } from "@toruslabs/openlogin-jrpc";

import { ADAPTER_STATUS_TYPE, IProvider, UserAuthInfo, UserInfo } from "../adapter/IAdapter";
import { ADAPTER_STATUS_TYPE, IAdapter, IProvider, UserAuthInfo, UserInfo } from "../adapter/IAdapter";
import { CustomChainConfig } from "../chain/IChainInterface";
import { WALLET_ADAPTER_TYPE } from "../wallet";

Expand All @@ -10,6 +10,7 @@ export interface IWeb3Auth extends SafeEventEmitter {
status: ADAPTER_STATUS_TYPE;
cachedAdapter: string | null;
provider: IProvider | null;
walletAdapters: Record<string, IAdapter<unknown>>;
init(): Promise<void>;
/**
* Connect to a specific wallet adapter
Expand Down
2 changes: 1 addition & 1 deletion packages/no-modal/src/noModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class Web3AuthNoModal extends SafeEventEmitter implements IWeb3Auth {

public cachedAdapter: string | null = null;

protected walletAdapters: Record<string, IAdapter<unknown>> = {};
public walletAdapters: Record<string, IAdapter<unknown>> = {};

protected commonJRPCProvider: CommonJRPCProvider | null = null;

Expand Down
44 changes: 44 additions & 0 deletions packages/plugins/wallet-services-connector-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Web3Auth Wallet Services Connector Plugin

[![npm version](https://img.shields.io/npm/v/@web3auth/torus-wallet-connector-plugin?label=%22%22)](https://www.npmjs.com/package/@web3auth/torus-wallet-connector-plugin/v/latest)
[![minzip](https://img.shields.io/bundlephobia/minzip/@web3auth/torus-wallet-connector-plugin?label=%22%22)](https://bundlephobia.com/result?p=@web3auth/torus-wallet-connector-plugin@latest)

> Web3Auth is where passwordless auth meets non-custodial key infrastructure for Web3 apps and wallets. By aggregating OAuth (Google, Twitter, Discord) logins, different wallets and innovative Multi Party Computation (MPC) - Web3Auth provides a seamless login experience to every user on your application.
Web3Auth Torus Wallet Connector Plugin helps you get the functionalities of the Torus Wallet into your Web3Auth Instance. It helps you use your Web3Auth key in the Torus Wallet, making it easier for your end user to make transactions, add money into their wallet and even use it across different applications using Torus Wallet.

## 📖 Documentation

Read more about the Web3Auth Torus Wallet Connector Plugin in the [official Web3Auth Documentation](https://web3auth.io/docs/sdk/web/plugins/torus-wallet).

## 💡 Features
- Plug and Play, OAuth based Web3 Authentication Service
- Fully decentralized, non-custodial key infrastructure
- End to end Whitelabelable solution
- Threshold Cryptography based Key Reconstruction
- Multi Factor Authentication Setup & Recovery (Includes password, backup phrase, device factor editing/deletion etc)
- Support for WebAuthn & Passwordless Login
- Support for connecting to multiple wallets
- DApp Active Session Management

...and a lot more

## 🔗 Installation

```shell
npm i --save @web3auth/torus-wallet-connector-plugin
```

## 🩹 Example

Checkout the examples for your preferred blockchain and platform in our [examples repository](https://github.com/Web3Auth/examples/)

## 🌐 Demo

Checkout the [Web3Auth Demo](https://demo-app.web3auth.io/) to see how Web3Auth can be used in your application.

## 💬 Troubleshooting and Support

- Have a look at our [Community Portal](https://community.web3auth.io/) to see if anyone has any questions or issues you might be having. Feel free to reate new topics and we'll help you out as soon as possible.
- Checkout our [Troubleshooting Documentation Page](https://web3auth.io/docs/troubleshooting) to know the common issues and solutions.
- For Priority Support, please have a look at our [Pricing Page](https://web3auth.io/pricing.html) for the plan that suits your needs.
68 changes: 68 additions & 0 deletions packages/plugins/wallet-services-connector-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "@web3auth/wallet-services-connector-plugin",
"version": "7.2.1",
"description": "Wallet services connector for which can be used with Web3Auth or private key providers used inside Web3Auth",
"keywords": [
"web3Auth/wallet-services-connector-plugin",
"web3Auth",
"multichainWallet",
"blockchain",
"ethereum",
"metamask"
],
"main": "dist/walletServicesConnectorPlugin.cjs.js",
"module": "dist/walletServicesConnectorPlugin.esm.js",
"unpkg": "dist/walletServicesConnectorPlugin.umd.min.js",
"jsdelivr": "dist/walletServicesConnectorPlugin.umd.min.js",
"types": "dist/types/index.d.ts",
"author": "Torus Labs",
"homepage": "https://github.com/Web3Auth/Web3Auth/tree/master/packages/plugins/wallet-services-connector-plugin#readme",
"license": "ISC",
"scripts": {
"test": "mocha --config ../../../.mocharc.json test/**.ts",
"test-debugger": "mocha --config ../../../.mocharc.json --inspect-brk test/**.ts",
"dev": "torus-scripts start",
"build": "torus-scripts build",
"lint": "eslint --fix 'src/**/*.ts'",
"prepack": "npm run build",
"pre-commit": "lint-staged --cwd ."
},
"files": [
"dist",
"src"
],
"devDependencies": {
"@metamask/rpc-errors": "^6.1.0"
},
"dependencies": {
"@web3auth/ws-embed": "../../../../wallet-services/packages/ws-embed",
"@web3auth/base": "^7.2.1",
"@web3auth/base-plugin": "^7.2.1",
"@web3auth/no-modal": "^7.2.1",
"@web3auth/openlogin-adapter": "^7.2.1",
"loglevel": "^1.8.1"
},
"peerDependencies": {
"@babel/runtime": "^7.x"
},
"lint-staged": {
"!(*d).ts": [
"eslint --cache --fix",
"prettier --write"
]
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Web3Auth/Web3Auth.git"
},
"bugs": {
"url": "https://github.com/Web3Auth/Web3Auth/issues"
},
"engines": {
"node": ">=18.x",
"npm": ">=9.x"
}
}
62 changes: 62 additions & 0 deletions packages/plugins/wallet-services-connector-plugin/src/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { ErrorCodes, IWeb3AuthError, Web3AuthError } from "@web3auth/base";

export class WalletServicesPluginError extends Web3AuthError {
protected static messages: ErrorCodes = {
5210: "Wallet Services Plugin is not initialized",
5211: "Web3Auth is connected to unsupported adapter. Wallet services connector plugin requires web3auth connected to openlogin adapter.",
5212: "Provider is required..",
5213: "Web3Auth instance is required while initialization.",
5214: "Web3Auth is not connected.",
5215: "UserInfo is required.",
5216: "Plugin is already initialized",
5217: "Wallet services instance is not set.",
};

public constructor(code: number, message?: string) {
// takes care of stack and proto
super(code, message);

// Set name explicitly as minification can mangle class names
Object.defineProperty(this, "name", { value: "WalletServicesPluginError" });
}

public static fromCode(code: number, extraMessage = ""): IWeb3AuthError {
return new WalletServicesPluginError(code, `${WalletServicesPluginError.messages[code]}${extraMessage}`);
}

public static notInitialized(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5210, extraMessage);
}

public static unsupportedAdapter(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5211, extraMessage);
}

public static providerRequired(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5212, extraMessage);
}

public static web3authRequired(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5213, extraMessage);
}

public static web3AuthNotConnected(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5214, extraMessage);
}

public static userInfoRequired(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5215, extraMessage);
}

public static alreadyInitialized(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5216, extraMessage);
}

public static torusWalletNotSet(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5217, extraMessage);
}

public static unsupportedChainNamespace(extraMessage = ""): IWeb3AuthError {
return WalletServicesPluginError.fromCode(5218, extraMessage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./plugin";
Loading

0 comments on commit ad0bcd3

Please sign in to comment.