@nextera.one/axis-server-sdk 1.6.0 → 1.8.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/dist/index.d.mts +164 -142
- package/dist/index.d.ts +164 -142
- package/dist/index.js +112 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -83
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1710,6 +1710,7 @@ function verifyResponse(ctx, response) {
|
|
|
1710
1710
|
}
|
|
1711
1711
|
return { passed: true };
|
|
1712
1712
|
}
|
|
1713
|
+
var ResponseObserver = verifyResponse;
|
|
1713
1714
|
|
|
1714
1715
|
// src/core/varint.ts
|
|
1715
1716
|
import { encodeVarint, decodeVarint, varintLength } from "@nextera.one/axis-protocol";
|
|
@@ -4063,6 +4064,88 @@ AxisSensorChainService = __decorateClass([
|
|
|
4063
4064
|
Injectable7()
|
|
4064
4065
|
], AxisSensorChainService);
|
|
4065
4066
|
|
|
4067
|
+
// src/utils/axis-tlv-codec.ts
|
|
4068
|
+
function encodeAxisTlvDto(dtoClass, data) {
|
|
4069
|
+
const schema = extractDtoSchema(dtoClass);
|
|
4070
|
+
const items = schema.fields.flatMap((field) => {
|
|
4071
|
+
const value = data[field.name];
|
|
4072
|
+
if (value === void 0 || value === null) {
|
|
4073
|
+
if (field.required) {
|
|
4074
|
+
throw new Error(`Missing required TLV response field: ${field.name}`);
|
|
4075
|
+
}
|
|
4076
|
+
return [];
|
|
4077
|
+
}
|
|
4078
|
+
return [{ type: field.tag, value: encodeField(field, value) }];
|
|
4079
|
+
});
|
|
4080
|
+
return buildTLVs(items);
|
|
4081
|
+
}
|
|
4082
|
+
function encodeField(field, value) {
|
|
4083
|
+
switch (field.kind) {
|
|
4084
|
+
case "utf8":
|
|
4085
|
+
return Buffer.from(String(value), "utf8");
|
|
4086
|
+
case "u64":
|
|
4087
|
+
return encodeU64(value);
|
|
4088
|
+
case "bytes":
|
|
4089
|
+
case "bytes16":
|
|
4090
|
+
return toBuffer(value);
|
|
4091
|
+
case "bool":
|
|
4092
|
+
return Buffer.from([value ? 1 : 0]);
|
|
4093
|
+
case "obj":
|
|
4094
|
+
case "arr":
|
|
4095
|
+
return Buffer.from(JSON.stringify(value), "utf8");
|
|
4096
|
+
default:
|
|
4097
|
+
return toBuffer(value);
|
|
4098
|
+
}
|
|
4099
|
+
}
|
|
4100
|
+
function encodeU64(value) {
|
|
4101
|
+
const encoded = Buffer.alloc(8);
|
|
4102
|
+
encoded.writeBigUInt64BE(
|
|
4103
|
+
typeof value === "bigint" ? value : BigInt(value)
|
|
4104
|
+
);
|
|
4105
|
+
return encoded;
|
|
4106
|
+
}
|
|
4107
|
+
function toBuffer(value) {
|
|
4108
|
+
if (Buffer.isBuffer(value)) {
|
|
4109
|
+
return value;
|
|
4110
|
+
}
|
|
4111
|
+
if (value instanceof Uint8Array) {
|
|
4112
|
+
return Buffer.from(value);
|
|
4113
|
+
}
|
|
4114
|
+
if (typeof value === "string") {
|
|
4115
|
+
return Buffer.from(value, "utf8");
|
|
4116
|
+
}
|
|
4117
|
+
throw new Error(`Unsupported TLV bytes value: ${typeof value}`);
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
// src/loom/loom.types.ts
|
|
4121
|
+
function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
|
|
4122
|
+
return `ar:${context}:${scope}:${softid}`;
|
|
4123
|
+
}
|
|
4124
|
+
function canonicalizeWrit(writ) {
|
|
4125
|
+
const ordered = {
|
|
4126
|
+
head: { tid: writ.head.tid, seq: writ.head.seq },
|
|
4127
|
+
body: {
|
|
4128
|
+
who: writ.body.who,
|
|
4129
|
+
act: writ.body.act,
|
|
4130
|
+
res: writ.body.res,
|
|
4131
|
+
law: writ.body.law
|
|
4132
|
+
},
|
|
4133
|
+
meta: { iat: writ.meta.iat, exp: writ.meta.exp, prev: writ.meta.prev }
|
|
4134
|
+
};
|
|
4135
|
+
return JSON.stringify(ordered);
|
|
4136
|
+
}
|
|
4137
|
+
function canonicalizeGrant(grant) {
|
|
4138
|
+
const ordered = {
|
|
4139
|
+
grant_id: grant.grant_id,
|
|
4140
|
+
issuer: grant.issuer,
|
|
4141
|
+
subject: grant.subject,
|
|
4142
|
+
grant_type: grant.grant_type,
|
|
4143
|
+
caps: grant.caps,
|
|
4144
|
+
meta: grant.meta
|
|
4145
|
+
};
|
|
4146
|
+
return JSON.stringify(ordered);
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4066
4149
|
// src/cce/index.ts
|
|
4067
4150
|
var cce_exports = {};
|
|
4068
4151
|
__export(cce_exports, {
|
|
@@ -5108,19 +5191,31 @@ __export(engine_exports, {
|
|
|
5108
5191
|
HandlerDiscoveryService: () => HandlerDiscoveryService,
|
|
5109
5192
|
IntentRouter: () => IntentRouter,
|
|
5110
5193
|
PRE_DECODE_BOUNDARY: () => PRE_DECODE_BOUNDARY,
|
|
5194
|
+
ResponseObserver: () => ResponseObserver,
|
|
5111
5195
|
SensorDiscoveryService: () => SensorDiscoveryService,
|
|
5112
5196
|
SensorRegistry: () => SensorRegistry,
|
|
5197
|
+
buildQueueMessage: () => buildQueueMessage,
|
|
5198
|
+
buildUnsignedWitness: () => buildUnsignedWitness,
|
|
5199
|
+
canonicalizeObservation: () => canonicalizeObservation,
|
|
5113
5200
|
createObservation: () => createObservation,
|
|
5201
|
+
decodeQueueMessage: () => decodeQueueMessage,
|
|
5202
|
+
encodeQueueMessage: () => encodeQueueMessage,
|
|
5114
5203
|
endStage: () => endStage,
|
|
5115
5204
|
finalizeObservation: () => finalizeObservation,
|
|
5205
|
+
hashObservation: () => hashObservation,
|
|
5116
5206
|
observation: () => observation_exports,
|
|
5207
|
+
parseAutoClaimEntries: () => parseAutoClaimEntries,
|
|
5208
|
+
parseStreamEntries: () => parseStreamEntries,
|
|
5117
5209
|
recordSensor: () => recordSensor,
|
|
5118
|
-
|
|
5210
|
+
stableJsonStringify: () => stableJsonStringify,
|
|
5211
|
+
startStage: () => startStage,
|
|
5212
|
+
verifyResponse: () => verifyResponse
|
|
5119
5213
|
});
|
|
5120
5214
|
|
|
5121
5215
|
// src/engine/observation/index.ts
|
|
5122
5216
|
var observation_exports = {};
|
|
5123
5217
|
__export(observation_exports, {
|
|
5218
|
+
ResponseObserver: () => ResponseObserver,
|
|
5124
5219
|
buildQueueMessage: () => buildQueueMessage,
|
|
5125
5220
|
buildUnsignedWitness: () => buildUnsignedWitness,
|
|
5126
5221
|
canonicalizeObservation: () => canonicalizeObservation,
|
|
@@ -5145,35 +5240,6 @@ __export(loom_exports, {
|
|
|
5145
5240
|
deriveAnchorReflection: () => deriveAnchorReflection
|
|
5146
5241
|
});
|
|
5147
5242
|
|
|
5148
|
-
// src/loom/loom.types.ts
|
|
5149
|
-
function deriveAnchorReflection(softid, context = "openlogs", scope = "loom") {
|
|
5150
|
-
return `ar:${context}:${scope}:${softid}`;
|
|
5151
|
-
}
|
|
5152
|
-
function canonicalizeWrit(writ) {
|
|
5153
|
-
const ordered = {
|
|
5154
|
-
head: { tid: writ.head.tid, seq: writ.head.seq },
|
|
5155
|
-
body: {
|
|
5156
|
-
who: writ.body.who,
|
|
5157
|
-
act: writ.body.act,
|
|
5158
|
-
res: writ.body.res,
|
|
5159
|
-
law: writ.body.law
|
|
5160
|
-
},
|
|
5161
|
-
meta: { iat: writ.meta.iat, exp: writ.meta.exp, prev: writ.meta.prev }
|
|
5162
|
-
};
|
|
5163
|
-
return JSON.stringify(ordered);
|
|
5164
|
-
}
|
|
5165
|
-
function canonicalizeGrant(grant) {
|
|
5166
|
-
const ordered = {
|
|
5167
|
-
grant_id: grant.grant_id,
|
|
5168
|
-
issuer: grant.issuer,
|
|
5169
|
-
subject: grant.subject,
|
|
5170
|
-
grant_type: grant.grant_type,
|
|
5171
|
-
caps: grant.caps,
|
|
5172
|
-
meta: grant.meta
|
|
5173
|
-
};
|
|
5174
|
-
return JSON.stringify(ordered);
|
|
5175
|
-
}
|
|
5176
|
-
|
|
5177
5243
|
// src/schemas/index.ts
|
|
5178
5244
|
var schemas_exports = {};
|
|
5179
5245
|
__export(schemas_exports, {
|
|
@@ -7184,59 +7250,6 @@ var utils_exports = {};
|
|
|
7184
7250
|
__export(utils_exports, {
|
|
7185
7251
|
encodeAxisTlvDto: () => encodeAxisTlvDto
|
|
7186
7252
|
});
|
|
7187
|
-
|
|
7188
|
-
// src/utils/axis-tlv-codec.ts
|
|
7189
|
-
function encodeAxisTlvDto(dtoClass, data) {
|
|
7190
|
-
const schema = extractDtoSchema(dtoClass);
|
|
7191
|
-
const items = schema.fields.flatMap((field) => {
|
|
7192
|
-
const value = data[field.name];
|
|
7193
|
-
if (value === void 0 || value === null) {
|
|
7194
|
-
if (field.required) {
|
|
7195
|
-
throw new Error(`Missing required TLV response field: ${field.name}`);
|
|
7196
|
-
}
|
|
7197
|
-
return [];
|
|
7198
|
-
}
|
|
7199
|
-
return [{ type: field.tag, value: encodeField(field, value) }];
|
|
7200
|
-
});
|
|
7201
|
-
return buildTLVs(items);
|
|
7202
|
-
}
|
|
7203
|
-
function encodeField(field, value) {
|
|
7204
|
-
switch (field.kind) {
|
|
7205
|
-
case "utf8":
|
|
7206
|
-
return Buffer.from(String(value), "utf8");
|
|
7207
|
-
case "u64":
|
|
7208
|
-
return encodeU64(value);
|
|
7209
|
-
case "bytes":
|
|
7210
|
-
case "bytes16":
|
|
7211
|
-
return toBuffer(value);
|
|
7212
|
-
case "bool":
|
|
7213
|
-
return Buffer.from([value ? 1 : 0]);
|
|
7214
|
-
case "obj":
|
|
7215
|
-
case "arr":
|
|
7216
|
-
return Buffer.from(JSON.stringify(value), "utf8");
|
|
7217
|
-
default:
|
|
7218
|
-
return toBuffer(value);
|
|
7219
|
-
}
|
|
7220
|
-
}
|
|
7221
|
-
function encodeU64(value) {
|
|
7222
|
-
const encoded = Buffer.alloc(8);
|
|
7223
|
-
encoded.writeBigUInt64BE(
|
|
7224
|
-
typeof value === "bigint" ? value : BigInt(value)
|
|
7225
|
-
);
|
|
7226
|
-
return encoded;
|
|
7227
|
-
}
|
|
7228
|
-
function toBuffer(value) {
|
|
7229
|
-
if (Buffer.isBuffer(value)) {
|
|
7230
|
-
return value;
|
|
7231
|
-
}
|
|
7232
|
-
if (value instanceof Uint8Array) {
|
|
7233
|
-
return Buffer.from(value);
|
|
7234
|
-
}
|
|
7235
|
-
if (typeof value === "string") {
|
|
7236
|
-
return Buffer.from(value, "utf8");
|
|
7237
|
-
}
|
|
7238
|
-
throw new Error(`Unsupported TLV bytes value: ${typeof value}`);
|
|
7239
|
-
}
|
|
7240
7253
|
export {
|
|
7241
7254
|
ATS1_HDR,
|
|
7242
7255
|
ATS1_SCHEMA,
|
|
@@ -7326,6 +7339,7 @@ export {
|
|
|
7326
7339
|
RESPONSE_TAG_ID,
|
|
7327
7340
|
RESPONSE_TAG_UPDATED_AT,
|
|
7328
7341
|
RESPONSE_TAG_UPDATED_BY,
|
|
7342
|
+
ResponseObserver,
|
|
7329
7343
|
RiskDecision,
|
|
7330
7344
|
SENSOR_METADATA_KEY,
|
|
7331
7345
|
Schema2002_PasskeyLoginOptionsRes,
|
|
@@ -7359,6 +7373,7 @@ export {
|
|
|
7359
7373
|
TLV_OFFSET,
|
|
7360
7374
|
TLV_OK,
|
|
7361
7375
|
TLV_PID,
|
|
7376
|
+
TLV_LOOM_PRESENCE_ID as TLV_PRESENCE_ID,
|
|
7362
7377
|
TLV_PREV_HASH,
|
|
7363
7378
|
TLV_PROOF_REF,
|
|
7364
7379
|
TLV_PROOF_TYPE,
|
|
@@ -7366,10 +7381,12 @@ export {
|
|
|
7366
7381
|
TLV_RECEIPT_HASH,
|
|
7367
7382
|
TLV_RID,
|
|
7368
7383
|
TLV_SHA256_CHUNK,
|
|
7384
|
+
TLV_LOOM_THREAD_HASH as TLV_THREAD_HASH,
|
|
7369
7385
|
TLV_TRACE_ID,
|
|
7370
7386
|
TLV_TS,
|
|
7371
7387
|
TLV_UPLOAD_ID,
|
|
7372
7388
|
TLV_VALIDATORS_KEY,
|
|
7389
|
+
TLV_LOOM_WRIT as TLV_WRIT,
|
|
7373
7390
|
TlvEnum,
|
|
7374
7391
|
TlvField,
|
|
7375
7392
|
TlvMinLen,
|
|
@@ -7392,7 +7409,9 @@ export {
|
|
|
7392
7409
|
canAccessResource,
|
|
7393
7410
|
canonicalJson,
|
|
7394
7411
|
canonicalJsonExcluding,
|
|
7412
|
+
canonicalizeGrant,
|
|
7395
7413
|
canonicalizeObservation,
|
|
7414
|
+
canonicalizeWrit,
|
|
7396
7415
|
cce_exports as cce,
|
|
7397
7416
|
classifyIntent,
|
|
7398
7417
|
computeReceiptHash,
|
|
@@ -7409,8 +7428,10 @@ export {
|
|
|
7409
7428
|
decodeTLVsList,
|
|
7410
7429
|
decodeVarint,
|
|
7411
7430
|
decorators_exports as decorators,
|
|
7431
|
+
deriveAnchorReflection,
|
|
7412
7432
|
encVarint,
|
|
7413
7433
|
encodeAxis1Frame,
|
|
7434
|
+
encodeAxisTlvDto,
|
|
7414
7435
|
encodeFrame,
|
|
7415
7436
|
encodeQueueMessage,
|
|
7416
7437
|
encodeTLVs,
|