@nextera.one/axis-server-sdk 0.9.2 → 1.0.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 +3 -245
- package/dist/index.d.ts +3 -245
- package/dist/index.js +2 -493
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -457
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -43,19 +43,14 @@ __export(index_exports, {
|
|
|
43
43
|
AXIS_OPCODES: () => AXIS_OPCODES,
|
|
44
44
|
AXIS_VERSION: () => AXIS_VERSION,
|
|
45
45
|
Ats1Codec: () => ats1_exports,
|
|
46
|
-
AuthLevel: () => AuthLevel,
|
|
47
46
|
AxisFrameZ: () => AxisFrameZ,
|
|
48
47
|
AxisPacketTags: () => T,
|
|
49
48
|
BodyProfile: () => BodyProfile,
|
|
50
49
|
CAPABILITIES: () => CAPABILITIES,
|
|
51
|
-
CapsuleStatus: () => CapsuleStatus,
|
|
52
50
|
ContractViolationError: () => ContractViolationError,
|
|
53
51
|
DEFAULT_CONTRACTS: () => DEFAULT_CONTRACTS,
|
|
54
52
|
DEFAULT_TIMEOUT: () => DEFAULT_TIMEOUT,
|
|
55
53
|
Decision: () => Decision,
|
|
56
|
-
DeviceStatus: () => DeviceStatus,
|
|
57
|
-
DeviceTrustLevel: () => DeviceTrustLevel,
|
|
58
|
-
DeviceType: () => DeviceType,
|
|
59
54
|
ERR_BAD_SIGNATURE: () => ERR_BAD_SIGNATURE,
|
|
60
55
|
ERR_CONTRACT_VIOLATION: () => ERR_CONTRACT_VIOLATION,
|
|
61
56
|
ERR_INVALID_PACKET: () => ERR_INVALID_PACKET,
|
|
@@ -74,7 +69,6 @@ __export(index_exports, {
|
|
|
74
69
|
Intent: () => Intent,
|
|
75
70
|
IntentRouter: () => IntentRouter,
|
|
76
71
|
IntentSensitivity: () => IntentSensitivity,
|
|
77
|
-
LoginChallengeStatus: () => LoginChallengeStatus,
|
|
78
72
|
MAX_BODY_LEN: () => MAX_BODY_LEN,
|
|
79
73
|
MAX_FRAME_LEN: () => MAX_FRAME_LEN,
|
|
80
74
|
MAX_HDR_LEN: () => MAX_HDR_LEN,
|
|
@@ -89,10 +83,6 @@ __export(index_exports, {
|
|
|
89
83
|
NCERT_PUB: () => NCERT_PUB,
|
|
90
84
|
NCERT_SCOPE: () => NCERT_SCOPE,
|
|
91
85
|
NCERT_SIG: () => NCERT_SIG,
|
|
92
|
-
NESTFLOW_INTENTS: () => NESTFLOW_INTENTS,
|
|
93
|
-
NESTFLOW_INTENT_SET: () => NESTFLOW_INTENT_SET,
|
|
94
|
-
NESTFLOW_POLICY_MAP: () => NESTFLOW_POLICY_MAP,
|
|
95
|
-
NestFlowCapsuleType: () => NestFlowCapsuleType,
|
|
96
86
|
PROOF_CAPABILITIES: () => PROOF_CAPABILITIES,
|
|
97
87
|
PROOF_CAPSULE: () => PROOF_CAPSULE,
|
|
98
88
|
PROOF_JWT: () => PROOF_JWT,
|
|
@@ -107,7 +97,6 @@ __export(index_exports, {
|
|
|
107
97
|
Schema2012_PasskeyLoginVerifyRes: () => Schema2012_PasskeyLoginVerifyRes,
|
|
108
98
|
Schema2021_PasskeyRegisterOptionsReq: () => Schema2021_PasskeyRegisterOptionsReq,
|
|
109
99
|
SensorDecisions: () => SensorDecisions,
|
|
110
|
-
SessionStatus: () => SessionStatus,
|
|
111
100
|
TLV_ACTOR_ID: () => TLV_ACTOR_ID,
|
|
112
101
|
TLV_AUD: () => TLV_AUD,
|
|
113
102
|
TLV_BODY_ARR: () => TLV_BODY_ARR,
|
|
@@ -139,9 +128,6 @@ __export(index_exports, {
|
|
|
139
128
|
TLV_TRACE_ID: () => TLV_TRACE_ID,
|
|
140
129
|
TLV_TS: () => TLV_TS,
|
|
141
130
|
TLV_UPLOAD_ID: () => TLV_UPLOAD_ID,
|
|
142
|
-
TickAuthChallengeStatus: () => TickAuthChallengeStatus,
|
|
143
|
-
TrustLinkStatus: () => TrustLinkStatus,
|
|
144
|
-
TrustLinkType: () => TrustLinkType,
|
|
145
131
|
axis1SigningBytes: () => axis1SigningBytes,
|
|
146
132
|
b64urlDecode: () => b64urlDecode,
|
|
147
133
|
b64urlDecodeString: () => b64urlDecodeString,
|
|
@@ -155,14 +141,6 @@ __export(index_exports, {
|
|
|
155
141
|
canAccessResource: () => canAccessResource,
|
|
156
142
|
canonicalJson: () => canonicalJson,
|
|
157
143
|
canonicalJsonExcluding: () => canonicalJsonExcluding,
|
|
158
|
-
checkBrowserProof: () => checkBrowserProof,
|
|
159
|
-
checkCapsule: () => checkCapsule,
|
|
160
|
-
checkDeviceTrust: () => checkDeviceTrust,
|
|
161
|
-
checkIntentPolicy: () => checkIntentPolicy,
|
|
162
|
-
checkLoginChallenge: () => checkLoginChallenge,
|
|
163
|
-
checkReplayProtection: () => checkReplayProtection,
|
|
164
|
-
checkSession: () => checkSession,
|
|
165
|
-
checkTickAuth: () => checkTickAuth,
|
|
166
144
|
classifyIntent: () => classifyIntent,
|
|
167
145
|
computeReceiptHash: () => computeReceiptHash,
|
|
168
146
|
computeSignaturePayload: () => computeSignaturePayload,
|
|
@@ -179,17 +157,10 @@ __export(index_exports, {
|
|
|
179
157
|
encodeTLVs: () => encodeTLVs,
|
|
180
158
|
encodeVarint: () => encodeVarint,
|
|
181
159
|
generateEd25519KeyPair: () => generateEd25519KeyPair,
|
|
182
|
-
getRequiredAuthLevel: () => getRequiredAuthLevel,
|
|
183
160
|
getSignTarget: () => getSignTarget,
|
|
184
161
|
hasScope: () => hasScope,
|
|
185
162
|
isAdminOpcode: () => isAdminOpcode,
|
|
186
|
-
isCapsuleTerminal: () => isCapsuleTerminal,
|
|
187
|
-
isDeviceTerminal: () => isDeviceTerminal,
|
|
188
163
|
isKnownOpcode: () => isKnownOpcode,
|
|
189
|
-
isLoginChallengeTerminal: () => isLoginChallengeTerminal,
|
|
190
|
-
isNestFlowIntent: () => isNestFlowIntent,
|
|
191
|
-
isSessionTerminal: () => isSessionTerminal,
|
|
192
|
-
isTickAuthTerminal: () => isTickAuthTerminal,
|
|
193
164
|
isTimestampValid: () => isTimestampValid,
|
|
194
165
|
nonce16: () => nonce16,
|
|
195
166
|
normalizeSensorDecision: () => normalizeSensorDecision,
|
|
@@ -200,7 +171,6 @@ __export(index_exports, {
|
|
|
200
171
|
packPasskeyRegisterOptionsReq: () => packPasskeyRegisterOptionsReq,
|
|
201
172
|
parseScope: () => parseScope,
|
|
202
173
|
resolveTimeout: () => resolveTimeout,
|
|
203
|
-
satisfiesAuthLevel: () => satisfiesAuthLevel,
|
|
204
174
|
sensitivityName: () => sensitivityName,
|
|
205
175
|
sha256: () => sha256,
|
|
206
176
|
signFrame: () => signFrame,
|
|
@@ -210,13 +180,7 @@ __export(index_exports, {
|
|
|
210
180
|
unpackPasskeyLoginVerifyReq: () => unpackPasskeyLoginVerifyReq,
|
|
211
181
|
unpackPasskeyRegisterOptionsReq: () => unpackPasskeyRegisterOptionsReq,
|
|
212
182
|
utf8: () => utf8,
|
|
213
|
-
validateCapsuleTransition: () => validateCapsuleTransition,
|
|
214
|
-
validateDeviceTransition: () => validateDeviceTransition,
|
|
215
183
|
validateFrameShape: () => validateFrameShape,
|
|
216
|
-
validateLoginChallengeTransition: () => validateLoginChallengeTransition,
|
|
217
|
-
validateSessionTransition: () => validateSessionTransition,
|
|
218
|
-
validateTickAuthTransition: () => validateTickAuthTransition,
|
|
219
|
-
validateTrustLinkTransition: () => validateTrustLinkTransition,
|
|
220
184
|
varintLength: () => varintLength,
|
|
221
185
|
varintU: () => varintU,
|
|
222
186
|
verifyFrameSignature: () => verifyFrameSignature
|
|
@@ -1572,10 +1536,10 @@ function tlv(type, value) {
|
|
|
1572
1536
|
]);
|
|
1573
1537
|
}
|
|
1574
1538
|
function buildTLVs(items, opts) {
|
|
1575
|
-
const
|
|
1539
|
+
const allow = opts?.allowDupTypes ?? /* @__PURE__ */ new Set();
|
|
1576
1540
|
const sorted = [...items].sort((a, b) => a.type - b.type);
|
|
1577
1541
|
for (let i = 1; i < sorted.length; i++) {
|
|
1578
|
-
if (sorted[i].type === sorted[i - 1].type && !
|
|
1542
|
+
if (sorted[i].type === sorted[i - 1].type && !allow.has(sorted[i].type)) {
|
|
1579
1543
|
throw new Error(`TLV_DUP_TYPE_${sorted[i].type}`);
|
|
1580
1544
|
}
|
|
1581
1545
|
}
|
|
@@ -2385,425 +2349,6 @@ function isTimestampValid(ts, skewSeconds = 120) {
|
|
|
2385
2349
|
const diff = Math.abs(now - ts);
|
|
2386
2350
|
return diff <= skewSeconds;
|
|
2387
2351
|
}
|
|
2388
|
-
|
|
2389
|
-
// src/nestflow/types.ts
|
|
2390
|
-
var DeviceType = /* @__PURE__ */ ((DeviceType2) => {
|
|
2391
|
-
DeviceType2["MOBILE"] = "mobile";
|
|
2392
|
-
DeviceType2["BROWSER"] = "browser";
|
|
2393
|
-
DeviceType2["CLI"] = "cli";
|
|
2394
|
-
DeviceType2["SERVICE"] = "service";
|
|
2395
|
-
return DeviceType2;
|
|
2396
|
-
})(DeviceType || {});
|
|
2397
|
-
var DeviceTrustLevel = /* @__PURE__ */ ((DeviceTrustLevel2) => {
|
|
2398
|
-
DeviceTrustLevel2["PRIMARY"] = "primary";
|
|
2399
|
-
DeviceTrustLevel2["TRUSTED"] = "trusted";
|
|
2400
|
-
DeviceTrustLevel2["EPHEMERAL"] = "ephemeral";
|
|
2401
|
-
return DeviceTrustLevel2;
|
|
2402
|
-
})(DeviceTrustLevel || {});
|
|
2403
|
-
var DeviceStatus = /* @__PURE__ */ ((DeviceStatus2) => {
|
|
2404
|
-
DeviceStatus2["ACTIVE"] = "active";
|
|
2405
|
-
DeviceStatus2["REVOKED"] = "revoked";
|
|
2406
|
-
DeviceStatus2["SUSPENDED"] = "suspended";
|
|
2407
|
-
return DeviceStatus2;
|
|
2408
|
-
})(DeviceStatus || {});
|
|
2409
|
-
var LoginChallengeStatus = /* @__PURE__ */ ((LoginChallengeStatus3) => {
|
|
2410
|
-
LoginChallengeStatus3["PENDING"] = "pending";
|
|
2411
|
-
LoginChallengeStatus3["SCANNED"] = "scanned";
|
|
2412
|
-
LoginChallengeStatus3["APPROVED"] = "approved";
|
|
2413
|
-
LoginChallengeStatus3["REJECTED"] = "rejected";
|
|
2414
|
-
LoginChallengeStatus3["EXPIRED"] = "expired";
|
|
2415
|
-
return LoginChallengeStatus3;
|
|
2416
|
-
})(LoginChallengeStatus || {});
|
|
2417
|
-
var TickAuthChallengeStatus = /* @__PURE__ */ ((TickAuthChallengeStatus2) => {
|
|
2418
|
-
TickAuthChallengeStatus2["PENDING"] = "pending";
|
|
2419
|
-
TickAuthChallengeStatus2["FULFILLED"] = "fulfilled";
|
|
2420
|
-
TickAuthChallengeStatus2["REJECTED"] = "rejected";
|
|
2421
|
-
TickAuthChallengeStatus2["EXPIRED"] = "expired";
|
|
2422
|
-
return TickAuthChallengeStatus2;
|
|
2423
|
-
})(TickAuthChallengeStatus || {});
|
|
2424
|
-
var NestFlowCapsuleType = /* @__PURE__ */ ((NestFlowCapsuleType2) => {
|
|
2425
|
-
NestFlowCapsuleType2["LOGIN"] = "login";
|
|
2426
|
-
NestFlowCapsuleType2["DEVICE_REGISTRATION"] = "device_registration";
|
|
2427
|
-
NestFlowCapsuleType2["STEP_UP"] = "step_up";
|
|
2428
|
-
NestFlowCapsuleType2["RECOVERY"] = "recovery";
|
|
2429
|
-
return NestFlowCapsuleType2;
|
|
2430
|
-
})(NestFlowCapsuleType || {});
|
|
2431
|
-
var CapsuleStatus = /* @__PURE__ */ ((CapsuleStatus2) => {
|
|
2432
|
-
CapsuleStatus2["ACTIVE"] = "active";
|
|
2433
|
-
CapsuleStatus2["CONSUMED"] = "consumed";
|
|
2434
|
-
CapsuleStatus2["REVOKED"] = "revoked";
|
|
2435
|
-
CapsuleStatus2["EXPIRED"] = "expired";
|
|
2436
|
-
return CapsuleStatus2;
|
|
2437
|
-
})(CapsuleStatus || {});
|
|
2438
|
-
var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
|
|
2439
|
-
SessionStatus2["ACTIVE"] = "active";
|
|
2440
|
-
SessionStatus2["EXPIRED"] = "expired";
|
|
2441
|
-
SessionStatus2["REVOKED"] = "revoked";
|
|
2442
|
-
return SessionStatus2;
|
|
2443
|
-
})(SessionStatus || {});
|
|
2444
|
-
var TrustLinkType = /* @__PURE__ */ ((TrustLinkType2) => {
|
|
2445
|
-
TrustLinkType2["LOGIN"] = "login";
|
|
2446
|
-
TrustLinkType2["PROMOTION"] = "promotion";
|
|
2447
|
-
TrustLinkType2["RECOVERY"] = "recovery";
|
|
2448
|
-
return TrustLinkType2;
|
|
2449
|
-
})(TrustLinkType || {});
|
|
2450
|
-
var TrustLinkStatus = /* @__PURE__ */ ((TrustLinkStatus2) => {
|
|
2451
|
-
TrustLinkStatus2["ACTIVE"] = "active";
|
|
2452
|
-
TrustLinkStatus2["REVOKED"] = "revoked";
|
|
2453
|
-
return TrustLinkStatus2;
|
|
2454
|
-
})(TrustLinkStatus || {});
|
|
2455
|
-
var AuthLevel = /* @__PURE__ */ ((AuthLevel2) => {
|
|
2456
|
-
AuthLevel2["SESSION"] = "session";
|
|
2457
|
-
AuthLevel2["SESSION_BROWSER"] = "session_browser";
|
|
2458
|
-
AuthLevel2["STEP_UP"] = "step_up";
|
|
2459
|
-
AuthLevel2["PRIMARY_DEVICE"] = "primary_device";
|
|
2460
|
-
return AuthLevel2;
|
|
2461
|
-
})(AuthLevel || {});
|
|
2462
|
-
|
|
2463
|
-
// src/nestflow/intents.ts
|
|
2464
|
-
var NESTFLOW_INTENTS = {
|
|
2465
|
-
// Auth
|
|
2466
|
-
AUTH_WEB_LOGIN_REQUEST: "auth.web.login.request",
|
|
2467
|
-
AUTH_WEB_LOGIN_SCAN: "auth.web.login.scan",
|
|
2468
|
-
// TickAuth
|
|
2469
|
-
TICKAUTH_CHALLENGE_CREATE: "tickauth.challenge.create",
|
|
2470
|
-
TICKAUTH_CHALLENGE_FULFILL: "tickauth.challenge.fulfill",
|
|
2471
|
-
TICKAUTH_CHALLENGE_REJECT: "tickauth.challenge.reject",
|
|
2472
|
-
// Capsule
|
|
2473
|
-
CAPSULE_ISSUE_LOGIN: "capsule.issue.login",
|
|
2474
|
-
CAPSULE_ISSUE_DEVICE_REGISTRATION: "capsule.issue.device_registration",
|
|
2475
|
-
CAPSULE_ISSUE_STEP_UP: "capsule.issue.step_up",
|
|
2476
|
-
CAPSULE_ISSUE_RECOVERY: "capsule.issue.recovery",
|
|
2477
|
-
// Session
|
|
2478
|
-
SESSION_ACTIVATE: "session.activate",
|
|
2479
|
-
SESSION_REFRESH: "session.refresh",
|
|
2480
|
-
SESSION_LOGOUT: "session.logout",
|
|
2481
|
-
// Device Trust
|
|
2482
|
-
DEVICE_TRUST_REQUEST: "device.trust.request",
|
|
2483
|
-
DEVICE_TRUST_PROMOTE: "device.trust.promote",
|
|
2484
|
-
DEVICE_REVOKE: "device.revoke",
|
|
2485
|
-
DEVICE_LIST: "device.list",
|
|
2486
|
-
DEVICE_RENAME: "device.rename",
|
|
2487
|
-
// Protected Operations
|
|
2488
|
-
FLOW_PUBLISH: "flow.publish",
|
|
2489
|
-
FLOW_DELETE: "flow.delete",
|
|
2490
|
-
NODE_DELETE: "node.delete",
|
|
2491
|
-
SECRET_ROTATE: "secret.rotate",
|
|
2492
|
-
ORG_SECURITY_UPDATE: "org.security.update",
|
|
2493
|
-
PRODUCTION_EXECUTION_APPROVE: "production.execution.approve",
|
|
2494
|
-
// Recovery
|
|
2495
|
-
IDENTITY_RECOVERY_START: "identity.recovery.start",
|
|
2496
|
-
IDENTITY_RECOVERY_COMPLETE: "identity.recovery.complete",
|
|
2497
|
-
PRIMARY_DEVICE_ROTATE: "primary.device.rotate",
|
|
2498
|
-
IDENTITY_LOCK: "identity.lock",
|
|
2499
|
-
IDENTITY_UNLOCK: "identity.unlock"
|
|
2500
|
-
};
|
|
2501
|
-
var NESTFLOW_INTENT_SET = new Set(
|
|
2502
|
-
Object.values(NESTFLOW_INTENTS)
|
|
2503
|
-
);
|
|
2504
|
-
function isNestFlowIntent(intent) {
|
|
2505
|
-
return NESTFLOW_INTENT_SET.has(intent);
|
|
2506
|
-
}
|
|
2507
|
-
|
|
2508
|
-
// src/nestflow/policy-map.ts
|
|
2509
|
-
var NESTFLOW_POLICY_MAP = {
|
|
2510
|
-
// Auth — unauthenticated initiator (session issued after)
|
|
2511
|
-
[NESTFLOW_INTENTS.AUTH_WEB_LOGIN_REQUEST]: "session" /* SESSION */,
|
|
2512
|
-
[NESTFLOW_INTENTS.AUTH_WEB_LOGIN_SCAN]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2513
|
-
// TickAuth — primary device handles challenges
|
|
2514
|
-
[NESTFLOW_INTENTS.TICKAUTH_CHALLENGE_CREATE]: "session" /* SESSION */,
|
|
2515
|
-
[NESTFLOW_INTENTS.TICKAUTH_CHALLENGE_FULFILL]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2516
|
-
[NESTFLOW_INTENTS.TICKAUTH_CHALLENGE_REJECT]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2517
|
-
// Capsule issuance — varies per type
|
|
2518
|
-
[NESTFLOW_INTENTS.CAPSULE_ISSUE_LOGIN]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2519
|
-
[NESTFLOW_INTENTS.CAPSULE_ISSUE_DEVICE_REGISTRATION]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2520
|
-
[NESTFLOW_INTENTS.CAPSULE_ISSUE_STEP_UP]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2521
|
-
[NESTFLOW_INTENTS.CAPSULE_ISSUE_RECOVERY]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2522
|
-
// Session management
|
|
2523
|
-
[NESTFLOW_INTENTS.SESSION_ACTIVATE]: "session" /* SESSION */,
|
|
2524
|
-
[NESTFLOW_INTENTS.SESSION_REFRESH]: "session_browser" /* SESSION_BROWSER */,
|
|
2525
|
-
[NESTFLOW_INTENTS.SESSION_LOGOUT]: "session" /* SESSION */,
|
|
2526
|
-
// Device trust management
|
|
2527
|
-
[NESTFLOW_INTENTS.DEVICE_TRUST_REQUEST]: "session_browser" /* SESSION_BROWSER */,
|
|
2528
|
-
[NESTFLOW_INTENTS.DEVICE_TRUST_PROMOTE]: "step_up" /* STEP_UP */,
|
|
2529
|
-
[NESTFLOW_INTENTS.DEVICE_REVOKE]: "step_up" /* STEP_UP */,
|
|
2530
|
-
[NESTFLOW_INTENTS.DEVICE_LIST]: "session" /* SESSION */,
|
|
2531
|
-
[NESTFLOW_INTENTS.DEVICE_RENAME]: "session_browser" /* SESSION_BROWSER */,
|
|
2532
|
-
// Protected operations — require step-up auth
|
|
2533
|
-
[NESTFLOW_INTENTS.FLOW_PUBLISH]: "session_browser" /* SESSION_BROWSER */,
|
|
2534
|
-
[NESTFLOW_INTENTS.FLOW_DELETE]: "step_up" /* STEP_UP */,
|
|
2535
|
-
[NESTFLOW_INTENTS.NODE_DELETE]: "step_up" /* STEP_UP */,
|
|
2536
|
-
[NESTFLOW_INTENTS.SECRET_ROTATE]: "step_up" /* STEP_UP */,
|
|
2537
|
-
[NESTFLOW_INTENTS.ORG_SECURITY_UPDATE]: "step_up" /* STEP_UP */,
|
|
2538
|
-
[NESTFLOW_INTENTS.PRODUCTION_EXECUTION_APPROVE]: "step_up" /* STEP_UP */,
|
|
2539
|
-
// Recovery — highest privilege
|
|
2540
|
-
[NESTFLOW_INTENTS.IDENTITY_RECOVERY_START]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2541
|
-
[NESTFLOW_INTENTS.IDENTITY_RECOVERY_COMPLETE]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2542
|
-
[NESTFLOW_INTENTS.PRIMARY_DEVICE_ROTATE]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2543
|
-
[NESTFLOW_INTENTS.IDENTITY_LOCK]: "primary_device" /* PRIMARY_DEVICE */,
|
|
2544
|
-
[NESTFLOW_INTENTS.IDENTITY_UNLOCK]: "primary_device" /* PRIMARY_DEVICE */
|
|
2545
|
-
};
|
|
2546
|
-
function getRequiredAuthLevel(intent) {
|
|
2547
|
-
return NESTFLOW_POLICY_MAP[intent];
|
|
2548
|
-
}
|
|
2549
|
-
var AUTH_LEVEL_ORDER = [
|
|
2550
|
-
"session" /* SESSION */,
|
|
2551
|
-
"session_browser" /* SESSION_BROWSER */,
|
|
2552
|
-
"step_up" /* STEP_UP */,
|
|
2553
|
-
"primary_device" /* PRIMARY_DEVICE */
|
|
2554
|
-
];
|
|
2555
|
-
function satisfiesAuthLevel(provided, required) {
|
|
2556
|
-
const providedIdx = AUTH_LEVEL_ORDER.indexOf(provided);
|
|
2557
|
-
const requiredIdx = AUTH_LEVEL_ORDER.indexOf(required);
|
|
2558
|
-
return providedIdx >= requiredIdx;
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
|
-
// src/nestflow/guards.ts
|
|
2562
|
-
var allow = () => ({ allowed: true });
|
|
2563
|
-
var deny = (reason) => ({ allowed: false, reason });
|
|
2564
|
-
function checkIntentPolicy(intent, currentAuthLevel) {
|
|
2565
|
-
const required = getRequiredAuthLevel(intent);
|
|
2566
|
-
if (!required) {
|
|
2567
|
-
return allow();
|
|
2568
|
-
}
|
|
2569
|
-
if (satisfiesAuthLevel(currentAuthLevel, required)) {
|
|
2570
|
-
return allow();
|
|
2571
|
-
}
|
|
2572
|
-
return {
|
|
2573
|
-
allowed: false,
|
|
2574
|
-
reason: `Intent '${intent}' requires auth level '${required}', got '${currentAuthLevel}'`,
|
|
2575
|
-
step_up_intent: required === "step_up" /* STEP_UP */ ? intent : void 0
|
|
2576
|
-
};
|
|
2577
|
-
}
|
|
2578
|
-
function checkSession(session) {
|
|
2579
|
-
if (!session) {
|
|
2580
|
-
return deny("No session found");
|
|
2581
|
-
}
|
|
2582
|
-
if (session.status !== "active" /* ACTIVE */) {
|
|
2583
|
-
return deny(`Session status is '${session.status}', expected 'active'`);
|
|
2584
|
-
}
|
|
2585
|
-
if (new Date(session.expires_at).getTime() < Date.now()) {
|
|
2586
|
-
return deny("Session has expired");
|
|
2587
|
-
}
|
|
2588
|
-
return allow();
|
|
2589
|
-
}
|
|
2590
|
-
function checkBrowserProof(proof, expectedNonce) {
|
|
2591
|
-
if (!proof) {
|
|
2592
|
-
return deny("Browser proof-of-possession required but not provided");
|
|
2593
|
-
}
|
|
2594
|
-
if (!proof.server_nonce || !proof.signature || !proof.signature_algorithm) {
|
|
2595
|
-
return deny("Browser proof is missing required fields");
|
|
2596
|
-
}
|
|
2597
|
-
if (proof.server_nonce !== expectedNonce) {
|
|
2598
|
-
return deny("Browser proof nonce does not match expected server nonce");
|
|
2599
|
-
}
|
|
2600
|
-
return allow();
|
|
2601
|
-
}
|
|
2602
|
-
var TRUST_ORDER = [
|
|
2603
|
-
"ephemeral" /* EPHEMERAL */,
|
|
2604
|
-
"trusted" /* TRUSTED */,
|
|
2605
|
-
"primary" /* PRIMARY */
|
|
2606
|
-
];
|
|
2607
|
-
function checkDeviceTrust(device, minimumTrust) {
|
|
2608
|
-
if (!device) {
|
|
2609
|
-
return deny("Device not found");
|
|
2610
|
-
}
|
|
2611
|
-
if (device.status !== "active" /* ACTIVE */) {
|
|
2612
|
-
return deny(`Device status is '${device.status}', expected 'active'`);
|
|
2613
|
-
}
|
|
2614
|
-
const deviceIdx = TRUST_ORDER.indexOf(device.trust_level);
|
|
2615
|
-
const requiredIdx = TRUST_ORDER.indexOf(minimumTrust);
|
|
2616
|
-
if (deviceIdx < requiredIdx) {
|
|
2617
|
-
return deny(
|
|
2618
|
-
`Device trust level '${device.trust_level}' does not meet minimum '${minimumTrust}'`
|
|
2619
|
-
);
|
|
2620
|
-
}
|
|
2621
|
-
return allow();
|
|
2622
|
-
}
|
|
2623
|
-
function checkCapsule(capsule, intent, requestingDeviceUid) {
|
|
2624
|
-
if (!capsule) {
|
|
2625
|
-
return deny("Capsule not found");
|
|
2626
|
-
}
|
|
2627
|
-
if (capsule.status !== "active" /* ACTIVE */) {
|
|
2628
|
-
return deny(`Capsule status is '${capsule.status}', expected 'active'`);
|
|
2629
|
-
}
|
|
2630
|
-
if (new Date(capsule.expires_at).getTime() < Date.now()) {
|
|
2631
|
-
return deny("Capsule has expired");
|
|
2632
|
-
}
|
|
2633
|
-
const intentAllowed = capsule.intents.some((pattern) => {
|
|
2634
|
-
if (pattern === "*") return true;
|
|
2635
|
-
if (pattern === intent) return true;
|
|
2636
|
-
if (pattern.endsWith(".*")) {
|
|
2637
|
-
return intent.startsWith(pattern.slice(0, -1));
|
|
2638
|
-
}
|
|
2639
|
-
return false;
|
|
2640
|
-
});
|
|
2641
|
-
if (!intentAllowed) {
|
|
2642
|
-
return deny(`Capsule does not authorize intent '${intent}'`);
|
|
2643
|
-
}
|
|
2644
|
-
if (capsule.device_uid && requestingDeviceUid && capsule.device_uid !== requestingDeviceUid) {
|
|
2645
|
-
return deny("Capsule is bound to a different device");
|
|
2646
|
-
}
|
|
2647
|
-
return allow();
|
|
2648
|
-
}
|
|
2649
|
-
function checkLoginChallenge(challenge, expectedStatus) {
|
|
2650
|
-
if (!challenge) {
|
|
2651
|
-
return deny("Login challenge not found");
|
|
2652
|
-
}
|
|
2653
|
-
if (new Date(challenge.expires_at).getTime() < Date.now()) {
|
|
2654
|
-
return deny("Login challenge has expired");
|
|
2655
|
-
}
|
|
2656
|
-
if (challenge.status !== expectedStatus) {
|
|
2657
|
-
return deny(
|
|
2658
|
-
`Login challenge status is '${challenge.status}', expected '${expectedStatus}'`
|
|
2659
|
-
);
|
|
2660
|
-
}
|
|
2661
|
-
return allow();
|
|
2662
|
-
}
|
|
2663
|
-
function checkTickAuth(challenge) {
|
|
2664
|
-
if (!challenge) {
|
|
2665
|
-
return deny("TickAuth challenge not found");
|
|
2666
|
-
}
|
|
2667
|
-
if (challenge.status !== "pending" /* PENDING */) {
|
|
2668
|
-
return deny(
|
|
2669
|
-
`TickAuth challenge status is '${challenge.status}', expected 'pending'`
|
|
2670
|
-
);
|
|
2671
|
-
}
|
|
2672
|
-
const now = Date.now();
|
|
2673
|
-
const start = new Date(challenge.tick_window.start).getTime();
|
|
2674
|
-
const end = new Date(challenge.tick_window.end).getTime();
|
|
2675
|
-
if (now < start || now > end) {
|
|
2676
|
-
return deny("TickAuth challenge is outside its tick window");
|
|
2677
|
-
}
|
|
2678
|
-
return allow();
|
|
2679
|
-
}
|
|
2680
|
-
async function checkReplayProtection(nonce, store, windowMs = 5 * 60 * 1e3) {
|
|
2681
|
-
if (!nonce) {
|
|
2682
|
-
return deny("Nonce is required for replay protection");
|
|
2683
|
-
}
|
|
2684
|
-
const seen = await store.has(nonce);
|
|
2685
|
-
if (seen) {
|
|
2686
|
-
return deny("Nonce has already been used (replay detected)");
|
|
2687
|
-
}
|
|
2688
|
-
await store.add(nonce, new Date(Date.now() + windowMs));
|
|
2689
|
-
return allow();
|
|
2690
|
-
}
|
|
2691
|
-
|
|
2692
|
-
// src/nestflow/invariants.ts
|
|
2693
|
-
var LOGIN_CHALLENGE_TRANSITIONS = {
|
|
2694
|
-
["pending" /* PENDING */]: [
|
|
2695
|
-
"scanned" /* SCANNED */,
|
|
2696
|
-
"expired" /* EXPIRED */
|
|
2697
|
-
],
|
|
2698
|
-
["scanned" /* SCANNED */]: [
|
|
2699
|
-
"approved" /* APPROVED */,
|
|
2700
|
-
"rejected" /* REJECTED */,
|
|
2701
|
-
"expired" /* EXPIRED */
|
|
2702
|
-
],
|
|
2703
|
-
["approved" /* APPROVED */]: [],
|
|
2704
|
-
["rejected" /* REJECTED */]: [],
|
|
2705
|
-
["expired" /* EXPIRED */]: []
|
|
2706
|
-
};
|
|
2707
|
-
var TICKAUTH_TRANSITIONS = {
|
|
2708
|
-
["pending" /* PENDING */]: [
|
|
2709
|
-
"fulfilled" /* FULFILLED */,
|
|
2710
|
-
"rejected" /* REJECTED */,
|
|
2711
|
-
"expired" /* EXPIRED */
|
|
2712
|
-
],
|
|
2713
|
-
["fulfilled" /* FULFILLED */]: [],
|
|
2714
|
-
["rejected" /* REJECTED */]: [],
|
|
2715
|
-
["expired" /* EXPIRED */]: []
|
|
2716
|
-
};
|
|
2717
|
-
var CAPSULE_TRANSITIONS = {
|
|
2718
|
-
["active" /* ACTIVE */]: [
|
|
2719
|
-
"consumed" /* CONSUMED */,
|
|
2720
|
-
"revoked" /* REVOKED */,
|
|
2721
|
-
"expired" /* EXPIRED */
|
|
2722
|
-
],
|
|
2723
|
-
["consumed" /* CONSUMED */]: [],
|
|
2724
|
-
["revoked" /* REVOKED */]: [],
|
|
2725
|
-
["expired" /* EXPIRED */]: []
|
|
2726
|
-
};
|
|
2727
|
-
var SESSION_TRANSITIONS = {
|
|
2728
|
-
["active" /* ACTIVE */]: ["expired" /* EXPIRED */, "revoked" /* REVOKED */],
|
|
2729
|
-
["expired" /* EXPIRED */]: [],
|
|
2730
|
-
["revoked" /* REVOKED */]: []
|
|
2731
|
-
};
|
|
2732
|
-
var DEVICE_TRANSITIONS = {
|
|
2733
|
-
["active" /* ACTIVE */]: ["suspended" /* SUSPENDED */, "revoked" /* REVOKED */],
|
|
2734
|
-
["suspended" /* SUSPENDED */]: ["active" /* ACTIVE */, "revoked" /* REVOKED */],
|
|
2735
|
-
["revoked" /* REVOKED */]: []
|
|
2736
|
-
};
|
|
2737
|
-
var TRUST_LINK_TRANSITIONS = {
|
|
2738
|
-
["active" /* ACTIVE */]: ["revoked" /* REVOKED */],
|
|
2739
|
-
["revoked" /* REVOKED */]: []
|
|
2740
|
-
};
|
|
2741
|
-
function checkTransition(entity, transitions, from, to) {
|
|
2742
|
-
const allowed = transitions[from];
|
|
2743
|
-
if (!allowed) {
|
|
2744
|
-
return {
|
|
2745
|
-
valid: false,
|
|
2746
|
-
reason: `${entity}: unknown current state '${from}'`
|
|
2747
|
-
};
|
|
2748
|
-
}
|
|
2749
|
-
if (!allowed.includes(to)) {
|
|
2750
|
-
return {
|
|
2751
|
-
valid: false,
|
|
2752
|
-
reason: `${entity}: invalid transition '${from}' \u2192 '${to}'. Allowed: [${allowed.join(", ")}]`
|
|
2753
|
-
};
|
|
2754
|
-
}
|
|
2755
|
-
return { valid: true };
|
|
2756
|
-
}
|
|
2757
|
-
function validateLoginChallengeTransition(from, to) {
|
|
2758
|
-
return checkTransition(
|
|
2759
|
-
"LoginChallenge",
|
|
2760
|
-
LOGIN_CHALLENGE_TRANSITIONS,
|
|
2761
|
-
from,
|
|
2762
|
-
to
|
|
2763
|
-
);
|
|
2764
|
-
}
|
|
2765
|
-
function validateTickAuthTransition(from, to) {
|
|
2766
|
-
return checkTransition("TickAuthChallenge", TICKAUTH_TRANSITIONS, from, to);
|
|
2767
|
-
}
|
|
2768
|
-
function validateCapsuleTransition(from, to) {
|
|
2769
|
-
return checkTransition("Capsule", CAPSULE_TRANSITIONS, from, to);
|
|
2770
|
-
}
|
|
2771
|
-
function validateSessionTransition(from, to) {
|
|
2772
|
-
return checkTransition("Session", SESSION_TRANSITIONS, from, to);
|
|
2773
|
-
}
|
|
2774
|
-
function validateDeviceTransition(from, to) {
|
|
2775
|
-
return checkTransition("Device", DEVICE_TRANSITIONS, from, to);
|
|
2776
|
-
}
|
|
2777
|
-
function validateTrustLinkTransition(from, to) {
|
|
2778
|
-
return checkTransition("TrustLink", TRUST_LINK_TRANSITIONS, from, to);
|
|
2779
|
-
}
|
|
2780
|
-
function isLoginChallengeTerminal(status) {
|
|
2781
|
-
return [
|
|
2782
|
-
"approved" /* APPROVED */,
|
|
2783
|
-
"rejected" /* REJECTED */,
|
|
2784
|
-
"expired" /* EXPIRED */
|
|
2785
|
-
].includes(status);
|
|
2786
|
-
}
|
|
2787
|
-
function isTickAuthTerminal(status) {
|
|
2788
|
-
return [
|
|
2789
|
-
"fulfilled" /* FULFILLED */,
|
|
2790
|
-
"rejected" /* REJECTED */,
|
|
2791
|
-
"expired" /* EXPIRED */
|
|
2792
|
-
].includes(status);
|
|
2793
|
-
}
|
|
2794
|
-
function isCapsuleTerminal(status) {
|
|
2795
|
-
return [
|
|
2796
|
-
"consumed" /* CONSUMED */,
|
|
2797
|
-
"revoked" /* REVOKED */,
|
|
2798
|
-
"expired" /* EXPIRED */
|
|
2799
|
-
].includes(status);
|
|
2800
|
-
}
|
|
2801
|
-
function isSessionTerminal(status) {
|
|
2802
|
-
return ["expired" /* EXPIRED */, "revoked" /* REVOKED */].includes(status);
|
|
2803
|
-
}
|
|
2804
|
-
function isDeviceTerminal(status) {
|
|
2805
|
-
return status === "revoked" /* REVOKED */;
|
|
2806
|
-
}
|
|
2807
2352
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2808
2353
|
0 && (module.exports = {
|
|
2809
2354
|
ATS1_HDR,
|
|
@@ -2812,19 +2357,14 @@ function isDeviceTerminal(status) {
|
|
|
2812
2357
|
AXIS_OPCODES,
|
|
2813
2358
|
AXIS_VERSION,
|
|
2814
2359
|
Ats1Codec,
|
|
2815
|
-
AuthLevel,
|
|
2816
2360
|
AxisFrameZ,
|
|
2817
2361
|
AxisPacketTags,
|
|
2818
2362
|
BodyProfile,
|
|
2819
2363
|
CAPABILITIES,
|
|
2820
|
-
CapsuleStatus,
|
|
2821
2364
|
ContractViolationError,
|
|
2822
2365
|
DEFAULT_CONTRACTS,
|
|
2823
2366
|
DEFAULT_TIMEOUT,
|
|
2824
2367
|
Decision,
|
|
2825
|
-
DeviceStatus,
|
|
2826
|
-
DeviceTrustLevel,
|
|
2827
|
-
DeviceType,
|
|
2828
2368
|
ERR_BAD_SIGNATURE,
|
|
2829
2369
|
ERR_CONTRACT_VIOLATION,
|
|
2830
2370
|
ERR_INVALID_PACKET,
|
|
@@ -2843,7 +2383,6 @@ function isDeviceTerminal(status) {
|
|
|
2843
2383
|
Intent,
|
|
2844
2384
|
IntentRouter,
|
|
2845
2385
|
IntentSensitivity,
|
|
2846
|
-
LoginChallengeStatus,
|
|
2847
2386
|
MAX_BODY_LEN,
|
|
2848
2387
|
MAX_FRAME_LEN,
|
|
2849
2388
|
MAX_HDR_LEN,
|
|
@@ -2858,10 +2397,6 @@ function isDeviceTerminal(status) {
|
|
|
2858
2397
|
NCERT_PUB,
|
|
2859
2398
|
NCERT_SCOPE,
|
|
2860
2399
|
NCERT_SIG,
|
|
2861
|
-
NESTFLOW_INTENTS,
|
|
2862
|
-
NESTFLOW_INTENT_SET,
|
|
2863
|
-
NESTFLOW_POLICY_MAP,
|
|
2864
|
-
NestFlowCapsuleType,
|
|
2865
2400
|
PROOF_CAPABILITIES,
|
|
2866
2401
|
PROOF_CAPSULE,
|
|
2867
2402
|
PROOF_JWT,
|
|
@@ -2876,7 +2411,6 @@ function isDeviceTerminal(status) {
|
|
|
2876
2411
|
Schema2012_PasskeyLoginVerifyRes,
|
|
2877
2412
|
Schema2021_PasskeyRegisterOptionsReq,
|
|
2878
2413
|
SensorDecisions,
|
|
2879
|
-
SessionStatus,
|
|
2880
2414
|
TLV_ACTOR_ID,
|
|
2881
2415
|
TLV_AUD,
|
|
2882
2416
|
TLV_BODY_ARR,
|
|
@@ -2908,9 +2442,6 @@ function isDeviceTerminal(status) {
|
|
|
2908
2442
|
TLV_TRACE_ID,
|
|
2909
2443
|
TLV_TS,
|
|
2910
2444
|
TLV_UPLOAD_ID,
|
|
2911
|
-
TickAuthChallengeStatus,
|
|
2912
|
-
TrustLinkStatus,
|
|
2913
|
-
TrustLinkType,
|
|
2914
2445
|
axis1SigningBytes,
|
|
2915
2446
|
b64urlDecode,
|
|
2916
2447
|
b64urlDecodeString,
|
|
@@ -2924,14 +2455,6 @@ function isDeviceTerminal(status) {
|
|
|
2924
2455
|
canAccessResource,
|
|
2925
2456
|
canonicalJson,
|
|
2926
2457
|
canonicalJsonExcluding,
|
|
2927
|
-
checkBrowserProof,
|
|
2928
|
-
checkCapsule,
|
|
2929
|
-
checkDeviceTrust,
|
|
2930
|
-
checkIntentPolicy,
|
|
2931
|
-
checkLoginChallenge,
|
|
2932
|
-
checkReplayProtection,
|
|
2933
|
-
checkSession,
|
|
2934
|
-
checkTickAuth,
|
|
2935
2458
|
classifyIntent,
|
|
2936
2459
|
computeReceiptHash,
|
|
2937
2460
|
computeSignaturePayload,
|
|
@@ -2948,17 +2471,10 @@ function isDeviceTerminal(status) {
|
|
|
2948
2471
|
encodeTLVs,
|
|
2949
2472
|
encodeVarint,
|
|
2950
2473
|
generateEd25519KeyPair,
|
|
2951
|
-
getRequiredAuthLevel,
|
|
2952
2474
|
getSignTarget,
|
|
2953
2475
|
hasScope,
|
|
2954
2476
|
isAdminOpcode,
|
|
2955
|
-
isCapsuleTerminal,
|
|
2956
|
-
isDeviceTerminal,
|
|
2957
2477
|
isKnownOpcode,
|
|
2958
|
-
isLoginChallengeTerminal,
|
|
2959
|
-
isNestFlowIntent,
|
|
2960
|
-
isSessionTerminal,
|
|
2961
|
-
isTickAuthTerminal,
|
|
2962
2478
|
isTimestampValid,
|
|
2963
2479
|
nonce16,
|
|
2964
2480
|
normalizeSensorDecision,
|
|
@@ -2969,7 +2485,6 @@ function isDeviceTerminal(status) {
|
|
|
2969
2485
|
packPasskeyRegisterOptionsReq,
|
|
2970
2486
|
parseScope,
|
|
2971
2487
|
resolveTimeout,
|
|
2972
|
-
satisfiesAuthLevel,
|
|
2973
2488
|
sensitivityName,
|
|
2974
2489
|
sha256,
|
|
2975
2490
|
signFrame,
|
|
@@ -2979,13 +2494,7 @@ function isDeviceTerminal(status) {
|
|
|
2979
2494
|
unpackPasskeyLoginVerifyReq,
|
|
2980
2495
|
unpackPasskeyRegisterOptionsReq,
|
|
2981
2496
|
utf8,
|
|
2982
|
-
validateCapsuleTransition,
|
|
2983
|
-
validateDeviceTransition,
|
|
2984
2497
|
validateFrameShape,
|
|
2985
|
-
validateLoginChallengeTransition,
|
|
2986
|
-
validateSessionTransition,
|
|
2987
|
-
validateTickAuthTransition,
|
|
2988
|
-
validateTrustLinkTransition,
|
|
2989
2498
|
varintLength,
|
|
2990
2499
|
varintU,
|
|
2991
2500
|
verifyFrameSignature
|