prividium 0.1.2 → 0.1.3

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
@@ -1,8 +1,8 @@
1
- # Prividium SDK & CLI
1
+ # Prividium SDK & CLI
2
2
 
3
- A TypeScript SDK and CLI for integrating with the Prividium authorization system. The SDK provides popup OAuth, token
4
- management, and a viem transport for secure RPC; the CLI runs a local authenticated JSON-RPC proxy to your Prividium RPC
5
- and manages basic configuration.
3
+ A TypeScript SDK and CLI for integrating with the Prividium authorization system. The SDK provides popup OAuth, token
4
+ management, and a viem transport for secure RPC; the CLI runs a local authenticated JSON-RPC proxy to your Prividium
5
+ RPC and manages basic configuration.
6
6
 
7
7
  ## Features
8
8
 
@@ -31,7 +31,7 @@ npx prividium proxy
31
31
 
32
32
  ## Quick Start
33
33
 
34
- ### 1. Create a Prividium Chain
34
+ ### 1. Create a Prividium Chain
35
35
 
36
36
  ```typescript
37
37
  import { createPrividiumChain } from 'prividium';
@@ -40,7 +40,7 @@ import { defineChain, createPublicClient, http } from 'viem';
40
40
  // Define your chain
41
41
  const prividiumChain = defineChain({
42
42
  id: 7777,
43
- name: 'Prividium Chain',
43
+ name: 'Prividium Chain',
44
44
  nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
45
45
  rpcUrls: { default: { http: [] } },
46
46
  blockExplorers: { default: { name: 'Explorer', url: 'https://explorer.prividium.io' } }
@@ -54,6 +54,7 @@ const prividium = createPrividiumChain({
54
54
  chain: prividiumChain,
55
55
  rpcUrl: 'https://rpc.prividium.io',
56
56
  authBaseUrl: 'https://auth.prividium.io',
57
+ permissionsApiBaseUrl: 'https://permissions.prividium.io/api',
57
58
  redirectUrl: window.location.origin + '/auth/callback',
58
59
  onAuthExpiry: () => {
59
60
  console.log('Authentication expired - please reconnect');
@@ -88,13 +89,13 @@ const balance = await client.getBalance({
88
89
 
89
90
  ### 4. Sending Transactions with Injected Wallets (MetaMask)
90
91
 
91
- Before sending transactions through injected wallets, you need to add the Prividium network and enable wallet RPC for
92
+ Before sending transactions through injected wallets, you need to add the Prividium network and enable wallet RPC for
92
93
  each transaction.
93
94
 
94
95
  ```typescript
95
96
  import { createWalletClient, custom, encodeFunctionData } from 'viem';
96
97
 
97
- // Add Prividium network to MetaMask
98
+ // Add Prividium network to MetaMask
98
99
  await prividium.addNetworkToWallet();
99
100
 
100
101
  // Create wallet client for MetaMask
@@ -172,7 +173,7 @@ page at the `redirectUrl` you configured:
172
173
 
173
174
  **How it works:**
174
175
 
175
- 1. User clicks "Login" → SDK opens popup to Prividium user panel
176
+ 1. User clicks "Login" → SDK opens popup to Prividium user panel
176
177
  2. User authenticates → user panel redirects popup to your callback page
177
178
  3. Callback page calls `handleAuthCallback()` → token is posted back to parent via `postMessage`
178
179
  4. SDK receives token, validates state parameter (CSRF protection), and closes popup
