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

[WIP] API Rework #554

Closed
wants to merge 80 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
ae751eb
move auth methods to taco-auth
piotr-roslaniec May 8, 2024
ec5ce9a
rewrite eip712 auth
piotr-roslaniec May 8, 2024
b57e3b9
chore: fix build errors
piotr-roslaniec Jun 4, 2024
e6de3e3
add a sketch of siwe provider
piotr-roslaniec May 15, 2024
b7de428
Change function name
manumonti May 23, 2024
919b31f
Expose createSIWEMessage parameters
manumonti May 24, 2024
d67cd13
Use EIP-4361 as Signature Provider
manumonti May 24, 2024
b602083
Update pnpm-lock file after rebase
manumonti May 27, 2024
8eca4c4
Add EIP-712 test
manumonti May 27, 2024
d365bba
Add scheme field to EIP712 message
manumonti May 27, 2024
704a08a
Generalize TypedSignature interface
manumonti May 27, 2024
14c128e
Use TypedSignature format as return of SiweMessage
manumonti May 27, 2024
4e226db
Add tests for SIWE message creation
manumonti May 27, 2024
e986f26
Add EIP761 and SIWE as context options and tests
manumonti May 28, 2024
39765fe
Replace didtools dependency with a depdency on siwe.
derekpierre May 30, 2024
0161445
Change scheme from "SIWE" to "EIP4361".
derekpierre May 30, 2024
b178040
Fix bug when determining whether condition requires signer or not; ca…
derekpierre May 30, 2024
a200135
Run linter.
derekpierre May 30, 2024
172d9f2
Update userAddressSchema to accomodate additional userAddress auth-sp…
derekpierre May 30, 2024
8a1e7ed
typedData entry for EIP4361 should be a string.
derekpierre May 31, 2024
5b78082
Fix fake provider chain id to be a positive number. Negative numbers …
derekpierre May 31, 2024
6af0e23
Fix/improve tests for taco-auth/context.
derekpierre May 31, 2024
d2eda8b
chore(linter): fix linter
piotr-roslaniec May 31, 2024
da018f2
Change getOrCreateSiweMessage to getOrCreateWalletSignature for EIP43…
derekpierre May 31, 2024
d2b2c80
set domain and uri in eip4361 dynamically
piotr-roslaniec May 31, 2024
49aa0b2
Update statement to include a mention of "TACo".
derekpierre May 31, 2024
246786e
fix siwe tests
piotr-roslaniec Jun 4, 2024
63306a6
deduplicate test methods
piotr-roslaniec Jun 4, 2024
120c0d9
refactor(auth-provider): first pass at refactoring taco-auth to suppo…
piotr-roslaniec Jun 13, 2024
c46bb82
refactor(auth-provider): introduce generic auth provider
piotr-roslaniec Jun 13, 2024
78001fe
refactor: clean up naming and todos
piotr-roslaniec Jun 13, 2024
524dff3
test(conditions): document context behavior
piotr-roslaniec Jun 14, 2024
8455f9f
refactor!(context): remove unused context method
piotr-roslaniec Jun 14, 2024
dc91ce0
refactor!(context): remove unused provider parameter
piotr-roslaniec Jun 14, 2024
7c44a99
refactor!(context): refactor validation and rename public methods
piotr-roslaniec Jun 14, 2024
12c7e7a
apply pr comments
piotr-roslaniec Jun 19, 2024
2c9ff52
feat(cond): expose requested params in user facing api
piotr-roslaniec Jun 20, 2024
119f2b9
feat!(cond): remove auth checking from cond expr
piotr-roslaniec Jun 24, 2024
62a0f78
refactor: rename methods for consistency
piotr-roslaniec Jun 24, 2024
333fb43
feat(eip4361): allow for reusing siwe messages
piotr-roslaniec Jun 12, 2024
7d9f561
refactor: don't reuse eip4361 alias
piotr-roslaniec Jun 24, 2024
914be0d
chore: document external eip4361 behavior
piotr-roslaniec Jun 24, 2024
baf8942
apply pr suggestions
piotr-roslaniec Jun 25, 2024
dfd96fb
feat(auth): set defaults for eip4361 providers
piotr-roslaniec Jun 25, 2024
5a4d072
chore: update lockfile
piotr-roslaniec Jul 2, 2024
4fcb8ed
feat!(cond): deprecate eip712 auth provider
piotr-roslaniec Jun 21, 2024
e9ce886
Deprecate EIP712 authentication provider (#532)
piotr-roslaniec Jul 2, 2024
be42ddc
feat(auth): validate user-provided auth signature
piotr-roslaniec Jun 28, 2024
c62ae73
apply pr suggestions
piotr-roslaniec Jul 3, 2024
6638c5d
chore: fix duplicated vitest dependency
piotr-roslaniec Jul 3, 2024
b3d724d
Validate user-provided `AuthSignature` (#537)
piotr-roslaniec Jul 3, 2024
f9e2030
validate eip4361 siwe message
piotr-roslaniec Jul 3, 2024
9ce1a99
feat(taco): expose auth providers from taco
piotr-roslaniec Jun 25, 2024
f452c6a
feat!(auth): expose eip4361 auth provider in taco api
piotr-roslaniec Jul 9, 2024
08367ad
apply pr suggestions
piotr-roslaniec Jul 10, 2024
0fba5c5
fix test not cathing edge cases
piotr-roslaniec Jul 10, 2024
28b3592
Expose auth providers from `taco` (#534)
derekpierre Jul 10, 2024
899eba4
feat!(auth): remove eip712
piotr-roslaniec Jul 9, 2024
b689493
Remove EIP712 authentication method (#546)
piotr-roslaniec Jul 11, 2024
918dba7
Add a sketch for reusing SIWE message
manumonti Jul 11, 2024
7d787cc
Use constant for EIP4361 auth scheme instead of string.
derekpierre Jul 12, 2024
6d9e8b3
Allow :userAddressExternalEIP4361 context variable wherever :userAddr…
derekpierre Jul 12, 2024
7bcb0f9
Add single sign-on EIP4361 auth provider for constructing auth signat…
derekpierre Jul 12, 2024
6709bf3
Run 'pnpm fix' to address linting issues.
derekpierre Jul 12, 2024
fc3ddf9
Reuse siwe authentication (#547)
derekpierre Jul 23, 2024
aa9e65e
Simplify calls to retrieveAndDecrypt and retrieve. We don't need to g…
derekpierre Jul 17, 2024
6c23e7b
Allow creation of Context from a message kit.
derekpierre Jul 18, 2024
e275628
Don't have ConditionExpr build a context, the context can be created …
derekpierre Jul 18, 2024
e0301b8
Allow ConditionContext to be an optional parameter for decryption; it…
derekpierre Jul 18, 2024
3f7967c
Allow address property to be public for SingleSignOnExternalEIP4361Au…
derekpierre Jul 18, 2024
d9f3481
Update tests to accomodate new architecture for ConditionContext.
derekpierre Jul 18, 2024
1c92bfd
Reconfigure taco-auth providers folder to have an eip4361 folder and …
derekpierre Jul 18, 2024
f3a36c4
Move RESERVED_CONTEXT_VARIABLES constant to context module since it i…
derekpierre Jul 18, 2024
cfc9c7e
Fix message to be use prefix constant.
derekpierre Jul 18, 2024
c808df1
Update nodejs example used for CI job to pass ConditionContext instea…
derekpierre Jul 19, 2024
790d966
Appease linter.
derekpierre Jul 19, 2024
6c3224b
Fix webpack-5 example to use ConditionContext instead of directly pro…
derekpierre Jul 19, 2024
d9c8745
Fix other taco examples to use ConditionContext instead of directly p…
derekpierre Jul 19, 2024
9acd772
Code cleanup based on RFC for #554.
derekpierre Jul 22, 2024
75e7a63
Add tests for processing addition of authProviders to ConditionContext.
derekpierre Jul 22, 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://rpc-mainnet.maticvigil.com"
RPC_PROVIDER_URL: 'https://rpc-mainnet.maticvigil.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