@zkpassport/sdk 0.1.1 → 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/README.md CHANGED
@@ -3,13 +3,13 @@
3
3
  ## Installation
4
4
 
5
5
  ```
6
- npm install https://github.com/zkpassport/zkpassport-sdk.git
6
+ npm install @zkpassport/sdk
7
7
  ```
8
8
 
9
9
  ## How to use
10
10
 
11
11
  ```ts
12
- import { ZkPassport } from 'zkpassport-sdk'
12
+ import { ZkPassport } from '@zkpassport/sdk'
13
13
 
14
14
  // Replace with your domain
15
15
  const zkPassport = new ZkPassport('demo.zkpassport.id')
@@ -57,45 +57,48 @@ onProofGenerated((result: ProofResult) => {
57
57
  console.log('nationality', result.queryResult.nationality.disclose.result)
58
58
  })
59
59
  ```
60
+
60
61
  ### Using with Next.js
61
62
 
62
- You can integrate `zkpassport-sdk` into a Next.js application by creating a backend API route and calling it from your frontend.
63
+ You can integrate `@zkpassport/sdk` into a Next.js application by creating a backend API route and calling it from your frontend.
63
64
 
64
65
  #### **Backend (API Route)**
65
66
 
66
67
  **App Router:** `app/api/zkpassport/route.ts`
68
+
67
69
  ```typescript
68
- import { NextResponse } from 'next/server';
69
- import { ZkPassport } from 'zkpassport-sdk';
70
+ import { NextResponse } from 'next/server'
71
+ import { ZkPassport } from '@zkpassport/sdk'
70
72
 
71
73
  export async function GET() {
72
- const zkPassport = new ZkPassport('demo.zkpassport.id'); // Replace with your domain
74
+ const zkPassport = new ZkPassport('demo.zkpassport.id') // Replace with your domain
73
75
  const queryBuilder = await zkPassport.request({
74
76
  name: 'ZKpassport Demo',
75
77
  logo: 'https://via.placeholder.com/150',
76
78
  purpose: 'Verify user nationality and first name',
77
- });
78
- const { url } = queryBuilder.disclose('nationality').disclose('firstname').done();
79
- return NextResponse.json({ url });
79
+ })
80
+ const { url } = queryBuilder.disclose('nationality').disclose('firstname').done()
81
+ return NextResponse.json({ url })
80
82
  }
81
83
  ```
82
84
 
83
85
  #### **Frontend Example**
84
86
 
85
87
  **App Router:** `app/page.tsx`
88
+
86
89
  ```tsx
87
- 'use client';
88
- import { useEffect, useState } from 'react';
90
+ 'use client'
91
+ import { useEffect, useState } from 'react'
89
92
 
90
93
  export default function Home() {
91
- const [verificationUrl, setVerificationUrl] = useState<string | null>(null);
94
+ const [verificationUrl, setVerificationUrl] = useState<string | null>(null)
92
95
 
93
96
  useEffect(() => {
94
97
  fetch('/api/zkpassport')
95
- .then(res => res.json())
96
- .then(data => setVerificationUrl(data.url))
97
- .catch(console.error);
98
- }, []);
98
+ .then((res) => res.json())
99
+ .then((data) => setVerificationUrl(data.url))
100
+ .catch(console.error)
101
+ }, [])
99
102
 
100
103
  return (
101
104
  <div>
@@ -108,9 +111,8 @@ export default function Home() {
108
111
  <p>Loading...</p>
109
112
  )}
110
113
  </div>
111
- );
114
+ )
112
115
  }
113
-
114
116
  ```
115
117
 
116
118
  ## Local installation
@@ -1,4 +1,4 @@
1
- import { CountryName } from '@/types/countries';
1
+ import { CountryName } from '../types/countries';
2
2
  /**
3
3
  * List of countries that are sanctioned by the US government.
4
4
  */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { DisclosableIDCredential, IDCredential, IDCredentialValue, NumericalIDCredential } from '@/types/credentials';
2
- import { ProofResult } from '@/types/query-result';
1
+ import { DisclosableIDCredential, IDCredential, IDCredentialValue, NumericalIDCredential } from './types/credentials';
2
+ import { ProofResult } from './types/query-result';
3
3
  export * from './constants';
4
4
  export * from './types';
