@naylence/runtime 0.3.5-test.6 → 0.3.5-test.8

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StorageProfileFactory = void 0;
4
+ exports.registerStorageProfile = registerStorageProfile;
4
5
  const zod_1 = require("zod");
5
6
  const factory_1 = require("@naylence/factory");
6
7
  const storage_provider_factory_js_1 = require("./storage-provider-factory.js");
@@ -8,6 +9,7 @@ const ENV_VAR_STORAGE_DB_DIRECTORY = 'FAME_STORAGE_DB_DIRECTORY';
8
9
  const ENV_VAR_STORAGE_MASTER_KEY = 'FAME_STORAGE_MASTER_KEY';
9
10
  const ENV_VAR_STORAGE_ENCRYPTED = 'FAME_STORAGE_ENCRYPTED';
10
11
  const PROFILE_NAME_MEMORY = 'memory';
12
+ const PROFILE_NAME_INDEXEDDB = 'indexeddb';
11
13
  const PROFILE_NAME_SQLITE = 'sqlite';
12
14
  const PROFILE_NAME_ENCRYPTED_SQLITE = 'encrypted-sqlite';
13
15
  const storageProfileSchema = zod_1.z
@@ -16,12 +18,15 @@ const storageProfileSchema = zod_1.z
16
18
  profile: zod_1.z
17
19
  .string()
18
20
  .optional()
19
- .describe('Storage profile name (memory | sqlite | encrypted-sqlite)'),
21
+ .describe('Storage profile name (memory | indexeddb | sqlite | encrypted-sqlite)'),
20
22
  })
21
23
  .passthrough();
22
24
  const MEMORY_PROFILE_CONFIG = {
23
25
  type: 'InMemoryStorageProvider',
24
26
  };
