GithubHelp home page GithubHelp logo

js-sdk's People

Stargazers

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

Watchers

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

js-sdk's Issues

New CSRF strategy

We are currently working on changing CSFR strategy in the scope of https://procoretech.atlassian.net/browse/VM-525
Would it be possible to change csrf token definition method here lib/csrf.ts to take it from cookie? For example like this document.cookie.match('(^|;)\\s*csrf_token\\s*=\\s*([^;]+)') and decode it after like this decodeURIComponent(csrfTokenFromCookie). Else we need to implement it in every hydra client which is using js-sdk library.

Cors issues

G'day!

I'm running into some cors issues using the implicit grant flow described in the docs to talk to the procore api from a SPA client.

I've got the auth going fine, but when I make a request (say to projects) via procore.get(projects(..)),

I get the following

Failed to load https://sandbox.procore.com/vapid/projects: Response to preflight request doesn't pass 
access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' 
which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost' is 
therefore not allowed access.

It is the same on the sandbox and the production api.
It fails on the preflight and doesn't make the actual request.
Is there another header I must include? From what I can tell, it's expecting the response from procore to contain 'Access-Control-Allow-Credentials' : true in the headers.

It works fine with web security disabled as a runtime flag for chrome.

Allow empty body response for status 204

Problem

Currently the response parser calls response.json() to get the body from the Stream. If the response is empty (as is expect for status HTTP 204 No Content) calling .json() will throw the error Unexpected end of JSON input.

Current Workaround

Return empty [] or {} from the offending endpoint.

Proposed solution

We should skip the call to .json() for requests expected to return no data and either return null or {} for the body

https://github.com/procore/js-sdk/blob/master/lib/client.ts#L67

https://stackoverflow.com/questions/37280029/whatwg-fetch-fails-when-json-parsing-an-empty-response-how-can-i-prevent-it

running yarn endpoints throws an error

Failed to fetch and parse JSON for endpoint: line item types (cost types) failed at step: Fetch
(node:28395) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token < in JSON at position 0
(node:28395) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

what are the values of action parameter?

Hi,

I am trying to get list of projects from api but it seams in an action parameter is required but I couldn't figure out what are the possible values can be.

const { body } = await procore.get(
      projects({ action: "", qs: { company_id: process.env.COMPANY_ID } }),
    );

Issue with running yarn endpoints multiple times

Running yarn endpoints more than once seems to add the endpoints to index.ts regardless of whether they are already there leading to an error on yarn compile for duplicate declarations

lib/index.ts(9,21): error TS2300: Duplicate identifier 'projectRoles'.
lib/index.ts(10,21): error TS2300: Duplicate identifier 'me'.
lib/index.ts(11,21): error TS2300: Duplicate identifier 'programs'.
lib/index.ts(12,21): error TS2300: Duplicate identifier 'authentication'.

PHP

Is there a sample wrapper for PHP?

CORS block localhost

I am using Procore SDK to integrate authentication in our app using implicit grant type

here is the code sample call back code never be called

res.redirect(
      authorize(
        {
          clientId: process.env.PROCORE_CLIENT_ID,
          uri: process.env.PROCORE_REDIRECT_URI,
        },
        { apiHostname: 'https://login.procore.com' }
      )
    );
    
    const result = await token(
      {
        id: process.env.PROCORE_CLIENT_ID,
        uri: process.env.PROCORE_REDIRECT_URI,
        code: req.query.code,
      },
      { apiHostname: 'https://login.procore.com' }
    );

but I got this error

Access to fetch at 'https://login.procore.com/oauth/authorize?response_type=code&client_id=MyClientId&redirect_uri=https%3A%2F%2F333f-105-35-1-213.ngrok.io%2Fprocore%2Fcallback' (redirected from 'http://localhost:3000/procore/authProcoreUser') from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled

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.