{"bugs":{"url":"https://github.com/clerkinc/javascript/issues"},"dist":{"shasum":"25424616464f39aa24f2a2b468b63b46fa56b099","tarball":"https://registry.npmjs.org/@clerk/backend-core/-/backend-core-1.0.1-alpha.0.tgz","fileCount":461,"integrity":"sha512-PU8N4yAKAQlVsT2X8X+QzomdDzXKzP462qjSixPNaTW/p04wT5dxgBR9TmXzPwHKVQhbUPFKZzMkJBCa+WFDFQ==","signatures":[{"sig":"MEUCIQDE7xVDq5lGH7kaEi0HjpYF61V9Ztwo1UPfudiyEdidVwIgEB+FUH3/FFdmEON2C+gCpwIJdMzm3wMFR9lFF0SaWFg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":573339,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiO66+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqFtg//VU4MkSWhD5pb6lsNSxhuqXzueGW1t4a39co/7XJ2uqrlVQcN\r\naoF3vv7gIBP9Z0RVJa70fqkwqodgonTXZQVzh9LUPS/an20J+Ke/4b8wXyRD\r\nk5L0M1e25pcJt8hucwMOY2bmYJjAzvpsuV2Ot7OTOlIBn8x2hezKH5hEKJFc\r\nKO4IkCjWqdwmCXzjnYHAdGKdhzBO4Pn181XS6tlth4UunOovfp5U6CNR/C8B\r\nDPdWQ2+YLm3cPcNYiSSykZe9t3/0Y5Hc8ab9yeGR+M4dpE42Pi+wIgnBturj\r\nEHlfwiC4louQFEA/FLI1FL+82L3FvZ76DHC/E4ZzVyADM0a86b1q0QhlrkVV\r\n2ESm1SgkAYYUdxh9ePYgWeZ0h0E8NpL6at0xQr2M/wjd0OsiW9zIeCn8npj1\r\n6C0ymFkcglHFLbbx9AycztfWUy1IpaWrfxPB/S3KawnXEpkWv+b5/zXdyf+t\r\nrau0EafuQ4lJm4sqy7AP1TP9TtrwUCe1gJgNA5CXAWB4aNw/kgwA8vtrs8zM\r\nH2UIbwkXtiXwrVKFw+zjXxWC+GMgRr1bH970n821VtYevdNuykZhXbbiVuJv\r\n04k84CrIGFkxJaWbW/fxsC3BKgMQvkrylxCV80KMVfmMjHPCXom+6t7jKZOO\r\nvmNUUHgVrsCEOsKOJTjbFhp6VPFbVyP1NeI=\r\n=e9L+\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/cjs/index.js","name":"@clerk/backend-core","type":"module","module":"dist/mjs/index.js","readme":"<p align=\"center\">\n  <a href=\"https://clerk.dev/\" target=\"_blank\" align=\"center\">\n    <img src=\"https://images.clerk.dev/static/clerk.svg\" height=\"50\">\n  </a>\n  <br />\n</p>\n\n# Clerk Backend Core SDK\n\n_Clerk Backend API core resources and authentication utilities for JavaScript environments._\n\n```diff\n! This package provides low-level utilities and is mostly used as the base for other Clerk SDKs.\n```\n\n## Usage\n\n```sh\nnpm install @clerk/backend-core\n# or\nyarn add @clerk/backend-core\n```\n\n## Architecture\n\n`@clerk/backend-core` contains all the logic for basic Clerk functionalities such as:\n\n- Determining the authentication state of a session.\n- Validating a Clerk token state.\n- Clerk API resource management.\n\nwithout being platform/environment specific.\n\n### How it works\n\nThis package is used as the base building block for Clerk JavaScript SDKs and environments. This is achieved by providing all the required business logic if only a few environment-specific utilities are implemented by the client.\n\n<p align=\"center\">\n  <a href=\"https://clerk.dev/\" target=\"_blank\" align=\"center\">\n    <img src=\"https://images.clerk.dev/static/backend_api_architecture.png\" height=\"350\">\n  </a>\n  <br />\n</p>\n\nIn essence, the client should supply these key functions in the Clerk [Base](./src/Base.ts#47) and [ClerkBackendAPI](./src/api/ClerkBackendAPI.ts) classes:\n\n1. Public key import `importKeyFunction`.\n2. JWT signature verification `verifySignatureFunction`.\n3. Base64 decoding `decodeBase64Function`.\n4. HTTP fetching utility for the API resource management `ClerkFetcher`.\n\nAfter supplying those in the `Base` and `ClerkBackendAPI` classes, you can use all the Clerk utilities required for the SDK business logic.\n\n### Creating a Base for a new SDK\n\n```ts\nconst importKey = async (jwk: JsonWebKey, algorithm: Algorithm) => {\n  //  ...\n};\n\nconst verifySignature = async (algorithm: Algorithm, key: CryptoKey, signature: Uint8Array, data: Uint8Array) => {\n  // ...\n};\n\nconst decodeBase64 = (base64: string) => {\n  // ...\n};\n\n/** Base initialization */\n\nconst examplePlatformBase = new Base(importKey, verifySignature, decodeBase64);\n```\n\nAfter creating the `Base` instance you can use core functions such as:\n\n```ts\nexamplePlatformBase.verifySessionToken(...);\n\nexamplePlatformBase.getAuthState(...);\n```\n\nThe `Base` utilities include the building blocks for developing any extra logic and middleware required for the target platform.\n\n### Validate the Authorized Party of a session token\n\nClerk's JWT session token, contains the azp claim, which equals the Origin of the request during token generation. You can provide a list of whitelisted origins to verify against, during every token verification, to protect your application of the subdomain cookie leaking attack. You can find an example below:\n\n```ts\nconst authorizedParties = ['http://localhost:3000', 'https://example.com'];\n\nexamplePlatformBase.verifySessionToken(token > { authorizedParties });\n```\n\n### Clerk API Resources\n\nAPI resource management is also provided by this package through the [ClerkBackendAPI](./src/api/ClerkBackendAPI.ts) class. For more information on the API resources you can checkout the [resource documentation page](https://docs.clerk.dev/reference/backend-api-reference).\n\nTo use the Clerk Backend API wrapper in any JavaScript platform, you would need to provide some specific SDK information and an HTTP fetching utility. See more at the [ClerkBackendAPIProps](./src/api/ClerkBackendAPI.ts#17) implementation.\n","gitHead":"ac871c42455fe7c0ccef8d487c8352d654ea7f29","license":"MIT","scripts":{"dev":"tsc -p tsconfig.esm.json --watch","test":"jest","build":"tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && ./moduleTypeFix"},"_npmUser":{"name":"nikosdouvlis","email":"nikosdouvlis@gmail.com"},"homepage":"https://clerk.dev/","deprecated":"This package has been deprecated - use @clerk/backend instead","repository":{"url":"git+https://github.com/clerkinc/javascript.git","type":"git"},"_npmVersion":"lerna/4.0.0/node@v16.14.2+arm64 (darwin)","description":"Clerk Backend API core resources and authentication utilities for JavaScript environments.","directories":{},"maintainers":[{"name":"giannis-clerk","email":"giannis@clerk.dev"},{"name":"igneel64","email":"p.perlepes@gmail.com"},{"name":"chanioxaris","email":"haris@clerk.dev"},{"name":"agis-clerk","email":"agis@clerk.dev"},{"name":"colinclerk","email":"colin@clerk.dev"},{"name":"bradenclerk","email":"braden@clerk.dev"},{"name":"sokratis","email":"sokratis.vidros@gmail.com"},{"name":"yourtallness","email":"mark@clerk.dev"},{"name":"nikosdouvlis","email":"nikosdouvlis@gmail.com"}],"_nodeVersion":"16.14.2","dependencies":{"tslib":"^2.3.1","@clerk/types":"^2.1.1-alpha.0","query-string":"^7.0.1","camelcase-keys":"^7.0.1","snakecase-keys":"^5.1.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"got":"^11.0.0","jest":"^27.4.7","nock":"^13.2.1","ts-jest":"^27.1.3","node-fetch":"^2.6.0","typescript":"^4.6.2","@types/jest":"^27.4.0","@types/node":"^16.11.12","@types/node-fetch":"^2","@peculiar/webcrypto":"^1.3.2"},"_npmOperationalInternal":{"tmp":"tmp/backend-core_1.0.1-alpha.0_1648078525927_0.4467406754901668","host":"s3://npm-registry-packages"},"_id":"@clerk/backend-core@1.0.1-alpha.0","version":"1.0.1-alpha.0"}