@walkeros/server-core 4.1.3-next-1779963694449 → 4.2.0-next-1780387694663

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/CHANGELOG.md CHANGED
@@ -1,11 +1,19 @@
1
1
  # @walkeros/server-core
2
2
 
3
- ## 4.1.3-next-1779963694449
3
+ ## 4.2.0-next-1780387694663
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - 2d64ed2: `getHashServer` now accepts an `algorithm` option (`sha256` default,
8
+ or `md5`), so destinations can request either digest from the shared util
9
+ instead of calling Node crypto directly. Criteo's email hashing composes this
10
+ util for its md5, sha256, and sha256_md5 forms. No behavior change for
11
+ existing SHA-256 callers.
7
12
  - Updated dependencies [908d6f0]
8
- - @walkeros/core@4.1.3-next-1779963694449
13
+ - Updated dependencies [f4a9013]
14
+ - Updated dependencies [654ba38]
15
+ - Updated dependencies [3eb2467]
16
+ - @walkeros/core@4.2.0-next-1780387694663
9
17
 
10
18
  ## 4.1.2
11
19
 
package/dist/index.d.mts CHANGED
@@ -7,7 +7,10 @@ interface SendServerOptions {
7
7
  }
8
8
  declare function sendServer(url: string, data?: SendDataValue, options?: SendServerOptions): Promise<SendResponse>;
9
9
 
10
- declare function getHashServer(str: string, length?: number): Promise<string>;
10
+ interface HashOptions {
11
+ algorithm?: 'sha256' | 'md5';
12
+ }
13
+ declare function getHashServer(str: string, length?: number, options?: HashOptions): Promise<string>;
11
14
 
12
15
  type TypesGeneric$1 = Destination$1.TypesGeneric;
