@farcaster/frame-core 0.0.22 → 0.0.24

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 (46) hide show
  1. package/dist/actions/ViewProfile.d.ts +4 -0
  2. package/dist/actions/ViewProfile.js +2 -0
  3. package/dist/actions/index.d.ts +1 -0
  4. package/dist/actions/index.js +2 -1
  5. package/dist/context.d.ts +72 -0
  6. package/dist/context.js +2 -0
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.js +25 -1
  9. package/dist/types.d.ts +5 -54
  10. package/esm/actions/AddFrame.d.ts +23 -27
  11. package/esm/actions/AddFrame.js +9 -9
  12. package/esm/actions/SignIn.d.ts +33 -35
  13. package/esm/actions/SignIn.js +5 -5
  14. package/esm/actions/ViewProfile.d.ts +4 -0
  15. package/esm/actions/ViewProfile.js +1 -0
  16. package/esm/actions/index.d.ts +3 -2
  17. package/esm/actions/index.js +3 -2
  18. package/esm/context.d.ts +72 -0
  19. package/esm/context.js +1 -0
  20. package/esm/errors.d.ts +7 -9
  21. package/esm/errors.js +6 -6
  22. package/esm/index.d.ts +4 -3
  23. package/esm/index.js +4 -3
  24. package/esm/internal/types.d.ts +7 -18
  25. package/esm/internal/types.js +1 -1
  26. package/esm/schemas/embeds.d.ts +169 -231
  27. package/esm/schemas/embeds.js +18 -24
  28. package/esm/schemas/events.d.ts +129 -225
  29. package/esm/schemas/events.js +17 -17
  30. package/esm/schemas/index.d.ts +5 -5
  31. package/esm/schemas/index.js +5 -5
  32. package/esm/schemas/manifest.d.ts +110 -154
  33. package/esm/schemas/manifest.js +23 -29
  34. package/esm/schemas/notifications.d.ts +58 -86
  35. package/esm/schemas/notifications.js +17 -17
  36. package/esm/schemas/shared.d.ts +33 -49
  37. package/esm/schemas/shared.js +19 -20
  38. package/esm/tsconfig.tsbuildinfo +1 -1
  39. package/esm/types.d.ts +101 -179
  40. package/esm/types.js +2 -2
  41. package/package.json +1 -1
  42. package/src/actions/ViewProfile.ts +5 -0
  43. package/src/actions/index.ts +1 -0
  44. package/src/context.ts +90 -0
  45. package/src/index.ts +2 -1
  46. package/src/types.ts +4 -64
@@ -0,0 +1,4 @@
1
+ export type ViewProfileOptions = {
2
+ fid: number;
3
+ };
4
+ export type ViewProfile = (options: ViewProfileOptions) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,3 @@
1
1
  export * as AddFrame from './AddFrame';
2
+ export * as ViewProfile from './ViewProfile';
2
3
  export * as SignIn from './SignIn';
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.SignIn = exports.AddFrame = void 0;
36
+ exports.SignIn = exports.ViewProfile = exports.AddFrame = void 0;
37
37
  exports.AddFrame = __importStar(require("./AddFrame"));
38
+ exports.ViewProfile = __importStar(require("./ViewProfile"));
38
39
  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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './actions';
2
- export * from './schemas';
2
+ export * as Context from './context';
3
3
  export * from './types';
4
+ export * from './schemas';
package/dist/index.js CHANGED
@@ -10,10 +10,34 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
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
+ });
13
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
16
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Context = void 0;
17
40
  __exportStar(require("./actions"), exports);
18
- __exportStar(require("./schemas"), exports);
41
+ exports.Context = __importStar(require("./context"));
19
42
  __exportStar(require("./types"), exports);
