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

@poap-xyz/providers

Package Overview
Dependencies
Maintainers
4
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poap-xyz/providers - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

dist/cjs/core/PoapMomentsApi/constants.d.ts

6

dist/cjs/core/PoapMomentsApi/PoapMomentsApi.d.ts
/// <reference types="node" />
import { MediaStatus } from './constants';
import { CreateMomentResponse } from './../../ports/MomentsApiProvider/Types/response';

@@ -13,6 +14,7 @@ import { CreateMomentInput } from './../../ports/MomentsApiProvider/Types/input';

}>;
uploadFile(file: Buffer, signedUrl: string): Promise<void>;
waitForMediaProcessing(mediaKey: string): Promise<void>;
uploadFile(file: Buffer, signedUrl: string, fileType: string): Promise<void>;
fetchMediaStatus(mediaKey: string): Promise<MediaStatus>;
waitForMediaProcessing(mediaKey: string, timeOut?: number): Promise<void>;
createMoment(input: CreateMomentInput): Promise<CreateMomentResponse>;
secureFetch(url: string, options: any): Promise<any>;
}

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

export { InvalidMediaFileError } from './core/PoapMomentsApi/errors/InvalidMediaFileError';
export { DropResponse } from './ports/DropApiProvider/Types/response';

@@ -2,0 +3,0 @@ export * from './ports';

@@ -9,4 +9,4 @@ /// <reference types="node" />

createMoment(input: CreateMomentInput): Promise<CreateMomentResponse>;
uploadFile(file: Buffer, signedUrl: string): Promise<void>;
waitForMediaProcessing(mediaKey: string): Promise<void>;
uploadFile(file: Buffer, signedUrl: string, fileType: string): Promise<void>;
waitForMediaProcessing(mediaKey: string, timeOut?: number): Promise<void>;
}
/// <reference types="node" />
import { MediaStatus } from './constants';
import { CreateMomentResponse } from './../../ports/MomentsApiProvider/Types/response';

@@ -13,6 +14,7 @@ import { CreateMomentInput } from './../../ports/MomentsApiProvider/Types/input';

}>;
uploadFile(file: Buffer, signedUrl: string): Promise<void>;
waitForMediaProcessing(mediaKey: string): Promise<void>;
uploadFile(file: Buffer, signedUrl: string, fileType: string): Promise<void>;
fetchMediaStatus(mediaKey: string): Promise<MediaStatus>;
waitForMediaProcessing(mediaKey: string, timeOut?: number): Promise<void>;
createMoment(input: CreateMomentInput): Promise<CreateMomentResponse>;
secureFetch(url: string, options: any): Promise<any>;
}

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

export { InvalidMediaFileError } from './core/PoapMomentsApi/errors/InvalidMediaFileError';
export { DropResponse } from './ports/DropApiProvider/Types/response';

@@ -2,0 +3,0 @@ export * from './ports';

@@ -9,4 +9,4 @@ /// <reference types="node" />

createMoment(input: CreateMomentInput): Promise<CreateMomentResponse>;
uploadFile(file: Buffer, signedUrl: string): Promise<void>;
waitForMediaProcessing(mediaKey: string): Promise<void>;
uploadFile(file: Buffer, signedUrl: string, fileType: string): Promise<void>;
waitForMediaProcessing(mediaKey: string, timeOut?: number): Promise<void>;
}
/// <reference types="node" />
import { MediaStatus } from './constants';
import { CreateMomentResponse } from './../../ports/MomentsApiProvider/Types/response';

@@ -13,6 +14,7 @@ import { CreateMomentInput } from './../../ports/MomentsApiProvider/Types/input';

}>;
uploadFile(file: Buffer, signedUrl: string): Promise<void>;
waitForMediaProcessing(mediaKey: string): Promise<void>;
uploadFile(file: Buffer, signedUrl: string, fileType: string): Promise<void>;
fetchMediaStatus(mediaKey: string): Promise<MediaStatus>;
waitForMediaProcessing(mediaKey: string, timeOut?: number): Promise<void>;
createMoment(input: CreateMomentInput): Promise<CreateMomentResponse>;
secureFetch(url: string, options: any): Promise<any>;
}

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

export { InvalidMediaFileError } from './core/PoapMomentsApi/errors/InvalidMediaFileError';
export { DropResponse } from './ports/DropApiProvider/Types/response';

@@ -2,0 +3,0 @@ export * from './ports';

@@ -7,2 +7,15 @@ (function (global, factory) {

class InvalidMediaFileError extends Error {
constructor() {
super(`InvalidMediaFile error: This media file is invalid or cannot be processed.`);
}
}
var MediaStatus;
(function (MediaStatus) {
MediaStatus["INVALID"] = "INVALID";
MediaStatus["PROCESSED"] = "PROCESSED";
MediaStatus["IN_PROCESS"] = "IN_PROCESS";
})(MediaStatus || (MediaStatus = {}));
const MOMENTS_BASE_URL = 'https://moments.poap.tech';

@@ -20,3 +33,3 @@ class PoapMomentsApi {

}
async uploadFile(file, signedUrl) {
async uploadFile(file, signedUrl, fileType) {
return await this.secureFetch(signedUrl, {

@@ -26,20 +39,36 @@ method: 'PUT',

headers: {
'Content-Type': 'application/octet-stream',
'Content-Type': fileType,
},
});
}
async waitForMediaProcessing(mediaKey) {
let status = 'IN_PROCESS';
await new Promise((resolve) => setTimeout(resolve, 2000));
while (status !== 'PROCESSED') {
try {
const response = await this.secureFetch(`${this.baseUrl}/media/${mediaKey}`, {
method: 'GET',
});
status = response.status;
async fetchMediaStatus(mediaKey) {
try {
const response = await this.secureFetch(`${this.baseUrl}/media/${mediaKey}`, {
method: 'GET',
});
return response.status;
}
catch (_a) {
return MediaStatus.IN_PROCESS;
}
}
async waitForMediaProcessing(mediaKey, timeOut = 60000) {
const delay = 2000;
const maxTries = timeOut / delay;
const checkStatus = async (tries) => {
if (tries >= maxTries) {
throw new Error('Exceeded maximum number of tries to check media processing status.');
}
catch (error) {
const status = await this.fetchMediaStatus(mediaKey);
if (status === MediaStatus.PROCESSED) {
return;
}
await new Promise((resolve) => setTimeout(resolve, 2000));
}
if (status === MediaStatus.INVALID) {
throw new InvalidMediaFileError();
}
await new Promise((resolve) => setTimeout(resolve, delay));
return checkStatus(tries + 1);
};
await new Promise((resolve) => setTimeout(resolve, delay));
return checkStatus(0);
}

@@ -190,2 +219,3 @@ async createMoment(input) {

exports.InvalidMediaFileError = InvalidMediaFileError;
exports.PoapCompass = PoapCompass;

@@ -192,0 +222,0 @@ exports.PoapDropApi = PoapDropApi;

@@ -9,4 +9,4 @@ /// <reference types="node" />

createMoment(input: CreateMomentInput): Promise<CreateMomentResponse>;
uploadFile(file: Buffer, signedUrl: string): Promise<void>;
waitForMediaProcessing(mediaKey: string): Promise<void>;
uploadFile(file: Buffer, signedUrl: string, fileType: string): Promise<void>;
waitForMediaProcessing(mediaKey: string, timeOut?: number): Promise<void>;
}
{
"name": "@poap-xyz/providers",
"version": "0.0.9",
"version": "0.0.10",
"description": "Providers module for the poap.js library",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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