From 7cea7dcdfa0258ece5ce7a7bb96999e0d50d71fd Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 6 Oct 2023 18:02:20 +0200
Subject: [PATCH 1/9] chore(release): release @nucypher/taco:0.1.0-rc.0
---
packages/taco/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/taco/package.json b/packages/taco/package.json
index c5ee587ae..b9ec0bfe3 100644
--- a/packages/taco/package.json
+++ b/packages/taco/package.json
@@ -1,6 +1,6 @@
{
"name": "@nucypher/taco",
- "version": "0.1.0",
+ "version": "0.1.0-rc.0",
"keywords": [
"taco",
"threshold",
From 23644ab7c34d454a24ccada76115c192d05e9f2e Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 6 Oct 2023 18:07:08 +0200
Subject: [PATCH 2/9] chore(release): release @nucypher/shared:0.1.0-rc.0
---
packages/shared/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/shared/package.json b/packages/shared/package.json
index bc61c6cac..c98cfb219 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -1,6 +1,6 @@
{
"name": "@nucypher/shared",
- "version": "0.1.0",
+ "version": "0.1.0-rc.0",
"keywords": [
"pre",
"taco",
From 120fd451b020df3ba9bdf52447e5874cbf14bfd1 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 6 Oct 2023 18:09:13 +0200
Subject: [PATCH 3/9] chore(release): release @nucypher/taco:0.1.0-rc.1
---
packages/taco/package.json | 4 ++--
pnpm-lock.yaml | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/packages/taco/package.json b/packages/taco/package.json
index b9ec0bfe3..1d9f57d57 100644
--- a/packages/taco/package.json
+++ b/packages/taco/package.json
@@ -1,6 +1,6 @@
{
"name": "@nucypher/taco",
- "version": "0.1.0-rc.0",
+ "version": "0.1.0-rc.1",
"keywords": [
"taco",
"threshold",
@@ -40,7 +40,7 @@
"dependencies": {
"@ethersproject/abstract-signer": "^5.7.0",
"@nucypher/nucypher-core": "0.13.0-alpha.1",
- "@nucypher/shared": "workspace:*",
+ "@nucypher/shared": "0.1.0-rc.0",
"semver": "^7.5.2",
"zod": "^3.22.1"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2e2c27101..1cc13c1b8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -516,7 +516,7 @@ importers:
specifier: 0.13.0-alpha.1
version: 0.13.0-alpha.1
'@nucypher/shared':
- specifier: workspace:*
+ specifier: 0.1.0-rc.0
version: link:../shared
ethers:
specifier: ^5.7.2
From 9397c13d57def4b83b25297dc0ba71f554eb91e3 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 6 Oct 2023 18:20:23 +0200
Subject: [PATCH 4/9] chore(typechain): remove typechain from postinstall steps
---
packages/shared/package.json | 1 -
1 file changed, 1 deletion(-)
diff --git a/packages/shared/package.json b/packages/shared/package.json
index c98cfb219..568f6d572 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -32,7 +32,6 @@
"build:module": "tsc --build ./tsconfig.es.json --verbose",
"clean": "rm -rf dist",
"exports:lint": "ts-unused-exports tsconfig.json --ignoreFiles src/index.ts",
- "postinstall": "pnpm typechain",
"lint": "eslint --ext .ts src",
"lint:fix": "pnpm lint --fix",
"package-check": "package-check",
From b0a2ca96bedeee531f0c4c6b9d2c92ada0271b2f Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 6 Oct 2023 18:21:20 +0200
Subject: [PATCH 5/9] chore(release): release @nucypher/shared:0.1.0-rc.1
---
packages/shared/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/shared/package.json b/packages/shared/package.json
index 568f6d572..9d5610b64 100644
--- a/packages/shared/package.json
+++ b/packages/shared/package.json
@@ -1,6 +1,6 @@
{
"name": "@nucypher/shared",
- "version": "0.1.0-rc.0",
+ "version": "0.1.0-rc.1",
"keywords": [
"pre",
"taco",
From 3b08a341dc6c20744d6489dfe78bfb5c57d224df Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 6 Oct 2023 18:22:19 +0200
Subject: [PATCH 6/9] chore(release): release @nucypher/taco:0.1.0-rc.2
---
packages/taco/package.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/taco/package.json b/packages/taco/package.json
index 1d9f57d57..612325cd7 100644
--- a/packages/taco/package.json
+++ b/packages/taco/package.json
@@ -1,6 +1,6 @@
{
"name": "@nucypher/taco",
- "version": "0.1.0-rc.1",
+ "version": "0.1.0-rc.2",
"keywords": [
"taco",
"threshold",
@@ -40,7 +40,7 @@
"dependencies": {
"@ethersproject/abstract-signer": "^5.7.0",
"@nucypher/nucypher-core": "0.13.0-alpha.1",
- "@nucypher/shared": "0.1.0-rc.0",
+ "@nucypher/shared": "0.1.0-rc.1",
"semver": "^7.5.2",
"zod": "^3.22.1"
},
From 149fb20013a20bcad5aaefbd577dea60ebe8305c Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Thu, 5 Oct 2023 15:30:47 +0200
Subject: [PATCH 7/9] feature(porter): add porter domains for taco and pre
---
examples/pre/nextjs/src/app/page.tsx | 3 ++-
examples/pre/nodejs/src/index.ts | 3 ++-
examples/pre/react/src/App.tsx | 8 +++-----
examples/pre/webpack-5/src/index.ts | 11 +++++++++--
examples/taco/nextjs/src/app/page.tsx | 5 +++--
examples/taco/nodejs/src/index.ts | 5 +++--
examples/taco/react/src/App.tsx | 5 +++--
examples/taco/webpack-5/src/index.ts | 5 +++--
packages/pre/src/index.ts | 9 +--------
packages/pre/src/porter.ts | 17 +++++++++++++++++
packages/shared/src/porter.ts | 11 +++++------
packages/taco/src/index.ts | 6 ++----
packages/taco/src/porter.ts | 18 ++++++++++++++++++
packages/taco/src/taco.ts | 9 ++-------
packages/taco/test/taco.test.ts | 2 +-
pnpm-lock.yaml | 2 +-
16 files changed, 75 insertions(+), 44 deletions(-)
create mode 100644 packages/pre/src/porter.ts
create mode 100644 packages/taco/src/porter.ts
diff --git a/examples/pre/nextjs/src/app/page.tsx b/examples/pre/nextjs/src/app/page.tsx
index 79648862b..65149bd36 100644
--- a/examples/pre/nextjs/src/app/page.tsx
+++ b/examples/pre/nextjs/src/app/page.tsx
@@ -5,6 +5,7 @@ import {
EnactedPolicy,
getPorterUri,
initialize,
+ PRE_DOMAIN,
SecretKey,
toHexString,
} from '@nucypher/pre';
@@ -106,7 +107,7 @@ function App() {
const policy = await alice.grant(
provider,
provider.getSigner(),
- getPorterUri('tapir'), // Testnet porter
+ getPorterUri(PRE_DOMAIN.TESTNET),
policyParams,
);
diff --git a/examples/pre/nodejs/src/index.ts b/examples/pre/nodejs/src/index.ts
index 7cb42d360..5006fa65a 100644
--- a/examples/pre/nodejs/src/index.ts
+++ b/examples/pre/nodejs/src/index.ts
@@ -3,6 +3,7 @@ import {
Bob,
getPorterUri,
initialize,
+ PRE_DOMAIN,
SecretKey,
toBytes,
} from '@nucypher/pre';
@@ -58,7 +59,7 @@ const runExample = async () => {
startDate: new Date(),
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // In 30 days,
};
- const porterUri = getPorterUri('tapir'); // Test network
+ const porterUri = getPorterUri(PRE_DOMAIN.TESTNET);
const alice = makeAlice();
console.log('Creating policy...');
diff --git a/examples/pre/react/src/App.tsx b/examples/pre/react/src/App.tsx
index d4901ad2b..3c3de670f 100644
--- a/examples/pre/react/src/App.tsx
+++ b/examples/pre/react/src/App.tsx
@@ -4,8 +4,9 @@ import {
EnactedPolicy,
getPorterUri,
initialize,
+ PRE_DOMAIN,
SecretKey,
- toHexString,
+ toHexString
} from '@nucypher/pre';
import { ethers } from 'ethers';
import { useEffect, useState } from 'react';
@@ -48,8 +49,6 @@ function App() {
return Loading...
;
}
- console.log({ Alice, Bob, getPorterUri, SecretKey, toHexString });
-
const makeAlice = () => {
const alice = Alice.fromSecretKey(SecretKey.random());
setAlice(alice);
@@ -96,11 +95,10 @@ function App() {
startDate,
endDate,
};
-
const policy = await alice.grant(
provider,
provider.getSigner(),
- getPorterUri('tapir'), // Testnet porter
+ getPorterUri(PRE_DOMAIN.TESTNET),
policyParams,
);
diff --git a/examples/pre/webpack-5/src/index.ts b/examples/pre/webpack-5/src/index.ts
index 3417a426d..f1dfa348f 100644
--- a/examples/pre/webpack-5/src/index.ts
+++ b/examples/pre/webpack-5/src/index.ts
@@ -1,4 +1,11 @@
-import { Alice, Bob, SecretKey, getPorterUri, initialize } from '@nucypher/pre';
+import {
+ Alice,
+ Bob,
+ PRE_DOMAIN,
+ SecretKey,
+ getPorterUri,
+ initialize,
+} from '@nucypher/pre';
import { ethers } from 'ethers';
declare global {
@@ -58,7 +65,7 @@ const runExample = async () => {
startDate,
endDate,
};
- const porterUri = getPorterUri('tapir'); // Test network
+ const porterUri = getPorterUri(PRE_DOMAIN.TESTNET);
const alice = makeAlice();
const policy = await alice.grant(
diff --git a/examples/taco/nextjs/src/app/page.tsx b/examples/taco/nextjs/src/app/page.tsx
index c9bcea875..a7e3da8fa 100644
--- a/examples/taco/nextjs/src/app/page.tsx
+++ b/examples/taco/nextjs/src/app/page.tsx
@@ -5,6 +5,7 @@ import {
encrypt, fromBytes,
getPorterUri,
initialize,
+ TACO_DOMAIN
} from '@nucypher/taco';
import {ethers} from 'ethers';
import {useEffect, useState} from 'react';
@@ -89,8 +90,8 @@ function App() {
const messageKit = await encrypt(provider, message, hasPositiveBalance, ritualId, signer);
console.log('Decrypting message...');
- const porterUri = getPorterUri('lynx'); // Test network
- const decryptedMessage = await decrypt(provider, messageKit, signer, porterUri);
+ const porterUri = getPorterUri(TACO_DOMAIN.DEV);
+ const decryptedMessage = await decrypt(provider, messageKit,porterUri,signer);
setDecryptedMessage(fromBytes(decryptedMessage));
};
diff --git a/examples/taco/nodejs/src/index.ts b/examples/taco/nodejs/src/index.ts
index be6f035ed..1bbfa6550 100644
--- a/examples/taco/nodejs/src/index.ts
+++ b/examples/taco/nodejs/src/index.ts
@@ -5,6 +5,7 @@ import {
fromBytes,
getPorterUri,
initialize,
+ TACO_DOMAIN,
toBytes,
} from '@nucypher/taco';
import * as dotenv from 'dotenv';
@@ -57,8 +58,8 @@ const runExample = async () => {
);
console.log('Decrypting message...');
- const porterUri = getPorterUri('lynx'); // Test network
- const decryptedBytes = await decrypt(provider, messageKit, signer, porterUri);
+ const porterUri = getPorterUri(TACO_DOMAIN.DEV);
+ const decryptedBytes = await decrypt(provider, messageKit, porterUri, signer);
const decryptedMessageString = fromBytes(decryptedBytes);
console.log('Decrypted message:', decryptedMessageString);
console.assert(
diff --git a/examples/taco/react/src/App.tsx b/examples/taco/react/src/App.tsx
index 4073fb53e..67691a937 100644
--- a/examples/taco/react/src/App.tsx
+++ b/examples/taco/react/src/App.tsx
@@ -5,6 +5,7 @@ import {
fromBytes,
getPorterUri,
initialize,
+ TACO_DOMAIN,
} from '@nucypher/taco';
import {ethers} from 'ethers';
import {useEffect, useState} from 'react';
@@ -89,8 +90,8 @@ function App() {
const messageKit = await encrypt(provider, message, hasPositiveBalance, ritualId, signer);
console.log('Decrypting message...');
- const porterUri = getPorterUri('lynx'); // Test network
- const decryptedMessage = await decrypt(provider, messageKit, signer, porterUri);
+ const porterUri = getPorterUri(TACO_DOMAIN.DEV);
+ const decryptedMessage = await decrypt(provider, messageKit, porterUri, signer);
setDecryptedMessage(fromBytes(decryptedMessage));
};
diff --git a/examples/taco/webpack-5/src/index.ts b/examples/taco/webpack-5/src/index.ts
index 370eada34..3554c8e76 100644
--- a/examples/taco/webpack-5/src/index.ts
+++ b/examples/taco/webpack-5/src/index.ts
@@ -5,6 +5,7 @@ import {
fromBytes,
getPorterUri,
initialize,
+ TACO_DOMAIN,
toBytes,
} from '@nucypher/taco';
import { ethers } from 'ethers';
@@ -47,8 +48,8 @@ const runExample = async () => {
);
console.log('Decrypting message...');
- const porterUri = getPorterUri('lynx'); // Test network
- const decryptedBytes = await decrypt(provider, messageKit, signer, porterUri);
+ const porterUri = getPorterUri(TACO_DOMAIN.DEV);
+ const decryptedBytes = await decrypt(provider, messageKit, porterUri, signer);
const decryptedMessage = fromBytes(decryptedBytes);
console.log('Decrypted message:', decryptedMessage);
};
diff --git a/packages/pre/src/index.ts b/packages/pre/src/index.ts
index 4f676b1ca..9b4a13d95 100644
--- a/packages/pre/src/index.ts
+++ b/packages/pre/src/index.ts
@@ -1,11 +1,3 @@
-export {
- PorterClient,
- fromHexString,
- getPorterUri,
- toBytes,
- toHexString,
-} from '@nucypher/shared';
-
export {
Ciphertext,
EncryptedTreasureMap,
@@ -21,3 +13,4 @@ export {
export { Alice, Bob, Enrico } from './characters';
export { Cohort } from './cohort';
export { EnactedPolicy } from './policy';
+export * from './porter';
diff --git a/packages/pre/src/porter.ts b/packages/pre/src/porter.ts
new file mode 100644
index 000000000..8e244265a
--- /dev/null
+++ b/packages/pre/src/porter.ts
@@ -0,0 +1,17 @@
+import { getPorterUri as doGetPorterUri } from '@nucypher/shared';
+
+type PreDomain = 'oryx';
+
+export const PRE_DOMAIN: Record = {
+ TESTNET: 'oryx',
+};
+
+export const getPorterUri = (domain: PreDomain): string => {
+ const preDomainKeys = Object.keys(PRE_DOMAIN);
+ if (!preDomainKeys.includes(domain)) {
+ throw new Error(`${domain} is not a valid PRE domain.`);
+ }
+ return doGetPorterUri(domain);
+};
+
+export { fromBytes, initialize, toBytes, toHexString } from '@nucypher/shared';
diff --git a/packages/shared/src/porter.ts b/packages/shared/src/porter.ts
index 175355766..816cc077a 100644
--- a/packages/shared/src/porter.ts
+++ b/packages/shared/src/porter.ts
@@ -12,21 +12,20 @@ import qs from 'qs';
import { Base64EncodedBytes, ChecksumAddress, HexEncodedBytes } from './types';
import { fromBase64, fromHexString, toBase64, toHexString } from './utils';
-type Network = 'mainnet' | 'tapir' | 'oryx' | 'lynx';
-
-const PORTER_URIS: Record = {
+const porterUri: Record = {
mainnet: 'https://porter.nucypher.community',
tapir: 'https://porter-tapir.nucypher.community',
oryx: 'https://porter-oryx.nucypher.community',
lynx: 'https://porter-lynx.nucypher.community',
};
+export type PorterNetwork = keyof typeof porterUri;
-export const getPorterUri = (network: Network): string => {
- const uri = PORTER_URIS[network];
+export const getPorterUri = (network: PorterNetwork): string => {
+ const uri = porterUri[network];
if (!uri) {
throw new Error(`No default Porter URI found for network: ${network}`);
}
- return PORTER_URIS[network];
+ return porterUri[network];
};
// /get_ursulas
diff --git a/packages/taco/src/index.ts b/packages/taco/src/index.ts
index b1c36b574..617e917b2 100644
--- a/packages/taco/src/index.ts
+++ b/packages/taco/src/index.ts
@@ -1,7 +1,5 @@
export { DkgPublicKey, ThresholdMessageKit } from '@nucypher/nucypher-core';
-export { fromBytes, getPorterUri, initialize, toBytes } from '@nucypher/shared';
-
export * as conditions from './conditions';
-
-export { decrypt, encrypt } from './taco';
+export * from './porter';
+export * from './taco';
diff --git a/packages/taco/src/porter.ts b/packages/taco/src/porter.ts
new file mode 100644
index 000000000..6572db214
--- /dev/null
+++ b/packages/taco/src/porter.ts
@@ -0,0 +1,18 @@
+import { getPorterUri as doGetPorterUri } from '@nucypher/shared';
+
+type TacoDomain = 'lynx' | 'tapir';
+
+export const TACO_DOMAIN: Record = {
+ DEV: 'lynx',
+ TESTNET: 'tapir',
+};
+
+export const getPorterUri = (domain: TacoDomain): string => {
+ const tacoDomainKeys = Object.keys(TACO_DOMAIN);
+ if (!tacoDomainKeys.includes(domain)) {
+ throw new Error(`${domain} is not a valid TACo domain.`);
+ }
+ return doGetPorterUri(domain);
+};
+
+export { fromBytes, initialize, toBytes, toHexString } from '@nucypher/shared';
diff --git a/packages/taco/src/taco.ts b/packages/taco/src/taco.ts
index 3a23bd132..317f1fb8e 100644
--- a/packages/taco/src/taco.ts
+++ b/packages/taco/src/taco.ts
@@ -4,12 +4,7 @@ import {
encryptForDkg,
ThresholdMessageKit,
} from '@nucypher/nucypher-core';
-import {
- DkgCoordinatorAgent,
- fromHexString,
- getPorterUri,
- toBytes,
-} from '@nucypher/shared';
+import { DkgCoordinatorAgent, fromHexString, toBytes } from '@nucypher/shared';
import { ethers } from 'ethers';
import { keccak256 } from 'ethers/lib/utils';
@@ -77,8 +72,8 @@ export const encryptWithPublicKey = async (
export const decrypt = async (
provider: ethers.providers.Provider,
messageKit: ThresholdMessageKit,
+ porterUri: string,
signer?: ethers.Signer,
- porterUri = getPorterUri('tapir'),
): Promise => {
const ritualId = await DkgCoordinatorAgent.getRitualIdFromPublicKey(
provider,
diff --git a/packages/taco/test/taco.test.ts b/packages/taco/test/taco.test.ts
index 6a62e1fdd..ba615f71a 100644
--- a/packages/taco/test/taco.test.ts
+++ b/packages/taco/test/taco.test.ts
@@ -81,8 +81,8 @@ describe('taco', () => {
const decryptedMessage = await taco.decrypt(
provider,
messageKit,
- signer,
fakePorterUri,
+ signer,
);
expect(getParticipantsSpy).toHaveBeenCalled();
expect(sessionKeySpy).toHaveBeenCalled();
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1cc13c1b8..4c2caa734 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -516,7 +516,7 @@ importers:
specifier: 0.13.0-alpha.1
version: 0.13.0-alpha.1
'@nucypher/shared':
- specifier: 0.1.0-rc.0
+ specifier: 0.1.0-rc.1
version: link:../shared
ethers:
specifier: ^5.7.2
From 76911fad192981145d47e0460e6f27ef4a52a495 Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 6 Oct 2023 16:35:25 +0200
Subject: [PATCH 8/9] apply pr suggestions
---
packages/shared/src/porter.ts | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/packages/shared/src/porter.ts b/packages/shared/src/porter.ts
index 816cc077a..c9a6e3f7b 100644
--- a/packages/shared/src/porter.ts
+++ b/packages/shared/src/porter.ts
@@ -18,14 +18,14 @@ const porterUri: Record = {
oryx: 'https://porter-oryx.nucypher.community',
lynx: 'https://porter-lynx.nucypher.community',
};
-export type PorterNetwork = keyof typeof porterUri;
+export type PorterDomain = keyof typeof porterUri;
-export const getPorterUri = (network: PorterNetwork): string => {
- const uri = porterUri[network];
+export const getPorterUri = (domain: PorterDomain): string => {
+ const uri = porterUri[domain];
if (!uri) {
- throw new Error(`No default Porter URI found for network: ${network}`);
+ throw new Error(`No default Porter URI found for domain: ${domain}`);
}
- return porterUri[network];
+ return porterUri[domain];
};
// /get_ursulas
From 21f6d93cde73101eaf1b2f4db85f54fe0f8229cd Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Mon, 16 Oct 2023 21:31:33 +0200
Subject: [PATCH 9/9] apply pr suggestions
---
examples/pre/nextjs/src/app/page.tsx | 4 ++--
examples/pre/nodejs/src/index.ts | 4 ++--
examples/pre/react/src/App.tsx | 4 ++--
examples/pre/webpack-5/src/index.ts | 6 +++---
examples/taco/nextjs/src/app/page.tsx | 9 +++++----
examples/taco/nodejs/src/index.ts | 4 ++--
examples/taco/react/src/App.tsx | 4 ++--
examples/taco/webpack-5/src/index.ts | 4 ++--
packages/pre/src/index.ts | 3 +--
packages/pre/src/porter.ts | 17 -----------------
packages/shared/src/porter.ts | 11 +++++++++--
packages/taco/src/index.ts | 2 +-
packages/taco/src/porter.ts | 18 ------------------
13 files changed, 31 insertions(+), 59 deletions(-)
delete mode 100644 packages/pre/src/porter.ts
delete mode 100644 packages/taco/src/porter.ts
diff --git a/examples/pre/nextjs/src/app/page.tsx b/examples/pre/nextjs/src/app/page.tsx
index 65149bd36..5e612d6b6 100644
--- a/examples/pre/nextjs/src/app/page.tsx
+++ b/examples/pre/nextjs/src/app/page.tsx
@@ -2,10 +2,10 @@
import {
Alice,
Bob,
+ domains,
EnactedPolicy,
getPorterUri,
initialize,
- PRE_DOMAIN,
SecretKey,
toHexString,
} from '@nucypher/pre';
@@ -107,7 +107,7 @@ function App() {
const policy = await alice.grant(
provider,
provider.getSigner(),
- getPorterUri(PRE_DOMAIN.TESTNET),
+ getPorterUri(domains.TESTNET),
policyParams,
);
diff --git a/examples/pre/nodejs/src/index.ts b/examples/pre/nodejs/src/index.ts
index 5006fa65a..931567605 100644
--- a/examples/pre/nodejs/src/index.ts
+++ b/examples/pre/nodejs/src/index.ts
@@ -1,9 +1,9 @@
import {
Alice,
Bob,
+ domains,
getPorterUri,
initialize,
- PRE_DOMAIN,
SecretKey,
toBytes,
} from '@nucypher/pre';
@@ -59,7 +59,7 @@ const runExample = async () => {
startDate: new Date(),
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // In 30 days,
};
- const porterUri = getPorterUri(PRE_DOMAIN.TESTNET);
+ const porterUri = getPorterUri(domains.TESTNET);
const alice = makeAlice();
console.log('Creating policy...');
diff --git a/examples/pre/react/src/App.tsx b/examples/pre/react/src/App.tsx
index 3c3de670f..54d9ea5a3 100644
--- a/examples/pre/react/src/App.tsx
+++ b/examples/pre/react/src/App.tsx
@@ -1,10 +1,10 @@
import {
Alice,
Bob,
+ domains,
EnactedPolicy,
getPorterUri,
initialize,
- PRE_DOMAIN,
SecretKey,
toHexString
} from '@nucypher/pre';
@@ -98,7 +98,7 @@ function App() {
const policy = await alice.grant(
provider,
provider.getSigner(),
- getPorterUri(PRE_DOMAIN.TESTNET),
+ getPorterUri(domains.TESTNET),
policyParams,
);
diff --git a/examples/pre/webpack-5/src/index.ts b/examples/pre/webpack-5/src/index.ts
index f1dfa348f..fe05e1f4b 100644
--- a/examples/pre/webpack-5/src/index.ts
+++ b/examples/pre/webpack-5/src/index.ts
@@ -1,10 +1,10 @@
import {
Alice,
Bob,
- PRE_DOMAIN,
- SecretKey,
+ domains,
getPorterUri,
initialize,
+ SecretKey,
} from '@nucypher/pre';
import { ethers } from 'ethers';
@@ -65,7 +65,7 @@ const runExample = async () => {
startDate,
endDate,
};
- const porterUri = getPorterUri(PRE_DOMAIN.TESTNET);
+ const porterUri = getPorterUri(domains.TESTNET);
const alice = makeAlice();
const policy = await alice.grant(
diff --git a/examples/taco/nextjs/src/app/page.tsx b/examples/taco/nextjs/src/app/page.tsx
index a7e3da8fa..adc7e6393 100644
--- a/examples/taco/nextjs/src/app/page.tsx
+++ b/examples/taco/nextjs/src/app/page.tsx
@@ -2,10 +2,11 @@
import {
conditions,
decrypt,
- encrypt, fromBytes,
+ domains,
+ encrypt,
+ fromBytes,
getPorterUri,
- initialize,
- TACO_DOMAIN
+ initialize
} from '@nucypher/taco';
import {ethers} from 'ethers';
import {useEffect, useState} from 'react';
@@ -90,7 +91,7 @@ function App() {
const messageKit = await encrypt(provider, message, hasPositiveBalance, ritualId, signer);
console.log('Decrypting message...');
- const porterUri = getPorterUri(TACO_DOMAIN.DEV);
+ const porterUri = getPorterUri(domains.DEV);
const decryptedMessage = await decrypt(provider, messageKit,porterUri,signer);
setDecryptedMessage(fromBytes(decryptedMessage));
diff --git a/examples/taco/nodejs/src/index.ts b/examples/taco/nodejs/src/index.ts
index 1bbfa6550..339fc7cb9 100644
--- a/examples/taco/nodejs/src/index.ts
+++ b/examples/taco/nodejs/src/index.ts
@@ -5,7 +5,7 @@ import {
fromBytes,
getPorterUri,
initialize,
- TACO_DOMAIN,
+ domains,
toBytes,
} from '@nucypher/taco';
import * as dotenv from 'dotenv';
@@ -58,7 +58,7 @@ const runExample = async () => {
);
console.log('Decrypting message...');
- const porterUri = getPorterUri(TACO_DOMAIN.DEV);
+ const porterUri = getPorterUri(domains.DEV);
const decryptedBytes = await decrypt(provider, messageKit, porterUri, signer);
const decryptedMessageString = fromBytes(decryptedBytes);
console.log('Decrypted message:', decryptedMessageString);
diff --git a/examples/taco/react/src/App.tsx b/examples/taco/react/src/App.tsx
index 67691a937..ad77f772a 100644
--- a/examples/taco/react/src/App.tsx
+++ b/examples/taco/react/src/App.tsx
@@ -1,11 +1,11 @@
import {
conditions,
decrypt,
+ domains,
encrypt,
fromBytes,
getPorterUri,
initialize,
- TACO_DOMAIN,
} from '@nucypher/taco';
import {ethers} from 'ethers';
import {useEffect, useState} from 'react';
@@ -90,7 +90,7 @@ function App() {
const messageKit = await encrypt(provider, message, hasPositiveBalance, ritualId, signer);
console.log('Decrypting message...');
- const porterUri = getPorterUri(TACO_DOMAIN.DEV);
+ const porterUri = getPorterUri(domains.DEV);
const decryptedMessage = await decrypt(provider, messageKit, porterUri, signer);
setDecryptedMessage(fromBytes(decryptedMessage));
diff --git a/examples/taco/webpack-5/src/index.ts b/examples/taco/webpack-5/src/index.ts
index 3554c8e76..5b44889ab 100644
--- a/examples/taco/webpack-5/src/index.ts
+++ b/examples/taco/webpack-5/src/index.ts
@@ -5,7 +5,7 @@ import {
fromBytes,
getPorterUri,
initialize,
- TACO_DOMAIN,
+ domains,
toBytes,
} from '@nucypher/taco';
import { ethers } from 'ethers';
@@ -48,7 +48,7 @@ const runExample = async () => {
);
console.log('Decrypting message...');
- const porterUri = getPorterUri(TACO_DOMAIN.DEV);
+ const porterUri = getPorterUri(domains.DEV);
const decryptedBytes = await decrypt(provider, messageKit, porterUri, signer);
const decryptedMessage = fromBytes(decryptedBytes);
console.log('Decrypted message:', decryptedMessage);
diff --git a/packages/pre/src/index.ts b/packages/pre/src/index.ts
index 9b4a13d95..c5bf1e123 100644
--- a/packages/pre/src/index.ts
+++ b/packages/pre/src/index.ts
@@ -7,10 +7,9 @@ export {
SecretKey,
Signer,
TreasureMap,
- initialize,
} from '@nucypher/nucypher-core';
+export { fromBytes, initialize, toBytes, toHexString, getPorterUri, domains } from '@nucypher/shared';
export { Alice, Bob, Enrico } from './characters';
export { Cohort } from './cohort';
export { EnactedPolicy } from './policy';
-export * from './porter';
diff --git a/packages/pre/src/porter.ts b/packages/pre/src/porter.ts
deleted file mode 100644
index 8e244265a..000000000
--- a/packages/pre/src/porter.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { getPorterUri as doGetPorterUri } from '@nucypher/shared';
-
-type PreDomain = 'oryx';
-
-export const PRE_DOMAIN: Record = {
- TESTNET: 'oryx',
-};
-
-export const getPorterUri = (domain: PreDomain): string => {
- const preDomainKeys = Object.keys(PRE_DOMAIN);
- if (!preDomainKeys.includes(domain)) {
- throw new Error(`${domain} is not a valid PRE domain.`);
- }
- return doGetPorterUri(domain);
-};
-
-export { fromBytes, initialize, toBytes, toHexString } from '@nucypher/shared';
diff --git a/packages/shared/src/porter.ts b/packages/shared/src/porter.ts
index c9a6e3f7b..2de148620 100644
--- a/packages/shared/src/porter.ts
+++ b/packages/shared/src/porter.ts
@@ -18,9 +18,16 @@ const porterUri: Record = {
oryx: 'https://porter-oryx.nucypher.community',
lynx: 'https://porter-lynx.nucypher.community',
};
-export type PorterDomain = keyof typeof porterUri;
-export const getPorterUri = (domain: PorterDomain): string => {
+export type Domain = keyof typeof porterUri;
+
+export const domains: Record = {
+ DEV: 'lynx',
+ TESTNET: 'tapir',
+ MAINNET: 'mainnet',
+};
+
+export const getPorterUri = (domain: Domain): string => {
const uri = porterUri[domain];
if (!uri) {
throw new Error(`No default Porter URI found for domain: ${domain}`);
diff --git a/packages/taco/src/index.ts b/packages/taco/src/index.ts
index 617e917b2..f2d9646f4 100644
--- a/packages/taco/src/index.ts
+++ b/packages/taco/src/index.ts
@@ -1,5 +1,5 @@
export { DkgPublicKey, ThresholdMessageKit } from '@nucypher/nucypher-core';
+export { fromBytes, initialize, toBytes, toHexString, getPorterUri, domains } from '@nucypher/shared';
export * as conditions from './conditions';
-export * from './porter';
export * from './taco';
diff --git a/packages/taco/src/porter.ts b/packages/taco/src/porter.ts
deleted file mode 100644
index 6572db214..000000000
--- a/packages/taco/src/porter.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { getPorterUri as doGetPorterUri } from '@nucypher/shared';
-
-type TacoDomain = 'lynx' | 'tapir';
-
-export const TACO_DOMAIN: Record = {
- DEV: 'lynx',
- TESTNET: 'tapir',
-};
-
-export const getPorterUri = (domain: TacoDomain): string => {
- const tacoDomainKeys = Object.keys(TACO_DOMAIN);
- if (!tacoDomainKeys.includes(domain)) {
- throw new Error(`${domain} is not a valid TACo domain.`);
- }
- return doGetPorterUri(domain);
-};
-
-export { fromBytes, initialize, toBytes, toHexString } from '@nucypher/shared';