зеркало из https://github.com/Azure/cosmos-sign.git
generateheaders -> generateHeaders
This commit is contained in:
Родитель
5f1024a85a
Коммит
443d032bc9
28
README.md
28
README.md
|
@ -10,41 +10,39 @@ Utility library for signing Azure Cosmos tokens and generating headers. Works in
|
||||||
|
|
||||||
## Generate a signed header value using your master key
|
## Generate a signed header value using your master key
|
||||||
|
|
||||||
``` js
|
```js
|
||||||
import { generateSignature } from "cosmos-sign"
|
import { generateSignature } from "cosmos-sign"
|
||||||
|
|
||||||
const masterKey = "< your master key here >";
|
const masterKey = "< your master key here >"
|
||||||
const method = "GET";
|
const method = "GET"
|
||||||
const resourceId = "";
|
const resourceId = ""
|
||||||
const resourceType = "";
|
const resourceType = ""
|
||||||
|
|
||||||
const result = generateSignature(masterKey, method, resourceType, resourceId);
|
const result = generateSignature(masterKey, method, resourceType, resourceId)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Generate a headers object instead
|
## Generate a headers object instead
|
||||||
|
|
||||||
``` js
|
```js
|
||||||
import { generateHeaders } from "cosmos-sign"
|
import { generateHeaders } from "cosmos-sign"
|
||||||
|
|
||||||
const masterKey = "< your master key here >";
|
const masterKey = "< your master key here >"
|
||||||
const method = "GET";
|
const method = "GET"
|
||||||
const resourceId = "";
|
const resourceId = ""
|
||||||
const resourceType = "";
|
const resourceType = ""
|
||||||
|
|
||||||
const headers = generateHeaders(masterKey, method, resourceType, resourceId);
|
const headers = generateHeaders(masterKey, method, resourceType, resourceId)
|
||||||
|
|
||||||
console.log(headers)
|
console.log(headers)
|
||||||
|
|
||||||
|
|
||||||
fetch("https://your-db.cosmos.azure.com/", {
|
fetch("https://your-db.cosmos.azure.com/", {
|
||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Optionally pass a date in
|
## Optionally pass a date in
|
||||||
|
|
||||||
``` js
|
```js
|
||||||
import { generateSignature } from "cosmos-sign"
|
import { generateSignature } from "cosmos-sign"
|
||||||
|
|
||||||
const masterKey = "< your master key here >";
|
const masterKey = "< your master key here >";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import assert from "assert"
|
import assert from "assert"
|
||||||
import { generateSignature, generateheaders } from "./browser"
|
import { generateSignature, generateHeaders } from "./browser"
|
||||||
|
|
||||||
const date = new Date("Sat, 17 Nov 2018 01:06:05 GMT")
|
const date = new Date("Sat, 17 Nov 2018 01:06:05 GMT")
|
||||||
const masterKey =
|
const masterKey =
|
||||||
|
@ -25,7 +25,7 @@ const signature = generateSignature(
|
||||||
date
|
date
|
||||||
)
|
)
|
||||||
|
|
||||||
const headers = generateheaders(
|
const headers = generateHeaders(
|
||||||
masterKey,
|
masterKey,
|
||||||
method,
|
method,
|
||||||
resourceType,
|
resourceType,
|
||||||
|
|
|
@ -10,4 +10,4 @@ const hmac = (key: string, message: string) => {
|
||||||
const signer = Signer(hmac)
|
const signer = Signer(hmac)
|
||||||
|
|
||||||
export const generateSignature = signer.signature
|
export const generateSignature = signer.signature
|
||||||
export const generateheaders = signer.headers
|
export const generateHeaders = signer.headers
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import assert from "assert"
|
import assert from "assert"
|
||||||
import { generateSignature, generateheaders } from "./node"
|
import { generateSignature, generateHeaders } from "./node"
|
||||||
|
|
||||||
const date = new Date("Sat, 17 Nov 2018 01:06:05 GMT")
|
const date = new Date("Sat, 17 Nov 2018 01:06:05 GMT")
|
||||||
const masterKey =
|
const masterKey =
|
||||||
|
@ -25,7 +25,7 @@ const signature = generateSignature(
|
||||||
date
|
date
|
||||||
)
|
)
|
||||||
|
|
||||||
const headers = generateheaders(
|
const headers = generateHeaders(
|
||||||
masterKey,
|
masterKey,
|
||||||
method,
|
method,
|
||||||
resourceType,
|
resourceType,
|
||||||
|
|
|
@ -11,4 +11,4 @@ const signer = Signer(hmac)
|
||||||
|
|
||||||
export const generateSignature = signer.signature
|
export const generateSignature = signer.signature
|
||||||
|
|
||||||
export const generateheaders = signer.headers
|
export const generateHeaders = signer.headers
|
||||||
|
|
Загрузка…
Ссылка в новой задаче