@aptly-as/app-sdk
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -23,3 +23,3 @@ /// <reference types="node" /> | ||
delete<T>(path: string, init?: Omit<RequestInit, 'body' | 'method'>): Promise<T>; | ||
downloadDocument(urlOrToken: string): Promise<{ | ||
downloadDocumentWithToken(downloadToken: string): Promise<{ | ||
buffer: Buffer; | ||
@@ -29,2 +29,7 @@ filename: string; | ||
}>; | ||
downloadDocument(path: string): Promise<{ | ||
buffer: Buffer; | ||
filename: string; | ||
contentType: string; | ||
}>; | ||
fetchJSON<T>(path: string, init?: RequestInit): Promise<T>; | ||
@@ -31,0 +36,0 @@ fetch(path: string, init?: RequestInit): Promise<Response>; |
@@ -38,6 +38,10 @@ import { AptlyApiError, AptlyErrorCode } from '@aptly-as/types'; | ||
} | ||
async downloadDocument(urlOrToken) { | ||
async downloadDocumentWithToken(downloadToken) { | ||
return this.downloadDocument(`/documents/${downloadToken}`); | ||
} | ||
async downloadDocument(path) { | ||
try { | ||
const documentUrl = urlOrToken.startsWith('http') ? urlOrToken : `${this.url}/documents/${urlOrToken}`; | ||
const response = await fetch(documentUrl); | ||
const response = await (path.startsWith('http') | ||
? fetch(path) | ||
: this.fetch(path)); | ||
if (response.status !== 200) { | ||
@@ -110,3 +114,4 @@ throw new AptlyApiError({ | ||
} | ||
response = await fetch(`${this.url}/${path}`, { | ||
const url = path.startsWith('http') ? path : `${this.url}/${path}`; | ||
response = await fetch(url, { | ||
headers: this.getJSONHeaders(init), | ||
@@ -113,0 +118,0 @@ ...init, |
@@ -35,2 +35,3 @@ /// <reference types="node" /> | ||
getAuthorizeRedirect(organization: string, path: string): string; | ||
getReinstallRedirect(organization: string): string; | ||
validateAuthorizeCode(code: string): AptlyAppAuthorizeCode; | ||
@@ -37,0 +38,0 @@ verifyToken(token: string): AptlyAppAuthorizeToken; |
@@ -88,2 +88,5 @@ import jwt from 'jsonwebtoken'; | ||
} | ||
getReinstallRedirect(organization) { | ||
return `${this.url}/api/v1/organizations/${organization}/apps/${this.client_id}/install`; | ||
} | ||
validateAuthorizeCode(code) { | ||
@@ -90,0 +93,0 @@ return this.crypto.verifyCode(this.client_id, code, this.client_secret); |
{ | ||
"name": "@aptly-as/app-sdk", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Aptly app SDK library for app communication and frontend development", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32183
807