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

@aptly-as/app-sdk

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aptly-as/app-sdk - npm Package Compare versions

Comparing version 0.4.0 to 1.0.0

2

dist/aptly/AptlyApi.d.ts

@@ -5,5 +5,7 @@ /// <reference types="node" />

export interface AptlyApiOAuth2Response {
token_type: 'bearer';
access_token: string;
expires_in: number;
refresh_token: string;
organization: string;
}

@@ -10,0 +12,0 @@ export declare class AptlyApi {

@@ -145,2 +145,10 @@ import { AptlyApiError, AptlyErrorCode } from '@aptly-as/types';

async getAccessToken(refresh_token = this.refresh_token) {
if (!refresh_token) {
throw new AptlyApiError({
status: '440',
code: AptlyErrorCode.SessionExpired,
title: 'refresh_token_required',
id: 'none',
});
}
const body = new URLSearchParams({

@@ -160,3 +168,9 @@ grant_type: 'refresh_token',

if (response.status !== 200) {
throw await response.json();
throw new AptlyApiError({
status: '440',
code: AptlyErrorCode.SessionExpired,
title: 'refresh_token_invalid',
detail: response.statusText,
id: 'none',
});
}

@@ -189,4 +203,4 @@ const data = (await response.json());

return false;
return new Date() >= new Date(this.appJWT.exp * 1000 - 100);
return new Date() <= new Date(this.appJWT.exp * 1000 - 100);
}
}

5

dist/AptlyOAuth2.d.ts

@@ -8,5 +8,3 @@ /// <reference types="node" />

code: string;
url: string;
organization: string;
app: string;
redirect_uri: string;
}

@@ -33,2 +31,3 @@ export interface IAptlyOAuth2Props {

verifyInstallCallback(url: string, query: URLSearchParams | string | Record<string, string | ReadonlyArray<string>> | Iterable<[string, string]> | ReadonlyArray<[string, string]> | NodeJS.Dict<string | string[]>): IAptlyAppRedirectSuccessProps;
installAppCode(code: string): Promise<AptlyApiOAuth2Response>;
authorizeAppCode(code: string): Promise<AptlyApiOAuth2Response>;

@@ -35,0 +34,0 @@ getAuthorizeRedirect(organization: string, path: string): string;

@@ -52,4 +52,9 @@ import jwt from 'jsonwebtoken';

const code = search.get('code') || '';
const redirect_uri = search.get('redirect_uri') || '';
search.delete('state');
search.delete('code');
search.delete('redirect_uri');
if (!redirect_uri.startsWith(this.APTLY_API_URL)) {
throw new Error('invalid_redirect_uri');
}
const callbackState = `${this.APP_API_URL}${plainUrl}?${search.toString()}`;

@@ -60,10 +65,19 @@ const decryptedState = this.crypto.aesDecrypt(state);

}
const verified = this.crypto.verifyCode(code, this.client_secret);
return {
url: `${this.url}/api/v1/organizations/${verified.organization}/apps/${verified.app}/install/complete`,
organization: verified.organization,
app: verified.app,
code,
};
return { redirect_uri, code };
}
async installAppCode(code) {
const response = await fetch(`${this.url}/api/apps/oauth2/token`, {
method: 'POST',
headers: new Headers({
Authorization: this.basicAuth(),
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
}),
body: new URLSearchParams({ grant_type: 'install_code', code }),
});
if (response.status !== 200) {
throw await response.json();
}
return (await response.json());
}
async authorizeAppCode(code) {

@@ -70,0 +84,0 @@ const response = await fetch(`${this.url}/api/apps/oauth2/token`, {

{
"name": "@aptly-as/app-sdk",
"version": "0.4.0",
"version": "1.0.0",
"description": "Aptly app SDK library for app communication and frontend development",

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

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