@toa.io/extensions.storages 1.0.0-alpha.13 → 1.0.0-alpha.143

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.
Files changed (90) hide show
  1. package/package.json +13 -14
  2. package/readme.md +94 -49
  3. package/schemas/annotation.cos.yaml +1 -0
  4. package/schemas/cloudinary.cos.yaml +30 -0
  5. package/schemas/fs.cos.yaml +2 -0
  6. package/schemas/s3.cos.yaml +1 -0
  7. package/schemas/tmp.cos.yaml +0 -1
  8. package/source/Entry.ts +11 -11
  9. package/source/Factory.ts +16 -9
  10. package/source/Provider.ts +19 -19
  11. package/source/Scanner.ts +57 -24
  12. package/source/Secrets.ts +6 -0
  13. package/source/Storage.test.ts +103 -279
  14. package/source/Storage.ts +55 -204
  15. package/source/deployment.ts +48 -15
  16. package/source/errors.ts +3 -0
  17. package/source/index.ts +1 -1
  18. package/source/manifest.ts +7 -6
  19. package/source/providers/Cloudinary.ts +274 -0
  20. package/source/providers/Declaration.ts +2 -1
  21. package/source/providers/FileSystem.ts +79 -25
  22. package/source/providers/S3.ts +81 -80
  23. package/source/providers/Temporary.ts +2 -3
  24. package/source/providers/Test.ts +4 -4
  25. package/source/providers/index.test.ts +102 -76
  26. package/source/providers/index.ts +9 -4
  27. package/source/schemas.ts +1 -0
  28. package/source/test/.env.example +4 -0
  29. package/source/test/arny.jpg +0 -0
  30. package/source/test/lenna.48x48.jpeg +0 -0
  31. package/source/test/sample.avi +0 -0
  32. package/source/test/sample.svg +4 -0
  33. package/source/test/sample.wav +0 -0
  34. package/source/test/util.ts +54 -12
  35. package/transpiled/Entry.d.ts +12 -10
  36. package/transpiled/Factory.js +11 -5
  37. package/transpiled/Factory.js.map +1 -1
  38. package/transpiled/Provider.d.ts +15 -15
  39. package/transpiled/Provider.js +3 -3
  40. package/transpiled/Provider.js.map +1 -1
  41. package/transpiled/Scanner.d.ts +5 -2
  42. package/transpiled/Scanner.js +49 -22
  43. package/transpiled/Scanner.js.map +1 -1
  44. package/transpiled/Secrets.d.ts +5 -0
  45. package/transpiled/Secrets.js +3 -0
  46. package/transpiled/Secrets.js.map +1 -0
  47. package/transpiled/Storage.d.ts +10 -19
  48. package/transpiled/Storage.js +47 -153
  49. package/transpiled/Storage.js.map +1 -1
  50. package/transpiled/deployment.d.ts +1 -1
  51. package/transpiled/deployment.js +40 -15
  52. package/transpiled/deployment.js.map +1 -1
  53. package/transpiled/errors.d.ts +2 -0
  54. package/transpiled/errors.js +6 -0
  55. package/transpiled/errors.js.map +1 -0
  56. package/transpiled/index.d.ts +1 -1
  57. package/transpiled/manifest.js +5 -2
  58. package/transpiled/manifest.js.map +1 -1
  59. package/transpiled/providers/Cloudinary.d.ts +42 -0
  60. package/transpiled/providers/Cloudinary.js +189 -0
  61. package/transpiled/providers/Cloudinary.js.map +1 -0
  62. package/transpiled/providers/Declaration.d.ts +3 -2
  63. package/transpiled/providers/FileSystem.d.ts +15 -7
  64. package/transpiled/providers/FileSystem.js +64 -24
  65. package/transpiled/providers/FileSystem.js.map +1 -1
  66. package/transpiled/providers/S3.d.ts +14 -14
  67. package/transpiled/providers/S3.js +62 -60
  68. package/transpiled/providers/S3.js.map +1 -1
  69. package/transpiled/providers/Temporary.d.ts +1 -2
  70. package/transpiled/providers/Temporary.js +2 -2
  71. package/transpiled/providers/Temporary.js.map +1 -1
  72. package/transpiled/providers/Test.d.ts +3 -3
  73. package/transpiled/providers/Test.js +2 -2
  74. package/transpiled/providers/Test.js.map +1 -1
  75. package/transpiled/providers/index.d.ts +6 -2
  76. package/transpiled/providers/index.js +2 -2
  77. package/transpiled/providers/index.js.map +1 -1
  78. package/transpiled/schemas.d.ts +1 -0
  79. package/transpiled/schemas.js +2 -1
  80. package/transpiled/schemas.js.map +1 -1
  81. package/transpiled/test/util.d.ts +70 -5
  82. package/transpiled/test/util.js +43 -4
  83. package/transpiled/test/util.js.map +1 -1
  84. package/transpiled/tsconfig.tsbuildinfo +1 -1
  85. package/source/providers/FileSystem.test.ts +0 -5
  86. package/source/providers/Memory.ts +0 -41
  87. package/source/providers/S3.test.ts +0 -133
  88. package/transpiled/providers/Memory.d.ts +0 -13
  89. package/transpiled/providers/Memory.js +0 -60
  90. package/transpiled/providers/Memory.js.map +0 -1