43
+ __exportStar(require("./schemas"), exports);
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
2
- import type { AddFrame, SignIn } from './actions';
3
- import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled, FrameNotificationDetails } from './schemas';
2
+ import type { AddFrame, SignIn, ViewProfile } from './actions';
3
+ import type { FrameContext } from './context';
4
+ import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
4
5
  export type SetPrimaryButtonOptions = {
5
6
  text: string;
6
7
  loading?: boolean;
@@ -9,58 +10,6 @@ export type SetPrimaryButtonOptions = {
9
10
  };
10
11
  export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
11
12
  export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
12
- export type AccountLocation = {
13
- placeId: string;
14
- /**
15
- * Human-readable string describing the location
16
- */
17
- description: string;
18
- };
19
- export type FrameLocationContextCastEmbed = {
20
- type: 'cast_embed';
21
- embed: string;
22
- cast: {
23
- fid: number;
24
- hash: string;
25
- };
26
- };
27
- export type FrameLocationContextNotification = {
28
- type: 'notification';
29
- notification: {
30
- notificationId: string;
31
- title: string;
32
- body: string;
33
- };
34
- };
35
- export type FrameLocationContextLauncher = {
36
- type: 'launcher';
37
- };
38
- export type FrameLocationContext = FrameLocationContextCastEmbed | FrameLocationContextNotification | FrameLocationContextLauncher;
39
- export type SafeAreaInsets = {
40
- top: number;
41
- bottom: number;
42
- left: number;
43
- right: number;
44
- };
45
- export type FrameContext = {
46
- user: {
47
- fid: number;
48
- username?: string;
49
- displayName?: string;
50
- /**
51
- * Profile image URL
52
- */
53
- pfpUrl?: string;
54
- location?: AccountLocation;
55
- };
56
- location?: FrameLocationContext;
57
- client: {
58
- clientFid: number;
59
- added: boolean;
60
- notificationDetails?: FrameNotificationDetails;
61
- safeAreaInsets?: SafeAreaInsets;
62
- };
63
- };
64
13
  export type ReadyOptions = {
65
14
  /**
66
15
  * Disable native gestures. Use this option if your frame uses gestures
@@ -98,6 +47,7 @@ export type WireFrameHost = {
98
47
  ethProviderRequestV2: RpcTransport;
99
48
  eip6963RequestProvider: () => void;
100
49
  addFrame: AddFrame.WireAddFrame;
50
+ viewProfile: ViewProfile.ViewProfile;
101
51
  };
102
52
  export type FrameHost = {
103
53
  context: FrameContext;
@@ -114,6 +64,7 @@ export type FrameHost = {
114
64
  */
115
65
  eip6963RequestProvider: () => void;
116
66
  addFrame: AddFrame.AddFrame;
67
+ viewProfile: ViewProfile.ViewProfile;
117
68
  };
118
69
  export type FrameEthProviderEventData = {
119
70
  type: 'frame_eth_provider_event';
@@ -1,40 +1,36 @@
1
- import * as Errors from '../errors'
2
- import type { OneOf } from '../internal/types'
3
- import type { FrameNotificationDetails } from '../schemas'
1
+ import * as Errors from '../errors';
2
+ import type { OneOf } from '../internal/types';
3
+ import type { FrameNotificationDetails } from '../schemas';
4
4
  export type AddFrameResult = {
5
- notificationDetails?: FrameNotificationDetails
6
- }
7
- export type AddFrame = () => Promise<AddFrameResult>
5
+ notificationDetails?: FrameNotificationDetails;
6
+ };
7
+ export type AddFrame = () => Promise<AddFrameResult>;
8
8
  type InvalidDomainManifestJsonError = {
9
- type: 'invalid_domain_manifest'
10
- }
9
+ type: 'invalid_domain_manifest';
10
+ };
11
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>
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>;
27
22
  /**
28
23
  * Thrown when the frame does not have a valid domain manifest.
29
24
  */
30
25
  export declare class InvalidDomainManifest extends Errors.BaseError {
31
- readonly name = 'AddFrame.InvalidDomainManifest'
32
- constructor()
26
+ readonly name = "AddFrame.InvalidDomainManifest";
27
+ constructor();
33
28
  }
34
29
  /**
35
30
  * Thrown when add frame action was rejected by the user.
36
31
  */
