@nibgate/sdk 0.2.7 → 0.2.8
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/SKILL.md +19 -0
- package/dist/nibgate.js +15 -1
- package/dist/nibgate.js.map +2 -2
- package/dist/nibgate.min.js +2 -2
- package/dist/nibgate.min.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/evm-gateway.js +16 -1
- package/src/browser/index.js +1 -1
- package/src/index.d.ts +3 -0
|
@@ -12,11 +12,17 @@ export async function createCircleGatewayBrowserAdapter(options = {}) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const DEFAULT_CIRCLE_CDN = 'https://esm.sh/@circle-fin/x402-batching@3.2.0/client?bundle';
|
|
15
|
+
const HOSTED_PAY_URL = 'https://api.nibgate.xyz/api/hub/pay';
|
|
16
|
+
|
|
17
|
+
function resolveAccessPath(resource, options) {
|
|
18
|
+
if (options.hosted || options.accessPath === 'hosted') return HOSTED_PAY_URL;
|
|
19
|
+
return options.accessPath || resource.accessPath || '/api/nibgate/access';
|
|
20
|
+
}
|
|
15
21
|
|
|
16
22
|
export function createEvmGatewayUnlock(resource, options = {}) {
|
|
17
23
|
const item = createGate(resource, options.gateOptions || {});
|
|
18
24
|
const win = browserWindow();
|
|
19
|
-
const accessPath =
|
|
25
|
+
const accessPath = resolveAccessPath(item.resource, options);
|
|
20
26
|
const source = options.source || 'nibgate-evm-gateway';
|
|
21
27
|
const network = options.network || 'eip155:5042002';
|
|
22
28
|
const statusTarget = typeof options.status === 'string' ? win?.document.querySelector(options.status) : options.status;
|
|
@@ -180,3 +186,12 @@ export function createEvmGatewayUnlock(resource, options = {}) {
|
|
|
180
186
|
if (options.autoMount !== false) mount();
|
|
181
187
|
return controller;
|
|
182
188
|
}
|
|
189
|
+
|
|
190
|
+
export function createHostedUnlock(resource, options = {}) {
|
|
191
|
+
return createEvmGatewayUnlock(resource, {
|
|
192
|
+
...options,
|
|
193
|
+
hosted: true,
|
|
194
|
+
circleClientModuleUrl: options.circleClientModuleUrl || DEFAULT_CIRCLE_CDN,
|
|
195
|
+
noWalletMessage: options.noWalletMessage || 'Install MetaMask or another EVM wallet to unlock premium content.',
|
|
196
|
+
});
|
|
197
|
+
}
|
package/src/browser/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { createGate } from './gate.js';
|
|
|
2
2
|
export { checkResourceAccess, payWithPaymentSignature, payAndUnlockResource } from './access.js';
|
|
3
3
|
export { createWalletCheckout } from './checkout.js';
|
|
4
4
|
export { createNibgate, nibgate } from './client.js';
|
|
5
|
-
export { createEvmGatewayUnlock, createCircleGatewayBrowserAdapter } from './evm-gateway.js';
|
|
5
|
+
export { createEvmGatewayUnlock, createHostedUnlock, createCircleGatewayBrowserAdapter } from './evm-gateway.js';
|
|
6
6
|
export { rateResource, createOnchainRating, mountRatingUI } from './rating-ui.js';
|
|
7
7
|
export { trackResourcePage, setupResourcePage } from './track.js';
|
|
8
8
|
export { createTransferCheckout, payWithTransfer } from './transfer.js';
|
package/src/index.d.ts
CHANGED
|
@@ -112,6 +112,7 @@ export type NibgateClient = {
|
|
|
112
112
|
createTransferCheckout(resource: NibgateResource | string, options: NibgateTransferCheckoutOptions): NibgateTransferCheckout;
|
|
113
113
|
payWithTransfer(resource: NibgateResource | string, options: NibgateTransferCheckoutOptions & NibgateAccessCheckOptions): Promise<NibgateAccessCheckResult>;
|
|
114
114
|
createEvmGatewayUnlock(resource: NibgateResource | string, options?: NibgateEvmGatewayUnlockOptions): NibgateEvmGatewayUnlockController;
|
|
115
|
+
createHostedUnlock(resource: NibgateResource | string, options?: NibgateEvmGatewayUnlockOptions): NibgateEvmGatewayUnlockController;
|
|
115
116
|
rateContentOnchain(resource: NibgateResource | string, options: NibgateOnchainRatingOptions): Promise<NibgateOnchainRatingResult>;
|
|
116
117
|
createOnchainRating(resource: NibgateResource | string, options?: NibgateOnchainRatingUiOptions): NibgateOnchainRatingController;
|
|
117
118
|
mountRatingUI(resource: NibgateResource | string, options?: NibgateRatingUiOptions): NibgateRatingUiController | null;
|
|
@@ -227,6 +228,7 @@ export type NibgateCircleGatewayBrowserAdapter = {
|
|
|
227
228
|
|
|
228
229
|
export type NibgateEvmGatewayUnlockOptions = {
|
|
229
230
|
source?: string;
|
|
231
|
+
hosted?: boolean;
|
|
230
232
|
accessPath?: string;
|
|
231
233
|
network?: string;
|
|
232
234
|
paymentProvider?: string;
|
|
@@ -414,6 +416,7 @@ export declare function payWithPaymentSignature(resource: NibgateResource | stri
|
|
|
414
416
|
export declare function createWalletCheckout(resource: NibgateResource | string, options: NibgateWalletCheckoutOptions): NibgateWalletCheckoutController;
|
|
415
417
|
export declare function createCircleGatewayBrowserAdapter(options: NibgateCircleGatewayBrowserAdapterOptions): Promise<NibgateCircleGatewayBrowserAdapter>;
|
|
416
418
|
export declare function createEvmGatewayUnlock(resource: NibgateResource | string, options?: NibgateEvmGatewayUnlockOptions): NibgateEvmGatewayUnlockController;
|
|
419
|
+
export declare function createHostedUnlock(resource: NibgateResource | string, options?: NibgateEvmGatewayUnlockOptions): NibgateEvmGatewayUnlockController;
|
|
417
420
|
export declare function payAndUnlockResource(resource: NibgateResource | string, options?: NibgatePaymentOptions): Promise<NibgatePaymentResult>;
|
|
418
421
|
export declare function setupResourcePage(resource: NibgateResource | string, options?: NibgatePageSetupOptions): NibgateGate;
|
|
419
422
|
export declare function rateResource(resource: NibgateResource | string, rating?: NibgateRating | number, extra?: Record<string, unknown>): boolean;
|