@4mica/sdk-deno 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +57 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 4mica Network
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sdk = require('@4mica/sdk');
|
|
4
|
+
var server = require('@4mica/sdk/server');
|
|
5
|
+
|
|
6
|
+
function _interopNamespace(e) {
|
|
7
|
+
if (e && e.__esModule) return e;
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var server__namespace = /*#__PURE__*/_interopNamespace(server);
|
|
25
|
+
|
|
26
|
+
// src/index.ts
|
|
27
|
+
function denoEnv() {
|
|
28
|
+
return typeof Deno !== "undefined" ? Deno.env.toObject() : {};
|
|
29
|
+
}
|
|
30
|
+
function buildConfig(options = {}) {
|
|
31
|
+
const builder = new sdk.ConfigBuilder().fromEnv(options.env ?? denoEnv());
|
|
32
|
+
return (options.configure ? options.configure(builder) : builder).build();
|
|
33
|
+
}
|
|
34
|
+
async function createClient(options = {}) {
|
|
35
|
+
return sdk.Client.new(buildConfig(options));
|
|
36
|
+
}
|
|
37
|
+
async function createPaywall(config, options) {
|
|
38
|
+
const client = await createClient(options);
|
|
39
|
+
return server.createPaywall(client, config);
|
|
40
|
+
}
|
|
41
|
+
function createPaywallFor(verifier, config) {
|
|
42
|
+
return server.createPaywall(verifier, config);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.server = server__namespace;
|
|
46
|
+
exports.buildConfig = buildConfig;
|
|
47
|
+
exports.createClient = createClient;
|
|
48
|
+
exports.createPaywall = createPaywall;
|
|
49
|
+
exports.createPaywallFor = createPaywallFor;
|
|
50
|
+
Object.keys(sdk).forEach(function (k) {
|
|
51
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return sdk[k]; }
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=index.cjs.map
|
|
57
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["ConfigBuilder","Client","coreCreatePaywall"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,OAAA,GAA8C;AACrD,EAAA,OAAO,OAAO,IAAA,KAAS,WAAA,GAAc,KAAK,GAAA,CAAI,QAAA,KAAa,EAAC;AAC9D;AAGO,SAAS,WAAA,CAAY,OAAA,GAA+B,EAAC,EAAW;AACrE,EAAA,MAAM,OAAA,GAAU,IAAIA,iBAAA,EAAc,CAAE,QAAQ,OAAA,CAAQ,GAAA,IAAO,SAAS,CAAA;AACpE,EAAA,OAAA,CAAQ,QAAQ,SAAA,GAAY,OAAA,CAAQ,UAAU,OAAO,CAAA,GAAI,SAAS,KAAA,EAAM;AAC1E;AAGA,eAAsB,YAAA,CACpB,OAAA,GAA+B,EAAC,EACf;AACjB,EAAA,OAAOC,UAAA,CAAO,GAAA,CAAI,WAAA,CAAY,OAAO,CAAC,CAAA;AACxC;AAGA,eAAsB,aAAA,CACpB,QACA,OAAA,EACkB;AAClB,EAAA,MAAM,MAAA,GAAS,MAAM,YAAA,CAAa,OAAO,CAAA;AACzC,EAAA,OAAOC,oBAAA,CAAkB,QAAQ,MAAM,CAAA;AACzC;AAGO,SAAS,gBAAA,CACd,UACA,MAAA,EACS;AACT,EAAA,OAAOA,oBAAA,CAAkB,UAAU,MAAM,CAAA;AAC3C","file":"index.cjs","sourcesContent":["import type { Config } from \"@4mica/sdk\";\nimport { Client, ConfigBuilder } from \"@4mica/sdk\";\nimport type {\n Paywall,\n PaywallConfig,\n PaywallVerifier,\n} from \"@4mica/sdk/server\";\nimport { createPaywall as coreCreatePaywall } from \"@4mica/sdk/server\";\n\n// Minimal ambient declaration so we can read `Deno.env` without a hard dep on\n// Deno's type definitions. Present at runtime under Deno; guarded otherwise.\ndeclare const Deno: { env: { toObject(): Record<string, string> } } | undefined;\n\n/** Options for the Deno env-driven factories. */\nexport interface CreateClientOptions {\n /** Environment source. Defaults to `Deno.env.toObject()`. */\n env?: Record<string, string | undefined>;\n /** Hook to tweak the builder after env is applied (e.g. `.network(\"base\")`). */\n configure?: (builder: ConfigBuilder) => ConfigBuilder;\n}\n\nfunction denoEnv(): Record<string, string | undefined> {\n return typeof Deno !== \"undefined\" ? Deno.env.toObject() : {};\n}\n\n/** Build a validated {@link Config} from `Deno.env` (+ optional overrides). */\nexport function buildConfig(options: CreateClientOptions = {}): Config {\n const builder = new ConfigBuilder().fromEnv(options.env ?? denoEnv());\n return (options.configure ? options.configure(builder) : builder).build();\n}\n\n/** Create a fully-initialised {@link Client} from `Deno.env`. */\nexport async function createClient(\n options: CreateClientOptions = {},\n): Promise<Client> {\n return Client.new(buildConfig(options));\n}\n\n/** Convenience factory: build a client from `Deno.env` and wrap it as a paywall. */\nexport async function createPaywall(\n config: PaywallConfig,\n options?: CreateClientOptions,\n): Promise<Paywall> {\n const client = await createClient(options);\n return coreCreatePaywall(client, config);\n}\n\n/** Wrap an already-built verifier (`client`, `client.rpc`, …) as a paywall. */\nexport function createPaywallFor(\n verifier: PaywallVerifier,\n config: PaywallConfig,\n): Paywall {\n return coreCreatePaywall(verifier, config);\n}\n\nexport * from \"@4mica/sdk\";\nexport * as server from \"@4mica/sdk/server\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConfigBuilder, Config, Client } from '@4mica/sdk';
|
|
2
|
+
export * from '@4mica/sdk';
|
|
3
|
+
import { PaywallConfig, Paywall, PaywallVerifier } from '@4mica/sdk/server';
|
|
4
|
+
import * as server from '@4mica/sdk/server';
|
|
5
|
+
export { server };
|
|
6
|
+
|
|
7
|
+
/** Options for the Deno env-driven factories. */
|
|
8
|
+
interface CreateClientOptions {
|
|
9
|
+
/** Environment source. Defaults to `Deno.env.toObject()`. */
|
|
10
|
+
env?: Record<string, string | undefined>;
|
|
11
|
+
/** Hook to tweak the builder after env is applied (e.g. `.network("base")`). */
|
|
12
|
+
configure?: (builder: ConfigBuilder) => ConfigBuilder;
|
|
13
|
+
}
|
|
14
|
+
/** Build a validated {@link Config} from `Deno.env` (+ optional overrides). */
|
|
15
|
+
declare function buildConfig(options?: CreateClientOptions): Config;
|
|
16
|
+
/** Create a fully-initialised {@link Client} from `Deno.env`. */
|
|
17
|
+
declare function createClient(options?: CreateClientOptions): Promise<Client>;
|
|
18
|
+
/** Convenience factory: build a client from `Deno.env` and wrap it as a paywall. */
|
|
19
|
+
declare function createPaywall(config: PaywallConfig, options?: CreateClientOptions): Promise<Paywall>;
|
|
20
|
+
/** Wrap an already-built verifier (`client`, `client.rpc`, …) as a paywall. */
|
|
21
|
+
declare function createPaywallFor(verifier: PaywallVerifier, config: PaywallConfig): Paywall;
|
|
22
|
+
|
|
23
|
+
export { type CreateClientOptions, buildConfig, createClient, createPaywall, createPaywallFor };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConfigBuilder, Config, Client } from '@4mica/sdk';
|
|
2
|
+
export * from '@4mica/sdk';
|
|
3
|
+
import { PaywallConfig, Paywall, PaywallVerifier } from '@4mica/sdk/server';
|
|
4
|
+
import * as server from '@4mica/sdk/server';
|
|
5
|
+
export { server };
|
|
6
|
+
|
|
7
|
+
/** Options for the Deno env-driven factories. */
|
|
8
|
+
interface CreateClientOptions {
|
|
9
|
+
/** Environment source. Defaults to `Deno.env.toObject()`. */
|
|
10
|
+
env?: Record<string, string | undefined>;
|
|
11
|
+
/** Hook to tweak the builder after env is applied (e.g. `.network("base")`). */
|
|
12
|
+
configure?: (builder: ConfigBuilder) => ConfigBuilder;
|
|
13
|
+
}
|
|
14
|
+
/** Build a validated {@link Config} from `Deno.env` (+ optional overrides). */
|
|
15
|
+
declare function buildConfig(options?: CreateClientOptions): Config;
|
|
16
|
+
/** Create a fully-initialised {@link Client} from `Deno.env`. */
|
|
17
|
+
declare function createClient(options?: CreateClientOptions): Promise<Client>;
|
|
18
|
+
/** Convenience factory: build a client from `Deno.env` and wrap it as a paywall. */
|
|
19
|
+
declare function createPaywall(config: PaywallConfig, options?: CreateClientOptions): Promise<Paywall>;
|
|
20
|
+
/** Wrap an already-built verifier (`client`, `client.rpc`, …) as a paywall. */
|
|
21
|
+
declare function createPaywallFor(verifier: PaywallVerifier, config: PaywallConfig): Paywall;
|
|
22
|
+
|
|
23
|
+
export { type CreateClientOptions, buildConfig, createClient, createPaywall, createPaywallFor };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ConfigBuilder, Client } from '@4mica/sdk';
|
|
2
|
+
export * from '@4mica/sdk';
|
|
3
|
+
import { createPaywall as createPaywall$1 } from '@4mica/sdk/server';
|
|
4
|
+
import * as server from '@4mica/sdk/server';
|
|
5
|
+
export { server };
|
|
6
|
+
|
|
7
|
+
// src/index.ts
|
|
8
|
+
function denoEnv() {
|
|
9
|
+
return typeof Deno !== "undefined" ? Deno.env.toObject() : {};
|
|
10
|
+
}
|
|
11
|
+
function buildConfig(options = {}) {
|
|
12
|
+
const builder = new ConfigBuilder().fromEnv(options.env ?? denoEnv());
|
|
13
|
+
return (options.configure ? options.configure(builder) : builder).build();
|
|
14
|
+
}
|
|
15
|
+
async function createClient(options = {}) {
|
|
16
|
+
return Client.new(buildConfig(options));
|
|
17
|
+
}
|
|
18
|
+
async function createPaywall(config, options) {
|
|
19
|
+
const client = await createClient(options);
|
|
20
|
+
return createPaywall$1(client, config);
|
|
21
|
+
}
|
|
22
|
+
function createPaywallFor(verifier, config) {
|
|
23
|
+
return createPaywall$1(verifier, config);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { buildConfig, createClient, createPaywall, createPaywallFor };
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["coreCreatePaywall"],"mappings":";;;;;;;AAqBA,SAAS,OAAA,GAA8C;AACrD,EAAA,OAAO,OAAO,IAAA,KAAS,WAAA,GAAc,KAAK,GAAA,CAAI,QAAA,KAAa,EAAC;AAC9D;AAGO,SAAS,WAAA,CAAY,OAAA,GAA+B,EAAC,EAAW;AACrE,EAAA,MAAM,OAAA,GAAU,IAAI,aAAA,EAAc,CAAE,QAAQ,OAAA,CAAQ,GAAA,IAAO,SAAS,CAAA;AACpE,EAAA,OAAA,CAAQ,QAAQ,SAAA,GAAY,OAAA,CAAQ,UAAU,OAAO,CAAA,GAAI,SAAS,KAAA,EAAM;AAC1E;AAGA,eAAsB,YAAA,CACpB,OAAA,GAA+B,EAAC,EACf;AACjB,EAAA,OAAO,MAAA,CAAO,GAAA,CAAI,WAAA,CAAY,OAAO,CAAC,CAAA;AACxC;AAGA,eAAsB,aAAA,CACpB,QACA,OAAA,EACkB;AAClB,EAAA,MAAM,MAAA,GAAS,MAAM,YAAA,CAAa,OAAO,CAAA;AACzC,EAAA,OAAOA,eAAA,CAAkB,QAAQ,MAAM,CAAA;AACzC;AAGO,SAAS,gBAAA,CACd,UACA,MAAA,EACS;AACT,EAAA,OAAOA,eAAA,CAAkB,UAAU,MAAM,CAAA;AAC3C","file":"index.js","sourcesContent":["import type { Config } from \"@4mica/sdk\";\nimport { Client, ConfigBuilder } from \"@4mica/sdk\";\nimport type {\n Paywall,\n PaywallConfig,\n PaywallVerifier,\n} from \"@4mica/sdk/server\";\nimport { createPaywall as coreCreatePaywall } from \"@4mica/sdk/server\";\n\n// Minimal ambient declaration so we can read `Deno.env` without a hard dep on\n// Deno's type definitions. Present at runtime under Deno; guarded otherwise.\ndeclare const Deno: { env: { toObject(): Record<string, string> } } | undefined;\n\n/** Options for the Deno env-driven factories. */\nexport interface CreateClientOptions {\n /** Environment source. Defaults to `Deno.env.toObject()`. */\n env?: Record<string, string | undefined>;\n /** Hook to tweak the builder after env is applied (e.g. `.network(\"base\")`). */\n configure?: (builder: ConfigBuilder) => ConfigBuilder;\n}\n\nfunction denoEnv(): Record<string, string | undefined> {\n return typeof Deno !== \"undefined\" ? Deno.env.toObject() : {};\n}\n\n/** Build a validated {@link Config} from `Deno.env` (+ optional overrides). */\nexport function buildConfig(options: CreateClientOptions = {}): Config {\n const builder = new ConfigBuilder().fromEnv(options.env ?? denoEnv());\n return (options.configure ? options.configure(builder) : builder).build();\n}\n\n/** Create a fully-initialised {@link Client} from `Deno.env`. */\nexport async function createClient(\n options: CreateClientOptions = {},\n): Promise<Client> {\n return Client.new(buildConfig(options));\n}\n\n/** Convenience factory: build a client from `Deno.env` and wrap it as a paywall. */\nexport async function createPaywall(\n config: PaywallConfig,\n options?: CreateClientOptions,\n): Promise<Paywall> {\n const client = await createClient(options);\n return coreCreatePaywall(client, config);\n}\n\n/** Wrap an already-built verifier (`client`, `client.rpc`, …) as a paywall. */\nexport function createPaywallFor(\n verifier: PaywallVerifier,\n config: PaywallConfig,\n): Paywall {\n return coreCreatePaywall(verifier, config);\n}\n\nexport * from \"@4mica/sdk\";\nexport * as server from \"@4mica/sdk/server\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@4mica/sdk-deno",
|
|
3
|
+
"version": "1.3.1",
|
|
4
|
+
"description": "Deno adapter for the 4Mica SDK: Deno.env-driven client and x402 paywall factories",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/4mica-Network/homepage.git",
|
|
10
|
+
"directory": "packages/sdk-deno"
|
|
11
|
+
},
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"default": "./dist/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"4mica",
|
|
40
|
+
"sdk",
|
|
41
|
+
"deno",
|
|
42
|
+
"x402",
|
|
43
|
+
"payments"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@4mica/sdk": "1.3.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@arethetypeswrong/cli": "^0.18.2",
|
|
50
|
+
"@types/node": "^24.10.1",
|
|
51
|
+
"publint": "^0.3.14",
|
|
52
|
+
"tsup": "^8.5.1",
|
|
53
|
+
"typescript": "^5.9.0",
|
|
54
|
+
"vitest": "^4.1.8",
|
|
55
|
+
"@4mica/tsconfig": "0.0.0"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"dev": "tsup --watch",
|
|
60
|
+
"clean": "rm -rf dist",
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"test": "vitest run --passWithNoTests",
|
|
63
|
+
"check:exports": "attw --pack . --profile node16 && publint --strict"
|
|
64
|
+
}
|
|
65
|
+
}
|