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

LIT-2841 - Remove ipfs-http-client and create encryption APIs for composition with any storage layer #427

Merged
merged 19 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d0a5455
fix(sev-snp-utils-sdk): LIT-2841 - Fix up test file for `sev-snp-util…
MaximusHaximus Apr 8, 2024
ed3806a
chore(global): LIT-2841 - Replace explicit `node-fetch` dep with `cro…
MaximusHaximus Apr 8, 2024
da85371
chore(lit-node-client): LIT-2841 - Remove unnecessary polyfilling of …
MaximusHaximus Apr 8, 2024
fe87372
fix(lit-node-client-nodejs): LIT-2841 - Replace `node-fetch` polyfill…
MaximusHaximus Apr 8, 2024
318c47d
build(global): LIT-2841 - Remove unused polyfills files, pragmas, and…
MaximusHaximus Apr 8, 2024
fd6064e
build(encryption): LIT-2841 - Remove postBuild file that monkey-patch…
MaximusHaximus Apr 8, 2024
495d115
build(global): LIT-2841 - Remove unused `postBuildIndividual` tooling
MaximusHaximus Apr 8, 2024
b518713
fix(encryption)!: LIT-2841 - Remove `ipfs-http-client` and use `cross…
MaximusHaximus Apr 10, 2024
69c4f33
types!(types): LIT-2841 - Update interfaces to replace to/from ipfs e…
MaximusHaximus Apr 11, 2024
51707cf
feat!(encryption): LIT-2841 - Define validators for Encrypt/DecryptTo…
MaximusHaximus Apr 11, 2024
1382ee0
feat!(encryption): LIT-2841 - Initial cut of replacing encrypt to and…
MaximusHaximus Apr 11, 2024
b6ba5c8
feat!(lit-node-client-nodejs): LIT-2841 - Replace exported `encryptTo…
MaximusHaximus Apr 11, 2024
4411916
chore(encryption): LIT-2841 - Code review feedback - make `dataType` …
MaximusHaximus Apr 16, 2024
dec1568
chore(contracts-sdk): LIT-2841 - Make `connect()` logging less spammy…
MaximusHaximus Apr 16, 2024
54bd94b
chore(contracts-sdk): LIT-2841 - Use local logger instead of `console…
MaximusHaximus Apr 16, 2024
ca44283
fix(encryption): LIT-2841 - Infer return type of `decryptFromJson()` …
MaximusHaximus Apr 17, 2024
29ffde9
fix(encryption): LIT-2841 - Use the same string output as the paramsV…
MaximusHaximus Apr 17, 2024
0c3bac2
fix(encryption): LIT-2841 - Remove overly strict requirement that bot…
MaximusHaximus Apr 18, 2024
93cdeb3
test(encryption): LIT-2841 - Implement e2e tests for encrypting and d…
MaximusHaximus Apr 18, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import path from 'path';
import * as LitJsSdk from '@lit-protocol/lit-node-client';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import { client } from '../00-setup.mjs';

export async function main() {
// ==================== Setup ====================
const chain = 'ethereum';
const accessControlConditions = [
{
contractAddress: '',
standardContractType: '',
chain,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: '>=',
value: '0',
},
},
];
const message = 'Hello world';
const blob = new Blob([message], { type: 'text/plain' });
const blobArray = new Uint8Array(await blob.arrayBuffer());

// ==================== Test Logic ====================
const encryptedJsonStr = await LitJsSdk.encryptToJson({
accessControlConditions,
authSig: globalThis.LitCI.CONTROLLER_AUTHSIG,
chain,
file: blob,
litNodeClient: client,
});

const decryptedFile = await LitJsSdk.decryptFromJson({
authSig: globalThis.LitCI.CONTROLLER_AUTHSIG,
parsedJsonData: JSON.parse(encryptedJsonStr),
litNodeClient: client,
});

// ==================== Post-Validation ====================
if (blobArray.length !== decryptedFile.length) {
return fail(
`decrypted file should match the original file but received ${decryptedFile}`
);
}
for (let i = 0; i < blobArray.length; i++) {
if (blobArray[i] !== decryptedFile[i]) {
return fail(`decrypted file should match the original file`);
}
}

// ==================== Success ====================
return success('File was encrypted and then decrypted successfully');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import path from 'path';
import * as LitJsSdk from '@lit-protocol/lit-node-client';
import { success, fail, testThis } from '../../tools/scripts/utils.mjs';
import { client } from '../00-setup.mjs';

export async function main() {
// ==================== Setup ====================
const chain = 'ethereum';
const accessControlConditions = [
{
contractAddress: '',
standardContractType: '',
chain,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: '>=',
value: '0',
},
},
];
const message = 'Hello world';

// ==================== Test Logic ====================
const encryptedJsonStr = await LitJsSdk.encryptToJson({
accessControlConditions,
authSig: globalThis.LitCI.CONTROLLER_AUTHSIG,
chain,
string: message,
litNodeClient: client,
});

const decryptedMessage = await LitJsSdk.decryptFromJson({
authSig: globalThis.LitCI.CONTROLLER_AUTHSIG,
parsedJsonData: JSON.parse(encryptedJsonStr),
litNodeClient: client,
});

// ==================== Post-Validation ====================
if (message !== decryptedMessage) {
return fail(
`decryptedMessage should be ${message} but received ${decryptedMessage}`
);
}

// ==================== Success ====================
return success('Message was encrypted and then decrypted successfully');
}

await testThis({ name: path.basename(import.meta.url), fn: main });
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"commander": "^9.4.0",
"concurrently": "^7.4.0",
"core-js": "^3.6.5",
"cross-fetch": "^3.1.4",
"crypto-browserify": "^3.12.0",
"cypress-wait-until": "^1.7.2",
"cypress-watch-and-reload": "^1.10.3",
Expand All @@ -120,15 +121,12 @@
"find-config": "^1.0.0",
"g": "^2.0.1",
"https-browserify": "^1.0.0",
"ipfs-http-client": "56.0.0",
"ipfs-unixfs-importer": "^12.0.0",
"jose": "^4.14.4",
"jszip": "^3.10.1",
"micromodal": "^0.4.10",
"multiformats": "^9.7.1",
"nanoid": "3.3.4",
"next": "13.3.0",
"node-fetch": "^2.6.1",
"react": "18.0.0",
"react-dom": "18.0.0",
"regenerator-runtime": "0.13.7",
Expand All @@ -152,6 +150,8 @@
"@nx/jest": "17.3.0",
"@nx/js": "17.3.0",
"@nx/linter": "17.3.0",
"@nx/next": "17.3.0",
"@nx/node": "17.3.0",
"@nx/plugin": "17.3.0",
"@nx/react": "17.3.0",
"@nx/web": "17.3.0",
Expand Down Expand Up @@ -199,9 +199,7 @@
"ts-jest": "29.1.2",
"ts-node": "10.9.1",
"typedoc": "^0.23.10",
"typescript": "~4.7.2",
"@nx/next": "17.3.0",
"@nx/node": "17.3.0"
joshLong145 marked this conversation as resolved.
Show resolved Hide resolved
"typescript": "~4.7.2"
},
"workspaces": [
"packages/*"
Expand Down
4 changes: 0 additions & 4 deletions packages/auth-helpers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// ----- autogen:polyfills:start -----
//
// ----- autogen:polyfills:end -----

export * from './lib/models';
export * from './lib/session-capability-object';
export * from './lib/resources';
Expand Down
8 changes: 0 additions & 8 deletions packages/contracts-sdk/polyfills.js

This file was deleted.

4 changes: 0 additions & 4 deletions packages/contracts-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export * from './lib/contracts-sdk';
export * from './lib/addresses';
export * from './lib/utils';

// ----- autogen:polyfills:start -----
//
// ----- autogen:polyfills:end -----
Loading
Loading