@pafi-dev/issuer 0.5.4 → 0.5.5
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/dist/index.cjs +0 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -61
- package/dist/index.d.ts +46 -61
- package/dist/index.js +1 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1188,60 +1188,6 @@ var IssuerApiHandlers = class {
|
|
|
1188
1188
|
isMinter: minter
|
|
1189
1189
|
};
|
|
1190
1190
|
}
|
|
1191
|
-
/**
|
|
1192
|
-
* `POST /build-consent-typed-data`
|
|
1193
|
-
*
|
|
1194
|
-
* Backend builds the full EIP-712 typed data payload for a
|
|
1195
|
-
* ReceiverConsent message. The domain (name, version, chainId,
|
|
1196
|
-
* verifyingContract) is read from the PointToken contract — mobile
|
|
1197
|
-
* never needs to know or hardcode these values. Forward the
|
|
1198
|
-
* response directly to `wallet.signTypedData()`.
|
|
1199
|
-
*
|
|
1200
|
-
* This ensures a single source of truth for domain + types, and
|
|
1201
|
-
* makes contract upgrades (domain version bump) transparent to
|
|
1202
|
-
* mobile apps — no app store review needed.
|
|
1203
|
-
*/
|
|
1204
|
-
async handleBuildConsentTypedData(userAddress, request) {
|
|
1205
|
-
if (request.chainId !== this.chainId) {
|
|
1206
|
-
throw new Error(
|
|
1207
|
-
`handleBuildConsentTypedData: unsupported chainId ${request.chainId}`
|
|
1208
|
-
);
|
|
1209
|
-
}
|
|
1210
|
-
const pointToken = (0, import_viem6.getAddress)(request.pointTokenAddress);
|
|
1211
|
-
if (!this.supportedTokens.has(pointToken)) {
|
|
1212
|
-
throw new Error(
|
|
1213
|
-
`handleBuildConsentTypedData: unsupported pointToken ${pointToken}`
|
|
1214
|
-
);
|
|
1215
|
-
}
|
|
1216
|
-
const consent = request.receiverConsent;
|
|
1217
|
-
if ((0, import_viem6.getAddress)(consent.originalReceiver) !== (0, import_viem6.getAddress)(userAddress)) {
|
|
1218
|
-
throw new Error(
|
|
1219
|
-
"handleBuildConsentTypedData: receiverConsent.originalReceiver must match authenticated user"
|
|
1220
|
-
);
|
|
1221
|
-
}
|
|
1222
|
-
if (consent.amount <= 0n) {
|
|
1223
|
-
throw new Error("handleBuildConsentTypedData: amount must be positive");
|
|
1224
|
-
}
|
|
1225
|
-
const nowSecs = BigInt(Math.floor(Date.now() / 1e3));
|
|
1226
|
-
if (consent.deadline <= nowSecs) {
|
|
1227
|
-
throw new Error("handleBuildConsentTypedData: deadline is in the past");
|
|
1228
|
-
}
|
|
1229
|
-
const name = await (0, import_core3.getTokenName)(this.provider, pointToken);
|
|
1230
|
-
const domain = {
|
|
1231
|
-
name,
|
|
1232
|
-
verifyingContract: pointToken,
|
|
1233
|
-
chainId: this.chainId
|
|
1234
|
-
};
|
|
1235
|
-
const typedData = (0, import_core3.buildReceiverConsentTypedData)(domain, consent);
|
|
1236
|
-
return {
|
|
1237
|
-
typedData: {
|
|
1238
|
-
domain: typedData.domain,
|
|
1239
|
-
types: typedData.types,
|
|
1240
|
-
primaryType: typedData.primaryType,
|
|
1241
|
-
message: typedData.message
|
|
1242
|
-
}
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
1191
|
/**
|
|
1246
1192
|
* `POST /claim`
|
|
1247
1193
|
*
|