@@ -1,16 +1,21 @@
1
1
  import { FileSystem } from './FileSystem'
2
2
  import { S3 } from './S3'
3
+ import { Cloudinary } from './Cloudinary'
3
4
  import { Temporary } from './Temporary'
4
5
  import { Test } from './Test'
5
- import { InMemory } from './Memory'
6
- import type { ProviderConstructor } from '../Provider'
6
+ import type { Constructor } from '../Provider'
7
7
 
8
8
  export const providers = {
9
9
  s3: S3,
10
+ cloudinary: Cloudinary,
10
11
  fs: FileSystem,
11
12
  tmp: Temporary,
12
- mem: InMemory,
13
13
  test: Test
14
- } as const satisfies Record<string, ProviderConstructor>
14
+ } as const satisfies Record<string, Constructor>
15
15
 
16
16
  export type { Declaration } from './Declaration'
17
+
18
+ export type { S3Options } from './S3'
19
+ export type { CloudinaryOptions } from './Cloudinary'
20
+ export type { FileSystemOptions } from './FileSystem'
21
+ export type { TemporaryOptions } from './Temporary'
package/source/schemas.ts CHANGED
@@ -9,6 +9,7 @@ const ns = namespace(path)
9
9
 
10
10
  export const annotation: Schema<Annotation> = ns.schema<Annotation>('annotation')
11
11
  export const s3: Schema<Declaration> = ns.schema<Declaration>('s3')
12
+ export const cloudinary: Schema<Declaration> = ns.schema<Declaration>('cloudinary')
12
13
  export const fs: Schema<Declaration> = ns.schema<Declaration>('fs')
13
14
  export const mem: Schema<Declaration> = ns.schema<Declaration>('mem')
14
15
  export const tmp: Schema<Declaration> = ns.schema<Declaration>('tmp')
@@ -1 +1,5 @@
1
1
  RUN_S3=1
