Skip to content

Commit 0cefe6d

Browse files
committed
feat: add README.md and LICENSE files
1 parent 92222ca commit 0cefe6d

File tree

10 files changed

+590
-405
lines changed

10 files changed

+590
-405
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ lerna-debug.log*
4141
fast-auth-.json
4242

4343
.env
44-
**/dist
44+
**/dist
45+
46+
.npmrc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Peersyst Technology
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

examples/wallet/web/src/pages/Sign.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ const Sign: React.FC = () => {
3333
await keyStore.setKey("testnet", wallet.accountId, wallet.keyPair!);
3434
const connection = await near.connect({ networkId: "testnet", nodeUrl: "https://rpc.testnet.near.org", keyStore });
3535
const account = new Account(connection.connection, wallet.accountId);
36-
37-
await account.addKey(PublicKey.fromString(publicKey!), permissions!.receiverId, permissions!.methodNames);
36+
let methodNames = permissions!.methodNames;
37+
if (methodNames.length == 1 && methodNames[0] == "*") {
38+
methodNames = undefined;
39+
}
40+
await account.addKey(PublicKey.fromString(publicKey!), permissions!.receiverId, methodNames, permissions!.allowance);
3841
window.location.assign(redirectURL!);
3942
} else {
4043
const keyStore = new near.keyStores.InMemoryKeyStore();

packages/dapp/core/README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,50 @@
1-
# @one-click-connect/dapp
1+
# @one-click-connect/dapp-core
22

33
## Overview
4+
`@one-click-connect/dapp-core` is a core library for building decentralized applications (dApps) with the One Click Connect ecosystem. It provides essential functionality for interacting with blockchain networks, managing wallet connections, and handling transactions.
45

5-
This package is the main package for the One-Click Connect DApp.
6+
## Installation
7+
```bash
8+
# Using pnpm (recommended)
9+
pnpm add @one-click-connect/dapp-core
10+
11+
# Using npm
12+
npm install @one-click-connect/dapp-core
13+
14+
# Using yarn
15+
yarn add @one-click-connect/dapp-core
16+
```
17+
18+
## Features
19+
- Simplified blockchain interactions
20+
- Wallet connection management
21+
- Transaction handling
22+
- Integration with the One Click Connect ecosystem
23+
24+
## Usage
25+
```typescript
26+
import { createDappCore } from '@one-click-connect/dapp-core';
27+
28+
// Initialize the core functionality
29+
const dappClient = new BrowserDAppClient(
30+
// Configuration options
31+
);
32+
33+
// Connect to wallet
34+
await dappClient.connect();
35+
36+
// Perform transactions
37+
// ...
38+
```
39+
40+
## API Reference
41+
Please refer to the typings and documentation within the code for a complete API reference.
42+
43+
## Related Packages
44+
- `@one-click-connect/dapp-sdk`: Extended SDK for dApp development
45+
- `@one-click-connect/core`: Core functionality for the One Click Connect ecosystem
46+
- `@one-click-connect/sdk`: Main SDK for the One Click Connect platform
47+
- `@one-click-connect/wallet`: Wallet integration for One Click Connect
48+
49+
## License
50+
[MIT License](../../../LICENSE)

packages/dapp/sdk/README.md

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,97 @@
1-
# @one-click-connect/dapp
1+
# @one-click-connect/dapp-sdk
22

33
## Overview
44

5-
This package is the main package for the One-Click Connect DApp.
5+
The `@one-click-connect/dapp-sdk` package provides an extended SDK for decentralized application (dApp) development in the One-Click Connect ecosystem. It builds on top of the core functionality to offer specialized tools and utilities for building NEAR-based decentralized applications with a simplified, user-friendly approach.
6+
7+
## Installation
8+
9+
```shell script
10+
# Using npm
11+
npm install @one-click-connect/dapp-sdk
12+
13+
# Using yarn
14+
yarn add @one-click-connect/dapp-sdk
15+
16+
# Using pnpm
17+
pnpm add @one-click-connect/dapp-sdk
18+
```
19+
20+
Note: This package has `near-api-js` as a peer dependency, so make sure it's installed in your project.
21+
22+
## Features
23+
24+
- **NEAR Protocol Integration**: Seamless integration with the NEAR blockchain
25+
- **Transaction Management**: Simplified API for creating, signing, and sending transactions
26+
- **Permissions Handling**: Management of user permissions for dApp interactions
27+
- **Browser Compatibility**: Designed specifically for browser-based applications
28+
- **TypeScript Support**: Full TypeScript definitions for improved developer experience
29+
30+
## Usage
31+
32+
```typescript
33+
import { DAppClient } from '@one-click-connect/dapp-sdk';
34+
import { Near } from 'near-api-js';
35+
import { BrowserLocalStorageKeyStore } from 'near-api-js/lib/key_stores';
36+
import { Permissions } from '@one-click-connect/core';
37+
38+
// Initialize dependencies
39+
const keyStore = new BrowserLocalStorageKeyStore();
40+
const near = new Near({
41+
keyStore,
42+
networkId: 'testnet',
43+
nodeUrl: 'https://rpc.testnet.near.org'
44+
});
45+
46+
// Create DApp client
47+
const client = new DAppClient(
48+
{
49+
appName: 'My NEAR dApp',
50+
contractId: 'mycontract.testnet'
51+
},
52+
near,
53+
keyStore,
54+
permissions
55+
);
56+
57+
// Use the client to interact with the NEAR blockchain
58+
async function sendTransaction() {
59+
const result = await client.sendTransaction({
60+
receiverId: 'recipient.testnet',
61+
actions: [/* your actions here */]
62+
});
63+
64+
console.log('Transaction result:', result);
65+
}
66+
```
67+
68+
## API Reference
69+
70+
### `DAppClient`
71+
72+
The main client class for dApp interactions.
73+
74+
#### Constructor
75+
76+
```typescript
77+
constructor(
78+
config: BaseDAppClientConfig,
79+
near: Near,
80+
keyStore: KeyStore,
81+
permissions: Permissions
82+
)
83+
```
84+
85+
### `NearProvider`
86+
87+
A provider implementation for NEAR blockchain interactions.
88+
89+
## Related Packages
90+
91+
- `@one-click-connect/core`: Core functionality for the One-Click Connect ecosystem
92+
- `@one-click-connect/sdk`: Base SDK for One-Click Connect
93+
- `@one-click-connect/dapp-core`: Core dApp functionality
94+
- `@one-click-connect/wallet`: Wallet implementation for One-Click Connect
95+
96+
## License
97+
[MIT License](../../../LICENSE)
Lines changed: 56 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,88 @@
1-
Wallet Selector One Click Connect is a package that allows apps to bypass the NEAR wallet selector modal and instantly sign users with the click of a button.
1+
# One Click Connect Wallet Selector
22

3-
# Table of Contents
3+
## Overview
44

5-
- [Table of Contents](#table-of-contents)
6-
- [One Click Connect Experiences](#keypom-oneclick-connect-experiences)
7-
- [Installation](#installation)
8-
- [Getting Started](#getting-started)
9-
- [setupOneClickConnect Parameters](#setuponeclickconnect-parameters)
10-
- [How do I trigger OneClick Connect?](#how-do-i-trigger-oneclick-connect)
11-
- [Connection Parameters](#connection-parameters)
12-
- [Optional Secret Key](#optional-secret-key)
13-
- [Example Flow with Secret Key](#example-flow-with-secret-key)
14-
- [Example Flow without Secret Key](#example-flow-without-secret-key)
15-
- [Example Usage](#example-usage)
5+
The One Click Connect Wallet Selector is a package that integrates with the NEAR wallet selector ecosystem, allowing applications to bypass the traditional NEAR wallet selector modal and enabling users to sign in with a single click. This package significantly reduces friction in the user authentication flow, making the dApp experience more seamless and efficient.
166

17-
---
7+
## Installation
188

19-
# One Click Connect Experiences
20-
21-
OneClick Connect is a great way to reduce friction for users signing into applications. Currently, the sign in flow for a new user is as follows:
22-
23-
1. User creates an account.
24-
2. They navigate to an application.
25-
3. Sign-in is clicked.
26-
4. The wallet selector modal is opened and the user needs to scroll to find their wallet.
27-
5. The user clicks their wallet and is redirected to the wallet's website to approve a transaction.
28-
6. The user is redirected back to the app and is signed in.
29-
30-
As NEAR pushes to abstract crypto complexities away from the end user, this approach is not scalable. Not only are there a lot of clicks and redirects, leading to a loss in user retention, but people must also know which wallet they own. This is a big problem for apps like Sweatcoin, where the wallet logic is hidden from the user.
31-
32-
The flow that OneClick Connect offers is as follows:
33-
34-
1. User creates an account.
35-
2. User clicks a button from inside a wallet application.
36-
3. User is instantly signed in and can start using the dApp.
37-
38-
This flow is much more seamless and removes all the redirects and wallet selector modal friction.
39-
40-
# Installation
41-
42-
To install the plugin, run the following command:
43-
44-
```bash
9+
```shell script
4510
npm install @one-click-connect/wallet-selector
4611
# or
4712
yarn add @one-click-connect/wallet-selector
4813
# or
4914
pnpm add @one-click-connect/wallet-selector
5015
```
5116

52-
# Getting Started
17+
## Features
18+
19+
- **Streamlined Authentication Flow**: Eliminates multiple redirects and clicks normally required in the NEAR wallet authentication process.
20+
- **NEAR Wallet Selector Integration**: Fully compatible with the official NEAR wallet selector, easily integrating alongside other wallet modules.
21+
- **Customizable Configuration**: Configure network settings, contract IDs, and allowed methods to suit your application's needs.
22+
- **Enhanced User Experience**: Ideal for applications that want to abstract away crypto complexities from end users.
23+
- **Direct Sign-in**: Enables users to connect directly from a wallet application to your dApp without intermediary steps.
5324

54-
Apps on NEAR should be compatible with the official [wallet selector](https://github.com/near/wallet-selector) plugin to enable signing and sending transactions. Like Mintbase Wallet, MyNEARWallet, Meteor Wallet etc, One Click Connect is a simple module for the wallet selector. This means that all you need to do is install the plugin and add its setup function to the wallet selector exactly as you would do with any other wallet.
25+
## Usage
5526

56-
To get started, navigate to the app's `setupWalletSelector` code where the selector is initialized. Here, you can specify which wallet modules your app should support. Simply import and add OneClick Connect's `setupOneClickConnect` function to the list of modules and you're good to go!
27+
The One Click Connect wallet selector can be easily integrated into your existing NEAR wallet selector setup:
5728

58-
```js
29+
```javascript
30+
import { setupWalletSelector } from '@near-wallet-selector/core';
5931
import { setupOneClickConnect } from '@one-click-connect/wallet-selector';
6032

6133
const selector = await setupWalletSelector({
62-
network: "testnet",
63-
modules: [
64-
setupMyNearWallet(),
65-
...,
66-
setupSender(),
67-
// Add the OneClick Connect function here
68-
setupOneClickConnect({
69-
networkId: "testnet",
70-
contractId: "guestbook.near-examples.testnet",
71-
methods: ["add_message"], // Optional, defaults to any methods ["*"]
72-
allowance: "250000000000000000000000" // Optional, access key allowance in Yocto, defaults to 1 NEAR
73-
})
74-
],
34+
network: "testnet",
35+
modules: [
36+
// Other wallet modules
37+
...,
38+
// Add the OneClick Connect module
39+
setupOneClickConnect({
40+
networkId: "testnet",
41+
contractId: "your-contract.near",
42+
methods: ["method_1", "method_2"] // Optional
43+
})
44+
]
7545
});
7646
```
7747

78-
## setupOneClickConnect Parameters
48+
### Traditional vs. One Click Connect Flow
7949

80-
- `networkId`: Either `testnet` or `mainnet`.
81-
- `contractId`: Specifies the contract that the limited access key is capable of calling.
82-
- `methods` (*Optional*): This controls what methods any limited access keys added will be able to call. Defaults to all methods.
83-
- `allowance` (*Optional*): Outlines the allowance for any limited access keys added. This defaults to 1 NEAR.
50+
**Traditional Flow:**
51+
1. User creates an account
52+
2. User navigates to the application
53+
3. User clicks sign-in
54+
4. The wallet selector modal opens
55+
5. User selects their wallet
56+
6. User is redirected to the wallet website to approve
57+
7. User is redirected back to the app
8458

85-
## How do I trigger OneClick Connect?
59+
**One Click Connect Flow:**
60+
1. User creates an account
61+
2. User clicks a button directly from the wallet application
62+
3. User is instantly signed in and ready to use the dApp
8663

87-
The OneClick Connect experience will trigger on any page that matches the following URL pattern:
88-
89-
```
90-
"http://app.example.com/?connection=tbin329...adwe0vjer"
91-
```
92-
93-
The string following `?connection=` is a base64 encoded stringified JSON containing connection information. This JSON can be seen below:
94-
95-
### Connection Parameters
96-
```ts
97-
connection = {
98-
accountId: string,
99-
walletId: string,
100-
walletTransactionUrl: string | undefined,
101-
chainId: string | undefined,
102-
secretKey: string | undefined,
103-
};
104-
```
64+
## API Reference
10565

106-
- `accountId`: The account being signed into the destination dApp.
107-
- `walletId`: ID of the wallet being used. For example, `sweat-wallet`.
108-
- `walletTransactionUrl`: This is the URL for a wallet signing transactions.
109-
- `chainId`: Destination chain for the sign in, defaults to NEAR.
110-
- `secretKey`: The secret key for signing transactions on the destination dApp. If undefined, OneClick will try to add it along with the first transaction the user signs.
66+
### setupOneClickConnect(options)
11167

112-
Any malformed string following `?connection=` that cannot be base64 decoded and JSON stringified will lead to a failed login.
113-
114-
### Optional Secret Key
115-
In the development of OneClick, it became apparent that exposing a secret key in the URL could pose a security concern in certain scenarios. For example, if the limited access key was meant to cast a vote in a DAO, then it would be imparative that the key is not exposed in order to ensure the integrity of the vote. This led to the creation of two flows, depending on your security needs.
68+
The main setup function that configures the One Click Connect module for the NEAR wallet selector.
11669

117-
#### Example Flow with Secret Key
118-
The first approach is the less secure method, directly exposing the secret key in the URL. The compromise in security grants you a smoother user experience. The flow is as follows:
70+
#### Parameters
11971

120-
1. dApp A, that the user is signed into with the full access key, creates a new limited access key for the user in the background
121-
2. This new key is placed into the connection object in the URL
122-
3. User clicks on the URL, signing them into dApp B. From here, they can instantly start signing transactions on dApp B, using the previously generated secret key, without ever needing to open their wallet.
72+
- **options** (object):
73+
- `networkId` (string): The NEAR network ID ("mainnet", "testnet", etc.)
74+
- `contractId` (string): The contract ID your application interacts with
75+
- `methods` (string[]): Optional array of contract methods to allow
12376

124-
#### Example Flow without Secret Key
125-
The second approach is more secure but includes an extra step. Rather than dApp A creating a limited access key before redirecting, this occurs when the user attempts to sign the first transaction on dApp B:
77+
#### Returns
12678

127-
1. dApp A, that the user is signed into with the full access key, creates a OneClick URL without any secret key in the connection object
128-
2. User clicks on URL, signing them into dApp B
129-
3. When the user tries to sign a transaction on dApp B, it redirects them back to their wallet to both sign the transaction and add a limited access key for dApp B.
130-
4. Once the user signs this, and the dApp B limited access key is added, they can now proceed to sign further transactions on dApp B without needing to open their wallet.
79+
A configured wallet selector module that can be used in the NEAR wallet selector setup.
13180

81+
## Related Packages
13282

133-
#### Example Usage
134-
Apps can utilize OneClick Connect on any page by ensuring the URL contains the `?connection=` parameter. For instance:
135-
- Any navigation to a URL like `"http://app.example.com/?connection=tbin329...adwe0vjer"` will automatically trigger the sign-in process using the provided connection object.
83+
- **@one-click-connect/core**: Core functionality for the One Click Connect ecosystem
84+
- **@one-click-connect/dapp-sdk**: SDK for dApp integration with One Click Connect
85+
- **@near-wallet-selector/core**: The official NEAR wallet selector that this package integrates with
13686

137-
Similarly, this would also trigger on `"http://app.example.com/nestedPage/gallery?connection=tbin329...adwe0vjer"`
87+
## License
88+
[MIT License](../../../LICENSE)

0 commit comments

Comments
 (0)