clawdentity 0.0.22 → 0.0.23
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/bin.js +64 -6
- package/dist/index.js +64 -6
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ravi Kiran Vemula
|
|
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/bin.js
CHANGED
|
@@ -24389,16 +24389,20 @@ function parsePeerProfile(payload) {
|
|
|
24389
24389
|
};
|
|
24390
24390
|
}
|
|
24391
24391
|
function parsePairingTicket(value) {
|
|
24392
|
-
|
|
24392
|
+
let ticket = parseNonEmptyString9(value);
|
|
24393
|
+
while (ticket.startsWith("`")) {
|
|
24394
|
+
ticket = ticket.slice(1);
|
|
24395
|
+
}
|
|
24396
|
+
while (ticket.endsWith("`")) {
|
|
24397
|
+
ticket = ticket.slice(0, -1);
|
|
24398
|
+
}
|
|
24399
|
+
ticket = ticket.trim().replace(/\s+/gu, "");
|
|
24393
24400
|
if (!ticket.startsWith(PAIRING_TICKET_PREFIX)) {
|
|
24394
24401
|
throw createCliError7(
|
|
24395
24402
|
"CLI_PAIR_CONFIRM_TICKET_INVALID",
|
|
24396
24403
|
"Pairing ticket is invalid"
|
|
24397
24404
|
);
|
|
24398
24405
|
}
|
|
24399
|
-
return ticket;
|
|
24400
|
-
}
|
|
24401
|
-
function parsePairingTicketIssuerOrigin(ticket) {
|
|
24402
24406
|
const encodedPayload = ticket.slice(PAIRING_TICKET_PREFIX.length);
|
|
24403
24407
|
if (encodedPayload.length === 0) {
|
|
24404
24408
|
throw createCliError7(
|
|
@@ -24406,15 +24410,26 @@ function parsePairingTicketIssuerOrigin(ticket) {
|
|
|
24406
24410
|
"Pairing ticket is invalid"
|
|
24407
24411
|
);
|
|
24408
24412
|
}
|
|
24409
|
-
let payloadRaw;
|
|
24410
24413
|
try {
|
|
24411
|
-
payloadRaw = new TextDecoder().decode(
|
|
24414
|
+
const payloadRaw = new TextDecoder().decode(
|
|
24415
|
+
decodeBase64url(encodedPayload)
|
|
24416
|
+
);
|
|
24417
|
+
const payload = JSON.parse(payloadRaw);
|
|
24418
|
+
if (!isRecord10(payload)) {
|
|
24419
|
+
throw new Error("invalid payload");
|
|
24420
|
+
}
|
|
24412
24421
|
} catch {
|
|
24413
24422
|
throw createCliError7(
|
|
24414
24423
|
"CLI_PAIR_CONFIRM_TICKET_INVALID",
|
|
24415
24424
|
"Pairing ticket is invalid"
|
|
24416
24425
|
);
|
|
24417
24426
|
}
|
|
24427
|
+
return ticket;
|
|
24428
|
+
}
|
|
24429
|
+
function parsePairingTicketIssuerOrigin(ticket) {
|
|
24430
|
+
const normalizedTicket = parsePairingTicket(ticket);
|
|
24431
|
+
const encodedPayload = normalizedTicket.slice(PAIRING_TICKET_PREFIX.length);
|
|
24432
|
+
const payloadRaw = new TextDecoder().decode(decodeBase64url(encodedPayload));
|
|
24418
24433
|
let payload;
|
|
24419
24434
|
try {
|
|
24420
24435
|
payload = JSON.parse(payloadRaw);
|
|
@@ -24447,6 +24462,26 @@ function parsePairingTicketIssuerOrigin(ticket) {
|
|
|
24447
24462
|
}
|
|
24448
24463
|
return issuerUrl.origin;
|
|
24449
24464
|
}
|
|
24465
|
+
function assertTicketIssuerMatchesProxy(input) {
|
|
24466
|
+
const issuerOrigin = parsePairingTicketIssuerOrigin(input.ticket);
|
|
24467
|
+
let proxyOrigin;
|
|
24468
|
+
try {
|
|
24469
|
+
proxyOrigin = new URL(input.proxyUrl).origin;
|
|
24470
|
+
} catch {
|
|
24471
|
+
throw createCliError7(
|
|
24472
|
+
"CLI_PAIR_PROXY_URL_INVALID",
|
|
24473
|
+
"Configured proxyUrl is invalid. Run `clawdentity config set proxyUrl <url>` and retry."
|
|
24474
|
+
);
|
|
24475
|
+
}
|
|
24476
|
+
if (issuerOrigin === proxyOrigin) {
|
|
24477
|
+
return;
|
|
24478
|
+
}
|
|
24479
|
+
const command = input.context === "confirm" ? "pair confirm" : "pair status";
|
|
24480
|
+
throw createCliError7(
|
|
24481
|
+
"CLI_PAIR_TICKET_ISSUER_MISMATCH",
|
|
24482
|
+
`Pairing ticket was issued by ${issuerOrigin}, but current proxy URL is ${proxyOrigin}. Run \`clawdentity config set proxyUrl ${issuerOrigin}\` and retry \`${command}\`.`
|
|
24483
|
+
);
|
|
24484
|
+
}
|
|
24450
24485
|
function parseAitAgentDid(ait) {
|
|
24451
24486
|
const parts = ait.split(".");
|
|
24452
24487
|
if (parts.length < 2) {
|
|
@@ -24846,6 +24881,12 @@ function mapConfirmPairError(status, payload) {
|
|
|
24846
24881
|
if (code === "PROXY_PAIR_TICKET_EXPIRED" || status === 410) {
|
|
24847
24882
|
return "Pairing ticket has expired";
|
|
24848
24883
|
}
|
|
24884
|
+
if (code === "PROXY_PAIR_TICKET_INVALID_ISSUER") {
|
|
24885
|
+
return message2 ? `Pair confirm failed: ticket issuer does not match this proxy (${message2}). Use the same proxy URL where the ticket was issued.` : "Pair confirm failed: ticket issuer does not match this proxy. Use the same proxy URL where the ticket was issued.";
|
|
24886
|
+
}
|
|
24887
|
+
if (code === "PROXY_PAIR_TICKET_INVALID_FORMAT" || code === "PROXY_PAIR_TICKET_UNSUPPORTED_VERSION") {
|
|
24888
|
+
return message2 ? `Pair confirm request is invalid (400): ${message2}. Re-copy the full ticket/QR without truncation.` : "Pair confirm request is invalid (400): pairing ticket is malformed. Re-copy the full ticket/QR without truncation.";
|
|
24889
|
+
}
|
|
24849
24890
|
if (status === 400) {
|
|
24850
24891
|
return message2 ? `Pair confirm request is invalid (400): ${message2}` : "Pair confirm request is invalid (400).";
|
|
24851
24892
|
}
|
|
@@ -24869,6 +24910,12 @@ function mapStatusPairError(status, payload) {
|
|
|
24869
24910
|
if (code === "PROXY_PAIR_STATUS_FORBIDDEN" || status === 403) {
|
|
24870
24911
|
return message2 ? `Pair status request is forbidden (403): ${message2}` : "Pair status request is forbidden (403).";
|
|
24871
24912
|
}
|
|
24913
|
+
if (code === "PROXY_PAIR_TICKET_INVALID_ISSUER") {
|
|
24914
|
+
return message2 ? `Pair status failed: ticket issuer does not match this proxy (${message2}). Use the same proxy URL where the ticket was issued.` : "Pair status failed: ticket issuer does not match this proxy. Use the same proxy URL where the ticket was issued.";
|
|
24915
|
+
}
|
|
24916
|
+
if (code === "PROXY_PAIR_TICKET_INVALID_FORMAT" || code === "PROXY_PAIR_TICKET_UNSUPPORTED_VERSION") {
|
|
24917
|
+
return message2 ? `Pair status request is invalid (400): ${message2}. Re-copy the full ticket/QR without truncation.` : "Pair status request is invalid (400): pairing ticket is malformed. Re-copy the full ticket/QR without truncation.";
|
|
24918
|
+
}
|
|
24872
24919
|
if (status === 400) {
|
|
24873
24920
|
return message2 ? `Pair status request is invalid (400): ${message2}` : "Pair status request is invalid (400).";
|
|
24874
24921
|
}
|
|
@@ -25347,6 +25394,12 @@ async function confirmPairing(agentName, options, dependencies = {}) {
|
|
|
25347
25394
|
}
|
|
25348
25395
|
ticket = parsePairingTicket(qrDecodeImpl(new Uint8Array(imageBytes)));
|
|
25349
25396
|
}
|
|
25397
|
+
ticket = parsePairingTicket(ticket);
|
|
25398
|
+
assertTicketIssuerMatchesProxy({
|
|
25399
|
+
ticket,
|
|
25400
|
+
proxyUrl,
|
|
25401
|
+
context: "confirm"
|
|
25402
|
+
});
|
|
25350
25403
|
const { ait, secretKey } = await readAgentProofMaterial(
|
|
25351
25404
|
normalizedAgentName,
|
|
25352
25405
|
dependencies
|
|
@@ -25424,6 +25477,11 @@ async function getPairingStatusOnce(agentName, options, dependencies = {}) {
|
|
|
25424
25477
|
fetchImpl
|
|
25425
25478
|
});
|
|
25426
25479
|
const ticket = parsePairingTicket(options.ticket);
|
|
25480
|
+
assertTicketIssuerMatchesProxy({
|
|
25481
|
+
ticket,
|
|
25482
|
+
proxyUrl,
|
|
25483
|
+
context: "status"
|
|
25484
|
+
});
|
|
25427
25485
|
const { ait, secretKey } = await readAgentProofMaterial(
|
|
25428
25486
|
agentName,
|
|
25429
25487
|
dependencies
|
package/dist/index.js
CHANGED
|
@@ -24389,16 +24389,20 @@ function parsePeerProfile(payload) {
|
|
|
24389
24389
|
};
|
|
24390
24390
|
}
|
|
24391
24391
|
function parsePairingTicket(value) {
|
|
24392
|
-
|
|
24392
|
+
let ticket = parseNonEmptyString9(value);
|
|
24393
|
+
while (ticket.startsWith("`")) {
|
|
24394
|
+
ticket = ticket.slice(1);
|
|
24395
|
+
}
|
|
24396
|
+
while (ticket.endsWith("`")) {
|
|
24397
|
+
ticket = ticket.slice(0, -1);
|
|
24398
|
+
}
|
|
24399
|
+
ticket = ticket.trim().replace(/\s+/gu, "");
|
|
24393
24400
|
if (!ticket.startsWith(PAIRING_TICKET_PREFIX)) {
|
|
24394
24401
|
throw createCliError7(
|
|
24395
24402
|
"CLI_PAIR_CONFIRM_TICKET_INVALID",
|
|
24396
24403
|
"Pairing ticket is invalid"
|
|
24397
24404
|
);
|
|
24398
24405
|
}
|
|
24399
|
-
return ticket;
|
|
24400
|
-
}
|
|
24401
|
-
function parsePairingTicketIssuerOrigin(ticket) {
|
|
24402
24406
|
const encodedPayload = ticket.slice(PAIRING_TICKET_PREFIX.length);
|
|
24403
24407
|
if (encodedPayload.length === 0) {
|
|
24404
24408
|
throw createCliError7(
|
|
@@ -24406,15 +24410,26 @@ function parsePairingTicketIssuerOrigin(ticket) {
|
|
|
24406
24410
|
"Pairing ticket is invalid"
|
|
24407
24411
|
);
|
|
24408
24412
|
}
|
|
24409
|
-
let payloadRaw;
|
|
24410
24413
|
try {
|
|
24411
|
-
payloadRaw = new TextDecoder().decode(
|
|
24414
|
+
const payloadRaw = new TextDecoder().decode(
|
|
24415
|
+
decodeBase64url(encodedPayload)
|
|
24416
|
+
);
|
|
24417
|
+
const payload = JSON.parse(payloadRaw);
|
|
24418
|
+
if (!isRecord10(payload)) {
|
|
24419
|
+
throw new Error("invalid payload");
|
|
24420
|
+
}
|
|
24412
24421
|
} catch {
|
|
24413
24422
|
throw createCliError7(
|
|
24414
24423
|
"CLI_PAIR_CONFIRM_TICKET_INVALID",
|
|
24415
24424
|
"Pairing ticket is invalid"
|
|
24416
24425
|
);
|
|
24417
24426
|
}
|
|
24427
|
+
return ticket;
|
|
24428
|
+
}
|
|
24429
|
+
function parsePairingTicketIssuerOrigin(ticket) {
|
|
24430
|
+
const normalizedTicket = parsePairingTicket(ticket);
|
|
24431
|
+
const encodedPayload = normalizedTicket.slice(PAIRING_TICKET_PREFIX.length);
|
|
24432
|
+
const payloadRaw = new TextDecoder().decode(decodeBase64url(encodedPayload));
|
|
24418
24433
|
let payload;
|
|
24419
24434
|
try {
|
|
24420
24435
|
payload = JSON.parse(payloadRaw);
|
|
@@ -24447,6 +24462,26 @@ function parsePairingTicketIssuerOrigin(ticket) {
|
|
|
24447
24462
|
}
|
|
24448
24463
|
return issuerUrl.origin;
|
|
24449
24464
|
}
|
|
24465
|
+
function assertTicketIssuerMatchesProxy(input) {
|
|
24466
|
+
const issuerOrigin = parsePairingTicketIssuerOrigin(input.ticket);
|
|
24467
|
+
let proxyOrigin;
|
|
24468
|
+
try {
|
|
24469
|
+
proxyOrigin = new URL(input.proxyUrl).origin;
|
|
24470
|
+
} catch {
|
|
24471
|
+
throw createCliError7(
|
|
24472
|
+
"CLI_PAIR_PROXY_URL_INVALID",
|
|
24473
|
+
"Configured proxyUrl is invalid. Run `clawdentity config set proxyUrl <url>` and retry."
|
|
24474
|
+
);
|
|
24475
|
+
}
|
|
24476
|
+
if (issuerOrigin === proxyOrigin) {
|
|
24477
|
+
return;
|
|
24478
|
+
}
|
|
24479
|
+
const command = input.context === "confirm" ? "pair confirm" : "pair status";
|
|
24480
|
+
throw createCliError7(
|
|
24481
|
+
"CLI_PAIR_TICKET_ISSUER_MISMATCH",
|
|
24482
|
+
`Pairing ticket was issued by ${issuerOrigin}, but current proxy URL is ${proxyOrigin}. Run \`clawdentity config set proxyUrl ${issuerOrigin}\` and retry \`${command}\`.`
|
|
24483
|
+
);
|
|
24484
|
+
}
|
|
24450
24485
|
function parseAitAgentDid(ait) {
|
|
24451
24486
|
const parts = ait.split(".");
|
|
24452
24487
|
if (parts.length < 2) {
|
|
@@ -24846,6 +24881,12 @@ function mapConfirmPairError(status, payload) {
|
|
|
24846
24881
|
if (code === "PROXY_PAIR_TICKET_EXPIRED" || status === 410) {
|
|
24847
24882
|
return "Pairing ticket has expired";
|
|
24848
24883
|
}
|
|
24884
|
+
if (code === "PROXY_PAIR_TICKET_INVALID_ISSUER") {
|
|
24885
|
+
return message2 ? `Pair confirm failed: ticket issuer does not match this proxy (${message2}). Use the same proxy URL where the ticket was issued.` : "Pair confirm failed: ticket issuer does not match this proxy. Use the same proxy URL where the ticket was issued.";
|
|
24886
|
+
}
|
|
24887
|
+
if (code === "PROXY_PAIR_TICKET_INVALID_FORMAT" || code === "PROXY_PAIR_TICKET_UNSUPPORTED_VERSION") {
|
|
24888
|
+
return message2 ? `Pair confirm request is invalid (400): ${message2}. Re-copy the full ticket/QR without truncation.` : "Pair confirm request is invalid (400): pairing ticket is malformed. Re-copy the full ticket/QR without truncation.";
|
|
24889
|
+
}
|
|
24849
24890
|
if (status === 400) {
|
|
24850
24891
|
return message2 ? `Pair confirm request is invalid (400): ${message2}` : "Pair confirm request is invalid (400).";
|
|
24851
24892
|
}
|
|
@@ -24869,6 +24910,12 @@ function mapStatusPairError(status, payload) {
|
|
|
24869
24910
|
if (code === "PROXY_PAIR_STATUS_FORBIDDEN" || status === 403) {
|
|
24870
24911
|
return message2 ? `Pair status request is forbidden (403): ${message2}` : "Pair status request is forbidden (403).";
|
|
24871
24912
|
}
|
|
24913
|
+
if (code === "PROXY_PAIR_TICKET_INVALID_ISSUER") {
|
|
24914
|
+
return message2 ? `Pair status failed: ticket issuer does not match this proxy (${message2}). Use the same proxy URL where the ticket was issued.` : "Pair status failed: ticket issuer does not match this proxy. Use the same proxy URL where the ticket was issued.";
|
|
24915
|
+
}
|
|
24916
|
+
if (code === "PROXY_PAIR_TICKET_INVALID_FORMAT" || code === "PROXY_PAIR_TICKET_UNSUPPORTED_VERSION") {
|
|
24917
|
+
return message2 ? `Pair status request is invalid (400): ${message2}. Re-copy the full ticket/QR without truncation.` : "Pair status request is invalid (400): pairing ticket is malformed. Re-copy the full ticket/QR without truncation.";
|
|
24918
|
+
}
|
|
24872
24919
|
if (status === 400) {
|
|
24873
24920
|
return message2 ? `Pair status request is invalid (400): ${message2}` : "Pair status request is invalid (400).";
|
|
24874
24921
|
}
|
|
@@ -25347,6 +25394,12 @@ async function confirmPairing(agentName, options, dependencies = {}) {
|
|
|
25347
25394
|
}
|
|
25348
25395
|
ticket = parsePairingTicket(qrDecodeImpl(new Uint8Array(imageBytes)));
|
|
25349
25396
|
}
|
|
25397
|
+
ticket = parsePairingTicket(ticket);
|
|
25398
|
+
assertTicketIssuerMatchesProxy({
|
|
25399
|
+
ticket,
|
|
25400
|
+
proxyUrl,
|
|
25401
|
+
context: "confirm"
|
|
25402
|
+
});
|
|
25350
25403
|
const { ait, secretKey } = await readAgentProofMaterial(
|
|
25351
25404
|
normalizedAgentName,
|
|
25352
25405
|
dependencies
|
|
@@ -25424,6 +25477,11 @@ async function getPairingStatusOnce(agentName, options, dependencies = {}) {
|
|
|
25424
25477
|
fetchImpl
|
|
25425
25478
|
});
|
|
25426
25479
|
const ticket = parsePairingTicket(options.ticket);
|
|
25480
|
+
assertTicketIssuerMatchesProxy({
|
|
25481
|
+
ticket,
|
|
25482
|
+
proxyUrl,
|
|
25483
|
+
context: "status"
|
|
25484
|
+
});
|
|
25427
25485
|
const { ait, secretKey } = await readAgentProofMaterial(
|
|
25428
25486
|
agentName,
|
|
25429
25487
|
dependencies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clawdentity",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@types/node": "^22.18.11",
|
|
33
33
|
"@types/pngjs": "^6.0.5",
|
|
34
34
|
"@types/qrcode": "^1.5.6",
|
|
35
|
-
"@clawdentity/connector": "0.0.0",
|
|
36
35
|
"@clawdentity/protocol": "0.0.0",
|
|
36
|
+
"@clawdentity/connector": "0.0.0",
|
|
37
37
|
"@clawdentity/sdk": "0.0.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|