UNPKG

@c15t/node-sdk

Version:

Official Node.js SDK for c15t. Connects to the Consent Engine to read and write consent records and preferences. TypeScript-first, simple APIs, built-in auth and retries.

54 lines (53 loc) 1.92 kB
"use strict"; var __webpack_require__ = {}; (()=>{ __webpack_require__.d = (exports1, definition)=>{ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, get: definition[key] }); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { c15tClient: ()=>c15tClient }); const contracts_namespaceObject = require("@c15t/backend/contracts"); const client_namespaceObject = require("@orpc/client"); const fetch_namespaceObject = require("@orpc/openapi-client/fetch"); function c15tClient(options) { const authHeaders = options.token ? { Authorization: `Bearer ${options.token}` } : {}; const baseUrl = new URL(options.baseUrl); if (options.prefix) baseUrl.pathname = options.prefix; const link = new fetch_namespaceObject.OpenAPILink(contracts_namespaceObject.contracts, { url: baseUrl.toString(), headers: { ...authHeaders, ...options.headers } }); return (0, client_namespaceObject.createORPCClient)(link); } exports.c15tClient = __webpack_exports__.c15tClient; for(var __webpack_i__ in __webpack_exports__)if (-1 === [ "c15tClient" ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; Object.defineProperty(exports, '__esModule', { value: true });