@@ -194,6 +195,7 @@ const prividium = createPrividiumChain({
194
195
  chain: prividiumChain,
195
196
  rpcUrl: 'https://rpc.prividium.io',
196
197
  authBaseUrl: 'https://auth.prividium.io',
198
+ permissionsApiBaseUrl: 'https://permissions.prividium.io/api',
197
199
  redirectUrl: window.location.origin + '/auth/callback',
198
200
  onAuthExpiry: () => {
199
201
  console.log('Authentication expired');
@@ -217,7 +219,7 @@ are not met, the user panel will guide them through the necessary setup steps be
217
219
 
218
220
  ### `createPrividiumChain(config)`
219
221
 
220
- Creates a new Prividium SDK instance.
222
+ Creates a new Prividium SDK instance.
221
223
 
222
224
  **Parameters:**
223
225
 
@@ -227,6 +229,7 @@ interface PrividiumConfig {
227
229
  chain: Chain; // Viem chain configuration (without rpcUrls)
228
230
  rpcUrl: string; // Private RPC endpoint URL
229
231
  authBaseUrl: string; // Authorization service base URL
232
+ permissionsApiBaseUrl: string; // Permissions API service base URL
230
233
  redirectUrl: string; // OAuth redirect URL
231
234
  storage?: Storage; // Custom storage implementation (optional)
232
235
  onAuthExpiry?: () => void; // Called when authentication expires (optional)
@@ -333,7 +336,7 @@ const prividium = createPrividiumChain({
333
336
 
334
337
  ### Multiple Chains
335
338
 
336
- Support multiple Prividium chains:
339
+ Support multiple Prividium chains:
337
340
 
338
341
  ```typescript
339
342
  const testnetPrividium = createPrividiumChain({
@@ -341,6 +344,7 @@ const testnetPrividium = createPrividiumChain({
341
344
  chain: testnetChain,
342
345
  rpcUrl: 'https://testnet-rpc.prividium.io',
343
346
  authBaseUrl: 'https://testnet-auth.prividium.io',
347
+ permissionsApiBaseUrl: 'https://testnet-permissions.prividium.io/api',
344
348
  redirectUrl: window.location.origin + '/auth/callback'
345
349
  });
346
350
 
@@ -349,6 +353,7 @@ const mainnetPrividium = createPrividiumChain({
349
353
  chain: mainnetChain,
350
354
  rpcUrl: 'https://mainnet-rpc.prividium.io',
351
355
  authBaseUrl: 'https://mainnet-auth.prividium.io',
356
+ permissionsApiBaseUrl: 'https://mainnet-permissions.prividium.io/api',
352
357
  redirectUrl: window.location.origin + '/auth/callback'
353
358
  });
354
359
  ```
@@ -404,9 +409,13 @@ The SDK uses the following localStorage keys:
404
409
 
405
410
  ## CLI
406
411
 
407
- Run a local, authenticated RPC proxy that forwards JSON-RPC requests to your Prividium RPC while injecting the OAuth
412
+ Run a local, authenticated RPC proxy that forwards JSON-RPC requests to your Prividium RPC while injecting the OAuth
408
413
  token obtained via a quick browser sign-in.
409
414
 
415
+ The proxy CLI is particularly useful for deploying contracts with standard Ethereum tools (like Foundry or Hardhat)
416
+ without having to manage authentication manually. The proxy automatically handles authentication headers, allowing you
417
+ to use your existing deployment workflows.
418
+
410
419
  ### Install & Run
411
420
 
412
421
  - Use without installing: `npx prividium proxy`
@@ -430,8 +439,8 @@ What happens:
430
439
 
431
440
  Flags:
432
441
 
433
- - `--rpc-url, -r` (string): Target Prividium RPC URL.
434
- - `--user-panel-url, -u` (string): URL used to log in to Prividium.
442
+ - `--rpc-url, -r` (string): Target Prividium RPC URL.
443
+ - `--user-panel-url, -u` (string): URL used to log in to Prividium™.
435
444
  - `--port, -p` (number, default `24101`): Local proxy port. This has to match with the port configured in the admin
436
445
  panel, which by default uses this same port.
437
446
  - `--host, -h` (string, default `127.0.0.1`): host binded to server. By default only connections comming from local
@@ -23,13 +23,13 @@ export const addConfig = (cli) => {
23
23
  .command('set', 'Updates config', (yargs) => yargs
24
24
  .option('rpcUrl', {
25
25
  alias: ['rpc-url', 'r'],
26
- description: 'Specifies target Prividium rpc url. These takes precedence over config file and env variable.',
26
+ description: 'Specifies target Prividium rpc url. These takes precedence over config file and env variable.',
27
27
  demandOption: true,
28
28
  type: 'string'
29
29
  })
30
30
  .option('userPanelUrl', {
31
31
  alias: ['user-panel-url', 'u'],
32
- description: 'Specifies url used to log in into the Prividium network. Takes precedence over config file and env variable',
32
+ description: 'Specifies url used to log in into the Prividium network. Takes precedence over config file and env variable',
33
33
  type: 'string',
34
34
  demandOption: true
35
35
  }), (args) => updateConfig({
@@ -35,13 +35,13 @@ export const addProxy = (cli) => {
35
35
  return cli.command('proxy', 'Starts authenticated rpc proxy server', (yargs) => yargs
36
36
  .option('rpcUrl', {
37
37
  alias: ['rpc-url', 'r'],
38
- description: 'Specifies target Prividium rpc url. These takes precedence over config file and env variable.',
38
+ description: 'Specifies target Prividium rpc url. These takes precedence over config file and env variable.',
39
39
  demandOption: false,
40
40
  type: 'string'
41
41
  })
42
42
  .option('userPanelUrl', {
43
43
  alias: ['user-panel-url', 'u'],
44
- description: 'Specifies url used to log in into the Prividium network. Takes precedence over config file and env variable',
44
+ description: 'Specifies url used to log in into the Prividium network. Takes precedence over config file and env variable',
45
45
  type: 'string'
46
46
  })
47
47
  .option('configPath', {
@@ -52,7 +52,7 @@ export const addProxy = (cli) => {
52
52
  })
53
53
  .option('port', {
54
54
  alias: ['p'],
55
- description: 'Port used for local proxy. This has to match with the port configured in your Prividium network.',
55
+ description: 'Port used for local proxy. This has to match with the port configured in your Prividium network.',
56
56
  default: 24101,
57
57
  type: 'number'
58
58
  })
@@ -49,7 +49,7 @@ export class ConfigFile {
49
49
  }
50
50
  print() {
51
51
  const { prividiumRpcUrl, userPanelUrl } = this.read();
52
- console.log(`${color.bold('Prividium rpc url')}: ${prividiumRpcUrl}`);
52
+ console.log(`${color.bold('Prividium rpc url')}: ${prividiumRpcUrl}`);
53
53
  console.log(`${color.bold('Log in url')}: ${userPanelUrl}`);
54
54
  }
55
55
  printPath() {
@@ -19,7 +19,7 @@ export class CreationWorkflow {
19
19
  start() {
20
20
  console.log(color.blue(HEADER));
21
21
  console.log('');
22
- intro('Starting prividium proxy');
22
+ intro('Starting Prividium™ proxy');
23
23
  }
24
24
  async gatherData(maybePrividiumRpcUrl, maybeUserPanelUrl) {
25
25
  const { url: prividiumRpcUrl, prompted: prompted1 } = await this.askForUrl(maybePrividiumRpcUrl, 'prividium rpc');
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>Prividium</title>
6
+ <title>Prividium™</title>
7
7
  <script src="https://cdn.tailwindcss.com"></script>
8
8
  </head>
9
9
  <body
@@ -16,7 +16,7 @@
16
16
  id="main-title"
17
17
  class="text-2xl md:text-3xl font-bold bg-gradient-to-r from-blue-700 to-blue-900 bg-clip-text text-transparent"
18
18
  >
19
- Finalizing Prividium sign-in...
19
+ Finalizing Prividium sign-in...
20
20
  </h1>
21
21
  <div class="mt-4">
22
22
  <svg
@@ -35,7 +35,7 @@
35
35
  </div>
36
36
  <div id="proxy-url" style="display: none" class="mt-6 text-blue-700 text-center">
37
37
  <img src="https://www.zksync.io/faq/faq-brackets.svg" alt="Success" class="h-12 w-auto mx-auto mb-3" />
38
- <span>You can now access your Prividium RPC proxy at: </span>
38
+ <span>You can now access your Prividium RPC proxy at: </span>
39
39
  <span class="font-bold">http://127.0.0.1:24101/rpc</span>
40
40
  </div>
41
41
  </div>
@@ -1,5 +1,5 @@
1
1
  import { http } from 'viem';
2
- import { chainConfig } from 'viem/zksync';
2
+ import { mainnet } from 'viem/chains';
3
3
  import { LocalStorage, TokenManager } from './storage.js';
4
4
  import { PopupAuth } from './popup-auth.js';
5
5
  export function createPrividiumChain(config) {
@@ -43,14 +43,15 @@ export function createPrividiumChain(config) {
43
43
  });
44
44
  return {
45
45
  chain: {
46
- ...chainConfig,
46
+ ...mainnet,
47
47
  ...config.chain,
48
+ id: config.chain.id,
48
49
  contracts: {
49
- ...chainConfig.contracts,
50
50
  ...config.chain.contracts,
51
- multicall3: undefined // Prividium doesn't support multicall yet
51
+ multicall3: undefined // Prividium doesn't support multicall yet
52
52
  },
53
- rpcUrls: { default: { http: [config.rpcUrl] } }
53
+ rpcUrls: { default: { http: [config.rpcUrl] } },
54
+ blockExplorers: config.chain.blockExplorers
54
55
  },
55
56
  transport,
56
57
  async authorize(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prividium",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "bin": {
5
5
  "prividium": "./bin/cli.js"
6
6
  },