@p2pdotme/sdk 1.2.0 → 1.2.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/zkkyc.d.cts CHANGED
@@ -13,7 +13,7 @@ declare class SdkError<TCode extends string = string> extends Error {
13
13
  });
14
14
  }
15
15
 
16
- type ZkkycErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "ENCODE_ERROR" | "RECLAIM_INIT_FAILED" | "RECLAIM_SESSION_NOT_FOUND" | "RECLAIM_PROOF_GENERATION_FAILED" | "RECLAIM_PROOF_INVALID" | "RECLAIM_POLLING_ABORTED" | "ZK_PASSPORT_INIT_FAILED" | "ZK_PASSPORT_REJECTED" | "ZK_PASSPORT_VERIFICATION_FAILED" | "ZK_PASSPORT_ABORTED" | "PEER_DEPENDENCY_MISSING";
16
+ type ZkkycErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "ENCODE_ERROR" | "RECLAIM_INIT_FAILED" | "RECLAIM_SESSION_NOT_FOUND" | "RECLAIM_PROOF_GENERATION_FAILED" | "RECLAIM_PROOF_INVALID" | "RECLAIM_POLLING_ABORTED" | "ZK_PASSPORT_INIT_FAILED" | "ZK_PASSPORT_REJECTED" | "ZK_PASSPORT_VERIFICATION_FAILED" | "ZK_PASSPORT_ABORTED" | "SIMPLE_KYC_SESSION_FAILED" | "SIMPLE_KYC_REDEEM_FAILED" | "PEER_DEPENDENCY_MISSING";
17
17
  declare class ZkkycError extends SdkError<ZkkycErrorCode> {
18
18
  constructor(message: string, options: {
19
19
  code: ZkkycErrorCode;
@@ -90,6 +90,13 @@ declare const ZodZkPassportRegisterParamsSchema: z.ZodObject<{
90
90
  isIDCard: z.ZodBoolean;
91
91
  }, z.core.$strip>;
92
92
  type ZkPassportRegisterParams = z.infer<typeof ZodZkPassportRegisterParamsSchema>;
93
+ declare const ZodSimpleKycSubmitParamsSchema: z.ZodObject<{
94
+ nullifier: z.ZodString;
95
+ limit: z.ZodBigInt;
96
+ expiry: z.ZodBigInt;
97
+ signature: z.ZodString;
98
+ }, z.core.$strip>;
99
+ type SimpleKycSubmitParams = z.infer<typeof ZodSimpleKycSubmitParamsSchema>;
93
100
 
94
101
  interface Zkkyc {
95
102
  prepareSocialVerify(params: SocialVerifyParams): Result<{
@@ -104,6 +111,10 @@ interface Zkkyc {
104
111
  to: Address;
105
112
  data: `0x${string}`;
106
113
  }, ZkkycError>;
114
+ prepareSubmitKycAttestation(params: SimpleKycSubmitParams): Result<{
115
+ to: Address;
116
+ data: `0x${string}`;
117
+ }, ZkkycError>;
107
118
  }
108
119
  /**
109
120
  * Creates a Zkkyc client that binds a reputation manager address,
@@ -111,7 +122,7 @@ interface Zkkyc {
111
122
  */
112
123
  declare function createZkkyc(config: ZkkycConfig): Zkkyc;
113
124
 
114
- type SocialPlatform = "linkedin" | "github" | "x" | "instagram" | "facebook";
125
+ type SocialPlatform = "linkedin" | "github" | "x" | "instagram" | "facebook" | "binance";
115
126
  /** Maps SocialPlatform to the capitalized name the contract expects for _socialName. */
116
127
  declare const SOCIAL_PLATFORM_NAMES: Record<SocialPlatform, string>;
117
128
  /**
@@ -170,6 +181,16 @@ interface ReclaimProofResult {
170
181
  }[];
171
182
  readonly sessionId: string;
172
183
  }
184
+ interface ReclaimSession {
185
+ /** The Reclaim session id (empty until known when resuming). */
186
+ readonly sessionId: string;
187
+ /** URL to display as a QR code or open as a deep link. Empty when resuming an existing session. */
188
+ readonly requestUrl: string;
189
+ /** Triggers the in-app Reclaim flow (browser only) and polls until the proof is ready. Call on user action (e.g. button click). */
190
+ readonly start: () => ResultAsync<ReclaimProofResult, ZkkycError>;
191
+ /** Aborts an in-flight polling loop started by `start`. */
192
+ readonly abort: () => void;
193
+ }
173
194
  /**
174
195
  * Single-object params for `createZkPassportFlow`. Merges app-level config
175
196
  * (domain, name, logo, purpose) with per-call options (walletAddress, onStatus).
@@ -213,6 +234,59 @@ interface ZkPassportSession {
213
234
  /** Aborts the flow. The result promise will reject with ZK_PASSPORT_ABORTED. */
214
235
  readonly abort: () => void;
215
236
  }
237
+ /**
238
+ * Params for `createSimpleKycFlow`. The app opens the hosted simple-kyc wizard,
239
+ * which runs onboard → passport → liveness → face match/dedup and, on approval,
240
+ * redirects back to `redirectUrl` with `?code=<code>&state=<state>`. The app
241
+ * then calls `resumeSimpleKycFlow` to redeem the code for the EIP-712 attestation.
242
+ */
243
+ interface SimpleKycFlowParams {
244
+ /**
245
+ * Base URL exposing the browser-facing `/v1/widget/public-sessions` and
246
+ * `/v1/widget/attestation` endpoints — the `kyc-proxy` in a client-only setup
247
+ * (e.g. http://localhost:8787). The proxy holds the X-API-Key and forwards to
248
+ * simple-kyc's key-gated endpoints.
249
+ */
250
+ readonly baseUrl: string;
251
+ /** The user's EVM wallet — bound into the attestation and credited on-chain. */
252
+ readonly walletAddress: Address;
253
+ /** Tenant slug (one per consuming contract), e.g. "p2p-reputation". */
254
+ readonly tenant: string;
255
+ /** Return URL — pass `${window.location.origin}<route>` so each app self-routes. */
256
+ readonly redirectUrl: string;
257
+ /**
258
+ * ISO-2 country code (e.g. "IN"). Required — the embedded wizard skips the
259
+ * country step, so the app must prebind it. Must be one of simple-kyc's
260
+ * supported markets (IN, NG, BR, MX, CO, AR, VE, ID).
261
+ */
262
+ readonly country: string;
263
+ /** Opaque state round-tripped back to the app (CSRF/nonce + page to restore). */
264
+ readonly state?: string;
265
+ /** Status callback. */
266
+ readonly onStatus?: (status: SimpleKycStatus) => void;
267
+ }
268
+ type SimpleKycStatus = {
269
+ type: "session_created";
270
+ widgetUrl: string;
271
+ } | {
272
+ type: "redirecting";
273
+ widgetUrl: string;
274
+ };
275
+ interface SimpleKycSession {
276
+ /** The hosted wizard URL to navigate to. */
277
+ readonly widgetUrl: string;
278
+ /** Convenience: navigate the browser to the wizard (no-op outside the browser). */
279
+ readonly redirect: () => void;
280
+ }
281
+ /** The on-chain-ready attestation, shaped for `prepareSubmitKycAttestation`. */
282
+ interface SimpleKycAttestation {
283
+ readonly nullifier: `0x${string}`;
284
+ readonly limit: bigint;
285
+ readonly expiry: bigint;
286
+ readonly signature: `0x${string}`;
287
+ /** The opaque unique-human handle (no PII), for app-side bookkeeping. */
288
+ readonly identityHash?: string;
289
+ }
216
290
 
217
291
  /** Default Reclaim provider IDs for each social platform. */
218
292
  declare const DEFAULT_RECLAIM_PROVIDER_IDS: Record<SocialPlatform, string>;
@@ -225,11 +299,38 @@ declare const ZK_PASSPORT_APP_LINKS: {
225
299
  declare const RECLAIM_APP_LINKS: {
226
300
  readonly ANDROID: "https://play.google.com/store/apps/details?id=org.reclaimprotocol.app";
227
301
  };
302
+ /** Default tenant slug for the P2P reputation contract on the simple-kyc service. */
303
+ declare const SIMPLE_KYC_DEFAULT_TENANT = "p2p-reputation";
228
304
 
229
- /** Runs the Reclaim social verification flow and returns proof data for on-chain submission. */
230
- declare function createReclaimFlow(params: ReclaimFlowParams): ResultAsync<ReclaimProofResult, ZkkycError>;
305
+ /**
306
+ * Initializes a Reclaim social verification flow and returns a session. `init()`
307
+ * runs eagerly here, so call this on page load; the returned session's `start()`
308
+ * triggers the in-app flow and polls for the proof, so call that on user action.
309
+ */
310
+ declare function createReclaimFlow(params: ReclaimFlowParams): ResultAsync<ReclaimSession, ZkkycError>;
311
+
312
+ /**
313
+ * Starts the hosted simple-kyc wizard flow. Creates a browser-initiable widget
314
+ * session (no API key in the browser — `baseUrl` points at the kyc-proxy, which
315
+ * injects the key and whose tenant allowlist validates the redirect_uri), then
316
+ * returns the wizard URL to navigate to.
317
+ *
318
+ * The wizard runs passport → liveness → face match/dedup and, on approval,
319
+ * redirects back to `redirectUrl` with `?code=<code>&state=<state>`. Call
320
+ * `resumeSimpleKycFlow({ baseUrl, code })` on return to fetch the attestation.
321
+ */
322
+ declare function createSimpleKycFlow(params: SimpleKycFlowParams): ResultAsync<SimpleKycSession, ZkkycError>;
323
+ /**
324
+ * Redeems the one-time `kyc_code` from the wizard's redirect for the EIP-712
325
+ * attestation. The result feeds straight into `zkkyc.prepareSubmitKycAttestation`.
326
+ * The endpoint returns only the (non-PII, self-verifying) attestation.
327
+ */
328
+ declare function resumeSimpleKycFlow(args: {
329
+ baseUrl: string;
330
+ code: string;
331
+ }): ResultAsync<SimpleKycAttestation, ZkkycError>;
231
332
 
232
333
  /** Initializes a ZK Passport verification flow and returns a session. */
233
334
  declare function createZkPassportFlow(params: ZkPassportFlowParams): ResultAsync<ZkPassportSession, ZkkycError>;
234
335
 
235
- export { type AnonAadharProofParams, DEFAULT_RECLAIM_PROVIDER_IDS, RECLAIM_APP_LINKS, type ReclaimFlowParams, type ReclaimProofResult, type ReclaimStatus, SOCIAL_PLATFORM_NAMES, type SocialPlatform, type SocialVerifyParams, ZK_PASSPORT_APP_LINKS, type ZkPassportFlowParams, type ZkPassportProofResult, type ZkPassportRegisterParams, type ZkPassportSession, type ZkPassportStatus, type Zkkyc, type ZkkycConfig, ZkkycError, type ZkkycErrorCode, createReclaimFlow, createZkPassportFlow, createZkkyc };
336
+ export { type AnonAadharProofParams, DEFAULT_RECLAIM_PROVIDER_IDS, RECLAIM_APP_LINKS, type ReclaimFlowParams, type ReclaimProofResult, type ReclaimSession, type ReclaimStatus, SIMPLE_KYC_DEFAULT_TENANT, SOCIAL_PLATFORM_NAMES, type SimpleKycAttestation, type SimpleKycFlowParams, type SimpleKycSession, type SimpleKycStatus, type SimpleKycSubmitParams, type SocialPlatform, type SocialVerifyParams, ZK_PASSPORT_APP_LINKS, type ZkPassportFlowParams, type ZkPassportProofResult, type ZkPassportRegisterParams, type ZkPassportSession, type ZkPassportStatus, type Zkkyc, type ZkkycConfig, ZkkycError, type ZkkycErrorCode, createReclaimFlow, createSimpleKycFlow, createZkPassportFlow, createZkkyc, resumeSimpleKycFlow };
package/dist/zkkyc.d.ts CHANGED
@@ -13,7 +13,7 @@ declare class SdkError<TCode extends string = string> extends Error {
13
13
  });
14
14
  }
15
15
 
16
- type ZkkycErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "ENCODE_ERROR" | "RECLAIM_INIT_FAILED" | "RECLAIM_SESSION_NOT_FOUND" | "RECLAIM_PROOF_GENERATION_FAILED" | "RECLAIM_PROOF_INVALID" | "RECLAIM_POLLING_ABORTED" | "ZK_PASSPORT_INIT_FAILED" | "ZK_PASSPORT_REJECTED" | "ZK_PASSPORT_VERIFICATION_FAILED" | "ZK_PASSPORT_ABORTED" | "PEER_DEPENDENCY_MISSING";
16
+ type ZkkycErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "ENCODE_ERROR" | "RECLAIM_INIT_FAILED" | "RECLAIM_SESSION_NOT_FOUND" | "RECLAIM_PROOF_GENERATION_FAILED" | "RECLAIM_PROOF_INVALID" | "RECLAIM_POLLING_ABORTED" | "ZK_PASSPORT_INIT_FAILED" | "ZK_PASSPORT_REJECTED" | "ZK_PASSPORT_VERIFICATION_FAILED" | "ZK_PASSPORT_ABORTED" | "SIMPLE_KYC_SESSION_FAILED" | "SIMPLE_KYC_REDEEM_FAILED" | "PEER_DEPENDENCY_MISSING";
17
17
  declare class ZkkycError extends SdkError<ZkkycErrorCode> {
18
18
  constructor(message: string, options: {
19
19
  code: ZkkycErrorCode;
@@ -90,6 +90,13 @@ declare const ZodZkPassportRegisterParamsSchema: z.ZodObject<{
90
90
  isIDCard: z.ZodBoolean;
91
91
  }, z.core.$strip>;
92
92
  type ZkPassportRegisterParams = z.infer<typeof ZodZkPassportRegisterParamsSchema>;
93
+ declare const ZodSimpleKycSubmitParamsSchema: z.ZodObject<{
94
+ nullifier: z.ZodString;
95
+ limit: z.ZodBigInt;
96
+ expiry: z.ZodBigInt;
97
+ signature: z.ZodString;
98
+ }, z.core.$strip>;
99
+ type SimpleKycSubmitParams = z.infer<typeof ZodSimpleKycSubmitParamsSchema>;
93
100
 
94
101
  interface Zkkyc {
95
102
  prepareSocialVerify(params: SocialVerifyParams): Result<{
@@ -104,6 +111,10 @@ interface Zkkyc {
104
111
  to: Address;
105
112
  data: `0x${string}`;
106
113
  }, ZkkycError>;
114
+ prepareSubmitKycAttestation(params: SimpleKycSubmitParams): Result<{
115
+ to: Address;
116
+ data: `0x${string}`;
117
+ }, ZkkycError>;
107
118
  }
108
119
  /**
109
120
  * Creates a Zkkyc client that binds a reputation manager address,
@@ -111,7 +122,7 @@ interface Zkkyc {
111
122
  */
112
123
  declare function createZkkyc(config: ZkkycConfig): Zkkyc;
113
124
 
114
- type SocialPlatform = "linkedin" | "github" | "x" | "instagram" | "facebook";
125
+ type SocialPlatform = "linkedin" | "github" | "x" | "instagram" | "facebook" | "binance";
115
126
  /** Maps SocialPlatform to the capitalized name the contract expects for _socialName. */
116
127
  declare const SOCIAL_PLATFORM_NAMES: Record<SocialPlatform, string>;
117
128
  /**
@@ -170,6 +181,16 @@ interface ReclaimProofResult {
170
181
  }[];
171
182
  readonly sessionId: string;
172
183
  }
184
+ interface ReclaimSession {
185
+ /** The Reclaim session id (empty until known when resuming). */
186
+ readonly sessionId: string;
187
+ /** URL to display as a QR code or open as a deep link. Empty when resuming an existing session. */
188
+ readonly requestUrl: string;
189
+ /** Triggers the in-app Reclaim flow (browser only) and polls until the proof is ready. Call on user action (e.g. button click). */
190
+ readonly start: () => ResultAsync<ReclaimProofResult, ZkkycError>;
191
+ /** Aborts an in-flight polling loop started by `start`. */
192
+ readonly abort: () => void;
193
+ }
173
194
  /**
174
195
  * Single-object params for `createZkPassportFlow`. Merges app-level config
175
196
  * (domain, name, logo, purpose) with per-call options (walletAddress, onStatus).
@@ -213,6 +234,59 @@ interface ZkPassportSession {
213
234
  /** Aborts the flow. The result promise will reject with ZK_PASSPORT_ABORTED. */
214
235
  readonly abort: () => void;
215
236
  }
237
+ /**
238
+ * Params for `createSimpleKycFlow`. The app opens the hosted simple-kyc wizard,
239
+ * which runs onboard → passport → liveness → face match/dedup and, on approval,
240
+ * redirects back to `redirectUrl` with `?code=<code>&state=<state>`. The app
241
+ * then calls `resumeSimpleKycFlow` to redeem the code for the EIP-712 attestation.
242
+ */
243
+ interface SimpleKycFlowParams {
244
+ /**
245
+ * Base URL exposing the browser-facing `/v1/widget/public-sessions` and
246
+ * `/v1/widget/attestation` endpoints — the `kyc-proxy` in a client-only setup
247
+ * (e.g. http://localhost:8787). The proxy holds the X-API-Key and forwards to
248
+ * simple-kyc's key-gated endpoints.
249
+ */
250
+ readonly baseUrl: string;
251
+ /** The user's EVM wallet — bound into the attestation and credited on-chain. */
252
+ readonly walletAddress: Address;
253
+ /** Tenant slug (one per consuming contract), e.g. "p2p-reputation". */
254
+ readonly tenant: string;
255
+ /** Return URL — pass `${window.location.origin}<route>` so each app self-routes. */
256
+ readonly redirectUrl: string;
257
+ /**
258
+ * ISO-2 country code (e.g. "IN"). Required — the embedded wizard skips the
259
+ * country step, so the app must prebind it. Must be one of simple-kyc's
260
+ * supported markets (IN, NG, BR, MX, CO, AR, VE, ID).
261
+ */
262
+ readonly country: string;
263
+ /** Opaque state round-tripped back to the app (CSRF/nonce + page to restore). */
264
+ readonly state?: string;
265
+ /** Status callback. */
266
+ readonly onStatus?: (status: SimpleKycStatus) => void;
267
+ }
268
+ type SimpleKycStatus = {
269
+ type: "session_created";
270
+ widgetUrl: string;
271
+ } | {
272
+ type: "redirecting";
273
+ widgetUrl: string;
274
+ };
275
+ interface SimpleKycSession {
276
+ /** The hosted wizard URL to navigate to. */
277
+ readonly widgetUrl: string;
278
+ /** Convenience: navigate the browser to the wizard (no-op outside the browser). */
279
+ readonly redirect: () => void;
280
+ }
281
+ /** The on-chain-ready attestation, shaped for `prepareSubmitKycAttestation`. */
282
+ interface SimpleKycAttestation {
283
+ readonly nullifier: `0x${string}`;
284
+ readonly limit: bigint;
285
+ readonly expiry: bigint;
286
+ readonly signature: `0x${string}`;
287
+ /** The opaque unique-human handle (no PII), for app-side bookkeeping. */
288
+ readonly identityHash?: string;
289
+ }
216
290
 
217
291
  /** Default Reclaim provider IDs for each social platform. */
218
292
  declare const DEFAULT_RECLAIM_PROVIDER_IDS: Record<SocialPlatform, string>;
@@ -225,11 +299,38 @@ declare const ZK_PASSPORT_APP_LINKS: {
225
299
  declare const RECLAIM_APP_LINKS: {
226
300
  readonly ANDROID: "https://play.google.com/store/apps/details?id=org.reclaimprotocol.app";
227
301
  };
302
+ /** Default tenant slug for the P2P reputation contract on the simple-kyc service. */
303
+ declare const SIMPLE_KYC_DEFAULT_TENANT = "p2p-reputation";
228
304
 
229
- /** Runs the Reclaim social verification flow and returns proof data for on-chain submission. */
230
- declare function createReclaimFlow(params: ReclaimFlowParams): ResultAsync<ReclaimProofResult, ZkkycError>;
305
+ /**
306
+ * Initializes a Reclaim social verification flow and returns a session. `init()`
307
+ * runs eagerly here, so call this on page load; the returned session's `start()`
308
+ * triggers the in-app flow and polls for the proof, so call that on user action.
309
+ */
310
+ declare function createReclaimFlow(params: ReclaimFlowParams): ResultAsync<ReclaimSession, ZkkycError>;
311
+
312
+ /**
313
+ * Starts the hosted simple-kyc wizard flow. Creates a browser-initiable widget
314
+ * session (no API key in the browser — `baseUrl` points at the kyc-proxy, which
315
+ * injects the key and whose tenant allowlist validates the redirect_uri), then
316
+ * returns the wizard URL to navigate to.
317
+ *
318
+ * The wizard runs passport → liveness → face match/dedup and, on approval,
319
+ * redirects back to `redirectUrl` with `?code=<code>&state=<state>`. Call
320
+ * `resumeSimpleKycFlow({ baseUrl, code })` on return to fetch the attestation.
321
+ */
322
+ declare function createSimpleKycFlow(params: SimpleKycFlowParams): ResultAsync<SimpleKycSession, ZkkycError>;
323
+ /**
324
+ * Redeems the one-time `kyc_code` from the wizard's redirect for the EIP-712
325
+ * attestation. The result feeds straight into `zkkyc.prepareSubmitKycAttestation`.
326
+ * The endpoint returns only the (non-PII, self-verifying) attestation.
327
+ */
328
+ declare function resumeSimpleKycFlow(args: {
329
+ baseUrl: string;
330
+ code: string;
331
+ }): ResultAsync<SimpleKycAttestation, ZkkycError>;
231
332
 
232
333
  /** Initializes a ZK Passport verification flow and returns a session. */
233
334
  declare function createZkPassportFlow(params: ZkPassportFlowParams): ResultAsync<ZkPassportSession, ZkkycError>;
234
335
 
235
- export { type AnonAadharProofParams, DEFAULT_RECLAIM_PROVIDER_IDS, RECLAIM_APP_LINKS, type ReclaimFlowParams, type ReclaimProofResult, type ReclaimStatus, SOCIAL_PLATFORM_NAMES, type SocialPlatform, type SocialVerifyParams, ZK_PASSPORT_APP_LINKS, type ZkPassportFlowParams, type ZkPassportProofResult, type ZkPassportRegisterParams, type ZkPassportSession, type ZkPassportStatus, type Zkkyc, type ZkkycConfig, ZkkycError, type ZkkycErrorCode, createReclaimFlow, createZkPassportFlow, createZkkyc };
336
+ export { type AnonAadharProofParams, DEFAULT_RECLAIM_PROVIDER_IDS, RECLAIM_APP_LINKS, type ReclaimFlowParams, type ReclaimProofResult, type ReclaimSession, type ReclaimStatus, SIMPLE_KYC_DEFAULT_TENANT, SOCIAL_PLATFORM_NAMES, type SimpleKycAttestation, type SimpleKycFlowParams, type SimpleKycSession, type SimpleKycStatus, type SimpleKycSubmitParams, type SocialPlatform, type SocialVerifyParams, ZK_PASSPORT_APP_LINKS, type ZkPassportFlowParams, type ZkPassportProofResult, type ZkPassportRegisterParams, type ZkPassportSession, type ZkPassportStatus, type Zkkyc, type ZkkycConfig, ZkkycError, type ZkkycErrorCode, createReclaimFlow, createSimpleKycFlow, createZkPassportFlow, createZkkyc, resumeSimpleKycFlow };