arcane-os 0.3.6 → 0.4.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.
@@ -1,7 +1,7 @@
1
1
  import {analyzeRiskSignals} from './RiskSignalAnalyzer.js';
2
2
  import {canonicalNetworkHostname,emptyArcaneNetworkPolicy,findDeniedDomainRule,loadArcaneNetworkPolicy} from './ArcaneNetworkPolicy.js?v=3';
3
3
 
4
- export const scamRiskSignals=Object.freeze([
4
+ export const scamRiskSignals=[
5
5
  {id:'urgency',label:'Urgency or secrecy pressure',weight:18,pattern:/\b(urgent|immediately|act now|do not tell|keep (?:this|it) secret|stay on the line)\b/i,guidance:'Pause. A legitimate organization will let you verify independently.'},
6
6
  {id:'payment',label:'Unusual payment request',weight:32,pattern:/\b(gift cards?|bitcoin|crypto(?:currency)?|wire transfer|cash courier|payment app|prepaid cards?)\b/i,guidance:'Do not pay. Contact the organization using a trusted number.'},
7
7
  {id:'credential',label:'Credential or access request',weight:35,pattern:/\b(password|passcode|verification code|one[- ]time code|otp|remote access|screen share)\b/i,guidance:'Never share security codes or grant remote access to an unexpected contact.'},
@@ -9,20 +9,20 @@ export const scamRiskSignals=Object.freeze([
9
9
  {id:'threat',label:'Threat or fear tactic',weight:28,pattern:/\b(arrest|warrant|deport|account (?:will be )?closed|service (?:will be )?cut off|in danger|kidnapped)\b/i,guidance:'Threats are designed to prevent careful checking. Stop and contact someone you trust.'},
10
10
  {id:'prize',label:'Unexpected prize or refund',weight:20,pattern:/\b(lottery|sweepstakes|prize|inheritance|refund|you(?: have|'ve) won)\b/i,guidance:'Do not pay a fee or disclose information to receive an unexpected benefit.'},
11
11
  {id:'link',label:'Pressure to open a link',weight:16,pattern:/\b(click|tap|open|visit|follow)\b.{0,36}\b(link|url|website)\b/i,guidance:'Do not use an unexpected link. Open the official app or type a trusted address yourself.'},
12
- ]);
12
+ ];
13
13
 
14
- const blockedDomainSignal=Object.freeze({
14
+ const blockedDomainSignal={
15
15
  id:'blocked-domain',
16
16
  label:'Domain blocked by Arcane network policy',
17
17
  weight:55,
18
18
  guidance:'Do not open or contact this domain. Arcane has a system-wide safety rule blocking it.',
19
- });
19
+ };
20
20
  let activeNetworkPolicy=emptyArcaneNetworkPolicy();
21
21
  let activeNetworkPolicyLoadSequence=0;
22
22
  let nextNetworkPolicyLoadSequence=0;
23
23
 
24
24
  function candidateHostnames(value){
25
- const text=String(value??'').normalize('NFKC').slice(0,20_000),hostnames=new Set();
25
+ const text=String(value??'').normalize('NFKC'),hostnames=new Set();
26
26
  const add=value=>{
27
27
  const candidate=String(value).replace(/^[([{<'"]+|[\])}>'",.;!?]+$/g,'');
28
28
  try{
@@ -46,13 +46,14 @@ export async function loadScamNetworkPolicy(options){
46
46
  return networkPolicy;
47
47
  }
48
48
 
49
- export function assessScamRisk(text,{networkPolicy=activeNetworkPolicy}={}){
49
+ export function assessScamRisk(text,{networkPolicy=activeNetworkPolicy,secure=false}={}){
50
50
  const result=analyzeRiskSignals(text,{signals:scamRiskSignals});
51
+ if(secure!==true)return result;
51
52
  let blocked=false;
52
53
  for(const hostname of candidateHostnames(text)){if(findDeniedDomainRule(networkPolicy,hostname)){blocked=true;break;}}
53
54
  if(!blocked)return result;
54
55
  const score=Math.min(100,result.score+blockedDomainSignal.weight);
55
- return Object.freeze({...result,score,level:levelForScore(score),matches:Object.freeze([...result.matches,blockedDomainSignal])});
56
+ return {...result,score,level:levelForScore(score),matches:[...result.matches,blockedDomainSignal]};
56
57
  }
57
58
 
58
59
  export function scamSafetyGuidance(result){
@@ -6,7 +6,6 @@ export const IMPORT_MAP_RELATIVE_PATH='modules/arcane.importmap.json';
6
6
  export const MANAGED_IMPORT_MAP_ATTRIBUTE='data-arcane-import-map';
7
7
 
8
8
  const JAVASCRIPT_EXTENSION=/\.(?:js|mjs)$/u;
9
- const NODE_ONLY_MODULE='modules/CaseEvidenceIndexer.js';
10
9
  const PERSISTENT_CHAT_IMPORT='#arcane/persistent-ai-chat-session';
11
10
  const PERSISTENT_CHAT_MODULE='modules/PersistentAIChatSession.js';
12
11
  const SDK_BROWSER_ENTRY='sdk/event-manager.mjs';
@@ -808,13 +807,8 @@ export async function buildImportMap({files,signal}={}){
808
807
  &&JAVASCRIPT_EXTENSION.test(relative))
809
808
  .sort(compareText);
810
809
  const namedRegistry=new Map();
811
- const excludedModules=[];
812
810
  for(const relative of modules){
813
811
  throwIfAborted(signal);
814
- if(relative===NODE_ONLY_MODULE){
815
- excludedModules.push(relative);
816
- continue;
817
- }
818
812
  const name=path.posix.basename(relative).replace(JAVASCRIPT_EXTENSION,'');
819
813
  registerSpecifier(namedRegistry,`arcane/${name}`,`./arcane/${relative}`);
820
814
  }
@@ -870,7 +864,7 @@ export async function buildImportMap({files,signal}={}){
870
864
  }
871
865
  return {
872
866
  imports,
873
- excludedModules:excludedModules.sort(compareText)
867
+ excludedModules:[]
874
868
  };
875
869
  }
876
870