New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@masa-finance/masa-sdk

Package Overview
Dependencies
Maintainers
4
Versions
375
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@masa-finance/masa-sdk - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

dist/src/account/createRandomWallet.d.ts

2

dist/package.json
{
"name": "@masa-finance/masa-sdk",
"version": "0.0.2",
"version": "0.0.3",
"description": "Brand new masa SDK",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

export { default as Masa } from "./masa";
export * from "./contracts";
export * from "./interface";

@@ -24,1 +24,2 @@ "use strict";

__exportStar(require("./contracts"), exports);
__exportStar(require("./interface"), exports);

@@ -1,2 +0,10 @@

export declare function getIdentity(): void;
export declare function mintIdentity(): void;
export interface IIdentity {
name: "Masa Soulbound Identity v1.0.0";
description: "A self-sovereign identity for accessing DeFi";
image: "https://metadata.masa.finance/v1.0/identity/masa-identity.png";
properties: {
tokenId: string;
account?: string;
soulName?: string;
};
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mintIdentity = exports.getIdentity = void 0;
function getIdentity() {
console.log("Identity");
}
exports.getIdentity = getIdentity;
function mintIdentity() {
console.log("Minting identity");
}
exports.mintIdentity = mintIdentity;

@@ -1,25 +0,64 @@

import { ethers } from "ethers";
import { BigNumber, ethers } from "ethers";
import MasaClient from "./utils/clients/middleware";
export default class Masa {
readonly client: MasaClient;
constructor({ provider, apiUrl, }: {
provider: ethers.providers.JsonRpcProvider;
readonly arweaveClient: import("arweave");
constructor({ cookie, wallet, apiUrl, environment, arweave: { host, port, protocol, logging }, }: {
cookie?: string;
wallet: ethers.Signer;
apiUrl: string;
environment: string;
arweave: {
host: string;
port: number;
protocol: string;
logging: boolean;
};
});
config: {
cookie?: string;
apiUrl: string;
environment: string;
network: string;
provider?: ethers.providers.JsonRpcProvider;
wallet: ethers.Signer;
};
session: {
checkLogin: () => Promise<boolean>;
sessionLogout: (cookie?: string) => Promise<any>;
login: (masa: Masa) => Promise<void>;
logout: (masa: Masa) => Promise<void>;
sessionLogout: () => Promise<any>;
login: () => Promise<{
address: string;
userId: any;
cookie: any;
} | undefined>;
logout: () => Promise<void>;
};
identity: {
loadIdentity: (masa: Masa, address: string) => Promise<ethers.BigNumber | undefined>;
loadIdentity: (address: string) => Promise<BigNumber | undefined>;
};
account: {
getBalances: (address: string) => Promise<{
ethBalance: BigNumber;
masaBalance: BigNumber;
usdcBalance: BigNumber;
wethBalance: BigNumber;
} | undefined>;
};
soulNames: {
loadSoulNamesFromIdentity: (identityId: BigNumber) => Promise<{
index: string;
tokenUri: string;
tokenDetails: [string, BigNumber, BigNumber, BigNumber, boolean] & {
sbtName: string;
identityId: BigNumber;
tokenId: BigNumber;
expirationDate: BigNumber;
active: boolean;
};
metadata: any;
}[]>;
};
metadata: {
metadataStore: (soulName: string) => Promise<any>;
getMetadata: (url: string) => Promise<any>;
patchMetadataUrl: (tokenUri: string) => string;
};
creditScore: {

@@ -38,5 +77,5 @@ creditScoreMint: (address: string, signature: string) => Promise<{

contracts: {
loadIdentityContracts: ({ provider, network, }: import("./contracts").LoadContractArgs) => Promise<import("./contracts").IIdentityContracts>;
loadIdentityContracts: () => Promise<import("./contracts").IIdentityContracts>;
addresses: import("./contracts").Addresses;
};
}

@@ -8,3 +8,2 @@ "use strict";

const check_login_1 = require("./session/check-login");
const load_identity_1 = require("./identity/load-identity");
const version_1 = require("./helpers/version");

@@ -14,4 +13,10 @@ const login_1 = require("./session/login");

const middleware_1 = __importDefault(require("./utils/clients/middleware"));
const arweave_1 = require("./utils/clients/arweave");
const loadSoulNamesFromIdentity_1 = require("./soul-name/loadSoulNamesFromIdentity");
const getBalances_1 = require("./account/getBalances");
const createRandomWallet_1 = require("./account/createRandomWallet");
const loadIdentity_1 = require("./identity/loadIdentity");
const patchMetadataUrl_1 = require("./helpers/patchMetadataUrl");
class Masa {
constructor({ provider, apiUrl, }) {
constructor({ cookie, wallet, apiUrl, environment, arweave: { host, port, protocol, logging }, }) {
this.config = {

@@ -21,14 +26,26 @@ apiUrl: "https://dev.middleware.masa.finance",

network: "goerli",
wallet: (0, createRandomWallet_1.createRandomWallet)(),
};
this.session = {
checkLogin: () => (0, check_login_1.checkLogin)(this),
sessionLogout: (cookie) => this.client.sessionLogout(cookie),
login: login_1.login,
logout: logout_1.logout,
sessionLogout: () => this.client.sessionLogout(),
login: () => (0, login_1.login)(this),
logout: () => (0, logout_1.logout)(this),
};
this.identity = {
loadIdentity: load_identity_1.loadIdentity,
loadIdentity: (address) => (0, loadIdentity_1.loadIdentity)(this, address),
};
this.account = {
getBalances: (address) => (0, getBalances_1.getBalances)(this, address),
};
this.soulNames = {
loadSoulNamesFromIdentity: (identityId) => (0, loadSoulNamesFromIdentity_1.loadSoulNamesFromIdentity)(this, identityId),
};
this.metadata = {
metadataStore: (soulName) => this.client.metadataStore(soulName),
getMetadata: (url) => this.client.getMetadata(url),
patchMetadataUrl: (tokenUri) => (0, patchMetadataUrl_1.patchMetadataUrl)(this, tokenUri),
};
this.creditScore = {
creditScoreMint: (address, signature) => this.client.creditScoreMint(address, signature, this.config.cookie),
creditScoreMint: (address, signature) => this.client.creditScoreMint(address, signature),
};

@@ -39,10 +56,23 @@ this.utils = {

this.contracts = {
loadIdentityContracts: contracts_1.loadIdentityContracts,
loadIdentityContracts: () => (0, contracts_1.loadIdentityContracts)({
provider: this.config.wallet.provider,
network: this.config.network,
}),
addresses: contracts_1.addresses,
};
this.client = new middleware_1.default({ apiUrl });
this.client = new middleware_1.default({
apiUrl,
cookie,
});
this.arweaveClient = (0, arweave_1.arweave)({
host,
port,
protocol,
logging,
});
this.config.wallet = wallet;
this.config.apiUrl = apiUrl;
this.config.provider = provider;
this.config.environment = environment;
}
}
exports.default = Masa;

@@ -13,5 +13,3 @@ "use strict";

exports.checkLogin = void 0;
const unpack_session_id_1 = require("../helpers/unpack-session-id");
const checkLogin = (masa) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
let loggedIn = false;

@@ -21,4 +19,3 @@ const checkSessionResponse = yield masa.client.sessionCheck();

console.log(`User ID: '${checkSessionResponse.user.userId}'`);
console.log(`Session ID: '${(0, unpack_session_id_1.unpackSessionId)(masa.config.cookie)}'`);
console.log(`Signer Address: '${yield ((_a = masa.config.provider) === null || _a === void 0 ? void 0 : _a.getSigner().getAddress())}'`);
console.log(`Signer Address: '${yield masa.config.wallet.getAddress()}'`);
console.log("\n");

@@ -25,0 +22,0 @@ loggedIn = true;

import Masa from "../masa";
export declare const login: (masa: Masa) => Promise<void>;
export declare const login: (masa: Masa) => Promise<{
address: string;
userId: any;
cookie: any;
} | undefined>;

@@ -14,5 +14,4 @@ "use strict";

const get_logintemplate_1 = require("./get-logintemplate");
const unpack_session_id_1 = require("../helpers/unpack-session-id");
const unpackSessionId_1 = require("../helpers/unpackSessionId");
const login = (masa) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
console.log("Logging in");

@@ -28,11 +27,8 @@ if (yield masa.session.checkLogin()) {

const msg = (0, get_logintemplate_1.getLoginTemplate)(challengeData.challenge, challengeData.expires);
const signer = yield ((_a = masa.config.provider) === null || _a === void 0 ? void 0 : _a.getSigner());
if (!signer)
return;
const address = yield signer.getAddress();
const address = yield masa.config.wallet.getAddress();
console.log(`Signer Address: '${address}'`);
console.log(`Signing: \n'${msg}'\n`);
const signature = yield signer.signMessage(msg);
const signature = yield masa.config.wallet.signMessage(msg);
console.log(`Signature: '${signature}'`);
const checkSignatureData = yield masa.client.checkSignature(address, signature, masa.config.cookie);
const checkSignatureData = yield masa.client.checkSignature(address, signature, challengeData.cookie);
if (checkSignatureData) {

@@ -42,5 +38,8 @@ console.log("\nLogged in as:");

console.log(`User ID: '${checkSignatureData.id}'`);
if (challengeData.cookie) {
console.log(`Session ID: '${(0, unpack_session_id_1.unpackSessionId)(challengeData.cookie)}'`);
}
console.log(`Session ID: '${(0, unpackSessionId_1.unpackSessionId)(challengeData.cookie)}'`);
return {
address,
userId: checkSignatureData.id,
cookie: challengeData.cookie,
};
}

@@ -47,0 +46,0 @@ }

import Arweave from "arweave";
export declare const arweave: (host: string, port: number, protocol: string, logging: boolean) => Arweave;
export declare const arweave: ({ host, port, protocol, logging, }: {
host: string;
port: number;
protocol: string;
logging: boolean;
}) => Arweave;

@@ -8,3 +8,3 @@ "use strict";

const arweave_1 = __importDefault(require("arweave"));
const arweave = (host, port, protocol, logging) => {
const arweave = ({ host, port, protocol, logging, }) => {
return arweave_1.default.init({

@@ -11,0 +11,0 @@ host,

export default class MasaClient {
private middlewareClient;
constructor({ apiUrl }: {
cookie?: string;
constructor({ apiUrl, cookie }: {
apiUrl: string;
cookie?: string;
});
sessionCheck: (cookie?: string) => Promise<any | undefined>;
getMetadata: (uri: string, cookie?: string) => Promise<any>;
metadataStore: (soulName: string, cookie?: string) => Promise<any | undefined>;
sessionCheck: () => Promise<any | undefined>;
getMetadata: (uri: string) => Promise<any>;
metadataStore: (soulName: string) => Promise<any | undefined>;
getChallenge: () => Promise<any | undefined>;
checkSignature: (address: string, signature: string, cookie?: string) => Promise<any | undefined>;
creditScoreMint: (address: string, signature: string, cookie?: string) => Promise<{
creditScoreMint: (address: string, signature: string) => Promise<{
success: any;
message: any;
} | undefined>;
sessionLogout: (cookie?: string) => Promise<any>;
sessionLogout: () => Promise<any>;
}

@@ -20,8 +20,8 @@ "use strict";

class MasaClient {
constructor({ apiUrl }) {
this.sessionCheck = (cookie) => __awaiter(this, void 0, void 0, function* () {
constructor({ apiUrl, cookie }) {
this.sessionCheck = () => __awaiter(this, void 0, void 0, function* () {
const checkResponse = yield this.middlewareClient
.get(`/session/check`, {
headers: {
cookie: cookie ? [cookie] : undefined,
cookie: this.cookie ? [this.cookie] : undefined,
},

@@ -37,6 +37,6 @@ })

});
this.getMetadata = (uri, cookie) => __awaiter(this, void 0, void 0, function* () {
this.getMetadata = (uri) => __awaiter(this, void 0, void 0, function* () {
const metadataResponse = yield this.middlewareClient.get(uri, {
headers: {
cookie: cookie ? [cookie] : undefined,
cookie: this.cookie ? [this.cookie] : undefined,
},

@@ -49,3 +49,3 @@ });

});
this.metadataStore = (soulName, cookie) => __awaiter(this, void 0, void 0, function* () {
this.metadataStore = (soulName) => __awaiter(this, void 0, void 0, function* () {
const storeMetadataResponse = yield this.middlewareClient

@@ -56,7 +56,7 @@ .post(`/storage/store`, {

headers: {
cookie: cookie ? [cookie] : undefined,
cookie: this.cookie ? [this.cookie] : undefined,
},
})
.catch((err) => {
console.error(err.message);
console.error("Storing metadata failed!", err.message);
});

@@ -72,3 +72,3 @@ if (storeMetadataResponse) {

.catch((err) => {
console.error(err.message);
console.error("Get Challenge failed!", err.message);
});

@@ -85,2 +85,3 @@ if (getChallengeResponse) {

this.checkSignature = (address, signature, cookie) => __awaiter(this, void 0, void 0, function* () {
const cookieToUse = cookie || this.cookie;
const checkSignatureResponse = yield this.middlewareClient

@@ -92,7 +93,7 @@ .post(`/session/check-signature`, {

headers: {
cookie: cookie ? [cookie] : undefined,
cookie: cookieToUse ? [cookieToUse] : undefined,
},
})
.catch((err) => {
console.error(err.message);
console.error("Check signature failed!", err.message);
});

@@ -104,3 +105,3 @@ if (checkSignatureResponse) {

});
this.creditScoreMint = (address, signature, cookie) => __awaiter(this, void 0, void 0, function* () {
this.creditScoreMint = (address, signature) => __awaiter(this, void 0, void 0, function* () {
const storeMetadataResponse = yield this.middlewareClient

@@ -112,3 +113,3 @@ .post(`/contracts/credit-score/mint`, {

headers: {
cookie: cookie ? [cookie] : undefined,
cookie: this.cookie ? [this.cookie] : undefined,
},

@@ -127,7 +128,7 @@ })

});
this.sessionLogout = (cookie) => __awaiter(this, void 0, void 0, function* () {
this.sessionLogout = () => __awaiter(this, void 0, void 0, function* () {
const logoutResponse = yield this.middlewareClient
.post(`/session/logout`, undefined, {
headers: {
cookie: cookie ? [cookie] : undefined,
cookie: this.cookie ? [this.cookie] : undefined,
},

@@ -143,2 +144,3 @@ })

});
this.cookie = cookie;
this.middlewareClient = axios_1.default.create({

@@ -145,0 +147,0 @@ baseURL: apiUrl,

{
"name": "@masa-finance/masa-sdk",
"version": "0.0.3",
"version": "0.0.4",
"description": "Brand new masa SDK",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc