@settlemint/sdk-ipfs 2.6.2 → 2.6.3
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/browser/ipfs.js.map +1 -1
- package/dist/ipfs.cjs +8 -4
- package/dist/ipfs.cjs.map +1 -1
- package/dist/ipfs.js.map +1 -1
- package/package.json +4 -4
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.3/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.3/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.3/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.3/sdk/ipfs/src/ipfs.ts#L60) |
|
|
116
116
|
|
|
117
117
|
##### Throws
|
|
118
118
|
|
package/dist/browser/ipfs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.js","names":[],"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,sBAAsB,EAAE,OAAO,EAE1C,UAAU;;;;;
|
|
1
|
+
{"version":3,"file":"ipfs.js","names":[],"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,sBAAsB,EAAE,OAAO,EAE1C,UAAU,WACX,CAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAa,kBAAkB,UAAU,EAC1C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;ACOF,SAAgB,iBAAiB,SAAmD;CAClF,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;AAE/D,QAAO,EACL,QAAQ,OAAO,EACb,KAAK,iBAAiB,UACvB,CAAC,EACH;;;;;;;;;;;;;;;;;;;;;AAsBH,SAAgB,uBAAuB,SAAyD;AAC9F,eAAc;CACd,MAAM,mBAAmB,SAAS,2BAA2B,QAAQ;AAErE,QAAO,EACL,QAAQ,OAAO;EACb,KAAK,iBAAiB;EACtB,SAAS,iBAAiB,cACtB,EACE,gBAAgB,iBAAiB,aAClC,GACD;EACL,CAAC,EACH"}
|
package/dist/ipfs.cjs
CHANGED
|
@@ -22,10 +22,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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);
|
|
29
|
+
let kubo_rpc_client = require("kubo-rpc-client");
|
|
30
|
+
kubo_rpc_client = __toESM(kubo_rpc_client);
|
|
31
|
+
let zod = require("zod");
|
|
32
|
+
zod = __toESM(zod);
|
|
29
33
|
|
|
30
34
|
//#region src/helpers/client-options.schema.ts
|
|
31
35
|
/**
|
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,6CACX,CAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAaC,oDAAkB,UAAU,EAC1C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;ACOF,SAAgB,iBAAiB,SAAmD;CAClF,MAAM,mEAA4B,qBAAqB,QAAQ;AAE/D,QAAO,EACL,oCAAe,EACb,KAAK,iBAAiB,UACvB,CAAC,EACH;;;;;;;;;;;;;;;;;;;;;AAsBH,SAAgB,uBAAuB,SAAyD;AAC9F,mDAAc;CACd,MAAM,mEAA4B,2BAA2B,QAAQ;AAErE,QAAO,EACL,oCAAe;EACb,KAAK,iBAAiB;EACtB,SAAS,iBAAiB,cACtB,EACE,gBAAgB,iBAAiB,aAClC,GACD;EACL,CAAC,EACH"}
|
package/dist/ipfs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.js","names":[],"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,sBAAsB,EAAE,OAAO,EAE1C,UAAU;;;;;
|
|
1
|
+
{"version":3,"file":"ipfs.js","names":[],"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,sBAAsB,EAAE,OAAO,EAE1C,UAAU,WACX,CAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAa,kBAAkB,UAAU,EAC1C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;ACOF,SAAgB,iBAAiB,SAAmD;CAClF,MAAM,mBAAmB,SAAS,qBAAqB,QAAQ;AAE/D,QAAO,EACL,QAAQ,OAAO,EACb,KAAK,iBAAiB,UACvB,CAAC,EACH;;;;;;;;;;;;;;;;;;;;;AAsBH,SAAgB,uBAAuB,SAAyD;AAC9F,eAAc;CACd,MAAM,mBAAmB,SAAS,2BAA2B,QAAQ;AAErE,QAAO,EACL,QAAQ,OAAO;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.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "FSL-1.1-MIT",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsdown",
|
|
44
|
-
"dev": "tsdown --watch",
|
|
44
|
+
"dev": "tsdown --watch ./src",
|
|
45
45
|
"publint": "publint run --strict",
|
|
46
46
|
"attw": "attw --pack .",
|
|
47
47
|
"test": "bun test",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@settlemint/sdk-utils": "2.6.
|
|
57
|
-
"kubo-rpc-client": "^
|
|
56
|
+
"@settlemint/sdk-utils": "2.6.3",
|
|
57
|
+
"kubo-rpc-client": "^6.0.0",
|
|
58
58
|
"zod": "^4"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {},
|