@deliverart/sdk-js-authentication 0.0.2 → 1.1.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.
package/package.json CHANGED
@@ -1,43 +1,30 @@
1
1
  {
2
2
  "name": "@deliverart/sdk-js-authentication",
3
3
  "description": "Authentication module for DeliverArt SDK",
4
- "version": "0.0.2",
4
+ "version": "1.1.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "tsup": {
9
+ "tsconfig": "./tsconfig.json"
10
+ },
8
11
  "exports": {
9
12
  ".": {
10
13
  "import": "./dist/index.js",
11
14
  "require": "./dist/index.cjs"
12
15
  }
13
16
  },
17
+ "files": [
18
+ "dist"
19
+ ],
14
20
  "dependencies": {
15
- "@deliverart/sdk-js-core": "0.1.4"
16
- },
17
- "devDependencies": {
18
- "@changesets/cli": "^2.29.4",
19
- "@eslint/js": "9.28.0",
20
- "@types/node": "22.15.30",
21
- "@typescript-eslint/eslint-plugin": "8.33.1",
22
- "@typescript-eslint/parser": "8.33.1",
23
- "eslint": "9.28.0",
24
- "eslint-config-prettier": "10.1.5",
25
- "eslint-plugin-simple-import-sort": "12.1.1",
26
- "prettier": "3.5.3",
27
- "tsup": "8.5.0",
28
- "typescript": "5.8.3"
21
+ "@deliverart/sdk-js-core": "1.1.0"
29
22
  },
30
23
  "publishConfig": {
31
24
  "access": "public"
32
25
  },
33
26
  "scripts": {
34
27
  "build": "tsup src/index.ts --dts --format esm,cjs",
35
- "dev": "tsup src/index.ts --dts --watch",
36
- "lint": "eslint .",
37
- "lint:fix": "eslint . --fix",
38
- "prettier": "prettier --check .",
39
- "prettier:fix": "prettier --write .",
40
- "version": "@changesets/cli version",
41
- "release": "@changesets/cli publish"
28
+ "dev": "tsup src/index.ts --dts --watch"
42
29
  }