37
32
  export declare class RejectedByUser extends Errors.BaseError {
38
- readonly name = 'AddFrame.RejectedByUser'
39
- constructor()
33
+ readonly name = "AddFrame.RejectedByUser";
34
+ constructor();
40
35
  }
36
+ export {};
@@ -1,19 +1,19 @@
1
- import * as Errors from '../errors'
1
+ import * as Errors from '../errors';
2
2
  /**
3
3
  * Thrown when the frame does not have a valid domain manifest.
4
4
  */
5
5
  export class InvalidDomainManifest extends Errors.BaseError {
6
- name = 'AddFrame.InvalidDomainManifest'
7
- constructor() {
8
- super('Invalid domain manifest')
9
- }
6
+ name = 'AddFrame.InvalidDomainManifest';
7
+ constructor() {
8
+ super('Invalid domain manifest');
9
+ }
10
10
  }
11
11
  /**
12
12
  * Thrown when add frame action was rejected by the user.
13
13
  */
14
14
  export class RejectedByUser extends Errors.BaseError {
15
- name = 'AddFrame.RejectedByUser'
16
- constructor() {
17
- super('Add frame rejected by user')
18
- }
15
+ name = 'AddFrame.RejectedByUser';
16
+ constructor() {
17
+ super('Add frame rejected by user');
18
+ }
19
19
  }
@@ -1,43 +1,41 @@
1
- import * as Errors from '../errors'
2
- import type { OneOf } from '../internal/types'
1
+ import * as Errors from '../errors';
2
+ import type { OneOf } from '../internal/types';
3
3
  export type SignInOptions = {
4
- /**
5
- * A random string used to prevent replay attacks.
6
- */
7
- nonce: string
8
- /**
9
- * Start time at which the signature becomes valid.
10
- * ISO 8601 datetime.
11
- */
12
- notBefore?: string
13
- /**
14
- * Expiration time at which the signature is no longer valid.
15
- * ISO 8601 datetime.
16
- */
17
- expirationTime?: string
18
- }
4
+ /**
5
+ * A random string used to prevent replay attacks.
6
+ */
7
+ nonce: string;
8
+ /**
9
+ * Start time at which the signature becomes valid.
10
+ * ISO 8601 datetime.
11
+ */
12
+ notBefore?: string;
13
+ /**
14
+ * Expiration time at which the signature is no longer valid.
15
+ * ISO 8601 datetime.
16
+ */
17
+ expirationTime?: string;
18
+ };
19
19
  export type SignInResult = {
20
- signature: string
21
- message: string
22
- }
23
- export type SignIn = (options: SignInOptions) => Promise<SignInResult>
20
+ signature: string;
21
+ message: string;
22
+ };
23
+ export type SignIn = (options: SignInOptions) => Promise<SignInResult>;
24
24
  type RejectedByUserJsonError = {
25
- type: 'rejected_by_user'
26
- }
27
- export type SignInJsonError = RejectedByUserJsonError
28
- export type SignInJsonResult = OneOf<
29
- | {
30
- result: SignInResult
31
- }
32
- | {
33
- error: SignInJsonError
34
- }
35
- >
36
- export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>
25
+ type: 'rejected_by_user';
26
+ };
27
+ export type SignInJsonError = RejectedByUserJsonError;
28
+ export type SignInJsonResult = OneOf<{
29
+ result: SignInResult;
30
+ } | {
31
+ error: SignInJsonError;
32
+ }>;
33
+ export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>;
37
34
  /**
38
35
  * Thrown when a sign in action was rejected.
39
36
  */
40
37
  export declare class RejectedByUser extends Errors.BaseError {
41
- readonly name = 'SignIn.RejectedByUser'
42
- constructor()
38
+ readonly name = "SignIn.RejectedByUser";
39
+ constructor();
43
40
  }
41
+ export {};
@@ -1,10 +1,10 @@
1
- import * as Errors from '../errors'
1
+ import * as Errors from '../errors';
2
2
  /**
3
3
  * Thrown when a sign in action was rejected.
4
4
  */
