@jodetx_dev/secureshield-web 0.0.0-stage โ†’ 4.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.
@@ -0,0 +1,595 @@
1
+ # ๐Ÿ›ก๏ธ SecureShield Web SDK โ€” Universal Integration Guide
2
+
3
+ > **Enterprise Zero-Trust Client Runtime Defense**
4
+ > Compatible with **ANY version** of Angular, React, Next.js, Vue, Nuxt, Svelte, Remix, Solid, Astro, Blazor, and Vanilla JavaScript.
5
+
6
+ ---
7
+
8
+ ## ๐ŸŒ Universal Framework Compatibility Guarantee
9
+
10
+ SecureShield Web SDK (`@secureshield/web`) is compiled into clean, self-contained ECMAScript Modules (ESM), Universal Browser IIFE scripts, and an AST-Hardened Enterprise Edition.
11
+ * **Zero Runtime Dependencies**: The SDK has `0` external npm dependencies. It will **never** cause peer-dependency conflicts with your framework, bundler, or package manager.
12
+ * **Forward & Backward Compatible**: Whether your project runs on legacy builds or next-generation compilers, SecureShield integrates seamlessly.
13
+
14
+ | Framework | Supported Versions | Architectural Patterns Supported |
15
+ | :--- | :--- | :--- |
16
+ | **Angular** | **Angular 2 through 22+ (All versions & future releases)** | Modern Standalone (`provideAppInitializer`, Signals) & Classic NgModule (`APP_INITIALIZER`, RxJS) |
17
+ | **React** | **React 15 through 19+ (All versions & future releases)** | Modern Hooks (`useContext`, `useEffect`, React Compiler) & Legacy Class Components (`HOC`) |
18
+ | **Next.js** | **Next.js 9 through 15+ (App Router & Pages Router)** | Modern App Router (`'use client'`, `app/layout.tsx`) & Classic Pages Router (`pages/_app.tsx`) |
19
+ | **Vue.js** | **Vue 2.0 through Vue 3.5+** | Vue 3 Composition API (`ref`, `<script setup>`) & Vue 2 Options API (`Vue.prototype`) |
20
+ | **Nuxt** | **Nuxt 2 & Nuxt 3+** | Nuxt 3 Nitro Client Plugins (`.client.ts`) & Nuxt 2 Client Plugins |
21
+ | **Svelte** | **Svelte 3, 4, and Svelte 5+** | Svelte 5 Runes (`$state`), SvelteKit & Classic Svelte Stores |
22
+ | **Vite / Webpack** | **Vite 2 through 6+, Webpack 4 & 5, Turbopack, Rollup, esbuild, Bun** | Native ESM imports, resolve aliases, and bundled single-file formats |
23
+ | **Vanilla Web** | **HTML5 / ES5 / ES6+** | Single-script `<script src="secureshield.js">` or `<script src="secureshield.hardened.js">` with Subresource Integrity (SRI) |
24
+
25
+ ---
26
+
27
+ ## ๐Ÿ“ฆ What's Inside the Release ZIP
28
+
29
+ When you extract `SecureShield_Web_SDK_Release.zip`, you get a complete, self-contained distribution package:
30
+
31
+ ```
32
+ SecureShield_Web_SDK_Release/
33
+ โ”œโ”€โ”€ package.json <-- ๐Ÿ“ฆ NPM package descriptor (@secureshield/web)
34
+ โ”œโ”€โ”€ index.js <-- ๐Ÿš€ Primary ESM entry point
35
+ โ”œโ”€โ”€ index.d.ts <-- ๐Ÿ“˜ TypeScript definitions (interfaces, types, configs)
36
+ โ”œโ”€โ”€ secureshield.js <-- ๐Ÿ›ก๏ธ Option A: Drop-in IIFE for classic <script src="secureshield.js"> tags
37
+ โ”œโ”€โ”€ secureshield.iife.js <-- ๐Ÿ“ฆ Option A: Standalone IIFE build
38
+ โ”œโ”€โ”€ secureshield.esm.js <-- โšก Option A: Standalone ES Module build
39
+ โ”œโ”€โ”€ secureshield.hardened.js <-- ๐Ÿ›ก๏ธ Option B: Hardened AST-Obfuscated IIFE (drop-in <script> compatible)
40
+ โ”œโ”€โ”€ secureshield.wasm.js <-- ๐Ÿ›ก๏ธ Option B: Drop-in alias for secureshield.hardened.js
41
+ โ”œโ”€โ”€ secureshield.hardened.esm.js <-- โšก Option B: Hardened AST-Obfuscated ES Module
42
+ โ”œโ”€โ”€ secureshield.js.sha256 <-- ๐Ÿ”’ Published SHA-256 Checksum (Option A Drop-in)
43
+ โ”œโ”€โ”€ secureshield.js.sri <-- ๐Ÿ›ก๏ธ Subresource Integrity (SRI) Hash for <script> tags
44
+ โ”œโ”€โ”€ secureshield.esm.js.sha256 <-- ๐Ÿ”’ Published SHA-256 Checksum (Option A ESM)
45
+ โ”œโ”€โ”€ secureshield.esm.js.sri <-- ๐Ÿ›ก๏ธ Subresource Integrity (SRI) Hash (Option A ESM)
46
+ โ”œโ”€โ”€ secureshield.iife.js.sha256<-- ๐Ÿ”’ Published SHA-256 Checksum (Option A IIFE)
47
+ โ”œโ”€โ”€ secureshield.iife.js.sri <-- ๐Ÿ›ก๏ธ Subresource Integrity (SRI) Hash (Option A IIFE)
48
+ โ”œโ”€โ”€ secureshield.hardened.js.sha256 <-- ๐Ÿ”’ Published SHA-256 Checksum (Option B Hardened)
49
+ โ”œโ”€โ”€ secureshield.hardened.js.sri <-- ๐Ÿ›ก๏ธ Subresource Integrity (SRI) Hash (Option B Hardened)
50
+ โ”œโ”€โ”€ secureshield.wasm.js.sha256<-- ๐Ÿ”’ Published SHA-256 Checksum (Option B alias)
51
+ โ”œโ”€โ”€ secureshield.wasm.js.sri <-- ๐Ÿ›ก๏ธ Subresource Integrity (SRI) Hash for <script> tags
52
+ โ”œโ”€โ”€ SECURESHIELD_WEB_SDK_SPECIFICATION.md <-- ๐Ÿ“‘ Technical Specification
53
+ โ”œโ”€โ”€ INTEGRATION_GUIDE.md <-- ๐Ÿ“– This Guide
54
+ โ””โ”€โ”€ README.md <-- ๐Ÿ“‹ Quick Overview
55
+ ```
56
+
57
+ ### ๐Ÿงช Independent Verification Kit (`SecureShield_Verification_Kit.zip`)
58
+
59
+ For security auditors and enterprise compliance teams requiring independent verification of the test suite and benchmark execution against compiled bundles:
60
+ - **Download**: [`SecureShield_Verification_Kit.zip`](/downloads/SecureShield_Verification_Kit.zip)
61
+ - **Published SHA-256**: `61129e02f00c24018900587d0de75d04ee4b52006fb93324bd6bb2042ce14025`
62
+ - **Execution**: Zero-dependency air-gapped test runner (`npm test`) and latency benchmark (`npm run benchmark`).
63
+
64
+ ---
65
+
66
+ ## ๐Ÿš€ Quick Setup: Extract & Install in 2 Minutes
67
+
68
+ ### Step 1: Extract into your project
69
+ Extract the ZIP archive directly into your project's source tree (recommended location: `src/secureshield-sdk/`):
70
+
71
+ ```
72
+ my-project/
73
+ โ”œโ”€โ”€ src/
74
+ โ”‚ โ”œโ”€โ”€ secureshield-sdk/
75
+ โ”‚ โ”‚ โ”œโ”€โ”€ package.json <-- Ensure this is directly inside src/secureshield-sdk/
76
+ โ”‚ โ”‚ โ”œโ”€โ”€ index.js
77
+ โ”‚ โ”‚ โ”œโ”€โ”€ index.d.ts
78
+ โ”‚ โ”‚ โ”œโ”€โ”€ secureshield.js
79
+ โ”‚ โ”‚ โ””โ”€โ”€ secureshield.wasm.js
80
+ ```
81
+ > [!IMPORTANT]
82
+ > If Windows *"Extract All..."* created an extra folder named `SecureShield_Web_SDK_Release`, move the files out so that `package.json` is located directly at `src/secureshield-sdk/package.json`.
83
+
84
+ ### Step 2: Link the SDK package
85
+ In your project terminal root, run:
86
+
87
+ ```bash
88
+ npm install ./src/secureshield-sdk
89
+ ```
90
+ *(Or for Yarn: `yarn add file:./src/secureshield-sdk` | PNPM: `pnpm add ./src/secureshield-sdk` | Bun: `bun add ./src/secureshield-sdk`)*
91
+
92
+ Alternatively, add it directly to your `package.json`:
93
+ ```json
94
+ {
95
+ "dependencies": {
96
+ "@secureshield/web": "file:src/secureshield-sdk"
97
+ }
98
+ }
99
+ ```
100
+
101
+ ---
102
+
103
+ ## ๐Ÿ…ฐ๏ธ 1. Angular Integration (Universal: Any Version)
104
+
105
+ ### Pattern A: Modern Standalone & Signals (Angular 17, 18, 19, 20, 21, 22+ and Future)
106
+
107
+ #### 1. Security Service (`src/app/services/secureshield.service.ts`):
108
+ ```typescript
109
+ import { Injectable, signal, inject, PLATFORM_ID } from '@angular/core';
110
+ import { isPlatformBrowser } from '@angular/common';
111
+ import { SecureShield, SecurityAuditReport } from '@secureshield/web';
112
+
113
+ @Injectable({
114
+ providedIn: 'root'
115
+ })
116
+ export class SecureShieldService {
117
+ private platformId = inject(PLATFORM_ID);
118
+ private sdkInstance: any = null;
119
+
120
+ // ๐Ÿšฆ Reactive Signals for UI bindings
121
+ public isShieldActive = signal<boolean>(false);
122
+ public trustScore = signal<number>(100);
123
+ public lastReport = signal<SecurityAuditReport | null>(null);
124
+
125
+ async initSecureShield(): Promise<void> {
126
+ // ๐Ÿ›ก๏ธ SSR Safety Guard
127
+ if (!isPlatformBrowser(this.platformId)) return;
128
+ if (this.sdkInstance) return;
129
+
130
+ try {
131
+ this.sdkInstance = await SecureShield.init({
132
+ tenantId: 'YOUR_TENANT_ID',
133
+ appId: 'YOUR_APP_ID',
134
+ serverUrl: 'https://security.yourcompany.com/api/v1/telemetry/ingest',
135
+ environment: 'production',
136
+ enableRuntimeIntegrityWatchdog: true,
137
+ enablePrototypeFreezing: false,
138
+ enableStorageLeakScrubber: true,
139
+ enableTabBlurShield: false,
140
+ onTamperDetected: (apiName: string, reason?: string) => {
141
+ console.warn(`[SecureShield Tamper Alert] ${apiName}: ${reason}`);
142
+ }
143
+ });
144
+
145
+ // Evaluate security state in background without stalling main render
146
+ setTimeout(async () => {
147
+ try {
148
+ const report = await this.sdkInstance.evaluateSecurityState();
149
+ this.lastReport.set(report);
150
+ this.trustScore.set(report.trustScore ?? 100);
151
+ this.isShieldActive.set(true);
152
+ } catch (e) {
153
+ console.warn('[SecureShield] Scan notice:', e);
154
+ }
155
+ }, 50);
156
+ } catch (error) {
157
+ console.error('[SecureShield] Initialization error:', error);
158
+ }
159
+ }
160
+
161
+ public isCleanForTransaction(): boolean {
162
+ return this.isShieldActive() && this.trustScore() >= 60;
163
+ }
164
+ }
165
+ ```
166
+
167
+ #### 2. App Initializer Bootloader (`src/app/app.config.ts`):
168
+ ```typescript
169
+ import { ApplicationConfig, provideZonelessChangeDetection, provideAppInitializer, inject } from '@angular/core';
170
+ import { provideRouter } from '@angular/router';
171
+ import { routes } from './app.routes';
172
+ import { SecureShieldService } from './services/secureshield.service';
173
+
174
+ export const appConfig: ApplicationConfig = {
175
+ providers: [
176
+ provideRouter(routes),
177
+ // ๐Ÿ›ก๏ธ Non-blocking startup hook (Angular 19, 20, 21, 22+)
178
+ provideAppInitializer(() => {
179
+ const shield = inject(SecureShieldService);
180
+ shield.initSecureShield().catch(err => console.warn('[SecureShield] Startup notice:', err));
181
+ return Promise.resolve(true); // Renders UI immediately in 0ms
182
+ })
183
+ ]
184
+ };
185
+ ```
186
+ *(For Angular 17 & 18 using `APP_INITIALIZER`: provide `{ provide: APP_INITIALIZER, useFactory: (s) => () => s.initSecureShield(), deps: [SecureShieldService], multi: true }`)*
187
+
188
+ #### 3. Functional Route Security Guard (`src/app/guards/security.guard.ts`):
189
+ ```typescript
190
+ import { inject } from '@angular/core';
191
+ import { CanActivateFn, Router } from '@angular/router';
192
+ import { SecureShieldService } from '../services/secureshield.service';
193
+
194
+ export const securityGuard: CanActivateFn = async (route, state) => {
195
+ const shield = inject(SecureShieldService);
196
+ const router = inject(Router);
197
+
198
+ if (shield.isShieldActive() && !shield.isCleanForTransaction()) {
199
+ console.warn('[SecureShield Guard] Compromised environment โ€” route blocked');
200
+ return router.parseUrl('/security-lockout');
201
+ }
202
+ return true;
203
+ };
204
+ ```
205
+
206
+ ---
207
+
208
+ ### Pattern B: Classic NgModule & RxJS (Angular 2 through 16)
209
+
210
+ #### 1. Module Provider (`src/app/app.module.ts`):
211
+ ```typescript
212
+ import { NgModule, APP_INITIALIZER } from '@angular/core';
213
+ import { BrowserModule } from '@angular/platform-browser';
214
+ import { AppComponent } from './app.component';
215
+ import { SecureShieldService } from './services/secureshield.service';
216
+
217
+ export function initSecurityFactory(shield: SecureShieldService) {
218
+ return () => shield.initSecureShield();
219
+ }
220
+
221
+ @NgModule({
222
+ declarations: [AppComponent],
223
+ imports: [BrowserModule],
224
+ providers: [
225
+ SecureShieldService,
226
+ {
227
+ provide: APP_INITIALIZER,
228
+ useFactory: initSecurityFactory,
229
+ deps: [SecureShieldService],
230
+ multi: true
231
+ }
232
+ ],
233
+ bootstrap: [AppComponent]
234
+ })
235
+ export class AppModule {}
236
+ ```
237
+
238
+ ---
239
+
240
+ ## โš›๏ธ 2. React Integration (Universal: React 15 โ†’ 19+)
241
+
242
+ ### Modern Pattern: Functional Components & Hooks (`src/providers/SecurityProvider.tsx`)
243
+ *Compatible with React 16.8, 17, 18, 19+, Vite, Next.js, CRA, Remix, and React Compiler:*
244
+
245
+ ```tsx
246
+ import React, { createContext, useContext, useEffect, useState } from 'react';
247
+ import { SecureShield, SecurityAuditReport } from '@secureshield/web';
248
+
249
+ interface SecurityContextType {
250
+ isShieldActive: boolean;
251
+ trustScore: number;
252
+ report: SecurityAuditReport | null;
253
+ shield: any;
254
+ }
255
+
256
+ const SecurityContext = createContext<SecurityContextType>({
257
+ isShieldActive: false,
258
+ trustScore: 100,
259
+ report: null,
260
+ shield: null
261
+ });
262
+
263
+ export function SecurityProvider({ children }: { children: React.ReactNode }) {
264
+ const [isShieldActive, setIsShieldActive] = useState(false);
265
+ const [trustScore, setTrustScore] = useState(100);
266
+ const [report, setReport] = useState<SecurityAuditReport | null>(null);
267
+ const [shield, setShield] = useState<any>(null);
268
+
269
+ useEffect(() => {
270
+ async function boot() {
271
+ try {
272
+ const instance = await SecureShield.init({
273
+ tenantId: 'YOUR_TENANT_ID',
274
+ appId: 'YOUR_APP_ID',
275
+ serverUrl: 'https://security.yourcompany.com/api/v1/telemetry/ingest',
276
+ environment: 'production',
277
+ enableRuntimeIntegrityWatchdog: true
278
+ });
279
+
280
+ setShield(instance);
281
+ const evalReport = await instance.evaluateSecurityState();
282
+ setReport(evalReport);
283
+ setTrustScore(evalReport.trustScore ?? 100);
284
+ setIsShieldActive(true);
285
+ } catch (err) {
286
+ console.error('[SecureShield] Boot failure:', err);
287
+ }
288
+ }
289
+ boot();
290
+ }, []);
291
+
292
+ return (
293
+ <SecurityContext.Provider value={{ isShieldActive, trustScore, report, shield }}>
294
+ {children}
295
+ </SecurityContext.Provider>
296
+ );
297
+ }
298
+
299
+ export const useSecurity = () => useContext(SecurityContext);
300
+ ```
301
+
302
+ Wrap your root element in `src/App.tsx` or `src/main.tsx`:
303
+ ```tsx
304
+ export function App() {
305
+ return (
306
+ <SecurityProvider>
307
+ <MainDashboard />
308
+ </SecurityProvider>
309
+ );
310
+ }
311
+ ```
312
+
313
+ ---
314
+
315
+ ## โšก 3. Next.js Integration (Universal: Next.js 9 โ†’ 15+)
316
+
317
+ ### App Router (Next.js 13, 14, 15+ / React 18 & 19)
318
+
319
+ #### 1. Configure `next.config.mjs`:
320
+ ```javascript
321
+ /** @type {import('next').NextConfig} */
322
+ const nextConfig = {
323
+ transpilePackages: ['@secureshield/web'],
324
+ webpack: (config, { isServer }) => {
325
+ if (!isServer) {
326
+ config.resolve.fallback = { ...config.resolve.fallback, fs: false, crypto: false };
327
+ }
328
+ return config;
329
+ }
330
+ };
331
+ export default nextConfig;
332
+ ```
333
+
334
+ #### 2. Create Client Boundary (`src/app/providers/SecurityProvider.tsx`):
335
+ ```tsx
336
+ 'use client';
337
+
338
+ import React from 'react';
339
+ import { SecurityProvider } from './SecurityContext';
340
+
341
+ export function NextSecurityProvider({ children }: { children: React.ReactNode }) {
342
+ return <SecurityProvider>{children}</SecurityProvider>;
343
+ }
344
+ ```
345
+
346
+ #### 3. Root Layout (`src/app/layout.tsx`):
347
+ ```tsx
348
+ import { NextSecurityProvider } from './providers/SecurityProvider';
349
+
350
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
351
+ return (
352
+ <html lang="en">
353
+ <body>
354
+ <NextSecurityProvider>
355
+ {children}
356
+ </NextSecurityProvider>
357
+ </body>
358
+ </html>
359
+ );
360
+ }
361
+ ```
362
+
363
+ ### Pages Router (Next.js 9 through 15+)
364
+ In `pages/_app.tsx`:
365
+ ```tsx
366
+ import type { AppProps } from 'next/app';
367
+ import { SecurityProvider } from '../src/providers/SecurityProvider';
368
+
369
+ export default function MyApp({ Component, pageProps }: AppProps) {
370
+ return (
371
+ <SecurityProvider>
372
+ <Component {...pageProps} />
373
+ </SecurityProvider>
374
+ );
375
+ }
376
+ ```
377
+
378
+ ---
379
+
380
+ ## ๐ŸŸข 4. Vue.js & Nuxt Integration (Universal: Vue 2 & 3+, Nuxt 2 & 3+)
381
+
382
+ ### Vue 3 Composition API (`src/plugins/secureshield.ts`):
383
+ ```typescript
384
+ import { App, ref } from 'vue';
385
+ import { SecureShield } from '@secureshield/web';
386
+
387
+ export const isShieldActive = ref(false);
388
+ export const trustScore = ref(100);
389
+
390
+ export const SecureShieldPlugin = {
391
+ async install(app: App) {
392
+ if (typeof window === 'undefined') return; // SSR Guard
393
+ try {
394
+ const sdk = await SecureShield.init({
395
+ headerKey: 'YOUR_HEADER_KEY',
396
+ encryptionKey: 'YOUR_ENCRYPTION_KEY',
397
+ initializationKey: 'YOUR_INIT_KEY',
398
+ tenantId: 'YOUR_TENANT_ID',
399
+ appId: 'YOUR_APP_ID',
400
+ serverUrl: 'https://security.yourcompany.com/api/v1/telemetry/ingest'
401
+ });
402
+
403
+ const report = await sdk.evaluateSecurityState();
404
+ trustScore.value = report.trustScore ?? 100;
405
+ isShieldActive.value = true;
406
+ } catch (e) {
407
+ console.error('[SecureShield Vue Plugin] Error:', e);
408
+ }
409
+ }
410
+ };
411
+ ```
412
+
413
+ Mount in `src/main.ts`:
414
+ ```typescript
415
+ import { createApp } from 'vue';
416
+ import App from './App.vue';
417
+ import { SecureShieldPlugin } from './plugins/secureshield';
418
+
419
+ const app = createApp(App);
420
+ app.use(SecureShieldPlugin);
421
+ app.mount('#app');
422
+ ```
423
+
424
+ ---
425
+
426
+ ## ๐ŸŒ 5. Vanilla HTML / JavaScript with Subresource Integrity (SRI)
427
+
428
+ For websites without bundlers or package managers:
429
+
430
+ ```html
431
+ <!DOCTYPE html>
432
+ <html lang="en">
433
+ <head>
434
+ <meta charset="UTF-8">
435
+ <title>Secured Banking Portal</title>
436
+
437
+ <!-- Load SecureShield with SRI Hash Verification -->
438
+ <script
439
+ src="./secureshield.js"
440
+ integrity="sha384-01wWPFe5yTKeRD+REEsyC1+DsSbLaVqCdxcvB0hATty8z3cEN4wpczfO3rK049qL"
441
+ crossorigin="anonymous">
442
+ </script>
443
+ </head>
444
+ <body>
445
+ <h1>Secure Dashboard</h1>
446
+ <script>
447
+ window.addEventListener('DOMContentLoaded', async () => {
448
+ const sdk = await window.SecureShield.init({
449
+ tenantId: 'YOUR_TENANT_ID',
450
+ appId: 'YOUR_APP_ID',
451
+ serverUrl: 'https://security.yourcompany.com/api/v1/telemetry/ingest'
452
+ });
453
+ const verdict = await sdk.evaluateSecurityState();
454
+ console.log('SecureShield Status:', verdict.verdict, 'Trust Score:', verdict.trustScore);
455
+ });
456
+ </script>
457
+ </body>
458
+ </html>
459
+ ```
460
+
461
+ ---
462
+
463
+ ## ๐Ÿ› ๏ธ Build Tooling & Version Troubleshooting Guide
464
+
465
+ ### Issue 1: Angular Build Version Mismatch
466
+ **Error**:
467
+ ```
468
+ Error: The current version of "@angular/build" supports Angular versions ^21.0.0,
469
+ but detected Angular version 22.1.6 instead.
470
+ ```
471
+ **Cause**: In Angular CLI, `@angular-devkit/build-angular` or `@angular/build` major version must match `@angular/core`.
472
+ **Fix**: Install the matching build package for your Angular version:
473
+ ```bash
474
+ npm install --save-dev @angular-devkit/build-angular@^<YOUR_ANGULAR_MAJOR>.0.0 @angular/build@^<YOUR_ANGULAR_MAJOR>.0.0
475
+ ```
476
+
477
+ ### Issue 2: NPM `ENOENT: no such file or directory, open '...package.json'`
478
+ **Cause**: When unzipping using Windows *"Extract All..."*, the files were placed inside an extra nested folder (e.g. `src/secureshield-sdk/SecureShield_Web_SDK_Release/package.json`).
479
+ **Fix**: Ensure all files are placed directly in `src/secureshield-sdk/` so `src/secureshield-sdk/package.json` exists, then re-run `npm install ./src/secureshield-sdk`.
480
+
481
+ ### Issue 3: Vite `Failed to resolve import "@secureshield/web"`
482
+ **Fix**: Add an alias in `vite.config.ts`:
483
+ ```typescript
484
+ import { fileURLToPath, URL } from 'node:url';
485
+
486
+ export default defineConfig({
487
+ resolve: {
488
+ alias: {
489
+ '@secureshield/web': fileURLToPath(new URL('./src/secureshield-sdk', import.meta.url))
490
+ }
491
+ }
492
+ });
493
+ ```
494
+
495
+ ### Issue 4: SSR / Hydration Mismatch
496
+ **Fix**: Wrap initialization in browser guards (`isPlatformBrowser(this.platformId)` in Angular, `typeof window !== 'undefined'` in React/Vue/Svelte/Next.js).
497
+
498
+ ### Issue 5: Local Development Tunnel (ngrok) Interstitial Warning Page
499
+ **Cause**: Free ngrok tunnels (`*.ngrok-free.dev` or `*.ngrok.app`) serve an HTML interstitial warning page on initial browser requests that lack the `ngrok-skip-browser-warning` header or bypass query parameter. Because production SDK releases do not attach non-standard tunneling headers to outbound HTTP requests, initial SDK handshake or telemetry requests routed to a free ngrok URL will receive an HTML warning page resulting in JSON parse errors.
500
+ **Fix**: When developing locally using free ngrok tunnels, use one of the following methods:
501
+ 1. Open the ngrok tunnel URL once in your browser and click **Visit Site** to set the bypass cookie for your browser session; or
502
+ 2. Upgrade to a paid ngrok account / custom domain which does not inject the interstitial page; or
503
+ 3. Append `?ngrok-skip-browser-warning=true` to your local development `serverUrl` endpoint (e.g. `serverUrl: 'https://<subdomain>.ngrok-free.dev/api/v1/telemetry/ingest?ngrok-skip-browser-warning=true'`).
504
+
505
+ ---
506
+
507
+ ## ๐Ÿ”’ Configuration Reference
508
+
509
+ | Option | Type | Default | Description |
510
+ |---|---|---|---|
511
+ | `headerKey` | `string` | Optional | Base64-encoded primary header cryptographic attestation key (legacy envelope auth). |
512
+ | `encryptionKey` | `string` | Optional | AES-256 telemetry payload encryption key. |
513
+ | `initializationKey` | `string` | Optional | Handshake signature authentication token. |
514
+ | `tenantId` | `string` | **Required** | Tenant UUID registered in your SecureShield portal. |
515
+ | `appId` | `string` | **Required** | Unique Application Identifier registered in your tenant portal. |
516
+ | `serverUrl` | `string` | **Required** | Portal telemetry ingestion gateway endpoint (required in `production` and `staging`). |
517
+ | `environment` | `'production' \| 'staging' \| 'development'` | `'production'` | Operational security policy environment (defaults to `'production'` fail-closed). |
518
+ | `enablePrototypeFreezing` | `boolean` | `false` | When enabled, freezes built-in ECMAScript prototypes against tampering. Note: Prototype freezing is irreversible for the session once invoked, even if initialization fails. |
519
+ | `enableRuntimeIntegrityWatchdog` | `boolean` | `true` | Real-time prototype tamper and hook interceptor. |
520
+ | `enableStorageLeakScrubber` | `boolean` | `true` | Scans and purges exposed tokens from `localStorage`/`sessionStorage`. |
521
+ | `enableTabBlurShield` | `boolean` | `false` | Automatically blurs sensitive content when the browser tab loses focus. |
522
+ | `onTamperDetected` | `Function` | `undefined` | Callback invoked immediately when memory/DOM/prototype tampering is detected. |
523
+ | `onRemediationTriggered` | `Function` | `undefined` | Callback invoked when server security remediation actions are executed. |
524
+
525
+ ---
526
+
527
+ ### โš ๏ธ Synchronous Configuration Validation & Error Handling (N-7)
528
+
529
+ Both `new SecureShield(config)` and `SecureShield.init(config)` perform synchronous validation before initiating any asynchronous network requests. If any parameter is invalid (e.g. unrecognized `environment` string, or missing `serverUrl` in `production` mode), the SDK throws a synchronous `[SecureShield Configuration Error]`.
530
+
531
+ Always wrap initialization in a `try...catch` block:
532
+
533
+ ```typescript
534
+ try {
535
+ const sdk = await SecureShield.init({
536
+ tenantId: 'TEN-ENTERPRISE-01',
537
+ appId: 'my_app',
538
+ serverUrl: 'https://security.example.com/api/v1/telemetry/ingest',
539
+ environment: 'production'
540
+ });
541
+ } catch (error) {
542
+ console.error('[SecureShield] Configuration or initialization error:', error);
543
+ }
544
+ ```
545
+
546
+ > [!NOTE]
547
+ > When `enablePrototypeFreezing: true` is configured, ECMAScript prototypes are sealed immediately during the initialization pipeline to prevent malicious scripts from modifying built-ins. Once applied, prototype freezing remains permanent for the lifetime of the browser session regardless of whether the backend handshake succeeds or encounters a network failure.
548
+
549
+ ### ๐Ÿ›‘ Runtime Pause State & Anti-Tamper Security (`setPaused`) (Finding R3-003)
550
+
551
+ Direct invocation of `sdk.setPaused(boolean)` is restricted exclusively to local debugging in `'development'` mode.
552
+ - In `production` or `staging`, calling `setPaused()` throws `[SecureShield Security Error] setPaused() is restricted in '<environment>'.` fail-closed to prevent client-side bypass of RASP threat detection.
553
+ - In `development`, calling `setPaused()` emits `[SecureShield Deprecation] setPaused() is deprecated.`
554
+ - To pause threat detection in production or staging, operators must issue server-signed Over-The-Air (OTA) remediation directives via the SecureShield portal (`signed_remediation` with ES256 cryptographic envelope).
555
+
556
+ ### ๐Ÿ”‘ Cryptographic Policy & Offline Lease Verification (N-13 & N-3)
557
+
558
+ SecureShield enforces hardware-grade WebCrypto cryptographic verification for all dynamic policies and offline leases:
559
+ - **JWS Detached Envelopes**: All policies and leases are delivered inside JWS detached envelopes (`alg: "ES256"`, ECDSA P-256).
560
+ - **Separated Key Architecture (G-N3-1, RO-1)**: Policy signing and offline lease signing employ independent cryptographic keypairs:
561
+ - Policy signing key ID: `secureshield_policy_p256_v3` (`typ: "secureshield-policy+jwt"`).
562
+ - Offline lease signing key ID: `secureshield_lease_p256_v3` (`typ: "secureshield-lease+jwt"`).
563
+ - *Legacy Key Revocation*: Compromised `v1` and `v2` keys are strictly revoked and rejected fail-closed in `production`.
564
+ Cross-envelope validation attempts fail immediately.
565
+ - **Clock Skew Compensation & Reload Persistence (NI-3, G-N13-7)**: Server-provided timestamps calibrate the client clock with an asymmetric clamp of `[-300s, +3600s]` (+1 hour allowance for slow client device clocks, and -300s clamp to prevent expired replay via forged server time), persisted in `localStorage` across reloads to prevent expired envelope replay.
566
+ - **Monotonic Anti-Replay (G-N13-6, NI-6)**: The SDK retains `#lastPolicyTimestamp` monotonically throughout the browser lifecycle (including across `clearSession()`), rejecting replayed configurations with earlier timestamps.
567
+ - **Offline Grace Lease Security (N-3, G-N3-8)**:
568
+ - All legacy unsigned leases are revoked fail-closed.
569
+ - Server leases default to 24-hour expiration (`exp = iat + 86400s`), capped at a maximum of 7 days client-side.
570
+ - Encrypted at rest using non-exportable WebCrypto AES-GCM 256 keys in IndexedDB with graceful in-memory fallback upon storage quota rejection (`QuotaExceededError`).
571
+ - Monotonic clock check includes a 60-second backward NTP skew tolerance (`NI-4`).
572
+ - Explicit session termination via `sdk.clearSession()`, `sdk.logout()`, or `sdk.revokeSession()` wipes both the IndexedDB lease vault and volatile `sessionStorage` while retaining monotonic policy timestamps to prevent replay (`G-N3-7`).
573
+
574
+ ### ๐Ÿ›ก๏ธ Client-Side DOM Lockout Overlay Defense-in-Depth Disclaimer (N-9, RO-7, G-N9-3, G-N9-2)
575
+
576
+ The `SecurityLockoutOverlay` provides active defense-in-depth UI friction against interactive tampering and unauthorized screen interaction during security lockouts:
577
+ - **Active Tamper Watchdogs**: `MutationObserver` instances continuously monitor the DOM, tracking child removals and attribute/style modifications on `document.documentElement` and `document.body` (e.g. attempting to hide the lockout with `opacity: 0`, `visibility: hidden`, or `display: none`). Any suppression attempt triggers immediate automated restoration and re-mounting.
578
+ - **Client-Side Friction Limitation**: Client-side DOM lockout overlays are designed to impede interactive attackers; they do not form an impenetrable security boundary against an adversary who has complete control over browser DevTools or runs unauthorized browser extensions.
579
+ - **Definitive Security Enforcement**: Absolute lockout enforcement relies on the cryptographic purge performed by `RemediationManager.wipeLocalKeys()`, which purges non-exportable IndexedDB lease keys, session tokens, and cached credentials, coupled with server-side session revocation on the SecureShield gateway.
580
+
581
+ ### ๐ŸŒ Supported Browser Matrix & ES2020 Runtime Baseline (NI-8)
582
+
583
+ The SecureShield Web SDK requires native ECMAScript 2020 (ES2020) language and runtime capabilities. Specifically, the SDK relies on native ECMAScript private class fields (`#privateField`), standard WebCrypto API (`crypto.subtle`), and IndexedDB:
584
+
585
+ | Browser | Minimum Version | Platform Support | Status |
586
+ | :--- | :--- | :--- | :--- |
587
+ | **Google Chrome / Chromium** | **74+** | Windows, macOS, Linux, Android | Fully Supported |
588
+ | **Mozilla Firefox** | **90+** | Windows, macOS, Linux, Android | Fully Supported |
589
+ | **Apple Safari** | **14.1+** | macOS, iOS, iPadOS | Fully Supported |
590
+ | **Microsoft Edge** | **79+** | Windows, macOS | Fully Supported |
591
+
592
+ > [!WARNING]
593
+ > Legacy browsers lacking support for ES2020 private class fields (e.g. Internet Explorer 11, legacy Edge < 79, Chrome < 74, Safari < 14.1) will fail during script parsing and are not supported. If legacy enterprise browser support is mandated, application build pipelines must transpile dependencies via Babel or SWC with private-field transforms enabled.
594
+
595
+
package/LICENSE ADDED
@@ -0,0 +1,36 @@
1
+ SECURESHIELD COMMERCIAL SOFTWARE LICENSE AGREEMENT
2
+ ==================================================
3
+
4
+ Notice to Users: This software is proprietary and confidential commercial software.
5
+ Copyright (c) 2026 SecureShield Enterprise. All Rights Reserved.
6
+
7
+ 1. GRANT OF LICENSE
8
+ Subject to the terms and conditions of an active Enterprise Master Services Agreement
9
+ ("MSA") or commercial software license subscription with SecureShield, you are granted
10
+ a non-exclusive, non-transferable, revocable license to incorporate the compiled client
11
+ SDK files into your web applications solely for the purpose of communicating with
12
+ authorized SecureShield backend gateways and services.
13
+
14
+ 2. RESTRICTIONS
15
+ Except as expressly permitted by your commercial license agreement, you shall not:
16
+ (a) Reverse engineer, decompile, decrypt, disassemble, or derive the source code
17
+ of this SDK or any of its detection algorithms;
18
+ (b) Sub-license, resell, rent, lease, or distribute standalone SDK binaries;
19
+ (c) Modify, adapt, translate, or create derivative works of the SDK;
20
+ (d) Remove, alter, or obscure any proprietary copyright notices, credentials,
21
+ or identification marks affixed to or contained within the SDK;
22
+ (e) Bypass, disable, or circumvent any runtime protection or policy verification
23
+ checks implemented by the SDK.
24
+
25
+ 3. DISCLAIMER OF WARRANTY
26
+ THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
27
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
28
+ PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT.
29
+
30
+ 4. TERMINATION
31
+ This license terminates immediately upon expiration, termination, or cancellation
32
+ of your commercial contract with SecureShield.
33
+
34
+ For licensing inquiries, enterprise subscriptions, or compliance questions, contact:
35
+ legal@secureshield.com
36
+