@dexterai/connect 0.26.4 → 0.29.1

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.
package/dist/server.d.ts CHANGED
@@ -18,11 +18,12 @@ declare const DEFAULT_ISS = "https://qdgumpoqnthrjfmqziwm.supabase.co/auth/v1";
18
18
  declare const DEFAULT_AUDIENCE = "authenticated";
19
19
  /** The namespaced claim sealed into the token by the access-token hook. */
20
20
  interface DexterClaim {
21
- ver: number;
21
+ ver: 1;
22
22
  /** Swig state address (base58) — the canonical Dexter Wallet identity. */
23
23
  vault: string;
24
24
  /** 16-byte passkey handle, base64url; absent on rows without one. */
25
25
  userHandle?: string;
26
+ origin?: string;
26
27
  agentGrant?: unknown;
27
28
  }
28
29
  type VerifyFailureReason = 'no_token' | 'invalid' | 'expired' | 'issuer_mismatch' | 'audience_mismatch';
package/dist/server.js CHANGED
@@ -1,3 +1,8 @@
1
+ import {
2
+ base64urlToBytes,
3
+ bytesToBase64url
4
+ } from "./chunk-EMCGL64H.js";
5
+
1
6
  // src/server.ts
2
7
  import {
3
8
  createLocalJWKSet,
@@ -7,6 +12,64 @@ import {
7
12
  } from "jose";
8
13
  var DEFAULT_ISS = "https://qdgumpoqnthrjfmqziwm.supabase.co/auth/v1";
9
14
  var DEFAULT_AUDIENCE = "authenticated";
15
+ var INVALID_CLAIM = /* @__PURE__ */ Symbol("invalid-claim");
16
+ var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
17
+ var BASE58_INDEX = new Map([...BASE58_ALPHABET].map((char, index) => [char, index]));
18
+ function isRecord(value) {
19
+ return typeof value === "object" && value !== null && !Array.isArray(value);
20
+ }
21
+ function isUserHandle(value) {
22
+ if (typeof value !== "string" || !/^[A-Za-z0-9_-]{22}$/.test(value)) return false;
23
+ try {
24
+ const bytes = base64urlToBytes(value);
25
+ return bytes.length === 16 && bytesToBase64url(bytes) === value;
26
+ } catch {
27
+ return false;
28
+ }
29
+ }
30
+ function isSolanaAddress(value) {
31
+ if (typeof value !== "string" || value.length < 32 || value.length > 44) return false;
32
+ const bytes = [0];
33
+ for (const char of value) {
34
+ const digit = BASE58_INDEX.get(char);
35
+ if (digit === void 0) return false;
36
+ let carry = digit;
37
+ for (let index = 0; index < bytes.length; index += 1) {
38
+ carry += bytes[index] * 58;
39
+ bytes[index] = carry & 255;
40
+ carry >>= 8;
41
+ }
42
+ while (carry > 0) {
43
+ bytes.push(carry & 255);
44
+ carry >>= 8;
45
+ }
46
+ }
47
+ let leadingZeroes = 0;
48
+ while (leadingZeroes < value.length - 1 && value[leadingZeroes] === "1") {
49
+ bytes.push(0);
50
+ leadingZeroes += 1;
51
+ }
52
+ return bytes.length === 32;
53
+ }
54
+ function parseDexterClaim(value) {
55
+ if (value === void 0) return null;
56
+ if (!isRecord(value) || value.ver !== 1 || !isSolanaAddress(value.vault)) {
57
+ return INVALID_CLAIM;
58
+ }
59
+ if (value.userHandle !== void 0 && !isUserHandle(value.userHandle)) {
60
+ return INVALID_CLAIM;
61
+ }
62
+ if (value.origin !== void 0 && typeof value.origin !== "string") {
63
+ return INVALID_CLAIM;
64
+ }
65
+ return {
66
+ ver: 1,
67
+ vault: value.vault,
68
+ ...value.userHandle === void 0 ? {} : { userHandle: value.userHandle },
69
+ ...value.origin === void 0 ? {} : { origin: value.origin },
70
+ ...value.agentGrant === void 0 ? {} : { agentGrant: value.agentGrant }
71
+ };
72
+ }
10
73
  function buildGetKey(opts) {
11
74
  if (opts.jwtKey) {
12
75
  const set = "keys" in opts.jwtKey ? opts.jwtKey : { keys: [opts.jwtKey] };
@@ -52,18 +115,30 @@ function createDexterClient(options = {}) {
52
115
  const { payload } = await jwtVerify(token, getKey, {
53
116
  issuer: iss,
54
117
  audience,
55
- algorithms: ["ES256"]
118
+ algorithms: ["ES256"],
56
119
  // pinned — defeats alg-confusion / alg:none
120
+ requiredClaims: ["sub", "exp", "iat"]
57
121
  });
58
- const dexter = payload.dexter;
122
+ if (typeof payload.sub !== "string" || payload.sub.length === 0) {
123
+ return { isSignedIn: false, reason: "invalid" };
124
+ }
125
+ const sessionId = payload.session_id;
126
+ const aal = payload.aal;
127
+ if (sessionId !== void 0 && sessionId !== null && typeof sessionId !== "string" || aal !== void 0 && aal !== null && typeof aal !== "string") {
128
+ return { isSignedIn: false, reason: "invalid" };
129
+ }
130
+ const dexter = parseDexterClaim(payload.dexter);
131
+ if (dexter === INVALID_CLAIM) {
132
+ return { isSignedIn: false, reason: "invalid" };
133
+ }
59
134
  return {
60
135
  isSignedIn: true,
61
- sub: payload.sub ?? "",
136
+ sub: payload.sub,
62
137
  vaultAddress: dexter?.vault ?? null,
63
138
  userHandle: dexter?.userHandle ?? null,
64
139
  agentGrant: dexter?.agentGrant ?? null,
65
- sessionId: payload.session_id ?? null,
66
- aal: payload.aal ?? null,
140
+ sessionId: sessionId ?? null,
141
+ aal: aal ?? null,
67
142
  claims: payload
68
143
  };
69
144
  } catch (err) {
package/dist/worldid.d.ts CHANGED
@@ -51,10 +51,8 @@ interface VerifyPersonhoodProps extends VerifyPersonhoodConfig {
51
51
  className?: string;
52
52
  }
53
53
  /**
54
- * Turnkey "Verify your personhood" element — the personhood sibling of
55
- * <SignInWithDexter>. Renders the branded DexterButton (loading while the RP
56
- * context signs server-side) that opens World App; on success hands the raw
57
- * IDKitResult to `onProof`. Brand voice: no emojis. Themeable via --dx-* vars.
54
+ * Turnkey "Verify your personhood" element. It renders DexterButton while the
55
+ * RP context is prepared, opens World App, and returns IDKitResult to `onProof`.
58
56
  */
59
57
  declare function VerifyPersonhood(props: VerifyPersonhoodProps): ReactElement;
60
58
 
package/dist/worldid.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DexterButton,
3
3
  ensureDexterButtonStyles
4
- } from "./chunk-TLCQSAE5.js";
4
+ } from "./chunk-T62F36N2.js";
5
5
 
6
6
  // src/worldid.tsx
7
7
  import { useEffect, useState } from "react";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dexterai/connect",
3
- "version": "0.26.4",
4
- "description": "Sign in with Dexter — passkey connector. Composes @dexterai/vault.",
3
+ "version": "0.29.1",
4
+ "description": "Connect apps and agents to a self-custodial Dexter Wallet with passkey identity, governed authority, hosted signing, and verifiable sessions.",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -12,6 +12,10 @@
12
12
  "types": "./dist/react.d.ts",
13
13
  "import": "./dist/react.js"
14
14
  },
15
+ "./hosted": {
16
+ "types": "./dist/hosted.d.ts",
17
+ "import": "./dist/hosted.js"
18
+ },
15
19
  "./worldid": {
16
20
  "types": "./dist/worldid.d.ts",
17
21
  "import": "./dist/worldid.js"
@@ -26,6 +30,7 @@
26
30
  ],
27
31
  "scripts": {
28
32
  "build": "tsup",
33
+ "prepack": "npm run build",
29
34
  "test": "vitest run",
30
35
  "typecheck": "tsc --noEmit"
31
36
  },