Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EPIC] Auth #527

Merged
merged 65 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2e431a2
move auth methods to taco-auth
piotr-roslaniec May 8, 2024
b14af6a
rewrite eip712 auth
piotr-roslaniec May 8, 2024
5f63ef3
chore: fix build errors
piotr-roslaniec Jun 4, 2024
824b2c3
add a sketch of siwe provider
piotr-roslaniec May 15, 2024
6dd66de
Change function name
manumonti May 23, 2024
c15a29c
Expose createSIWEMessage parameters
manumonti May 24, 2024
eb7cdf3
Use EIP-4361 as Signature Provider
manumonti May 24, 2024
d487be3
Add EIP-712 test
manumonti May 27, 2024
563d410
Add scheme field to EIP712 message
manumonti May 27, 2024
7568d6b
Generalize TypedSignature interface
manumonti May 27, 2024
8eadb44
Use TypedSignature format as return of SiweMessage
manumonti May 27, 2024
87eecba
Add tests for SIWE message creation
manumonti May 27, 2024
450529c
Add EIP761 and SIWE as context options and tests
manumonti May 28, 2024
fde1cd0
Replace didtools dependency with a depdency on siwe.
derekpierre May 30, 2024
842527d
Change scheme from "SIWE" to "EIP4361".
derekpierre May 30, 2024
afff97c
Fix bug when determining whether condition requires signer or not; ca…
derekpierre May 30, 2024
13b4c70
Run linter.
derekpierre May 30, 2024
9788b7a
Update userAddressSchema to accomodate additional userAddress auth-sp…
derekpierre May 30, 2024
e172c29
typedData entry for EIP4361 should be a string.
derekpierre May 31, 2024
d402653
Fix fake provider chain id to be a positive number. Negative numbers …
derekpierre May 31, 2024
812852e
Fix/improve tests for taco-auth/context.
derekpierre May 31, 2024
6b7038e
chore(linter): fix linter
piotr-roslaniec May 31, 2024
ef59520
Change getOrCreateSiweMessage to getOrCreateWalletSignature for EIP43…
derekpierre May 31, 2024
6af5ccf
set domain and uri in eip4361 dynamically
piotr-roslaniec May 31, 2024
bd26f6c
Update statement to include a mention of "TACo".
derekpierre May 31, 2024
97592fa
fix siwe tests
piotr-roslaniec Jun 4, 2024
14968cb
deduplicate test methods
piotr-roslaniec Jun 4, 2024
6594081
refactor(auth-provider): first pass at refactoring taco-auth to suppo…
piotr-roslaniec Jun 13, 2024
1e584ce
refactor(auth-provider): introduce generic auth provider
piotr-roslaniec Jun 13, 2024
4301729
refactor: clean up naming and todos
piotr-roslaniec Jun 13, 2024
2fd1c0c
test(conditions): document context behavior
piotr-roslaniec Jun 14, 2024
be852e2
refactor!(context): remove unused context method
piotr-roslaniec Jun 14, 2024
9d40acd
refactor!(context): remove unused provider parameter
piotr-roslaniec Jun 14, 2024
3dcc965
refactor!(context): refactor validation and rename public methods
piotr-roslaniec Jun 14, 2024
f6cea3a
apply pr comments
piotr-roslaniec Jun 19, 2024
220f95e
feat(cond): expose requested params in user facing api
piotr-roslaniec Jun 20, 2024
0d34270
feat!(cond): remove auth checking from cond expr
piotr-roslaniec Jun 24, 2024
e0fb8ad
refactor: rename methods for consistency
piotr-roslaniec Jun 24, 2024
6b22c97
feat(eip4361): allow for reusing siwe messages
piotr-roslaniec Jun 12, 2024
93ecc21
refactor: don't reuse eip4361 alias
piotr-roslaniec Jun 24, 2024
28f05dd
chore: document external eip4361 behavior
piotr-roslaniec Jun 24, 2024
deb06cb
apply pr suggestions
piotr-roslaniec Jun 25, 2024
27c0b0d
feat(auth): set defaults for eip4361 providers
piotr-roslaniec Jun 25, 2024
06a166e
chore: update lockfile
piotr-roslaniec Jul 2, 2024
7b1857b
feat!(cond): deprecate eip712 auth provider
piotr-roslaniec Jun 21, 2024
7c3b23e
feat(auth): validate user-provided auth signature
piotr-roslaniec Jun 28, 2024
ef47a09
apply pr suggestions
piotr-roslaniec Jul 3, 2024
4a3cfec
chore: fix duplicated vitest dependency
piotr-roslaniec Jul 3, 2024
8508e3d
validate eip4361 siwe message
piotr-roslaniec Jul 3, 2024
e887a64
feat(taco): expose auth providers from taco
piotr-roslaniec Jun 25, 2024
b1d0b8c
feat!(auth): expose eip4361 auth provider in taco api
piotr-roslaniec Jul 9, 2024
b52ad1a
apply pr suggestions
piotr-roslaniec Jul 10, 2024
ea19c5d
fix test not cathing edge cases
piotr-roslaniec Jul 10, 2024
895ed91
feat!(auth): remove eip712
piotr-roslaniec Jul 9, 2024
3553dac
Add a sketch for reusing SIWE message
manumonti Jul 11, 2024
e65ae29
Use constant for EIP4361 auth scheme instead of string.
derekpierre Jul 12, 2024
61c41d9
Allow :userAddressExternalEIP4361 context variable wherever :userAddr…
derekpierre Jul 12, 2024
831615b
Add single sign-on EIP4361 auth provider for constructing auth signat…
derekpierre Jul 12, 2024
8b66ad2
Run 'pnpm fix' to address linting issues.
derekpierre Jul 12, 2024
0df9017
Export single sign-on provider as part of @nucypher/taco for now unti…
derekpierre Jul 23, 2024
1a5ddf9
Fix pnpm lock file post rebase.
derekpierre Jul 26, 2024
c6cb58a
Fix linting errors post rebase.
derekpierre Jul 26, 2024
f50dd40
chore(release): release @nucypher/shared:0.3.0.
derekpierre Jul 26, 2024
2c017b7
chore(release): release @nucypher/taco-auth:0.1.0
derekpierre Jul 26, 2024
8cb3e9e
chose(release): release @nucypher/taco:0.4.0
derekpierre Jul 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [
[
"@nucypher/shared",
"@nucypher/taco"
]
],
"fixed": [["@nucypher/shared", "@nucypher/taco"]],
"linked": [],
"access": "public",
"baseBranch": "main",
Expand Down
37 changes: 17 additions & 20 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,51 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
'root': true,
'parser': '@typescript-eslint/parser',
'env': {
'es6': true,
root: true,
parser: '@typescript-eslint/parser',
env: {
es6: true,
},
'ignorePatterns': [
ignorePatterns: [
'node_modules',
'build',
'coverage',
'src/contracts/ethers-typechain',
],
'plugins': [
'import',
'eslint-comments',
],
'extends': [
plugins: ['import', 'eslint-comments'],
extends: [
'eslint:recommended',
'plugin:eslint-comments/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'prettier',
],
'globals': {
'BigInt': true,
'console': true,
'WebAssembly': true,
globals: {
BigInt: true,
console: true,
WebAssembly: true,
},
'rules': {
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'eslint-comments/disable-enable-pair': [
'error',
{
'allowWholeFile': true,
allowWholeFile: true,
},
],
'import/order': [
'error',
{
'newlines-between': 'always',
'alphabetize': {
'order': 'asc',
alphabetize: {
order: 'asc',
},
},
],
'sort-imports': [
'error',
{
'ignoreDeclarationSort': true,
'ignoreCase': true,
ignoreDeclarationSort: true,
ignoreCase: true,
},
],
},
Expand Down
18 changes: 11 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,23 @@

- [ ] 1
- [ ] 2
- [X] 3
- [x] 3

**What this does:**
> High-level idea of the changes introduced in this PR.
> List relevant API changes (if any), as well as related PRs and issues.

> High-level idea of the changes introduced in this PR. List relevant API
> changes (if any), as well as related PRs and issues.

**Issues fixed/closed:**

> - Fixes #...

**Why it's needed:**
> Explain how this PR fits in the greater context of the NuCypher Network.
> E.g., if this PR address a `nucypher/productdev` issue, let reviewers know!

> Explain how this PR fits in the greater context of the NuCypher Network. E.g.,
> if this PR address a `nucypher/productdev` issue, let reviewers know!

**Notes for reviewers:**
> What should reviewers focus on?
> Is there a particular commit/function/section of your PR that requires more attention from reviewers?

> What should reviewers focus on? Is there a particular commit/function/section
> of your PR that requires more attention from reviewers?
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: "monthly"
interval: 'monthly'
open-pull-requests-limit: 5
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "monthly"
interval: 'monthly'
open-pull-requests-limit: 5
17 changes: 9 additions & 8 deletions .github/workflows/lynx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ name: '🔎 Lynx Testnet Example'

on:
schedule:
- cron: "0 * * * *" # Every hour
- cron: '0 * * * *' # Every hour
pull_request:
workflow_dispatch:

# TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
env:
RPC_PROVIDER_URL: "https://rpc-amoy.polygon.technology"
ENCRYPTOR_PRIVATE_KEY: "0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86"
CONSUMER_PRIVATE_KEY: "0xf307e165339cb5deb2b8ec59c31a5c0a957b8e8453ce7fe8a19d9a4c8acf36d4"
RITUAL_ID: "0"
RPC_PROVIDER_URL: 'https://rpc-amoy.polygon.technology'
ENCRYPTOR_PRIVATE_KEY: '0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86'
CONSUMER_PRIVATE_KEY: '0xf307e165339cb5deb2b8ec59c31a5c0a957b8e8453ce7fe8a19d9a4c8acf36d4'
RITUAL_ID: '0'

jobs:
networks:
name: '🔎 Lynx Testnet Example on Node ${{ matrix.node }} and ${{ matrix.os }}'
name:
'🔎 Lynx Testnet Example on Node ${{ matrix.node }} and ${{ matrix.os }}'

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '18.x' ]
os: [ ubuntu-latest ]
node: ['18.x']
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI
on: [ push, pull_request ]
on: [push, pull_request]

concurrency: ${{ github.workflow }}-${{ github.ref }}

Expand All @@ -9,8 +9,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '18.x', '20.x', '22.x' ]
os: [ ubuntu-latest ]
node: ['18.x', '20.x', '22.x']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -41,7 +41,6 @@ jobs:
with:
# https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954/21
fail_ci_if_error: false

# TODO: Fix or replace bundlemon on CI
# - name: Analyze bundle size
# uses: lironer/bundlemon-action@v1
10 changes: 5 additions & 5 deletions .github/workflows/mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: '🔎 Mainnet Example'

on:
schedule:
- cron: "0 * * * *" # Every hour
- cron: '0 * * * *' # Every hour
workflow_dispatch:

# TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
env:
RPC_PROVIDER_URL: "https://polygon.llamarpc.com"
RPC_PROVIDER_URL: 'https://polygon.llamarpc.com'
ENCRYPTOR_PRIVATE_KEY: ${{ secrets.MAINNET_ENCRYPTOR_PRIVATE_KEY }}
CONSUMER_PRIVATE_KEY: ${{ secrets.MAINNET_CONSUMER_PRIVATE_KEY }}
RITUAL_ID: "9"
RITUAL_ID: '9'

jobs:
networks:
Expand All @@ -19,8 +19,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '18.x' ]
os: [ ubuntu-latest ]
node: ['18.x']
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: 'Test npmjs.com package'

on:
schedule:
- cron: "0 * * * *" # Every hour
- cron: '0 * * * *' # Every hour
workflow_dispatch:

jobs:
npm:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '18.x' ]
version: [ 'latest', 'mainnet', 'devnet', 'testnet' ]
node: ['18.x']
version: ['latest', 'mainnet', 'devnet', 'testnet']

steps:
- uses: pnpm/action-setup@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Release
on:
push:
branches:
- "main"
- 'main'

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
publish:
name: Publish NPM package using changesets
runs-on: "ubuntu-latest"
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/tapir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ name: '🔎 Tapir Testnet Example'

on:
schedule:
- cron: "0 * * * *" # Every hour
- cron: '0 * * * *' # Every hour
pull_request:
branches:
- main
workflow_dispatch:

# TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
env:
RPC_PROVIDER_URL: "https://rpc-amoy.polygon.technology"
ENCRYPTOR_PRIVATE_KEY: "0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86"
CONSUMER_PRIVATE_KEY: "0xf307e165339cb5deb2b8ec59c31a5c0a957b8e8453ce7fe8a19d9a4c8acf36d4"
RITUAL_ID: "0"
RPC_PROVIDER_URL: 'https://rpc-amoy.polygon.technology'
ENCRYPTOR_PRIVATE_KEY: '0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86'
CONSUMER_PRIVATE_KEY: '0xf307e165339cb5deb2b8ec59c31a5c0a957b8e8453ce7fe8a19d9a4c8acf36d4'
RITUAL_ID: '0'

jobs:
networks:
name: '🔎 Tapir Testnet Example on Node ${{ matrix.node }} and ${{ matrix.os }}'
name:
'🔎 Tapir Testnet Example on Node ${{ matrix.node }} and ${{ matrix.os }}'

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '18.x' ]
os: [ ubuntu-latest ]
node: ['18.x']
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 4 additions & 2 deletions demos/taco-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export default function App() {
setDecryptedMessage('');
setDecryptionErrors([]);

const encryptedMessageHex = await downloadData(encryptedMessageId) as string;
const encryptedMessageHex = (await downloadData(
encryptedMessageId,
)) as string;
const encryptedMessage = ThresholdMessageKit.fromBytes(
Buffer.from(encryptedMessageHex, 'hex'),
);
Expand Down Expand Up @@ -119,7 +121,7 @@ export default function App() {
<h2>Notice</h2>
<p>
In production (mainnet domain), your wallet address (encryptor) will also have
to be allow-listed for this specific ritual. However, we have
to be allow-listed for this specific ritual. However, we have
<a href={'https://docs.threshold.network/app-development/threshold-access-control-tac/integration-guide/get-started-with-tac#testnet-configuration'}>publicly available testnet rituals</a>
for use when developing your apps.
</p>
Expand Down
3 changes: 1 addition & 2 deletions demos/taco-nft-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { useEthers } from '@usedapp/core';
import { ethers } from 'ethers';
import React, { useEffect, useState } from 'react';

import { DEFAULT_DOMAIN, DEFAULT_RITUAL_ID } from './config';
import { Decrypt } from './Decrypt';
import { Encrypt } from './Encrypt';
import { NFTConditionBuilder } from './NFTConditionBuilder';
import { Spinner } from './Spinner';
import { DEFAULT_DOMAIN, DEFAULT_RITUAL_ID } from './config';

const chainIdForDomain = {
[domains.DEVNET]: 80002,
Expand Down Expand Up @@ -43,7 +43,6 @@ export default function App() {
switchNetwork(chainId);
}, [chainId]);


const encryptMessage = async (message: string) => {
if (!condition) {
return;
Expand Down
6 changes: 3 additions & 3 deletions demos/taco-nft-demo/src/NFTConditionBuilder.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { conditions } from '@nucypher/taco';
import { Sepolia, useEthers} from '@usedapp/core';
import { Sepolia, useEthers } from '@usedapp/core';
import React, { useState } from 'react';

interface Props {
Expand Down Expand Up @@ -97,8 +97,8 @@ export const NFTConditionBuilder = ({
<div>
<p>
You can mint an NFT{' '}
<a href="https://nfts2me.com/create/generative/">here</a> or use your own
contract.
<a href="https://nfts2me.com/create/generative/">here</a> or use
your own contract.
</p>
</div>
<div>
Expand Down
8 changes: 4 additions & 4 deletions demos/taco-nft-demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"noEmit": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true
"skipLibCheck": true,
},
"references": [
{
"path": "../../packages/taco/tsconfig.es.json"
}
]
"path": "../../packages/taco/tsconfig.es.json",
},
],
}
4 changes: 2 additions & 2 deletions demos/taco-nft-demo/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ module.exports = {
DEFAULT_RITUAL_ID: JSON.stringify(process.env.DEFAULT_RITUAL_ID),
DEFAULT_DOMAIN: JSON.stringify(process.env.DEFAULT_DOMAIN),
},
}
})
},
}),
].filter(Boolean),
module: {
rules: [
Expand Down
2 changes: 1 addition & 1 deletion examples/pre/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
toHexString,
} from '@nucypher/pre';
import { ethers } from 'ethers';
import { hexlify } from "ethers/lib/utils";
import { hexlify } from 'ethers/lib/utils';
import { useEffect, useState } from 'react';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Loading
Loading