@rare-id/platform-kit-fastify 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ import { FastifyInstance } from 'fastify';
2
+ import { RarePlatformKit } from '@rare-id/platform-kit-web';
3
+
4
+ declare function registerRarePlatformKit(app: FastifyInstance, options: {
5
+ kit: RarePlatformKit;
6
+ }): Promise<void>;
7
+
8
+ export { registerRarePlatformKit };
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ // src/index.ts
2
+ async function registerRarePlatformKit(app, options) {
3
+ app.post("/auth/challenge", async (request) => {
4
+ const body = request.body;
5
+ const challenge = await options.kit.issueChallenge(body?.aud);
6
+ return {
7
+ nonce: challenge.nonce,
8
+ aud: challenge.aud,
9
+ issued_at: challenge.issuedAt,
10
+ expires_at: challenge.expiresAt
11
+ };
12
+ });
13
+ app.post("/auth/complete", async (request) => {
14
+ const body = request.body;
15
+ return options.kit.completeAuth({
16
+ nonce: String(body.nonce),
17
+ agentId: String(body.agent_id),
18
+ sessionPubkey: String(body.session_pubkey),
19
+ delegationToken: String(body.delegation_token),
20
+ signatureBySession: String(body.signature_by_session),
21
+ publicIdentityAttestation: body.public_identity_attestation,
22
+ fullIdentityAttestation: body.full_identity_attestation
23
+ });
24
+ });
25
+ }
26
+ export {
27
+ registerRarePlatformKit
28
+ };
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@rare-id/platform-kit-fastify",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "sideEffects": false,
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/0xsidfan/Rare.git",
21
+ "directory": "rare-platform-kit-ts/packages/platform-kit-fastify"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "provenance": false
26
+ },
27
+ "dependencies": {
28
+ "fastify": "^5.2.1",
29
+ "@rare-id/platform-kit-web": "0.1.0"
30
+ },
31
+ "scripts": {
32
+ "build": "tsup src/index.ts --format esm --dts",
33
+ "test": "vitest run",
34
+ "lint": "biome check src",
35
+ "typecheck": "tsc -p tsconfig.json --noEmit"
36
+ }
37
+ }