@gesturegate/sdk 0.1.0 → 0.1.2

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/index.d.ts CHANGED
@@ -1,14 +1,41 @@
1
1
  import { type Address, type Hex, type PublicClient } from "viem";
2
2
  export declare const monadTestnetChainId = 10143;
3
- export declare const gestureGateIntentDomain: {
4
- readonly name: "GestureGate";
5
- readonly version: "1";
6
- readonly chainId: 10143;
3
+ export declare const monadMainnetChainId = 143;
4
+ /** The official GestureGate deployment. Partners do not configure these values. */
5
+ export declare const gestureGateDeployments: {
6
+ readonly 10143: {
7
+ readonly chainId: 10143;
8
+ readonly apiOrigin: "https://gesturegate.vercel.app";
9
+ readonly registryAddress: Address;
10
+ };
11
+ readonly 143: {
12
+ readonly chainId: 143;
13
+ readonly apiOrigin: "https://gesturegate.vercel.app";
14
+ readonly registryAddress: Address;
15
+ };
7
16
  };
17
+ export type GestureGateDeployment = {
18
+ chainId: number;
19
+ apiOrigin: string;
20
+ registryAddress: Address;
21
+ };
22
+ export declare function getGestureGateDeployment(chainId: number): GestureGateDeployment | undefined;
23
+ export type GestureGateIntentDomain = {
24
+ name: "GestureGate";
25
+ version: "1";
26
+ chainId: number;
27
+ };
28
+ /** Builds an EIP-712 domain that is bound to the chain being verified. */
29
+ export declare function getGestureGateIntentDomain(chainId: number): GestureGateIntentDomain;
30
+ /** Testnet compatibility export. New integrations select the domain by chain. */
31
+ export declare const gestureGateIntentDomain: GestureGateIntentDomain;
8
32
  export declare const gestureGateIntentTypes: {
9
33
  readonly GateIntent: readonly [{
10
34
  readonly name: "subject";
11
35
  readonly type: "address";
36
+ }, {
37
+ readonly name: "projectId";
38
+ readonly type: "string";
12
39
  }, {
13
40
  readonly name: "action";
14
41
  readonly type: "string";
@@ -36,11 +63,12 @@ export declare const gestureGateRegistryAbi: readonly [{
36
63
  }];
37
64
  }];
38
65
  export type SignTypedData = (args: {
39
- domain: typeof gestureGateIntentDomain;
66
+ domain: GestureGateIntentDomain;
40
67
  types: typeof gestureGateIntentTypes;
41
68
  primaryType: "GateIntent";
42
69
  message: {
43
70
  subject: Address;
71
+ projectId: string;
44
72
  action: "REQUEST_CHALLENGE";
45
73
  nonce: Hex;
46
74
  expiresAt: bigint;
@@ -51,6 +79,7 @@ export type HostedStart = {
51
79
  expiresAt: string;
52
80
  transactionHash: Hex;
53
81
  verifyUrl: string;
82
+ chainId: number;
54
83
  };
55
84
  export type HostedVerifiedMessage = {
56
85
  type: "gesturegate:verified";
@@ -59,46 +88,54 @@ export type HostedVerifiedMessage = {
59
88
  };
60
89
  export type VerificationCheck = {
61
90
  publicClient: PublicClient;
62
- registryAddress: Address;
63
91
  address: Address;
64
92
  ttlSeconds: number;
93
+ /** For local development or a future self-hosted GestureGate deployment. */
94
+ deployment?: GestureGateDeployment;
65
95
  };
66
96
  export type VerificationStatus = Pick<VerificationCheck, "address" | "ttlSeconds"> & {
67
97
  isVerified: boolean;
68
98
  };
69
99
  export type EnsureVerifiedOptions = VerificationCheck & {
70
- apiOrigin: string;
100
+ projectId: string;
71
101
  signTypedData: SignTypedData;
72
102
  popupName?: string;
73
103
  popupFeatures?: string;
74
104
  };
75
105
  export type GestureGateClientOptions = Omit<VerificationCheck, "address" | "ttlSeconds"> & {
76
- apiOrigin: string;
106
+ projectId: string;
77
107
  defaultTtlSeconds: number;
108
+ /** Per-chain deployments, useful while a Mainnet deployment is being configured. */
109
+ deployments?: Partial<Record<number, GestureGateDeployment>>;
78
110
  };
79
- export declare function createChallengeIntent(subject: Address, signTypedData: SignTypedData, now?: number): Promise<{
111
+ export declare function createChallengeIntent(subject: Address, projectId: string, signTypedData: SignTypedData, now?: number, chainId?: number): Promise<{
80
112
  subject: `0x${string}`;
113
+ projectId: string;
81
114
  nonce: `0x${string}`;
82
115
  expiresAt: string;
83
116
  signature: `0x${string}`;
117
+ chainId: number;
84
118
  }>;
85
119
  export declare function startHostedVerification(options: {
86
- apiOrigin: string;
120
+ projectId: string;
87
121
  address: Address;
88
122
  signTypedData: SignTypedData;
123
+ deployment?: GestureGateDeployment;
89
124
  }): Promise<{
90
125
  challengeId: string;
91
126
  expiresAt: string;
92
127
  transactionHash: `0x${string}`;
93
128
  verifyUrl: string;
129
+ chainId: number;
94
130
  }>;
95
131
  export declare function isVerifiedWithin(options: VerificationCheck): Promise<boolean>;
96
132
  /** Returns an explicit address-bound status for application UI and guards. */
97
133
  export declare function getVerificationStatus(options: VerificationCheck): Promise<VerificationStatus>;
98
134
  export declare function openHostedVerification(options: {
99
- apiOrigin: string;
135
+ projectId: string;
100
136
  address: Address;
101
137
  signTypedData: SignTypedData;
138
+ deployment?: GestureGateDeployment;
102
139
  popupName?: string;
103
140
  popupFeatures?: string;
104
141
  }): Promise<HostedVerifiedMessage>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAEnF,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC;AAEX,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;CAOzB,CAAC;AAEX,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;EAMxB,CAAC;AAEZ,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE;IACjC,MAAM,EAAE,OAAO,uBAAuB,CAAC;IACvC,KAAK,EAAE,OAAO,sBAAsB,CAAC;IACrC,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAC;QAAC,KAAK,EAAE,GAAG,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3F,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEnB,MAAM,MAAM,WAA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AAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAMnG;AAED,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,CAAC,EAAE,qBAAqB,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,kCAsCA;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB;;;;;;;;GAUlE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB;qBAWzC,OAAO;kBAQf;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,aAAa,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;4BAKpF;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,aAAa,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;GAQpJ"}
package/dist/index.js CHANGED
@@ -1,13 +1,32 @@
1
1
  import { keccak256, toHex } from "viem";
2
2
  export const monadTestnetChainId = 10143;
3
- export const gestureGateIntentDomain = {
4
- name: "GestureGate",
5
- version: "1",
6
- chainId: monadTestnetChainId,
3
+ export const monadMainnetChainId = 143;
4
+ /** The official GestureGate deployment. Partners do not configure these values. */
5
+ export const gestureGateDeployments = {
6
+ [monadTestnetChainId]: {
7
+ chainId: monadTestnetChainId,
8
+ apiOrigin: "https://gesturegate.vercel.app",
9
+ registryAddress: "0x0B8a46b6c46a37B8B91C78D3f73549747e2027e3",
10
+ },
11
+ [monadMainnetChainId]: {
12
+ chainId: monadMainnetChainId,
13
+ apiOrigin: "https://gesturegate.vercel.app",
14
+ registryAddress: "0xaa280c0502A36E311aa7d301F0Bf997691b06968",
15
+ },
7
16
  };
17
+ export function getGestureGateDeployment(chainId) {
18
+ return gestureGateDeployments[chainId];
19
+ }
20
+ /** Builds an EIP-712 domain that is bound to the chain being verified. */
21
+ export function getGestureGateIntentDomain(chainId) {
22
+ return { name: "GestureGate", version: "1", chainId };
23
+ }
24
+ /** Testnet compatibility export. New integrations select the domain by chain. */
25
+ export const gestureGateIntentDomain = getGestureGateIntentDomain(monadTestnetChainId);
8
26
  export const gestureGateIntentTypes = {
9
27
  GateIntent: [
10
28
  { name: "subject", type: "address" },
29
+ { name: "projectId", type: "string" },
11
30
  { name: "action", type: "string" },
12
31
  { name: "nonce", type: "bytes32" },
13
32
  { name: "expiresAt", type: "uint256" },
@@ -30,20 +49,38 @@ function randomNonce() {
30
49
  function apiPath(apiOrigin, path) {
31
50
  return `${apiOrigin.replace(/\/$/, "")}${path}`;
32
51
  }
33
- export async function createChallengeIntent(subject, signTypedData, now = Date.now()) {
52
+ async function resolveDeployment(publicClient, override) {
53
+ const chainId = await publicClient.getChainId();
54
+ const deployment = override ?? getGestureGateDeployment(chainId);
55
+ if (!deployment)
56
+ throw new Error("GestureGate is not available on this network. Switch to Monad Testnet.");
57
+ if (deployment.chainId !== chainId)
58
+ throw new Error("Your wallet is connected to the wrong network for this GestureGate deployment.");
59
+ return deployment;
60
+ }
61
+ function defaultDeployment() {
62
+ const deployment = getGestureGateDeployment(monadTestnetChainId);
63
+ if (!deployment)
64
+ throw new Error("The official GestureGate Monad Testnet deployment is missing.");
65
+ return deployment;
66
+ }
67
+ export async function createChallengeIntent(subject, projectId, signTypedData, now = Date.now(), chainId = monadTestnetChainId) {
68
+ if (!/^ggp_[A-Za-z0-9_-]{8,}$/.test(projectId))
69
+ throw new Error("projectId must be a valid GestureGate project ID.");
34
70
  const expiresAt = BigInt(Math.floor(now / 1_000) + 180);
35
71
  const nonce = randomNonce();
36
72
  const signature = await signTypedData({
37
- domain: gestureGateIntentDomain,
73
+ domain: getGestureGateIntentDomain(chainId),
38
74
  types: gestureGateIntentTypes,
39
75
  primaryType: "GateIntent",
40
- message: { subject, action: "REQUEST_CHALLENGE", nonce, expiresAt },
76
+ message: { subject, projectId, action: "REQUEST_CHALLENGE", nonce, expiresAt },
41
77
  });
42
- return { subject, nonce, expiresAt: expiresAt.toString(), signature };
78
+ return { subject, projectId, nonce, expiresAt: expiresAt.toString(), signature, chainId };
43
79
  }
44
80
  export async function startHostedVerification(options) {
45
- const intent = await createChallengeIntent(options.address, options.signTypedData);
46
- const response = await fetch(apiPath(options.apiOrigin, "/api/challenges"), {
81
+ const deployment = options.deployment ?? defaultDeployment();
82
+ const intent = await createChallengeIntent(options.address, options.projectId, options.signTypedData, Date.now(), deployment.chainId);
83
+ const response = await fetch(apiPath(deployment.apiOrigin, "/api/challenges"), {
47
84
  method: "POST",
48
85
  headers: { "content-type": "application/json" },
49
86
  body: JSON.stringify(intent),
@@ -51,7 +88,7 @@ export async function startHostedVerification(options) {
51
88
  const result = await response.json();
52
89
  if (!response.ok)
53
90
  throw new Error(result.error ?? "GestureGate could not start verification.");
54
- if (!result.challengeId || !result.expiresAt || !result.transactionHash || !result.verifyUrl) {
91
+ if (!result.challengeId || !result.expiresAt || !result.transactionHash || !result.verifyUrl || result.chainId !== deployment.chainId) {
55
92
  throw new Error("GestureGate returned an incomplete verification session.");
56
93
  }
57
94
  // The API also returns an inline-flow session token. Hosted partners never
@@ -61,14 +98,16 @@ export async function startHostedVerification(options) {
61
98
  expiresAt: result.expiresAt,
62
99
  transactionHash: result.transactionHash,
63
100
  verifyUrl: result.verifyUrl,
101
+ chainId: result.chainId,
64
102
  };
65
103
  }
66
104
  export async function isVerifiedWithin(options) {
67
105
  if (!Number.isInteger(options.ttlSeconds) || options.ttlSeconds <= 0) {
68
106
  throw new Error("ttlSeconds must be a positive whole number.");
69
107
  }
108
+ const deployment = await resolveDeployment(options.publicClient, options.deployment);
70
109
  return options.publicClient.readContract({
71
- address: options.registryAddress,
110
+ address: deployment.registryAddress,
72
111
  abi: gestureGateRegistryAbi,
73
112
  functionName: "isVerifiedWithin",
74
113
  args: [options.address, BigInt(options.ttlSeconds)],
@@ -91,9 +130,10 @@ export async function openHostedVerification(options) {
91
130
  if (!popup)
92
131
  throw new Error("Popup was blocked. Allow popups to verify with GestureGate.");
93
132
  try {
133
+ const deployment = options.deployment ?? defaultDeployment();
94
134
  const start = await startHostedVerification(options);
95
135
  popup.location.assign(start.verifyUrl);
96
- const expectedOrigin = new URL(options.apiOrigin).origin;
136
+ const expectedOrigin = new URL(deployment.apiOrigin).origin;
97
137
  return await new Promise((resolve, reject) => {
98
138
  const closeTimer = window.setInterval(() => {
99
139
  if (popup.closed) {
@@ -147,22 +187,32 @@ export function createGestureGateClient(options) {
147
187
  if (!Number.isInteger(options.defaultTtlSeconds) || options.defaultTtlSeconds <= 0) {
148
188
  throw new Error("defaultTtlSeconds must be a positive whole number.");
149
189
  }
150
- const check = (address, ttlSeconds = options.defaultTtlSeconds) => getVerificationStatus({
190
+ const deploymentForCurrentChain = async () => {
191
+ const chainId = await options.publicClient.getChainId();
192
+ const deployment = options.deployments?.[chainId] ?? options.deployment ?? getGestureGateDeployment(chainId);
193
+ if (!deployment)
194
+ throw new Error("GestureGate is not configured for the connected network.");
195
+ if (deployment.chainId !== chainId)
196
+ throw new Error("Your wallet is connected to the wrong network for this GestureGate deployment.");
197
+ return deployment;
198
+ };
199
+ const check = async (address, ttlSeconds = options.defaultTtlSeconds) => getVerificationStatus({
151
200
  publicClient: options.publicClient,
152
- registryAddress: options.registryAddress,
153
201
  address,
154
202
  ttlSeconds,
203
+ deployment: await deploymentForCurrentChain(),
155
204
  });
156
205
  return Object.freeze({
157
206
  check,
158
- open: (input) => openHostedVerification({
159
- apiOrigin: options.apiOrigin,
207
+ open: async (input) => openHostedVerification({
208
+ projectId: options.projectId,
209
+ deployment: await deploymentForCurrentChain(),
160
210
  ...input,
161
211
  }),
162
- ensureVerified: (input) => ensureVerified({
212
+ ensureVerified: async (input) => ensureVerified({
163
213
  publicClient: options.publicClient,
164
- registryAddress: options.registryAddress,
165
- apiOrigin: options.apiOrigin,
214
+ projectId: options.projectId,
215
+ deployment: await deploymentForCurrentChain(),
166
216
  ttlSeconds: input.ttlSeconds ?? options.defaultTtlSeconds,
167
217
  ...input,
168
218
  }),
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@gesturegate/sdk",
3
- "version": "0.1.0",
4
- "description": "Framework-neutral hosted verification client for GestureGate on Monad.",
5
- "license": "MIT",
6
- "type": "module",
7
- "sideEffects": false,
8
- "keywords": ["captcha", "human-verification", "monad", "viem", "web3"],
3
+ "version": "0.1.2",
4
+ "description": "Framework-neutral hosted verification client for GestureGate on Monad.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "keywords": ["captcha", "human-verification", "monad", "viem", "web3"],
9
9
  "files": ["dist"],
10
10
  "main": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts",
@@ -15,12 +15,12 @@
15
15
  "import": "./dist/index.js"
16
16
  }
17
17
  },
18
- "scripts": {
19
- "build": "tsc -p tsconfig.json"
20
- },
21
- "publishConfig": {
22
- "access": "public"
23
- },
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
24
  "peerDependencies": {
25
25
  "viem": ">=2.0.0"
26
26
  }