Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
yarn-error.log
yarn-error.log
.yalc
53 changes: 53 additions & 0 deletions dist/ceramic.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { CeramicApi } from "@ceramicnetwork/common";
declare global {
interface Window {
ceramic?: CeramicApi;
[index: string]: any;
}
}
/**
* Authenticate for Lit + Ceramic.
* Creates a CeramicApi object on the ceramic testnet
*
* @returns {Promise<CeramicApi>} ceramicPromise pass in _createCeramic() promise
*/
export declare function _createCeramic(ceramicNodeUrl: string): Promise<CeramicApi>;
/**
* Authenticate for Lit + Ceramic.
* This uses a wallet provider to interact with the user's wallet
* Once the user has authorized, the address is retrieved and the
* decentralized identity is created. An IDX is also created for
* convenience.
*
* @param {Promise<CeramicApi>} ceramicPromise pass in _createCeramic() promise
* @returns {Promise<Array<any>>} Promise of ceramic IDX ID, ceramic object
* and user's ETH Address
*/
export declare function _authenticateCeramic(ceramicPromise: Promise<CeramicApi>): Promise<Array<any>>;
/**
* Write to Ceramic. This function takes in an auth and what one would
* like written and then sends it to a ceramic node in the proper format
* @param {any[]} auth is the authentication passed via the persons wallet
* @param {any[]} array of encrypted key, symkey, accessControlConditions, and chain
* @returns {Promise<string>} promise with the ceramic streamID, can be used to look up data
*/
export declare function _writeCeramic(auth: any[], toBeWritten: any[]): Promise<string>;
export declare function _updateCeramic(auth: any[], streamId: string, newContent: any[]): Promise<string>;
/**
* Read to Ceramic. This function takes in an auth and the streamID of the desired data and then sends it to a ceramic node in the proper format getting back a promised string of whatever was stored
*
* @param {any[]} auth is the authentication passed via the user's wallet
* @param {string} streamId ID hash of the stream
* @returns {Promise<string>} promise with the ceramic streamID's output
*/
export declare function _readCeramic(auth: any[], streamId: string): Promise<string>;
/**
* Decode info from base64. Data is stored in base64 to make upload to ceramic
* more seamless. This function decodes it so it can be decrypted with Lit in
* the next step in the read and decrypt process
*
* @param {string} response response received from ceramic streamID
* @returns {Promise<Array<any>} array of decrypted zip and symmetric key + AAC and chain
*/
export declare function _decodeFromB64(response: string): Promise<any[] | "There was an error decrypting, is it possible you inputted the wrong streamID?">;
//# sourceMappingURL=ceramic.d.ts.map
1 change: 1 addition & 0 deletions dist/ceramic.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ceramic.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ exports._updateCeramic = _updateCeramic;
* Read to Ceramic. This function takes in an auth and the streamID of the desired data and then sends it to a ceramic node in the proper format getting back a promised string of whatever was stored
*
* @param {any[]} auth is the authentication passed via the user's wallet
* @param {String} streamId ID hash of the stream
* @param {string} streamId ID hash of the stream
* @returns {Promise<string>} promise with the ceramic streamID's output
*/
function _readCeramic(auth, streamId) {
Expand Down
8 changes: 8 additions & 0 deletions dist/client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Starts Lit Client in background. should be run upon starting of project.
*
* @param {Window} window the window of the project, to which it attaches
* a litNodeClient
*/
export declare function _startLitClient(window: Window): Promise<void>;
//# sourceMappingURL=client.d.ts.map
1 change: 1 addition & 0 deletions dist/client.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 3 additions & 21 deletions dist/client.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand Down Expand Up @@ -56,7 +37,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports._startLitClient = void 0;
var LitJsSdk = __importStar(require("lit-js-sdk"));
// import * as LitJsSdk from "lit-js-sdk";
var lit_js_sdk_1 = require("lit-js-sdk");
/**
* Starts Lit Client in background. should be run upon starting of project.
*
Expand All @@ -68,7 +50,7 @@ function _startLitClient(window) {
var client;
return __generator(this, function (_a) {
console.log("Starting Lit Client...");
client = new LitJsSdk.LitNodeClient();
client = new lit_js_sdk_1.LitNodeClient();
client.connect();
window.litNodeClient = client;
return [2 /*return*/];
Expand Down
9 changes: 9 additions & 0 deletions dist/idx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { CeramicApi } from '@ceramicnetwork/common';
import { IDX } from '@ceramicstudio/idx';
declare global {
interface Window {
idx?: IDX;
}
}
export declare function createIDX(ceramic: CeramicApi): IDX;
//# sourceMappingURL=idx.d.ts.map
1 change: 1 addition & 0 deletions dist/idx.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Integration } from "./integration";
export { Integration };
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions dist/integration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { CeramicApi } from "@ceramicnetwork/common";
import type { DID } from "dids";
import { LitNodeClient } from "lit-js-sdk";
import { AllLitChainsKeys } from "lit-js-sdk/dist/types";
declare global {
interface Window {
did?: DID;
litNodeClient: LitNodeClient;
}
}
export declare class Integration {
ceramicPromise: Promise<CeramicApi>;
chain: AllLitChainsKeys;
constructor(ceramicNodeUrl?: string, chainParam?: AllLitChainsKeys);
startLitClient(window: Window): void;
/**
* Encrypts using Lit and then writes using Ceramic
* whatever the module user inputs (as long as it is a string for now)
*
* @param {string} toEncrypt what the module user wants to encrypt and store on ceramic
* @param {Array<Object>} accessControlConditions the access control conditions that govern who is able to decrypt this data. See the docs here for examples: https://developer.litprotocol.com/docs/SDK/accessControlConditionExamples
* @param {string} accessControlConditionType the access control condition type you are using. Pass `accessControlConditions` for traditional access control conditions. This is the default if you don't pass anything. Pass `evmContractConditions` for custom smart contract access control conditions
* @returns {Promise<string>} A promise that resolves to a streamID for the encrypted data that's been stored
*/
encryptAndWrite(toEncrypt: string, accessControlConditions: Array<Object>, accessControlConditionType?: string): Promise<string>;
/**
* Retrieves a stream and decrypts message then returns to user
*
* @param {string} streamID the streamID of the encrypted data the user wants to access
* @returns {Promise<string>} A promise that resolves to the unencrypted string of what was stored
*/
readAndDecrypt(streamID: string): Promise<any>;
/**
* Retrieves a stream and decrypts message then returns to user
*
* @param {string} streamID the streamID of the encrypted data that you want to update the access control conditions for
* @param {Array<Object>} accessControlConditions the access control conditions that govern who is able to decrypt this data. Note that you cannot change the accessControlConditionType using this method, and you must use the same condition type that was used when you ran encryptAndWrite. See the docs here for examples of accessControlConditions: https://developer.litprotocol.com/docs/SDK/accessControlConditionExamples
* @returns {Promise<string>} A promise that resolves to the unencrypted string of what was stored
*/
updateAccess(streamID: string, newAccessControlConditions: Array<Object>): Promise<any>;
}
//# sourceMappingURL=integration.d.ts.map
1 change: 1 addition & 0 deletions dist/integration.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions dist/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ var Integration = /** @class */ (function () {
* Encrypts using Lit and then writes using Ceramic
* whatever the module user inputs (as long as it is a string for now)
*
* @param {String} toEncrypt what the module user wants to encrypt and store on ceramic
* @param {string} toEncrypt what the module user wants to encrypt and store on ceramic
* @param {Array<Object>} accessControlConditions the access control conditions that govern who is able to decrypt this data. See the docs here for examples: https://developer.litprotocol.com/docs/SDK/accessControlConditionExamples
* @param {String} accessControlConditionType the access control condition type you are using. Pass `accessControlConditions` for traditional access control conditions. This is the default if you don't pass anything. Pass `evmContractConditions` for custom smart contract access control conditions
* @returns {Promise<String>} A promise that resolves to a streamID for the encrypted data that's been stored
* @param {string} accessControlConditionType the access control condition type you are using. Pass `accessControlConditions` for traditional access control conditions. This is the default if you don't pass anything. Pass `evmContractConditions` for custom smart contract access control conditions
* @returns {Promise<string>} A promise that resolves to a streamID for the encrypted data that's been stored
*/
Integration.prototype.encryptAndWrite = function (toEncrypt, accessControlConditions, accessControlConditionType) {
if (accessControlConditionType === void 0) { accessControlConditionType = "accessControlConditions"; }
Expand Down Expand Up @@ -95,8 +95,8 @@ var Integration = /** @class */ (function () {
/**
* Retrieves a stream and decrypts message then returns to user
*
* @param {String} streamID the streamID of the encrypted data the user wants to access
* @returns {Promise<String>} A promise that resolves to the unencrypted string of what was stored
* @param {string} streamID the streamID of the encrypted data the user wants to access
* @returns {Promise<string>} A promise that resolves to the unencrypted string of what was stored
*/
Integration.prototype.readAndDecrypt = function (streamID) {
return __awaiter(this, void 0, void 0, function () {
Expand Down Expand Up @@ -133,9 +133,9 @@ var Integration = /** @class */ (function () {
/**
* Retrieves a stream and decrypts message then returns to user
*
* @param {String} streamID the streamID of the encrypted data that you want to update the access control conditions for
* @param {string} streamID the streamID of the encrypted data that you want to update the access control conditions for
* @param {Array<Object>} accessControlConditions the access control conditions that govern who is able to decrypt this data. Note that you cannot change the accessControlConditionType using this method, and you must use the same condition type that was used when you ran encryptAndWrite. See the docs here for examples of accessControlConditions: https://developer.litprotocol.com/docs/SDK/accessControlConditionExamples
* @returns {Promise<String>} A promise that resolves to the unencrypted string of what was stored
* @returns {Promise<string>} A promise that resolves to the unencrypted string of what was stored
*/
Integration.prototype.updateAccess = function (streamID, newAccessControlConditions) {
return __awaiter(this, void 0, void 0, function () {
Expand Down
45 changes: 45 additions & 0 deletions dist/lit.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { AllLitChainsKeys } from "lit-js-sdk/dist/types";
/**
* This function encodes into base 64.
* it's useful for storing symkeys and files in ceramic
* @param {Uint8Array} input a file or any data
* @returns {string} returns a string of b64
*/
export declare function encodeb64(uintarray: any): string;
/**
* This function converts blobs to base 64.
* for easier storage in ceramic
* @param {Blob} blob what you'd like to encode
* @returns {Promise<string>} returns a string of b64
*/
export declare function blobToBase64(blob: Blob): Promise<unknown>;
/**
* This function decodes from base 64.
* it's useful for decrypting symkeys and files in ceramic
* @param {blob} input a b64 string
* @returns {string} returns the data as a string
*/
export declare function decodeb64(b64String: any): Uint8Array;
/**
* encrypts a message with Lit returns required details
* this obfuscates data such that it can be stored on ceramic without
* non-permissioned eyes seeing what the data is
* @param {string} aStringThatYouWishToEncrypt the clear text you'd like encrypted
* @param {Array<Object>} accessControlConditions the access control conditions that govern who is able to decrypt this data. See the docs here for examples: https://developer.litprotocol.com/docs/SDK/accessControlConditionExamples
* @param {string} chain the chain you'd like to use for checking the access control conditions
* @param {string} accessControlConditionType the access control condition type you are using. Pass `accessControlConditions` for traditional access control conditions. This is the default if you don't pass anything. Pass `evmContractConditions` for custom smart contract access control conditions
* @returns {Promise<Array<any>>} returns, in this order: encryptedZipBase64, encryptedSymmetricKeyBase64, accessControlConditions, chain
*/
export declare function _encryptWithLit(aStringThatYouWishToEncrypt: string, accessControlConditions: Array<Object>, chain: AllLitChainsKeys, accessControlConditionType?: string): Promise<Array<any>>;
/**
* decrypt encrypted zip and symmetric key using the lit protocol
* @param {Uint8Array} encryptedZip encrypted data that will be converted into a string
* @param {Uint8Array} encryptedSymmKey symmetric key
* @param {Array<any>} accessControlConditions conditions that determine access
* @param {string} chain the chain you'd like to use for checking the access control conditions
* @param {string} accessControlConditionType the access control condition type you are using. Pass `accessControlConditions` for traditional access control conditions. This is the default if you don't pass anything. Pass `evmContractConditions` for custom smart contract access control conditions
* @returns {Promise<string>} promise with the decrypted string
*/
export declare function _decryptWithLit(encryptedZip: Uint8Array, encryptedSymmKey: Uint8Array, accessControlConditions: Array<any>, chain: AllLitChainsKeys, accessControlConditionType?: string): Promise<string>;
export declare function _saveEncryptionKey(newAccessControlConditions: Array<any>, encryptedSymmetricKey: Uint8Array, chain: AllLitChainsKeys): Promise<string>;
//# sourceMappingURL=lit.d.ts.map
1 change: 1 addition & 0 deletions dist/lit.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading