this repo has no description
1import type { Key, RuntimeImplementation } from "@atproto/oauth-client";
2import { default as NativeModule } from "./ExpoAtprotoAuthModule";
3import { generateJwk } from "./react-native-key";
4
5export class ReactNativeRuntimeImplementation implements RuntimeImplementation {
6 async createKey(algs: string[]): Promise<Key> {
7 if (!algs.includes("ES256")) {
8 throw TypeError("ES256 is the only supported algo");
9 }
10 // @ts-expect-error TODO:
11 return generateJwk("ES256");
12 }
13
14 getRandomValues(length: number): Uint8Array | PromiseLike<Uint8Array> {
15 return NativeModule.getRandomValues(length);
16 }
17
18 digest(
19 bytes: Uint8Array,
20 algorithim: { name: string },
21 ): Uint8Array | PromiseLike<Uint8Array> {
22 if (algorithim.name == "sha256") {
23 return NativeModule.digest(bytes, algorithim.name);
24 }
25
26 throw new TypeError(`Unsupported algorithim: ${algorithim.name}`);
27 }
28}