@farcaster/frame-core 0.0.21 → 0.0.23

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.
Files changed (70) hide show
  1. package/dist/actions/AddFrame.d.ts +36 -0
  2. package/dist/actions/AddFrame.js +57 -0
  3. package/dist/actions/{signIn.d.ts → SignIn.d.ts} +7 -6
  4. package/dist/actions/{signIn.js → SignIn.js} +1 -1
  5. package/dist/actions/index.d.ts +2 -0
  6. package/dist/actions/index.js +38 -0
  7. package/dist/context.d.ts +72 -0
  8. package/dist/context.js +2 -0
  9. package/dist/errors.js +1 -1
  10. package/dist/index.d.ts +4 -3
  11. package/dist/index.js +6 -5
  12. package/dist/internal/types.d.ts +3 -2
  13. package/dist/schemas/embeds.d.ts +1 -1
  14. package/dist/schemas/embeds.js +3 -3
  15. package/dist/schemas/events.d.ts +1 -1
  16. package/dist/schemas/events.js +5 -5
  17. package/dist/schemas/index.d.ts +5 -5
  18. package/dist/schemas/manifest.d.ts +1 -1
  19. package/dist/schemas/manifest.js +4 -4
  20. package/dist/schemas/notifications.d.ts +1 -1
  21. package/dist/schemas/shared.d.ts +1 -1
  22. package/dist/schemas/shared.js +4 -4
  23. package/dist/types.d.ts +40 -80
  24. package/esm/actions/AddFrame.d.ts +40 -0
  25. package/esm/actions/AddFrame.js +19 -0
  26. package/esm/actions/SignIn.d.ts +43 -0
  27. package/esm/actions/SignIn.js +10 -0
  28. package/esm/actions/index.d.ts +2 -0
  29. package/esm/actions/index.js +2 -0
  30. package/esm/context.d.ts +76 -0
  31. package/esm/context.js +1 -0
  32. package/esm/errors.d.ts +9 -7
  33. package/esm/errors.js +6 -6
  34. package/esm/index.d.ts +4 -3
  35. package/esm/index.js +4 -3
  36. package/esm/internal/types.d.ts +19 -7
  37. package/esm/internal/types.js +1 -1
  38. package/esm/schemas/embeds.d.ts +231 -169
  39. package/esm/schemas/embeds.js +25 -19
  40. package/esm/schemas/events.d.ts +225 -129
  41. package/esm/schemas/events.js +18 -18
  42. package/esm/schemas/index.d.ts +5 -5
  43. package/esm/schemas/index.js +5 -5
  44. package/esm/schemas/manifest.d.ts +154 -110
  45. package/esm/schemas/manifest.js +29 -23
  46. package/esm/schemas/notifications.d.ts +86 -58
  47. package/esm/schemas/notifications.js +17 -17
  48. package/esm/schemas/shared.d.ts +49 -33
  49. package/esm/schemas/shared.js +20 -19
  50. package/esm/tsconfig.tsbuildinfo +1 -1
  51. package/esm/types.d.ts +132 -147
  52. package/esm/types.js +2 -2
  53. package/package.json +4 -5
  54. package/src/actions/AddFrame.ts +51 -0
  55. package/src/actions/SignIn.ts +51 -0
  56. package/src/actions/index.ts +2 -0
  57. package/src/context.ts +90 -0
  58. package/src/errors.ts +4 -4
  59. package/src/index.ts +4 -3
  60. package/src/internal/types.ts +3 -4
  61. package/src/schemas/embeds.ts +13 -13
  62. package/src/schemas/events.ts +17 -17
  63. package/src/schemas/index.ts +5 -5
  64. package/src/schemas/manifest.ts +11 -11
  65. package/src/schemas/notifications.ts +8 -10
  66. package/src/schemas/shared.ts +13 -13
  67. package/src/types.ts +88 -149
  68. package/esm/actions/signIn.d.ts +0 -40
  69. package/esm/actions/signIn.js +0 -10
  70. package/src/actions/signIn.ts +0 -50
