@farcaster/frame-core 0.0.21 → 0.0.22
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/dist/actions/AddFrame.d.ts +36 -0
- package/dist/actions/AddFrame.js +57 -0
- package/dist/actions/{signIn.d.ts → SignIn.d.ts} +7 -6
- package/dist/actions/{signIn.js → SignIn.js} +1 -1
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.js +38 -0
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -25
- package/dist/internal/types.d.ts +3 -2
- package/dist/schemas/embeds.d.ts +1 -1
- package/dist/schemas/embeds.js +3 -3
- package/dist/schemas/events.d.ts +1 -1
- package/dist/schemas/events.js +5 -5
- package/dist/schemas/index.d.ts +5 -5
- package/dist/schemas/manifest.d.ts +1 -1
- package/dist/schemas/manifest.js +4 -4
- package/dist/schemas/notifications.d.ts +1 -1
- package/dist/schemas/shared.d.ts +1 -1
- package/dist/schemas/shared.js +4 -4
- package/dist/types.d.ts +42 -31
- package/esm/actions/AddFrame.d.ts +40 -0
- package/esm/actions/AddFrame.js +19 -0
- package/esm/actions/SignIn.d.ts +43 -0
- package/esm/actions/SignIn.js +10 -0
- package/esm/actions/index.d.ts +2 -0
- package/esm/actions/index.js +2 -0
- package/esm/errors.d.ts +9 -7
- package/esm/errors.js +6 -6
- package/esm/index.d.ts +3 -3
- package/esm/index.js +3 -3
- package/esm/internal/types.d.ts +19 -7
- package/esm/internal/types.js +1 -1
- package/esm/schemas/embeds.d.ts +231 -169
- package/esm/schemas/embeds.js +25 -19
- package/esm/schemas/events.d.ts +225 -129
- package/esm/schemas/events.js +18 -18
- package/esm/schemas/index.d.ts +5 -5
- package/esm/schemas/index.js +5 -5
- package/esm/schemas/manifest.d.ts +154 -110
- package/esm/schemas/manifest.js +29 -23
- package/esm/schemas/notifications.d.ts +86 -58
- package/esm/schemas/notifications.js +17 -17
- package/esm/schemas/shared.d.ts +49 -33
- package/esm/schemas/shared.js +20 -19
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/types.d.ts +180 -140
- package/esm/types.js +2 -2
- package/package.json +4 -5
- package/src/actions/AddFrame.ts +51 -0
- package/src/actions/SignIn.ts +51 -0
- package/src/actions/index.ts +2 -0
- package/src/errors.ts +4 -4
- package/src/index.ts +3 -3
- package/src/internal/types.ts +3 -4
- package/src/schemas/embeds.ts +13 -13
- package/src/schemas/events.ts +17 -17
- package/src/schemas/index.ts +5 -5
- package/src/schemas/manifest.ts +11 -11
- package/src/schemas/notifications.ts +8 -10
- package/src/schemas/shared.ts +13 -13
- package/src/types.ts +125 -124
- package/esm/actions/signIn.d.ts +0 -40
- package/esm/actions/signIn.js +0 -10
- 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
|
-
|
|
24
|
+
type RejectedByUserJsonError = {
|
|
25
25
|
type: 'rejected_by_user';
|
|
26
26
|
};
|
|
27
|
-
export type
|
|
28
|
-
export type
|
|
27
|
+
export type SignInJsonError = RejectedByUserJsonError;
|
|
28
|
+
export type SignInJsonResult = OneOf<{
|
|
29
29
|
result: SignInResult;
|
|
30
30
|
} | {
|
|
31
|
-
error:
|
|
31
|
+
error: SignInJsonError;
|
|
32
32
|
}>;
|
|
33
|
-
export type WireSignIn = (options: SignInOptions) => Promise<
|
|
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(
|
|
44
|
+
super('Sign in rejected by user');
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
exports.RejectedByUser = RejectedByUser;
|
|
@@ -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"));
|
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 =
|
|
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,3 @@
|
|
|
1
|
-
export *
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './actions';
|
|
2
|
+
export * from './schemas';
|
|
3
|
+
export * from './types';
|
package/dist/index.js
CHANGED
|
@@ -10,33 +10,10 @@ 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
|
-
});
|
|
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
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
15
|
};
|
|
38
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports
|
|
40
|
-
exports.SignIn = __importStar(require("./actions/signIn"));
|
|
41
|
-
__exportStar(require("./types"), exports);
|
|
17
|
+
__exportStar(require("./actions"), exports);
|
|
42
18
|
__exportStar(require("./schemas"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
package/dist/internal/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
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
|
|
8
|
+
export {};
|
package/dist/schemas/embeds.d.ts
CHANGED
package/dist/schemas/embeds.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
21
|
+
version: zod_1.z.literal('next'),
|
|
22
22
|
imageUrl: shared_1.secureUrlSchema,
|
|
23
23
|
button: exports.buttonSchema,
|
|
24
24
|
});
|
package/dist/schemas/events.d.ts
CHANGED
package/dist/schemas/events.js
CHANGED
|
@@ -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(
|
|
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(
|
|
11
|
+
event: zod_1.z.literal('frame_removed'),
|
|
12
12
|
});
|
|
13
13
|
exports.eventNotificationsEnabledSchema = zod_1.z.object({
|
|
14
|
-
event: zod_1.z.literal(
|
|
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(
|
|
18
|
+
event: zod_1.z.literal('notifications_disabled'),
|
|
19
19
|
});
|
|
20
|
-
exports.serverEventSchema = zod_1.z.discriminatedUnion(
|
|
20
|
+
exports.serverEventSchema = zod_1.z.discriminatedUnion('event', [
|
|
21
21
|
exports.eventFrameAddedSchema,
|
|
22
22
|
exports.eventFrameRemovedSchema,
|
|
23
23
|
exports.eventNotificationsEnabledSchema,
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './embeds';
|
|
2
|
+
export * from './events';
|
|
3
|
+
export * from './shared';
|
|
4
|
+
export * from './manifest';
|
|
5
|
+
export * from './notifications';
|
package/dist/schemas/manifest.js
CHANGED
|
@@ -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(
|
|
12
|
-
zod_1.z.literal(
|
|
13
|
-
zod_1.z.literal(
|
|
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,
|
package/dist/schemas/shared.d.ts
CHANGED
package/dist/schemas/shared.js
CHANGED
|
@@ -5,14 +5,14 @@ const zod_1 = require("zod");
|
|
|
5
5
|
exports.secureUrlSchema = zod_1.z
|
|
6
6
|
.string()
|
|
7
7
|
.url()
|
|
8
|
-
.startsWith(
|
|
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:
|
|
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(
|
|
25
|
-
key: zod_1.z.string().startsWith(
|
|
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,12 +1,13 @@
|
|
|
1
|
-
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
export type
|
|
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';
|
|
4
|
+
export type SetPrimaryButtonOptions = {
|
|
5
5
|
text: string;
|
|
6
6
|
loading?: boolean;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
hidden?: boolean;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
|
+
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
|
|
10
11
|
export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
|
|
11
12
|
export type AccountLocation = {
|
|
12
13
|
placeId: string;
|
|
@@ -16,7 +17,7 @@ export type AccountLocation = {
|
|
|
16
17
|
description: string;
|
|
17
18
|
};
|
|
18
19
|
export type FrameLocationContextCastEmbed = {
|
|
19
|
-
type:
|
|
20
|
+
type: 'cast_embed';
|
|
20
21
|
embed: string;
|
|
21
22
|
cast: {
|
|
22
23
|
fid: number;
|
|
@@ -24,7 +25,7 @@ export type FrameLocationContextCastEmbed = {
|
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
export type FrameLocationContextNotification = {
|
|
27
|
-
type:
|
|
28
|
+
type: 'notification';
|
|
28
29
|
notification: {
|
|
29
30
|
notificationId: string;
|
|
30
31
|
title: string;
|
|
@@ -32,7 +33,7 @@ export type FrameLocationContextNotification = {
|
|
|
32
33
|
};
|
|
33
34
|
};
|
|
34
35
|
export type FrameLocationContextLauncher = {
|
|
35
|
-
type:
|
|
36
|
+
type: 'launcher';
|
|
36
37
|
};
|
|
37
38
|
export type FrameLocationContext = FrameLocationContextCastEmbed | FrameLocationContextNotification | FrameLocationContextLauncher;
|
|
38
39
|
export type SafeAreaInsets = {
|
|
@@ -60,15 +61,6 @@ export type FrameContext = {
|
|
|
60
61
|
safeAreaInsets?: SafeAreaInsets;
|
|
61
62
|
};
|
|
62
63
|
};
|
|
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>;
|
|
72
64
|
export type ReadyOptions = {
|
|
73
65
|
/**
|
|
74
66
|
* Disable native gestures. Use this option if your frame uses gestures
|
|
@@ -104,7 +96,8 @@ export type WireFrameHost = {
|
|
|
104
96
|
setPrimaryButton: SetPrimaryButton;
|
|
105
97
|
ethProviderRequest: EthProviderRequest;
|
|
106
98
|
ethProviderRequestV2: RpcTransport;
|
|
107
|
-
|
|
99
|
+
eip6963RequestProvider: () => void;
|
|
100
|
+
addFrame: AddFrame.WireAddFrame;
|
|
108
101
|
};
|
|
109
102
|
export type FrameHost = {
|
|
110
103
|
context: FrameContext;
|
|
@@ -115,10 +108,15 @@ export type FrameHost = {
|
|
|
115
108
|
setPrimaryButton: SetPrimaryButton;
|
|
116
109
|
ethProviderRequest: EthProviderRequest;
|
|
117
110
|
ethProviderRequestV2: RpcTransport;
|
|
118
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Receive forwarded eip6963:requestProvider events from the frame document.
|
|
113
|
+
* Hosts must emit an EventEip6963AnnounceProvider in response.
|
|
114
|
+
*/
|
|
115
|
+
eip6963RequestProvider: () => void;
|
|
116
|
+
addFrame: AddFrame.AddFrame;
|
|
119
117
|
};
|
|
120
118
|
export type FrameEthProviderEventData = {
|
|
121
|
-
type:
|
|
119
|
+
type: 'frame_eth_provider_event';
|
|
122
120
|
} & EthProviderWireEvent;
|
|
123
121
|
export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
|
|
124
122
|
export type ProviderRpcError = {
|
|
@@ -127,29 +125,42 @@ export type ProviderRpcError = {
|
|
|
127
125
|
message?: string;
|
|
128
126
|
};
|
|
129
127
|
export type EthProviderWireEvent = {
|
|
130
|
-
event:
|
|
128
|
+
event: 'accountsChanged';
|
|
131
129
|
params: [readonly Address.Address[]];
|
|
132
130
|
} | {
|
|
133
|
-
event:
|
|
131
|
+
event: 'chainChanged';
|
|
134
132
|
params: [string];
|
|
135
133
|
} | {
|
|
136
|
-
event:
|
|
134
|
+
event: 'connect';
|
|
137
135
|
params: [Provider.ConnectInfo];
|
|
138
136
|
} | {
|
|
139
|
-
event:
|
|
137
|
+
event: 'disconnect';
|
|
140
138
|
params: [ProviderRpcError];
|
|
141
139
|
} | {
|
|
142
|
-
event:
|
|
140
|
+
event: 'message';
|
|
143
141
|
params: [Provider.Message];
|
|
144
142
|
};
|
|
145
|
-
export type EmitEthProvider = <event extends EthProviderWireEvent[
|
|
143
|
+
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
|
|
146
144
|
event: event;
|
|
147
|
-
}>[
|
|
145
|
+
}>['params']) => void;
|
|
148
146
|
export type EventFrameAddRejected = {
|
|
149
|
-
event:
|
|
150
|
-
reason: AddFrameRejectedReason;
|
|
147
|
+
event: 'frame_add_rejected';
|
|
148
|
+
reason: AddFrame.AddFrameRejectedReason;
|
|
151
149
|
};
|
|
152
150
|
export type EventPrimaryButtonClicked = {
|
|
153
|
-
event:
|
|
151
|
+
event: 'primary_button_clicked';
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Metadata of the EIP-1193 Provider.
|
|
155
|
+
*/
|
|
156
|
+
export interface EIP6963ProviderInfo {
|
|
157
|
+
icon: `data:image/${string}`;
|
|
158
|
+
name: string;
|
|
159
|
+
rdns: string;
|
|
160
|
+
uuid: string;
|
|
161
|
+
}
|
|
162
|
+
export type EventEip6963AnnounceProvider = {
|
|
163
|
+
event: 'eip6963:announceProvider';
|
|
164
|
+
info: EIP6963ProviderInfo;
|
|
154
165
|
};
|
|
155
|
-
export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked;
|
|
166
|
+
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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as Errors from '../errors'
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when the frame does not have a valid domain manifest.
|
|
4
|
+
*/
|
|
5
|
+
export class InvalidDomainManifest extends Errors.BaseError {
|
|
6
|
+
name = 'AddFrame.InvalidDomainManifest'
|
|
7
|
+
constructor() {
|
|
8
|
+
super('Invalid domain manifest')
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when add frame action was rejected by the user.
|
|
13
|
+
*/
|
|
14
|
+
export class RejectedByUser extends Errors.BaseError {
|
|
15
|
+
name = 'AddFrame.RejectedByUser'
|
|
16
|
+
constructor() {
|
|
17
|
+
super('Add frame rejected by user')
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as Errors from '../errors'
|
|
2
|
+
import type { OneOf } from '../internal/types'
|
|
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
|
+
}
|
|
19
|
+
export type SignInResult = {
|
|
20
|
+
signature: string
|
|
21
|
+
message: string
|
|
22
|
+
}
|
|
23
|
+
export type SignIn = (options: SignInOptions) => Promise<SignInResult>
|
|
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>
|
|
37
|
+
/**
|
|
38
|
+
* Thrown when a sign in action was rejected.
|
|
39
|
+
*/
|
|
40
|
+
export declare class RejectedByUser extends Errors.BaseError {
|
|
41
|
+
readonly name = 'SignIn.RejectedByUser'
|
|
42
|
+
constructor()
|
|
43
|
+
}
|