@turnkey/http
Advanced tools
Comparing version 0.1.2 to 0.1.3
# @turnkey/http | ||
## 0.1.3 | ||
### Patch Changes | ||
- Support runtime config for credentials | ||
## 0.1.2 | ||
@@ -4,0 +10,0 @@ |
"use strict"; | ||
/* @generated by `@tkhq/fetchers`. DO NOT EDIT BY HAND */ | ||
/* @generated by `@turnkey/fetchers`. DO NOT EDIT BY HAND */ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
@@ -4,0 +4,0 @@ if (k2 === undefined) k2 = k; |
"use strict"; | ||
/* @generated by `@tkhq/fetchers`. DO NOT EDIT BY HAND */ | ||
/* @generated by `@turnkey/fetchers`. DO NOT EDIT BY HAND */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.postSignTransaction = exports.postSignMessage = exports.postDeleteUsers = exports.postDeletePolicy = exports.postDeleteInvitation = exports.postDeleteApiKeys = exports.postCreateUsers = exports.postCreatePolicy = exports.postCreateKeys = exports.postCreateInvitations = exports.postCreateApiKeys = exports.postGetWhoami = exports.postGetUsers = exports.postGetKeys = exports.postGetUser = exports.postGetOrganization = exports.postGetKey = exports.postGetActivity = void 0; | ||
exports.postGetKey = exports.postSignTransaction = exports.postSignMessage = exports.postDeleteUsers = exports.postDeletePolicy = exports.postDeleteInvitation = exports.postDeleteApiKeys = exports.postCreateUsers = exports.postCreatePolicy = exports.postCreateKeys = exports.postCreateInvitations = exports.postCreateApiKeys = exports.postGetWhoami = exports.postGetUsers = exports.postGetKeys = exports.postGetUser = exports.postGetOrganization = exports.postGetActivity = void 0; | ||
const base_1 = require("../../../../../base"); | ||
@@ -13,9 +13,2 @@ /** `POST /public/v1/query/get_activity` */ | ||
exports.postGetActivity = postGetActivity; | ||
/** `POST /public/v1/query/get_key` */ | ||
const postGetKey = (input) => (0, base_1.request)({ | ||
uri: "/public/v1/query/get_key", | ||
method: "POST", | ||
body: input.body, | ||
}); | ||
exports.postGetKey = postGetKey; | ||
/** `POST /public/v1/query/get_organization` */ | ||
@@ -133,2 +126,9 @@ const postGetOrganization = (input) => (0, base_1.request)({ | ||
exports.postSignTransaction = postSignTransaction; | ||
/** `POST /tkhq/public/v1/query/get_key` */ | ||
const postGetKey = (input) => (0, base_1.request)({ | ||
uri: "/tkhq/public/v1/query/get_key", | ||
method: "POST", | ||
body: input.body, | ||
}); | ||
exports.postGetKey = postGetKey; | ||
//# sourceMappingURL=public_api.fetcher.js.map |
@@ -10,6 +10,2 @@ /** | ||
}; | ||
"/public/v1/query/get_key": { | ||
/** Get details about a Private Key */ | ||
post: operations["PublicApiService_GetKey"]; | ||
}; | ||
"/public/v1/query/get_organization": { | ||
@@ -79,2 +75,6 @@ /** Get details about an Organization */ | ||
}; | ||
"/tkhq/public/v1/query/get_key": { | ||
/** Get details about a Private Key */ | ||
post: operations["PublicApiService_GetKey"]; | ||
}; | ||
}; | ||
@@ -815,28 +815,2 @@ export type definitions = { | ||
}; | ||
/** Get details about a Private Key */ | ||
PublicApiService_GetKey: { | ||
parameters: { | ||
body: { | ||
body: definitions["v1GetKeyRequest"]; | ||
}; | ||
}; | ||
responses: { | ||
/** A successful response. */ | ||
200: { | ||
schema: definitions["v1GetKeyResponse"]; | ||
}; | ||
/** Returned when the user does not have permission to access the resource. */ | ||
403: { | ||
schema: unknown; | ||
}; | ||
/** Returned when the resource does not exist. */ | ||
404: { | ||
schema: string; | ||
}; | ||
/** An unexpected error response. */ | ||
default: { | ||
schema: definitions["rpcStatus"]; | ||
}; | ||
}; | ||
}; | ||
/** Get details about an Organization */ | ||
@@ -1258,4 +1232,30 @@ PublicApiService_GetOrganization: { | ||
}; | ||
/** Get details about a Private Key */ | ||
PublicApiService_GetKey: { | ||
parameters: { | ||
body: { | ||
body: definitions["v1GetKeyRequest"]; | ||
}; | ||
}; | ||
responses: { | ||
/** A successful response. */ | ||
200: { | ||
schema: definitions["v1GetKeyResponse"]; | ||
}; | ||
/** Returned when the user does not have permission to access the resource. */ | ||
403: { | ||
schema: unknown; | ||
}; | ||
/** Returned when the resource does not exist. */ | ||
404: { | ||
schema: string; | ||
}; | ||
/** An unexpected error response. */ | ||
default: { | ||
schema: definitions["rpcStatus"]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
export type external = {}; | ||
//# sourceMappingURL=public_api.types.d.ts.map |
@@ -9,2 +9,3 @@ "use strict"; | ||
const stamp_1 = require("./stamp"); | ||
const config_1 = require("./config"); | ||
const sharedHeaders = {}; | ||
@@ -16,2 +17,3 @@ const sharedRequestOptions = { | ||
const { uri: inputUri, method, headers: inputHeaders = {}, query: inputQuery = {}, substitution: inputSubstitution = {}, body: inputBody = {}, } = input; | ||
const { apiPublicKey, apiPrivateKey } = (0, config_1.getConfig)(); | ||
const url = constructUrl({ | ||
@@ -22,9 +24,7 @@ uri: inputUri, | ||
}); | ||
const API_PUBLIC_KEY = assertNonEmptyString(process.env.API_PUBLIC_KEY, `process.env.API_PUBLIC_KEY`); | ||
const API_PRIVATE_KEY = assertNonEmptyString(process.env.API_PRIVATE_KEY, `process.env.API_PRIVATE_KEY`); | ||
const sealedBody = stableStringify(inputBody); | ||
const jsonStamp = Buffer.from(stableStringify((0, stamp_1.stamp)({ | ||
content: sealedBody, | ||
privateKey: API_PRIVATE_KEY, | ||
publicKey: API_PUBLIC_KEY, | ||
privateKey: apiPrivateKey, | ||
publicKey: apiPublicKey, | ||
}))); | ||
@@ -58,3 +58,3 @@ const response = await (0, node_fetch_1.default)(url.toString(), { | ||
const { uri, query, substitution } = input; | ||
const baseUrl = assertNonEmptyString(process.env.BASE_URL, `process.env.BASE_URL`); | ||
const { baseUrl } = (0, config_1.getConfig)(); | ||
const url = new URL(substitutePath(uri, substitution), baseUrl); | ||
@@ -94,8 +94,2 @@ for (const key in query) { | ||
exports.stableStringify = stableStringify; | ||
function assertNonEmptyString(input, name) { | ||
if (typeof input !== "string" || !input) { | ||
throw new Error(`Expected non empty string for "${name}", got ${input}`); | ||
} | ||
return input; | ||
} | ||
//# sourceMappingURL=base.js.map |
export * from "./__generated__/barrel"; | ||
export { init } from "./config"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -17,3 +17,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.init = void 0; | ||
__exportStar(require("./__generated__/barrel"), exports); | ||
var config_1 = require("./config"); | ||
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return config_1.init; } }); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@turnkey/http", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
# @turnkey/http | ||
[![npm](https://img.shields.io/npm/v/@turnkey/http?color=%234C48FF)](https://www.npmjs.com/package/@turnkey/http) | ||
Typed HTTP client for interacting with [Turnkey](https://turnkey.io) API. | ||
@@ -7,6 +9,25 @@ | ||
The runtime expects certain environment variables to be set: | ||
## Getting started | ||
- `process.env.BASE_URL` | ||
- `process.env.API_PUBLIC_KEY` | ||
- `process.env.API_PRIVATE_KEY` | ||
```bash | ||
$ npm install @turnkey/http | ||
``` | ||
Before making http calls, initialize the package with your credentials: | ||
```typescript | ||
import { PublicApiService, init } from "@turnkey/http"; | ||
init({ | ||
apiPublicKey: "...", | ||
apiPrivateKey: "...", | ||
baseUrl: "...", | ||
}); | ||
// Now you can make authenticated requests! | ||
const data = await PublicApiService.postGetWhoami({ | ||
body: { | ||
organizationId: "...", | ||
}, | ||
}); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
337186
32
6777
33
0