azot 0.9.0-alpha.1 → 0.9.1

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/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Azot API
2
2
 
3
- Type definitions for the latesst [Azot](https://azot.so) API.
3
+ Type definitions for the latest [Azot](https://azot.so) API.
4
4
 
5
5
  ## Getting Started
6
6
 
7
- Check [TypeScript interfaces](https://github.com/azot-labs/azot/tree/main/packages/api/types) to get started with our API. If you want to discover and install extensions, check out [Extension List](https://github.com/azot-labs/azot/tree/main/extensions/).
7
+ Check [TypeScript interfaces](https://www.npmjs.com/package/azot?activeTab=code) to get started with our API. If you want to discover and install extensions, check out [Extension List](https://github.com/azot-labs/extensions/blob/main/extensions.json).
8
8
 
9
9
  ## Community
10
10
 
package/bin/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),t=e((exports,t)=>{let{readFileSync:n,writeFileSync:r}=require(`node:fs`),{join:i}=require(`node:path`),a=(e,t)=>{let a=n(e,`utf8`),o=t||i(process.cwd(),`package.json`),s=require(o),c=/module\.exports\s*=\s*(\w+)/g,l,u;for(;(l=c.exec(a))!==null;)u=l;if(!u)throw Error(`No module.exports found in source file`);let d=u[1],f=a.replace(/(module\.exports\s*=\s*(\w+))(?![^]*module\.exports\s*=\s*\w+)/,`${d}.package=${JSON.stringify(s)};module.exports = $2`);return r(e,f,`utf8`),{code:f,packageJson:s}};t.exports={injectPackageJson:a}}),n=e((exports,t)=>{let{createCipheriv:n,createDecipheriv:r,publicEncrypt:i,privateDecrypt:a,randomBytes:o}=require(`node:crypto`),{readFileSync:s,writeFileSync:c}=require(`node:fs`),l=Buffer.from(`STX`,`utf8`),u=(e,t,r)=>{let a=o(32),u=o(16),d=s(t),f=n(`aes-256-cbc`,a,u),p=Buffer.concat([f.update(d),f.final()]),m=i(e,a),h=Buffer.concat([l,u,m,p]);return r&&c(r,h),{aesIv:u,encryptedAesKey:m,encryptedCode:p}},d=(e,t,n)=>{let i=s(t),o=l.byteLength,u=i.subarray(0,o);if(!u.equals(l))throw Error(`Incorrect file format`);let d=o,f=d+16,p=f+512,m=i.subarray(d,f),h=i.subarray(f,p),g=i.subarray(p),_=a(e,h),v=r(`aes-256-cbc`,_,m),y=Buffer.concat([v.update(g),v.final()]),b=y.toString(`utf8`);return n&&c(n,b),b};t.exports={encrypt:u,decrypt:d}}),r=e((exports,t)=>{let{readFileSync:n,writeFileSync:r}=require(`node:fs`),i=require(`javascript-obfuscator`),a=(e,t)=>{let a=n(e,`utf8`);console.log(`Obfuscating...`),console.time(`Obfuscation complete in`);let o=i.obfuscate(a,{target:`node`,compact:!0,controlFlowFlattening:!0,controlFlowFlatteningThreshold:1,deadCodeInjection:!0,debugProtection:!0,identifierNamesGenerator:`hexadecimal`,numbersToExpressions:!0,selfDefending:!0,simplify:!0,splitStrings:!0,splitStringsChunkLength:5,stringArray:!0,stringArrayCallsTransform:!0,stringArrayCallsTransformThreshold:1,stringArrayEncoding:[`base64`],stringArrayIndexShift:!0,stringArrayRotate:!0,stringArrayShuffle:!0,stringArrayWrappersCount:2,stringArrayWrappersChainedCalls:!0,stringArrayWrappersType:`function`,stringArrayThreshold:1,transformObjectKeys:!0,unicodeEscapeSequence:!1});console.timeEnd(`Obfuscation complete in`);let s=o.getObfuscatedCode();return r(t||e,s),s};t.exports={obfuscate:a}});const{parseArgs:i}=require(`node:util`),{rmSync:a,readdirSync:o,readFileSync:s}=require(`node:fs`),c=require(`node:path`),{build:l}=require(`tsdown`),{injectPackageJson:u}=t(),{encrypt:d,decrypt:f}=n(),{obfuscate:p}=r(),m=i({allowPositionals:!0,allowNegative:!0,options:{input:{type:`string`,short:`i`,description:`Path to the input file`},key:{type:`string`,short:`k`,description:`Path to the key file (public for encrypt, private for decrypt)`},output:{type:`string`,short:`o`,description:`Path to the output file`},watch:{type:`boolean`,description:`Watch file changes`},minify:{type:`boolean`,description:`Minify output`},obfuscate:{type:`boolean`,description:`Obfuscate output`},encrypt:{type:`boolean`,description:`Encrypt extension source code (.js will be packed inside .stx)`},decrypt:{type:`boolean`,description:`Decrypt encrypted extension`}}}),h=()=>{let e=[process.cwd(),c.join(process.cwd(),`src`),c.join(process.cwd(),`lib`)];for(let t of e){let e=o(t),n=e.filter(e=>!e.endsWith(`.d.ts`)).find(e=>new Set([`.ts`,`.js`]).has(c.extname(e)));if(n)return c.join(t,n)}};(async()=>{let[e,...t]=m.positionals,n=m.values.input||t[0]||h();if(e===`build`||e===`pack`){let t=typeof m.values.minify==`boolean`?m.values.minify:!0;await l({entry:n,format:`cjs`,platform:`node`,target:`node22`,watch:m.values.watch,minify:t}),m.values.input=c.join(process.cwd(),`dist`,c.basename(n).replace(/\.ts$/,`.js`));let{packageJson:r}=u(m.values.input),i=typeof m.values.obfuscate==`boolean`,o=i?m.values.obfuscate:r.private;o&&p(m.values.input,m.values.input);let f=m.values.encrypt||e===`pack`;if(f){let e=s(m.values.key||c.join(__dirname,`../public.pem`)),t=m.values.output||m.values.input.replace(/\.js$/,`-${r.version}.stx`);d(e,m.values.input,t),a(m.values.input)}}else if(e===`decrypt`){let e=s(m.values.key||c.join(__dirname,`../private.pem`)),t=m.values.output||n.replace(/\.stx$/,`.js`);f(e,n,t),a(m.values.input)}else if(e===`dev`||e===`develop`||!e){let e=typeof m.values.minify==`boolean`?m.values.minify:!1;await l({entry:n,format:`cjs`,platform:`node`,target:`node20`,watch:!0,minify:e})}})();
2
+ var e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),t=e(((exports,t)=>{let{readFileSync:n,writeFileSync:r}=require(`node:fs`),{join:i}=require(`node:path`),a=(e,t)=>{let a=n(e,`utf8`),o=t||i(process.cwd(),`package.json`),s=require(o),c=/module\.exports\s*=\s*(\w+)/g,l,u;for(;(l=c.exec(a))!==null;)u=l;if(!u)throw Error(`No module.exports found in source file`);let d=u[1],f=a.replace(/(module\.exports\s*=\s*(\w+))(?![^]*module\.exports\s*=\s*\w+)/,`${d}.package=${JSON.stringify(s)};module.exports = $2`);return r(e,f,`utf8`),{code:f,packageJson:s}};t.exports={injectPackageJson:a}})),n=e(((exports,t)=>{let{createCipheriv:n,createDecipheriv:r,publicEncrypt:i,privateDecrypt:a,randomBytes:o}=require(`node:crypto`),{readFileSync:s,writeFileSync:c}=require(`node:fs`),l=Buffer.from(`STX`,`utf8`),u=(e,t,r)=>{let a=o(32),u=o(16),d=s(t),f=n(`aes-256-cbc`,a,u),p=Buffer.concat([f.update(d),f.final()]),m=i(e,a),h=Buffer.concat([l,u,m,p]);return r&&c(r,h),{aesIv:u,encryptedAesKey:m,encryptedCode:p}},d=(e,t,n)=>{let i=s(t),o=l.byteLength,u=i.subarray(0,o);if(!u.equals(l))throw Error(`Incorrect file format`);let d=o,f=d+16,p=f+512,m=i.subarray(d,f),h=i.subarray(f,p),g=i.subarray(p),_=a(e,h),v=r(`aes-256-cbc`,_,m),y=Buffer.concat([v.update(g),v.final()]),b=y.toString(`utf8`);return n&&c(n,b),b};t.exports={encrypt:u,decrypt:d}})),r=e(((exports,t)=>{let{readFileSync:n,writeFileSync:r}=require(`node:fs`),i=require(`javascript-obfuscator`),a=(e,t)=>{let a=n(e,`utf8`);console.log(`Obfuscating...`),console.time(`Obfuscation complete in`);let o=i.obfuscate(a,{target:`node`,compact:!0,controlFlowFlattening:!0,controlFlowFlatteningThreshold:1,deadCodeInjection:!0,debugProtection:!0,identifierNamesGenerator:`hexadecimal`,numbersToExpressions:!0,selfDefending:!0,simplify:!0,splitStrings:!0,splitStringsChunkLength:5,stringArray:!0,stringArrayCallsTransform:!0,stringArrayCallsTransformThreshold:1,stringArrayEncoding:[`base64`],stringArrayIndexShift:!0,stringArrayRotate:!0,stringArrayShuffle:!0,stringArrayWrappersCount:2,stringArrayWrappersChainedCalls:!0,stringArrayWrappersType:`function`,stringArrayThreshold:1,transformObjectKeys:!0,unicodeEscapeSequence:!1});console.timeEnd(`Obfuscation complete in`);let s=o.getObfuscatedCode();return r(t||e,s),s};t.exports={obfuscate:a}}));const{parseArgs:i}=require(`node:util`),{rmSync:a,readdirSync:o,readFileSync:s}=require(`node:fs`),c=require(`node:path`),{build:l}=require(`tsdown`),{injectPackageJson:u}=t(),{encrypt:d,decrypt:f}=n(),{obfuscate:p}=r(),m=i({allowPositionals:!0,allowNegative:!0,options:{input:{type:`string`,short:`i`,description:`Path to the input file`},key:{type:`string`,short:`k`,description:`Path to the key file (public for encrypt, private for decrypt)`},output:{type:`string`,short:`o`,description:`Path to the output file`},format:{type:`string`,short:`f`,description:`Output format`},watch:{type:`boolean`,description:`Watch file changes`},minify:{type:`boolean`,description:`Minify output`},obfuscate:{type:`boolean`,description:`Obfuscate output`},encrypt:{type:`boolean`,description:`Encrypt extension source code (.js will be packed inside .stx)`},decrypt:{type:`boolean`,description:`Decrypt encrypted extension`}}}),h=()=>{let e=[process.cwd(),c.join(process.cwd(),`src`),c.join(process.cwd(),`lib`)];for(let t of e){let e=o(t),n=e.filter(e=>!e.endsWith(`.d.ts`)).find(e=>new Set([`.ts`,`.js`]).has(c.extname(e)));if(n)return c.join(t,n)}};(async()=>{let[e,...t]=m.positionals,n=m.values.input||t[0]||h();if(e===`build`||e===`pack`){let t=typeof m.values.minify==`boolean`?m.values.minify:!0;await l({entry:n,format:m.values.format??`cjs`,platform:`node`,target:`node22`,watch:m.values.watch,minify:t}),m.values.input=c.join(process.cwd(),`dist`,c.basename(n).replace(/\.ts$/,`.js`));let{packageJson:r}=u(m.values.input),i=typeof m.values.obfuscate==`boolean`,o=i?m.values.obfuscate:r.private;o&&p(m.values.input,m.values.input);let f=m.values.encrypt||e===`pack`;if(f){let e=s(m.values.key||c.join(__dirname,`../public.pem`)),t=m.values.output||m.values.input.replace(/\.js$/,`-${r.version}.stx`);d(e,m.values.input,t),a(m.values.input)}}else if(e===`decrypt`){let e=s(m.values.key||c.join(__dirname,`../private.pem`)),t=m.values.output||n.replace(/\.stx$/,`.js`);f(e,n,t),a(m.values.input)}else if(e===`dev`||e===`develop`||!e){let e=typeof m.values.minify==`boolean`?m.values.minify:!1;await l({entry:n,format:m.values.format??`cjs`,platform:`node`,target:`node20`,watch:!0,minify:e})}})();
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- const e=e=>e,t=`Streamyx`in globalThis?globalThis.Streamyx:{},n=`Azot`in globalThis?globalThis.Azot:{};!globalThis.Azot&&globalThis.Streamyx&&(globalThis.Azot=globalThis.Streamyx),module.exports={defineExtension:e,...t,...n};
1
+ const e=e=>e,t=`Streamyx`in globalThis?globalThis.Streamyx:{},n=`Azot`in globalThis?globalThis.Azot:{};if(!globalThis.Azot&&globalThis.Streamyx&&(globalThis.Azot=globalThis.Streamyx),!globalThis.Azot.input){let e=async(e,t)=>{let n=t?.fields??{answer:{label:e}},r=await globalThis.Azot.prompt.ask({title:t?.title,description:e,fields:n});return r};globalThis.Azot.input=e}module.exports={defineExtension:e,...t,...n};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azot",
3
- "version": "0.9.0-alpha.1",
3
+ "version": "0.9.1",
4
4
  "description": "Build extensions for Azot with Node.js",
5
5
  "homepage": "https://developers.azot.so",
6
6
  "main": "./dist/index.js",
@@ -54,18 +54,18 @@
54
54
  "node": ">=20"
55
55
  },
56
56
  "devDependencies": {
57
- "@eslint/js": "^9.31.0",
58
- "@types/node": "^24.0.14",
57
+ "@eslint/js": "^9.33.0",
58
+ "@types/node": "^24.2.1",
59
59
  "dasha": "^3.1.6",
60
- "eslint": "^9.31.0",
61
- "eslint-config-prettier": "^10.1.5",
62
- "eslint-plugin-prettier": "^5.5.1",
60
+ "eslint": "^9.33.0",
61
+ "eslint-config-prettier": "^10.1.8",
62
+ "eslint-plugin-prettier": "^5.5.4",
63
63
  "globals": "^16.3.0",
64
64
  "prettier": "^3.6.2",
65
- "typescript": "^5.8.3"
65
+ "typescript": "^5.9.2"
66
66
  },
67
67
  "dependencies": {
68
68
  "javascript-obfuscator": "^4.1.1",
69
- "tsdown": "^0.12.9"
69
+ "tsdown": "^0.14.1"
70
70
  }
71
71
  }
package/types/azot.d.ts CHANGED
@@ -25,9 +25,19 @@ declare global {
25
25
  version: string;
26
26
  utils: Common;
27
27
  prompt<T = PromptResponse>(request: PromptRequest): Promise<T>;
28
+
29
+ input<T extends string = 'answer'>(
30
+ message: string,
31
+ options?: DialogOptions<T>,
32
+ ): Promise<Record<T, string>>;
28
33
  }
29
34
  }
30
35
 
36
+ export interface DialogOptions<T extends string> {
37
+ title?: string;
38
+ fields?: Record<T, InputField>;
39
+ }
40
+
31
41
  export type InputType =
32
42
  | 'text'
33
43
  | 'password'
@@ -9,7 +9,10 @@ export interface ExtensionConfig {
9
9
  }
10
10
 
11
11
  export interface Extension {
12
- canHandle?(url: string): boolean | Promise<boolean>;
12
+ /**
13
+ * Can handle URL or URL pattern
14
+ */
15
+ canHandle?: ((url: URL) => boolean | Promise<boolean>) | string;
13
16
 
14
17
  /**
15
18
  * Performs initialization of extension (e.g. token refresh)