@@ -0,0 +1,36 @@
1
+ import * as Errors from '../errors';
2
+ import type { OneOf } from '../internal/types';
3
+ import type { FrameNotificationDetails } from '../schemas';
4
+ export type AddFrameResult = {
5
+ notificationDetails?: FrameNotificationDetails;
6
+ };
7
+ export type AddFrame = () => Promise<AddFrameResult>;
8
+ type InvalidDomainManifestJsonError = {
9
+ type: 'invalid_domain_manifest';
10
+ };
11
+ type RejectedByUserJsonError = {
12
+ type: 'rejected_by_user';
13
+ };
14
+ export type AddFrameJsonError = InvalidDomainManifestJsonError | RejectedByUserJsonError;
15
+ export type AddFrameRejectedReason = AddFrameJsonError['type'];
16
+ export type AddFrameJsonResult = OneOf<{
17
+ result: AddFrameResult;
18
+ } | {
19
+ error: AddFrameJsonError;
20
+ }>;
21
+ export type WireAddFrame = () => Promise<AddFrameJsonResult>;
22
+ /**
23
+ * Thrown when the frame does not have a valid domain manifest.
24
+ */
25
+ export declare class InvalidDomainManifest extends Errors.BaseError {
26
+ readonly name = "AddFrame.InvalidDomainManifest";
27
+ constructor();
28
+ }
29
+ /**
30
+ * Thrown when add frame action was rejected by the user.
31
+ */
32
+ export declare class RejectedByUser extends Errors.BaseError {
33
+ readonly name = "AddFrame.RejectedByUser";
34
+ constructor();
35
+ }
36
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.RejectedByUser = exports.InvalidDomainManifest = void 0;
37
+ const Errors = __importStar(require("../errors"));
38
+ /**
39
+ * Thrown when the frame does not have a valid domain manifest.
40
+ */
41
+ class InvalidDomainManifest extends Errors.BaseError {
42
+ name = 'AddFrame.InvalidDomainManifest';
43
+ constructor() {
44
+ super('Invalid domain manifest');
45
+ }
46
+ }
47
+ exports.InvalidDomainManifest = InvalidDomainManifest;
48
+ /**
49
+ * Thrown when add frame action was rejected by the user.
50
+ */
51
+ class RejectedByUser extends Errors.BaseError {
52
+ name = 'AddFrame.RejectedByUser';
53
+ constructor() {
54
+ super('Add frame rejected by user');
55
+ }
56
+ }
57
+ exports.RejectedByUser = RejectedByUser;
@@ -1,5 +1,5 @@
1
1
  import * as Errors from '../errors';