2
+ RUN_CLOUDINARY=1
3
+
4
+ CLOUDINARY_API_KEY=cloudinary_api_key
5
+ CLOUDINARY_API_SECRET=cloudinary_api_secret
Binary file
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ <svg width="160" height="160" viewBox="0 0 160 160" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="160" height="160" rx="6" fill="white"/>
3
+ <path d="M83.8172 117.311H77.1506V75.6034C76.519 64.0461 71.2424 54.9753 62.4955 50.5487C55.8003 47.163 48.1655 47.3486 43.0436 51.0295C40.1688 53.0962 38.5807 55.5676 38.1898 58.5867C37.3617 64.9771 42.1922 72.4486 44.1231 74.7915L38.9812 79.0344C38.6222 78.5963 30.2131 68.2629 31.5783 57.7295C32.2107 52.8533 34.7593 48.7772 39.1526 45.6153C46.3817 40.42 56.4798 40.0343 65.5055 44.601C72.2494 48.0136 77.4112 53.7335 80.5225 60.9231C83.6337 53.7335 88.7954 48.0137 95.539 44.601C104.566 40.0343 114.664 40.42 121.892 45.6153C126.286 48.7772 128.834 52.8533 129.467 57.7295C130.832 68.2629 122.423 78.5963 122.064 79.0344L116.918 74.7963C116.988 74.7106 123.858 66.2201 122.853 58.5677C122.457 55.5582 120.87 53.0914 118.001 51.0295C112.879 47.3486 105.244 47.1582 98.5495 50.5487C89.5949 55.0803 84.2775 64.4793 83.8573 76.4304C83.8678 76.7653 83.8748 77.1016 83.8783 77.4392L83.8335 77.4396C83.8333 77.4617 83.833 77.4837 83.8328 77.5058L83.8172 77.5056V117.311Z" fill="#323232"/>
4
+ </svg>
Binary file
@@ -1,10 +1,13 @@
1
1
  import { join } from 'node:path'
2
2
  import dotenv from 'dotenv'
3
- import type { ProviderSecrets } from '../Provider'
4
- import type { providers } from '../providers'
5
- import type { FileSystemOptions } from '../providers/FileSystem'
6
- import type { S3Options } from '../providers/S3'
7
- import type { TemporaryOptions } from '../providers/Temporary'
3
+ import type { Secrets } from '../Secrets'
4
+ import type {
5
+ providers,
6
+ S3Options,
7
+ CloudinaryOptions,
8
+ FileSystemOptions,
9
+ TemporaryOptions
10
+ } from '../providers'
8
11
 
9
12
  dotenv.config({ path: join(__dirname, '.env') })
10
13
 
@@ -16,10 +19,6 @@ export const suites = [
16
19
  directory: 'toa-storages-temp'
17
20
  }
18
21
  },
19
- {
20
- run: true,
21
- provider: 'mem'
22
- },
23
22
  {
24
23
  run: process.env.RUN_S3 === '1',
25
24
  provider: 's3',
@@ -32,14 +31,57 @@ export const suites = [
32
31
  ACCESS_KEY_ID: 'developer',
33
32
  SECRET_ACCESS_KEY: 'secret'
34
33
  }
34
+ },
35
+ {
36
+ run: process.env.RUN_CLOUDINARY === '1',
37
+ provider: 'cloudinary',
38
+ options: {
39
+ environment: 'dl5z4zgth',
40
+ type: 'image',
41
+ prefix: 'toa-dev',
42
+ transformations: [
43
+ {
44
+ extension: '(?<width>\\d*)x(?<height>\\d*)(z(?<zoom>\\d*))?',
45
+ transformation: {
46
+ width: '<width>',
47
+ height: '<height>',
48
+ zoom: '<zoom>',
49
+ crop: 'thumb',
50
+ gravity: 'face'
51
+ },
52
+ optional: true
53
+ },
54
+ {
55
+ extension: '\\[(?<width>\\d*)x(?<height>\\d*)\\](z(?<zoom>\\d+))?',
56
+ transformation: {
57
+ width: '<width>',
58
+ height: '<height>',
59
+ zoom: '<zoom>',
60
+ crop: 'fit'
61
+ },
62
+ optional: true
63
+ },
64
+ {
65
+ extension: '(?<format>jpeg|webp)',
66
+ transformation: {
67
+ fetch_format: '<format>'
68
+ },
69
+ optional: true
70
+ }
71
+ ]
72
+ },
73
+ secrets: {
74
+ API_KEY: process.env.CLOUDINARY_API_KEY ?? '',
75
+ API_SECRET: process.env.CLOUDINARY_API_SECRET ?? ''
76
+ }
35
77
  }
36
78
  // add more providers here, use `run` as a condition to run the test
37
79
  // e.g.: `run: process.env.ACCESS_KEY_ID !== undefined`
