@credo-ts/react-native 0.6.4-alpha-20260312090026 → 0.6.4-alpha-20260312154622
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,8 +1,9 @@
|
|
|
1
|
+
import { rnfs } from "./rnfs.mjs";
|
|
1
2
|
import { Buffer, CredoError, TypedArrayEncoder, getDirFromFilePath } from "@credo-ts/core";
|
|
2
3
|
import { Platform } from "react-native";
|
|
3
|
-
import * as RNFS from "react-native-fs";
|
|
4
4
|
|
|
5
5
|
//#region src/ReactNativeFileSystem.ts
|
|
6
|
+
const RNFS = rnfs();
|
|
6
7
|
var ReactNativeFileSystem = class {
|
|
7
8
|
/**
|
|
8
9
|
* Create new ReactNativeFileSystem class instance.
|
|
@@ -17,7 +18,7 @@ var ReactNativeFileSystem = class {
|
|
|
17
18
|
* Files will be created under baseTempPath/.afj directory. If not specified, it will be set to
|
|
18
19
|
* RNFS.TemporaryDirectoryPath
|
|
19
20
|
*
|
|
20
|
-
* @see https://github.com/
|
|
21
|
+
* @see https://github.com/birdofpreyru/react-native-fs#constants
|
|
21
22
|
*/
|
|
22
23
|
constructor(options) {
|
|
23
24
|
this.dataPath = `${options?.baseDataPath ?? RNFS.DocumentDirectoryPath}/.afj`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeFileSystem.mjs","names":[],"sources":["../src/ReactNativeFileSystem.ts"],"sourcesContent":["import type { DownloadToFileOptions, FileSystem } from '@credo-ts/core'\
|
|
1
|
+
{"version":3,"file":"ReactNativeFileSystem.mjs","names":[],"sources":["../src/ReactNativeFileSystem.ts"],"sourcesContent":["import type { DownloadToFileOptions, FileSystem } from '@credo-ts/core'\nimport { Buffer, CredoError, getDirFromFilePath, TypedArrayEncoder } from '@credo-ts/core'\nimport { Platform } from 'react-native'\nimport { rnfs } from './rnfs'\n\nconst RNFS = rnfs()\n\nexport class ReactNativeFileSystem implements FileSystem {\n public readonly dataPath\n public readonly cachePath\n public readonly tempPath\n\n /**\n * Create new ReactNativeFileSystem class instance.\n *\n * @param baseDataPath The base path to use for reading and writing data files used within the framework.\n * Files will be created under baseDataPath/.afj directory. If not specified, it will be set to\n * RNFS.DocumentDirectoryPath\n * @param baseCachePath The base path to use for reading and writing cache files used within the framework.\n * Files will be created under baseCachePath/.afj directory. If not specified, it will be set to\n * RNFS.CachesDirectoryPath\n * @param baseTempPath The base path to use for reading and writing temporary files within the framework.\n * Files will be created under baseTempPath/.afj directory. If not specified, it will be set to\n * RNFS.TemporaryDirectoryPath\n *\n * @see https://github.com/birdofpreyru/react-native-fs#constants\n */\n public constructor(options?: { baseDataPath?: string; baseCachePath?: string; baseTempPath?: string }) {\n this.dataPath = `${options?.baseDataPath ?? RNFS.DocumentDirectoryPath}/.afj`\n // In Android, TemporaryDirectoryPath falls back to CachesDirectoryPath\n this.cachePath = options?.baseCachePath\n ? `${options?.baseCachePath}/.afj`\n : `${RNFS.CachesDirectoryPath}/.afj${Platform.OS === 'android' ? '/cache' : ''}`\n this.tempPath = options?.baseTempPath\n ? `${options?.baseTempPath}/.afj`\n : `${RNFS.TemporaryDirectoryPath}/.afj${Platform.OS === 'android' ? '/temp' : ''}`\n }\n\n public async exists(path: string): Promise<boolean> {\n return RNFS.exists(path)\n }\n\n public async createDirectory(path: string): Promise<void> {\n await RNFS.mkdir(getDirFromFilePath(path))\n }\n\n public async copyFile(sourcePath: string, destinationPath: string): Promise<void> {\n await RNFS.copyFile(sourcePath, destinationPath)\n }\n\n public async write(path: string, data: string): Promise<void> {\n // Make sure parent directories exist\n await RNFS.mkdir(getDirFromFilePath(path))\n\n return RNFS.writeFile(path, data, 'utf8')\n }\n\n public async read(path: string): Promise<string> {\n return RNFS.readFile(path, 'utf8')\n }\n\n public async delete(path: string): Promise<void> {\n await RNFS.unlink(path)\n }\n\n public async downloadToFile(url: string, path: string, options?: DownloadToFileOptions) {\n // Make sure parent directories exist\n await RNFS.mkdir(getDirFromFilePath(path))\n\n const fromUrl = this.encodeUriIfRequired(url)\n\n const { promise } = RNFS.downloadFile({\n fromUrl,\n toFile: path,\n })\n\n await promise\n\n if (options?.verifyHash) {\n // RNFS returns hash as HEX\n const fileHash = await RNFS.hash(path, options.verifyHash.algorithm)\n const fileHashBuffer = Buffer.from(fileHash, 'hex')\n\n // If hash doesn't match, remove file and throw error\n if (fileHashBuffer.compare(options.verifyHash.hash) !== 0) {\n await RNFS.unlink(path)\n throw new CredoError(\n `Hash of downloaded file does not match expected hash. Expected: ${TypedArrayEncoder.toBase58(\n options.verifyHash.hash\n )}, Actual: ${TypedArrayEncoder.toBase58(fileHashBuffer)}`\n )\n }\n }\n }\n\n private encodeUriIfRequired(uri: string) {\n // Some characters in the URL might be invalid for\n // the native os to handle. Only encode if necessary.\n return uri === decodeURI(uri) ? encodeURI(uri) : uri\n }\n}\n"],"mappings":";;;;;AAKA,MAAM,OAAO,MAAM;AAEnB,IAAa,wBAAb,MAAyD;;;;;;;;;;;;;;;;CAoBvD,AAAO,YAAY,SAAoF;AACrG,OAAK,WAAW,GAAG,SAAS,gBAAgB,KAAK,sBAAsB;AAEvE,OAAK,YAAY,SAAS,gBACtB,GAAG,SAAS,cAAc,SAC1B,GAAG,KAAK,oBAAoB,OAAO,SAAS,OAAO,YAAY,WAAW;AAC9E,OAAK,WAAW,SAAS,eACrB,GAAG,SAAS,aAAa,SACzB,GAAG,KAAK,uBAAuB,OAAO,SAAS,OAAO,YAAY,UAAU;;CAGlF,MAAa,OAAO,MAAgC;AAClD,SAAO,KAAK,OAAO,KAAK;;CAG1B,MAAa,gBAAgB,MAA6B;AACxD,QAAM,KAAK,MAAM,mBAAmB,KAAK,CAAC;;CAG5C,MAAa,SAAS,YAAoB,iBAAwC;AAChF,QAAM,KAAK,SAAS,YAAY,gBAAgB;;CAGlD,MAAa,MAAM,MAAc,MAA6B;AAE5D,QAAM,KAAK,MAAM,mBAAmB,KAAK,CAAC;AAE1C,SAAO,KAAK,UAAU,MAAM,MAAM,OAAO;;CAG3C,MAAa,KAAK,MAA+B;AAC/C,SAAO,KAAK,SAAS,MAAM,OAAO;;CAGpC,MAAa,OAAO,MAA6B;AAC/C,QAAM,KAAK,OAAO,KAAK;;CAGzB,MAAa,eAAe,KAAa,MAAc,SAAiC;AAEtF,QAAM,KAAK,MAAM,mBAAmB,KAAK,CAAC;EAE1C,MAAM,UAAU,KAAK,oBAAoB,IAAI;EAE7C,MAAM,EAAE,YAAY,KAAK,aAAa;GACpC;GACA,QAAQ;GACT,CAAC;AAEF,QAAM;AAEN,MAAI,SAAS,YAAY;GAEvB,MAAM,WAAW,MAAM,KAAK,KAAK,MAAM,QAAQ,WAAW,UAAU;GACpE,MAAM,iBAAiB,OAAO,KAAK,UAAU,MAAM;AAGnD,OAAI,eAAe,QAAQ,QAAQ,WAAW,KAAK,KAAK,GAAG;AACzD,UAAM,KAAK,OAAO,KAAK;AACvB,UAAM,IAAI,WACR,mEAAmE,kBAAkB,SACnF,QAAQ,WAAW,KACpB,CAAC,YAAY,kBAAkB,SAAS,eAAe,GACzD;;;;CAKP,AAAQ,oBAAoB,KAAa;AAGvC,SAAO,QAAQ,UAAU,IAAI,GAAG,UAAU,IAAI,GAAG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { __require };
|
package/build/rnfs.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { __require } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/rnfs.ts
|
|
4
|
+
const rnfs = () => {
|
|
5
|
+
try {
|
|
6
|
+
return __require("@dr.pogodin/react-native-fs");
|
|
7
|
+
} catch {
|
|
8
|
+
try {
|
|
9
|
+
return __require("react-native-fs");
|
|
10
|
+
} catch {
|
|
11
|
+
throw new Error(`Could not find '@dr.pogodin/react-native-fs' or 'react-native-fs' as a peerDependency. Make sure to add either one of them`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { rnfs };
|
|
18
|
+
//# sourceMappingURL=rnfs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rnfs.mjs","names":[],"sources":["../src/rnfs.ts"],"sourcesContent":["export const rnfs = () => {\n try {\n return require('@dr.pogodin/react-native-fs')\n } catch {\n try {\n return require('react-native-fs')\n } catch {\n throw new Error(\n `Could not find '@dr.pogodin/react-native-fs' or 'react-native-fs' as a peerDependency. Make sure to add either one of them`\n )\n }\n }\n}\n"],"mappings":";;;AAAA,MAAa,aAAa;AACxB,KAAI;AACF,mBAAe,8BAA8B;SACvC;AACN,MAAI;AACF,oBAAe,kBAAkB;UAC3B;AACN,SAAM,IAAI,MACR,6HACD"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
".": "./build/index.mjs",
|
|
5
5
|
"./package.json": "./package.json"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.6.4-alpha-
|
|
7
|
+
"version": "0.6.4-alpha-20260312154622",
|
|
8
8
|
"files": [
|
|
9
9
|
"build"
|
|
10
10
|
],
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"events": "^3.3.0",
|
|
23
|
-
"@credo-ts/core": "0.6.4-alpha-
|
|
23
|
+
"@credo-ts/core": "0.6.4-alpha-20260312154622"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"react-native": "^0.83.1",
|
|
27
27
|
"react-native-fs": "^2.20.0",
|
|
28
|
+
"@dr.pogodin/react-native-fs": "^2.37.0",
|
|
28
29
|
"react-native-get-random-values": "^2.0.0",
|
|
29
30
|
"typescript": "~5.9.3"
|
|
30
31
|
},
|
|
@@ -32,12 +33,19 @@
|
|
|
32
33
|
"@animo-id/expo-secure-environment": "^0.1.1",
|
|
33
34
|
"expo-crypto": "^15.0.7",
|
|
34
35
|
"react-native": ">=0.71.4",
|
|
35
|
-
"react-native-fs": "
|
|
36
|
+
"@dr.pogodin/react-native-fs": ">= 2.37.0",
|
|
37
|
+
"react-native-fs": ">= 2",
|
|
36
38
|
"react-native-get-random-values": ">=1.11.0 <3.0.0"
|
|
37
39
|
},
|
|
38
40
|
"peerDependenciesMeta": {
|
|
39
41
|
"@animo-id/expo-secure-environment": {
|
|
40
42
|
"optional": true
|
|
43
|
+
},
|
|
44
|
+
"react-native-fs": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"@dr.pogodin/react-native-fs": {
|
|
48
|
+
"optional": true
|
|
41
49
|
}
|
|
42
50
|
},
|
|
43
51
|
"scripts": {
|