XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.21k stars 512 forks source link

Is "authorization" param working? #1017

Closed dmitryrn closed 5 years ago

dmitryrn commented 5 years ago

As I can see in docs https://github.com/ripple/ripple-lib/blob/develop/docs/index.md#parameters there is "authorization" param exist, but in source neither in .d.ts nor in .ts I can not see "authorization" param. Are docs outdated https://github.com/ripple/ripple-lib/blob/develop/src/api.ts#L76?

Can I use user:password auth with ws_public somehow?

intelliot commented 5 years ago

The type in the .d.ts / .ts file is missing the param. In addition to the APIOptions, the RippleAPI constructor also accepts ConnectionOptions:

export interface ConnectionOptions {
  trace?: boolean,
  proxy?: string
  proxyAuthorization?: string
  authorization?: string
  trustedCertificates?: string[]
  key?: string
  passphrase?: string
  certificate?: string
  timeout?: number
}

https://github.com/ripple/ripple-lib/blob/develop/src/common/connection.ts#L10

It should work if you set the "authorization" param. If using TypeScript, it may give you an error; I think you can work around that with type assertion: as APIOptions. I will look at fixing the type. Thanks for opening this issue!