@stacknet/keyutils 0.3.1 → 0.3.5

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.
@@ -0,0 +1,108 @@
1
+ interface NodeKeyInfo {
2
+ id: string;
3
+ keyIndex?: number | null;
4
+ key: string;
5
+ userId: string;
6
+ status: 'active' | 'inactive' | 'expired' | 'closed' | 'listed';
7
+ tokenBalance: number;
8
+ maxTokens: number;
9
+ createdAt: string;
10
+ expiresAt?: string;
11
+ label?: string;
12
+ paperWork?: string;
13
+ stackId?: string;
14
+ stackName?: string;
15
+ }
16
+ interface LedgerEntry {
17
+ id: string;
18
+ keyId: string;
19
+ type: 'credit' | 'debit' | 'mint' | 'reward';
20
+ amount: number;
21
+ description: string;
22
+ createdAt: string;
23
+ metadata?: Record<string, unknown>;
24
+ }
25
+ interface PricingInfo {
26
+ priceUsd: number;
27
+ priceCents: number;
28
+ priceSol?: number;
29
+ tokenAllocation: number;
30
+ tokenAllocationFormatted: string;
31
+ currentDay: number;
32
+ currentEpoch: number;
33
+ nextHalvingDate: number;
34
+ daysUntilHalving: number;
35
+ keysSold: number;
36
+ saleActive: boolean;
37
+ saleStartDate: number;
38
+ }
39
+ interface MintResult {
40
+ success: boolean;
41
+ key?: NodeKeyInfo;
42
+ transactionId?: string;
43
+ error?: string;
44
+ }
45
+ type PaymentMethod = 'solana' | 'stripe';
46
+ interface KeyListing {
47
+ id: string;
48
+ keyId: string;
49
+ keyIndex?: number | null;
50
+ sellerId: string;
51
+ askPriceCents: number;
52
+ currency: string;
53
+ tokenBalance: number;
54
+ maxTokens: number;
55
+ paperWork?: string;
56
+ stackId?: string;
57
+ stackName?: string;
58
+ status: 'active' | 'sold' | 'cancelled';
59
+ createdAt: number;
60
+ }
61
+ interface ListingResult {
62
+ listingId: string;
63
+ keyId: string;
64
+ askPriceCents: number;
65
+ currency: string;
66
+ status: string;
67
+ }
68
+ interface DirectTransferResult {
69
+ keyId: string;
70
+ fromUserId: string;
71
+ toUserId: string;
72
+ transferredAt: number;
73
+ }
74
+ type Platform = 'ios' | 'android' | 'windows' | 'mac' | 'linux';
75
+ interface PlatformDownload {
76
+ platform: Platform;
77
+ label: string;
78
+ url: string;
79
+ compatible: boolean;
80
+ }
81
+ type KeyWidgetTab = 'buy' | 'use' | 'keys';
82
+ interface KeyUtilsConfig {
83
+ apiBaseUrl: string;
84
+ stackId?: string;
85
+ stackName?: string;
86
+ paymentMethods?: PaymentMethod[];
87
+ merchantWallet?: string;
88
+ protocolTreasuryWallet?: string;
89
+ protocolFeeBps?: number;
90
+ stripePublicKey?: string;
91
+ theme?: 'light' | 'dark' | 'system';
92
+ maxQuantity?: number;
93
+ keyImage?: string;
94
+ keyImageClass?: string;
95
+ aispImage?: string;
96
+ termsUrl?: string;
97
+ solanaRpcUrl?: string;
98
+ }
99
+ interface KeyUtilsCallbacks {
100
+ onMintSuccess?: (result: MintResult) => void;
101
+ onMintError?: (error: Error) => void;
102
+ onPaymentStart?: (method: PaymentMethod) => void;
103
+ onPaymentComplete?: (method: PaymentMethod, transactionId: string) => void;
104
+ onListingCreated?: (listing: ListingResult) => void;
105
+ onTransferComplete?: (result: DirectTransferResult) => void;
106
+ }
107
+
108
+ export type { DirectTransferResult, KeyListing, KeyUtilsCallbacks, KeyUtilsConfig, KeyWidgetTab, LedgerEntry, ListingResult, MintResult, NodeKeyInfo, PaymentMethod, Platform, PlatformDownload, PricingInfo };
@@ -0,0 +1,108 @@
1
+ interface NodeKeyInfo {
2
+ id: string;
3
+ keyIndex?: number | null;
4
+ key: string;
5
+ userId: string;
6
+ status: 'active' | 'inactive' | 'expired' | 'closed' | 'listed';
7
+ tokenBalance: number;
8
+ maxTokens: number;
9
+ createdAt: string;
10
+ expiresAt?: string;
11
+ label?: string;
12
+ paperWork?: string;
13
+ stackId?: string;
14
+ stackName?: string;
15
+ }
16
+ interface LedgerEntry {
17
+ id: string;
18
+ keyId: string;
19
+ type: 'credit' | 'debit' | 'mint' | 'reward';
20
+ amount: number;
21
+ description: string;
22
+ createdAt: string;
23
+ metadata?: Record<string, unknown>;
24
+ }
25
+ interface PricingInfo {
26
+ priceUsd: number;
27
+ priceCents: number;
28
+ priceSol?: number;
29
+ tokenAllocation: number;
30
+ tokenAllocationFormatted: string;
31
+ currentDay: number;
32
+ currentEpoch: number;
33
+ nextHalvingDate: number;
34
+ daysUntilHalving: number;
35
+ keysSold: number;
36
+ saleActive: boolean;
37
+ saleStartDate: number;
38
+ }
39
+ interface MintResult {
40
+ success: boolean;
41
+ key?: NodeKeyInfo;
42
+ transactionId?: string;
43
+ error?: string;
44
+ }
45
+ type PaymentMethod = 'solana' | 'stripe';
46
+ interface KeyListing {
47
+ id: string;
48
+ keyId: string;
49
+ keyIndex?: number | null;
50
+ sellerId: string;
51
+ askPriceCents: number;
52
+ currency: string;
53
+ tokenBalance: number;
54
+ maxTokens: number;
55
+ paperWork?: string;
56
+ stackId?: string;
57
+ stackName?: string;
58
+ status: 'active' | 'sold' | 'cancelled';
59
+ createdAt: number;
60
+ }
61
+ interface ListingResult {
62
+ listingId: string;
63
+ keyId: string;
64
+ askPriceCents: number;
65
+ currency: string;
66
+ status: string;
67
+ }
68
+ interface DirectTransferResult {
69
+ keyId: string;
70
+ fromUserId: string;
71
+ toUserId: string;
72
+ transferredAt: number;
73
+ }
74
+ type Platform = 'ios' | 'android' | 'windows' | 'mac' | 'linux';
75
+ interface PlatformDownload {
76
+ platform: Platform;
77
+ label: string;
78
+ url: string;
79
+ compatible: boolean;
80
+ }
81
+ type KeyWidgetTab = 'buy' | 'use' | 'keys';
82
+ interface KeyUtilsConfig {
83
+ apiBaseUrl: string;
84
+ stackId?: string;
85
+ stackName?: string;
86
+ paymentMethods?: PaymentMethod[];
87
+ merchantWallet?: string;
88
+ protocolTreasuryWallet?: string;
89
+ protocolFeeBps?: number;
90
+ stripePublicKey?: string;
91
+ theme?: 'light' | 'dark' | 'system';
92
+ maxQuantity?: number;
93
+ keyImage?: string;
94
+ keyImageClass?: string;
95
+ aispImage?: string;
96
+ termsUrl?: string;
97
+ solanaRpcUrl?: string;
98
+ }
99
+ interface KeyUtilsCallbacks {
100
+ onMintSuccess?: (result: MintResult) => void;
101
+ onMintError?: (error: Error) => void;
102
+ onPaymentStart?: (method: PaymentMethod) => void;
103
+ onPaymentComplete?: (method: PaymentMethod, transactionId: string) => void;
104
+ onListingCreated?: (listing: ListingResult) => void;
105
+ onTransferComplete?: (result: DirectTransferResult) => void;
106
+ }
107
+
108
+ export type { DirectTransferResult, KeyListing, KeyUtilsCallbacks, KeyUtilsConfig, KeyWidgetTab, LedgerEntry, ListingResult, MintResult, NodeKeyInfo, PaymentMethod, Platform, PlatformDownload, PricingInfo };
File without changes
@@ -0,0 +1 @@
1
+ 'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge');function n(){if(typeof document>"u")return {};let r=document.cookie.match(/(?:^|;\s*)__csrf=([^;]*)/);return r?{"x-csrf-token":r[1]}:{}}function c(...r){return tailwindMerge.twMerge(clsx.clsx(r))}function a(r){return r==null?"0":r>=1e9?`${(r/1e9).toFixed(1)}B`:r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:r.toLocaleString()}function l(r,e){return e<=0?0:Math.min(100,Math.round(r/e*100))}function d(r){return r>=70?"bg-green-500":r>=30?"bg-yellow-500":"bg-red-500"}function m(r){let e=typeof r=="string"&&/^\d+$/.test(r)?Number(r):r,t=new Date(e);return isNaN(t.getTime())?String(r):t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function p(){if(typeof navigator>"u")return "mac";let r=navigator.userAgent.toLowerCase();return /iphone|ipad|ipod/.test(r)?"ios":/android/.test(r)?"android":/win/.test(r)?"windows":/linux/.test(r)?"linux":"mac"}exports.calculateBalancePercentage=l;exports.cn=c;exports.csrfHeaders=n;exports.detectPlatform=p;exports.formatDate=m;exports.formatTokens=a;exports.getBalanceColor=d;
@@ -0,0 +1,14 @@
1
+ import { ClassValue } from 'clsx';
2
+ import { Platform } from '../types/index.cjs';
3
+
4
+ /** Read __csrf cookie and return as x-csrf-token header for mutations */
5
+ declare function csrfHeaders(): Record<string, string>;
6
+
7
+ declare function cn(...inputs: ClassValue[]): string;
8
+ declare function formatTokens(amount: number | undefined | null): string;
9
+ declare function calculateBalancePercentage(current: number, max: number): number;
10
+ declare function getBalanceColor(percentage: number): string;
11
+ declare function formatDate(dateString: string | number): string;
12
+ declare function detectPlatform(): Platform;
13
+
14
+ export { calculateBalancePercentage, cn, csrfHeaders, detectPlatform, formatDate, formatTokens, getBalanceColor };
@@ -0,0 +1,14 @@
1
+ import { ClassValue } from 'clsx';
2
+ import { Platform } from '../types/index.js';
3
+
4
+ /** Read __csrf cookie and return as x-csrf-token header for mutations */
5
+ declare function csrfHeaders(): Record<string, string>;
6
+
7
+ declare function cn(...inputs: ClassValue[]): string;
8
+ declare function formatTokens(amount: number | undefined | null): string;
9
+ declare function calculateBalancePercentage(current: number, max: number): number;
10
+ declare function getBalanceColor(percentage: number): string;
11
+ declare function formatDate(dateString: string | number): string;
12
+ declare function detectPlatform(): Platform;
13
+
14
+ export { calculateBalancePercentage, cn, csrfHeaders, detectPlatform, formatDate, formatTokens, getBalanceColor };
@@ -0,0 +1 @@
1
+ import {clsx}from'clsx';import {twMerge}from'tailwind-merge';function n(){if(typeof document>"u")return {};let r=document.cookie.match(/(?:^|;\s*)__csrf=([^;]*)/);return r?{"x-csrf-token":r[1]}:{}}function c(...r){return twMerge(clsx(r))}function a(r){return r==null?"0":r>=1e9?`${(r/1e9).toFixed(1)}B`:r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:r.toLocaleString()}function l(r,e){return e<=0?0:Math.min(100,Math.round(r/e*100))}function d(r){return r>=70?"bg-green-500":r>=30?"bg-yellow-500":"bg-red-500"}function m(r){let e=typeof r=="string"&&/^\d+$/.test(r)?Number(r):r,t=new Date(e);return isNaN(t.getTime())?String(r):t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function p(){if(typeof navigator>"u")return "mac";let r=navigator.userAgent.toLowerCase();return /iphone|ipad|ipod/.test(r)?"ios":/android/.test(r)?"android":/win/.test(r)?"windows":/linux/.test(r)?"linux":"mac"}export{l as calculateBalancePercentage,c as cn,n as csrfHeaders,p as detectPlatform,m as formatDate,a as formatTokens,d as getBalanceColor};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacknet/keyutils",
3
- "version": "0.3.1",
3
+ "version": "0.3.5",
4
4
  "description": "Reusable components for buying and managing StackNet node keys",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",