@nibgate/sdk 0.1.2 → 0.1.4

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
@@ -166,6 +166,7 @@ const premiumGuide = {
166
166
  let lastPayment = null;
167
167
 
168
168
  const rating = createOnchainRating(premiumGuide, {
169
+ // Optional on Arc Testnet. The SDK defaults to NIBGATE_REPUTATION_CONTRACT.
169
170
  contractAddress: process.env.NEXT_PUBLIC_NIBGATE_REPUTATION_CONTRACT,
170
171
  siteId: process.env.NEXT_PUBLIC_NIBGATE_SITE_ID,
171
172
  token: process.env.NEXT_PUBLIC_NIBGATE_SITE_TOKEN,
@@ -194,6 +195,8 @@ createEvmGatewayUnlock(premiumGuide, {
194
195
 
195
196
  The lower-level `rateContentOnchain(resource, options)` function is also exported for custom UIs.
196
197
 
198
+ The SDK exports the current Arc Testnet reputation deployment as `NIBGATE_REPUTATION_CONTRACT`, plus `NIBGATE_REPUTATION_CHAIN_ID`, `NIBGATE_REPUTATION_CHAIN_NAME`, and `NIBGATE_REPUTATION_RPC_URL`. Pass `contractAddress` only when overriding the default deployment.
199
+
197
200
  Ratings are proof-gated. Page views, time spent, scroll depth, and referrers are analytics signals; they should not become trust by themselves. Reputation-critical inputs use indexed onchain rating proofs. Signed ratings remain available only for local tests and migration tooling.
198
201
 
199
202
  Nibgate reputation uses a versioned content identity:
@@ -337,6 +340,7 @@ Nibgate settings
337
340
  - Price
338
341
  - Currency
339
342
  - Payment receiver for this exact content
343
+ - Ratings enabled: on / off
340
344
  - License or citation terms
341
345
  ```
342
346
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nibgate/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Framework-agnostic browser and server package for creator-owned gated content, unlock events, and receipts.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -75,7 +75,7 @@ export function rateResource(resource, rating = {}, extra = {}) {
75
75
  return emit('content_rating', payload);
76
76
  }
77
77
 
78
- export { contentRatingHash, NIBGATE_CONTENT_HASH_NAMESPACE, NIBGATE_REPUTATION_ABI, rateContentOnchain, reviewTextHash } from './reputation.js';
78
+ export { contentRatingHash, NIBGATE_CONTENT_HASH_NAMESPACE, NIBGATE_REPUTATION_ABI, NIBGATE_REPUTATION_CHAIN_ID, NIBGATE_REPUTATION_CHAIN_NAME, NIBGATE_REPUTATION_CONTRACT, NIBGATE_REPUTATION_RPC_URL, rateContentOnchain, reviewTextHash } from './reputation.js';
79
79
 
80
80
  export function trackResourcePage(resource, options = {}) {
81
81
  const item = createGate(resource, options.gateOptions || {});
@@ -6,6 +6,10 @@ const RATE_CONTENT_SELECTOR = '0xc62fad09';
6
6
  const ZERO_HASH = `0x${'0'.repeat(64)}`;
7
7
 
8
8
  export const NIBGATE_CONTENT_HASH_NAMESPACE = 'nibgate:content:v1';
9
+ export const NIBGATE_REPUTATION_CHAIN_ID = 5042002;
10
+ export const NIBGATE_REPUTATION_CHAIN_NAME = 'Arc Testnet';
11
+ export const NIBGATE_REPUTATION_RPC_URL = 'https://rpc.testnet.arc.network';
12
+ export const NIBGATE_REPUTATION_CONTRACT = '0x9f27fd62e75f86a3c7addfdba443aab1f930e281';
9
13
 
10
14
  export const NIBGATE_REPUTATION_ABI = [
11
15
  {
@@ -105,7 +109,7 @@ export async function rateContentOnchain(resource, options = {}) {
105
109
  const provider = options.provider || globalThis?.ethereum;
106
110
  if (!provider?.request) throw new Error('Connect an EVM wallet to rate this content onchain.');
107
111
 
108
- const contractAddress = options.contractAddress || options.reputationContract;
112
+ const contractAddress = options.contractAddress || options.reputationContract || NIBGATE_REPUTATION_CONTRACT;
109
113
  if (!contractAddress) throw new Error('Nibgate reputation contract address is not configured.');
110
114
 
111
115
  const accounts = await provider.request({ method: 'eth_requestAccounts' });
@@ -77,7 +77,12 @@ export function normalizeResource(resource = {}) {
77
77
  imageUrl: input.imageUrl || input.image || undefined,
78
78
  tags: input.tags || undefined,
79
79
  access: normalizeAccessPolicy(input.access),
80
- unlock: normalizeUnlockPolicy(input.unlock)
80
+ unlock: normalizeUnlockPolicy(input.unlock),
81
+ ratingsEnabled: input.ratingsEnabled ?? input.enableRatings ?? input.reputation?.ratingsEnabled ?? true,
82
+ reputation: {
83
+ ...(typeof input.reputation === 'object' && input.reputation ? input.reputation : {}),
84
+ ratingsEnabled: input.ratingsEnabled ?? input.enableRatings ?? input.reputation?.ratingsEnabled ?? true
85
+ }
81
86
  };
82
87
  }
83
88
 
@@ -11,6 +11,7 @@ export const NIBGATE_CONTENT_SETTING_FIELDS = [
11
11
  { name: 'price', label: 'Price', type: 'text', defaultValue: '0.005' },
12
12
  { name: 'currency', label: 'Currency', type: 'text', defaultValue: 'USDC' },
13
13
  { name: 'recipient', label: 'Recipient wallet', type: 'wallet', defaultValue: '' },
14
+ { name: 'ratingsEnabled', label: 'Enable ratings', type: 'boolean', defaultValue: true },
14
15
  { name: 'license', label: 'License / terms', type: 'textarea', defaultValue: '' }
15
16
  ];
16
17
 
@@ -31,6 +32,7 @@ export function createNibgateContentSettings(input = {}) {
31
32
  price: String(input.price ?? input.amount ?? '0.005'),
32
33
  currency: input.currency || 'USDC',
33
34
  recipient: input.recipient || input.payTo || input.receiverAddress || input.creatorWallet || '',
35
+ ratingsEnabled: input.ratingsEnabled ?? input.enableRatings ?? input.reputation?.ratingsEnabled ?? true,
34
36
  license: input.license || input.terms || ''
35
37
  };
36
38
  }
package/src/index.d.ts CHANGED
@@ -42,6 +42,12 @@ export type NibgateResource = {
42
42
  tags?: readonly string[] | string;
43
43
  access?: NibgateAccessMode | NibgateAccessPolicy;
44
44
  unlock?: NibgateUnlockMode | NibgateUnlockPolicy;
45
+ ratingsEnabled?: boolean;
46
+ enableRatings?: boolean;
47
+ reputation?: {
48
+ ratingsEnabled?: boolean;
49
+ [key: string]: unknown;
50
+ };
45
51
  [key: string]: unknown;
46
52
  };
47
53
 
@@ -380,6 +386,7 @@ export type NibgateContentSettings = {
380
386
  price: string;
381
387
  currency: string;
382
388
  recipient: string;
389
+ ratingsEnabled: boolean;
383
390
  license: string;
384
391
  };
385
392
  export declare const NIBGATE_CONTENT_SETTING_FIELDS: readonly NibgateContentSettingField[];
@@ -411,6 +418,10 @@ export declare function setupResourcePage(resource: NibgateResource | string, op
411
418
  export declare function rateResource(resource: NibgateResource | string, rating?: NibgateRating | number, extra?: Record<string, unknown>): boolean;
412
419
  export declare const NIBGATE_REPUTATION_ABI: readonly unknown[];
413
420
  export declare const NIBGATE_CONTENT_HASH_NAMESPACE: 'nibgate:content:v1';
421
+ export declare const NIBGATE_REPUTATION_CHAIN_ID: 5042002;
422
+ export declare const NIBGATE_REPUTATION_CHAIN_NAME: 'Arc Testnet';
423
+ export declare const NIBGATE_REPUTATION_RPC_URL: 'https://rpc.testnet.arc.network';
424
+ export declare const NIBGATE_REPUTATION_CONTRACT: '0x9f27fd62e75f86a3c7addfdba443aab1f930e281';
414
425
  export declare function contentRatingHash(resource: NibgateResource | string, options?: Record<string, unknown>): string;
415
426
  export declare function reviewTextHash(review?: string): string;
416
427
  export declare function rateContentOnchain(resource: NibgateResource | string, options: NibgateOnchainRatingOptions): Promise<NibgateOnchainRatingResult>;
package/src/server.d.ts CHANGED
@@ -68,9 +68,11 @@ export type NibgateContentSettings = {
68
68
  humanAccess: NibgateAccessMode;
69
69
  agentAccess: NibgateAccessMode;
70
70
  unlockMode: NibgateUnlockMode | string;
71
+ paymentRail: NibgatePaymentRail | string;
71
72
  price: string;
72
73
  currency: string;
73
74
  recipient: string;
75
+ ratingsEnabled: boolean;
74
76
  license: string;
75
77
  };
76
78
  export declare const NIBGATE_CONTENT_SETTING_FIELDS: readonly NibgateContentSettingField[];