@settlemint/sdk-ipfs 2.3.2-mainb65cc53b → 2.3.2-maineefa9743
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/ipfs.cjs +55 -83
- package/dist/ipfs.cjs.map +1 -1
- package/dist/ipfs.d.cts +7 -15
- package/dist/ipfs.d.ts +7 -15
- package/dist/ipfs.mjs +43 -0
- package/dist/ipfs.mjs.map +1 -0
- package/package.json +6 -6
- package/dist/browser/ipfs.d.ts +0 -81
- package/dist/browser/ipfs.js +0 -73
- package/dist/browser/ipfs.js.map +0 -1
- package/dist/ipfs.js +0 -73
- package/dist/ipfs.js.map +0 -1
package/dist/ipfs.cjs
CHANGED
|
@@ -1,97 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
1
|
+
"use strict";
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
8
10
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
17
|
};
|
|
18
|
-
var
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
// src/ipfs.ts
|
|
21
|
+
var ipfs_exports = {};
|
|
22
|
+
__export(ipfs_exports, {
|
|
23
|
+
createIpfsClient: () => createIpfsClient,
|
|
24
|
+
createServerIpfsClient: () => createServerIpfsClient
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(ipfs_exports);
|
|
27
|
+
var import_runtime = require("@settlemint/sdk-utils/runtime");
|
|
28
|
+
var import_validation2 = require("@settlemint/sdk-utils/validation");
|
|
29
|
+
var import_kubo_rpc_client = require("kubo-rpc-client");
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
|
|
31
|
+
// src/helpers/client-options.schema.ts
|
|
32
|
+
var import_validation = require("@settlemint/sdk-utils/validation");
|
|
33
|
+
var import_v4 = require("zod/v4");
|
|
34
|
+
var ClientOptionsSchema = import_v4.z.object({
|
|
35
|
+
/** The URL of the IPFS instance to connect to */
|
|
36
|
+
instance: import_validation.UrlSchema
|
|
37
|
+
});
|
|
38
|
+
var ServerClientOptionsSchema = ClientOptionsSchema.extend({
|
|
39
|
+
/** The access token used to authenticate with the SettleMint platform */
|
|
40
|
+
accessToken: import_validation.ApplicationAccessTokenSchema
|
|
41
|
+
});
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
//#region src/ipfs.ts
|
|
42
|
-
/**
|
|
43
|
-
* Creates an IPFS client for client-side use
|
|
44
|
-
*
|
|
45
|
-
* @param options - Configuration options for the client
|
|
46
|
-
* @returns An object containing the configured IPFS client instance
|
|
47
|
-
* @throws Will throw an error if the options fail validation
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* import { createIpfsClient } from '@settlemint/sdk-ipfs';
|
|
51
|
-
*
|
|
52
|
-
* const { client } = createIpfsClient({
|
|
53
|
-
* instance: 'https://ipfs.settlemint.com'
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* // Upload a file using Blob
|
|
57
|
-
* const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
|
|
58
|
-
* const result = await client.add(blob);
|
|
59
|
-
* console.log(result.cid.toString());
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
43
|
+
// src/ipfs.ts
|
|
62
44
|
function createIpfsClient(options) {
|
|
63
|
-
|
|
64
|
-
|
|
45
|
+
const validatedOptions = (0, import_validation2.validate)(ClientOptionsSchema, options);
|
|
46
|
+
return {
|
|
47
|
+
client: (0, import_kubo_rpc_client.create)({
|
|
48
|
+
url: validatedOptions.instance
|
|
49
|
+
})
|
|
50
|
+
};
|
|
65
51
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Creates an IPFS client for server-side use with authentication
|
|
68
|
-
*
|
|
69
|
-
* @param options - Configuration options for the client including authentication
|
|
70
|
-
* @returns An object containing the authenticated IPFS client instance
|
|
71
|
-
* @throws Will throw an error if called on the client side or if options validation fails
|
|
72
|
-
* @example
|
|
73
|
-
* import { createServerIpfsClient } from '@settlemint/sdk-ipfs';
|
|
74
|
-
*
|
|
75
|
-
* const { client } = createServerIpfsClient({
|
|
76
|
-
* instance: process.env.SETTLEMINT_IPFS_ENDPOINT,
|
|
77
|
-
* accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
78
|
-
* });
|
|
79
|
-
*
|
|
80
|
-
* // Upload a file using Blob
|
|
81
|
-
* const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
|
|
82
|
-
* const result = await client.add(blob);
|
|
83
|
-
* console.log(result.cid.toString());
|
|
84
|
-
*/
|
|
85
52
|
function createServerIpfsClient(options) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
53
|
+
(0, import_runtime.ensureServer)();
|
|
54
|
+
const validatedOptions = (0, import_validation2.validate)(ServerClientOptionsSchema, options);
|
|
55
|
+
return {
|
|
56
|
+
client: (0, import_kubo_rpc_client.create)({
|
|
57
|
+
url: validatedOptions.instance,
|
|
58
|
+
headers: {
|
|
59
|
+
"x-auth-token": validatedOptions.accessToken
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
};
|
|
92
63
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
createIpfsClient,
|
|
67
|
+
createServerIpfsClient
|
|
68
|
+
});
|
|
97
69
|
//# sourceMappingURL=ipfs.cjs.map
|
package/dist/ipfs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/ipfs.ts","../src/helpers/client-options.schema.ts"],"sourcesContent":["import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport { type KuboRPCClient, create } from \"kubo-rpc-client\";\nimport {\n type ClientOptions,\n ClientOptionsSchema,\n type ServerClientOptions,\n ServerClientOptionsSchema,\n} from \"./helpers/client-options.schema.js\";\n\n/**\n * Creates an IPFS client for client-side use\n *\n * @param options - Configuration options for the client\n * @returns An object containing the configured IPFS client instance\n * @throws Will throw an error if the options fail validation\n * @example\n * ```ts\n * import { createIpfsClient } from '@settlemint/sdk-ipfs';\n *\n * const { client } = createIpfsClient({\n * instance: 'https://ipfs.settlemint.com'\n * });\n *\n * // Upload a file using Blob\n * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });\n * const result = await client.add(blob);\n * console.log(result.cid.toString());\n * ```\n */\nexport function createIpfsClient(options: ClientOptions): { client: KuboRPCClient } {\n const validatedOptions = validate(ClientOptionsSchema, options);\n\n return {\n client: create({\n url: validatedOptions.instance,\n }),\n };\n}\n\n/**\n * Creates an IPFS client for server-side use with authentication\n *\n * @param options - Configuration options for the client including authentication\n * @returns An object containing the authenticated IPFS client instance\n * @throws Will throw an error if called on the client side or if options validation fails\n * @example\n * import { createServerIpfsClient } from '@settlemint/sdk-ipfs';\n *\n * const { client } = createServerIpfsClient({\n * instance: process.env.SETTLEMINT_IPFS_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN\n * });\n *\n * // Upload a file using Blob\n * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });\n * const result = await client.add(blob);\n * console.log(result.cid.toString());\n */\nexport function createServerIpfsClient(options: ServerClientOptions): { client: KuboRPCClient } {\n ensureServer();\n const validatedOptions = validate(ServerClientOptionsSchema, options);\n\n return {\n client: create({\n url: validatedOptions.instance,\n headers: {\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n };\n}\n","import { ApplicationAccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod/v4\";\n\n/**\n * Schema for validating client options for the IPFS client.\n */\nexport const ClientOptionsSchema = z.object({\n /** The URL of the IPFS instance to connect to */\n instance: UrlSchema,\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Schema for validating server client options for the IPFS client.\n * Extends the ClientOptionsSchema with additional server-specific fields.\n */\nexport const ServerClientOptionsSchema = ClientOptionsSchema.extend({\n /** The access token used to authenticate with the SettleMint platform */\n accessToken: ApplicationAccessTokenSchema,\n});\n\n/**\n * Type definition for server client options derived from the ServerClientOptionsSchema.\n */\nexport type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,IAAAA,qBAAyB;AACzB,6BAA2C;;;ACF3C,wBAAwD;AACxD,gBAAkB;AAKX,IAAM,sBAAsB,YAAE,OAAO;AAAA;AAAA,EAE1C,UAAU;AACZ,CAAC;AAWM,IAAM,4BAA4B,oBAAoB,OAAO;AAAA;AAAA,EAElE,aAAa;AACf,CAAC;;;ADOM,SAAS,iBAAiB,SAAmD;AAClF,QAAM,uBAAmB,6BAAS,qBAAqB,OAAO;AAE9D,SAAO;AAAA,IACL,YAAQ,+BAAO;AAAA,MACb,KAAK,iBAAiB;AAAA,IACxB,CAAC;AAAA,EACH;AACF;AAqBO,SAAS,uBAAuB,SAAyD;AAC9F,mCAAa;AACb,QAAM,uBAAmB,6BAAS,2BAA2B,OAAO;AAEpE,SAAO;AAAA,IACL,YAAQ,+BAAO;AAAA,MACb,KAAK,iBAAiB;AAAA,MACtB,SAAS;AAAA,QACP,gBAAgB,iBAAiB;AAAA,MACnC;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":["import_validation"]}
|
package/dist/ipfs.d.cts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { KuboRPCClient } from
|
|
2
|
-
import { z } from
|
|
1
|
+
import { KuboRPCClient } from 'kubo-rpc-client';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
3
|
|
|
4
|
-
//#region src/helpers/client-options.schema.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Schema for validating client options for the IPFS client.
|
|
7
|
-
*/
|
|
8
4
|
/**
|
|
9
5
|
* Schema for validating client options for the IPFS client.
|
|
10
6
|
*/
|
|
11
7
|
declare const ClientOptionsSchema: z.ZodObject<{
|
|
12
|
-
|
|
8
|
+
instance: z.ZodString;
|
|
13
9
|
}, z.core.$strip>;
|
|
14
10
|
/**
|
|
15
11
|
* Type definition for client options derived from the ClientOptionsSchema.
|
|
@@ -20,16 +16,14 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
20
16
|
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
21
17
|
*/
|
|
22
18
|
declare const ServerClientOptionsSchema: z.ZodObject<{
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
instance: z.ZodString;
|
|
20
|
+
accessToken: z.ZodString;
|
|
25
21
|
}, z.core.$strip>;
|
|
26
22
|
/**
|
|
27
23
|
* Type definition for server client options derived from the ServerClientOptionsSchema.
|
|
28
24
|
*/
|
|
29
25
|
type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;
|
|
30
26
|
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/ipfs.d.ts
|
|
33
27
|
/**
|
|
34
28
|
* Creates an IPFS client for client-side use
|
|
35
29
|
*
|
|
@@ -51,7 +45,7 @@ type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;
|
|
|
51
45
|
* ```
|
|
52
46
|
*/
|
|
53
47
|
declare function createIpfsClient(options: ClientOptions): {
|
|
54
|
-
|
|
48
|
+
client: KuboRPCClient;
|
|
55
49
|
};
|
|
56
50
|
/**
|
|
57
51
|
* Creates an IPFS client for server-side use with authentication
|
|
@@ -73,9 +67,7 @@ declare function createIpfsClient(options: ClientOptions): {
|
|
|
73
67
|
* console.log(result.cid.toString());
|
|
74
68
|
*/
|
|
75
69
|
declare function createServerIpfsClient(options: ServerClientOptions): {
|
|
76
|
-
|
|
70
|
+
client: KuboRPCClient;
|
|
77
71
|
};
|
|
78
72
|
|
|
79
|
-
//#endregion
|
|
80
73
|
export { createIpfsClient, createServerIpfsClient };
|
|
81
|
-
//# sourceMappingURL=ipfs.d.cts.map
|
package/dist/ipfs.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { KuboRPCClient } from
|
|
2
|
-
import { z } from
|
|
1
|
+
import { KuboRPCClient } from 'kubo-rpc-client';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
3
|
|
|
4
|
-
//#region src/helpers/client-options.schema.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Schema for validating client options for the IPFS client.
|
|
7
|
-
*/
|
|
8
4
|
/**
|
|
9
5
|
* Schema for validating client options for the IPFS client.
|
|
10
6
|
*/
|
|
11
7
|
declare const ClientOptionsSchema: z.ZodObject<{
|
|
12
|
-
|
|
8
|
+
instance: z.ZodString;
|
|
13
9
|
}, z.core.$strip>;
|
|
14
10
|
/**
|
|
15
11
|
* Type definition for client options derived from the ClientOptionsSchema.
|
|
@@ -20,16 +16,14 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
20
16
|
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
21
17
|
*/
|
|
22
18
|
declare const ServerClientOptionsSchema: z.ZodObject<{
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
instance: z.ZodString;
|
|
20
|
+
accessToken: z.ZodString;
|
|
25
21
|
}, z.core.$strip>;
|
|
26
22
|
/**
|
|
27
23
|
* Type definition for server client options derived from the ServerClientOptionsSchema.
|
|
28
24
|
*/
|
|
29
25
|
type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;
|
|
30
26
|
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/ipfs.d.ts
|
|
33
27
|
/**
|
|
34
28
|
* Creates an IPFS client for client-side use
|
|
35
29
|
*
|
|
@@ -51,7 +45,7 @@ type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;
|
|
|
51
45
|
* ```
|
|
52
46
|
*/
|
|
53
47
|
declare function createIpfsClient(options: ClientOptions): {
|
|
54
|
-
|
|
48
|
+
client: KuboRPCClient;
|
|
55
49
|
};
|
|
56
50
|
/**
|
|
57
51
|
* Creates an IPFS client for server-side use with authentication
|
|
@@ -73,9 +67,7 @@ declare function createIpfsClient(options: ClientOptions): {
|
|
|
73
67
|
* console.log(result.cid.toString());
|
|
74
68
|
*/
|
|
75
69
|
declare function createServerIpfsClient(options: ServerClientOptions): {
|
|
76
|
-
|
|
70
|
+
client: KuboRPCClient;
|
|
77
71
|
};
|
|
78
72
|
|
|
79
|
-
//#endregion
|
|
80
73
|
export { createIpfsClient, createServerIpfsClient };
|
|
81
|
-
//# sourceMappingURL=ipfs.d.ts.map
|
package/dist/ipfs.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/ipfs.ts
|
|
2
|
+
import { ensureServer } from "@settlemint/sdk-utils/runtime";
|
|
3
|
+
import { validate } from "@settlemint/sdk-utils/validation";
|
|
4
|
+
import { create } from "kubo-rpc-client";
|
|
5
|
+
|
|
6
|
+
// src/helpers/client-options.schema.ts
|
|
7
|
+
import { ApplicationAccessTokenSchema, UrlSchema } from "@settlemint/sdk-utils/validation";
|
|
8
|
+
import { z } from "zod/v4";
|
|
9
|
+
var ClientOptionsSchema = z.object({
|
|
10
|
+
/** The URL of the IPFS instance to connect to */
|
|
11
|
+
instance: UrlSchema
|
|
12
|
+
});
|
|
13
|
+
var ServerClientOptionsSchema = ClientOptionsSchema.extend({
|
|
14
|
+
/** The access token used to authenticate with the SettleMint platform */
|
|
15
|
+
accessToken: ApplicationAccessTokenSchema
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// src/ipfs.ts
|
|
19
|
+
function createIpfsClient(options) {
|
|
20
|
+
const validatedOptions = validate(ClientOptionsSchema, options);
|
|
21
|
+
return {
|
|
22
|
+
client: create({
|
|
23
|
+
url: validatedOptions.instance
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createServerIpfsClient(options) {
|
|
28
|
+
ensureServer();
|
|
29
|
+
const validatedOptions = validate(ServerClientOptionsSchema, options);
|
|
30
|
+
return {
|
|
31
|
+
client: create({
|
|
32
|
+
url: validatedOptions.instance,
|
|
33
|
+
headers: {
|
|
34
|
+
"x-auth-token": validatedOptions.accessToken
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
createIpfsClient,
|
|
41
|
+
createServerIpfsClient
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=ipfs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ipfs.ts","../src/helpers/client-options.schema.ts"],"sourcesContent":["import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport { type KuboRPCClient, create } from \"kubo-rpc-client\";\nimport {\n type ClientOptions,\n ClientOptionsSchema,\n type ServerClientOptions,\n ServerClientOptionsSchema,\n} from \"./helpers/client-options.schema.js\";\n\n/**\n * Creates an IPFS client for client-side use\n *\n * @param options - Configuration options for the client\n * @returns An object containing the configured IPFS client instance\n * @throws Will throw an error if the options fail validation\n * @example\n * ```ts\n * import { createIpfsClient } from '@settlemint/sdk-ipfs';\n *\n * const { client } = createIpfsClient({\n * instance: 'https://ipfs.settlemint.com'\n * });\n *\n * // Upload a file using Blob\n * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });\n * const result = await client.add(blob);\n * console.log(result.cid.toString());\n * ```\n */\nexport function createIpfsClient(options: ClientOptions): { client: KuboRPCClient } {\n const validatedOptions = validate(ClientOptionsSchema, options);\n\n return {\n client: create({\n url: validatedOptions.instance,\n }),\n };\n}\n\n/**\n * Creates an IPFS client for server-side use with authentication\n *\n * @param options - Configuration options for the client including authentication\n * @returns An object containing the authenticated IPFS client instance\n * @throws Will throw an error if called on the client side or if options validation fails\n * @example\n * import { createServerIpfsClient } from '@settlemint/sdk-ipfs';\n *\n * const { client } = createServerIpfsClient({\n * instance: process.env.SETTLEMINT_IPFS_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN\n * });\n *\n * // Upload a file using Blob\n * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });\n * const result = await client.add(blob);\n * console.log(result.cid.toString());\n */\nexport function createServerIpfsClient(options: ServerClientOptions): { client: KuboRPCClient } {\n ensureServer();\n const validatedOptions = validate(ServerClientOptionsSchema, options);\n\n return {\n client: create({\n url: validatedOptions.instance,\n headers: {\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n };\n}\n","import { ApplicationAccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod/v4\";\n\n/**\n * Schema for validating client options for the IPFS client.\n */\nexport const ClientOptionsSchema = z.object({\n /** The URL of the IPFS instance to connect to */\n instance: UrlSchema,\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Schema for validating server client options for the IPFS client.\n * Extends the ClientOptionsSchema with additional server-specific fields.\n */\nexport const ServerClientOptionsSchema = ClientOptionsSchema.extend({\n /** The access token used to authenticate with the SettleMint platform */\n accessToken: ApplicationAccessTokenSchema,\n});\n\n/**\n * Type definition for server client options derived from the ServerClientOptionsSchema.\n */\nexport type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAA6B,cAAc;;;ACF3C,SAAS,8BAA8B,iBAAiB;AACxD,SAAS,SAAS;AAKX,IAAM,sBAAsB,EAAE,OAAO;AAAA;AAAA,EAE1C,UAAU;AACZ,CAAC;AAWM,IAAM,4BAA4B,oBAAoB,OAAO;AAAA;AAAA,EAElE,aAAa;AACf,CAAC;;;ADOM,SAAS,iBAAiB,SAAmD;AAClF,QAAM,mBAAmB,SAAS,qBAAqB,OAAO;AAE9D,SAAO;AAAA,IACL,QAAQ,OAAO;AAAA,MACb,KAAK,iBAAiB;AAAA,IACxB,CAAC;AAAA,EACH;AACF;AAqBO,SAAS,uBAAuB,SAAyD;AAC9F,eAAa;AACb,QAAM,mBAAmB,SAAS,2BAA2B,OAAO;AAEpE,SAAO;AAAA,IACL,QAAQ,OAAO;AAAA,MACb,KAAK,iBAAiB;AAAA,MACtB,SAAS;AAAA,QACP,gBAAgB,iBAAiB;AAAA,MACnC;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@settlemint/sdk-ipfs",
|
|
3
3
|
"description": "IPFS integration module for SettleMint SDK, enabling decentralized storage and content addressing",
|
|
4
|
-
"version": "2.3.2-
|
|
4
|
+
"version": "2.3.2-maineefa9743",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "FSL-1.1-MIT",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": ["dist"],
|
|
24
24
|
"main": "./dist/ipfs.cjs",
|
|
25
|
-
"module": "./dist/ipfs.
|
|
25
|
+
"module": "./dist/ipfs.mjs",
|
|
26
26
|
"types": "./dist/ipfs.d.ts",
|
|
27
27
|
"exports": {
|
|
28
28
|
"./package.json": "./package.json",
|
|
29
29
|
".": {
|
|
30
30
|
"import": {
|
|
31
31
|
"types": "./dist/ipfs.d.ts",
|
|
32
|
-
"default": "./dist/ipfs.
|
|
32
|
+
"default": "./dist/ipfs.mjs"
|
|
33
33
|
},
|
|
34
34
|
"require": {
|
|
35
35
|
"types": "./dist/ipfs.d.cts",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
-
"build": "
|
|
42
|
-
"dev": "
|
|
41
|
+
"build": "tsup-node",
|
|
42
|
+
"dev": "tsup-node --watch",
|
|
43
43
|
"publint": "publint run --strict",
|
|
44
44
|
"attw": "attw --pack .",
|
|
45
45
|
"test": "bun test",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@settlemint/sdk-utils": "2.3.2-
|
|
54
|
+
"@settlemint/sdk-utils": "2.3.2-maineefa9743",
|
|
55
55
|
"kubo-rpc-client": "^5",
|
|
56
56
|
"zod": "^3.25.0"
|
|
57
57
|
},
|
package/dist/browser/ipfs.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { KuboRPCClient } from "kubo-rpc-client";
|
|
2
|
-
import { z } from "zod/v4";
|
|
3
|
-
|
|
4
|
-
//#region src/helpers/client-options.schema.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Schema for validating client options for the IPFS client.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Schema for validating client options for the IPFS client.
|
|
10
|
-
*/
|
|
11
|
-
declare const ClientOptionsSchema: z.ZodObject<{
|
|
12
|
-
instance: z.ZodString;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
/**
|
|
15
|
-
* Type definition for client options derived from the ClientOptionsSchema.
|
|
16
|
-
*/
|
|
17
|
-
type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
18
|
-
/**
|
|
19
|
-
* Schema for validating server client options for the IPFS client.
|
|
20
|
-
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
21
|
-
*/
|
|
22
|
-
declare const ServerClientOptionsSchema: z.ZodObject<{
|
|
23
|
-
instance: z.ZodString;
|
|
24
|
-
accessToken: z.ZodString;
|
|
25
|
-
}, z.core.$strip>;
|
|
26
|
-
/**
|
|
27
|
-
* Type definition for server client options derived from the ServerClientOptionsSchema.
|
|
28
|
-
*/
|
|
29
|
-
type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/ipfs.d.ts
|
|
33
|
-
/**
|
|
34
|
-
* Creates an IPFS client for client-side use
|
|
35
|
-
*
|
|
36
|
-
* @param options - Configuration options for the client
|
|
37
|
-
* @returns An object containing the configured IPFS client instance
|
|
38
|
-
* @throws Will throw an error if the options fail validation
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { createIpfsClient } from '@settlemint/sdk-ipfs';
|
|
42
|
-
*
|
|
43
|
-
* const { client } = createIpfsClient({
|
|
44
|
-
* instance: 'https://ipfs.settlemint.com'
|
|
45
|
-
* });
|
|
46
|
-
*
|
|
47
|
-
* // Upload a file using Blob
|
|
48
|
-
* const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
|
|
49
|
-
* const result = await client.add(blob);
|
|
50
|
-
* console.log(result.cid.toString());
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
declare function createIpfsClient(options: ClientOptions): {
|
|
54
|
-
client: KuboRPCClient;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Creates an IPFS client for server-side use with authentication
|
|
58
|
-
*
|
|
59
|
-
* @param options - Configuration options for the client including authentication
|
|
60
|
-
* @returns An object containing the authenticated IPFS client instance
|
|
61
|
-
* @throws Will throw an error if called on the client side or if options validation fails
|
|
62
|
-
* @example
|
|
63
|
-
* import { createServerIpfsClient } from '@settlemint/sdk-ipfs';
|
|
64
|
-
*
|
|
65
|
-
* const { client } = createServerIpfsClient({
|
|
66
|
-
* instance: process.env.SETTLEMINT_IPFS_ENDPOINT,
|
|
67
|
-
* accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
68
|
-
* });
|
|
69
|
-
*
|
|
70
|
-
* // Upload a file using Blob
|
|
71
|
-
* const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
|
|
72
|
-
* const result = await client.add(blob);
|
|
73
|
-
* console.log(result.cid.toString());
|
|
74
|
-
*/
|
|
75
|
-
declare function createServerIpfsClient(options: ServerClientOptions): {
|
|
76
|
-
client: KuboRPCClient;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
//#endregion
|
|
80
|
-
export { createIpfsClient, createServerIpfsClient };
|
|
81
|
-
//# sourceMappingURL=ipfs.d.ts.map
|
package/dist/browser/ipfs.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { ensureServer } from "@settlemint/sdk-utils/runtime";
|
|
2
|
-
import { AccessTokenSchema, UrlSchema, validate } from "@settlemint/sdk-utils/validation";
|
|
3
|
-
import { create } from "kubo-rpc-client";
|
|
4
|
-
import { z } from "zod/v4";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/client-options.schema.ts
|
|
7
|
-
/**
|
|
8
|
-
* Schema for validating client options for the IPFS client.
|
|
9
|
-
*/
|
|
10
|
-
const ClientOptionsSchema = z.object({ instance: UrlSchema });
|
|
11
|
-
/**
|
|
12
|
-
* Schema for validating server client options for the IPFS client.
|
|
13
|
-
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
14
|
-
*/
|
|
15
|
-
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: AccessTokenSchema });
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/ipfs.ts
|
|
19
|
-
/**
|
|
20
|
-
* Creates an IPFS client for client-side use
|
|
21
|
-
*
|
|
22
|
-
* @param options - Configuration options for the client
|
|
23
|
-
* @returns An object containing the configured IPFS client instance
|
|
24
|
-
* @throws Will throw an error if the options fail validation
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* import { createIpfsClient } from '@settlemint/sdk-ipfs';
|
|
28
|
-
*
|
|
29
|
-
* const { client } = createIpfsClient({
|
|
30
|
-
* instance: 'https://ipfs.settlemint.com'
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // Upload a file using Blob
|
|
34
|
-
* const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
|
|
35
|
-
* const result = await client.add(blob);
|
|
36
|
-
* console.log(result.cid.toString());
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
function createIpfsClient(options) {
|
|
40
|
-
const validatedOptions = validate(ClientOptionsSchema, options);
|
|
41
|
-
return { client: create({ url: validatedOptions.instance }) };
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Creates an IPFS client for server-side use with authentication
|
|
45
|
-
*
|
|
46
|
-
* @param options - Configuration options for the client including authentication
|
|
47
|
-
* @returns An object containing the authenticated IPFS client instance
|
|
48
|
-
* @throws Will throw an error if called on the client side or if options validation fails
|
|
49
|
-
* @example
|
|
50
|
-
* import { createServerIpfsClient } from '@settlemint/sdk-ipfs';
|
|
51
|
-
*
|
|
52
|
-
* const { client } = createServerIpfsClient({
|
|
53
|
-
* instance: process.env.SETTLEMINT_IPFS_ENDPOINT,
|
|
54
|
-
* accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
55
|
-
* });
|
|
56
|
-
*
|
|
57
|
-
* // Upload a file using Blob
|
|
58
|
-
* const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
|
|
59
|
-
* const result = await client.add(blob);
|
|
60
|
-
* console.log(result.cid.toString());
|
|
61
|
-
*/
|
|
62
|
-
function createServerIpfsClient(options) {
|
|
63
|
-
ensureServer();
|
|
64
|
-
const validatedOptions = validate(ServerClientOptionsSchema, options);
|
|
65
|
-
return { client: create({
|
|
66
|
-
url: validatedOptions.instance,
|
|
67
|
-
headers: { "x-auth-token": validatedOptions.accessToken }
|
|
68
|
-
}) };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
export { createIpfsClient, createServerIpfsClient };
|
|
73
|
-
//# sourceMappingURL=ipfs.js.map
|
package/dist/browser/ipfs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.js","names":["options: ClientOptions","options: ServerClientOptions"],"sources":["../../src/helpers/client-options.schema.ts","../../src/ipfs.ts"],"sourcesContent":["import { AccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod/v4\";\n\n/**\n * Schema for validating client options for the IPFS client.\n */\nexport const ClientOptionsSchema = z.object({\n /** The URL of the IPFS instance to connect to */\n instance: UrlSchema,\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Schema for validating server client options for the IPFS client.\n * Extends the ClientOptionsSchema with additional server-specific fields.\n */\nexport const ServerClientOptionsSchema = ClientOptionsSchema.extend({\n /** The access token used to authenticate with the SettleMint platform */\n accessToken: AccessTokenSchema,\n});\n\n/**\n * Type definition for server client options derived from the ServerClientOptionsSchema.\n */\nexport type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;\n","import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport { type KuboRPCClient, create } from \"kubo-rpc-client\";\nimport {\n type ClientOptions,\n ClientOptionsSchema,\n type ServerClientOptions,\n ServerClientOptionsSchema,\n} from \"./helpers/client-options.schema.js\";\n\n/**\n * Creates an IPFS client for client-side use\n *\n * @param options - Configuration options for the client\n * @returns An object containing the configured IPFS client instance\n * @throws Will throw an error if the options fail validation\n * @example\n * ```ts\n * import { createIpfsClient } from '@settlemint/sdk-ipfs';\n *\n * const { client } = createIpfsClient({\n * instance: 'https://ipfs.settlemint.com'\n * });\n *\n * // Upload a file using Blob\n * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });\n * const result = await client.add(blob);\n * console.log(result.cid.toString());\n * ```\n */\nexport function createIpfsClient(options: ClientOptions): { client: KuboRPCClient } {\n const validatedOptions = validate(ClientOptionsSchema, options);\n\n return {\n client: create({\n url: validatedOptions.instance,\n }),\n };\n}\n\n/**\n * Creates an IPFS client for server-side use with authentication\n *\n * @param options - Configuration options for the client including authentication\n * @returns An object containing the authenticated IPFS client instance\n * @throws Will throw an error if called on the client side or if options validation fails\n * @example\n * import { createServerIpfsClient } from '@settlemint/sdk-ipfs';\n *\n * const { client } = createServerIpfsClient({\n * instance: process.env.SETTLEMINT_IPFS_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN\n * });\n *\n * // Upload a file using Blob\n * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });\n * const result = await client.add(blob);\n * console.log(result.cid.toString());\n */\nexport function createServerIpfsClient(options: ServerClientOptions): { client: KuboRPCClient } {\n ensureServer();\n const validatedOptions = validate(ServerClientOptionsSchema, options);\n\n return {\n client: create({\n url: validatedOptions.instance,\n headers: {\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n };\n}\n"],"mappings":";;;;;;;;;AAMA,MAAa,sBAAsB,EAAE,OAAO,EAE1C,UAAU,UACX,EAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAa,kBACd,EAAC;;;;;;;;;;;;;;;;;;;;;;;;ACOF,SAAgB,iBAAiBA,SAAmD;CAClF,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;AAE/D,QAAO,EACL,QAAQ,OAAO,EACb,KAAK,iBAAiB,SACvB,EAAC,CACH;AACF;;;;;;;;;;;;;;;;;;;;AAqBD,SAAgB,uBAAuBC,SAAyD;AAC9F,eAAc;CACd,MAAM,mBAAmB,SAAS,2BAA2B,QAAQ;AAErE,QAAO,EACL,QAAQ,OAAO;EACb,KAAK,iBAAiB;EACtB,SAAS,EACP,gBAAgB,iBAAiB,YAClC;CACF,EAAC,CACH;AACF"}
|
package/dist/ipfs.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { ensureServer } from "@settlemint/sdk-utils/runtime";
|
|
2
|
-
import { AccessTokenSchema, UrlSchema, validate } from "@settlemint/sdk-utils/validation";
|
|
3
|
-
import { create } from "kubo-rpc-client";
|
|
4
|
-
import { z } from "zod/v4";
|
|
5
|
-
|
|
6
|
-
//#region src/helpers/client-options.schema.ts
|
|
7
|
-
/**
|
|
8
|
-
* Schema for validating client options for the IPFS client.
|
|
9
|
-
*/
|
|
10
|
-
const ClientOptionsSchema = z.object({ instance: UrlSchema });
|
|
11
|
-
/**
|
|
12
|
-
* Schema for validating server client options for the IPFS client.
|
|
13
|
-
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
14
|
-
*/
|
|
15
|
-
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: AccessTokenSchema });
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/ipfs.ts
|
|
19
|
-
/**
|
|
20
|
-
* Creates an IPFS client for client-side use
|
|
21
|
-
*
|
|
22
|
-
* @param options - Configuration options for the client
|
|
23
|
-
* @returns An object containing the configured IPFS client instance
|
|
24
|
-
* @throws Will throw an error if the options fail validation
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* import { createIpfsClient } from '@settlemint/sdk-ipfs';
|
|
28
|
-
*
|
|
29
|
-
* const { client } = createIpfsClient({
|
|
30
|
-
* instance: 'https://ipfs.settlemint.com'
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // Upload a file using Blob
|
|
34
|
-
* const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
|
|
35
|
-
* const result = await client.add(blob);
|
|
36
|
-
* console.log(result.cid.toString());
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
function createIpfsClient(options) {
|
|
40
|
-
const validatedOptions = validate(ClientOptionsSchema, options);
|
|
41
|
-
return { client: create({ url: validatedOptions.instance }) };
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Creates an IPFS client for server-side use with authentication
|
|
45
|
-
*
|
|
46
|
-
* @param options - Configuration options for the client including authentication
|
|
47
|
-
* @returns An object containing the authenticated IPFS client instance
|
|
48
|
-
* @throws Will throw an error if called on the client side or if options validation fails
|
|
49
|
-
* @example
|
|
50
|
-
* import { createServerIpfsClient } from '@settlemint/sdk-ipfs';
|
|
51
|
-
*
|
|
52
|
-
* const { client } = createServerIpfsClient({
|
|
53
|
-
* instance: process.env.SETTLEMINT_IPFS_ENDPOINT,
|
|
54
|
-
* accessToken: process.env.SETTLEMINT_ACCESS_TOKEN
|
|
55
|
-
* });
|
|
56
|
-
*
|
|
57
|
-
* // Upload a file using Blob
|
|
58
|
-
* const blob = new Blob(['Hello, world!'], { type: 'text/plain' });
|
|
59
|
-
* const result = await client.add(blob);
|
|
60
|
-
* console.log(result.cid.toString());
|
|
61
|
-
*/
|
|
62
|
-
function createServerIpfsClient(options) {
|
|
63
|
-
ensureServer();
|
|
64
|
-
const validatedOptions = validate(ServerClientOptionsSchema, options);
|
|
65
|
-
return { client: create({
|
|
66
|
-
url: validatedOptions.instance,
|
|
67
|
-
headers: { "x-auth-token": validatedOptions.accessToken }
|
|
68
|
-
}) };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
export { createIpfsClient, createServerIpfsClient };
|
|
73
|
-
//# sourceMappingURL=ipfs.js.map
|
package/dist/ipfs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.js","names":["options: ClientOptions","options: ServerClientOptions"],"sources":["../src/helpers/client-options.schema.ts","../src/ipfs.ts"],"sourcesContent":["import { AccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod/v4\";\n\n/**\n * Schema for validating client options for the IPFS client.\n */\nexport const ClientOptionsSchema = z.object({\n /** The URL of the IPFS instance to connect to */\n instance: UrlSchema,\n});\n\n/**\n * Type definition for client options derived from the ClientOptionsSchema.\n */\nexport type ClientOptions = z.infer<typeof ClientOptionsSchema>;\n\n/**\n * Schema for validating server client options for the IPFS client.\n * Extends the ClientOptionsSchema with additional server-specific fields.\n */\nexport const ServerClientOptionsSchema = ClientOptionsSchema.extend({\n /** The access token used to authenticate with the SettleMint platform */\n accessToken: AccessTokenSchema,\n});\n\n/**\n * Type definition for server client options derived from the ServerClientOptionsSchema.\n */\nexport type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>;\n","import { ensureServer } from \"@settlemint/sdk-utils/runtime\";\nimport { validate } from \"@settlemint/sdk-utils/validation\";\nimport { type KuboRPCClient, create } from \"kubo-rpc-client\";\nimport {\n type ClientOptions,\n ClientOptionsSchema,\n type ServerClientOptions,\n ServerClientOptionsSchema,\n} from \"./helpers/client-options.schema.js\";\n\n/**\n * Creates an IPFS client for client-side use\n *\n * @param options - Configuration options for the client\n * @returns An object containing the configured IPFS client instance\n * @throws Will throw an error if the options fail validation\n * @example\n * ```ts\n * import { createIpfsClient } from '@settlemint/sdk-ipfs';\n *\n * const { client } = createIpfsClient({\n * instance: 'https://ipfs.settlemint.com'\n * });\n *\n * // Upload a file using Blob\n * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });\n * const result = await client.add(blob);\n * console.log(result.cid.toString());\n * ```\n */\nexport function createIpfsClient(options: ClientOptions): { client: KuboRPCClient } {\n const validatedOptions = validate(ClientOptionsSchema, options);\n\n return {\n client: create({\n url: validatedOptions.instance,\n }),\n };\n}\n\n/**\n * Creates an IPFS client for server-side use with authentication\n *\n * @param options - Configuration options for the client including authentication\n * @returns An object containing the authenticated IPFS client instance\n * @throws Will throw an error if called on the client side or if options validation fails\n * @example\n * import { createServerIpfsClient } from '@settlemint/sdk-ipfs';\n *\n * const { client } = createServerIpfsClient({\n * instance: process.env.SETTLEMINT_IPFS_ENDPOINT,\n * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN\n * });\n *\n * // Upload a file using Blob\n * const blob = new Blob(['Hello, world!'], { type: 'text/plain' });\n * const result = await client.add(blob);\n * console.log(result.cid.toString());\n */\nexport function createServerIpfsClient(options: ServerClientOptions): { client: KuboRPCClient } {\n ensureServer();\n const validatedOptions = validate(ServerClientOptionsSchema, options);\n\n return {\n client: create({\n url: validatedOptions.instance,\n headers: {\n \"x-auth-token\": validatedOptions.accessToken,\n },\n }),\n };\n}\n"],"mappings":";;;;;;;;;AAMA,MAAa,sBAAsB,EAAE,OAAO,EAE1C,UAAU,UACX,EAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAa,kBACd,EAAC;;;;;;;;;;;;;;;;;;;;;;;;ACOF,SAAgB,iBAAiBA,SAAmD;CAClF,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;AAE/D,QAAO,EACL,QAAQ,OAAO,EACb,KAAK,iBAAiB,SACvB,EAAC,CACH;AACF;;;;;;;;;;;;;;;;;;;;AAqBD,SAAgB,uBAAuBC,SAAyD;AAC9F,eAAc;CACd,MAAM,mBAAmB,SAAS,2BAA2B,QAAQ;AAErE,QAAO,EACL,QAAQ,OAAO;EACb,KAAK,iBAAiB;EACtB,SAAS,EACP,gBAAgB,iBAAiB,YAClC;CACF,EAAC,CACH;AACF"}
|