payid 0.4.7 → 0.4.9
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.
|
@@ -20,6 +20,7 @@ __export(client_exports, {
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
// src/core/client/client.ts
|
|
23
|
+
import { loadWasm } from "payid-rule-engine";
|
|
23
24
|
import "ethers";
|
|
24
25
|
function isRuleSource(rule) {
|
|
25
26
|
return typeof rule === "object" && rule !== null && "uri" in rule;
|
|
@@ -28,6 +29,22 @@ var PayIDClient = class {
|
|
|
28
29
|
constructor(debugTrace, wasm) {
|
|
29
30
|
this.debugTrace = debugTrace;
|
|
30
31
|
this.wasm = wasm;
|
|
32
|
+
this._ready = loadWasm(this.wasm).then(() => {
|
|
33
|
+
}).catch(() => {
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Preload promise — WASM mulai di-fetch saat createPayID() dipanggil,
|
|
37
|
+
// bukan saat evaluate() pertama. Hasilnya di-cache di wasm.ts.
|
|
38
|
+
_ready;
|
|
39
|
+
/**
|
|
40
|
+
* Tunggu sampai WASM siap. Opsional — evaluate() akan menunggu sendiri,
|
|
41
|
+
* tapi bisa di-await eksplisit untuk warmup:
|
|
42
|
+
*
|
|
43
|
+
* const client = createPayID();
|
|
44
|
+
* await client.ready(); // WASM pasti sudah loaded setelah ini
|
|
45
|
+
*/
|
|
46
|
+
async ready() {
|
|
47
|
+
return this._ready;
|
|
31
48
|
}
|
|
32
49
|
async evaluate(context, rule) {
|
|
33
50
|
const config = isRuleSource(rule) ? (await resolveRule(rule)).config : rule;
|
|
@@ -3,41 +3,19 @@ import { ethers } from 'ethers';
|
|
|
3
3
|
import { R as RuleSource, D as DecisionProof } from './types-B8pJQdMQ.js';
|
|
4
4
|
import { P as PayIDSessionPolicyPayloadV1 } from './types-BmMf7udp.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @class PayIDClient
|
|
8
|
-
* @description Client-side PayID engine.
|
|
9
|
-
*
|
|
10
|
-
* Fully serverless — aman dipakai di browser, mobile, edge.
|
|
11
|
-
* Tidak butuh issuer wallet, tidak butuh server.
|
|
12
|
-
*
|
|
13
|
-
* Untuk attestation, gunakan EAS UIDs yang di-fetch via `eas.EASClient`.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* const client = new PayIDClient(wasmBinary)
|
|
18
|
-
*
|
|
19
|
-
* // 1. Evaluate rule
|
|
20
|
-
* const result = await client.evaluate(context, ruleConfig)
|
|
21
|
-
*
|
|
22
|
-
* // 2. Evaluate + generate proof (payer sign sendiri)
|
|
23
|
-
* const { result, proof } = await client.evaluateAndProve({
|
|
24
|
-
* context,
|
|
25
|
-
* authorityRule: ruleConfig,
|
|
26
|
-
* payId: "pay.id/merchant",
|
|
27
|
-
* payer: await signer.getAddress(),
|
|
28
|
-
* receiver: "0xRECEIVER",
|
|
29
|
-
* asset: USDT_ADDRESS,
|
|
30
|
-
* amount: parseUnits("100", 6),
|
|
31
|
-
* signer,
|
|
32
|
-
* verifyingContract: PAYID_VERIFIER_ADDRESS,
|
|
33
|
-
* ruleAuthority: RULE_AUTHORITY_ADDRESS,
|
|
34
|
-
* })
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
6
|
declare class PayIDClient {
|
|
38
7
|
private readonly debugTrace?;
|
|
39
8
|
private readonly wasm?;
|
|
9
|
+
private readonly _ready;
|
|
40
10
|
constructor(debugTrace?: boolean | undefined, wasm?: Uint8Array | undefined);
|
|
11
|
+
/**
|
|
12
|
+
* Tunggu sampai WASM siap. Opsional — evaluate() akan menunggu sendiri,
|
|
13
|
+
* tapi bisa di-await eksplisit untuk warmup:
|
|
14
|
+
*
|
|
15
|
+
* const client = createPayID();
|
|
16
|
+
* await client.ready(); // WASM pasti sudah loaded setelah ini
|
|
17
|
+
*/
|
|
18
|
+
ready(): Promise<void>;
|
|
41
19
|
evaluate(context: RuleContext, rule: RuleConfig | RuleSource): Promise<RuleResult>;
|
|
42
20
|
evaluateAndProve(params: {
|
|
43
21
|
context: RuleContext;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { i as sessionPolicy } from './index-BQQnMG2H.js';
|
|
|
7
7
|
export { i as rule } from './index-DerQdZmf.js';
|
|
8
8
|
export { i as issuer } from './index-2JCvey4-.js';
|
|
9
9
|
export { i as context } from './index-BEvnPzzt.js';
|
|
10
|
-
export { i as client } from './index-
|
|
10
|
+
export { i as client } from './index-BUTI_SDh.js';
|
|
11
11
|
import './types-BmMf7udp.js';
|
|
12
12
|
|
|
13
13
|
interface PayIDClient {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payid",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"ethers": "^6.16.0",
|
|
40
|
-
"payid-rule-engine": "^0.
|
|
40
|
+
"payid-rule-engine": "^0.3.0",
|
|
41
41
|
"payid-types": "^0.1.9"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|