From 443d032bc9869fcb1c858d1c87d922311843a37f Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Sat, 17 Nov 2018 15:05:56 -0500 Subject: [PATCH] generateheaders -> generateHeaders --- README.md | 28 +++++++++++++--------------- src/browser.test.ts | 4 ++-- src/browser.ts | 2 +- src/node.test.ts | 4 ++-- src/node.ts | 2 +- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 70e1447..0dc1820 100644 --- a/README.md +++ b/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 -``` js +```js import { generateSignature } from "cosmos-sign" -const masterKey = "< your master key here >"; -const method = "GET"; -const resourceId = ""; -const resourceType = ""; +const masterKey = "< your master key here >" +const method = "GET" +const resourceId = "" +const resourceType = "" -const result = generateSignature(masterKey, method, resourceType, resourceId); +const result = generateSignature(masterKey, method, resourceType, resourceId) ``` ## Generate a headers object instead -``` js +```js import { generateHeaders } from "cosmos-sign" -const masterKey = "< your master key here >"; -const method = "GET"; -const resourceId = ""; -const resourceType = ""; +const masterKey = "< your master key here >" +const method = "GET" +const resourceId = "" +const resourceType = "" -const headers = generateHeaders(masterKey, method, resourceType, resourceId); +const headers = generateHeaders(masterKey, method, resourceType, resourceId) console.log(headers) - fetch("https://your-db.cosmos.azure.com/", { headers }) - ``` ## Optionally pass a date in -``` js +```js import { generateSignature } from "cosmos-sign" const masterKey = "< your master key here >"; diff --git a/src/browser.test.ts b/src/browser.test.ts index c5ef43b..48e0cbe 100644 --- a/src/browser.test.ts +++ b/src/browser.test.ts @@ -1,5 +1,5 @@ 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 masterKey = @@ -25,7 +25,7 @@ const signature = generateSignature( date ) -const headers = generateheaders( +const headers = generateHeaders( masterKey, method, resourceType, diff --git a/src/browser.ts b/src/browser.ts index 714fe24..8676ea8 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -10,4 +10,4 @@ const hmac = (key: string, message: string) => { const signer = Signer(hmac) export const generateSignature = signer.signature -export const generateheaders = signer.headers +export const generateHeaders = signer.headers diff --git a/src/node.test.ts b/src/node.test.ts index 819dd4b..2e3b6cc 100644 --- a/src/node.test.ts +++ b/src/node.test.ts @@ -1,5 +1,5 @@ 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 masterKey = @@ -25,7 +25,7 @@ const signature = generateSignature( date ) -const headers = generateheaders( +const headers = generateHeaders( masterKey, method, resourceType, diff --git a/src/node.ts b/src/node.ts index 9f8ee5f..f9d5348 100644 --- a/src/node.ts +++ b/src/node.ts @@ -11,4 +11,4 @@ const signer = Signer(hmac) export const generateSignature = signer.signature -export const generateheaders = signer.headers +export const generateHeaders = signer.headers