@party-stack/expo-runtime 0.4.0 → 0.4.2
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/README.md +16 -0
- package/lib/ExpoFileSystemBlobBytesStore.d.ts +10 -8
- package/lib/ExpoFileSystemBlobBytesStore.d.ts.map +1 -1
- package/lib/ExpoFileSystemBlobBytesStore.js +50 -45
- package/lib/ExpoFileSystemBlobBytesStore.js.map +1 -1
- package/lib/ExpoNetworkConnectivity.d.ts +12 -10
- package/lib/ExpoNetworkConnectivity.d.ts.map +1 -1
- package/lib/ExpoNetworkConnectivity.js +37 -36
- package/lib/ExpoNetworkConnectivity.js.map +1 -1
- package/lib/ExpoSecretStore.d.ts +9 -7
- package/lib/ExpoSecretStore.d.ts.map +1 -1
- package/lib/ExpoSecretStore.js +24 -21
- package/lib/ExpoSecretStore.js.map +1 -1
- package/lib/createExpoBrowserAuthentication.d.ts +3 -1
- package/lib/createExpoBrowserAuthentication.d.ts.map +1 -1
- package/lib/createExpoBrowserAuthentication.js +19 -21
- package/lib/createExpoBrowserAuthentication.js.map +1 -1
- package/lib/createExpoRuntime.d.ts +4 -1
- package/lib/createExpoRuntime.d.ts.map +1 -1
- package/lib/createExpoRuntime.js +36 -43
- package/lib/createExpoRuntime.js.map +1 -1
- package/lib/hashStorageName.d.ts +4 -0
- package/lib/hashStorageName.d.ts.map +1 -0
- package/lib/hashStorageName.js +9 -0
- package/lib/hashStorageName.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +0 -1
- package/lib/polyfill.d.ts +1 -0
- package/lib/polyfill.js +33 -0
- package/lib/polyfill.js.map +1 -0
- package/package.json +27 -22
- package/lib/ExpoSecretStore.test.d.ts +0 -2
- package/lib/ExpoSecretStore.test.d.ts.map +0 -1
- package/lib/ExpoSecretStore.test.js +0 -40
- package/lib/ExpoSecretStore.test.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Expo runtime
|
|
2
|
+
|
|
3
|
+
This runtime targets Expo SDK 57. Install `@party-stack/expo-runtime` and its Expo peer dependencies using SDK 57-compatible versions. Expo installs `expo/fetch` as the default native fetch starting in SDK 56; no separate `expo-fetch` package or fetch installer is needed. The runtime includes `expo-blob`.
|
|
4
|
+
|
|
5
|
+
Import the required polyfill first in your application entry point, before importing application code or creating clients:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import "@party-stack/expo-runtime/polyfill";
|
|
9
|
+
import "expo-router/entry";
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Then use `createExpoRuntime` from `@party-stack/expo-runtime` as your installation's runtime provider.
|
|
13
|
+
|
|
14
|
+
The polyfill replaces global `Blob` with Expo Blob and global `File` with a compatible class extending Expo Blob. It leaves Expo’s installed fetch unchanged. Import it once at startup; it is a separate entry point so importing the runtime alone does not replace Blob or File. Attachment uploads use Expo’s default fetch; do not opt back into React Native fetch with `EXPO_PUBLIC_USE_RN_FETCH`.
|
|
15
|
+
|
|
16
|
+
Attachment storage requires blobs with `arrayBuffer()`, as provided by Expo Blob and Expo File. Blobs returned by other native libraries may still use React Native's older Blob implementation; convert those to compatible blobs before passing them to the runtime. Cache reads return `expo-file-system` File objects, which Expo fetch accepts as upload bodies.
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BlobBytesStore } from "@party-stack/runtime";
|
|
2
|
+
//#region src/ExpoFileSystemBlobBytesStore.d.ts
|
|
2
3
|
export interface ExpoFileSystemBlobBytesStoreOptions {
|
|
3
|
-
|
|
4
|
+
directoryName: string;
|
|
4
5
|
}
|
|
5
6
|
export declare class ExpoFileSystemBlobBytesStore implements BlobBytesStore {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
#private;
|
|
8
|
+
constructor(options: ExpoFileSystemBlobBytesStoreOptions);
|
|
9
|
+
write(id: string, blob: Blob): Promise<void>;
|
|
10
|
+
read(id: string): Promise<Blob>;
|
|
11
|
+
delete(id: string): Promise<void>;
|
|
12
|
+
clear(): Promise<void>;
|
|
12
13
|
}
|
|
14
|
+
//#endregion
|
|
13
15
|
//# sourceMappingURL=ExpoFileSystemBlobBytesStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoFileSystemBlobBytesStore.d.ts","
|
|
1
|
+
{"version":3,"file":"ExpoFileSystemBlobBytesStore.d.ts","names":[],"sources":["../src/ExpoFileSystemBlobBytesStore.ts"],"mappings":";;iBAIiB;EACb;;qBAGS,wCAAwC;;EAGjD,YAAY,SAAS;EAIf,MAAM,YAAY,MAAM,OAAO;EAOrC,KAAK,aAAa,QAAQ;EAU1B,OAAO,aAAa;EAOpB,SAAS"}
|
|
@@ -1,47 +1,52 @@
|
|
|
1
|
+
import { hashStorageName } from "./hashStorageName.js";
|
|
1
2
|
import { Directory, File, Paths } from "expo-file-system";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
3
|
+
//#region src/ExpoFileSystemBlobBytesStore.ts
|
|
4
|
+
var ExpoFileSystemBlobBytesStore = class {
|
|
5
|
+
#directoryName;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.#directoryName = options.directoryName;
|
|
8
|
+
}
|
|
9
|
+
async write(id, blob) {
|
|
10
|
+
const file = await this.#file(id);
|
|
11
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
12
|
+
file.create({
|
|
13
|
+
intermediates: true,
|
|
14
|
+
overwrite: true
|
|
15
|
+
});
|
|
16
|
+
file.write(bytes);
|
|
17
|
+
}
|
|
18
|
+
read(id) {
|
|
19
|
+
return Promise.resolve().then(async () => {
|
|
20
|
+
const file = await this.#file(id);
|
|
21
|
+
if (!file.exists) throw new Error(`Blob bytes not found for "${id}".`);
|
|
22
|
+
return file;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
delete(id) {
|
|
26
|
+
return Promise.resolve().then(async () => {
|
|
27
|
+
const file = await this.#file(id);
|
|
28
|
+
if (file.exists) file.delete();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
clear() {
|
|
32
|
+
return Promise.resolve().then(() => {
|
|
33
|
+
const directory = new Directory(Paths.document, this.#directoryName);
|
|
34
|
+
if (directory.exists) directory.delete();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
#directory() {
|
|
38
|
+
const directory = new Directory(Paths.document, this.#directoryName);
|
|
39
|
+
directory.create({
|
|
40
|
+
idempotent: true,
|
|
41
|
+
intermediates: true
|
|
42
|
+
});
|
|
43
|
+
return directory;
|
|
44
|
+
}
|
|
45
|
+
#file(id) {
|
|
46
|
+
return hashStorageName(id).then((name) => new File(this.#directory(), name));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ExpoFileSystemBlobBytesStore };
|
|
51
|
+
|
|
47
52
|
//# sourceMappingURL=ExpoFileSystemBlobBytesStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoFileSystemBlobBytesStore.js","
|
|
1
|
+
{"version":3,"file":"ExpoFileSystemBlobBytesStore.js","names":[],"sources":["../src/ExpoFileSystemBlobBytesStore.ts"],"sourcesContent":["import { Directory, File, Paths } from \"expo-file-system\";\nimport { hashStorageName } from \"./hashStorageName.js\";\nimport type { BlobBytesStore } from \"@party-stack/runtime\";\n\nexport interface ExpoFileSystemBlobBytesStoreOptions {\n directoryName: string;\n}\n\nexport class ExpoFileSystemBlobBytesStore implements BlobBytesStore {\n #directoryName: string;\n\n constructor(options: ExpoFileSystemBlobBytesStoreOptions) {\n this.#directoryName = options.directoryName;\n }\n\n async write(id: string, blob: Blob): Promise<void> {\n const file = await this.#file(id);\n const bytes = new Uint8Array(await blob.arrayBuffer());\n file.create({ intermediates: true, overwrite: true });\n file.write(bytes);\n }\n\n read(id: string): Promise<Blob> {\n return Promise.resolve().then(async () => {\n const file = await this.#file(id);\n if (!file.exists) {\n throw new Error(`Blob bytes not found for \"${id}\".`);\n }\n return file;\n });\n }\n\n delete(id: string): Promise<void> {\n return Promise.resolve().then(async () => {\n const file = await this.#file(id);\n if (file.exists) file.delete();\n });\n }\n\n clear(): Promise<void> {\n return Promise.resolve().then(() => {\n const directory = new Directory(Paths.document, this.#directoryName);\n if (directory.exists) directory.delete();\n });\n }\n\n #directory(): Directory {\n const directory = new Directory(Paths.document, this.#directoryName);\n directory.create({ idempotent: true, intermediates: true });\n return directory;\n }\n\n #file(id: string): Promise<File> {\n return hashStorageName(id).then((name) => new File(this.#directory(), name));\n }\n}\n"],"mappings":";;;AAQA,IAAa,+BAAb,MAAoE;CAChE;CAEA,YAAY,SAA8C;EACtD,KAAK,iBAAiB,QAAQ;CAClC;CAEA,MAAM,MAAM,IAAY,MAA2B;EAC/C,MAAM,OAAO,MAAM,KAAK,MAAM,EAAE;EAChC,MAAM,QAAQ,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;EACrD,KAAK,OAAO;GAAE,eAAe;GAAM,WAAW;EAAK,CAAC;EACpD,KAAK,MAAM,KAAK;CACpB;CAEA,KAAK,IAA2B;EAC5B,OAAO,QAAQ,QAAQ,CAAC,CAAC,KAAK,YAAY;GACtC,MAAM,OAAO,MAAM,KAAK,MAAM,EAAE;GAChC,IAAI,CAAC,KAAK,QACN,MAAM,IAAI,MAAM,6BAA6B,GAAG,GAAG;GAEvD,OAAO;EACX,CAAC;CACL;CAEA,OAAO,IAA2B;EAC9B,OAAO,QAAQ,QAAQ,CAAC,CAAC,KAAK,YAAY;GACtC,MAAM,OAAO,MAAM,KAAK,MAAM,EAAE;GAChC,IAAI,KAAK,QAAQ,KAAK,OAAO;EACjC,CAAC;CACL;CAEA,QAAuB;EACnB,OAAO,QAAQ,QAAQ,CAAC,CAAC,WAAW;GAChC,MAAM,YAAY,IAAI,UAAU,MAAM,UAAU,KAAK,cAAc;GACnE,IAAI,UAAU,QAAQ,UAAU,OAAO;EAC3C,CAAC;CACL;CAEA,aAAwB;EACpB,MAAM,YAAY,IAAI,UAAU,MAAM,UAAU,KAAK,cAAc;EACnE,UAAU,OAAO;GAAE,YAAY;GAAM,eAAe;EAAK,CAAC;EAC1D,OAAO;CACX;CAEA,MAAM,IAA2B;EAC7B,OAAO,gBAAgB,EAAE,CAAC,CAAC,MAAM,SAAS,IAAI,KAAK,KAAK,WAAW,GAAG,IAAI,CAAC;CAC/E;AACJ"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NetworkConnectivity } from "@party-stack/runtime";
|
|
2
|
+
//#region src/ExpoNetworkConnectivity.d.ts
|
|
2
3
|
export declare class ExpoNetworkConnectivity implements NetworkConnectivity {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
private readonly listeners;
|
|
5
|
+
private connected;
|
|
6
|
+
private readonly unsubscribe;
|
|
7
|
+
static create(): Promise<ExpoNetworkConnectivity>;
|
|
8
|
+
private constructor();
|
|
9
|
+
get isConnected(): boolean;
|
|
10
|
+
subscribe(listener: (isConnected: boolean) => void): () => void;
|
|
11
|
+
close(): void;
|
|
12
|
+
private update;
|
|
12
13
|
}
|
|
14
|
+
//#endregion
|
|
13
15
|
//# sourceMappingURL=ExpoNetworkConnectivity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoNetworkConnectivity.d.ts","
|
|
1
|
+
{"version":3,"file":"ExpoNetworkConnectivity.d.ts","names":[],"sources":["../src/ExpoNetworkConnectivity.ts"],"mappings":";;qBAGa,mCAAmC;mBAC3B;UACT;mBACS;SAEJ,UAAU,QAAQ;UAKxB;MAOH;EAIJ,UAAU,WAAW;EAOrB;UAKQ"}
|
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import NetInfo from "@react-native-community/netinfo";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
2
|
+
//#region src/ExpoNetworkConnectivity.ts
|
|
3
|
+
var ExpoNetworkConnectivity = class ExpoNetworkConnectivity {
|
|
4
|
+
listeners = /* @__PURE__ */ new Set();
|
|
5
|
+
connected;
|
|
6
|
+
unsubscribe;
|
|
7
|
+
static async create() {
|
|
8
|
+
const initialState = await NetInfo.fetch();
|
|
9
|
+
return new ExpoNetworkConnectivity(initialState.isConnected === true);
|
|
10
|
+
}
|
|
11
|
+
constructor(initialIsConnected) {
|
|
12
|
+
this.connected = initialIsConnected;
|
|
13
|
+
this.unsubscribe = NetInfo.addEventListener((state) => {
|
|
14
|
+
this.update(state.isConnected === true);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
get isConnected() {
|
|
18
|
+
return this.connected;
|
|
19
|
+
}
|
|
20
|
+
subscribe(listener) {
|
|
21
|
+
this.listeners.add(listener);
|
|
22
|
+
return () => {
|
|
23
|
+
this.listeners.delete(listener);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
close() {
|
|
27
|
+
this.unsubscribe();
|
|
28
|
+
this.listeners.clear();
|
|
29
|
+
}
|
|
30
|
+
update(isConnected) {
|
|
31
|
+
if (isConnected === this.connected) return;
|
|
32
|
+
this.connected = isConnected;
|
|
33
|
+
for (const listener of this.listeners) listener(isConnected);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ExpoNetworkConnectivity };
|
|
38
|
+
|
|
38
39
|
//# sourceMappingURL=ExpoNetworkConnectivity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoNetworkConnectivity.js","
|
|
1
|
+
{"version":3,"file":"ExpoNetworkConnectivity.js","names":[],"sources":["../src/ExpoNetworkConnectivity.ts"],"sourcesContent":["import NetInfo from \"@react-native-community/netinfo\";\nimport type { NetworkConnectivity } from \"@party-stack/runtime\";\n\nexport class ExpoNetworkConnectivity implements NetworkConnectivity {\n private readonly listeners = new Set<(isConnected: boolean) => void>();\n private connected: boolean;\n private readonly unsubscribe: () => void;\n\n static async create(): Promise<ExpoNetworkConnectivity> {\n const initialState = await NetInfo.fetch();\n return new ExpoNetworkConnectivity(initialState.isConnected === true);\n }\n\n private constructor(initialIsConnected: boolean) {\n this.connected = initialIsConnected;\n this.unsubscribe = NetInfo.addEventListener((state) => {\n this.update(state.isConnected === true);\n });\n }\n\n get isConnected(): boolean {\n return this.connected;\n }\n\n subscribe(listener: (isConnected: boolean) => void): () => void {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n }\n\n close(): void {\n this.unsubscribe();\n this.listeners.clear();\n }\n\n private update(isConnected: boolean): void {\n if (isConnected === this.connected) return;\n this.connected = isConnected;\n for (const listener of this.listeners) {\n listener(isConnected);\n }\n }\n}\n"],"mappings":";;AAGA,IAAa,0BAAb,MAAa,wBAAuD;CAChE,4BAA6B,IAAI,IAAoC;CACrE;CACA;CAEA,aAAa,SAA2C;EACpD,MAAM,eAAe,MAAM,QAAQ,MAAM;EACzC,OAAO,IAAI,wBAAwB,aAAa,gBAAgB,IAAI;CACxE;CAEA,YAAoB,oBAA6B;EAC7C,KAAK,YAAY;EACjB,KAAK,cAAc,QAAQ,kBAAkB,UAAU;GACnD,KAAK,OAAO,MAAM,gBAAgB,IAAI;EAC1C,CAAC;CACL;CAEA,IAAI,cAAuB;EACvB,OAAO,KAAK;CAChB;CAEA,UAAU,UAAsD;EAC5D,KAAK,UAAU,IAAI,QAAQ;EAC3B,aAAa;GACT,KAAK,UAAU,OAAO,QAAQ;EAClC;CACJ;CAEA,QAAc;EACV,KAAK,YAAY;EACjB,KAAK,UAAU,MAAM;CACzB;CAEA,OAAe,aAA4B;EACvC,IAAI,gBAAgB,KAAK,WAAW;EACpC,KAAK,YAAY;EACjB,KAAK,MAAM,YAAY,KAAK,WACxB,SAAS,WAAW;CAE5B;AACJ"}
|
package/lib/ExpoSecretStore.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SecretStore } from "@party-stack/runtime";
|
|
2
|
+
//#region src/ExpoSecretStore.d.ts
|
|
2
3
|
export declare class ExpoSecretStore implements SecretStore {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
private readonly prefix;
|
|
5
|
+
constructor(prefix: string);
|
|
6
|
+
get(key: string): Promise<string | undefined>;
|
|
7
|
+
set(key: string, value: string): Promise<void>;
|
|
8
|
+
delete(key: string): Promise<void>;
|
|
9
|
+
private key;
|
|
9
10
|
}
|
|
11
|
+
//#endregion
|
|
10
12
|
//# sourceMappingURL=ExpoSecretStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSecretStore.d.ts","
|
|
1
|
+
{"version":3,"file":"ExpoSecretStore.d.ts","names":[],"sources":["../src/ExpoSecretStore.ts"],"mappings":";;qBASa,2BAA2B;mBACP;EAA7B,YAA6B;EAE7B,IAAI,cAAc;EAIlB,IAAI,aAAa,gBAAgB;EAIjC,OAAO,cAAc;UAIb"}
|
package/lib/ExpoSecretStore.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { deleteItemAsync, getItemAsync, setItemAsync } from "expo-secure-store";
|
|
2
|
-
|
|
2
|
+
//#region src/ExpoSecretStore.ts
|
|
3
3
|
function encodeKey(value) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export class ExpoSecretStore {
|
|
8
|
-
prefix;
|
|
9
|
-
constructor(prefix) {
|
|
10
|
-
this.prefix = prefix;
|
|
11
|
-
}
|
|
12
|
-
get(key) {
|
|
13
|
-
return getItemAsync(this.key(key)).then((value) => value ?? undefined);
|
|
14
|
-
}
|
|
15
|
-
set(key, value) {
|
|
16
|
-
return setItemAsync(this.key(key), value);
|
|
17
|
-
}
|
|
18
|
-
delete(key) {
|
|
19
|
-
return deleteItemAsync(this.key(key));
|
|
20
|
-
}
|
|
21
|
-
key(key) {
|
|
22
|
-
return encodeKey(JSON.stringify([this.prefix, key]));
|
|
23
|
-
}
|
|
4
|
+
const bytes = new TextEncoder().encode(value);
|
|
5
|
+
return `party-stack.${Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
24
6
|
}
|
|
7
|
+
var ExpoSecretStore = class {
|
|
8
|
+
prefix;
|
|
9
|
+
constructor(prefix) {
|
|
10
|
+
this.prefix = prefix;
|
|
11
|
+
}
|
|
12
|
+
get(key) {
|
|
13
|
+
return getItemAsync(this.key(key)).then((value) => value ?? void 0);
|
|
14
|
+
}
|
|
15
|
+
set(key, value) {
|
|
16
|
+
return setItemAsync(this.key(key), value);
|
|
17
|
+
}
|
|
18
|
+
delete(key) {
|
|
19
|
+
return deleteItemAsync(this.key(key));
|
|
20
|
+
}
|
|
21
|
+
key(key) {
|
|
22
|
+
return encodeKey(JSON.stringify([this.prefix, key]));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ExpoSecretStore };
|
|
27
|
+
|
|
25
28
|
//# sourceMappingURL=ExpoSecretStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSecretStore.js","
|
|
1
|
+
{"version":3,"file":"ExpoSecretStore.js","names":[],"sources":["../src/ExpoSecretStore.ts"],"sourcesContent":["import { deleteItemAsync, getItemAsync, setItemAsync } from \"expo-secure-store\";\nimport type { SecretStore } from \"@party-stack/runtime\";\n\n// https://docs.expo.dev/versions/latest/sdk/securestore#securestoresetitemkey-value-options\nfunction encodeKey(value: string): string {\n const bytes = new TextEncoder().encode(value);\n return `party-stack.${Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\nexport class ExpoSecretStore implements SecretStore {\n constructor(private readonly prefix: string) {}\n\n get(key: string): Promise<string | undefined> {\n return getItemAsync(this.key(key)).then((value) => value ?? undefined);\n }\n\n set(key: string, value: string): Promise<void> {\n return setItemAsync(this.key(key), value);\n }\n\n delete(key: string): Promise<void> {\n return deleteItemAsync(this.key(key));\n }\n\n private key(key: string): string {\n return encodeKey(JSON.stringify([this.prefix, key]));\n }\n}\n"],"mappings":";;AAIA,SAAS,UAAU,OAAuB;CACtC,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;CAC5C,OAAO,eAAe,MAAM,KAAK,QAAQ,SAAS,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;AACjG;AAEA,IAAa,kBAAb,MAAoD;CACnB;CAA7B,YAAY,QAAiC;EAAhB,KAAA,SAAA;CAAiB;CAE9C,IAAI,KAA0C;EAC1C,OAAO,aAAa,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,UAAU,SAAS,KAAA,CAAS;CACzE;CAEA,IAAI,KAAa,OAA8B;EAC3C,OAAO,aAAa,KAAK,IAAI,GAAG,GAAG,KAAK;CAC5C;CAEA,OAAO,KAA4B;EAC/B,OAAO,gBAAgB,KAAK,IAAI,GAAG,CAAC;CACxC;CAEA,IAAY,KAAqB;EAC7B,OAAO,UAAU,KAAK,UAAU,CAAC,KAAK,QAAQ,GAAG,CAAC,CAAC;CACvD;AACJ"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BrowserAuthentication } from "@party-stack/runtime";
|
|
2
|
+
//#region src/createExpoBrowserAuthentication.d.ts
|
|
2
3
|
export declare function createExpoBrowserAuthentication(): BrowserAuthentication;
|
|
4
|
+
//#endregion
|
|
3
5
|
//# sourceMappingURL=createExpoBrowserAuthentication.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoBrowserAuthentication.d.ts","
|
|
1
|
+
{"version":3,"file":"createExpoBrowserAuthentication.d.ts","names":[],"sources":["../src/createExpoBrowserAuthentication.ts"],"mappings":";;wBAGgB,mCAAmC"}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { BrowserAuthenticationCancelledError
|
|
2
|
-
import { dismissAuthSession, openAuthSessionAsync
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
dismissAuthSession();
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
};
|
|
1
|
+
import { BrowserAuthenticationCancelledError } from "@party-stack/runtime";
|
|
2
|
+
import { dismissAuthSession, openAuthSessionAsync } from "expo-web-browser";
|
|
3
|
+
//#region src/createExpoBrowserAuthentication.ts
|
|
4
|
+
function createExpoBrowserAuthentication() {
|
|
5
|
+
return { start({ redirectUrl }) {
|
|
6
|
+
return {
|
|
7
|
+
async open(authorizationUrl) {
|
|
8
|
+
const result = await openAuthSessionAsync(authorizationUrl, redirectUrl);
|
|
9
|
+
if (result.type === "success") return { callbackUrl: result.url };
|
|
10
|
+
throw new BrowserAuthenticationCancelledError();
|
|
11
|
+
},
|
|
12
|
+
close() {
|
|
13
|
+
dismissAuthSession();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
} };
|
|
22
17
|
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { createExpoBrowserAuthentication };
|
|
20
|
+
|
|
23
21
|
//# sourceMappingURL=createExpoBrowserAuthentication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoBrowserAuthentication.js","
|
|
1
|
+
{"version":3,"file":"createExpoBrowserAuthentication.js","names":[],"sources":["../src/createExpoBrowserAuthentication.ts"],"sourcesContent":["import { BrowserAuthenticationCancelledError, type BrowserAuthentication } from \"@party-stack/runtime\";\nimport { dismissAuthSession, openAuthSessionAsync } from \"expo-web-browser\";\n\nexport function createExpoBrowserAuthentication(): BrowserAuthentication {\n return {\n start({ redirectUrl }) {\n return {\n async open(authorizationUrl) {\n const result = await openAuthSessionAsync(authorizationUrl, redirectUrl);\n if (result.type === \"success\") {\n return {\n callbackUrl: result.url,\n };\n }\n throw new BrowserAuthenticationCancelledError();\n },\n close() {\n dismissAuthSession();\n },\n };\n },\n };\n}\n"],"mappings":";;;AAGA,SAAgB,kCAAyD;CACrE,OAAO,EACH,MAAM,EAAE,eAAe;EACnB,OAAO;GACH,MAAM,KAAK,kBAAkB;IACzB,MAAM,SAAS,MAAM,qBAAqB,kBAAkB,WAAW;IACvE,IAAI,OAAO,SAAS,WAChB,OAAO,EACH,aAAa,OAAO,IACxB;IAEJ,MAAM,IAAI,oCAAoC;GAClD;GACA,QAAQ;IACJ,mBAAmB;GACvB;EACJ;CACJ,EACJ;AACJ"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { RuntimeAdapter } from "@party-stack/runtime";
|
|
1
2
|
import "temporal-polyfill/global";
|
|
2
|
-
|
|
3
|
+
//#region src/createExpoRuntime.d.ts
|
|
4
|
+
export declare const createExpoRuntime: (owner: string, namespace: string) => Promise<RuntimeAdapter>;
|
|
5
|
+
//#endregion
|
|
3
6
|
//# sourceMappingURL=createExpoRuntime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoRuntime.d.ts","
|
|
1
|
+
{"version":3,"file":"createExpoRuntime.d.ts","names":[],"sources":["../src/createExpoRuntime.ts"],"mappings":";;;qBAaa,oBAAoB,eAAe,sBAAsB,QAAQ"}
|
package/lib/createExpoRuntime.js
CHANGED
|
@@ -1,48 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
import "temporal-polyfill/global";
|
|
3
|
-
import { SingleProcessCoordination } from "@party-stack/coordination";
|
|
4
|
-
import { defineRuntime } from "@party-stack/runtime";
|
|
5
|
-
import { createExpoSQLitePersistence, } from "@tanstack/expo-db-sqlite-persistence";
|
|
6
|
-
import { deleteDatabaseAsync, openDatabaseAsync } from "expo-sqlite";
|
|
7
|
-
import { createExpoBrowserAuthentication } from "./createExpoBrowserAuthentication.js";
|
|
1
|
+
import { hashStorageName } from "./hashStorageName.js";
|
|
8
2
|
import { ExpoFileSystemBlobBytesStore } from "./ExpoFileSystemBlobBytesStore.js";
|
|
9
3
|
import { ExpoNetworkConnectivity } from "./ExpoNetworkConnectivity.js";
|
|
10
4
|
import { ExpoSecretStore } from "./ExpoSecretStore.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
connectivity.close();
|
|
44
|
-
await database.closeAsync();
|
|
45
|
-
},
|
|
46
|
-
};
|
|
5
|
+
import { createExpoBrowserAuthentication } from "./createExpoBrowserAuthentication.js";
|
|
6
|
+
import { defineRuntime } from "@party-stack/runtime";
|
|
7
|
+
import "temporal-polyfill/global";
|
|
8
|
+
import { SingleProcessCoordination } from "@party-stack/coordination";
|
|
9
|
+
import { createExpoSQLitePersistence } from "@tanstack/expo-db-sqlite-persistence";
|
|
10
|
+
import { deleteDatabaseAsync, openDatabaseAsync } from "expo-sqlite";
|
|
11
|
+
//#region src/createExpoRuntime.ts
|
|
12
|
+
const createExpoRuntime = defineRuntime(async (owner, namespace) => {
|
|
13
|
+
const name = `party-stack:${owner}:${namespace}`;
|
|
14
|
+
const storageName = `party-stack-${await hashStorageName(JSON.stringify([owner, namespace]))}`;
|
|
15
|
+
const [database, connectivity] = await Promise.all([openDatabaseAsync(`${storageName}.db`), ExpoNetworkConnectivity.create()]);
|
|
16
|
+
const persistence = createExpoSQLitePersistence({ database });
|
|
17
|
+
const coordination = new SingleProcessCoordination({ scope: name });
|
|
18
|
+
const blobBytes = new ExpoFileSystemBlobBytesStore({ directoryName: `${storageName}-blobs` });
|
|
19
|
+
return {
|
|
20
|
+
owner,
|
|
21
|
+
namespace,
|
|
22
|
+
blobBytes,
|
|
23
|
+
browserAuthentication: createExpoBrowserAuthentication(),
|
|
24
|
+
secrets: new ExpoSecretStore(`${name}:secrets`),
|
|
25
|
+
connectivity,
|
|
26
|
+
coordination,
|
|
27
|
+
persistence,
|
|
28
|
+
destroy: async () => {
|
|
29
|
+
await Promise.all([deleteDatabaseAsync(`${storageName}.db`), blobBytes.clear()]);
|
|
30
|
+
},
|
|
31
|
+
cleanup: async () => {
|
|
32
|
+
await coordination.close();
|
|
33
|
+
connectivity.close();
|
|
34
|
+
await database.closeAsync();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
47
37
|
});
|
|
38
|
+
//#endregion
|
|
39
|
+
export { createExpoRuntime };
|
|
40
|
+
|
|
48
41
|
//# sourceMappingURL=createExpoRuntime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpoRuntime.js","
|
|
1
|
+
{"version":3,"file":"createExpoRuntime.js","names":[],"sources":["../src/createExpoRuntime.ts"],"sourcesContent":["// SQLite persistence revives Temporal values through the registered global constructors.\nimport \"temporal-polyfill/global\";\nimport { SingleProcessCoordination } from \"@party-stack/coordination\";\nimport { defineRuntime } from \"@party-stack/runtime\";\nimport { createExpoSQLitePersistence } from \"@tanstack/expo-db-sqlite-persistence\";\nimport { deleteDatabaseAsync, openDatabaseAsync } from \"expo-sqlite\";\nimport { createExpoBrowserAuthentication } from \"./createExpoBrowserAuthentication.js\";\nimport { ExpoFileSystemBlobBytesStore } from \"./ExpoFileSystemBlobBytesStore.js\";\nimport { ExpoNetworkConnectivity } from \"./ExpoNetworkConnectivity.js\";\nimport { ExpoSecretStore } from \"./ExpoSecretStore.js\";\nimport { hashStorageName } from \"./hashStorageName.js\";\nimport type { RuntimeAdapter } from \"@party-stack/runtime\";\n\nexport const createExpoRuntime: (owner: string, namespace: string) => Promise<RuntimeAdapter> = defineRuntime(\n async (owner, namespace) => {\n const name = `party-stack:${owner}:${namespace}`;\n const storageName = `party-stack-${await hashStorageName(JSON.stringify([owner, namespace]))}`;\n const [database, connectivity] = await Promise.all([\n openDatabaseAsync(`${storageName}.db`),\n ExpoNetworkConnectivity.create(),\n ]);\n const persistence = createExpoSQLitePersistence({\n database: database,\n });\n const coordination = new SingleProcessCoordination({\n scope: name,\n });\n const blobBytes = new ExpoFileSystemBlobBytesStore({\n directoryName: `${storageName}-blobs`,\n });\n return {\n owner,\n namespace,\n blobBytes,\n browserAuthentication: createExpoBrowserAuthentication(),\n secrets: new ExpoSecretStore(`${name}:secrets`),\n connectivity,\n coordination,\n persistence,\n destroy: async () => {\n await Promise.all([deleteDatabaseAsync(`${storageName}.db`), blobBytes.clear()]);\n },\n cleanup: async () => {\n await coordination.close();\n connectivity.close();\n await database.closeAsync();\n },\n };\n }\n);\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,oBAAmF,cAC5F,OAAO,OAAO,cAAc;CACxB,MAAM,OAAO,eAAe,MAAM,GAAG;CACrC,MAAM,cAAc,eAAe,MAAM,gBAAgB,KAAK,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;CAC3F,MAAM,CAAC,UAAU,gBAAgB,MAAM,QAAQ,IAAI,CAC/C,kBAAkB,GAAG,YAAY,IAAI,GACrC,wBAAwB,OAAO,CACnC,CAAC;CACD,MAAM,cAAc,4BAA4B,EAClC,SACd,CAAC;CACD,MAAM,eAAe,IAAI,0BAA0B,EAC/C,OAAO,KACX,CAAC;CACD,MAAM,YAAY,IAAI,6BAA6B,EAC/C,eAAe,GAAG,YAAY,QAClC,CAAC;CACD,OAAO;EACH;EACA;EACA;EACA,uBAAuB,gCAAgC;EACvD,SAAS,IAAI,gBAAgB,GAAG,KAAK,SAAS;EAC9C;EACA;EACA;EACA,SAAS,YAAY;GACjB,MAAM,QAAQ,IAAI,CAAC,oBAAoB,GAAG,YAAY,IAAI,GAAG,UAAU,MAAM,CAAC,CAAC;EACnF;EACA,SAAS,YAAY;GACjB,MAAM,aAAa,MAAM;GACzB,aAAa,MAAM;GACnB,MAAM,SAAS,WAAW;EAC9B;CACJ;AACJ,CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashStorageName.d.ts","names":[],"sources":["../src/hashStorageName.ts"],"mappings":";wBAEgB,gBAAgB,gBAAgB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CryptoDigestAlgorithm, digestStringAsync } from "expo-crypto";
|
|
2
|
+
//#region src/hashStorageName.ts
|
|
3
|
+
function hashStorageName(value) {
|
|
4
|
+
return digestStringAsync(CryptoDigestAlgorithm.SHA256, value);
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { hashStorageName };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=hashStorageName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashStorageName.js","names":[],"sources":["../src/hashStorageName.ts"],"sourcesContent":["import { CryptoDigestAlgorithm, digestStringAsync } from \"expo-crypto\";\n\nexport function hashStorageName(value: string): Promise<string> {\n return digestStringAsync(CryptoDigestAlgorithm.SHA256, value);\n}\n"],"mappings":";;AAEA,SAAgB,gBAAgB,OAAgC;CAC5D,OAAO,kBAAkB,sBAAsB,QAAQ,KAAK;AAChE"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { createExpoRuntime } from "./createExpoRuntime.js";
|
|
2
|
+
export { createExpoRuntime };
|
package/lib/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/lib/polyfill.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Blob } from "expo-blob";
|
|
2
|
+
//#region src/polyfill.ts
|
|
3
|
+
globalThis.Blob = Blob;
|
|
4
|
+
var ExpoFile = class extends globalThis.Blob {
|
|
5
|
+
#name;
|
|
6
|
+
#lastModified;
|
|
7
|
+
constructor(parts, name, options = {}) {
|
|
8
|
+
super(parts, options);
|
|
9
|
+
this.#name = String(name);
|
|
10
|
+
this.#lastModified = options.lastModified ?? Date.now();
|
|
11
|
+
Object.defineProperty(this, "name", {
|
|
12
|
+
value: this.#name,
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
get name() {
|
|
17
|
+
return this.#name;
|
|
18
|
+
}
|
|
19
|
+
get lastModified() {
|
|
20
|
+
return this.#lastModified;
|
|
21
|
+
}
|
|
22
|
+
get webkitRelativePath() {
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
25
|
+
get [Symbol.toStringTag]() {
|
|
26
|
+
return "File";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
globalThis.File = ExpoFile;
|
|
30
|
+
//#endregion
|
|
31
|
+
export {};
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=polyfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polyfill.js","names":[],"sources":["../src/polyfill.ts"],"sourcesContent":["import { Blob } from \"expo-blob\";\n\n// Expo declarations predate the current DOM Blob byte-array generics.\nglobalThis.Blob = Blob as unknown as typeof globalThis.Blob;\n\n// React Native File extends its own Blob class, so replace it alongside Blob.\nclass ExpoFile extends globalThis.Blob implements File {\n readonly #name: string;\n readonly #lastModified: number;\n\n constructor(parts: BlobPart[], name: string, options: FilePropertyBag = {}) {\n super(parts, options);\n this.#name = String(name);\n this.#lastModified = options.lastModified ?? Date.now();\n // Expo FormData checks own descriptors before assigning a blob filename.\n // An inherited getter alone would make that assignment throw.\n Object.defineProperty(this, \"name\", { value: this.#name, enumerable: true });\n }\n\n get name(): string {\n return this.#name;\n }\n\n get lastModified(): number {\n return this.#lastModified;\n }\n\n get webkitRelativePath(): string {\n return \"\";\n }\n\n get [Symbol.toStringTag](): string {\n return \"File\";\n }\n}\n\nglobalThis.File = ExpoFile;\n"],"mappings":";;AAGA,WAAW,OAAO;AAGlB,IAAM,WAAN,cAAuB,WAAW,KAAqB;CACnD;CACA;CAEA,YAAY,OAAmB,MAAc,UAA2B,CAAC,GAAG;EACxE,MAAM,OAAO,OAAO;EACpB,KAAK,QAAQ,OAAO,IAAI;EACxB,KAAK,gBAAgB,QAAQ,gBAAgB,KAAK,IAAI;EAGtD,OAAO,eAAe,MAAM,QAAQ;GAAE,OAAO,KAAK;GAAO,YAAY;EAAK,CAAC;CAC/E;CAEA,IAAI,OAAe;EACf,OAAO,KAAK;CAChB;CAEA,IAAI,eAAuB;EACvB,OAAO,KAAK;CAChB;CAEA,IAAI,qBAA6B;EAC7B,OAAO;CACX;CAEA,KAAK,OAAO,eAAuB;EAC/B,OAAO;CACX;AACJ;AAEA,WAAW,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@party-stack/expo-runtime",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"files": [
|
|
5
|
+
"lib"
|
|
6
|
+
],
|
|
4
7
|
"type": "module",
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"./lib/polyfill.js"
|
|
10
|
+
],
|
|
5
11
|
"exports": {
|
|
6
12
|
".": {
|
|
7
13
|
"types": "./lib/index.d.ts",
|
|
8
14
|
"default": "./lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./polyfill": {
|
|
17
|
+
"types": "./lib/polyfill.d.ts",
|
|
18
|
+
"default": "./lib/polyfill.js"
|
|
9
19
|
}
|
|
10
20
|
},
|
|
11
|
-
"files": [
|
|
12
|
-
"lib"
|
|
13
|
-
],
|
|
14
21
|
"dependencies": {
|
|
15
|
-
"@tanstack/expo-db-sqlite-persistence": "0.2.
|
|
16
|
-
"expo-
|
|
17
|
-
"expo-
|
|
22
|
+
"@tanstack/expo-db-sqlite-persistence": "0.2.34",
|
|
23
|
+
"expo-blob": "^57.0.2",
|
|
24
|
+
"expo-crypto": "^57.0.4",
|
|
25
|
+
"expo-secure-store": "^57.0.4",
|
|
26
|
+
"expo-web-browser": "^57.0.3",
|
|
18
27
|
"temporal-polyfill": "^0.3.0",
|
|
19
|
-
"@party-stack/coordination": "0.3.
|
|
20
|
-
"@party-stack/runtime": "0.4.
|
|
28
|
+
"@party-stack/coordination": "0.3.1",
|
|
29
|
+
"@party-stack/runtime": "0.4.2"
|
|
21
30
|
},
|
|
22
31
|
"devDependencies": {
|
|
23
|
-
"@bobbyfidz/universal-build-config": "^0.1.1",
|
|
24
32
|
"@react-native-community/netinfo": "^12.0.1",
|
|
25
|
-
"
|
|
26
|
-
"expo-file-system": "^
|
|
27
|
-
"expo-sqlite": "^
|
|
28
|
-
"typescript": "~
|
|
29
|
-
"
|
|
33
|
+
"expo": "^57.0.29",
|
|
34
|
+
"expo-file-system": "^57.0.7",
|
|
35
|
+
"expo-sqlite": "^57.0.4",
|
|
36
|
+
"typescript": "~7.0.2",
|
|
37
|
+
"vite-plus": "1.2.0",
|
|
38
|
+
"@party-stack/build-config": "0.1.3"
|
|
30
39
|
},
|
|
31
40
|
"peerDependencies": {
|
|
32
41
|
"@react-native-community/netinfo": "^12.0.1",
|
|
33
|
-
"expo
|
|
34
|
-
"expo-
|
|
35
|
-
|
|
36
|
-
"scripts": {
|
|
37
|
-
"build": "tsc",
|
|
38
|
-
"lint": "eslint",
|
|
39
|
-
"test": "vitest run --pass-with-no-tests"
|
|
42
|
+
"expo": "^57.0.29",
|
|
43
|
+
"expo-file-system": "^57.0.7",
|
|
44
|
+
"expo-sqlite": "^57.0.4"
|
|
40
45
|
}
|
|
41
46
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSecretStore.test.d.ts","sourceRoot":"","sources":["../src/ExpoSecretStore.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi, } from "vitest";
|
|
2
|
-
import { ExpoSecretStore } from "./ExpoSecretStore.js";
|
|
3
|
-
const secureStore = vi.hoisted(() => ({
|
|
4
|
-
deleteItemAsync: vi.fn((key) => {
|
|
5
|
-
void key;
|
|
6
|
-
return Promise.resolve();
|
|
7
|
-
}),
|
|
8
|
-
getItemAsync: vi.fn((key) => {
|
|
9
|
-
void key;
|
|
10
|
-
return Promise.resolve(null);
|
|
11
|
-
}),
|
|
12
|
-
setItemAsync: vi.fn((key, value) => {
|
|
13
|
-
void key;
|
|
14
|
-
void value;
|
|
15
|
-
return Promise.resolve();
|
|
16
|
-
}),
|
|
17
|
-
}));
|
|
18
|
-
vi.mock("expo-secure-store", () => secureStore);
|
|
19
|
-
describe("ExpoSecretStore", () => {
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
vi.clearAllMocks();
|
|
22
|
-
});
|
|
23
|
-
it("encodes namespaced keys using only SecureStore-safe characters", async () => {
|
|
24
|
-
const store = new ExpoSecretStore("party-stack:user@example.com:oauth");
|
|
25
|
-
await store.set("tokens/client:id", "secret");
|
|
26
|
-
const key = secureStore.setItemAsync
|
|
27
|
-
.mock.calls[0]?.[0];
|
|
28
|
-
expect(key).toMatch(/^[A-Za-z0-9._-]+$/);
|
|
29
|
-
expect(key).not.toContain("user@example.com");
|
|
30
|
-
expect(secureStore.setItemAsync).toHaveBeenCalledWith(key, "secret");
|
|
31
|
-
});
|
|
32
|
-
it("separates prefix and key without collisions", async () => {
|
|
33
|
-
await new ExpoSecretStore("a").set("b:c", "one");
|
|
34
|
-
await new ExpoSecretStore("a:b").set("c", "two");
|
|
35
|
-
expect(secureStore.setItemAsync
|
|
36
|
-
.mock.calls[0]?.[0]).not.toBe(secureStore.setItemAsync
|
|
37
|
-
.mock.calls[1]?.[0]);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
//# sourceMappingURL=ExpoSecretStore.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoSecretStore.test.js","sourceRoot":"","sources":["../src/ExpoSecretStore.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,QAAQ,EACR,MAAM,EACN,EAAE,EACF,EAAE,GACL,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAClC,eAAe,EAAE,EAAE,CAAC,EAAE,CAClB,CAAC,GAAW,EAAE,EAAE;QACZ,KAAK,GAAG,CAAC;QACT,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC,CACJ;IACD,YAAY,EAAE,EAAE,CAAC,EAAE,CACf,CAAC,GAAW,EAAE,EAAE;QACZ,KAAK,GAAG,CAAC;QACT,OAAO,OAAO,CAAC,OAAO,CAClB,IAAI,CACP,CAAC;IACN,CAAC,CACJ;IACD,YAAY,EAAE,EAAE,CAAC,EAAE,CACf,CACI,GAAW,EACX,KAAa,EACf,EAAE;QACA,KAAK,GAAG,CAAC;QACT,KAAK,KAAK,CAAC;QACX,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC,CACJ;CACJ,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAC9B,WAAW,CACd,CAAC;AAEF,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,UAAU,CAAC,GAAG,EAAE;QACZ,EAAE,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;QAC5E,MAAM,KAAK,GACP,IAAI,eAAe,CACf,oCAAoC,CACvC,CAAC;QAEN,MAAM,KAAK,CAAC,GAAG,CACX,kBAAkB,EAClB,QAAQ,CACX,CAAC;QAEF,MAAM,GAAG,GACL,WAAW,CAAC,YAAY;aACnB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CACf,mBAAmB,CACtB,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CACrB,kBAAkB,CACrB,CAAC;QACF,MAAM,CACF,WAAW,CAAC,YAAY,CAC3B,CAAC,oBAAoB,CAClB,GAAG,EACH,QAAQ,CACX,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,IAAI,eAAe,CACrB,GAAG,CACN,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpB,MAAM,IAAI,eAAe,CACrB,KAAK,CACR,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAElB,MAAM,CACF,WAAW,CAAC,YAAY;aACnB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAC1B,CAAC,GAAG,CAAC,IAAI,CACN,WAAW,CAAC,YAAY;aACnB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAC1B,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|