38
80
  ] satisfies Suite[]
39
81
 
40
- interface Suite {
82
+ export interface Suite {
41
83
  run: boolean
42
84
  provider: keyof typeof providers
43
- options?: FileSystemOptions | S3Options | TemporaryOptions
44
- secrets?: ProviderSecrets
85
+ options?: S3Options | CloudinaryOptions | FileSystemOptions | TemporaryOptions
86
+ secrets?: Secrets
45
87
  }
@@ -1,14 +1,16 @@
1
- export interface Entry {
1
+ /// <reference types="node" />
2
+ import type { Readable } from 'node:stream';
3
+ export type Entry = {
2
4
  id: string;
3
- size: number;
5
+ } & Metadata;
6
+ export type Stream = {
7
+ stream: Readable;
8
+ } & Metadata;
9
+ export interface Metadata {
4
10
  type: string;
5
- created: number;
6
- variants: Variant[];
7
- meta: Record<string, unknown>;
8
- }
9
- interface Variant {
10
- name: string;
11
11
  size: number;
12
- type: string;
12
+ checksum: string;
13
+ created: string;
14
+ attributes: Attributes;
13
15
  }
14
- export {};
16
+ export type Attributes = Record<string, string>;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Factory = void 0;
7
7
  const node_assert_1 = __importDefault(require("node:assert"));
8
+ const openspan_1 = require("openspan");
8
9
  const generic_1 = require("@toa.io/generic");
9
10
  const providers_1 = require("./providers");
10
11
  const Storage_1 = require("./Storage");
@@ -14,8 +15,8 @@ const Annotation_1 = require("./Annotation");
14
15
  class Factory {
15
16
  annotation;
16
17
  constructor() {
17
- const env = process.env.TOA_STORAGES;
18
- node_assert_1.default.ok(env !== undefined, 'TOA_STORAGES is not defined');
18
+ const env = process.env[deployment_1.ENV_PREFIX];
19
+ node_assert_1.default.ok(env !== undefined, `${deployment_1.ENV_PREFIX} is not defined`);
19
20
  this.annotation = (0, generic_1.decode)(env);
20
21
  (0, Annotation_1.validateAnnotation)(this.annotation);
21
22
  }
@@ -30,10 +31,15 @@ class Factory {
30
31
  return storages;
31
32
  }
32
33
  createStorage(name, declaration) {
33
- const { provider: providerId, ...options } = declaration;
34
- const Provider = providers_1.providers[providerId];
34
+ const { provider: id, ...options } = declaration;
35
+ const Provider = providers_1.providers[id];
35
36
  const secrets = this.resolveSecrets(name, Provider);
36
37
  const provider = new Provider(options, secrets);
38
+ openspan_1.console.debug('Storage created', {
39
+ name,
40
+ provider: id,
41
+ ...(provider.root === undefined ? undefined : { root: provider.root })
42
+ });
37
43
  return new Storage_1.Storage(provider);
38
44
  }
39
45
  resolveSecrets(storageName, Class) {
@@ -41,7 +47,7 @@ class Factory {
41
47
  return {};
42
48
  const secrets = {};
43
49
  for (const secret of Class.SECRETS) {
44
- const variable = `${deployment_1.SERIALIZATION_PREFIX}_${storageName}_${secret.name}`.toUpperCase();
50
+ const variable = `${deployment_1.ENV_PREFIX}_${storageName}_${secret.name}`.toUpperCase();
45
51
  const value = process.env[variable];
46
52
  node_assert_1.default.ok(secret.optional === true || value !== undefined, `'${variable}' is not defined`);
47
53
  secrets[secret.name] = value;
@@ -1 +1 @@
1
- {"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAChC,6CAAwC;AACxC,2CAAuC;AACvC,uCAAkD;AAClD,qCAAiC;AACjC,6CAAmD;AACnD,6CAAiD;AAKjD,MAAa,OAAO;IACD,UAAU,CAAY;IAEvC;QACE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;QAEpC,qBAAM,CAAC,EAAE,CAAC,GAAG,KAAK,SAAS,EAAE,6BAA6B,CAAC,CAAA;QAE3D,IAAI,CAAC,UAAU,GAAG,IAAA,gBAAM,EAAC,GAAG,CAAC,CAAA;QAE7B,IAAA,+BAAkB,EAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC;IAEM,MAAM;QACX,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;QAEtC,OAAO,IAAI,eAAM,CAAC,QAAQ,CAAC,CAAA;IAC7B,CAAC;IAEO,cAAc;QACpB,MAAM,QAAQ,GAAa,EAAE,CAAA;QAE7B,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;YAC/D,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QAExD,OAAO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,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;SACvE,CAAC,CAAA;QAEF,OAAO,IAAI,iBAAO,CAAC,QAAQ,CAAC,CAAA;IAC9B,CAAC;IAEO,cAAc,CAAE,WAAmB,EAAE,KAAkB;QAC7D,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;YAC7B,OAAO,EAAE,CAAA;QAEX,MAAM,OAAO,GAAuC,EAAE,CAAA;QAEtD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YACnC,MAAM,QAAQ,GAAG,GAAG,uBAAU,IAAI,WAAW,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;YAC5E,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAEnC,qBAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EACvD,IAAI,QAAQ,kBAAkB,CAAC,CAAA;YAEjC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;QAC9B,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA7DD,0BA6DC"}
@@ -1,20 +1,20 @@
1
1
  /// <reference types="node" />
2
- import { type Readable } from 'node:stream';
3
- export type ProviderSecrets<K extends string = string> = Record<K | string, string | undefined>;
4
- export interface ProviderSecret {
5
- readonly name: string;
6
- readonly optional?: boolean;
7
- }
2
+ import type { Metadata, Stream } from './Entry';
3
+ import type { Readable } from 'node:stream';
4
+ import type { Maybe } from '@toa.io/types';
5
+ import type { Secret, Secrets } from './Secrets';
8
6
  export declare abstract class Provider<Options = void> {
9
- static readonly SECRETS: readonly ProviderSecret[];
10
- constructor(_: Options, secrets?: ProviderSecrets);
11
- abstract get(path: string): Promise<Readable | null>;
12
- abstract put(path: string, filename: string, stream: Readable): Promise<void>;
7
+ static readonly SECRETS?: readonly Secret[];
8
+ readonly root?: string;
9
+ protected constructor(_: Options, secrets?: Secrets);
10
+ abstract get(path: string): Promise<Maybe<Stream>>;
11
+ abstract head(path: string): Promise<Maybe<Metadata>>;
12
+ abstract put(path: string, stream: Readable): Promise<void>;
13
+ abstract commit(path: string, metadata: Metadata): Promise<void>;
13
14
  abstract delete(path: string): Promise<void>;
14
- abstract move(from: string, to: string): Promise<void>;
15
+ abstract move(from: string, to: string): Promise<Maybe<void>>;
15
16
  }
16
- export interface ProviderConstructor {
17
- readonly SECRETS: readonly ProviderSecret[];
18
- prototype: Provider;
19
- new (options: any, secrets?: ProviderSecrets): Provider;
17
+ export interface Constructor {
18
+ SECRETS?: readonly Secret[];
19
+ new (options: any, secrets?: Secrets): Provider;
20
20
  }
@@ -26,10 +26,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Provider = void 0;
27
27
  const assert = __importStar(require("node:assert"));
28
28
  class Provider {
29
- static SECRETS = [];
29
+ static SECRETS;
30
+ root;
30
31
  constructor(_, secrets) {
31
- for (const { name, optional = false } of new.target.SECRETS)
32
- assert.ok(optional || secrets?.[name] !== undefined, `Missing secret '${name}'`);
32
+ new.target.SECRETS?.forEach(({ name, optional }) => assert.ok(optional === true || secrets?.[name] !== undefined, `Missing secret '${name}'`));
33
33
  }
34
34
  }
35
35
  exports.Provider = Provider;
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.js","sourceRoot":"","sources":["../source/Provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAqC;AASrC,MAAsB,QAAQ;IACrB,MAAM,CAAU,OAAO,GAA8B,EAAE,CAAA;IAE9D,YAAoB,CAAU,EAAE,OAAyB;QACvD,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO;YACzD,MAAM,CAAC,EAAE,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,mBAAmB,IAAI,GAAG,CAAC,CAAA;IACpF,CAAC;;AANH,4BAeC"}
1
+ {"version":3,"file":"Provider.js","sourceRoot":"","sources":["../source/Provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AAMrC,MAAsB,QAAQ;IACrB,MAAM,CAAU,OAAO,CAAoB;IAClC,IAAI,CAAS;IAE7B,YAAuB,CAAU,EAAE,OAAiB;QAClD,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CACjD,MAAM,CAAC,EAAE,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,mBAAmB,IAAI,GAAG,CAAC,CAAC,CAAA;IAC9F,CAAC;CAaF;AApBD,4BAoBC"}
@@ -4,12 +4,13 @@ import { PassThrough, type TransformCallback } from 'node:stream';
4
4
  export declare class Scanner extends PassThrough {
5
5
  size: number;
6
6
  type: string;
7
- error: Error | null;
7
+ error?: Error;
8
8
  private readonly hash;
9
9
  private readonly claim?;
10
10
  private readonly accept?;
11
+ private readonly limit?;
11
12
  private position;
12
- private detected;
13
+ private completed;
13
14
  private readonly chunks;
14
15
  constructor(control?: ScanOptions);
15
16
  digest(): string;
@@ -18,9 +19,11 @@ export declare class Scanner extends PassThrough {
18
19
  private complete;
19
20
  private verify;
20
21
  private match;
22
+ private negotiate;
21
23
  private interrupt;
22
24
  }
23
25
  export interface ScanOptions {
24
26
  claim?: string;
25
27
  accept?: string;
28
+ limit?: number;
26
29
  }
@@ -1,24 +1,29 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.Scanner = void 0;
4
7
  const node_stream_1 = require("node:stream");
5
8
  const node_crypto_1 = require("node:crypto");
6
- const agent_1 = require("@toa.io/agent");
7
9
  const error_value_1 = require("error-value");
10
+ const negotiator_1 = __importDefault(require("negotiator"));
8
11
  class Scanner extends node_stream_1.PassThrough {
9
12
  size = 0;
10
13
  type = 'application/octet-stream';
11
- error = null;
14
+ error;
12
15
  hash = (0, node_crypto_1.createHash)('md5');
13
16
  claim;
14
17
  accept;
18
+ limit;
15
19
  position = 0;
16
- detected = false;
20
+ completed = false;
17
21
  chunks = [];
18
22
  constructor(control) {
19
23
  super();
20
24
  this.claim = control?.claim;
21
25
  this.accept = control?.accept;
26
+ this.limit = control?.limit;
22
27
  }
23
28
  digest() {
24
29
  return this.hash.digest('hex');
@@ -30,7 +35,7 @@ class Scanner extends node_stream_1.PassThrough {
30
35
  process = (buffer) => {
31
36
  this.size += buffer.length;
32
37
  this.hash.update(buffer);
33
- if (this.detected)
38
+ if (this.completed)
34
39
  return;
35
40
  if (this.position + buffer.length > HEADER_SIZE)
36
41
  buffer = buffer.subarray(0, HEADER_SIZE - this.position);
@@ -38,18 +43,25 @@ class Scanner extends node_stream_1.PassThrough {
38
43
  this.position += buffer.length;
39
44
  if (this.position === HEADER_SIZE)
40
45
  this.complete();
46
+ if (this.limit !== undefined && this.size > this.limit)
47
+ this.interrupt(ERR_LIMIT_EXCEEDED);
41
48
  };
42
49
  complete() {
43
50
  const header = Buffer.concat(this.chunks).toString('hex');
44
51
  const signature = SIGNATURES
45
- .find(({ hex, off }) => header.slice(off, off + hex.length) === hex);
52
+ .find(({ off, hex, expression }) => {
53
+ const sig = header.slice(off, off + hex.length);
54
+ return expression === undefined
55
+ ? sig === hex
56
+ : expression.test(sig);
57
+ });
46
58
  const type = signature?.type ?? this.claim;
47
59
  if (type !== undefined) {
48
60
  this.match(type);
49
61
  this.type = type;
50
62
  }
51
63
  this.verify(signature);
52
- this.detected = true;
64
+ this.completed = true;
53
65
  }
54
66
  verify(signature) {
55
67
  if (this.claim === undefined || this.claim === 'application/octet-stream')
@@ -63,36 +75,51 @@ class Scanner extends node_stream_1.PassThrough {
63
75
  match(type) {
64
76
  if (this.accept === undefined)
65
77
  return;
66
- const unacceptable = (0, agent_1.negotiate)(this.accept, [type]) === null;
78
+ const unacceptable = this.negotiate(this.accept, [type]) === null;
67
79
  if (unacceptable)
68
80
  this.interrupt(ERR_NOT_ACCEPTABLE);
69
81
  }
82
+ negotiate(accept, type) {
83
+ return new negotiator_1.default({ headers: { accept } }).mediaType(type) ?? null;
84
+ }
70
85
  interrupt(error) {
86
+ this.completed = true;
71
87
  this.error = error;
72
- this.end();
88
+ this.destroy(error);
73
89
  }
74
90
  }
75
91
  exports.Scanner = Scanner;
76
92
  // https://en.wikipedia.org/wiki/List_of_file_signatures
77
93
  const SIGNATURES = [
78
- { hex: 'ffd8ffe0', off: 0, type: 'image/jpeg' },
79
- { hex: 'ffd8ffe1', off: 0, type: 'image/jpeg' },
80
- { hex: 'ffd8ffee', off: 0, type: 'image/jpeg' },
81
- { hex: 'ffd8ffdb', off: 0, type: 'image/jpeg' },
82
- { hex: '89504e47', off: 0, type: 'image/png' },
83
- { hex: '47494638', off: 0, type: 'image/gif' },
84
- { hex: '52494646', off: 0, type: 'image/webp' },
85
- { hex: '4a584c200d0a870a', off: 8, type: 'image/jxl' },
86
- { hex: '6674797068656963', off: 8, type: 'image/heic' },
87
- { hex: '6674797061766966', off: 8, type: 'image/avif' }
94
+ { hex: 'ff d8 ff e0', off: 0, type: 'image/jpeg' },
95
+ { hex: 'ff d8 ff e1', off: 0, type: 'image/jpeg' },
96
+ { hex: 'ff d8 ff e2', off: 0, type: 'image/jpeg' },
97
+ { hex: 'ff d8 ff ee', off: 0, type: 'image/jpeg' },
98
+ { hex: 'ff d8 ff db', off: 0, type: 'image/jpeg' },
99
+ { hex: '89 50 4e 47', off: 0, type: 'image/png' },
100
+ { hex: '47 49 46 38', off: 0, type: 'image/gif' },
101
+ { hex: '52 49 46 46 ?? ?? ?? ?? 57 45 42 50', off: 0, type: 'image/webp' },
102
+ { hex: '4a 58 4c 20 0d 0a 87 0a', off: 8, type: 'image/jxl' },
103
+ { hex: '66 74 79 70 68 65 69 63', off: 8, type: 'image/heic' },
104
+ { hex: '66 74 79 70 61 76 69 66', off: 8, type: 'image/avif' },
105
+ { hex: '52 49 46 46 ?? ?? ?? ?? 41 56 49 20', off: 0, type: 'video/avi' },
106
+ { hex: '52 49 46 46 ?? ?? ?? ?? 57 41 56 45', off: 0, type: 'audio/wav' }
88
107
  /*
89
108
  When adding a new signature, include a copyright-free sample file in the `.tests` directory
90
- and update the 'signatures' test group in `Storage.test.ts`.
109
+ and update the `signatures` test group in `Storage.test.ts`.
91
110
  */
92
- ];
111
+ ].map((signature) => {
112
+ signature.hex = signature.hex.replaceAll(' ', '');
113
+ if (signature.hex.includes('??')) {
114
+ const expression = signature.hex.replaceAll(/(?<wildcards>\?{1,24})/g, (_, wildcards) => `[0-9a-f]{${wildcards.length}}`);
115
+ signature.expression = new RegExp(expression, 'i');
116
+ }
117
+ return signature;
118
+ });
93
119
  const HEADER_SIZE = SIGNATURES
94
120
  .reduce((max, { off, hex }) => Math.max(max, off + hex.length), 0) / 2;
95
121
  const KNOWN_TYPES = new Set(SIGNATURES.map(({ type }) => type));
96
- const ERR_TYPE_MISMATCH = (0, error_value_1.Err)('TYPE_MISMATCH');
97
- const ERR_NOT_ACCEPTABLE = (0, error_value_1.Err)('NOT_ACCEPTABLE');
122
+ const ERR_TYPE_MISMATCH = new error_value_1.Err('TYPE_MISMATCH');
123
+ const ERR_NOT_ACCEPTABLE = new error_value_1.Err('NOT_ACCEPTABLE');
124
+ const ERR_LIMIT_EXCEEDED = new error_value_1.Err('LIMIT_EXCEEDED');
98
125
  //# sourceMappingURL=Scanner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scanner.js","sourceRoot":"","sources":["../source/Scanner.ts"],"names":[],"mappings":";;;AAAA,6CAAiE;AACjE,6CAAwC;AACxC,yCAAy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CAAC,CAAA;AACpD,MAAM,kBAAkB,GAAG,IAAI,iBAAG,CAAC,gBAAgB,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ export type Secrets<K extends string = string> = Record<K | string, string | undefined>;
2
+ export interface Secret {
3
+ readonly name: string;
4
+ readonly optional?: boolean;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Secrets.js","sourceRoot":"","sources":["../source/Secrets.ts"],"names":[],"mappings":""}
@@ -1,32 +1,23 @@
1
1
  /// <reference types="node" />
2
- import { Readable } from 'node:stream';
2
+ import type { Readable } from 'node:stream';
3
+ import type { Attributes, Entry, Stream } from './Entry';
3
4
  import type { ScanOptions } from './Scanner';
4
5
  import type { Provider } from './Provider';
5
- import type { Entry } from './Entry';
6
6
  export declare class Storage {
7
7
  private readonly provider;
8
8
  constructor(provider: Provider);
9
9
  put(path: string, stream: Readable, options?: Options): Maybe<Entry>;
10
- get(path: string): Maybe<Entry>;
11
- fetch(path: string): Maybe<Readable>;
10
+ get(path: string): Maybe<Stream>;
11
+ head(path: string): Promise<Maybe<Entry>>;
12
12
  delete(path: string): Maybe<void>;
13
- list(path: string): Promise<string[]>;
14
- permute(path: string, ids: string[]): Maybe<void>;
15
- conceal(path: string): Maybe<void>;
16
- reveal(path: string): Maybe<void>;
17
- diversify(path: string, name: string, stream: Readable): Maybe<void>;
18
- annotate(path: string, key: string, value?: unknown): Maybe<void>;
19
- private transit;
20
- private persist;
21
- private create;
22
- private save;
23
- private enroll;
24
- private parse;
13
+ path(): string | null;
14
+ private locate;
25
15
  }
26
- type Maybe<T> = Promise<T | Error>;
27
- type Meta = Record<string, string>;
28
16
  interface Options extends ScanOptions {
29
- meta?: Meta;
17
+ id?: string;
18
+ origin?: string;
19
+ attributes?: Attributes;
30
20
  }
21
+ type Maybe<T> = Promise<T | Error>;
31
22
  export type Storages = Record<string, Storage>;
32
23
  export {};