@nextera.one/axis-server-sdk 0.8.0 → 0.9.1
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 +53 -9
- package/dist/index.d.ts +53 -9
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1944,6 +1944,16 @@ var INTENT_REQUIREMENTS = {
|
|
|
1944
1944
|
"admin.*": ["admin"]
|
|
1945
1945
|
};
|
|
1946
1946
|
|
|
1947
|
+
// src/risk/index.ts
|
|
1948
|
+
var RiskDecision = /* @__PURE__ */ ((RiskDecision2) => {
|
|
1949
|
+
RiskDecision2["ALLOW"] = "ALLOW";
|
|
1950
|
+
RiskDecision2["THROTTLE"] = "THROTTLE";
|
|
1951
|
+
RiskDecision2["STEP_UP"] = "STEP_UP";
|
|
1952
|
+
RiskDecision2["WITNESS"] = "WITNESS";
|
|
1953
|
+
RiskDecision2["DENY"] = "DENY";
|
|
1954
|
+
return RiskDecision2;
|
|
1955
|
+
})(RiskDecision || {});
|
|
1956
|
+
|
|
1947
1957
|
// src/core/opcodes.ts
|
|
1948
1958
|
var AXIS_OPCODES = /* @__PURE__ */ new Set([
|
|
1949
1959
|
"CAPSULE.ISSUE",
|
|
@@ -2063,6 +2073,49 @@ function resolveTimeout(intent) {
|
|
|
2063
2073
|
}
|
|
2064
2074
|
return DEFAULT_TIMEOUT;
|
|
2065
2075
|
}
|
|
2076
|
+
|
|
2077
|
+
// src/core/frame-validator.ts
|
|
2078
|
+
function validateFrameShape(frame) {
|
|
2079
|
+
if (!frame || typeof frame !== "object") {
|
|
2080
|
+
return false;
|
|
2081
|
+
}
|
|
2082
|
+
if (frame.v !== 1) {
|
|
2083
|
+
return false;
|
|
2084
|
+
}
|
|
2085
|
+
const requiredStrings = ["pid", "nonce", "actorId", "opcode"];
|
|
2086
|
+
for (const key of requiredStrings) {
|
|
2087
|
+
if (typeof frame[key] !== "string" || frame[key].length < 6) {
|
|
2088
|
+
return false;
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
if (typeof frame.ts !== "number" || !Number.isFinite(frame.ts)) {
|
|
2092
|
+
return false;
|
|
2093
|
+
}
|
|
2094
|
+
if (frame.aud !== void 0 && (typeof frame.aud !== "string" || frame.aud.length === 0)) {
|
|
2095
|
+
return false;
|
|
2096
|
+
}
|
|
2097
|
+
if (!frame.sig || typeof frame.sig !== "object") {
|
|
2098
|
+
return false;
|
|
2099
|
+
}
|
|
2100
|
+
if (frame.sig.alg !== "EdDSA") {
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
if (typeof frame.sig.kid !== "string" || frame.sig.kid.length < 8) {
|
|
2104
|
+
return false;
|
|
2105
|
+
}
|
|
2106
|
+
if (typeof frame.sig.value !== "string" || frame.sig.value.length < 32) {
|
|
2107
|
+
return false;
|
|
2108
|
+
}
|
|
2109
|
+
if (typeof frame.body !== "object" || frame.body === null) {
|
|
2110
|
+
return false;
|
|
2111
|
+
}
|
|
2112
|
+
return true;
|
|
2113
|
+
}
|
|
2114
|
+
function isTimestampValid(ts, skewSeconds = 120) {
|
|
2115
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
2116
|
+
const diff = Math.abs(now - ts);
|
|
2117
|
+
return diff <= skewSeconds;
|
|
2118
|
+
}
|
|
2066
2119
|
export {
|
|
2067
2120
|
ATS1_HDR,
|
|
2068
2121
|
ATS1_SCHEMA,
|
|
@@ -2118,6 +2171,7 @@ export {
|
|
|
2118
2171
|
PROOF_NONE,
|
|
2119
2172
|
PROOF_WITNESS,
|
|
2120
2173
|
ProofType,
|
|
2174
|
+
RiskDecision,
|
|
2121
2175
|
Schema2002_PasskeyLoginOptionsRes,
|
|
2122
2176
|
Schema2011_PasskeyLoginVerifyReq,
|
|
2123
2177
|
Schema2012_PasskeyLoginVerifyRes,
|
|
@@ -2187,6 +2241,7 @@ export {
|
|
|
2187
2241
|
hasScope,
|
|
2188
2242
|
isAdminOpcode,
|
|
2189
2243
|
isKnownOpcode,
|
|
2244
|
+
isTimestampValid,
|
|
2190
2245
|
nonce16,
|
|
2191
2246
|
normalizeSensorDecision,
|
|
2192
2247
|
packPasskeyLoginOptionsReq,
|
|
@@ -2205,6 +2260,7 @@ export {
|
|
|
2205
2260
|
unpackPasskeyLoginVerifyReq,
|
|
2206
2261
|
unpackPasskeyRegisterOptionsReq,
|
|
2207
2262
|
utf8,
|
|
2263
|
+
validateFrameShape,
|
|
2208
2264
|
varintLength,
|
|
2209
2265
|
varintU,
|
|
2210
2266
|
verifyFrameSignature
|