Coder Social home page Coder Social logo

Oz.client.Connection in browser about oz HOT 6 CLOSED

outmoded avatar outmoded commented on July 19, 2024
Oz.client.Connection in browser

from oz.

Comments (6)

richardolsson avatar richardolsson commented on July 19, 2024 1

Thank you for your swift reply!

Maybe I'm missing something, but isn't Oz.client.Connection intended to help with the entire lifecycle, ticket reissue workflow, et c? Are you saying that should never happen in the browser, even for a client-side only application?

Other than the fact that app keys would not be secret in a browser app, I don't as of yet see why the entire workflow couldn't happen directly in the browser. Please help me understand.

from oz.

hueniverse avatar hueniverse commented on July 19, 2024

You don't need Oz.client in the browser. You just need to use the hawk browser code directly. I have no idea about using it with browerify. I would never try that.

from oz.

hueniverse avatar hueniverse commented on July 19, 2024

In theory it could, but it was written for node, not the browser. If you are going to use it in the browser, you are on your own. I don't use it on the browser, I have my own browser logic code to handle it which I cannot share because it's too integrated into our logic. We just use hawk directly.

from oz.

richardolsson avatar richardolsson commented on July 19, 2024

Thanks for the update. I'm thinking Oz.client.Connection would be very useful in any setting, including the browser.

Would you consider accepting a PR which solves this? Using the node http/https modules generally works fine with tools like Browserify, so I'm guessing the issue is somewhere in the way Wreck uses these modules, and could be remedied either by small changes to Wreck or using http/https directly in Oz.client.Connection.

from oz.

hueniverse avatar hueniverse commented on July 19, 2024

Probably not. I am not a fan of using browserify.

from oz.

AJamesPhillips avatar AJamesPhillips commented on July 19, 2024

@richardolsson the hawk package.json lists "browser" pointing to dist/browser.js. If you use require('oz/lib/client') in browser code with webpack, then dist/browser.js will be referenced as opposed to Hawk's lib/index.js with its lib/client.js.

The authenticate function signature in browser.js accepts 4 arguments and synchronously returns a boolean. The client.js authenticate accepts a 5th argument of a callback. Thus the callback is never being called:

const OzClient = require('oz/lib/client');
new OzClient.Connection({uri, credentials}).request("/protected", user_ticket, {}, (err, result, code, ticket) => {
    // never reached
});

That might be the problem you're experiencing? Anyway, if I can't iron (no pun intended ;) ) it out I will follow hueniverse's advice and build my own wrapper around hawk. Though as you also said it would be nice to avoid copy and pasting the work hueniverse has put into the client.Connection helper for client-side applications.

from oz.

Related Issues (20)

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.