@cryptonly/x402 0.0.0-stage → 0.1.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Cryptonly
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/README.md CHANGED
@@ -1,3 +1,44 @@
1
- # Temporary Holding Version
1
+ <img src="https://raw.githubusercontent.com/cryptonly-net/.github/main/profile/assets/header-banner.svg" alt="Cryptonly" width="100%" />
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <div align="center">
4
+
5
+ # Cryptonly — x402 facilitator
6
+
7
+ Facilitator client for x402 payments.
8
+
9
+ [Website](https://cryptonly.net) · [Documentation](https://cryptonly.gitbook.io/docs) · [Contact](https://cryptonly.net/contact/)
10
+
11
+ </div>
12
+
13
+ ---
14
+
15
+ Pass it to `x402ResourceServer` from `@x402/express`, `@x402/hono`, or `@x402/next`.
16
+
17
+ ```bash
18
+ npm install @cryptonly/x402
19
+ ```
20
+
21
+ `@x402/core` ^2 is a peer dependency. Also install the framework package you use, such as `@x402/express` or `@x402/evm`.
22
+
23
+ ```ts
24
+ import { CryptonlyFacilitatorClient } from '@cryptonly/x402';
25
+ import { ExactEvmScheme } from '@x402/evm/exact/server';
26
+ import { x402ResourceServer } from '@x402/express';
27
+
28
+ const facilitator = new CryptonlyFacilitatorClient({
29
+ apiKey: process.env.CRYPTONLY_API_KEY!,
30
+ });
31
+
32
+ const server = new x402ResourceServer(facilitator).register(
33
+ 'eip155:8453',
34
+ new ExactEvmScheme(),
35
+ );
36
+ ```
37
+
38
+ `apiKey` is your Cryptonly API key. It is sent as `x-tenant-api-key` on verify and settle.
39
+
40
+ ```ts
41
+ const facilitator = new CryptonlyFacilitatorClient({
42
+ apiKey: process.env.CRYPTONLY_API_KEY!,
43
+ });
44
+ ```
@@ -0,0 +1,33 @@
1
+ import { HTTPFacilitatorClient } from '@x402/core/server';
2
+ /** Configuration for {@link CryptonlyFacilitatorClient}. */
3
+ export type CryptonlyFacilitatorConfig = {
4
+ /**
5
+ * Cryptonly API key.
6
+ */
7
+ apiKey: string;
8
+ /**
9
+ * When `true`, uses the sandbox facilitator. Defaults to production.
10
+ */
11
+ sandbox?: boolean;
12
+ };
13
+ /**
14
+ * Cryptonly facilitator client for the x402 protocol.
15
+ *
16
+ * Extends `HTTPFacilitatorClient` from `@x402/core/server`.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const facilitator = new CryptonlyFacilitatorClient({
21
+ * apiKey: process.env.CRYPTONLY_API_KEY!,
22
+ * sandbox: true,
23
+ * });
24
+ * const server = new x402ResourceServer(facilitator).register(
25
+ * 'eip155:84532',
26
+ * new ExactEvmScheme(),
27
+ * );
28
+ * ```
29
+ */
30
+ export declare class CryptonlyFacilitatorClient extends HTTPFacilitatorClient {
31
+ constructor(config: CryptonlyFacilitatorConfig);
32
+ }
33
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAO1D,4DAA4D;AAC5D,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AASF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,0BAA2B,SAAQ,qBAAqB;gBACvD,MAAM,EAAE,0BAA0B;CAc/C"}
package/dist/client.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CryptonlyFacilitatorClient = void 0;
4
+ const server_1 = require("@x402/core/server");
5
+ const constants_js_1 = require("./constants.js");
6
+ function resolveFacilitatorUrl(config) {
7
+ const origin = config.sandbox
8
+ ? constants_js_1.SANDBOX_MERCHANT_API_BASE_URL
9
+ : constants_js_1.MERCHANT_API_BASE_URL;
10
+ return `${origin}/x402`;
11
+ }
12
+ /**
13
+ * Cryptonly facilitator client for the x402 protocol.
14
+ *
15
+ * Extends `HTTPFacilitatorClient` from `@x402/core/server`.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const facilitator = new CryptonlyFacilitatorClient({
20
+ * apiKey: process.env.CRYPTONLY_API_KEY!,
21
+ * sandbox: true,
22
+ * });
23
+ * const server = new x402ResourceServer(facilitator).register(
24
+ * 'eip155:84532',
25
+ * new ExactEvmScheme(),
26
+ * );
27
+ * ```
28
+ */
29
+ class CryptonlyFacilitatorClient extends server_1.HTTPFacilitatorClient {
30
+ constructor(config) {
31
+ if (!config?.apiKey) {
32
+ throw new TypeError('CryptonlyFacilitatorClient: `apiKey` is required');
33
+ }
34
+ const headers = { [constants_js_1.MERCHANT_API_KEY_HEADER]: config.apiKey };
35
+ super({
36
+ url: resolveFacilitatorUrl(config),
37
+ createAuthHeaders: async () => ({
38
+ verify: headers,
39
+ settle: headers,
40
+ supported: headers,
41
+ }),
42
+ });
43
+ }
44
+ }
45
+ exports.CryptonlyFacilitatorClient = CryptonlyFacilitatorClient;
46
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,8CAA0D;AAC1D,iDAIwB;AAcxB,SAAS,qBAAqB,CAAC,MAAkC;IAC/D,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO;QAC3B,CAAC,CAAC,4CAA6B;QAC/B,CAAC,CAAC,oCAAqB,CAAC;IAC1B,OAAO,GAAG,MAAM,OAAO,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,0BAA2B,SAAQ,8BAAqB;IACnE,YAAY,MAAkC;QAC5C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,OAAO,GAAG,EAAE,CAAC,sCAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QAC7D,KAAK,CAAC;YACJ,GAAG,EAAE,qBAAqB,CAAC,MAAM,CAAC;YAClC,iBAAiB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;gBAC9B,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE,OAAO;gBACf,SAAS,EAAE,OAAO;aACnB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;CACF;AAfD,gEAeC"}
@@ -0,0 +1,7 @@
1
+ /** Default origin for the merchant API (no path; no trailing slash). */
2
+ export declare const MERCHANT_API_BASE_URL: "https://api-merchant.cryptonly.net";
3
+ /** Origin for the sandbox merchant API. */
4
+ export declare const SANDBOX_MERCHANT_API_BASE_URL: "https://sandbox-api-merchant.cryptonly.net";
5
+ /** Header that carries the merchant (tenant) API key. */
6
+ export declare const MERCHANT_API_KEY_HEADER: "x-tenant-api-key";
7
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,EAAG,oCAA6C,CAAC;AAEnF,2CAA2C;AAC3C,eAAO,MAAM,6BAA6B,EACxC,4CAAqD,CAAC;AAExD,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,EAAG,kBAA2B,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MERCHANT_API_KEY_HEADER = exports.SANDBOX_MERCHANT_API_BASE_URL = exports.MERCHANT_API_BASE_URL = void 0;
4
+ /** Default origin for the merchant API (no path; no trailing slash). */
5
+ exports.MERCHANT_API_BASE_URL = 'https://api-merchant.cryptonly.net';
6
+ /** Origin for the sandbox merchant API. */
7
+ exports.SANDBOX_MERCHANT_API_BASE_URL = 'https://sandbox-api-merchant.cryptonly.net';
8
+ /** Header that carries the merchant (tenant) API key. */
9
+ exports.MERCHANT_API_KEY_HEADER = 'x-tenant-api-key';
10
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,wEAAwE;AAC3D,QAAA,qBAAqB,GAAG,oCAA6C,CAAC;AAEnF,2CAA2C;AAC9B,QAAA,6BAA6B,GACxC,4CAAqD,CAAC;AAExD,yDAAyD;AAC5C,QAAA,uBAAuB,GAAG,kBAA2B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { CryptonlyFacilitatorClient } from './client.js';
2
+ export type { CryptonlyFacilitatorConfig } from './client.js';
3
+ export { MERCHANT_API_BASE_URL, MERCHANT_API_KEY_HEADER, SANDBOX_MERCHANT_API_BASE_URL, } from './constants.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SANDBOX_MERCHANT_API_BASE_URL = exports.MERCHANT_API_KEY_HEADER = exports.MERCHANT_API_BASE_URL = exports.CryptonlyFacilitatorClient = void 0;
4
+ var client_js_1 = require("./client.js");
5
+ Object.defineProperty(exports, "CryptonlyFacilitatorClient", { enumerable: true, get: function () { return client_js_1.CryptonlyFacilitatorClient; } });
6
+ var constants_js_1 = require("./constants.js");
7
+ Object.defineProperty(exports, "MERCHANT_API_BASE_URL", { enumerable: true, get: function () { return constants_js_1.MERCHANT_API_BASE_URL; } });
8
+ Object.defineProperty(exports, "MERCHANT_API_KEY_HEADER", { enumerable: true, get: function () { return constants_js_1.MERCHANT_API_KEY_HEADER; } });
9
+ Object.defineProperty(exports, "SANDBOX_MERCHANT_API_BASE_URL", { enumerable: true, get: function () { return constants_js_1.SANDBOX_MERCHANT_API_BASE_URL; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AAAhD,uHAAA,0BAA0B,OAAA;AAEnC,+CAIwB;AAHtB,qHAAA,qBAAqB,OAAA;AACrB,uHAAA,uBAAuB,OAAA;AACvB,6HAAA,6BAA6B,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@cryptonly/x402",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Cryptonly facilitator client for the x402 payment protocol.",
5
+ "license": "MIT",
6
+ "private": false,
7
+ "type": "commonjs",
8
+ "sideEffects": false,
9
+ "engines": {
10
+ "node": ">=18"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/cryptonly-net/x402.git"
15
+ },
16
+ "homepage": "https://github.com/cryptonly-net/x402#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/cryptonly-net/x402/issues"
19
+ },
20
+ "keywords": [
21
+ "cryptonly",
22
+ "x402",
23
+ "facilitator",
24
+ "payments",
25
+ "client",
26
+ "typescript"
27
+ ],
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.js",
35
+ "default": "./dist/index.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "scripts": {
42
+ "build": "tsc -p tsconfig.build.json",
43
+ "clean": "rm -rf dist",
44
+ "prepare": "npm run build",
45
+ "prepublishOnly": "npm run build",
46
+ "test": "jest"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "peerDependencies": {
52
+ "@x402/core": "^2"
53
+ },
54
+ "devDependencies": {
55
+ "@types/jest": "^29.5.14",
56
+ "@x402/core": "^2.28.0",
57
+ "jest": "^29.7.0",
58
+ "ts-jest": "^29.2.0",
59
+ "typescript": "^5.9.3"
60
+ }
61
+ }