@settlemint/sdk-ipfs 2.6.4 → 2.6.6-prc6016dbc
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 +4 -4
- package/dist/ipfs.cjs +7 -34
- package/dist/ipfs.cjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ The SettleMint IPFS SDK provides a simple way to interact with IPFS (InterPlanet
|
|
|
46
46
|
|
|
47
47
|
> **createIpfsClient**(`options`): `object`
|
|
48
48
|
|
|
49
|
-
Defined in: [sdk/ipfs/src/ipfs.ts:31](https://github.com/settlemint/sdk/blob/v2.6.
|
|
49
|
+
Defined in: [sdk/ipfs/src/ipfs.ts:31](https://github.com/settlemint/sdk/blob/v2.6.6/sdk/ipfs/src/ipfs.ts#L31)
|
|
50
50
|
|
|
51
51
|
Creates an IPFS client for client-side use
|
|
52
52
|
|
|
@@ -65,7 +65,7 @@ An object containing the configured IPFS client instance
|
|
|
65
65
|
|
|
66
66
|
| Name | Type | Defined in |
|
|
67
67
|
| ------ | ------ | ------ |
|
|
68
|
-
| `client` | `KuboRPCClient` | [sdk/ipfs/src/ipfs.ts:31](https://github.com/settlemint/sdk/blob/v2.6.
|
|
68
|
+
| `client` | `KuboRPCClient` | [sdk/ipfs/src/ipfs.ts:31](https://github.com/settlemint/sdk/blob/v2.6.6/sdk/ipfs/src/ipfs.ts#L31) |
|
|
69
69
|
|
|
70
70
|
##### Throws
|
|
71
71
|
|
|
@@ -92,7 +92,7 @@ console.log(result.cid.toString());
|
|
|
92
92
|
|
|
93
93
|
> **createServerIpfsClient**(`options`): `object`
|
|
94
94
|
|
|
95
|
-
Defined in: [sdk/ipfs/src/ipfs.ts:60](https://github.com/settlemint/sdk/blob/v2.6.
|
|
95
|
+
Defined in: [sdk/ipfs/src/ipfs.ts:60](https://github.com/settlemint/sdk/blob/v2.6.6/sdk/ipfs/src/ipfs.ts#L60)
|
|
96
96
|
|
|
97
97
|
Creates an IPFS client for server-side use with authentication
|
|
98
98
|
|
|
@@ -112,7 +112,7 @@ An object containing the authenticated IPFS client instance
|
|
|
112
112
|
|
|
113
113
|
| Name | Type | Defined in |
|
|
114
114
|
| ------ | ------ | ------ |
|
|
115
|
-
| `client` | `KuboRPCClient` | [sdk/ipfs/src/ipfs.ts:60](https://github.com/settlemint/sdk/blob/v2.6.
|
|
115
|
+
| `client` | `KuboRPCClient` | [sdk/ipfs/src/ipfs.ts:60](https://github.com/settlemint/sdk/blob/v2.6.6/sdk/ipfs/src/ipfs.ts#L60) |
|
|
116
116
|
|
|
117
117
|
##### Throws
|
|
118
118
|
|
package/dist/ipfs.cjs
CHANGED
|
@@ -1,46 +1,19 @@
|
|
|
1
1
|
/* SettleMint IPFS SDK - Distributed Storage */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
-
value: mod,
|
|
21
|
-
enumerable: true
|
|
22
|
-
}) : target, mod));
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
let __settlemint_sdk_utils_runtime = require("@settlemint/sdk-utils/runtime");
|
|
26
|
-
__settlemint_sdk_utils_runtime = __toESM(__settlemint_sdk_utils_runtime);
|
|
27
|
-
let __settlemint_sdk_utils_validation = require("@settlemint/sdk-utils/validation");
|
|
28
|
-
__settlemint_sdk_utils_validation = __toESM(__settlemint_sdk_utils_validation);
|
|
2
|
+
let _settlemint_sdk_utils_runtime = require("@settlemint/sdk-utils/runtime");
|
|
3
|
+
let _settlemint_sdk_utils_validation = require("@settlemint/sdk-utils/validation");
|
|
29
4
|
let kubo_rpc_client = require("kubo-rpc-client");
|
|
30
|
-
kubo_rpc_client = __toESM(kubo_rpc_client);
|
|
31
5
|
let zod = require("zod");
|
|
32
|
-
zod = __toESM(zod);
|
|
33
6
|
|
|
34
7
|
//#region src/helpers/client-options.schema.ts
|
|
35
8
|
/**
|
|
36
9
|
* Schema for validating client options for the IPFS client.
|
|
37
10
|
*/
|
|
38
|
-
const ClientOptionsSchema = zod.z.object({ instance:
|
|
11
|
+
const ClientOptionsSchema = zod.z.object({ instance: _settlemint_sdk_utils_validation.UrlSchema });
|
|
39
12
|
/**
|
|
40
13
|
* Schema for validating server client options for the IPFS client.
|
|
41
14
|
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
42
15
|
*/
|
|
43
|
-
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken:
|
|
16
|
+
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: _settlemint_sdk_utils_validation.AccessTokenSchema.optional() });
|
|
44
17
|
|
|
45
18
|
//#endregion
|
|
46
19
|
//#region src/ipfs.ts
|
|
@@ -65,7 +38,7 @@ const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: __se
|
|
|
65
38
|
* ```
|
|
66
39
|
*/
|
|
67
40
|
function createIpfsClient(options) {
|
|
68
|
-
const validatedOptions = (0,
|
|
41
|
+
const validatedOptions = (0, _settlemint_sdk_utils_validation.validate)(ClientOptionsSchema, options);
|
|
69
42
|
return { client: (0, kubo_rpc_client.create)({ url: validatedOptions.instance }) };
|
|
70
43
|
}
|
|
71
44
|
/**
|
|
@@ -88,8 +61,8 @@ function createIpfsClient(options) {
|
|
|
88
61
|
* console.log(result.cid.toString());
|
|
89
62
|
*/
|
|
90
63
|
function createServerIpfsClient(options) {
|
|
91
|
-
(0,
|
|
92
|
-
const validatedOptions = (0,
|
|
64
|
+
(0, _settlemint_sdk_utils_runtime.ensureServer)();
|
|
65
|
+
const validatedOptions = (0, _settlemint_sdk_utils_validation.validate)(ServerClientOptionsSchema, options);
|
|
93
66
|
return { client: (0, kubo_rpc_client.create)({
|
|
94
67
|
url: validatedOptions.instance,
|
|
95
68
|
headers: validatedOptions.accessToken ? { "x-auth-token": validatedOptions.accessToken } : undefined
|
package/dist/ipfs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.cjs","names":["z","UrlSchema","AccessTokenSchema"],"sources":["../src/helpers/client-options.schema.ts","../src/ipfs.ts"],"sourcesContent":["import { AccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod\";\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.optional(),\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: validatedOptions.accessToken\n ? {\n \"x-auth-token\": validatedOptions.accessToken,\n }\n : undefined,\n }),\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ipfs.cjs","names":["z","UrlSchema","AccessTokenSchema"],"sources":["../src/helpers/client-options.schema.ts","../src/ipfs.ts"],"sourcesContent":["import { AccessTokenSchema, UrlSchema } from \"@settlemint/sdk-utils/validation\";\nimport { z } from \"zod\";\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.optional(),\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: validatedOptions.accessToken\n ? {\n \"x-auth-token\": validatedOptions.accessToken,\n }\n : undefined,\n }),\n };\n}\n"],"mappings":";;;;;;;;;;AAMA,MAAa,sBAAsBA,MAAE,OAAO,EAE1C,UAAUC,4CACX,CAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAaC,mDAAkB,UAAU,EAC1C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;ACOF,SAAgB,iBAAiB,SAAmD;CAClF,MAAM,kEAA4B,qBAAqB,QAAQ;AAE/D,QAAO,EACL,oCAAe,EACb,KAAK,iBAAiB,UACvB,CAAC,EACH;;;;;;;;;;;;;;;;;;;;;AAsBH,SAAgB,uBAAuB,SAAyD;AAC9F,kDAAc;CACd,MAAM,kEAA4B,2BAA2B,QAAQ;AAErE,QAAO,EACL,oCAAe;EACb,KAAK,iBAAiB;EACtB,SAAS,iBAAiB,cACtB,EACE,gBAAgB,iBAAiB,aAClC,GACD;EACL,CAAC,EACH"}
|
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.6.
|
|
4
|
+
"version": "2.6.6-prc6016dbc",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "FSL-1.1-MIT",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"test": "bun test",
|
|
48
48
|
"test:coverage": "bun test --coverage",
|
|
49
49
|
"typecheck": "tsc --noEmit",
|
|
50
|
-
"publish-npm": "
|
|
50
|
+
"publish-npm": "npm publish --provenance --tag ${TAG} --access public",
|
|
51
51
|
"prepack": "cp ../../LICENSE .",
|
|
52
52
|
"docs": "typedoc --options '../../typedoc.config.mjs' --entryPoints src/ipfs.ts --out ./docs"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@settlemint/sdk-utils": "2.6.
|
|
56
|
+
"@settlemint/sdk-utils": "2.6.6-prc6016dbc",
|
|
57
57
|
"kubo-rpc-client": "^6.0.0",
|
|
58
58
|
"zod": "^4"
|
|
59
59
|
},
|