eluv-io / elv-live-js

Eluvio Live JavaScript SDK
MIT License
4 stars 3 forks source link

add elv-live tenant_auth_curl #163

Closed elv-todd closed 9 months ago

elv-todd commented 9 months ago

we need this because these tenant auth tokens time out after 10 seconds, not enough time to copy-n-paste tokens, needs to be a single operation.

$ ./elv-live tenant_auth_curl
 tenant_auth_curl <url_path> [post_body]

Generate a tenant token and use it to call an authd endpoint.

Positionals:
  url_path   URL path                                                                                [string] [required]
  post_body  optional body; if set will POST, if not, will GET                                                  [string]

Options:
      --as_url   Alternate authority service URL (include '/as/' route if necessary)                            [string]

sample:

$ ./elv-live tenant_auth_curl /faucet/addOTP/iten4TXq2en3qtu3JREnE5tSLRf9zLod '{"tenant_id":"iten4TXq2en3qtu3JREnE5tSLRf9zLod","eth_amount":0.03}' --as_url http://localhost:8080/as
Network: demov3
curl -s -H "Authorization: Bearer ES256K_7MoEEbwCQyGoFv24FMKhz3mveCUrygk2wNuE3PQTYs2tTuP7LHKFaqpQGHH6Uif2kkfWcjN18BBcHcdxBJEbio3mV" http://localhost:8080/as/faucet/addOTP/iten4TXq2en3qtu3JREnE5tSLRf9zLod?ts=1705609696246 -d '{"tenant_id":"iten4TXq2en3qtu3JREnE5tSLRf9zLod","eth_amount":0.03}'
{"otp_id":"9OI47zMJPeVa","status":"success"}
elv-todd commented 9 months ago

(might be nicer to collapse the url prefix and path into one URL - is there a reason why separating them is more ergonomical? We can use the URL module to add the ts query param)

oh, yea -- we can just have the url prefix be defined by the network, plus allow --as_url override like that other commands for localhost ... that's better, changed it to that