Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ceramic-cacao

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ceramic-cacao - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

8

lib/cacao.d.ts

@@ -12,5 +12,5 @@ import * as multiformats from 'multiformats';

nonce: string;
iat: number;
nbf?: number;
exp?: number;
iat: string;
nbf?: string;
exp?: string;
statement?: string;

@@ -29,3 +29,3 @@ requestId?: string;

export declare type VerifyOptions = {
atTime?: number;
atTime?: number | string;
};

@@ -32,0 +32,0 @@ export declare namespace Cacao {

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

domain: siweMessage.domain,
iat: Date.parse(siweMessage.issuedAt),
iat: siweMessage.issuedAt,
iss: `did:pkh:eip155:${siweMessage.chainId}:${siweMessage.address}`,

@@ -59,6 +59,6 @@ aud: siweMessage.uri,

if (siweMessage.notBefore) {
cacao.p.nbf = Date.parse(siweMessage.notBefore);
cacao.p.nbf = siweMessage.notBefore;
}
if (siweMessage.expirationTime) {
cacao.p.exp = Date.parse(siweMessage.expirationTime);
cacao.p.exp = siweMessage.expirationTime;
}

@@ -89,7 +89,15 @@ if (siweMessage.statement) {

}
const atTime = options.atTime ? options.atTime : Date.now();
if (cacao.p.iat > atTime || cacao.p.nbf > atTime) {
let atTime = Date.now();
if (options.atTime) {
if (typeof options.atTime === 'string') {
atTime = Date.parse(options.atTime);
} else {
// Assuming options.atTime is a UNIX timestamp with seconds-precision
atTime = options.atTime * 1000;
}
}
if (Date.parse(cacao.p.iat) > atTime || Date.parse(cacao.p.nbf) > atTime) {
throw new Error(`CACAO is not valid yet`);
}
if (cacao.p.exp < atTime) {
if (Date.parse(cacao.p.exp) < atTime) {
throw new Error(`CACAO has expired`);

@@ -96,0 +104,0 @@ }

{
"name": "ceramic-cacao",
"version": "0.0.6",
"version": "0.0.7",
"description": "Typescript library for Ceramic OCAP",

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

Sorry, the diff of this file is not supported yet

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