@1sat/utils 0.0.1
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/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +235 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @1sat/utils - Utility functions for 1Sat Ordinals SDK
|
|
3
|
+
*
|
|
4
|
+
* For byte manipulation, use @bsv/sdk Utils directly:
|
|
5
|
+
* import { Utils } from '@bsv/sdk'
|
|
6
|
+
* const { toArray, toBase64, toHex, toUTF8 } = Utils
|
|
7
|
+
*/
|
|
8
|
+
import type { CollectionItemSubTypeData, CollectionSubTypeData, IconInscription, MAP, PreMAP } from '@1sat/types';
|
|
9
|
+
/**
|
|
10
|
+
* Parse an outpoint string (txid_vout) into its components
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseOutpoint(outpoint: string): {
|
|
13
|
+
txid: string;
|
|
14
|
+
vout: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Format txid and vout into an outpoint string
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatOutpoint(txid: string, vout: number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Validate that a string is a valid outpoint format
|
|
22
|
+
*/
|
|
23
|
+
export declare function isValidOutpoint(outpoint: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Convert PreMAP metadata to MAP by stringifying non-string values
|
|
26
|
+
* Arrays and objects are JSON.stringify'd, other values are String()'d
|
|
27
|
+
*/
|
|
28
|
+
export declare function stringifyMetaData(metaData?: PreMAP): MAP | undefined;
|
|
29
|
+
export declare const ErrorOversizedIcon: Error;
|
|
30
|
+
export declare const ErrorIconProportions: Error;
|
|
31
|
+
export declare const ErrorInvalidIconData: Error;
|
|
32
|
+
export declare const ErrorImageDimensionsUndefined: Error;
|
|
33
|
+
/**
|
|
34
|
+
* Validate icon inscription data
|
|
35
|
+
* Returns null if valid, Error if invalid
|
|
36
|
+
*/
|
|
37
|
+
export declare function validIconData(icon: IconInscription): Promise<Error | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Validate icon outpoint format (txid_vout)
|
|
40
|
+
*/
|
|
41
|
+
export declare function validIconFormat(icon: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Validate collection or collection item subtype data
|
|
44
|
+
* Returns Error if validation fails, undefined if valid
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateSubTypeData(subType: 'collection' | 'collectionItem', subTypeData: CollectionItemSubTypeData | CollectionSubTypeData): Error | undefined;
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACX,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,EAEf,GAAG,EACH,MAAM,EACN,MAAM,aAAa,CAAA;AAUpB;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACZ,CAWA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAuBzD;AAMD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAqBpE;AAMD,eAAO,MAAM,kBAAkB,OAE9B,CAAA;AACD,eAAO,MAAM,oBAAoB,OAA4C,CAAA;AAC7E,eAAO,MAAM,oBAAoB,OAAsC,CAAA;AACvE,eAAO,MAAM,6BAA6B,OAEzC,CAAA;AA2CD;;;GAGG;AACH,wBAAsB,aAAa,CAClC,IAAI,EAAE,eAAe,GACnB,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CA6BvB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,YAAY,GAAG,gBAAgB,EACxC,WAAW,EAAE,yBAAyB,GAAG,qBAAqB,GAC5D,KAAK,GAAG,SAAS,CAgFnB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @1sat/utils - Utility functions for 1Sat Ordinals SDK
|
|
3
|
+
*
|
|
4
|
+
* For byte manipulation, use @bsv/sdk Utils directly:
|
|
5
|
+
* import { Utils } from '@bsv/sdk'
|
|
6
|
+
* const { toArray, toBase64, toHex, toUTF8 } = Utils
|
|
7
|
+
*/
|
|
8
|
+
import { Utils } from '@bsv/sdk';
|
|
9
|
+
import { imageMeta } from 'image-meta';
|
|
10
|
+
const { toArray, toUTF8 } = Utils;
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Outpoint Utilities
|
|
13
|
+
// ============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Parse an outpoint string (txid_vout) into its components
|
|
16
|
+
*/
|
|
17
|
+
export function parseOutpoint(outpoint) {
|
|
18
|
+
const parts = outpoint.split('_');
|
|
19
|
+
if (parts.length !== 2) {
|
|
20
|
+
throw new Error(`Invalid outpoint format: ${outpoint}`);
|
|
21
|
+
}
|
|
22
|
+
const [txid, voutStr] = parts;
|
|
23
|
+
const vout = Number.parseInt(voutStr, 10);
|
|
24
|
+
if (Number.isNaN(vout)) {
|
|
25
|
+
throw new Error(`Invalid vout in outpoint: ${outpoint}`);
|
|
26
|
+
}
|
|
27
|
+
return { txid, vout };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format txid and vout into an outpoint string
|
|
31
|
+
*/
|
|
32
|
+
export function formatOutpoint(txid, vout) {
|
|
33
|
+
return `${txid}_${vout}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validate that a string is a valid outpoint format
|
|
37
|
+
*/
|
|
38
|
+
export function isValidOutpoint(outpoint) {
|
|
39
|
+
if (!outpoint.includes('_') || outpoint.endsWith('_')) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const parts = outpoint.split('_');
|
|
43
|
+
if (parts.length !== 2) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const [txid, voutStr] = parts;
|
|
47
|
+
const vout = Number.parseInt(voutStr, 10);
|
|
48
|
+
if (Number.isNaN(vout) || vout < 0) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// txid should be 64 hex characters (unless it starts with _)
|
|
52
|
+
if (!outpoint.startsWith('_') && txid.length !== 64) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// Metadata Utilities
|
|
59
|
+
// ============================================================================
|
|
60
|
+
/**
|
|
61
|
+
* Convert PreMAP metadata to MAP by stringifying non-string values
|
|
62
|
+
* Arrays and objects are JSON.stringify'd, other values are String()'d
|
|
63
|
+
*/
|
|
64
|
+
export function stringifyMetaData(metaData) {
|
|
65
|
+
if (!metaData)
|
|
66
|
+
return undefined;
|
|
67
|
+
const result = {
|
|
68
|
+
app: metaData.app,
|
|
69
|
+
type: metaData.type,
|
|
70
|
+
};
|
|
71
|
+
for (const [key, value] of Object.entries(metaData)) {
|
|
72
|
+
if (value !== undefined) {
|
|
73
|
+
if (typeof value === 'string') {
|
|
74
|
+
result[key] = value;
|
|
75
|
+
}
|
|
76
|
+
else if (Array.isArray(value) || typeof value === 'object') {
|
|
77
|
+
result[key] = JSON.stringify(value);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
result[key] = String(value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// Icon Validation
|
|
88
|
+
// ============================================================================
|
|
89
|
+
export const ErrorOversizedIcon = new Error('Image must be a square image with dimensions <= 400x400');
|
|
90
|
+
export const ErrorIconProportions = new Error('Image must be a square image');
|
|
91
|
+
export const ErrorInvalidIconData = new Error('Error processing image');
|
|
92
|
+
export const ErrorImageDimensionsUndefined = new Error('Image dimensions are undefined');
|
|
93
|
+
const IMAGE_CONTENT_TYPES = [
|
|
94
|
+
'image/png',
|
|
95
|
+
'image/jpeg',
|
|
96
|
+
'image/gif',
|
|
97
|
+
'image/svg+xml',
|
|
98
|
+
'image/webp',
|
|
99
|
+
];
|
|
100
|
+
function isImageContentType(value) {
|
|
101
|
+
return IMAGE_CONTENT_TYPES.includes(value);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Validate an SVG icon (base64 encoded)
|
|
105
|
+
*/
|
|
106
|
+
function validateSvg(svgBase64) {
|
|
107
|
+
const svgString = toUTF8(toArray(svgBase64, 'base64'));
|
|
108
|
+
const widthMatch = svgString.match(/<svg[^>]*\s+width="([^"]+)"/);
|
|
109
|
+
const heightMatch = svgString.match(/<svg[^>]*\s+height="([^"]+)"/);
|
|
110
|
+
if (!widthMatch || !heightMatch) {
|
|
111
|
+
return ErrorImageDimensionsUndefined;
|
|
112
|
+
}
|
|
113
|
+
const width = Number.parseInt(widthMatch[1], 10);
|
|
114
|
+
const height = Number.parseInt(heightMatch[1], 10);
|
|
115
|
+
if (Number.isNaN(width) || Number.isNaN(height)) {
|
|
116
|
+
return ErrorImageDimensionsUndefined;
|
|
117
|
+
}
|
|
118
|
+
if (width !== height) {
|
|
119
|
+
return ErrorIconProportions;
|
|
120
|
+
}
|
|
121
|
+
if (width > 400 || height > 400) {
|
|
122
|
+
return ErrorOversizedIcon;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Validate icon inscription data
|
|
128
|
+
* Returns null if valid, Error if invalid
|
|
129
|
+
*/
|
|
130
|
+
export async function validIconData(icon) {
|
|
131
|
+
const { dataB64, contentType } = icon;
|
|
132
|
+
if (contentType === 'image/svg+xml') {
|
|
133
|
+
return validateSvg(dataB64);
|
|
134
|
+
}
|
|
135
|
+
if (!isImageContentType(contentType)) {
|
|
136
|
+
return ErrorInvalidIconData;
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
const buffer = Uint8Array.from(toArray(dataB64, 'base64'));
|
|
140
|
+
const dimensions = imageMeta(buffer);
|
|
141
|
+
if (dimensions.width === undefined || dimensions.height === undefined) {
|
|
142
|
+
return ErrorImageDimensionsUndefined;
|
|
143
|
+
}
|
|
144
|
+
if (dimensions.width !== dimensions.height) {
|
|
145
|
+
return ErrorIconProportions;
|
|
146
|
+
}
|
|
147
|
+
if (dimensions.width > 400 || dimensions.height > 400) {
|
|
148
|
+
return ErrorOversizedIcon;
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return ErrorInvalidIconData;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Validate icon outpoint format (txid_vout)
|
|
158
|
+
*/
|
|
159
|
+
export function validIconFormat(icon) {
|
|
160
|
+
return isValidOutpoint(icon);
|
|
161
|
+
}
|
|
162
|
+
// ============================================================================
|
|
163
|
+
// SubType Data Validation
|
|
164
|
+
// ============================================================================
|
|
165
|
+
/**
|
|
166
|
+
* Validate collection or collection item subtype data
|
|
167
|
+
* Returns Error if validation fails, undefined if valid
|
|
168
|
+
*/
|
|
169
|
+
export function validateSubTypeData(subType, subTypeData) {
|
|
170
|
+
try {
|
|
171
|
+
if (subType === 'collection') {
|
|
172
|
+
const collectionData = subTypeData;
|
|
173
|
+
if (!collectionData.description) {
|
|
174
|
+
return new Error('Collection description is required');
|
|
175
|
+
}
|
|
176
|
+
if (!collectionData.quantity) {
|
|
177
|
+
return new Error('Collection quantity is required');
|
|
178
|
+
}
|
|
179
|
+
if (collectionData.rarityLabels) {
|
|
180
|
+
if (!Array.isArray(collectionData.rarityLabels)) {
|
|
181
|
+
return new Error('Rarity labels must be an array');
|
|
182
|
+
}
|
|
183
|
+
if (!collectionData.rarityLabels.every((label) => {
|
|
184
|
+
return Object.values(label).every((value) => typeof value === 'string');
|
|
185
|
+
})) {
|
|
186
|
+
return new Error(`Invalid rarity labels ${collectionData.rarityLabels}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (collectionData.traits) {
|
|
190
|
+
if (typeof collectionData.traits !== 'object') {
|
|
191
|
+
return new Error('Collection traits must be an object');
|
|
192
|
+
}
|
|
193
|
+
if (!Object.keys(collectionData.traits).every((key) => typeof key === 'string' &&
|
|
194
|
+
typeof collectionData.traits[key] === 'object')) {
|
|
195
|
+
return new Error('Collection traits must be a valid CollectionTraits object');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (subType === 'collectionItem') {
|
|
200
|
+
const itemData = subTypeData;
|
|
201
|
+
if (!itemData.collectionId) {
|
|
202
|
+
return new Error('Collection id is required');
|
|
203
|
+
}
|
|
204
|
+
if (!itemData.collectionId.includes('_')) {
|
|
205
|
+
return new Error('Collection id must be a valid outpoint');
|
|
206
|
+
}
|
|
207
|
+
if (itemData.collectionId.split('_')[0].length !== 64) {
|
|
208
|
+
return new Error('Collection id must contain a valid txid');
|
|
209
|
+
}
|
|
210
|
+
if (Number.isNaN(Number.parseInt(itemData.collectionId.split('_')[1]))) {
|
|
211
|
+
return new Error('Collection id must contain a valid vout');
|
|
212
|
+
}
|
|
213
|
+
if (itemData.mintNumber && typeof itemData.mintNumber !== 'number') {
|
|
214
|
+
return new Error('Mint number must be a number');
|
|
215
|
+
}
|
|
216
|
+
if (itemData.rank && typeof itemData.rank !== 'number') {
|
|
217
|
+
return new Error('Rank must be a number');
|
|
218
|
+
}
|
|
219
|
+
if (itemData.rarityLabel && typeof itemData.rarityLabel !== 'string') {
|
|
220
|
+
return new Error('Rarity label must be a string');
|
|
221
|
+
}
|
|
222
|
+
if (itemData.traits && typeof itemData.traits !== 'object') {
|
|
223
|
+
return new Error('Traits must be an object');
|
|
224
|
+
}
|
|
225
|
+
if (itemData.attachments && !Array.isArray(itemData.attachments)) {
|
|
226
|
+
return new Error('Attachments must be an array');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return new Error('Invalid JSON data');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;AAEjC,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAI7C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACjC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,EAAE,CAAC,CAAA;IACxD,CAAC;IACD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAA;IAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACzC,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;Q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S,CAAA;IACjB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;IACtC,CAAC;AACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@1sat/utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Utility functions for 1Sat Ordinals SDK",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
19
|
+
},
|
|
20
|
+
"keywords": ["1sat", "bsv", "ordinals", "utils"],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@1sat/types": "workspace:*",
|
|
24
|
+
"image-meta": "^0.2.2"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@bsv/sdk": "^1.9.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@bsv/sdk": "^1.9.24",
|
|
31
|
+
"typescript": "^5.9.3"
|
|
32
|
+
}
|
|
33
|
+
}
|