Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ jobs:

- name: Run Typescript compiler
run: yarn type-check

- name: Run Prettier
run: yarn format

- name: Run Eslint
run: yarn lint
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
echo "registry=https://registry.npmjs.org/" > .npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc

- run: npm publish --scope=@internxt --access public
- run: npm publish --scope=@internxt --access public
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
unit-tests:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
os: ['ubuntu-latest', 'windows-latest']
runs-on: ${{ matrix.os }}
steps:
- name: Set core.autocrlf to false
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# inxt-js

API and CLI for the Internxt network

## Usage

Soon

## How the project is structurared

```
/src
/cli
/lib
/models
/core
/services
/services
```
16 changes: 8 additions & 8 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
declare namespace NodeJS {
interface ProcessEnv {
BRIDGE_PASS: string;
BRIDGE_USER: string;
BRIDGE_URL: string | undefined;
BUCKET_ID: string;
MNEMONIC:string;
}
}
interface ProcessEnv {
BRIDGE_PASS: string;
BRIDGE_USER: string;
BRIDGE_URL: string | undefined;
BUCKET_ID: string;
MNEMONIC: string;
}
}
2 changes: 2 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export default [
{
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-require-imports': 'off',
'no-console': 'off',
'no-undef': 'off',
},
},
];
3 changes: 1 addition & 2 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"entry": ["src/cli/*.ts"],
"project": ["src/**/*.ts"],
"ignoreDependencies": ["express", "@types/express"],
"project": ["src/**/*.ts", "tests/**/*.ts"],
"rules": {
"enumMembers": "off"
}
Expand Down
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
"scripts": {
"clean": "rimraf dist build coverage",
"build": "yarn clean && tsc -p tsconfig.build.json",
"type-check": "tsc",
"test": "vitest run --coverage",
"test:watch": "vitest watch",
"lint": "eslint ./src",
"lint:fix": "yarn run lint --fix",
"cli": "ts-node --files src/cli/index.ts",
"format": "prettier --write src/**/*.{js,jsx,tsx,ts} tests/**/*.{js,jsx,tsx,ts}",
"========== Code style ==========": "",
"type-check": "tsc",
"lint": "eslint src tests",
"lint:fix": "yarn run lint --fix",
"format": "prettier . --check",
"format:fix": "prettier . --write",
"find-deadcode": "knip",
"prepare": "husky"
},
Expand All @@ -27,13 +29,11 @@
"@internxt/eslint-config-internxt": "^2.1.0",
"@internxt/prettier-config": "^2.0.1",
"@types/async": "=3.2.9",
"@types/express": "^5.0.6",
"@types/node": "^25.6.0",
"@vitest/coverage-istanbul": "^4.1.5",
"commander": "^14.0.3",
"dotenv": "^17.4.2",
"eslint": "^10.3.0",
"express": "^5.2.1",
"husky": "^9.1.7",
"knip": "^6.13.1",
"lint-staged": "^17.0.2",
Expand All @@ -44,7 +44,6 @@
"vitest": "^4.1.5"
},
"dependencies": {
"@internxt/lib": "1.4.2",
"@internxt/sdk": "1.16.2",
"async": "^3.2.6",
"axios": "^1.16.0",
Expand Down
133 changes: 0 additions & 133 deletions src/api/ExchangeReport.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from './ActionState';
export * from './Abortable';
export * from './Bucket';
export * from './EnvironmentConfig';
export * from './ExchangeReport';
export * from './FileObject';
export * from './fileinfo';
export * from './Shard';
21 changes: 2 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { request } from '@internxt/lib';
import {
UploadStrategyFunction,
UploadOptions,
Expand All @@ -11,37 +10,29 @@
Events,
} from './lib/core';

import { EncryptFilename, GenerateFileKey } from './lib/utils/crypto';
import { EncryptFilename } from './lib/utils/crypto';

// TODO: Remove this
import { BUCKET_ID_NOT_PROVIDED, ENCRYPTION_KEY_NOT_PROVIDED } from './api/constants';
import { ActionState, ActionTypes, Bucket, EnvironmentConfig } from './api';

import { FileInfo, GetFileInfo } from './api/fileinfo';
import { Bridge, CreateFileTokenResponse, GetDownloadLinksResponse } from './services/api';
import { HashStream } from './lib/utils/streams';
import { downloadFileV2 } from './lib/core/download/downloadV2';
import { FileVersionOneError } from '@internxt/sdk/dist/network/download';
import { upload as uploadFileV2 } from './lib/core/upload/uploadV2';

type GetBucketsCallback = (err: Error | null, result: any) => void;

Check warning on line 25 in src/index.ts

View workflow job for this annotation

GitHub Actions / checks

Unexpected any. Specify a different type

type GetBucketIdCallback = (err: Error | null, result: any) => void;

Check warning on line 27 in src/index.ts

View workflow job for this annotation

GitHub Actions / checks

Unexpected any. Specify a different type

type ListFilesCallback = (err: Error | null, result: any) => void;

type DeleteFileCallback = (err: Error | null, result: any) => void;

const utils = {
generateFileKey: GenerateFileKey,
Hasher: HashStream,
};

export class Environment {
config: EnvironmentConfig;

static utils = utils;

constructor(config: EnvironmentConfig) {
this.config = config;
}
Expand Down Expand Up @@ -86,9 +77,6 @@
.start<Bucket>()
.then((bucket) => {
return bucket.id;
})
.catch((err) => {
throw new Error(request.extractMessageFromError(err));
});
}

Expand All @@ -114,12 +102,7 @@
* @param cb Callback that will receive the response after deletion
*/
deleteBucket(bucketId: string): Promise<void> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inly used in the cli so we don't really need to parse the error and we can remove the library @internxt/lib.

return new Bridge(this.config)
.deleteBucket(bucketId)
.start<void>()
.catch((err) => {
throw new Error(request.extractMessageFromError(err));
});
return new Bridge(this.config).deleteBucket(bucketId).start<void>();
}

/**
Expand Down
9 changes: 0 additions & 9 deletions src/lib/models/ShardMeta.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/models/index.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/lib/utils/crypto/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ export async function GenerateBucketKey(mnemonic: string, bucketId: string): Pro
return GetDeterministicKey(seed, bucketId).toString('hex').slice(0, 64);
}

// export async function GenerateFileKey(mnemonic: string, bucketId: string, index: Buffer): Promise<Buffer> {
// const bucketKey = await GenerateBucketKey(mnemonic, bucketId);

// return GetDeterministicKey(bucketKey.slice(0, 32), index.toString('hex')).slice(0, 32);
// }

export async function EncryptFilename(mnemonic: string, bucketId: string, filename: string): Promise<string> {
const bucketKey = await GenerateBucketKey(mnemonic, bucketId);

Expand Down
Loading
Loading