5
5
  export declare class ZkPassport {
package/dist/index.js CHANGED
@@ -69,10 +69,10 @@ var crypto_1 = require("crypto");
69
69
  var i18n_iso_countries_1 = require("i18n-iso-countries");
70
70
  //import { UltraHonkBackend, ProofData, CompiledCircuit } from '@noir-lang/backend_barretenberg'
71
71
  var utils_1 = require("@noble/ciphers/utils");
72
- var websocket_1 = require("@/websocket");
73
- var json_rpc_1 = require("@/json-rpc");
74
- var encryption_1 = require("@/encryption");
75
- var logger_1 = __importDefault(require("@/logger"));
72
+ var websocket_1 = require("./websocket");
73
+ var json_rpc_1 = require("./json-rpc");
74
+ var encryption_1 = require("./encryption");
75
+ var logger_1 = __importDefault(require("./logger"));
76
76
  (0, i18n_iso_countries_1.registerLocale)(require('i18n-iso-countries/langs/en.json'));
77
77
  function normalizeCountry(country) {
78
78
  var normalizedCountry;
@@ -1,5 +1,5 @@
1
- import { JsonRpcRequest, JsonRpcResponse } from '@/types/json-rpc';
2
- import { WebSocketClient } from '@/websocket';
1
+ import { JsonRpcRequest, JsonRpcResponse } from './types/json-rpc';
2
+ import { WebSocketClient } from './websocket';
3
3
  export declare function createJsonRpcRequest(method: string, params: any): JsonRpcRequest;
4
4
  export declare function createEncryptedJsonRpcRequest(method: string, params: any, sharedSecret: Uint8Array, topic: string): Promise<JsonRpcRequest>;
5
5
  export declare function sendEncryptedJsonRpcRequest(method: string, params: any, sharedSecret: Uint8Array, topic: string, wsClient: WebSocketClient): Promise<boolean>;
package/dist/json-rpc.js CHANGED
@@ -44,8 +44,8 @@ exports.createEncryptedJsonRpcRequest = createEncryptedJsonRpcRequest;
44
44
  exports.sendEncryptedJsonRpcRequest = sendEncryptedJsonRpcRequest;
45
45
  exports.createJsonRpcResponse = createJsonRpcResponse;
46
46
  var crypto_1 = require("crypto");
47
- var encryption_1 = require("@/encryption");
48
- var logger_1 = __importDefault(require("@/logger"));
47
+ var encryption_1 = require("./encryption");
48
+ var logger_1 = __importDefault(require("./logger"));
49
49
  function createJsonRpcRequest(method, params) {
50
50
  return {
51
51
  jsonrpc: '2.0',
package/dist/mobile.js CHANGED
@@ -41,10 +41,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.ZkPassportProver = void 0;
43
43
  var utils_1 = require("@noble/ciphers/utils");
44
- var websocket_1 = require("@/websocket");
45
- var json_rpc_1 = require("@/json-rpc");
46
- var encryption_1 = require("@/encryption");
47
- var logger_1 = __importDefault(require("@/logger"));
44
+ var websocket_1 = require("./websocket");
45
+ var json_rpc_1 = require("./json-rpc");
46
+ var encryption_1 = require("./encryption");
47
+ var logger_1 = __importDefault(require("./logger"));
48
48
  var ZkPassportProver = /** @class */ (function () {
49
49
  function ZkPassportProver() {
50
50
  this.topicToKeyPair = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zkpassport/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { CountryName } from '@/types/countries'
1
+ import { CountryName } from '../types/countries'
2
2
 
3
3
  /**
4
4
  * List of countries that are sanctioned by the US government.
package/src/index.ts CHANGED
@@ -6,16 +6,16 @@ import {
6
6
  IDCredentialConfig,
7
7
  IDCredentialValue,
8
8
  NumericalIDCredential,
9
- } from '@/types/credentials'
10
- import { ProofResult } from '@/types/query-result'
11
- import { CountryName } from '@/types/countries'
9
+ } from './types/credentials'
10
+ import { ProofResult } from './types/query-result'
11
+ import { CountryName } from './types/countries'
12
12
  //import { UltraHonkBackend, ProofData, CompiledCircuit } from '@noir-lang/backend_barretenberg'
13
13
  import { bytesToHex } from '@noble/ciphers/utils'
14
- import { getWebSocketClient, WebSocketClient } from '@/websocket'
15
- import { createEncryptedJsonRpcRequest } from '@/json-rpc'
16
- import { decrypt, generateECDHKeyPair, getSharedSecret } from '@/encryption'
17
- import { JsonRpcRequest } from '@/types/json-rpc'
18
- import logger from '@/logger'
14
+ import { getWebSocketClient, WebSocketClient } from './websocket'
15
+ import { createEncryptedJsonRpcRequest } from './json-rpc'
16
+ import { decrypt, generateECDHKeyPair, getSharedSecret } from './encryption'
17
+ import { JsonRpcRequest } from './types/json-rpc'
18
+ import logger from './logger'
19
19
 
20
20
  registerLocale(require('i18n-iso-countries/langs/en.json'))
21
21
 
package/src/json-rpc.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { randomBytes } from 'crypto'
2
- import { JsonRpcRequest, JsonRpcResponse } from '@/types/json-rpc'
3
- import { encrypt } from '@/encryption'
4
- import { WebSocketClient } from '@/websocket'
5
- import logger from '@/logger'
2
+ import { JsonRpcRequest, JsonRpcResponse } from './types/json-rpc'
3
+ import { encrypt } from './encryption'
4
+ import { WebSocketClient } from './websocket'
5
+ import logger from './logger'
6
6
 
7
7
  export function createJsonRpcRequest(method: string, params: any): JsonRpcRequest {
8
8
  return {
package/src/mobile.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { bytesToHex } from '@noble/ciphers/utils'
2
- import { getWebSocketClient, WebSocketClient } from '@/websocket'
3
- import { sendEncryptedJsonRpcRequest } from '@/json-rpc'
4
- import { decrypt, generateECDHKeyPair, getSharedSecret } from '@/encryption'
5
- import { JsonRpcRequest } from '@/types/json-rpc'
6
- import logger from '@/logger'
2
+ import { getWebSocketClient, WebSocketClient } from './websocket'
3
+ import { sendEncryptedJsonRpcRequest } from './json-rpc'
4
+ import { decrypt, generateECDHKeyPair, getSharedSecret } from './encryption'
5
+ import { JsonRpcRequest } from './types/json-rpc'
6
+ import logger from './logger'
7
7
 
8
8
  export class ZkPassportProver {
9
9
  private domain?: string