27
+ const INDEXEDDB_PROFILE_CONFIG = {
28
+ type: 'IndexedDBStorageProvider',
29
+ };
25
30
  const SQLITE_PROFILE_CONFIG = {
26
31
  type: 'SQLiteStorageProvider',
27
32
  dbDirectory: factory_1.Expressions.env(ENV_VAR_STORAGE_DB_DIRECTORY, './data/sqlite'),
@@ -36,11 +41,25 @@ const ENCRYPTED_SQLITE_PROFILE_CONFIG = {
36
41
  masterKey: factory_1.Expressions.env(ENV_VAR_STORAGE_MASTER_KEY),
37
42
  isCached: true,
38
43
  };
39
- const PROFILE_MAP = {
44
+ // Base profile map with browser-safe options
45
+ const BASE_PROFILE_MAP = {
40
46
  [PROFILE_NAME_MEMORY]: MEMORY_PROFILE_CONFIG,
41
- [PROFILE_NAME_SQLITE]: SQLITE_PROFILE_CONFIG,
42
- [PROFILE_NAME_ENCRYPTED_SQLITE]: ENCRYPTED_SQLITE_PROFILE_CONFIG,
47
+ [PROFILE_NAME_INDEXEDDB]: INDEXEDDB_PROFILE_CONFIG,
48
+ };
49
+ // Extended profile map - can be augmented by Node.js environment
50
+ const PROFILE_MAP = {
51
+ ...BASE_PROFILE_MAP,
43
52
  };
53
+ // Function to register additional profiles (used by Node.js build)
54
+ function registerStorageProfile(name, config) {
55
+ PROFILE_MAP[name] = config;
56
+ }
57
+ // Register SQLite profiles if we're in Node.js environment
58
+ // This check allows the code to work in both browser and Node.js
59
+ if (typeof process !== 'undefined' && process.versions?.node) {
60
+ PROFILE_MAP[PROFILE_NAME_SQLITE] = SQLITE_PROFILE_CONFIG;
61
+ PROFILE_MAP[PROFILE_NAME_ENCRYPTED_SQLITE] = ENCRYPTED_SQLITE_PROFILE_CONFIG;
62
+ }
44
63
  class StorageProfileFactory extends storage_provider_factory_js_1.StorageProviderFactory {
45
64
  constructor() {
46
65
  super(...arguments);
@@ -1 +1 @@
1
- {"version":3,"file":"storage-profile-factory.js","sourceRoot":"","sources":["../../../../../src/naylence/fame/storage/storage-profile-factory.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,+CAI2B;AAG3B,+EAKuC;AAEvC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AACjE,MAAM,0BAA0B,GAAG,yBAAyB,CAAC;AAC7D,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AAE3D,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AACrC,MAAM,mBAAmB,GAAG,QAAQ,C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+B;QAE/B,MAAM,SAAS,GAAG,MAAM,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;QACvD,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC;YACxC,GAAI,SAAqC;YACzC,IAAI,EAAE,gBAAgB;SACvB,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,mBAAmB,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1E,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,4BAA4B,WAAW,0BAA0B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvG,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAA0B;YAC3C,GAAG,OAAO;YACV,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI;SACpC,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAc,EACnC,gEAAkC,EAClC,aAAa,EACb,aAAa,CACd,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,kDAAkD,WAAW,GAAG,CACjE,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAxCD,sDAwCC;AAED,IAAA,4DAA8B,EAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC"}
1
+ {"version":3,"file":"storage-profile-factory.js","sourceRoot":"","sources":["../../../../../src/naylence/fame/storage/storage-profile-factory.ts"],"names":[],"mappings":";;;AAsEA,wDAKC;AA3ED,6BAAwB;AACxB,+CAI2B;AAG3B,+EAKuC;AAEvC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AACjE,MAAM,0BAA0B,GAAG,yBAAyB,CAAC;AAC7D,MAAM,yBAAyB,GAAG,wBAAwB,CA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AM,QAAQ,GAAG,MAAM,IAAA,wBAAc,EACnC,gEAAkC,EAClC,aAAa,EACb,aAAa,CACd,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,kDAAkD,WAAW,GAAG,CACjE,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAxCD,sDAwCC;AAED,IAAA,4DAA8B,EAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC"}
@@ -5,6 +5,7 @@ const ENV_VAR_STORAGE_DB_DIRECTORY = 'FAME_STORAGE_DB_DIRECTORY';
5
5
  const ENV_VAR_STORAGE_MASTER_KEY = 'FAME_STORAGE_MASTER_KEY';
6
6
  const ENV_VAR_STORAGE_ENCRYPTED = 'FAME_STORAGE_ENCRYPTED';
7
7
  const PROFILE_NAME_MEMORY = 'memory';
8
+ const PROFILE_NAME_INDEXEDDB = 'indexeddb';
8
9
  const PROFILE_NAME_SQLITE = 'sqlite';
9
10
  const PROFILE_NAME_ENCRYPTED_SQLITE = 'encrypted-sqlite';
10
11
  const storageProfileSchema = z
@@ -13,12 +14,15 @@ const storageProfileSchema = z
13
14
  profile: z
14
15
  .string()
15
16
  .optional()
16
- .describe('Storage profile name (memory | sqlite | encrypted-sqlite)'),
17
+ .describe('Storage profile name (memory | indexeddb | sqlite | encrypted-sqlite)'),
17
18
  })
18
19
  .passthrough();
19
20
  const MEMORY_PROFILE_CONFIG = {
20
21
  type: 'InMemoryStorageProvider',
21
22
  };
23
+ const INDEXEDDB_PROFILE_CONFIG = {
24
+ type: 'IndexedDBStorageProvider',
25
+ };
22
26
  const SQLITE_PROFILE_CONFIG = {
23
27
  type: 'SQLiteStorageProvider',
24
28
  dbDirectory: Expressions.env(ENV_VAR_STORAGE_DB_DIRECTORY, './data/sqlite'),
@@ -33,11 +37,25 @@ const ENCRYPTED_SQLITE_PROFILE_CONFIG = {
33
37
  masterKey: Expressions.env(ENV_VAR_STORAGE_MASTER_KEY),
34
38
  isCached: true,
35
39
  };
36
- const PROFILE_MAP = {
40
+ // Base profile map with browser-safe options
41
+ const BASE_PROFILE_MAP = {
37
42
  [PROFILE_NAME_MEMORY]: MEMORY_PROFILE_CONFIG,
38
- [PROFILE_NAME_SQLITE]: SQLITE_PROFILE_CONFIG,
39
- [PROFILE_NAME_ENCRYPTED_SQLITE]: ENCRYPTED_SQLITE_PROFILE_CONFIG,
43
+ [PROFILE_NAME_INDEXEDDB]: INDEXEDDB_PROFILE_CONFIG,
44
+ };
45
+ // Extended profile map - can be augmented by Node.js environment
46
+ const PROFILE_MAP = {
47
+ ...BASE_PROFILE_MAP,
40
48
  };
49
+ // Function to register additional profiles (used by Node.js build)
50
+ export function registerStorageProfile(name, config) {
51
+ PROFILE_MAP[name] = config;
52
+ }
53
+ // Register SQLite profiles if we're in Node.js environment
54
+ // This check allows the code to work in both browser and Node.js
55
+ if (typeof process !== 'undefined' && process.versions?.node) {
56
+ PROFILE_MAP[PROFILE_NAME_SQLITE] = SQLITE_PROFILE_CONFIG;
57
+ PROFILE_MAP[PROFILE_NAME_ENCRYPTED_SQLITE] = ENCRYPTED_SQLITE_PROFILE_CONFIG;
58
+ }
41
59
  export class StorageProfileFactory extends StorageProviderFactory {
42
60
  constructor() {
43
61
  super(...arguments);
@@ -1 +1 @@
1
- {"version":3,"file":"storage-profile-factory.js","sourceRoot":"","sources":["../../../../../src/naylence/fame/storage/storage-profile-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAEL,sBAAsB,EACtB,8BAA8B,EAC9B,kCAAkC,GACnC,MAAM,+BAA+B,CAAC;AAEvC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AACjE,MAAM,0BAA0B,GAAG,yBAAyB,CAAC;AAC7D,MAAM,yBAAyB,GAAG,wBAAwB,CAA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gBAAgB,CAAC;IAuC1C,CAAC;IArCQ,KAAK,CAAC,MAAM,CACjB,MAA8D,EAC9D,OAA+B;QAE/B,MAAM,SAAS,GAAG,MAAM,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;QACvD,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC;YACxC,GAAI,SAAqC;YACzC,IAAI,EAAE,gBAAgB;SACvB,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,mBAAmB,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1E,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QAC/C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,4BAA4B,WAAW,0BAA0B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvG,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAA0B;YAC3C,GAAG,OAAO;YACV,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI;SACpC,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC,kCAAkC,EAClC,aAAa,EACb,aAAa,CACd,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,kDAAkD,WAAW,GAAG,CACjE,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,8BAA8B,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC"}
1
+ {"version":3,"file":"storage-profile-factory.js","sourceRoot":"","sources":["../../../../../src/naylence/fame/storage/storage-profile-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAEL,sBAAs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WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACvG,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAA0B;YAC3C,GAAG,OAAO;YACV,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI;SACpC,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,cAAc,CACnC,kCAAkC,EAClC,aAAa,EACb,aAAa,CACd,CAAC;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,kDAAkD,WAAW,GAAG,CACjE,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,8BAA8B,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,CAAC"}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@naylence/core');
4
+ var zod = require('zod');
4
5
  var factory = require('@naylence/factory');
5
6
  var fs = require('fs');
6
- var zod = require('zod');
7
7
  var yaml = require('yaml');
8
8
  var sha2_js = require('@noble/hashes/sha2.js');
9
9
  var utils_js = require('@noble/hashes/utils.js');
@@ -847,7 +847,7 @@ function coerceNumber(value) {
847
847
  }
848
848
  return undefined;
849
849
  }
850
- function coerceBoolean(value) {
850
+ function coerceBoolean$1(value) {
851
851
  if (typeof value === 'boolean') {
852
852
  return value;
853
853
  }
@@ -871,7 +871,7 @@ function normalizeTaskSpawnerConfig(config = {}) {
871
871
  0;
872
872
  const defaultTimeout = coerceNumber(firstDefined(source, ['defaultTimeout', 'default_timeout'])) ??
873
873
  0;
874
- const autoCleanup = coerceBoolean(firstDefined(source, ['autoCleanup', 'auto_cleanup'])) ??
874
+ const autoCleanup = coerceBoolean$1(firstDefined(source, ['autoCleanup', 'auto_cleanup'])) ??
875
875
  true;
876
876
  return {
877
877
  maxConcurrent,
@@ -894,7 +894,7 @@ function normalizeSpawnOptions(options = {}) {
894
894
  function normalizeShutdownOptions(options = {}) {
895
895
  const source = options;
896
896
  const gracePeriod = coerceNumber(firstDefined(source, ['gracePeriod', 'grace_period'])) ?? 2000;
897
- const cancelHanging = coerceBoolean(firstDefined(source, ['cancelHanging', 'cancel_hanging'])) ??
897
+ const cancelHanging = coerceBoolean$1(firstDefined(source, ['cancelHanging', 'cancel_hanging'])) ??
898
898
  true;
899
899
  const joinTimeout = coerceNumber(firstDefined(source, ['joinTimeout', 'join_timeout'])) ?? 1000;
900
900
  return {
@@ -2946,6 +2946,211 @@ class StorageProviderFactory extends factory.AbstractResourceFactory {
2946
2946
  return instance;
2947
2947
  }
2948
2948
  }
2949
+ function registerStorageProviderFactory(type, factory$1) {
2950
+ factory.registerFactory(STORAGE_PROVIDER_FACTORY_BASE_TYPE, type, factory$1);
2951
+ }
2952
+
2953
+ const inMemoryStorageProviderConfigSchema = zod.z
2954
+ .object({
2955
+ type: zod.z
2956
+ .literal('InMemoryStorageProvider')
2957
+ .default('InMemoryStorageProvider'),
2958
+ })
2959
+ .passthrough();
2960
+ class InMemoryStorageProviderFactory extends StorageProviderFactory {
2961
+ constructor() {
2962
+ super(...arguments);
2963
+ this.type = 'InMemoryStorageProvider';
2964
+ }
2965
+ async create(config) {
2966
+ // Validate configuration and ensure correct type information
2967
+ const candidate = config ?? { type: 'InMemoryStorageProvider' };
2968
+ inMemoryStorageProviderConfigSchema.parse({
2969
+ type: candidate.type,
2970
+ ...candidate,
2971
+ });
2972
+ return new InMemoryStorageProvider();
2973
+ }
2974
+ }
2975
+ registerStorageProviderFactory('InMemoryStorageProvider', InMemoryStorageProviderFactory);
2976
+
2977
+ const CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE = 'CredentialProviderFactory';
2978
+ class CredentialProviderFactory extends factory.AbstractResourceFactory {
2979
+ static async createCredentialProvider(config, options = {}) {
2980
+ const instance = config
2981
+ ? await factory.createResource(CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE, config, options)
2982
+ : await factory.createDefaultResource(CREDENTIAL_PROVIDER_FACTORY_BASE_TYPE, null, options);
2983
+ if (!instance) {
2984
+ throw new Error('Failed to create credential provider from configuration');
2985
+ }
2986
+ return instance;
2987
+ }
2988
+ }
2989
+
2990
+ function normalizeEnvConfig(config) {
2991
+ if (!config) {
2992
+ return {
2993
+ type: 'EnvCredentialProvider',
2994
+ varName: 'DEFAULT_VAR',
2995
+ };
2996
+ }
2997
+ if ('varName' in config &&
2998
+ typeof config.varName === 'string' &&
2999
+ config.varName.length > 0) {
3000
+ return {
3001
+ type: 'EnvCredentialProvider',
3002
+ varName: config.varName,
3003
+ };
3004
+ }
3005
+ const rawName = config.varName ??
3006
+ config.var_name;
3007
+ if (typeof rawName !== 'string' || rawName.length === 0) {
3008
+ throw new Error('EnvCredentialProvider requires a non-empty "varName"');
3009
+ }
3010
+ return {
3011
+ type: 'EnvCredentialProvider',
3012
+ varName: rawName,
3013
+ };
3014
+ }
3015
+
3016
+ function normalizePromptConfig(config) {
3017
+ if (!config) {
3018
+ return {
3019
+ type: 'PromptCredentialProvider',
3020
+ credentialName: 'credential',
3021
+ };
3022
+ }
3023
+ const credentialName = config.credentialName ??
3024
+ config.credential_name ??
3025
+ 'credential';
3026
+ if (typeof credentialName !== 'string' || credentialName.length === 0) {
3027
+ throw new Error('PromptCredentialProvider requires a non-empty "credentialName"');
3028
+ }
3029
+ return {
3030
+ type: 'PromptCredentialProvider',
3031
+ credentialName,
3032
+ };
3033
+ }
3034
+
3035
+ function normalizeSecretStoreConfig(config) {
3036
+ if (!config) {
3037
+ return {
3038
+ type: 'SecretStoreCredentialProvider',
3039
+ secretName: 'default',
3040
+ };
3041
+ }
3042
+ if ('secretName' in config &&
3043
+ typeof config.secretName === 'string' &&
3044
+ config.secretName.length > 0) {
3045
+ return {
3046
+ type: 'SecretStoreCredentialProvider',
3047
+ secretName: config.secretName,
3048
+ };
3049
+ }
3050
+ const rawName = config.secretName ??
3051
+ config.secret_name;
3052
+ if (typeof rawName !== 'string' || rawName.length === 0) {
3053
+ throw new Error('SecretStoreCredentialProvider requires a non-empty "secretName"');
3054
+ }
3055
+ return {
3056
+ type: 'SecretStoreCredentialProvider',
3057
+ secretName: rawName,
3058
+ };
3059
+ }
3060
+
3061
+ function normalizeStaticConfig(config) {
3062
+ if (!config) {
3063
+ return {
3064
+ type: 'StaticCredentialProvider',
3065
+ credentialValue: '',
3066
+ };
3067
+ }
3068
+ if ('credentialValue' in config &&
3069
+ typeof config.credentialValue === 'string') {
3070
+ return {
3071
+ type: 'StaticCredentialProvider',
3072
+ credentialValue: config.credentialValue,
3073
+ };
3074
+ }
3075
+ const rawValue = config.credentialValue ??
3076
+ config.credential_value;
3077
+ if (typeof rawValue !== 'string') {
3078
+ throw new Error('StaticCredentialProvider requires a "credentialValue" string');
3079
+ }
3080
+ return {
3081
+ type: 'StaticCredentialProvider',
3082
+ credentialValue: rawValue,
3083
+ };
3084
+ }
3085
+
3086
+ function isCredentialProviderConfig(value) {
3087
+ return Boolean(value &&
3088
+ typeof value === 'object' &&
3089
+ 'type' in value);
3090
+ }
3091
+ class SecretSource {
3092
+ static normalize(value) {
3093
+ if (value === null || value === undefined) {
3094
+ throw new TypeError('Secret source cannot be null or undefined');
3095
+ }
3096
+ if (isCredentialProviderConfig(value)) {
3097
+ switch (value.type) {
3098
+ case 'EnvCredentialProvider':
3099
+ return normalizeEnvConfig(value);
3100
+ case 'SecretStoreCredentialProvider':
3101
+ return normalizeSecretStoreConfig(value);
3102
+ case 'StaticCredentialProvider':
3103
+ return normalizeStaticConfig(value);
3104
+ case 'PromptCredentialProvider':
3105
+ return normalizePromptConfig(value);
3106
+ default:
3107
+ return { ...value };
3108
+ }
3109
+ }
3110
+ if (typeof value === 'string') {
3111
+ if (value.startsWith('env://')) {
3112
+ const varName = value.slice('env://'.length);
3113
+ if (!varName) {
3114
+ throw new Error("Environment variable name cannot be empty in 'env://' URI");
3115
+ }
3116
+ return normalizeEnvConfig({ type: 'EnvCredentialProvider', varName });
3117
+ }
3118
+ if (value.startsWith('secret://')) {
3119
+ const secretName = value.slice('secret://'.length);
3120
+ if (!secretName) {
3121
+ throw new Error("Secret name cannot be empty in 'secret://' URI");
3122
+ }
3123
+ return normalizeSecretStoreConfig({
3124
+ type: 'SecretStoreCredentialProvider',
3125
+ secretName,
3126
+ });
3127
+ }
3128
+ return normalizeStaticConfig({
3129
+ type: 'StaticCredentialProvider',
3130
+ credentialValue: value,
3131
+ });
3132
+ }
3133
+ if (typeof value === 'object') {
3134
+ const recordValue = value;
3135
+ if (!('type' in recordValue) || typeof recordValue.type !== 'string') {
3136
+ throw new TypeError("Secret source dict inputs must include a string 'type' field");
3137
+ }
3138
+ switch (recordValue.type) {
3139
+ case 'EnvCredentialProvider':
3140
+ return normalizeEnvConfig(recordValue);
3141
+ case 'SecretStoreCredentialProvider':
3142
+ return normalizeSecretStoreConfig(recordValue);
3143
+ case 'StaticCredentialProvider':
3144
+ return normalizeStaticConfig(recordValue);
3145
+ case 'PromptCredentialProvider':
3146
+ return normalizePromptConfig(recordValue);
3147
+ default:
3148
+ return { ...recordValue };
3149
+ }
3150
+ }
3151
+ throw new TypeError(`Unsupported secret source type: ${typeof value}. Expected string, dict with 'type' field, or CredentialProviderConfig instance.`);
3152
+ }
3153
+ }
2949
3154
 
2950
3155
  function isModuleNotFoundError(error) {
2951
3156
  if (!(error instanceof Error)) {
@@ -2967,8 +3172,9 @@ function isModuleNotFoundError(error) {
2967
3172
  * Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
2968
3173
  */
2969
3174
  async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
2970
- const options = { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
2971
- ;
3175
+ const options = typeof dependencyNameOrOptions === 'string'
3176
+ ? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
3177
+ : dependencyNameOrOptions;
2972
3178
  const dependencyName = options.dependencyName;
2973
3179
  try {
2974
3180
  return await loader();
@@ -2990,6 +3196,219 @@ async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
2990
3196
  }
2991
3197
  }
2992
3198
 
3199
+ const indexedDBConfigSchema = zod.z
3200
+ .object({
3201
+ type: zod.z
3202
+ .literal('IndexedDBStorageProvider')
3203
+ .default('IndexedDBStorageProvider'),
3204
+ mode: zod.z
3205
+ .union([zod.z.literal('dx'), zod.z.literal('hardened'), zod.z.string()])
3206
+ .optional()
3207
+ .default('dx'),
3208
+ dbName: zod.z.string().min(1).default('naylence'),
3209
+ version: zod.z.union([zod.z.number().int().positive(), zod.z.string()]).default(1),
3210
+ namespacePrefix: zod.z.string().optional().default('kv'),
3211
+ enableCaching: zod.z.union([zod.z.boolean(), zod.z.string()]).optional(),
3212
+ isEncrypted: zod.z.union([zod.z.boolean(), zod.z.string()]).optional(),
3213
+ masterKey: zod.z
3214
+ .union([zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown()), zod.z.null()])
3215
+ .optional()
3216
+ .default(null),
3217
+ })
3218
+ .passthrough();
3219
+ const TRUE_VALUES = new Set(['true', '1', 'yes', 'on']);
3220
+ const FALSE_VALUES = new Set(['false', '0', 'no', 'off', '']);
3221
+ function coerceBoolean(value, fieldName, defaultValue) {
3222
+ if (value === undefined) {
3223
+ return defaultValue;
3224
+ }
3225
+ if (typeof value === 'boolean') {
3226
+ return value;
3227
+ }
3228
+ if (typeof value === 'string') {
3229
+ const normalized = value.trim().toLowerCase();
3230
+ if (TRUE_VALUES.has(normalized)) {
3231
+ return true;
3232
+ }
3233
+ if (FALSE_VALUES.has(normalized)) {
3234
+ return false;
3235
+ }
3236
+ }
3237
+ throw new Error(`Expected a boolean-like value for '${fieldName}' but received '${String(value)}'`);
3238
+ }
3239
+ function normalizeIndexedDBConfig(config) {
3240
+ const candidate = {
3241
+ ...config,
3242
+ };
3243
+ if (candidate.dbName === undefined && typeof candidate.db_name === 'string') {
3244
+ candidate.dbName = candidate.db_name;
3245
+ }
3246
+ if (candidate.namespacePrefix === undefined &&
3247
+ typeof candidate.namespace_prefix === 'string') {
3248
+ candidate.namespacePrefix = candidate.namespace_prefix;
3249
+ }
3250
+ if (candidate.enableCaching === undefined &&
3251
+ candidate.enable_caching !== undefined) {
3252
+ candidate.enableCaching = candidate.enable_caching;
3253
+ }
3254
+ if (candidate.isEncrypted === undefined &&
3255
+ candidate.is_encrypted !== undefined) {
3256
+ candidate.isEncrypted = candidate.is_encrypted;
3257
+ }
3258
+ if (candidate.masterKey === undefined && candidate.master_key !== undefined) {
3259
+ candidate.masterKey = candidate.master_key;
3260
+ }
3261
+ const parsed = indexedDBConfigSchema.parse({
3262
+ ...candidate,
3263
+ type: 'IndexedDBStorageProvider',
3264
+ });
3265
+ const normalizedMode = (typeof parsed.mode === 'string' ? parsed.mode : 'dx').toLowerCase();
3266
+ if (normalizedMode !== 'dx' && normalizedMode !== 'hardened') {
3267
+ throw new Error("mode must be either 'dx' or 'hardened'");
3268
+ }
3269
+ const versionValue = typeof parsed.version === 'string'
3270
+ ? parseInt(parsed.version, 10)
3271
+ : parsed.version;
3272
+ if (!Number.isInteger(versionValue) || versionValue <= 0) {
3273
+ throw new Error('version must be a positive integer');
3274
+ }
3275
+ const enableCaching = coerceBoolean(parsed.enableCaching, 'enableCaching', normalizedMode === 'dx');
3276
+ const isEncrypted = coerceBoolean(parsed.isEncrypted, 'isEncrypted', true);
3277
+ let masterKeyConfig = null;
3278
+ if (parsed.masterKey !== null && parsed.masterKey !== undefined) {
3279
+ masterKeyConfig = SecretSource.normalize(parsed.masterKey);
3280
+ }
3281
+ if (normalizedMode === 'hardened' && !masterKeyConfig) {
3282
+ throw new Error('hardened mode requires a masterKey configuration');
3283
+ }
3284
+ return {
3285
+ type: 'IndexedDBStorageProvider',
3286
+ mode: normalizedMode,
3287
+ dbName: parsed.dbName,
3288
+ version: versionValue,
3289
+ namespacePrefix: parsed.namespacePrefix ?? 'kv',
3290
+ enableCaching,
3291
+ isEncrypted,
3292
+ masterKey: masterKeyConfig,
3293
+ };
3294
+ }
3295
+ class IndexedDBStorageProviderFactory extends StorageProviderFactory {
3296
+ constructor() {
3297
+ super(...arguments);
3298
+ this.type = 'IndexedDBStorageProvider';
3299
+ this.isDefault = true;
3300
+ this.priority = 50;
3301
+ }
3302
+ async create(config) {
3303
+ const normalized = normalizeIndexedDBConfig(config);
3304
+ const { IndexedDBStorageProvider } = await getIndexedDbStorageProviderModule();
3305
+ let masterKeyProvider = null;
3306
+ if (normalized.masterKey) {
3307
+ masterKeyProvider =
3308
+ await CredentialProviderFactory.createCredentialProvider(normalized.masterKey);
3309
+ }
3310
+ return new IndexedDBStorageProvider({
3311
+ mode: normalized.mode,
3312
+ dbName: normalized.dbName,
3313
+ version: normalized.version,
3314
+ namespacePrefix: normalized.namespacePrefix,
3315
+ enableCaching: normalized.enableCaching,
3316
+ isEncrypted: normalized.isEncrypted,
3317
+ masterKeyProvider,
3318
+ });
3319
+ }
3320
+ }
3321
+ let indexedDbStorageProviderModulePromise = null;
3322
+ function getIndexedDbStorageProviderModule() {
3323
+ if (!indexedDbStorageProviderModulePromise) {
3324
+ indexedDbStorageProviderModulePromise = safeImport(() => Promise.resolve().then(function () { return indexeddbStorageProvider; }), 'IndexedDBStorageProvider', {
3325
+ helpMessage: 'Failed to load the IndexedDB storage provider. Ensure IndexedDB is available or install the required polyfills.',
3326
+ });
3327
+ }
3328
+ return indexedDbStorageProviderModulePromise;
3329
+ }
3330
+ registerStorageProviderFactory('IndexedDBStorageProvider', IndexedDBStorageProviderFactory);
3331
+
3332
+ const ENV_VAR_STORAGE_DB_DIRECTORY = 'FAME_STORAGE_DB_DIRECTORY';
3333
+ const ENV_VAR_STORAGE_MASTER_KEY = 'FAME_STORAGE_MASTER_KEY';
3334
+ const ENV_VAR_STORAGE_ENCRYPTED = 'FAME_STORAGE_ENCRYPTED';
3335
+ const PROFILE_NAME_MEMORY = 'memory';
3336
+ const PROFILE_NAME_INDEXEDDB = 'indexeddb';
3337
+ const PROFILE_NAME_SQLITE = 'sqlite';
3338
+ const PROFILE_NAME_ENCRYPTED_SQLITE = 'encrypted-sqlite';
3339
+ const storageProfileSchema = zod.z
3340
+ .object({
3341
+ type: zod.z.literal('StorageProfile').default('StorageProfile'),
3342
+ profile: zod.z
3343
+ .string()
3344
+ .optional()
3345
+ .describe('Storage profile name (memory | indexeddb | sqlite | encrypted-sqlite)'),
3346
+ })
3347
+ .passthrough();
3348
+ const MEMORY_PROFILE_CONFIG = {
3349
+ type: 'InMemoryStorageProvider',
3350
+ };
3351
+ const INDEXEDDB_PROFILE_CONFIG = {
3352
+ type: 'IndexedDBStorageProvider',
3353
+ };
3354
+ const SQLITE_PROFILE_CONFIG = {
3355
+ type: 'SQLiteStorageProvider',
3356
+ dbDirectory: factory.Expressions.env(ENV_VAR_STORAGE_DB_DIRECTORY, './data/sqlite'),
3357
+ isEncrypted: factory.Expressions.env(ENV_VAR_STORAGE_ENCRYPTED, 'false'),
3358
+ masterKey: factory.Expressions.env(ENV_VAR_STORAGE_MASTER_KEY, ''),
3359
+ isCached: true,
3360
+ };
3361
+ const ENCRYPTED_SQLITE_PROFILE_CONFIG = {
3362
+ type: 'SQLiteStorageProvider',
3363
+ dbDirectory: factory.Expressions.env(ENV_VAR_STORAGE_DB_DIRECTORY, './data/sqlite'),
3364
+ isEncrypted: 'true',
3365
+ masterKey: factory.Expressions.env(ENV_VAR_STORAGE_MASTER_KEY),
3366
+ isCached: true,
3367
+ };
3368
+ // Base profile map with browser-safe options
3369
+ const BASE_PROFILE_MAP = {
3370
+ [PROFILE_NAME_MEMORY]: MEMORY_PROFILE_CONFIG,
3371
+ [PROFILE_NAME_INDEXEDDB]: INDEXEDDB_PROFILE_CONFIG,
3372
+ };
3373
+ // Extended profile map - can be augmented by Node.js environment
3374
+ const PROFILE_MAP$1 = {
3375
+ ...BASE_PROFILE_MAP,
3376
+ };
3377
+ // Register SQLite profiles if we're in Node.js environment
3378
+ // This check allows the code to work in both browser and Node.js
3379
+ if (typeof process !== 'undefined' && process.versions?.node) {
3380
+ PROFILE_MAP$1[PROFILE_NAME_SQLITE] = SQLITE_PROFILE_CONFIG;
3381
+ PROFILE_MAP$1[PROFILE_NAME_ENCRYPTED_SQLITE] = ENCRYPTED_SQLITE_PROFILE_CONFIG;
3382
+ }
3383
+ class StorageProfileFactory extends StorageProviderFactory {
3384
+ constructor() {
3385
+ super(...arguments);
3386
+ this.type = 'StorageProfile';
3387
+ }
3388
+ async create(config, options) {
3389
+ const candidate = config ?? { type: 'StorageProfile' };
3390
+ const parsed = storageProfileSchema.parse({
3391
+ ...candidate,
3392
+ type: 'StorageProfile',
3393
+ });
3394
+ const profileName = (parsed.profile ?? PROFILE_NAME_MEMORY).toLowerCase();
3395
+ const profileConfig = PROFILE_MAP$1[profileName];
3396
+ if (!profileConfig) {
3397
+ throw new Error(`Unknown storage profile '${profileName}'. Supported profiles: ${Object.keys(PROFILE_MAP$1).join(', ')}`);
3398
+ }
3399
+ const createOptions = {
3400
+ ...options,
3401
+ validate: options?.validate ?? true,
3402
+ };
3403
+ const provider = await factory.createResource(STORAGE_PROVIDER_FACTORY_BASE_TYPE, profileConfig, createOptions);
3404
+ if (!provider) {
3405
+ throw new Error(`Failed to create storage provider for profile '${profileName}'`);
3406
+ }
3407
+ return provider;
3408
+ }
3409
+ }
3410
+ registerStorageProviderFactory('StorageProfile', StorageProfileFactory);
3411
+
2993
3412
  const DEFAULT_DB_NAME$3 = 'naylence-secrets';
2994
3413
  const DEFAULT_STORE_NAME$1 = 'auto-master-key';
2995
3414
  const DEFAULT_KEY_ID$2 = 'master';
@@ -3738,6 +4157,11 @@ class IndexedDBStorageProvider extends EncryptedStorageProviderBase {
3738
4157
  }
3739
4158
  IndexedDBStorageProvider.supportedModes = new Set(['dx', 'hardened']);
3740
4159
 
4160
+ var indexeddbStorageProvider = /*#__PURE__*/Object.freeze({
4161
+ __proto__: null,
4162
+ IndexedDBStorageProvider: IndexedDBStorageProvider
4163
+ });
4164
+
3741
4165
  const globalScope$1 = globalThis;
3742
4166
  const nodeStack = globalScope$1.__naylenceNodeStack__ ?? (globalScope$1.__naylenceNodeStack__ = []);
3743
4167
  function getCurrentNode() {