Compare commits
4 Commits
@nhost/rea
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd4c54ee91 | ||
|
|
b30ff6f507 | ||
|
|
ff7ae21a87 | ||
|
|
6d2c7b26c0 |
@@ -39,10 +39,10 @@ HTTP endpoints are automatically generated based on the file structure under `fu
|
|||||||
As such, given this file structure:
|
As such, given this file structure:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
functions / index.js
|
functions/index.js
|
||||||
users / index.ts
|
functions/users/index.ts
|
||||||
active.ts
|
functions/active.ts
|
||||||
my - company.js
|
functions/my-company.js
|
||||||
```
|
```
|
||||||
|
|
||||||
The following endpoints will be available:
|
The following endpoints will be available:
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/hasura-storage-js
|
# @nhost/hasura-storage-js
|
||||||
|
|
||||||
|
## 0.1.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- ff7ae21: Introducing `setAdminSecret` to allow users of the SDK to use `x-hasura-admin-secret` request header in storage related functions
|
||||||
|
|
||||||
## 0.0.12
|
## 0.0.12
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/hasura-storage-js",
|
"name": "@nhost/hasura-storage-js",
|
||||||
"version": "0.0.12",
|
"version": "0.1.0",
|
||||||
"description": "Hasura-storage client",
|
"description": "Hasura-storage client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ import {
|
|||||||
ApiUploadResponse,
|
ApiUploadResponse,
|
||||||
UploadHeaders
|
UploadHeaders
|
||||||
} from './utils/types'
|
} from './utils/types'
|
||||||
|
|
||||||
export class HasuraStorageApi {
|
export class HasuraStorageApi {
|
||||||
private url: string
|
private url: string
|
||||||
private httpClient: AxiosInstance
|
private httpClient: AxiosInstance
|
||||||
private accessToken: string | undefined
|
private accessToken?: string
|
||||||
|
private adminSecret?: string
|
||||||
|
|
||||||
constructor({ url }: { url: string }) {
|
constructor({ url }: { url: string }) {
|
||||||
this.url = url
|
this.url = url
|
||||||
@@ -66,8 +68,28 @@ export class HasuraStorageApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setAccessToken(accessToken: string | undefined) {
|
/**
|
||||||
|
* Set the access token to use for authentication.
|
||||||
|
*
|
||||||
|
* @param accessToken Access token
|
||||||
|
* @returns Hasura Storage API instance
|
||||||
|
*/
|
||||||
|
setAccessToken(accessToken?: string): HasuraStorageApi {
|
||||||
this.accessToken = accessToken
|
this.accessToken = accessToken
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the admin secret to use for authentication.
|
||||||
|
*
|
||||||
|
* @param adminSecret Hasura admin secret
|
||||||
|
* @returns Hasura Storage API instance
|
||||||
|
*/
|
||||||
|
setAdminSecret(adminSecret?: string): HasuraStorageApi {
|
||||||
|
this.adminSecret = adminSecret
|
||||||
|
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
private generateUploadHeaders(params: ApiUploadParams): UploadHeaders {
|
private generateUploadHeaders(params: ApiUploadParams): UploadHeaders {
|
||||||
@@ -83,14 +105,21 @@ export class HasuraStorageApi {
|
|||||||
if (name) {
|
if (name) {
|
||||||
uploadheaders['x-nhost-file-name'] = name
|
uploadheaders['x-nhost-file-name'] = name
|
||||||
}
|
}
|
||||||
|
|
||||||
return uploadheaders
|
return uploadheaders
|
||||||
}
|
}
|
||||||
|
|
||||||
private generateAuthHeaders() {
|
private generateAuthHeaders() {
|
||||||
if (!this.accessToken) {
|
if (!this.adminSecret && !this.accessToken) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.adminSecret) {
|
||||||
|
return {
|
||||||
|
'x-hasura-admin-secret': this.adminSecret
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Authorization: `Bearer ${this.accessToken}`
|
Authorization: `Bearer ${this.accessToken}`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,27 @@ export class HasuraStorageClient {
|
|||||||
return { error: null }
|
return { error: null }
|
||||||
}
|
}
|
||||||
|
|
||||||
setAccessToken(accessToken: string | undefined): void {
|
/**
|
||||||
|
* Set the access token to use for authentication.
|
||||||
|
*
|
||||||
|
* @param accessToken Access token
|
||||||
|
* @returns Hasura Storage Client instance
|
||||||
|
*/
|
||||||
|
setAccessToken(accessToken?: string): HasuraStorageClient {
|
||||||
this.api.setAccessToken(accessToken)
|
this.api.setAccessToken(accessToken)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the admin secret to use for authentication.
|
||||||
|
*
|
||||||
|
* @param adminSecret Hasura admin secret
|
||||||
|
* @returns Hasura Storage Client instance
|
||||||
|
*/
|
||||||
|
setAdminSecret(adminSecret?: string): HasuraStorageClient {
|
||||||
|
this.api.setAdminSecret(adminSecret)
|
||||||
|
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @nhost/nhost-js
|
# @nhost/nhost-js
|
||||||
|
|
||||||
|
## 0.3.13
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [ff7ae21]
|
||||||
|
- @nhost/hasura-storage-js@0.1.0
|
||||||
|
|
||||||
## 0.3.12
|
## 0.3.12
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nhost-js",
|
"name": "@nhost/nhost-js",
|
||||||
"version": "0.3.12",
|
"version": "0.3.13",
|
||||||
"description": "Nhost JavaScript SDK",
|
"description": "Nhost JavaScript SDK",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/react-auth
|
# @nhost/react-auth
|
||||||
|
|
||||||
|
## 2.0.11
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@0.3.13
|
||||||
|
|
||||||
## 2.0.10
|
## 2.0.10
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-auth",
|
"name": "@nhost/react-auth",
|
||||||
"version": "2.0.10",
|
"version": "2.0.11",
|
||||||
"description": "Nhost React client",
|
"description": "Nhost React client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
Reference in New Issue
Block a user