Skip to content

Commit

Permalink
Fix lit-agent-signer being a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
spacesailor24 committed Dec 21, 2024
1 parent 37f7d36 commit d3b1d0e
Show file tree
Hide file tree
Showing 23 changed files with 1,368 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/lit-agent-signer
Submodule lit-agent-signer deleted from 07ddd9
1 change: 1 addition & 0 deletions packages/lit-agent-signer/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LIT_AUTH_PRIVATE_KEY=
31 changes: 31 additions & 0 deletions packages/lit-agent-signer/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint

- name: Run tests
run: npm test
env:
LIT_AUTH_PRIVATE_KEY: ${{ secrets.LIT_AUTH_PRIVATE_KEY }}
27 changes: 27 additions & 0 deletions packages/lit-agent-signer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dependencies
node_modules/

# Build output
dist/

# IDE files
.idea/
.vscode/
*.sublime-*

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Environment variables
.env
.env.local
.env.*.local

# OS files
.DS_Store
Thumbs.db

lit-session-storage
48 changes: 48 additions & 0 deletions packages/lit-agent-signer/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Dependencies
node_modules
.pnp
.pnp.js

# Build outputs
dist
build
coverage
lib
.next
out

# Cache and logs
.cache
.npm
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Environment and config files
.env*
.env.local
.env.development.local
.env.test.local
.env.production.local

# Editor directories and files
.idea
.vscode
*.swp
*.swo

# System files
.DS_Store
Thumbs.db

# Package files
package-lock.json
yarn.lock
pnpm-lock.yaml

# Generated files
*.min.js
*.map

lit-session-storage
21 changes: 21 additions & 0 deletions packages/lit-agent-signer/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"singleAttributePerLine": false,
"bracketSameLine": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}
7 changes: 7 additions & 0 deletions packages/lit-agent-signer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 WorkGraph, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
119 changes: 119 additions & 0 deletions packages/lit-agent-signer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Lit Serverside Signer SDK

A lightweight SDK for signing transactions and messages with Lit Protocol. This SDK simplifies the process of creating wallets and signing transactions using Lit's Programmable Key Pairs (PKPs).

This SDK is a wrapper around our [full-featured SDK](https://github.com/lit-protocol/js-sdk) which also supports client-side functionality, decryption, and more.
functionality, decryption, and more.

## Features

- 🔑 Easy wallet creation and management
- ✍️ Transaction and message signing
- 🔒 Secure key management via [Lit Protocol](https://litprotocol.com)
- 🚀 Simple, serverside-focused API
- ⚡ Lightweight and efficient

## Installation

```bash
npm install @lit-protocol/lit-agent-signer
# or
yarn add @lit-protocol/lit-agent-signer
```

## Quick Start

```typescript
import { LitClient } from '@lit-protocol/lit-agent-signer';

// Initialize the client with your Lit auth key
const client = await LitClient.create(process.env.LIT_AUTH_PRIVATE_KEY);

// Create a new wallet
const { pkp } = await client.createWallet();
console.log('Wallet created:', pkp);

// Sign a transaction or message
const signedMessage = await client.sign({
toSign: '0x8111e78458fec7fb123fdfe3c559a1f7ae33bf21bf81d1bad589e9422c648cbd',
});
console.log('Message signed:', signedMessage);
```

## Usage Guide

### Initialization

First, initialize the client with your Lit authentication key:

```typescript
const client = await LitClient.create(authKey);
```

### Wallet Management

Create a new wallet:

```typescript
const { pkp } = await client.createWallet();
```

Get existing wallet:

```typescript
const pkp = client.getPkp();
```

### Signing

Sign a message or transaction:

```typescript
const signedMessage = await client.sign({
toSign: '0x8111e78458fec7fb123fdfe3c559a1f7ae33bf21bf81d1bad589e9422c648cbd',
});
```

### Execute JavaScript Code

You can also execute JavaScript code using Lit Protocol:

```typescript
const result = await client.executeJs({
code: `
Lit.Actions.setResponse({ response: message + " - processed by Lit Protocol" });
`,
jsParams: {
message: 'Hello',
},
});
```

### Cleanup

When you're done, disconnect the client:

```typescript
await client.disconnect();
```

## Environment Variables

Make sure to set up the following environment variable:

- `LIT_AUTH_PRIVATE_KEY`: Your Lit Protocol authentication key

## Examples

Check out the `examples` directory for more detailed examples:

- `basic-usage.ts`: Complete example showing all main features
- `minimal-signing.ts`: Minimal example focused on transaction signing

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

MIT License
63 changes: 63 additions & 0 deletions packages/lit-agent-signer/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['**/dist/', '**/node_modules/', '**/*.js', '**/*.jsx'],
},
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking'
),
{
plugins: {
'@typescript-eslint': typescriptEslint,
},

languageOptions: {
globals: {
...globals.node,
...globals.jest,
},

parser: tsParser,
ecmaVersion: 2020,
sourceType: 'module',

parserOptions: {
project: ['./tsconfig.json'],
},
},

rules: {
'@typescript-eslint/no-explicit-any': 'warn',

'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],

'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
},
},
];
Loading

0 comments on commit d3b1d0e

Please sign in to comment.