13
16
  interface Destination<T extends TypesGeneric$1 = Destination$1.Types> extends Destination$1.Instance<T> {
@@ -83,4 +86,4 @@ declare namespace elb {
83
86
  export type { elb_CommandDestination as CommandDestination, elb_CommandRun as CommandRun, elb_Fn as Fn, elb_PushData as PushData, elb_PushOptions as PushOptions, elb_PushResult as PushResult, elb_Return as Return };
84
87
  }
85
88
 
86
- export { destination as DestinationServer, elb as Elb, type SendServerOptions, source as SourceServer, getHashServer, sendServer };
89
+ export { destination as DestinationServer, elb as Elb, type HashOptions, type SendServerOptions, source as SourceServer, getHashServer, sendServer };
package/dist/index.d.ts CHANGED
@@ -7,7 +7,10 @@ interface SendServerOptions {
7
7
  }
8
8
  declare function sendServer(url: string, data?: SendDataValue, options?: SendServerOptions): Promise<SendResponse>;
9
9
 
10
- declare function getHashServer(str: string, length?: number): Promise<string>;
10
+ interface HashOptions {
11
+ algorithm?: 'sha256' | 'md5';
12
+ }
13
+ declare function getHashServer(str: string, length?: number, options?: HashOptions): Promise<string>;
11
14
 
12
15
  type TypesGeneric$1 = Destination$1.TypesGeneric;
13
16
  interface Destination<T extends TypesGeneric$1 = Destination$1.Types> extends Destination$1.Instance<T> {
@@ -83,4 +86,4 @@ declare namespace elb {
83
86
  export type { elb_CommandDestination as CommandDestination, elb_CommandRun as CommandRun, elb_Fn as Fn, elb_PushData as PushData, elb_PushOptions as PushOptions, elb_PushResult as PushResult, elb_Return as Return };
84
87
  }
85
88
 
86
- export { destination as DestinationServer, elb as Elb, type SendServerOptions, source as SourceServer, getHashServer, sendServer };
89
+ export { destination as DestinationServer, elb as Elb, type HashOptions, type SendServerOptions, source as SourceServer, getHashServer, sendServer };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.create,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,u=(e,t,a,u)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of s(t))n.call(e,c)||c===a||r(e,c,{get:()=>t[c],enumerable:!(u=o(t,c))||u.enumerable});return e},c=(e,o,s)=>(s=null!=e?t(a(e)):{},u(!o&&e&&e.__esModule?s:r(s,"default",{value:e,enumerable:!0}),e)),i={};((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})})(i,{DestinationServer:()=>y,Elb:()=>v,SourceServer:()=>b,getHashServer:()=>h,sendServer:()=>f}),module.exports=(e=i,u(r({},"__esModule",{value:!0}),e));var d=require("@walkeros/core"),l=c(require("http")),p=c(require("https"));function f(e,t,r={}){const o=(0,d.getHeaders)(r.headers),s=(0,d.transformData)(t),a=r.method||"POST",n=r.timeout||5e3;return new Promise(t=>{const r=new URL(e),u="https:"===r.protocol?p:l,c={method:a,headers:o},i=u.request(r,c,e=>{const r=[];e.on("data",e=>{r.push(e)}),e.on("end",()=>{const o=!!(e.statusCode&&e.statusCode>=200&&e.statusCode<300),s=Buffer.concat(r).toString(),a=(0,d.tryCatch)(JSON.parse,()=>s)(s);t({ok:o,data:a,error:o?void 0:`${e.statusCode} ${e.statusMessage}`})})});i.on("error",e=>{t({ok:!1,error:e.message})}),i.on("timeout",()=>{i.destroy(),t({ok:!1,error:"Request timeout"})}),i.setTimeout(n),s&&i.write(s),i.end()})}var m=require("crypto");async function h(e,t){return(await async function(e){const t=(0,m.createHash)("sha256");return t.update(e),t.digest("hex")}(e)).slice(0,t)}var y={},b={},v={};//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t=Object.create,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,u=(e,t,a,u)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of s(t))n.call(e,c)||c===a||r(e,c,{get:()=>t[c],enumerable:!(u=o(t,c))||u.enumerable});return e},c=(e,o,s)=>(s=null!=e?t(a(e)):{},u(!o&&e&&e.__esModule?s:r(s,"default",{value:e,enumerable:!0}),e)),i={};((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})})(i,{DestinationServer:()=>y,Elb:()=>g,SourceServer:()=>b,getHashServer:()=>h,sendServer:()=>f}),module.exports=(e=i,u(r({},"__esModule",{value:!0}),e));var d=require("@walkeros/core"),l=c(require("http")),p=c(require("https"));function f(e,t,r={}){const o=(0,d.getHeaders)(r.headers),s=(0,d.transformData)(t),a=r.method||"POST",n=r.timeout||5e3;return new Promise(t=>{const r=new URL(e),u="https:"===r.protocol?p:l,c={method:a,headers:o},i=u.request(r,c,e=>{const r=[];e.on("data",e=>{r.push(e)}),e.on("end",()=>{const o=!!(e.statusCode&&e.statusCode>=200&&e.statusCode<300),s=Buffer.concat(r).toString(),a=(0,d.tryCatch)(JSON.parse,()=>s)(s);t({ok:o,data:a,error:o?void 0:`${e.statusCode} ${e.statusMessage}`})})});i.on("error",e=>{t({ok:!1,error:e.message})}),i.on("timeout",()=>{i.destroy(),t({ok:!1,error:"Request timeout"})}),i.setTimeout(n),s&&i.write(s),i.end()})}var m=require("crypto");async function h(e,t,r={}){const o=r.algorithm??"sha256";return(await async function(e,t){const r=(0,m.createHash)(t);return r.update(e),r.digest("hex")}(e,o)).slice(0,t)}var y={},b={},g={};//# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/sendServer.ts","../src/getHashServer.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts"],"sourcesContent":["// Export server-specific utilities\nexport * from './sendServer';\nexport * from './getHashServer';\n\n// Export server-specific types\nexport * from './types';\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport { getHeaders, transformData, tryCatch } from '@walkeros/core';\nimport * as http from 'http';\nimport * as https from 'https';\n\nexport interface SendServerOptions {\n headers?: SendHeaders;\n method?: string;\n timeout?: number;\n}\n\nexport function sendServer(\n url: string,\n data?: SendDataValue,\n options: SendServerOptions = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const method = options.method || 'POST';\n const timeout = options.timeout || 5000;\n\n return new Promise((resolve) => {\n const urlObj = new URL(url);\n const lib = urlObj.protocol === 'https:' ? https : http;\n const options: http.RequestOptions | https.RequestOptions = {\n method,\n headers,\n };\n\n const req = lib.request(urlObj, options, (res) => {\n const chunks: Uint8Array[] = [];\n\n res.on('data', (chunk) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const ok = !!(\n res.statusCode &&\n res.statusCode >= 200 &&\n res.statusCode < 300\n );\n\n const responseData = Buffer.concat(chunks).toString();\n const parsedData = tryCatch(\n JSON.parse,\n () => responseData,\n )(responseData);\n\n resolve({\n ok,\n data: parsedData,\n error: ok ? undefined : `${res.statusCode} ${res.statusMessage}`,\n });\n });\n });\n\n req.on('error', (error) => {\n resolve({\n ok: false,\n error: error.message,\n });\n });\n\n req.on('timeout', () => {\n req.destroy();\n resolve({\n ok: false,\n error: 'Request timeout',\n });\n });\n\n req.setTimeout(timeout);\n\n if (body) req.write(body);\n\n req.end();\n });\n}\n","import { createHash } from 'crypto';\n\nasync function sha256(message: string): Promise<string> {\n const hash = createHash('sha256');\n hash.update(message);\n return hash.digest('hex');\n}\n\nexport async function getHashServer(\n str: string,\n length?: number,\n): Promise<string> {\n return (await sha256(str)).slice(0, length);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core Env interface for server-side destinations.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSDestination.Env {\n // Server environments can include SDK constructors, API clients, etc.\n // Each destination extends this further with specific requirements\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Source as WalkerOSSource } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = WalkerOSSource.Types>\n extends WalkerOSSource.Instance<T> {}\n\nexport type Config<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.PartialConfig<T>;\n\nexport type Init<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Init<T>;\n\nexport type InitSource<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.InitSource<T>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core BaseEnv interface for server-side sources.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSSource.BaseEnv {\n // Server environments can include SDK constructors, API clients, etc.\n // Each source extends this further with specific requirements\n}\n","import type { Elb } from '@walkeros/core';\nimport type { Destination, Init, Config } from './destination';\n\nexport type Fn<R = Return> = Elb.Fn<R> & CommandDestination<R> & CommandRun<R>;\n\nexport type CommandDestination<R = void> = (\n event: 'walker destination',\n destination: Destination | Init,\n config?: Config,\n) => R;\n\nexport type CommandRun<R = void> = (event: 'walker run') => R;\n\nexport type PushData = Elb.PushData | Destination | Init;\n\nexport type PushOptions = Config;\n\nexport type PushResult = Elb.PushResult;\n\nexport type Return<R = Promise<PushResult>> = R;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kBAAoD;AACpD,WAAsB;AACtB,YAAuB;AAQhB,SAAS,WACd,KACA,MACA,UAA6B,CAAC,GACP;AACvB,QAAM,cAAU,wBAAW,QAAQ,OAAO;AAC1C,QAAM,WAAO,2BAAc,IAAI;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AO,OAAO;AACnB,SAAO,KAAK,OAAO,KAAK;AAC1B;AAEA,eAAsB,cACpB,KACA,QACiB;AACjB,UAAQ,MAAM,OAAO,GAAG,GAAG,MAAM,GAAG,MAAM;AAC5C;;;ACbA;;;ACAA;;;ACAA;","names":["options"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/sendServer.ts","../src/getHashServer.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts"],"sourcesContent":["// Export server-specific utilities\nexport * from './sendServer';\nexport * from './getHashServer';\n\n// Export server-specific types\nexport * from './types';\n","import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport { getHeaders, transformData, tryCatch } from '@walkeros/core';\nimport * as http from 'http';\nimport * as https from 'https';\n\nexport interface SendServerOptions {\n headers?: SendHeaders;\n method?: string;\n timeout?: number;\n}\n\nexport function sendServer(\n url: string,\n data?: SendDataValue,\n options: SendServerOptions = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const method = options.method || 'POST';\n const timeout = options.timeout || 5000;\n\n return new Promise((resolve) => {\n const urlObj = new URL(url);\n const lib = urlObj.protocol === 'https:' ? https : http;\n const options: http.RequestOptions | https.RequestOptions = {\n method,\n headers,\n };\n\n const req = lib.request(urlObj, options, (res) => {\n const chunks: Uint8Array[] = [];\n\n res.on('data', (chunk) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const ok = !!(\n res.statusCode &&\n res.statusCode >= 200 &&\n res.statusCode < 300\n );\n\n const responseData = Buffer.concat(chunks).toString();\n const parsedData = tryCatch(\n JSON.parse,\n () => responseData,\n )(responseData);\n\n resolve({\n ok,\n data: parsedData,\n error: ok ? undefined : `${res.statusCode} ${res.statusMessage}`,\n });\n });\n });\n\n req.on('error', (error) => {\n resolve({\n ok: false,\n error: error.message,\n });\n });\n\n req.on('timeout', () => {\n req.destroy();\n resolve({\n ok: false,\n error: 'Request timeout',\n });\n });\n\n req.setTimeout(timeout);\n\n if (body) req.write(body);\n\n req.end();\n });\n}\n","import { createHash } from 'crypto';\n\nexport interface HashOptions {\n algorithm?: 'sha256' | 'md5';\n}\n\nasync function digest(message: string, algorithm: string): Promise<string> {\n const hash = createHash(algorithm);\n hash.update(message);\n return hash.digest('hex');\n}\n\nexport async function getHashServer(\n str: string,\n length?: number,\n options: HashOptions = {},\n): Promise<string> {\n const algorithm = options.algorithm ?? 'sha256';\n return (await digest(str, algorithm)).slice(0, length);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core Env interface for server-side destinations.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSDestination.Env {\n // Server environments can include SDK constructors, API clients, etc.\n // Each destination extends this further with specific requirements\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Source as WalkerOSSource } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = WalkerOSSource.Types>\n extends WalkerOSSource.Instance<T> {}\n\nexport type Config<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.PartialConfig<T>;\n\nexport type Init<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Init<T>;\n\nexport type InitSource<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.InitSource<T>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core BaseEnv interface for server-side sources.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSSource.BaseEnv {\n // Server environments can include SDK constructors, API clients, etc.\n // Each source extends this further with specific requirements\n}\n","import type { Elb } from '@walkeros/core';\nimport type { Destination, Init, Config } from './destination';\n\nexport type Fn<R = Return> = Elb.Fn<R> & CommandDestination<R> & CommandRun<R>;\n\nexport type CommandDestination<R = void> = (\n event: 'walker destination',\n destination: Destination | Init,\n config?: Config,\n) => R;\n\nexport type CommandRun<R = void> = (event: 'walker run') => R;\n\nexport type PushData = Elb.PushData | Destination | Init;\n\nexport type PushOptions = Config;\n\nexport type PushResult = Elb.PushResult;\n\nexport type Return<R = Promise<PushResult>> = R;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kBAAoD;AACpD,WAAsB;AACtB,YAAuB;AAQhB,SAAS,WACd,KACA,MACA,UAA6B,CAAC,GACP;AACvB,QAAM,cAAU,wBAAW,QAAQ,OAAO;AAC1C,QAAM,WAAO,2BAAc,IAAI;AAC/B,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,UAAU,QAAQ,WAAW;AAEnC,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,SAAS,IAAI,IAAI,GAAG;AAC1B,UAAM,MAAM,OAAO,aAAa,WAAW,QAAQ;AACnD,UAAMA,WAAsD;AAAA,MAC1D;AAAA,MACA;AAAA,IACF;AAEA,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js CHANGED
@@ -1 +1 @@
1
- import{getHeaders as t,transformData as e,tryCatch as o}from"@walkeros/core";import*as r from"http";import*as s from"https";function a(a,n,u={}){const i=t(u.headers),c=e(n),d=u.method||"POST",m=u.timeout||5e3;return new Promise(t=>{const e=new URL(a),n="https:"===e.protocol?s:r,u={method:d,headers:i},p=n.request(e,u,e=>{const r=[];e.on("data",t=>{r.push(t)}),e.on("end",()=>{const s=!!(e.statusCode&&e.statusCode>=200&&e.statusCode<300),a=Buffer.concat(r).toString(),n=o(JSON.parse,()=>a)(a);t({ok:s,data:n,error:s?void 0:`${e.statusCode} ${e.statusMessage}`})})});p.on("error",e=>{t({ok:!1,error:e.message})}),p.on("timeout",()=>{p.destroy(),t({ok:!1,error:"Request timeout"})}),p.setTimeout(m),c&&p.write(c),p.end()})}import{createHash as n}from"crypto";async function u(t,e){return(await async function(t){const e=n("sha256");return e.update(t),e.digest("hex")}(t)).slice(0,e)}var i={},c={},d={};export{i as DestinationServer,d as Elb,c as SourceServer,u as getHashServer,a as sendServer};//# sourceMappingURL=index.mjs.map
1
+ import{getHeaders as t,transformData as e,tryCatch as o}from"@walkeros/core";import*as r from"http";import*as s from"https";function a(a,n,i={}){const u=t(i.headers),c=e(n),m=i.method||"POST",d=i.timeout||5e3;return new Promise(t=>{const e=new URL(a),n="https:"===e.protocol?s:r,i={method:m,headers:u},p=n.request(e,i,e=>{const r=[];e.on("data",t=>{r.push(t)}),e.on("end",()=>{const s=!!(e.statusCode&&e.statusCode>=200&&e.statusCode<300),a=Buffer.concat(r).toString(),n=o(JSON.parse,()=>a)(a);t({ok:s,data:n,error:s?void 0:`${e.statusCode} ${e.statusMessage}`})})});p.on("error",e=>{t({ok:!1,error:e.message})}),p.on("timeout",()=>{p.destroy(),t({ok:!1,error:"Request timeout"})}),p.setTimeout(d),c&&p.write(c),p.end()})}import{createHash as n}from"crypto";async function i(t,e,o={}){const r=o.algorithm??"sha256";return(await async function(t,e){const o=n(e);return o.update(t),o.digest("hex")}(t,r)).slice(0,e)}var u={},c={},m={};export{u as DestinationServer,m as Elb,c as SourceServer,i as getHashServer,a as sendServer};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sendServer.ts","../src/getHashServer.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts"],"sourcesContent":["import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport { getHeaders, transformData, tryCatch } from '@walkeros/core';\nimport * as http from 'http';\nimport * as https from 'https';\n\nexport interface SendServerOptions {\n headers?: SendHeaders;\n method?: string;\n timeout?: number;\n}\n\nexport function sendServer(\n url: string,\n data?: SendDataValue,\n options: SendServerOptions = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const method = options.method || 'POST';\n const timeout = options.timeout || 5000;\n\n return new Promise((resolve) => {\n const urlObj = new URL(url);\n const lib = urlObj.protocol === 'https:' ? https : http;\n const options: http.RequestOptions | https.RequestOptions = {\n method,\n headers,\n };\n\n const req = lib.request(urlObj, options, (res) => {\n const chunks: Uint8Array[] = [];\n\n res.on('data', (chunk) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const ok = !!(\n res.statusCode &&\n res.statusCode >= 200 &&\n res.statusCode < 300\n );\n\n const responseData = Buffer.concat(chunks).toString();\n const parsedData = tryCatch(\n JSON.parse,\n () => responseData,\n )(responseData);\n\n resolve({\n ok,\n data: parsedData,\n error: ok ? undefined : `${res.statusCode} ${res.statusMessage}`,\n });\n });\n });\n\n req.on('error', (error) => {\n resolve({\n ok: false,\n error: error.message,\n });\n });\n\n req.on('timeout', () => {\n req.destroy();\n resolve({\n ok: false,\n error: 'Request timeout',\n });\n });\n\n req.setTimeout(timeout);\n\n if (body) req.write(body);\n\n req.end();\n });\n}\n","import { createHash } from 'crypto';\n\nasync function sha256(message: string): Promise<string> {\n const hash = createHash('sha256');\n hash.update(message);\n return hash.digest('hex');\n}\n\nexport async function getHashServer(\n str: string,\n length?: number,\n): Promise<string> {\n return (await sha256(str)).slice(0, length);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core Env interface for server-side destinations.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSDestination.Env {\n // Server environments can include SDK constructors, API clients, etc.\n // Each destination extends this further with specific requirements\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Source as WalkerOSSource } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = WalkerOSSource.Types>\n extends WalkerOSSource.Instance<T> {}\n\nexport type Config<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.PartialConfig<T>;\n\nexport type Init<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Init<T>;\n\nexport type InitSource<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.InitSource<T>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core BaseEnv interface for server-side sources.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSSource.BaseEnv {\n // Server environments can include SDK constructors, API clients, etc.\n // Each source extends this further with specific requirements\n}\n","import type { Elb } from '@walkeros/core';\nimport type { Destination, Init, Config } from './destination';\n\nexport type Fn<R = Return> = Elb.Fn<R> & CommandDestination<R> & CommandRun<R>;\n\nexport type CommandDestination<R = void> = (\n event: 'walker destination',\n destination: Destination | Init,\n config?: Config,\n) => R;\n\nexport type CommandRun<R = void> = (event: 'walker run') => R;\n\nexport type PushData = Elb.PushData | Destination | Init;\n\nexport type PushOptions = Config;\n\nexport type PushResult = Elb.PushResult;\n\nexport type Return<R = Promise<PushResult>> = R;\n"],"mappings":";AACA,SAAS,YAAY,eAAe,gBAAgB;AACpD,YAAY,UAAU;AACtB,YAAY,WAAW;AAQhB,SAAS,WACd,KACA,MACA,UAA6B,CAAC,GACP;AACvB,QAAM,UAAU,WAAW,QAAQ,OAAO;AAC1C,QAAM,OAAO,cAAc,IAAI;AAC/B,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,UAAU,QAAQ,WAAW;AAEnC,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,SAAS,IAAI,IAAI,GAAG;AAC1B,UAAM,MAAM,OAAO,aAAa,WAAW,QAAQ;AACnD,UAAMA,WAAsD;AAAA,MAC1D;AAAA,MACA;AAAA,IACF;AAEA,UAAM,MAAM,IAAI,QAAQ,QAAQA,UAAS,CAAC,QAAQ;AAChD,YAAM,SAAuB,CAAC;AAE9B,UAAI,GAAG,QAAQ,CAAC,UAAU;AACxB,eAAO,KAAK,KAAK;AAAA,MACnB,CAAC;AAED,UAAI,GAAG,OAAO,MAAM;AAClB,cAAM,KAAK,CAAC,EACV,IAAI,cACJ,IAAI,cAAc,OAClB,IAAI,aAAa;AAGnB,cAAM,eAAe,OAAO,OAAO,MAAM,EAAE,SAAS;AACpD,cAAM,aAAa;AAAA,UACjB,KAAK;AAAA,UACL,MAAM;AAAA,QACR,EAAE,YAAY;AAEd,gBAAQ;AAAA,UACN;AAAA,UACA,MAAM;AAAA,UACN,OAAO,KAAK,SAAY,GAAG,IAAI,UAAU,IAAI,IAAI,aAAa;AAAA,QAChE,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAED,QAAI,GAAG,SAAS,CAAC,UAAU;AACzB,cAAQ;AAAA,QACN,IAAI;AAAA,QACJ,OAAO,MAAM;AAAA,MACf,CAAC;AAAA,IACH,CAAC;AAED,QAAI,GAAG,WAAW,MAAM;AACtB,UAAI,QAAQ;AACZ,cAAQ;AAAA,QACN,IAAI;AAAA,QACJ,OAAO;AAAA,MACT,CAAC;AAAA,IACH,CAAC;AAED,QAAI,WAAW,OAAO;AAEtB,QAAI,KAAM,KAAI,MAAM,IAAI;AAExB,QAAI,IAAI;AAAA,EACV,CAAC;AACH;;;AC9EA,SAAS,kBAAkB;AAE3B,eAAe,OAAO,SAAkC;AACtD,QAAM,OAAO,WAAW,QAAQ;AAChC,OAAK,OAAO,OAAO;AACnB,SAAO,KAAK,OAAO,KAAK;AAC1B;AAEA,eAAsB,cACpB,KACA,QACiB;AACjB,UAAQ,MAAM,OAAO,GAAG,GAAG,MAAM,GAAG,MAAM;AAC5C;;;ACbA;;;ACAA;;;ACAA;","names":["options"]}
1
+ {"version":3,"sources":["../src/sendServer.ts","../src/getHashServer.ts","../src/types/destination.ts","../src/types/source.ts","../src/types/elb.ts"],"sourcesContent":["import type { SendDataValue, SendHeaders, SendResponse } from '@walkeros/core';\nimport { getHeaders, transformData, tryCatch } from '@walkeros/core';\nimport * as http from 'http';\nimport * as https from 'https';\n\nexport interface SendServerOptions {\n headers?: SendHeaders;\n method?: string;\n timeout?: number;\n}\n\nexport function sendServer(\n url: string,\n data?: SendDataValue,\n options: SendServerOptions = {},\n): Promise<SendResponse> {\n const headers = getHeaders(options.headers);\n const body = transformData(data);\n const method = options.method || 'POST';\n const timeout = options.timeout || 5000;\n\n return new Promise((resolve) => {\n const urlObj = new URL(url);\n const lib = urlObj.protocol === 'https:' ? https : http;\n const options: http.RequestOptions | https.RequestOptions = {\n method,\n headers,\n };\n\n const req = lib.request(urlObj, options, (res) => {\n const chunks: Uint8Array[] = [];\n\n res.on('data', (chunk) => {\n chunks.push(chunk);\n });\n\n res.on('end', () => {\n const ok = !!(\n res.statusCode &&\n res.statusCode >= 200 &&\n res.statusCode < 300\n );\n\n const responseData = Buffer.concat(chunks).toString();\n const parsedData = tryCatch(\n JSON.parse,\n () => responseData,\n )(responseData);\n\n resolve({\n ok,\n data: parsedData,\n error: ok ? undefined : `${res.statusCode} ${res.statusMessage}`,\n });\n });\n });\n\n req.on('error', (error) => {\n resolve({\n ok: false,\n error: error.message,\n });\n });\n\n req.on('timeout', () => {\n req.destroy();\n resolve({\n ok: false,\n error: 'Request timeout',\n });\n });\n\n req.setTimeout(timeout);\n\n if (body) req.write(body);\n\n req.end();\n });\n}\n","import { createHash } from 'crypto';\n\nexport interface HashOptions {\n algorithm?: 'sha256' | 'md5';\n}\n\nasync function digest(message: string, algorithm: string): Promise<string> {\n const hash = createHash(algorithm);\n hash.update(message);\n return hash.digest('hex');\n}\n\nexport async function getHashServer(\n str: string,\n length?: number,\n options: HashOptions = {},\n): Promise<string> {\n const algorithm = options.algorithm ?? 'sha256';\n return (await digest(str, algorithm)).slice(0, length);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Destination as WalkerOSDestination } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSDestination.TypesGeneric;\n\nexport interface Destination<T extends TypesGeneric = WalkerOSDestination.Types>\n extends WalkerOSDestination.Instance<T> {}\n\nexport type Init = WalkerOSDestination.Init;\n\nexport type Config<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PartialConfig<T>;\n\nexport type InitFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.InitFn<T>;\n\nexport type PushFn<T extends TypesGeneric = WalkerOSDestination.Types> =\n WalkerOSDestination.PushFn<T>;\n\nexport type PushEvent<Mapping = unknown> =\n WalkerOSDestination.PushEvent<Mapping>;\n\nexport type PushEvents<Mapping = unknown> =\n WalkerOSDestination.PushEvents<Mapping>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core Env interface for server-side destinations.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSDestination.Env {\n // Server environments can include SDK constructors, API clients, etc.\n // Each destination extends this further with specific requirements\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Source as WalkerOSSource } from '@walkeros/core';\n\nexport type TypesGeneric = WalkerOSSource.TypesGeneric;\n\nexport interface Source<T extends TypesGeneric = WalkerOSSource.Types>\n extends WalkerOSSource.Instance<T> {}\n\nexport type Config<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Config<T>;\n\nexport type PartialConfig<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.PartialConfig<T>;\n\nexport type Init<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.Init<T>;\n\nexport type InitSource<T extends TypesGeneric = WalkerOSSource.Types> =\n WalkerOSSource.InitSource<T>;\n\n/**\n * Server-specific environment requirements interface\n *\n * Extends the core BaseEnv interface for server-side sources.\n * Used for dependency injection of SDK classes and external APIs.\n */\nexport interface Env extends WalkerOSSource.BaseEnv {\n // Server environments can include SDK constructors, API clients, etc.\n // Each source extends this further with specific requirements\n}\n","import type { Elb } from '@walkeros/core';\nimport type { Destination, Init, Config } from './destination';\n\nexport type Fn<R = Return> = Elb.Fn<R> & CommandDestination<R> & CommandRun<R>;\n\nexport type CommandDestination<R = void> = (\n event: 'walker destination',\n destination: Destination | Init,\n config?: Config,\n) => R;\n\nexport type CommandRun<R = void> = (event: 'walker run') => R;\n\nexport type PushData = Elb.PushData | Destination | Init;\n\nexport type PushOptions = Config;\n\nexport type PushResult = Elb.PushResult;\n\nexport type Return<R = Promise<PushResult>> = R;\n"],"mappings":";AACA,SAAS,YAAY,eAAe,gBAAgB;AACpD,YAAY,UAAU;AACtB,YAAY,WAAW;AAQhB,SAAS,WACd,KACA,MACA,UAA6B,CAAC,GACP;AACvB,QAAM,UAAU,WAAW,QAAQ,OAAO;AAC1C,QAAM,OAAO,cAAc,IAAI;AAC/B,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,UAAU,QAAQ,WAAW;AAEnC,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,SAAS,IAAI,IAAI,GAAG;AAC1B,UAAM,MAAM,OAAO,aAAa,WAAW,QAAQ;AACnD,UAAMA,WAAsD;AAAA,MAC1D;AAAA,MACA;AAAA,IACF;AAEA,UAAM,MAAM,IAAI,QAAQ,QAAQA,UAAS,CAAC,QAAQ;AAChD,YAAM,SAAuB,CAAC;AAE9B,UAAI,GAAG,QAAQ,CAAC,UAAU;AACxB,eAAO,KAAK,KAAK;AAAA,MACnB,CAAC;AAED,UAAI,GAAG,OAAO,MAAM;AAClB,cAAM,KAAK,CAAC,EACV,IAAI,cACJ,IAAI,cAAc,OAClB,IAAI,aAAa;AAGnB,cAAM,eAAe,OAAO,OAAO,MAAM,EAAE,SAAS;AACpD,cAAM,aAAa;AAAA,UACjB,KAAK;AAAA,UACL,MAAM;AAAA,QACR,EAAE,YAAY;AAEd,gBAAQ;AAAA,UACN;AAAA,UACA,MAAM;AAAA,UACN,OAAO,KAAK,SAAY,GAAG,IAAI,UAAU,IAAI,IAAI,aAAa;AAAA,QAChE,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAED,QAAI,GAAG,SAAS,CAAC,UAAU;AACzB,cAAQ;AAAA,QACN,IAAI;AAAA,QACJ,OAAO,MAAM;AAAA,MACf,CAAC;AAAA,IACH,CAAC;AAED,QAAI,GAAG,WAAW,MAAM;AACtB,UAAI,QAAQ;AACZ,cAAQ;AAAA,QACN,IAAI;AAAA,QACJ,OAAO;AAAA,MACT,CAAC;AAAA,IACH,CAAC;AAED,QAAI,WAAW,OAAO;AAEtB,QAAI,KAAM,KAAI,MAAM,IAAI;AAExB,QAAI,IAAI;AAAA,EACV,CAAC;AACH;;;AC9EA,SAAS,kBAAkB;AAM3B,eAAe,OAAO,SAAiB,WAAoC;AACzE,QAAM,OAAO,WAAW,SAAS;AACjC,OAAK,OAAO,OAAO;AACnB,SAAO,KAAK,OAAO,KAAK;AAC1B;AAEA,eAAsB,cACpB,KACA,QACA,UAAuB,CAAC,GACP;AACjB,QAAM,YAAY,QAAQ,aAAa;AACvC,UAAQ,MAAM,OAAO,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM;AACvD;;;ACnBA;;;ACAA;;;ACAA;","names":["options"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/server-core",
3
3
  "description": "Server-specific utilities for walkerOS",
4
- "version": "4.1.3-next-1779963694449",
4
+ "version": "4.2.0-next-1780387694663",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -27,8 +27,8 @@
27
27
  "update": "npx npm-check-updates -u && npm update"
28
28
  },
29
29
  "devDependencies": {
30
- "@walkeros/collector": "4.1.3-next-1779963694449",
31
- "@walkeros/core": "4.1.3-next-1779963694449"
30
+ "@walkeros/collector": "4.2.0-next-1780387694663",
31
+ "@walkeros/core": "4.2.0-next-1780387694663"
32
32
  },
33
33
  "repository": {
34
34
  "url": "git+https://github.com/elbwalker/walkerOS.git",
@@ -52,6 +52,6 @@
52
52
  }
53
53
  ],
54
54
  "dependencies": {
55
- "@walkeros/core": "4.1.3-next-1779963694449"
55
+ "@walkeros/core": "4.2.0-next-1780387694663"
56
56
  }
57
57
  }