2
- import { OneOf } from '../internal/types';
2
+ import type { OneOf } from '../internal/types';
3
3
  export type SignInOptions = {
4
4
  /**
5
5
  * A random string used to prevent replay attacks.
@@ -21,16 +21,16 @@ export type SignInResult = {
21
21
  message: string;
22
22
  };
23
23
  export type SignIn = (options: SignInOptions) => Promise<SignInResult>;
24
- export type RejectedByUserError = {
24
+ type RejectedByUserJsonError = {
25
25
  type: 'rejected_by_user';
26
26
  };
27
- export type JsonSignInError = RejectedByUserError;
28
- export type WireSignInResponse = OneOf<{
27
+ export type SignInJsonError = RejectedByUserJsonError;
28
+ export type SignInJsonResult = OneOf<{
29
29
  result: SignInResult;
30
30
  } | {
31
- error: JsonSignInError;
31
+ error: SignInJsonError;
32
32
  }>;
33
- export type WireSignIn = (options: SignInOptions) => Promise<WireSignInResponse>;
33
+ export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>;
34
34
  /**
35
35
  * Thrown when a sign in action was rejected.
36
36
  */
@@ -38,3 +38,4 @@ export declare class RejectedByUser extends Errors.BaseError {
38
38
  readonly name = "SignIn.RejectedByUser";
39
39
  constructor();
40
40
  }
41
+ export {};
@@ -41,7 +41,7 @@ const Errors = __importStar(require("../errors"));
41
41
  class RejectedByUser extends Errors.BaseError {
42
42
  name = 'SignIn.RejectedByUser';
43
43
  constructor() {
44
- super("Sign in rejected by user");
44
+ super('Sign in rejected by user');
45
45
  }
46
46
  }
47
47
  exports.RejectedByUser = RejectedByUser;
@@ -0,0 +1,2 @@
1
+ export * as AddFrame from './AddFrame';
2
+ export * as SignIn from './SignIn';
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SignIn = exports.AddFrame = void 0;
37
+ exports.AddFrame = __importStar(require("./AddFrame"));
38
+ exports.SignIn = __importStar(require("./SignIn"));
@@ -0,0 +1,72 @@
1
+ import type { FrameNotificationDetails } from './schemas';
2
+ export type CastEmbedLocationContext = {
3
+ type: 'cast_embed';
4
+ embed: string;
5
+ cast: {
6
+ fid: number;
7
+ hash: string;
8
+ };
9
+ };
10
+ export type NotificationLocationContext = {
11
+ type: 'notification';
12
+ notification: {
13
+ notificationId: string;
14
+ title: string;
15
+ body: string;
16
+ };
17
+ };
18
+ export type LauncherLocationContext = {
19
+ type: 'launcher';
20
+ };
21
+ export type ChannelLocationContext = {
22
+ type: 'channel';
23
+ channel: {
24
+ /**
25
+ * Channel key identifier
26
+ */
27
+ key: string;
28
+ /**
29
+ * Channel name
30
+ */
31
+ name: string;
32
+ /**
33
+ * Channel profile image URL
34
+ */
35
+ imageUrl?: string;
36
+ };
37
+ };
38
+ export type LocationContext = CastEmbedLocationContext | NotificationLocationContext | LauncherLocationContext | ChannelLocationContext;
39
+ export type AccountLocation = {
40
+ placeId: string;
41
+ /**
42
+ * Human-readable string describing the location
43
+ */
44
+ description: string;
45
+ };
46
+ export type UserContext = {
47
+ fid: number;
48
+ username?: string;
49
+ displayName?: string;
50
+ /**
51
+ * Profile image URL
52
+ */
53
+ pfpUrl?: string;
54
+ location?: AccountLocation;
55
+ };
56
+ export type SafeAreaInsets = {
57
+ top: number;
58
+ bottom: number;
59
+ left: number;
60
+ right: number;
61
+ };
62
+ export type ClientContext = {
63
+ clientFid: number;
64
+ added: boolean;
65
+ notificationDetails?: FrameNotificationDetails;
66
+ safeAreaInsets?: SafeAreaInsets;
67
+ };
68
+ export type FrameContext = {
69
+ client: ClientContext;
70
+ user: UserContext;
71
+ location?: LocationContext;
72
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/errors.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseError = void 0;
4
4
  class BaseError extends Error {
5
- name = "BaseError";
5
+ name = 'BaseError';
6
6
  cause;
7
7
  constructor(message, options = {}) {
8
8
  super(message, options.cause ? { cause: options.cause } : undefined);
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * as SignIn from "./actions/signIn";
2
- export * from "./types";
3
- export * from "./schemas";
1
+ export * from './actions';
2
+ export * as Context from './context';
3
+ export * from './types';
4
+ export * from './schemas';
package/dist/index.js CHANGED
@@ -15,6 +15,9 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
18
21
  var __importStar = (this && this.__importStar) || (function () {
19
22
  var ownKeys = function(o) {
20
23
  ownKeys = Object.getOwnPropertyNames || function (o) {
@@ -32,11 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
32
35
  return result;
33
36
  };
34
37
  })();
35
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
- };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.SignIn = void 0;
40
- exports.SignIn = __importStar(require("./actions/signIn"));
39
+ exports.Context = void 0;
40
+ __exportStar(require("./actions"), exports);
41
+ exports.Context = __importStar(require("./context"));
41
42
  __exportStar(require("./types"), exports);
42
43
  __exportStar(require("./schemas"), exports);
@@ -1,7 +1,8 @@
1
- export type Compute<type> = {
1
+ type Compute<type> = {
2
2
  [key in keyof type]: type[key];
3
3
  } & unknown;
4
+ type KeyofUnion<type> = type extends type ? keyof type : never;
4
5
  export type OneOf<union extends object, fallback extends object | undefined = undefined, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer item ? Compute<item & {
5
6
  [key in Exclude<keys, keyof item>]?: fallback extends object ? key extends keyof fallback ? fallback[key] : undefined : undefined;
6
7
  }> : never;
7
- export type KeyofUnion<type> = type extends type ? keyof type : never;
8
+ export {};
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  export declare const actionLaunchFrameSchema: z.ZodObject<{
3
3
  type: z.ZodLiteral<"launch_frame">;
4
4
  name: z.ZodString;
@@ -4,13 +4,13 @@ exports.safeParseFrameEmbed = exports.frameEmbedNextSchema = exports.buttonSchem
4
4
  const zod_1 = require("zod");
5
5
  const shared_1 = require("./shared");
6
6
  exports.actionLaunchFrameSchema = zod_1.z.object({
7
- type: zod_1.z.literal("launch_frame"),
7
+ type: zod_1.z.literal('launch_frame'),
8
8
  name: shared_1.frameNameSchema,
9
9
  url: shared_1.secureUrlSchema,
10
10
  splashImageUrl: shared_1.secureUrlSchema.optional(),
11
11
  splashBackgroundColor: shared_1.hexColorSchema.optional(),
12
12
  });
13
- exports.actionSchema = zod_1.z.discriminatedUnion("type", [
13
+ exports.actionSchema = zod_1.z.discriminatedUnion('type', [
14
14
  exports.actionLaunchFrameSchema,
15
15
  ]);
16
16
  exports.buttonSchema = zod_1.z.object({
@@ -18,7 +18,7 @@ exports.buttonSchema = zod_1.z.object({
18
18
  action: exports.actionSchema,
19
19
  });
20
20
  exports.frameEmbedNextSchema = zod_1.z.object({
21
- version: zod_1.z.literal("next"),
21
+ version: zod_1.z.literal('next'),
22
22
  imageUrl: shared_1.secureUrlSchema,
23
23
  button: exports.buttonSchema,
24
24
  });
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  export declare const eventFrameAddedSchema: z.ZodObject<{
3
3
  event: z.ZodLiteral<"frame_added">;
4
4
  notificationDetails: z.ZodOptional<z.ZodObject<{
@@ -4,20 +4,20 @@ exports.serverEventSchema = exports.notificationsDisabledSchema = exports.eventN
4
4
  const zod_1 = require("zod");
5
5
  const notifications_1 = require("./notifications");
6
6
  exports.eventFrameAddedSchema = zod_1.z.object({
7
- event: zod_1.z.literal("frame_added"),
7
+ event: zod_1.z.literal('frame_added'),
8
8
  notificationDetails: notifications_1.notificationDetailsSchema.optional(),
9
9
  });
10
10
  exports.eventFrameRemovedSchema = zod_1.z.object({
11
- event: zod_1.z.literal("frame_removed"),
11
+ event: zod_1.z.literal('frame_removed'),
12
12
  });
13
13
  exports.eventNotificationsEnabledSchema = zod_1.z.object({
14
- event: zod_1.z.literal("notifications_enabled"),
14
+ event: zod_1.z.literal('notifications_enabled'),
15
15
  notificationDetails: notifications_1.notificationDetailsSchema.required(),
16
16
  });
17
17
  exports.notificationsDisabledSchema = zod_1.z.object({
18
- event: zod_1.z.literal("notifications_disabled"),
18
+ event: zod_1.z.literal('notifications_disabled'),
19
19
  });
20
- exports.serverEventSchema = zod_1.z.discriminatedUnion("event", [
20
+ exports.serverEventSchema = zod_1.z.discriminatedUnion('event', [
21
21
  exports.eventFrameAddedSchema,
22
22
  exports.eventFrameRemovedSchema,
23
23
  exports.eventNotificationsEnabledSchema,
@@ -1,5 +1,5 @@
1
- export * from "./embeds";
2
- export * from "./events";
3
- export * from "./shared";
4
- export * from "./manifest";
5
- export * from "./notifications";
1
+ export * from './embeds';
2
+ export * from './events';
3
+ export * from './shared';
4
+ export * from './manifest';
5
+ export * from './notifications';
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  export declare const domainFrameConfigSchema: z.ZodObject<{
3
3
  version: z.ZodUnion<[z.ZodLiteral<"0.0.0">, z.ZodLiteral<"0.0.1">, z.ZodLiteral<"1">, z.ZodLiteral<"next">]>;
4
4
  name: z.ZodString;
@@ -8,10 +8,10 @@ exports.domainFrameConfigSchema = zod_1.z.object({
8
8
  // backwards compatibilty. next should always resolve to the most recent
9
9
  // schema version.
10
10
  version: zod_1.z.union([
11
- zod_1.z.literal("0.0.0"),
12
- zod_1.z.literal("0.0.1"),
13
- zod_1.z.literal("1"),
14
- zod_1.z.literal('next')
11
+ zod_1.z.literal('0.0.0'),
12
+ zod_1.z.literal('0.0.1'),
13
+ zod_1.z.literal('1'),
14
+ zod_1.z.literal('next'),
15
15
  ]),
16
16
  name: shared_1.frameNameSchema,
17
17
  iconUrl: shared_1.secureUrlSchema,
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  export declare const notificationDetailsSchema: z.ZodObject<{
3
3
  url: z.ZodString;
4
4
  token: z.ZodString;
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
  export declare const secureUrlSchema: z.ZodString;
3
3
  export declare const frameNameSchema: z.ZodString;
4
4
  export declare const buttonTitleSchema: z.ZodString;
@@ -5,14 +5,14 @@ const zod_1 = require("zod");
5
5
  exports.secureUrlSchema = zod_1.z
6
6
  .string()
7
7
  .url()
8
- .startsWith("https://", { message: "Must be an https url" })
8
+ .startsWith('https://', { message: 'Must be an https url' })
9
9
  .max(512);
10
10
  exports.frameNameSchema = zod_1.z.string().max(32);
11
11
  exports.buttonTitleSchema = zod_1.z.string().max(32);
12
12
  exports.hexColorSchema = zod_1.z
13
13
  .string()
14
14
  .regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
15
- message: "Invalid hex color code. It should be in the format #RRGGBB or #RGB.",
15
+ message: 'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
16
16
  });
17
17
  exports.encodedJsonFarcasterSignatureSchema = zod_1.z.object({
18
18
  header: zod_1.z.string(),
@@ -21,6 +21,6 @@ exports.encodedJsonFarcasterSignatureSchema = zod_1.z.object({
21
21
  });
22
22
  exports.jsonFarcasterSignatureHeaderSchema = zod_1.z.object({
23
23
  fid: zod_1.z.number(),
24
- type: zod_1.z.literal("app_key"),
25
- key: zod_1.z.string().startsWith("0x"),
24
+ type: zod_1.z.literal('app_key'),
25
+ key: zod_1.z.string().startsWith('0x'),
26
26
  });
package/dist/types.d.ts CHANGED
@@ -1,74 +1,15 @@
1
- import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from "ox";
2
- import { FrameNotificationDetails, EventFrameAdded, EventFrameRemoved, EventNotificationsEnabled, EventNotificationsDisabled } from "./schemas";
3
- import * as SignIn from "./actions/signIn";
4
- export type SetPrimaryButton = (options: {
1
+ import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
2
+ import type { AddFrame, SignIn } from './actions';
3
+ import type { FrameContext } from './context';
4
+ import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
5
+ export type SetPrimaryButtonOptions = {
5
6
  text: string;
6
7
  loading?: boolean;
7
8
  disabled?: boolean;
8
9
  hidden?: boolean;
9
- }) => void;
10
- export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
11
- export type AccountLocation = {
12
- placeId: string;
13
- /**
14
- * Human-readable string describing the location
15
- */
16
- description: string;
17
- };
18
- export type FrameLocationContextCastEmbed = {
19
- type: "cast_embed";
20
- embed: string;
21
- cast: {
22
- fid: number;
23
- hash: string;
24
- };
25
- };
26
- export type FrameLocationContextNotification = {
27
- type: "notification";
28
- notification: {
29
- notificationId: string;
30
- title: string;
31
- body: string;
32
- };
33
- };
34
- export type FrameLocationContextLauncher = {
35
- type: "launcher";
36
- };
37
- export type FrameLocationContext = FrameLocationContextCastEmbed | FrameLocationContextNotification | FrameLocationContextLauncher;
38
- export type SafeAreaInsets = {
39
- top: number;
40
- bottom: number;
41
- left: number;
42
- right: number;
43
10
  };
44
- export type FrameContext = {
45
- user: {
46
- fid: number;
47
- username?: string;
48
- displayName?: string;
49
- /**
50
- * Profile image URL
51
- */
52
- pfpUrl?: string;
53
- location?: AccountLocation;
54
- };
55
- location?: FrameLocationContext;
56
- client: {
57
- clientFid: number;
58
- added: boolean;
59
- notificationDetails?: FrameNotificationDetails;
60
- safeAreaInsets?: SafeAreaInsets;
61
- };
62
- };
63
- export type AddFrameRejectedReason = "invalid_domain_manifest" | "rejected_by_user";
64
- export type AddFrameResult = {
65
- added: true;
66
- notificationDetails?: FrameNotificationDetails;
67
- } | {
68
- added: false;
69
- reason: AddFrameRejectedReason;
70
- };
71
- export type AddFrame = () => Promise<AddFrameResult>;
11
+ export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
12
+ export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
72
13
  export type ReadyOptions = {
73
14
  /**
74
15
  * Disable native gestures. Use this option if your frame uses gestures
@@ -104,7 +45,8 @@ export type WireFrameHost = {
104
45
  setPrimaryButton: SetPrimaryButton;
105
46
  ethProviderRequest: EthProviderRequest;
106
47
  ethProviderRequestV2: RpcTransport;
107
- addFrame: AddFrame;
48
+ eip6963RequestProvider: () => void;
49
+ addFrame: AddFrame.WireAddFrame;
108
50
  };
109
51
  export type FrameHost = {
110
52
  context: FrameContext;
@@ -115,10 +57,15 @@ export type FrameHost = {
115
57
  setPrimaryButton: SetPrimaryButton;
116
58
  ethProviderRequest: EthProviderRequest;
117
59
  ethProviderRequestV2: RpcTransport;
118
- addFrame: AddFrame;
60
+ /**
61
+ * Receive forwarded eip6963:requestProvider events from the frame document.
62
+ * Hosts must emit an EventEip6963AnnounceProvider in response.
63
+ */
64
+ eip6963RequestProvider: () => void;
65
+ addFrame: AddFrame.AddFrame;
119
66
  };
120
67
  export type FrameEthProviderEventData = {
121
- type: "frame_eth_provider_event";
68
+ type: 'frame_eth_provider_event';
122
69
  } & EthProviderWireEvent;
123
70
  export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
124
71
  export type ProviderRpcError = {
@@ -127,29 +74,42 @@ export type ProviderRpcError = {
127
74
  message?: string;
128
75
  };
129
76
  export type EthProviderWireEvent = {
130
- event: "accountsChanged";
77
+ event: 'accountsChanged';
131
78
  params: [readonly Address.Address[]];
132
79
  } | {
133
- event: "chainChanged";
80
+ event: 'chainChanged';
134
81
  params: [string];
135
82
  } | {
136
- event: "connect";
83
+ event: 'connect';
137
84
  params: [Provider.ConnectInfo];
138
85
  } | {
139
- event: "disconnect";
86
+ event: 'disconnect';
140
87
  params: [ProviderRpcError];
141
88
  } | {
142
- event: "message";
89
+ event: 'message';
143
90
  params: [Provider.Message];
144
91
  };
145
- export type EmitEthProvider = <event extends EthProviderWireEvent["event"]>(event: event, params: Extract<EthProviderWireEvent, {
92
+ export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
146
93
  event: event;
147
- }>["params"]) => void;
94
+ }>['params']) => void;
148
95
  export type EventFrameAddRejected = {
149
- event: "frame_add_rejected";
150
- reason: AddFrameRejectedReason;
96
+ event: 'frame_add_rejected';
97
+ reason: AddFrame.AddFrameRejectedReason;
151
98
  };
152
99
  export type EventPrimaryButtonClicked = {
153
- event: "primary_button_clicked";
100
+ event: 'primary_button_clicked';
101
+ };
102
+ /**
103
+ * Metadata of the EIP-1193 Provider.
104
+ */
105
+ export interface EIP6963ProviderInfo {
106
+ icon: `data:image/${string}`;
107
+ name: string;
108
+ rdns: string;
109
+ uuid: string;
110
+ }
111
+ export type EventEip6963AnnounceProvider = {
112
+ event: 'eip6963:announceProvider';
113
+ info: EIP6963ProviderInfo;
154
114
  };
155
- export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked;
115
+ export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | EventEip6963AnnounceProvider;
@@ -0,0 +1,40 @@
1
+ import * as Errors from '../errors'
2
+ import type { OneOf } from '../internal/types'
3
+ import type { FrameNotificationDetails } from '../schemas'
4
+ export type AddFrameResult = {
5
+ notificationDetails?: FrameNotificationDetails
6
+ }
7
+ export type AddFrame = () => Promise<AddFrameResult>
8
+ type InvalidDomainManifestJsonError = {
9
+ type: 'invalid_domain_manifest'
10
+ }
11
+ type RejectedByUserJsonError = {
12
+ type: 'rejected_by_user'
13
+ }
14
+ export type AddFrameJsonError =
15
+ | InvalidDomainManifestJsonError
16
+ | RejectedByUserJsonError
17
+ export type AddFrameRejectedReason = AddFrameJsonError['type']
18
+ export type AddFrameJsonResult = OneOf<
19
+ | {
20
+ result: AddFrameResult
21
+ }
22
+ | {
23
+ error: AddFrameJsonError
24
+ }
25
+ >
26
+ export type WireAddFrame = () => Promise<AddFrameJsonResult>
27
+ /**
28
+ * Thrown when the frame does not have a valid domain manifest.
29
+ */
30
+ export declare class InvalidDomainManifest extends Errors.BaseError {
31
+ readonly name = 'AddFrame.InvalidDomainManifest'
32
+ constructor()
33
+ }
34
+ /**
35
+ * Thrown when add frame action was rejected by the user.
36
+ */
37
+ export declare class RejectedByUser extends Errors.BaseError {
38
+ readonly name = 'AddFrame.RejectedByUser'
39
+ constructor()
40
+ }