Code Monkey home page Code Monkey logo

envato.js's People

Contributors

baileyherbert avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

envato.js's Issues

Exposing API token in the header?

When checking the network tab and viewing details I can see this info:

GET /v3/market/buyer/purchase?code=PURCHASE-CODE HTTP/2
Host: api.envato.com
User-Agent: Envato.js (https://github.com/baileyherbert/envato.js)
Referer: http://localhost/
authorization: Bearer MY-TOKEN-HERE
x-client: envato.js
Origin: http://localhost

as you can see the authorization part includes my API token MY-TOKEN-HERE , is this safe to expose it like this?

OAuth authorization issue

Hello Bailey!

I've got the error when using OAuth:

Authentication failed: OAuthError: Received an HTTP error
    at OAuth.<anonymous> (.../node_modules/envato/dist/clients/oauth.js:51:23)
    at Generator.next (<anonymous>)
    at fulfilled (.../node_modules/envato/dist/clients/oauth.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  http: BadRequestError: Bad Request
      at HttpClient._getHttpError (.../node_modules/envato/dist/helpers/http.js:111:30)
      at HttpClient.<anonymous> (.../node_modules/envato/dist/helpers/http.js:43:29)
      at Generator.next (<anonymous>)
      at fulfilled (.../node_modules/envato/dist/helpers/http.js:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {
    code: 400,
    response: {
      error: 'invalid_request',
      error_description: 'No authorization header passed'
    }
  }
}

Issue coming from line:

const client = await oauth.getClient(code);

from your example:

// This is an example express route to handle the request
app.get('/authenticate', async function(req, res) {
    try {
        // Fetch the code from the URL
        const code = req.query.code;

        // Authenticate the user via the API
    	const client = await oauth.getClient(code);
        const username = await client.private.getUsername();

        // You can also get their User ID for data storage
        const { userId } = await client.getIdentity();

        res.send(`Hello, ${username}!`);
    }
    catch (error) {
        console.error('Authentication failed:', error);
        res.status(500).send('Something broke! Try again.');
    }
});

My suggestion, how to fix it in attach:
Fix_for_OAuth_authorization_flow.patch.zip

Thanks in advance.

Looking up an invalid purchase code throws an error

Client.private.getSale โ€” If the code is incorrectly formatted, the API now returns an HTTP 422 error. It should catch the error and return undefined in this case, or better yet, check that the code is valid before sending it to the API.

HttpError: Unknown error
    at Client.handleResponse (C:\Users\Bailey\Downloads\envato-test\node_modules\envato\dist\client.js:188:40)
    at Request._callback (C:\Users\Bailey\Downloads\envato-test\node_modules\envato\dist\client.js:162:22)
    at Request.self.callback (C:\Users\Bailey\Downloads\envato-test\node_modules\request\request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (C:\Users\Bailey\Downloads\envato-test\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> (C:\Users\Bailey\Downloads\envato-test\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:421:28)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12) {
  code: 422,
  response: {
    error: 422,
    description: 'Purchase code provided with an invalid format'
  }
}

Ts fix

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/envato/dist/types/api.d.ts b/node_modules/envato/dist/types/api.d.ts
index b63775a..bc46f13 100644
--- a/node_modules/envato/dist/types/api.d.ts
+++ b/node_modules/envato/dist/types/api.d.ts
@@ -68,6 +68,12 @@ export interface Item {
         version: string;
         description: string;
     };
+    wordpress_plugin_metadata:{
+        plugin_name: string;
+        author_name: string;
+        version: string;
+        description: string;
+    },
     rating: number;
     rating_count: number;
     published_at: Date;
@@ -115,6 +121,7 @@ export interface Item {
         };
         live_site?: {
             url: string;
+            href:string
         };
         icon_preview?: {
             icon_url: string;

This issue body was partially generated by patch-package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.