@rare-id/platform-kit-express 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,9 @@
1
+ import { Request, Response } from 'express';
2
+ import { RarePlatformKit } from '@rare-id/platform-kit-web';
3
+
4
+ declare function createExpressRareHandlers(kit: RarePlatformKit): {
5
+ issueChallenge: (req: Request, res: Response) => Promise<void>;
6
+ completeAuth: (req: Request, res: Response) => Promise<void>;
7
+ };
8
+
9
+ export { createExpressRareHandlers };
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ // src/index.ts
2
+ function createExpressRareHandlers(kit) {
3
+ return {
4
+ issueChallenge: async (req, res) => {
5
+ try {
6
+ const challenge = await kit.issueChallenge(req.body?.aud);
7
+ res.json({
8
+ nonce: challenge.nonce,
9
+ aud: challenge.aud,
10
+ issued_at: challenge.issuedAt,
11
+ expires_at: challenge.expiresAt
12
+ });
13
+ } catch (error) {
14
+ res.status(400).json({ detail: String(error) });
15
+ }
16
+ },
17
+ completeAuth: async (req, res) => {
18
+ try {
19
+ const result = await kit.completeAuth({
20
+ nonce: req.body.nonce,
21
+ agentId: req.body.agent_id,
22
+ sessionPubkey: req.body.session_pubkey,
23
+ delegationToken: req.body.delegation_token,
24
+ signatureBySession: req.body.signature_by_session,
25
+ publicIdentityAttestation: req.body.public_identity_attestation,
26
+ fullIdentityAttestation: req.body.full_identity_attestation
27
+ });
28
+ res.json(result);
29
+ } catch (error) {
30
+ res.status(400).json({ detail: String(error) });
31
+ }
32
+ }
33
+ };
34
+ }
35
+ export {
36
+ createExpressRareHandlers
37
+ };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@rare-id/platform-kit-express",
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-express"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "provenance": false
26
+ },
27
+ "dependencies": {
28
+ "express": "^4.21.2",
29
+ "@rare-id/platform-kit-web": "0.1.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/express": "^5.0.0"
33
+ },
34
+ "scripts": {
35
+ "build": "tsup src/index.ts --format esm --dts",
36
+ "test": "vitest run",
37
+ "lint": "biome check src",
38
+ "typecheck": "tsc -p tsconfig.json --noEmit"
39
+ }
40
+ }