43
30
  }
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3
- "changelog": "@changesets/cli/changelog",
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "restricted",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "patch",
10
- "ignore": []
11
- }
@@ -1,47 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- permissions:
9
- contents: write
10
-
11
- jobs:
12
- release:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v4
16
-
17
- - uses: pnpm/action-setup@v2
18
- with:
19
- version: 8
20
-
21
- - uses: actions/setup-node@v4
22
- with:
23
- node-version: '20'
24
- registry-url: 'https://registry.npmjs.org'
25
- always-auth: true
26
- env:
27
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28
-
29
- - name: Install deps
30
- run: pnpm install
31
-
32
- - name: Build
33
- run: pnpm build
34
-
35
- - name: Create version and changelog
36
- run: pnpx @changesets/cli version
37
-
38
- - name: Publish to NPM
39
- run: pnpx @changesets/cli publish
40
- env:
41
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42
-
43
- - name: Push updated versions and changelogs
44
- uses: EndBug/add-and-commit@v9
45
- with:
46
- message: 'chore(release): version bump'
47
- add: '.'
package/.prettierrc DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "semi": false,
3
- "singleQuote": true,
4
- "printWidth": 100,
5
- "trailingComma": "all",
6
- "arrowParens": "avoid"
7
- }
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- # @deliverart/sdk-js-authentication
2
-
3
- ## 0.0.2
4
-
5
- ### Patch Changes
6
-
7
- - 8803bd3: Ignore lock
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # sdk-js-authentication
2
-
3
- Authentication plugin for SDK
package/dist/index.cjs DELETED
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- AuthenticationError: () => AuthenticationError,
24
- AuthenticationPlugin: () => AuthenticationPlugin
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
- // src/errors.ts
29
- var AuthenticationError = class extends Error {
30
- constructor(message = "Authentication failed") {
31
- super(message);
32
- this.name = "AuthenticationError";
33
- }
34
- };
35
-
36
- // src/plugin.ts
37
- var AuthenticationPlugin = class {
38
- config;
39
- enabled = true;
40
- constructor(config) {
41
- this.config = config;
42
- }
43
- setup(client) {
44
- client.http.interceptors.request.use(async (config) => {
45
- if (!this.enabled) {
46
- return config;
47
- }
48
- const token = await this.config.getAccessToken();
49
- if (!token) {
50
- throw new AuthenticationError("No access token found. Please authenticate first.");
51
- }
52
- config.headers.Authorization = `Bearer ${token}`;
53
- return config;
54
- });
55
- return {
56
- authentication: {
57
- enable: () => {
58
- this.enabled = true;
59
- },
60
- disable: () => {
61
- this.enabled = false;
62
- }
63
- }
64
- };
65
- }
66
- };
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- AuthenticationError,
70
- AuthenticationPlugin
71
- });
package/dist/index.d.cts DELETED
@@ -1,24 +0,0 @@
1
- import { ApiExtension, ApiClientPlugin, ApiClient } from '@deliverart/sdk-js-core';
2
-
3
- declare class AuthenticationError extends Error {
4
- constructor(message?: string);
5
- }
6
-
7
- interface AuthenticationConfig {
8
- getAccessToken: () => Promise<string | null>;
9
- }
10
- interface AuthenticationExtension extends ApiExtension {
11
- authentication: {
12
- enable: () => void;
13
- disable: () => void;
14
- };
15
- }
16
-
17
- declare class AuthenticationPlugin implements ApiClientPlugin<AuthenticationExtension> {
18
- private readonly config;
19
- private enabled;
20
- constructor(config: AuthenticationConfig);
21
- setup(client: ApiClient): AuthenticationExtension;
22
- }
23
-
24
- export { type AuthenticationConfig, AuthenticationError, type AuthenticationExtension, AuthenticationPlugin };
package/dist/index.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import { ApiExtension, ApiClientPlugin, ApiClient } from '@deliverart/sdk-js-core';
2
-
3
- declare class AuthenticationError extends Error {
4
- constructor(message?: string);
5
- }
6
-
7
- interface AuthenticationConfig {
8
- getAccessToken: () => Promise<string | null>;
9
- }
10
- interface AuthenticationExtension extends ApiExtension {
11
- authentication: {
12
- enable: () => void;
13
- disable: () => void;
14
- };
15
- }
16
-
17
- declare class AuthenticationPlugin implements ApiClientPlugin<AuthenticationExtension> {
18
- private readonly config;
19
- private enabled;
20
- constructor(config: AuthenticationConfig);
21
- setup(client: ApiClient): AuthenticationExtension;
22
- }
23
-
24
- export { type AuthenticationConfig, AuthenticationError, type AuthenticationExtension, AuthenticationPlugin };
package/dist/index.js DELETED
@@ -1,43 +0,0 @@
1
- // src/errors.ts
2
- var AuthenticationError = class extends Error {
3
- constructor(message = "Authentication failed") {
4
- super(message);
5
- this.name = "AuthenticationError";
6
- }
7
- };
8
-
9
- // src/plugin.ts
10
- var AuthenticationPlugin = class {
11
- config;
12
- enabled = true;
13
- constructor(config) {
14
- this.config = config;
15
- }
16
- setup(client) {
17
- client.http.interceptors.request.use(async (config) => {
18
- if (!this.enabled) {
19
- return config;
20
- }
21
- const token = await this.config.getAccessToken();
22
- if (!token) {
23
- throw new AuthenticationError("No access token found. Please authenticate first.");
24
- }
25
- config.headers.Authorization = `Bearer ${token}`;
26
- return config;
27
- });
28
- return {
29
- authentication: {
30
- enable: () => {
31
- this.enabled = true;
32
- },
33
- disable: () => {
34
- this.enabled = false;
35
- }
36
- }
37
- };
38
- }
39
- };
40
- export {
41
- AuthenticationError,
42
- AuthenticationPlugin
43
- };
package/eslint.config.js DELETED
@@ -1,37 +0,0 @@
1
- /* eslint-disable */
2
- // eslint.config.js per @typescript-eslint v8
3
- import js from '@eslint/js'
4
- import prettier from 'eslint-config-prettier'
5
- import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort'
6
- import tsPlugin from '@typescript-eslint/eslint-plugin'
7
- import tsParser from '@typescript-eslint/parser'
8
-
9
- export default [
10
- js.configs.recommended,
11
- {
12
- files: ['**/*.ts'],
13
- languageOptions: {
14
- parser: tsParser,
15
- globals: {
16
- process: 'readonly',
17
- },
18
- parserOptions: {
19
- project: ['./tsconfig.json'],
20
- tsconfigRootDir: process.cwd(),
21
- sourceType: 'module',
22
- },
23
- },
24
- plugins: {
25
- '@typescript-eslint': tsPlugin,
26
- 'simple-import-sort': simpleImportSortPlugin,
27
- },
28
- rules: {
29
- 'simple-import-sort/imports': 'error',
30
- 'simple-import-sort/exports': 'error',
31
- '@typescript-eslint/no-unused-vars': 'warn',
32
- },
33
- },
34
- prettier,
35
- ]
36
-
37
- export const ignores = ['dist', 'node_modules']
package/src/errors.ts DELETED
@@ -1,6 +0,0 @@
1
- export class AuthenticationError extends Error {
2
- constructor(message = 'Authentication failed') {
3
- super(message)
4
- this.name = 'AuthenticationError'
5
- }
6
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './errors'
2
- export * from './plugin'
3
- export * from './types'
package/src/plugin.ts DELETED
@@ -1,38 +0,0 @@
1
- import { type ApiClient, type ApiClientPlugin } from '@deliverart/sdk-js-core'
2
-
3
- import { AuthenticationError } from './errors'
4
- import { type AuthenticationConfig, type AuthenticationExtension } from './types'
5
-
6
- export class AuthenticationPlugin implements ApiClientPlugin<AuthenticationExtension> {
7
- private readonly config: AuthenticationConfig
8
- private enabled = true
9
-
10
- constructor(config: AuthenticationConfig) {
11
- this.config = config
12
- }
13
-
14
- setup(client: ApiClient): AuthenticationExtension {
15
- client.http.interceptors.request.use(async config => {
16
- if (!this.enabled) {
17
- return config
18
- }
19
- const token = await this.config.getAccessToken()
20
- if (!token) {
21
- throw new AuthenticationError('No access token found. Please authenticate first.')
22
- }
23
- config.headers.Authorization = `Bearer ${token}`
24
- return config
25
- })
26
-
27
- return {
28
- authentication: {
29
- enable: () => {
30
- this.enabled = true
31
- },
32
- disable: () => {
33
- this.enabled = false
34
- },
35
- },
36
- }
37
- }
38
- }
package/src/types.ts DELETED
@@ -1,12 +0,0 @@
1
- import { type ApiExtension } from '@deliverart/sdk-js-core'
2
-
3
- export interface AuthenticationConfig {
4
- getAccessToken: () => Promise<string | null>
5
- }
6
-
7
- export interface AuthenticationExtension extends ApiExtension {
8
- authentication: {
9
- enable: () => void
10
- disable: () => void
11
- }
12
- }
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "Node",
6
- "esModuleInterop": true,
7
- "forceConsistentCasingInFileNames": true,
8
- "strict": true,
9
- "skipLibCheck": true,
10
- "outDir": "dist",
11
- "declaration": true,
12
- "declarationMap": true
13
- },
14
- "include": ["src"]
15
- }