@settlemint/sdk-ipfs 2.3.5-pra0b86359 → 2.3.5-prb695ce87
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 +2 -2
- package/dist/browser/ipfs.d.ts +1 -1
- package/dist/browser/ipfs.js +2 -2
- package/dist/browser/ipfs.js.map +1 -1
- package/dist/ipfs.cjs +2 -2
- package/dist/ipfs.cjs.map +1 -1
- package/dist/ipfs.d.cts +1 -1
- package/dist/ipfs.d.ts +1 -1
- package/dist/ipfs.js +2 -2
- package/dist/ipfs.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -100,8 +100,8 @@ Creates an IPFS client for server-side use with authentication
|
|
|
100
100
|
|
|
101
101
|
| Parameter | Type | Description |
|
|
102
102
|
| ------ | ------ | ------ |
|
|
103
|
-
| `options` | \{ `accessToken
|
|
104
|
-
| `options.accessToken
|
|
103
|
+
| `options` | \{ `accessToken?`: `string`; `instance`: `string`; \} | Configuration options for the client including authentication |
|
|
104
|
+
| `options.accessToken?` | `string` | The access token used to authenticate with the SettleMint platform |
|
|
105
105
|
| `options.instance` | `string` | The URL of the IPFS instance to connect to |
|
|
106
106
|
|
|
107
107
|
##### Returns
|
package/dist/browser/ipfs.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
21
21
|
*/
|
|
22
22
|
declare const ServerClientOptionsSchema: z.ZodObject<{
|
|
23
23
|
instance: z.ZodString;
|
|
24
|
-
accessToken: z.ZodString
|
|
24
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
25
25
|
}, z.core.$strip>;
|
|
26
26
|
/**
|
|
27
27
|
* Type definition for server client options derived from the ServerClientOptionsSchema.
|
package/dist/browser/ipfs.js
CHANGED
|
@@ -12,7 +12,7 @@ const ClientOptionsSchema = z.object({ instance: UrlSchema });
|
|
|
12
12
|
* Schema for validating server client options for the IPFS client.
|
|
13
13
|
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
14
14
|
*/
|
|
15
|
-
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: AccessTokenSchema });
|
|
15
|
+
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: AccessTokenSchema.optional() });
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/ipfs.ts
|
|
@@ -64,7 +64,7 @@ function createServerIpfsClient(options) {
|
|
|
64
64
|
const validatedOptions = validate(ServerClientOptionsSchema, options);
|
|
65
65
|
return { client: create({
|
|
66
66
|
url: validatedOptions.instance,
|
|
67
|
-
headers: { "x-auth-token": validatedOptions.accessToken }
|
|
67
|
+
headers: validatedOptions.accessToken ? { "x-auth-token": validatedOptions.accessToken } : undefined
|
|
68
68
|
}) };
|
|
69
69
|
}
|
|
70
70
|
|
package/dist/browser/ipfs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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:
|
|
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.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,UACX,EAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAa,kBAAkB,UAAU,CAC1C,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,iBAAiB,cACtB,EACE,gBAAgB,iBAAiB,YAClC,IACD;CACL,EAAC,CACH;AACF"}
|
package/dist/ipfs.cjs
CHANGED
|
@@ -35,7 +35,7 @@ const ClientOptionsSchema = zod_v4.z.object({ instance: __settlemint_sdk_utils_v
|
|
|
35
35
|
* Schema for validating server client options for the IPFS client.
|
|
36
36
|
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
37
37
|
*/
|
|
38
|
-
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: __settlemint_sdk_utils_validation.AccessTokenSchema });
|
|
38
|
+
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: __settlemint_sdk_utils_validation.AccessTokenSchema.optional() });
|
|
39
39
|
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/ipfs.ts
|
|
@@ -87,7 +87,7 @@ function createServerIpfsClient(options) {
|
|
|
87
87
|
const validatedOptions = (0, __settlemint_sdk_utils_validation.validate)(ServerClientOptionsSchema, options);
|
|
88
88
|
return { client: (0, kubo_rpc_client.create)({
|
|
89
89
|
url: validatedOptions.instance,
|
|
90
|
-
headers: { "x-auth-token": validatedOptions.accessToken }
|
|
90
|
+
headers: validatedOptions.accessToken ? { "x-auth-token": validatedOptions.accessToken } : undefined
|
|
91
91
|
}) };
|
|
92
92
|
}
|
|
93
93
|
|
package/dist/ipfs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs.cjs","names":["UrlSchema","
|
|
1
|
+
{"version":3,"file":"ipfs.cjs","names":["UrlSchema","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.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,SAAE,OAAO,EAE1C,UAAUA,4CACX,EAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAa,oDAAkB,UAAU,CAC1C,EAAC;;;;;;;;;;;;;;;;;;;;;;;;ACOF,SAAgB,iBAAiBC,SAAmD;CAClF,MAAM,mBAAmB,gDAAS,qBAAqB,QAAQ;AAE/D,QAAO,EACL,QAAQ,4BAAO,EACb,KAAK,iBAAiB,SACvB,EAAC,CACH;AACF;;;;;;;;;;;;;;;;;;;;AAqBD,SAAgB,uBAAuBC,SAAyD;AAC9F,mDAAc;CACd,MAAM,mBAAmB,gDAAS,2BAA2B,QAAQ;AAErE,QAAO,EACL,QAAQ,4BAAO;EACb,KAAK,iBAAiB;EACtB,SAAS,iBAAiB,cACtB,EACE,gBAAgB,iBAAiB,YAClC,IACD;CACL,EAAC,CACH;AACF"}
|
package/dist/ipfs.d.cts
CHANGED
|
@@ -21,7 +21,7 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
21
21
|
*/
|
|
22
22
|
declare const ServerClientOptionsSchema: z.ZodObject<{
|
|
23
23
|
instance: z.ZodString;
|
|
24
|
-
accessToken: z.ZodString
|
|
24
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
25
25
|
}, z.core.$strip>;
|
|
26
26
|
/**
|
|
27
27
|
* Type definition for server client options derived from the ServerClientOptionsSchema.
|
package/dist/ipfs.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
|
|
21
21
|
*/
|
|
22
22
|
declare const ServerClientOptionsSchema: z.ZodObject<{
|
|
23
23
|
instance: z.ZodString;
|
|
24
|
-
accessToken: z.ZodString
|
|
24
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
25
25
|
}, z.core.$strip>;
|
|
26
26
|
/**
|
|
27
27
|
* Type definition for server client options derived from the ServerClientOptionsSchema.
|
package/dist/ipfs.js
CHANGED
|
@@ -12,7 +12,7 @@ const ClientOptionsSchema = z.object({ instance: UrlSchema });
|
|
|
12
12
|
* Schema for validating server client options for the IPFS client.
|
|
13
13
|
* Extends the ClientOptionsSchema with additional server-specific fields.
|
|
14
14
|
*/
|
|
15
|
-
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: AccessTokenSchema });
|
|
15
|
+
const ServerClientOptionsSchema = ClientOptionsSchema.extend({ accessToken: AccessTokenSchema.optional() });
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/ipfs.ts
|
|
@@ -64,7 +64,7 @@ function createServerIpfsClient(options) {
|
|
|
64
64
|
const validatedOptions = validate(ServerClientOptionsSchema, options);
|
|
65
65
|
return { client: create({
|
|
66
66
|
url: validatedOptions.instance,
|
|
67
|
-
headers: { "x-auth-token": validatedOptions.accessToken }
|
|
67
|
+
headers: validatedOptions.accessToken ? { "x-auth-token": validatedOptions.accessToken } : undefined
|
|
68
68
|
}) };
|
|
69
69
|
}
|
|
70
70
|
|
package/dist/ipfs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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:
|
|
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.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,UACX,EAAC;;;;;AAWF,MAAa,4BAA4B,oBAAoB,OAAO,EAElE,aAAa,kBAAkB,UAAU,CAC1C,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,iBAAiB,cACtB,EACE,gBAAgB,iBAAiB,YAClC,IACD;CACL,EAAC,CACH;AACF"}
|
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.5-
|
|
4
|
+
"version": "2.3.5-prb695ce87",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"license": "FSL-1.1-MIT",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@settlemint/sdk-utils": "2.3.5-
|
|
54
|
+
"@settlemint/sdk-utils": "2.3.5-prb695ce87",
|
|
55
55
|
"kubo-rpc-client": "^5",
|
|
56
56
|
"zod": "^3.25.0"
|
|
57
57
|
},
|