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

@nylas/identity

Package Overview
Dependencies
Maintainers
8
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nylas/identity - npm Package Compare versions

Comparing version 2.0.0-canary.0 to 2.0.0-canary.1

6

CHANGELOG.md
# @nylas/identity
## 2.0.0-canary.1
### Patch Changes
- [#188](https://github.com/nylas/nylas/pull/188) [`436c634`](https://github.com/nylas/nylas/commit/436c63449488024649e41a9fbdc58736db089ce2) Thanks [@pooja169usp](https://github.com/pooja169usp)! - [nylas-scheduler-editor] Added better error handling for expired sessions
## 2.0.0-canary.0

@@ -4,0 +10,0 @@

48

cjs/app.js

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

return __awaiter(this, void 0, void 0, function () {
var access_token, response, responseData, error_1;
var grant, access_token, response, responseData, error_1;
return __generator(this, function (_a) {

@@ -112,3 +112,7 @@ switch (_a.label) {

case 1:
access_token = (_a.sent()).access_token;
grant = _a.sent();
if (!grant) {
return [2 /*return*/, false];
}
access_token = grant.access_token;
_a.label = 2;

@@ -141,3 +145,3 @@ case 2:

return __awaiter(this, void 0, void 0, function () {
var id_token, response, responseData, error_2;
var grant, id_token, response, responseData, error_2;
return __generator(this, function (_a) {

@@ -147,3 +151,7 @@ switch (_a.label) {

case 1:
id_token = (_a.sent()).id_token;
grant = _a.sent();
if (!grant) {
return [2 /*return*/, false];
}
id_token = grant.id_token;
_a.label = 2;

@@ -730,3 +738,3 @@ case 2:

return __awaiter(this, void 0, void 0, function () {
var refresh_token, payload, response, responseData, payload_4, now, isValidToken, payload_5, payload_6, error_4, payload;
var grant, refresh_token, payload, response, responseData, payload_4, now, isValidToken, payload_5, payload_6, error_4, payload;
return __generator(this, function (_a) {

@@ -736,3 +744,7 @@ switch (_a.label) {

case 1:
refresh_token = (_a.sent()).refresh_token;
grant = _a.sent();
if (!grant) {
return [2 /*return*/, false];
}
refresh_token = grant.refresh_token;
_a.label = 2;

@@ -892,5 +904,5 @@ case 2:

return __awaiter(this, void 0, void 0, function () {
var now, _a, access_token, expires_in, token, timeLeft, grant;
return __generator(this, function (_b) {
switch (_b.label) {
var now, grantResponse, access_token, expires_in, token, timeLeft, grant;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:

@@ -900,3 +912,7 @@ now = (0, helpers_1.getTimestamp)();

case 1:
_a = _b.sent(), access_token = _a.access_token, expires_in = _a.expires_in;
grantResponse = _a.sent();
if (!grantResponse) {
return [2 /*return*/, null];
}
access_token = grantResponse.access_token, expires_in = grantResponse.expires_in;
token = access_token;

@@ -914,6 +930,6 @@ if (token) {

case 2:
_b.sent();
_a.sent();
return [4 /*yield*/, this.Storage.getGrant(grant_id, this.multiAccount)];
case 3:
grant = _b.sent();
grant = _a.sent();
return [2 /*return*/, grant.access_token];

@@ -983,2 +999,5 @@ }

case 5:
if (!token) {
throw new Error("Access token not found");
}
headers = request.headers;

@@ -1038,5 +1057,6 @@ if (!Headers.prototype.isPrototypeOf(headers)) {

window.dispatchEvent(new CustomEvent("onSessionExpired", payload));
_a.label = 15;
case 15:
this.logout();
_a.label = 15;
case 15: return [2 /*return*/];
return [2 /*return*/];
case 16: return [2 /*return*/, responseData];

@@ -1043,0 +1063,0 @@ case 17:

{
"name": "@nylas/identity",
"version": "2.0.0-canary.0",
"version": "2.0.0-canary.1",
"description": "Nylas SDK for handling authentication and session management in browser and server",

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

@@ -61,7 +61,7 @@ import { Config, AuthConfig, IDToken, ProviderList } from "./@types";

public async validateAccessToken(grant_id: string = ""): Promise<boolean> {
const { access_token } = await this.Storage.getGrant(
grant_id,
this.multiAccount,
);
const grant = await this.Storage.getGrant(grant_id, this.multiAccount);
if (!grant) {
return false;
}
const { access_token } = grant;
try {

@@ -85,7 +85,7 @@ const response: any = await fetch(

public async validateIDToken(grant_id: string = ""): Promise<boolean> {
const { id_token } = await this.Storage.getGrant(
grant_id,
this.multiAccount,
);
const grant = await this.Storage.getGrant(grant_id, this.multiAccount);
if (!grant) {
return false;
}
const { id_token } = grant;
try {

@@ -516,6 +516,7 @@ const response: any = await fetch(

public async tokenExchange(grant_id: string = "") {
const { refresh_token } = await this.Storage.getGrant(
grant_id,
this.multiAccount,
);
const grant = await this.Storage.getGrant(grant_id, this.multiAccount);
if (!grant) {
return false;
}
const refresh_token = grant.refresh_token;
try {

@@ -646,6 +647,10 @@ const payload = {

const now = getTimestamp();
const { access_token, expires_in } = await this.Storage.getGrant(
const grantResponse = await this.Storage.getGrant(
grant_id,
this.multiAccount,
);
if (!grantResponse) {
return null;
}
const { access_token, expires_in } = grantResponse;
const token = access_token;

@@ -709,2 +714,6 @@ if (token) {

}
if (!token) {
throw new Error("Access token not found");
}
let headers = request.headers;

@@ -758,4 +767,4 @@ if (!Headers.prototype.isPrototypeOf(headers)) {

window.dispatchEvent(new CustomEvent("onSessionExpired", payload));
this.logout();
}
this.logout();
return;

@@ -762,0 +771,0 @@ }

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