Skip to content

Commit

Permalink
feat: update type definitions for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
iykazrji committed Nov 19, 2024
1 parent 3711960 commit 162db38
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class NativeTEKStamperModule(reactContext: ReactApplicationContext) :
MasterKey.Builder(context.applicationContext)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
// requires that the phone be unlocked
.setUserAuthenticationRequired(true)
.setUserAuthenticationRequired(false)
.build()

/**
Expand Down
2 changes: 1 addition & 1 deletion account-kit/rn-signer/example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const pkg = require("../package.json");

const root = path.resolve(__dirname, "..");
// handles the hoisted modules
const repoRoot = path.resolve(__dirname, "../../../node_modules");
const repoRoot = path.resolve(__dirname, "../../..");

/**
* Metro configuration
Expand Down
11 changes: 7 additions & 4 deletions account-kit/rn-signer/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ import {
type User,
} from "@account-kit/signer";
import NativeTEKStamper from "./NativeTEKStamper";
import { z } from "zod";

export type RNSignerClientParams = {
connection: ConnectionConfig;
rootOrgId?: string;
};
export const RNSignerClientParamsSchema = z.object({
connection: z.custom<ConnectionConfig>(),
rootOrgId: z.string().optional(),
});

export type RNSignerClientParams = z.input<typeof RNSignerClientParamsSchema>;

// TODO: need to emit events
export class RNSignerClient extends BaseSignerClient<undefined> {
Expand Down
39 changes: 39 additions & 0 deletions account-kit/rn-signer/src/signer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { z } from "zod";
import {
BaseAlchemySigner,
SessionManagerParamsSchema,
} from "@account-kit/signer";
// eslint-disable-next-line import/extensions
import { RNSignerClient, RNSignerClientParamsSchema } from "./client";

const RNAlchemySignerParamsSchema = z
.object({
client: z.custom<RNSignerClient>().or(RNSignerClientParamsSchema),
})
.extend({
sessionConfig: SessionManagerParamsSchema.omit({
client: true,
storage: true,
}).optional(),
});

export type RNAlchemySignerParams = z.input<typeof RNAlchemySignerParamsSchema>;

export class RNAlchemySigner extends BaseAlchemySigner<RNSignerClient> {
constructor(params: RNAlchemySignerParams) {
const { sessionConfig, ...params_ } =
RNAlchemySignerParamsSchema.parse(params);

let client: RNSignerClient;

if ("connection" in params_.client) {
client = new RNSignerClient(params_.client);
} else {
client = params_.client;
}
super({
client,
sessionConfig,
});
}
}
5 changes: 4 additions & 1 deletion account-kit/signer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export {
OauthFailedError,
} from "./client/index.js";
export type * from "./client/types.js";
export { DEFAULT_SESSION_MS } from "./session/manager.js";
export {
DEFAULT_SESSION_MS,
SessionManagerParamsSchema,
} from "./session/manager.js";
export type * from "./signer.js";
export { AlchemyWebSigner } from "./signer.js";
export type * from "./types.js";
Expand Down

0 comments on commit 162db38

Please sign in to comment.