Skip to content

Commit

Permalink
Migrated to new schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
baptistegreve committed Aug 22, 2022
1 parent 8f3ae93 commit af5ee4e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 104 deletions.
30 changes: 18 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const MAINNET_NODE_URL = "https://node1.orbis.club/";
const TESTNET_NODE_URL = "https://ceramic-clay.3boxlabs.com";

/** Set schemas Commit IDs */
const postSchemaStream = "kjzl6cwe1jw14b44gtfdmeyqi7oei5wv1721f352h0umfmb7k7eiihb3lurvtv8";
const postSchemaCommit = "k1dpgaqe3i64kjzmj5ruz0sjw9ux0i878xztjdm6c62burw0zf3ew7snpgak2gnzx51c3yzc2s01iq3chsbu4fdi7tsmwc3oox1v1p2kkrzccq736k37m6jzx";
const postSchemaStream = "kjzl6cwe1jw145vf8e3qu3bdm9o4wbe1x9tnq197re4knsywt0e9e8a49phe75n";
const postSchemaCommit = "k3y52l7qbv1frxlrgboamtzkwucrmtszxoluwp4xj6sgixa09aatet6vyd17oyw3k";

const channelSchemaStream = "kjzl6cwe1jw1481vk3z30owkij3665fa33b54b7wjw7v4csscrvfuurpv8xaikh";
const channelSchemaCommit = "k6zn3rc3v8qin14jvrfyxfhajtbjuqj1ae3v7cptbh4dp47lm9rrrta4bw26td7cvu2ixs5s9be21r6q0jn4i1eb7zvtz2ka3xt9059eochaq5a1ajobl16";
const channelSchemaStream = "kjzl6cwe1jw14aiqo5jzao1pb9vnw9zcaown9f524ohdb9wvm06zslvwtmjvqpp";
const channelSchemaCommit = "k3y52l7qbv1fryit9nri2zv040695xizbg145eznz5a3io6hsshdqjfmxeoddpyps";

const profileSchemaStream = "kjzl6cwe1jw147z3fd3tpwhnid3kroebsn9wimfawhcoe09thzudg43semys0dh";
const profileSchemaCommit = "k3y52l7qbv1fry0pkd977c71j6l5fothvvpif8fgtize5flxtryvzml6y03bb6nsw";
Expand Down Expand Up @@ -110,8 +110,9 @@ export class Orbis {

/** Step 2: Create an authProvider object using the address connected */
let authProvider;
let address = addresses[0].toLowerCase();
try {
authProvider = new EthereumAuthProvider(provider, addresses[0])
authProvider = new EthereumAuthProvider(provider, address)
} catch(e) {
return {
status: 300,
Expand Down Expand Up @@ -155,11 +156,11 @@ export class Orbis {

/** Step 5 (optional): Initialize the connection to Lit */
if(lit == true) {
let _userAuthSig = localStorage.getItem("lit-auth-signature-" + addresses[0]);
let _userAuthSig = localStorage.getItem("lit-auth-signature-" + address);
if(!_userAuthSig || _userAuthSig == "" || _userAuthSig == undefined) {
try {
/** Generate the signature for Lit */
let resLitSig = await generateLitSignature(provider, addresses[0]);
let resLitSig = await generateLitSignature(provider, address);
} catch(e) {
console.log("Error connecting to Lit network: " + e);
}
Expand Down Expand Up @@ -276,12 +277,17 @@ export class Orbis {
/** Step 3: Create a new session for this did */
let did;
try {
this.session = new DIDSession({ authProvider })

/** Expire session in 30 days by default */
const expirationDate = new Date(Date.now() + 60 * 60 * 24 * 30 * 1000)
const expirationString = expirationDate.toISOString()
did = await this.session.authorize({expirationTime: expirationString})
const oneMonth = 60 * 60 * 24 * 31;

this.session = await DIDSession.authorize(
authProvider,
{
resources: [`ceramic://*`],
expiresInSecs: oneMonth
}
);
did = this.session.did;
} catch(e) {
return {
status: 300,
Expand Down
93 changes: 3 additions & 90 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orbisclub/orbis-sdk",
"version": "0.2.98",
"version": "0.3.03",
"description": "Official package to implement quickly an Orbis powered decentralized social layer within your application.",
"author": "Baptiste Grève",
"license": "ISC",
Expand Down
6 changes: 5 additions & 1 deletion utils/lit-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function getAuthSig() {

/** Decrypt a string using Lit based on a set of inputs. */
export async function decryptString(encryptedContent) {
console.log("Enter decryptString");
/** Make sure Lit is ready before trying to decrypt the string */
await litIsReady();

Expand All @@ -91,6 +92,7 @@ export async function decryptString(encryptedContent) {
let decodedString;
try {
decodedString = decodeb64(encryptedContent.encryptedString);
console.log("decryptString(): decodedString:", decodedString);
} catch(e) {
console.log("Error decoding b64 string: ", e);
throw new Error(e);
Expand Down Expand Up @@ -120,7 +122,9 @@ export async function decryptString(encryptedContent) {

/** Decrypt the string using the encryption key */
try {
const decryptedString = await LitJsSdk.decryptString(new Blob([decodedString]), decryptedSymmKey);
let _blob = new Blob([decodedString]);
console.log("decryptString(): _blob:", _blob);
const decryptedString = await LitJsSdk.decryptString(_blob, decryptedSymmKey);
return {
status: 200,
result: decryptedString
Expand Down

0 comments on commit af5ee4e

Please sign in to comment.