@opentabs-dev/opentabs-plugin-prescript-test 0.0.4 → 0.0.5

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,6 +1,6 @@
1
1
  "use strict";
2
2
  (() => {
3
- // dist/_pre_script_setup_7d3ba156-ad4d-4c05-9feb-8e65eff6118d.ts
3
+ // dist/_pre_script_setup_67844edc-1db7-4cdf-946b-e2d215ea888e.ts
4
4
  if (!globalThis.__openTabs) {
5
5
  globalThis.__openTabs = {};
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["_pre_script_setup_7d3ba156-ad4d-4c05-9feb-8e65eff6118d.ts", "../node_modules/@opentabs-dev/plugin-sdk/src/pre-script.ts", "../src/pre-script.ts"],
3
+ "sources": ["_pre_script_setup_67844edc-1db7-4cdf-946b-e2d215ea888e.ts", "../node_modules/@opentabs-dev/plugin-sdk/src/pre-script.ts", "../src/pre-script.ts"],
4
4
  "sourcesContent": ["declare global {\n var __openTabs: {\n _preScriptRunner?: (fn: (ctx: {\n set(key: string, value: unknown): void;\n log: {\n debug(...args: unknown[]): void;\n info(...args: unknown[]): void;\n warn(...args: unknown[]): void;\n error(...args: unknown[]): void;\n };\n }) => void) => void;\n preScript?: Record<string, Record<string, unknown>>;\n } | undefined;\n}\n\nif (!globalThis.__openTabs) {\n (globalThis as Record<string, unknown>).__openTabs = {};\n}\nconst _ot = globalThis.__openTabs!;\nif (!_ot.preScript) {\n _ot.preScript = {};\n}\n\n// Reset this plugin's pre-script bucket on every load. Each navigation gets\n// a clean slate so stale values from the previous page don't leak.\n_ot.preScript[\"prescript-test\"] = {};\n\n// Plugin-scoped logger. Pre-script logs go directly to console \u2014 the\n// extension's ISOLATED-world log relay hasn't loaded yet at document_start.\nconst _logPrefix = \"[opentabs:prescript-test:pre-script]\";\nconst _log = {\n debug: (...args: unknown[]) => { console.debug(_logPrefix, ...args); },\n info: (...args: unknown[]) => { console.info(_logPrefix, ...args); },\n warn: (...args: unknown[]) => { console.warn(_logPrefix, ...args); },\n error: (...args: unknown[]) => { console.error(_logPrefix, ...args); },\n};\n\n// Install _preScriptRunner so definePreScript() in the user module can invoke\n// the callback synchronously. Self-destructs after first call so it cannot\n// be called again after the pre-script has loaded.\n_ot._preScriptRunner = (fn) => {\n delete _ot._preScriptRunner;\n const ctx = {\n set(key: string, value: unknown) {\n _ot.preScript![\"prescript-test\"]![key] = value;\n },\n log: _log,\n };\n try {\n fn(ctx as Parameters<typeof fn>[0]);\n } catch (e) {\n console.error(_logPrefix, 'pre-script threw:', e);\n }\n};\n", null, "import { definePreScript } from '@opentabs-dev/plugin-sdk/pre-script';\n\n/**\n * Pre-script for the prescript-test plugin.\n *\n * Runs at document_start in MAIN world, strictly before any page script.\n * Wraps window.fetch to capture bearer tokens from outbound requests \u2014\n * simulating the PR #69 scenario where the page overwrites window.fetch\n * immediately after its own bootstrap fetch, which would prevent a normal\n * adapter from ever seeing the token.\n *\n * The adapter reads the captured values later via getPreScriptValue().\n */\ndefinePreScript(({ set, log }) => {\n const g = globalThis as Record<string, unknown>;\n const origFetch = g['fetch'] as typeof fetch;\n\n const patchedFetch = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {\n // Resolve the URL string for storage\n const url = typeof input === 'string' ? input : input instanceof URL ? input.href : (input as Request).url;\n\n // Extract any Authorization: Bearer header from whichever HeadersInit shape was passed\n const headers = init?.headers;\n let bearer: string | undefined;\n\n if (headers instanceof Headers) {\n bearer = headers.get('Authorization') ?? headers.get('authorization') ?? undefined;\n } else if (Array.isArray(headers)) {\n for (const entry of headers as string[][]) {\n if (entry[0]?.toLowerCase() === 'authorization') {\n bearer = entry[1];\n break;\n }\n }\n } else if (headers && typeof headers === 'object') {\n const h = headers as Record<string, string>;\n bearer = h['Authorization'] ?? h['authorization'];\n }\n\n if (bearer?.startsWith('Bearer ')) {\n set('authToken', bearer.slice(7));\n set('authUrl', url);\n set('capturedAt', Date.now());\n log.debug(`[prescript-test] captured bearer for ${url}`);\n }\n\n return origFetch(input, init);\n };\n\n g['fetch'] = patchedFetch;\n log.info('[prescript-test] fetch interceptor installed');\n});\n"],
5
5
  "mappings": ";;;AAeA,MAAI,CAAC,WAAW,YAAY;AAC1B,IAAC,WAAuC,aAAa,CAAC;AAAA,EACxD;AACA,MAAM,MAAM,WAAW;AACvB,MAAI,CAAC,IAAI,WAAW;AAClB,QAAI,YAAY,CAAC;AAAA,EACnB;AAIA,MAAI,UAAU,gBAAgB,IAAI,CAAC;AAInC,MAAM,aAAa;AACnB,MAAM,OAAO;AAAA,IACX,OAAO,IAAI,SAAoB;AAAE,cAAQ,MAAM,YAAY,GAAG,IAAI;AAAA,IAAG;AAAA,IACrE,MAAO,IAAI,SAAoB;AAAE,cAAQ,KAAK,YAAY,GAAG,IAAI;AAAA,IAAG;AAAA,IACpE,MAAO,IAAI,SAAoB;AAAE,cAAQ,KAAK,YAAY,GAAG,IAAI;AAAA,IAAG;AAAA,IACpE,OAAO,IAAI,SAAoB;AAAE,cAAQ,MAAM,YAAY,GAAG,IAAI;AAAA,IAAG;AAAA,EACvE;AAKA,MAAI,mBAAmB,CAAC,OAAO;AAC7B,WAAO,IAAI;AACX,UAAM,MAAM;AAAA,MACV,IAAI,KAAa,OAAgB;AAC/B,YAAI,UAAW,gBAAgB,EAAG,GAAG,IAAI;AAAA,MAC3C;AAAA,MACA,KAAK;AAAA,IACP;AACA,QAAI;AACF,SAAG,GAA+B;AAAA,IACpC,SAAS,GAAG;AACV,cAAQ,MAAM,YAAY,qBAAqB,CAAC;AAAA,IAClD;AAAA,EACF;;;ACJO,MAAM,kBAAkB,CAAC,OAA6C;AAC3E,UAAM,KAAM,WAAuC;AAGnD,QAAI,mBAAmB,EAAE;EAC3B;;;ACzCA,kBAAgB,CAAC,EAAE,KAAK,IAAI,MAAM;AAChC,UAAM,IAAI;AACV,UAAM,YAAY,EAAE,OAAO;AAE3B,UAAM,eAAe,OAAO,OAA0B,SAA0C;AAE9F,YAAM,MAAM,OAAO,UAAU,WAAW,QAAQ,iBAAiB,MAAM,MAAM,OAAQ,MAAkB;AAGvG,YAAM,UAAU,MAAM;AACtB,UAAI;AAEJ,UAAI,mBAAmB,SAAS;AAC9B,iBAAS,QAAQ,IAAI,eAAe,KAAK,QAAQ,IAAI,eAAe,KAAK;AAAA,MAC3E,WAAW,MAAM,QAAQ,OAAO,GAAG;AACjC,mBAAW,SAAS,SAAuB;AACzC,cAAI,MAAM,CAAC,GAAG,YAAY,MAAM,iBAAiB;AAC/C,qBAAS,MAAM,CAAC;AAChB;AAAA,UACF;AAAA,QACF;AAAA,MACF,WAAW,WAAW,OAAO,YAAY,UAAU;AACjD,cAAM,IAAI;AACV,iBAAS,EAAE,eAAe,KAAK,EAAE,eAAe;AAAA,MAClD;AAEA,UAAI,QAAQ,WAAW,SAAS,GAAG;AACjC,YAAI,aAAa,OAAO,MAAM,CAAC,CAAC;AAChC,YAAI,WAAW,GAAG;AAClB,YAAI,cAAc,KAAK,IAAI,CAAC;AAC5B,YAAI,MAAM,wCAAwC,GAAG,EAAE;AAAA,MACzD;AAEA,aAAO,UAAU,OAAO,IAAI;AAAA,IAC9B;AAEA,MAAE,OAAO,IAAI;AACb,QAAI,KAAK,8CAA8C;AAAA,EACzD,CAAC;",
6
6
  "names": []
package/dist/tools.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "sdkVersion": "0.0.105",
2
+ "sdkVersion": "0.0.106",
3
3
  "preScriptFile": "pre-script.iife.js",
4
- "preScriptHash": "2397ffa2d74520209848a1105df8046d2cbfa482466e0e1f5bf440ff54b312bb",
4
+ "preScriptHash": "714ef94de1679435b9e31cc19bfdb550cddb2fa818d1815d85d9a92edbaeaa0a",
5
5
  "tools": [
6
6
  {
7
7
  "name": "echo_auth",
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.4",
6
+ "version": "0.0.5",
7
7
  "type": "module",
8
8
  "main": "dist/adapter.iife.js",
9
9
  "keywords": [
@@ -42,11 +42,11 @@
42
42
  "zod": "^4.0.0"
43
43
  },
44
44
  "dependencies": {
45
- "@opentabs-dev/plugin-sdk": "^0.0.105"
45
+ "@opentabs-dev/plugin-sdk": "^0.0.106"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@biomejs/biome": "2.4.6",
49
- "@opentabs-dev/plugin-tools": "^0.0.105",
49
+ "@opentabs-dev/plugin-tools": "^0.0.106",
50
50
  "jiti": "^2.6.1",
51
51
  "typescript": "^6.0.3",
52
52
  "zod": "^4.3.6"