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

calimero-auth-sdk

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calimero-auth-sdk - npm Package Compare versions

Comparing version 0.4.5 to 0.4.6

15

lib/index.d.ts

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

import * as nearAPI from "near-api-js";
export declare const MAX_CALIMERO_TOKEN_DURATION: number;

@@ -6,8 +7,5 @@ export declare class WalletData {

blockId: string;
publicKey: string;
signature: string;
keyType: string;
constructor(accId: string, message: string, blockId: string, pubKey: string, sig: string, keyType: string);
serialize(): string;
static deserialize(serialized: string): WalletData;
publicKey: nearAPI.utils.PublicKey;
signature: Uint8Array;
constructor(accId: string, message: string, blockId: string, pubKey: nearAPI.utils.PublicKey, sig: Uint8Array);
}

@@ -20,5 +18,2 @@ export declare class CalimeroTokenData {

constructor(accountId: string, shardId: string, from?: Date, to?: Date);
serialize(): string;
toHash(): string;
static deserialize(serialized: string): CalimeroTokenData;
isDurationValid(): boolean;

@@ -33,4 +28,2 @@ }

verify(): boolean;
serialize(): string;
static deserialize(serializedToken: string): CalimeroToken;
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CalimeroToken = exports.CalimeroTokenData = exports.WalletData = exports.MAX_CALIMERO_TOKEN_DURATION = void 0;
const nearAPI = __importStar(require("near-api-js"));
const js_sha256_1 = require("js-sha256");

@@ -37,4 +13,3 @@ //Max valid period for a token would be 30 days

signature;
keyType;
constructor(accId, message, blockId, pubKey, sig, keyType) {
constructor(accId, message, blockId, pubKey, sig) {
this.accountId = accId;

@@ -45,13 +20,3 @@ this.message = message;

this.signature = sig;
this.keyType = keyType;
}
serialize() {
const arr = Object.values(this);
return arr.join("..");
}
static deserialize(serialized) {
const objects = serialized.split("..");
const wd = new WalletData(objects[0], objects[1], objects[2], objects[3], objects[4], objects[5]);
return wd;
}
}

@@ -70,14 +35,2 @@ exports.WalletData = WalletData;

}
serialize() {
const ser = this.shardId + ".." + this.from.toISOString() + ".." + this.to.toISOString();
return ser;
}
toHash() {
return js_sha256_1.sha256.update(this.serialize()).toString();
}
static deserialize(serialized) {
const objects = serialized.split("..");
const ctd = new CalimeroTokenData(objects[0], objects[1], new Date(objects[1]), new Date(objects[2]));
return ctd;
}
isDurationValid() {

@@ -106,12 +59,7 @@ const isOrderRight = this.from < this.to;

blockId: this.walletData.blockId,
publicKey: this.walletData.publicKey,
keyType: this.walletData.keyType,
publicKey: Buffer.from(this.walletData.publicKey.data).toString('base64'),
keyType: this.walletData.publicKey.keyType,
};
const encoded = JSON.stringify(data);
const msg = new Uint8Array(Buffer.from(js_sha256_1.sha256.update(Buffer.from(encoded)).arrayBuffer()));
const sig = new Uint8Array(Buffer.from(this.walletData.signature, "base64"));
// const pk = nearAPI.utils.PublicKey(this.walletData.publicKey);
const pk = new nearAPI.utils.PublicKey({ keyType: 0, data: this.walletData.publicKey });
const trueMessage = this.tokenData.toHash() === this.walletData.message;
return trueMessage && pk.verify(msg, sig);
const encodedSignedData = JSON.stringify(data);
return this.walletData.publicKey.verify(new Uint8Array(js_sha256_1.sha256.update(Buffer.from(encodedSignedData)).arrayBuffer()), this.walletData.signature);
}

@@ -121,16 +69,2 @@ verify() {

}
serialize() {
return this.walletData.serialize() + "..." + this.tokenData.serialize();
}
static deserialize(serializedToken) {
const [walletDataString, tokenDataString] = serializedToken.split("...");
try {
const tokenData = CalimeroTokenData.deserialize(tokenDataString);
const walletData = WalletData.deserialize(walletDataString);
return new CalimeroToken(walletData, tokenData);
}
catch (e) {
throw Error("Scrambled token data");
}
}
}

@@ -137,0 +71,0 @@ exports.CalimeroToken = CalimeroToken;

{
"name": "calimero-auth-sdk",
"version": "0.4.5",
"version": "0.4.6",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "type": "commonjs",

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