5
5
  export class RejectedByUser extends Errors.BaseError {
6
- name = 'SignIn.RejectedByUser'
7
- constructor() {
8
- super('Sign in rejected by user')
9
- }
6
+ name = 'SignIn.RejectedByUser';
7
+ constructor() {
8
+ super('Sign in rejected by user');
9
+ }
10
10
  }
@@ -0,0 +1,4 @@
1
+ export type ViewProfileOptions = {
2
+ fid: number;
3
+ };
4
+ export type ViewProfile = (options: ViewProfileOptions) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,3 @@
1
- export * as AddFrame from './AddFrame'
2
- export * as SignIn from './SignIn'
1
+ export * as AddFrame from './AddFrame';
2
+ export * as ViewProfile from './ViewProfile';
3
+ export * as SignIn from './SignIn';
@@ -1,2 +1,3 @@
1
- export * as AddFrame from './AddFrame'
2
- export * as SignIn from './SignIn'
1
+ export * as AddFrame from './AddFrame';
2
+ export * as ViewProfile from './ViewProfile';
3
+ export * as SignIn from './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
+ };
package/esm/context.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/esm/errors.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- export declare class BaseError<
2
- cause extends Error | undefined = undefined,
3
- > extends Error {
4
- name: string
5
- cause: cause
6
- constructor(message: string, options?: BaseError.Options<cause>)
1
+ export declare class BaseError<cause extends Error | undefined = undefined> extends Error {
2
+ name: string;
3
+ cause: cause;
4
+ constructor(message: string, options?: BaseError.Options<cause>);
7
5
  }
8
6
  export declare namespace BaseError {
9
- type Options<cause extends Error | undefined = Error | undefined> = {
10
- cause?: cause | undefined
11
- }
7
+ type Options<cause extends Error | undefined = Error | undefined> = {
8
+ cause?: cause | undefined;
9
+ };
12
10
  }
package/esm/errors.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export class BaseError extends Error {
2
- name = 'BaseError'
3
- cause
4
- constructor(message, options = {}) {
5
- super(message, options.cause ? { cause: options.cause } : undefined)
6
- this.cause = options.cause
7
- }
2
+ name = 'BaseError';
3
+ cause;
4
+ constructor(message, options = {}) {
5
+ super(message, options.cause ? { cause: options.cause } : undefined);
6
+ this.cause = options.cause;
7
+ }
8
8
  }
package/esm/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export * from './actions'
2
- export * from './schemas'
3
- export * from './types'
1
+ export * from './actions';
2
+ export * as Context from './context';
3
+ export * from './types';
4
+ export * from './schemas';
package/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export * from './actions'
2
- export * from './schemas'
3
- export * from './types'
1
+ export * from './actions';
2
+ export * as Context from './context';
3
+ export * from './types';
4
+ export * from './schemas';
@@ -1,19 +1,8 @@
1
1
  type Compute<type> = {
2
- [key in keyof type]: type[key]
3
- } & unknown
4
- type KeyofUnion<type> = type extends type ? keyof type : never
5
- export type OneOf<
6
- union extends object,
7
- fallback extends object | undefined = undefined,
8
- keys extends KeyofUnion<union> = KeyofUnion<union>,
9
- > = union extends infer item
10
- ? Compute<
11
- item & {
12
- [key in Exclude<keys, keyof item>]?: fallback extends object
13
- ? key extends keyof fallback
14
- ? fallback[key]
15
- : undefined
16
- : undefined
17
- }
18
- >
19
- : never
2
+ [key in keyof type]: type[key];
3
+ } & unknown;
4
+ type KeyofUnion<type> = type extends type ? keyof type : never;
5
+ export type OneOf<union extends object, fallback extends object | undefined = undefined, keys extends KeyofUnion<union> = KeyofUnion<union>> = union extends infer item ? Compute<item & {
6
+ [key in Exclude<keys, keyof item>]?: fallback extends object ? key extends keyof fallback ? fallback[key] : undefined : undefined;
7
+ }> : never;
8
+ export {};
@@ -1 +1 @@
1
- export {}
1
+ export {};