Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabotechs/signway-js-sdk
Create signed URLs for signway
https://github.com/gabotechs/signway-js-sdk
api sdk signed-url
Last synced: 29 days ago
JSON representation
Create signed URLs for signway
- Host: GitHub
- URL: https://github.com/gabotechs/signway-js-sdk
- Owner: gabotechs
- License: mit
- Created: 2023-06-11T15:16:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-12T10:23:33.000Z (about 1 year ago)
- Last Synced: 2024-04-24T09:09:01.054Z (7 months ago)
- Topics: api, sdk, signed-url
- Language: TypeScript
- Homepage: https://signway.io
- Size: 56.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Signway JS SDK
The Signway JS SDK enables you to generate signed URLs for the [Signway service](https://github.com/gabotechs/signway).
Signway facilitates a secure, direct request from a client-side application to a
third-party API without exposing sensitive credentials.# Install
To install the Signway JS SDK, run the following command:
```shell
npm install signway-sdk
```# Usage
```ts
import { signUrl } from "signway-sdk";console.log(signUrl({
/**
* The Application ID.
* It can be either a Signway managed Application ID (ex: ID0123ABCD...),
* or the ID provided when launching your own Signway instance (`$ signway `)
* ^
*/
id: process.env.SW_ID,
/**
* The Application Secret paired with the provided Application ID.
* It can be either a Signway managed Application Secret (ex: Gi8p1uZ39cg...),
* or the Secret provided when launching your own Signway instance (`$ signway `)
* ^
*/
secret: process.env.SW_SECRET,
/**
* The Signway host that will proxy the signed request.
* If you are using Signway managed, it should be "https://api.signway.io",
* otherwise, it should be the url where your own Signway instance is listening.
*/
host: "https://api.signway.io",
/**
* To which URL the request will be proxy-ed by the Signway host. This url
* will be embedded into your signed url as a query parameter, that way
* Signway will know where to proxy the request.
*/
proxyUrl: "https://api.openai.com/v1/completions",
/**
* The validity period of signed URL in seconds. Signway will reject the request
* if this number of seconds have happened since the signed URL was created.
*/
expiry: 10,
/**
* The method that will be used for performing the request through Signway.
* If a signed URL with a POST method is created, but when performing the
* HTTP query to Signway a GET method is used, the request will be rejected.
*/
method: "POST",
/**
* [Optional] headers to include in the signature. Any headers set here must
* also be included in the final HTTP request with the exact value provided here.
* Additional headers not present here can anyways be sent freely and Signway will
* not take them into account for validating the request's signature.
*/
headers: { 'Content-Type': 'application/json' },
/**
* [Optional] which body to include in the signature. If provided, the final
* HTTP request must include exactly this body, otherwise the Signway will reject
* the request. If not provided, the body will not be taken into account for
* calculating the signature, and consumers can freely send any body they want.
*/
body: `{
"model": "text-davinci-003",
"stream": true,
"prompt": "Say this is a test"
}`
}))
```