@farcaster/miniapp-core 0.3.7 → 0.3.9
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/SignManifest.d.ts +51 -0
- package/dist/actions/SignManifest.js +67 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +2 -1
- package/dist/schemas/events.d.ts +0 -64
- package/dist/schemas/events.js +1 -11
- package/dist/schemas/manifest.d.ts +28 -28
- package/dist/types.d.ts +6 -8
- package/dist/types.js +1 -0
- package/esm/actions/SignManifest.d.ts +51 -0
- package/esm/actions/SignManifest.js +28 -0
- package/esm/actions/index.d.ts +1 -0
- package/esm/actions/index.js +1 -0
- package/esm/schemas/events.d.ts +0 -64
- package/esm/schemas/events.js +0 -10
- package/esm/schemas/manifest.d.ts +28 -28
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/types.d.ts +6 -8
- package/esm/types.js +1 -0
- package/package.json +1 -1
- package/src/actions/SignManifest.ts +77 -0
- package/src/actions/index.ts +1 -0
- package/src/schemas/events.ts +0 -16
- package/src/types.ts +4 -10
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as Errors from '../errors.ts';
|
|
2
|
+
import type { OneOf } from '../internal/types.ts';
|
|
3
|
+
export type SignManifestOptions = {
|
|
4
|
+
domain: string;
|
|
5
|
+
};
|
|
6
|
+
export type SignManifestResult = {
|
|
7
|
+
header: string;
|
|
8
|
+
payload: string;
|
|
9
|
+
signature: string;
|
|
10
|
+
};
|
|
11
|
+
export type SignManifest = (options: SignManifestOptions) => Promise<SignManifestResult>;
|
|
12
|
+
type RejectedByUserJsonError = {
|
|
13
|
+
type: 'rejected_by_user';
|
|
14
|
+
};
|
|
15
|
+
type InvalidDomainJsonError = {
|
|
16
|
+
type: 'invalid_domain';
|
|
17
|
+
};
|
|
18
|
+
type GenericErrorJsonError = {
|
|
19
|
+
type: 'generic_error';
|
|
20
|
+
message?: string;
|
|
21
|
+
};
|
|
22
|
+
export type SignManifestJsonError = RejectedByUserJsonError | InvalidDomainJsonError | GenericErrorJsonError;
|
|
23
|
+
export type SignManifestRejectedReason = SignManifestJsonError['type'];
|
|
24
|
+
export type SignManifestJsonResult = OneOf<{
|
|
25
|
+
result: SignManifestResult;
|
|
26
|
+
} | {
|
|
27
|
+
error: SignManifestJsonError;
|
|
28
|
+
}>;
|
|
29
|
+
export type WireSignManifest = (options: SignManifestOptions) => Promise<SignManifestJsonResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Thrown when sign manifest action was rejected by the user.
|
|
32
|
+
*/
|
|
33
|
+
export declare class RejectedByUser extends Errors.BaseError {
|
|
34
|
+
readonly name = "SignManifest.RejectedByUser";
|
|
35
|
+
constructor();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Thrown when the provided domain is invalid.
|
|
39
|
+
*/
|
|
40
|
+
export declare class InvalidDomain extends Errors.BaseError {
|
|
41
|
+
readonly name = "SignManifest.InvalidDomain";
|
|
42
|
+
constructor();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Thrown when manifest signing fails for generic reasons.
|
|
46
|
+
*/
|
|
47
|
+
export declare class GenericError extends Errors.BaseError {
|
|
48
|
+
readonly name = "SignManifest.GenericError";
|
|
49
|
+
constructor(message?: string);
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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.GenericError = exports.InvalidDomain = exports.RejectedByUser = void 0;
|
|
37
|
+
const Errors = __importStar(require("../errors.js"));
|
|
38
|
+
/**
|
|
39
|
+
* Thrown when sign manifest action was rejected by the user.
|
|
40
|
+
*/
|
|
41
|
+
class RejectedByUser extends Errors.BaseError {
|
|
42
|
+
name = 'SignManifest.RejectedByUser';
|
|
43
|
+
constructor() {
|
|
44
|
+
super('Sign manifest rejected by user');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.RejectedByUser = RejectedByUser;
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when the provided domain is invalid.
|
|
50
|
+
*/
|
|
51
|
+
class InvalidDomain extends Errors.BaseError {
|
|
52
|
+
name = 'SignManifest.InvalidDomain';
|
|
53
|
+
constructor() {
|
|
54
|
+
super('Invalid domain provided');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.InvalidDomain = InvalidDomain;
|
|
58
|
+
/**
|
|
59
|
+
* Thrown when manifest signing fails for generic reasons.
|
|
60
|
+
*/
|
|
61
|
+
class GenericError extends Errors.BaseError {
|
|
62
|
+
name = 'SignManifest.GenericError';
|
|
63
|
+
constructor(message = 'Manifest signing failed') {
|
|
64
|
+
super(message);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.GenericError = GenericError;
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * as Ready from './Ready.ts';
|
|
|
6
6
|
export * as RequestCameraAndMicrophoneAccess from './RequestCameraAndMicrophoneAccess.ts';
|
|
7
7
|
export * as SendToken from './SendToken.ts';
|
|
8
8
|
export * as SignIn from './SignIn.ts';
|
|
9
|
+
export * as SignManifest from './SignManifest.ts';
|
|
9
10
|
export * as SwapToken from './SwapToken.ts';
|
|
10
11
|
export * as ViewCast from './ViewCast.ts';
|
|
11
12
|
export * as ViewProfile from './ViewProfile.ts';
|
package/dist/actions/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ViewToken = exports.ViewProfile = exports.ViewCast = exports.SwapToken = exports.SignIn = exports.SendToken = exports.RequestCameraAndMicrophoneAccess = exports.Ready = exports.OpenMiniApp = exports.Haptics = exports.ComposeCast = exports.AddMiniApp = void 0;
|
|
36
|
+
exports.ViewToken = exports.ViewProfile = exports.ViewCast = exports.SwapToken = exports.SignManifest = exports.SignIn = exports.SendToken = exports.RequestCameraAndMicrophoneAccess = exports.Ready = exports.OpenMiniApp = exports.Haptics = exports.ComposeCast = exports.AddMiniApp = void 0;
|
|
37
37
|
exports.AddMiniApp = __importStar(require("./AddMiniApp.js"));
|
|
38
38
|
exports.ComposeCast = __importStar(require("./ComposeCast.js"));
|
|
39
39
|
exports.Haptics = __importStar(require("./Haptics.js"));
|
|
@@ -42,6 +42,7 @@ exports.Ready = __importStar(require("./Ready.js"));
|
|
|
42
42
|
exports.RequestCameraAndMicrophoneAccess = __importStar(require("./RequestCameraAndMicrophoneAccess.js"));
|
|
43
43
|
exports.SendToken = __importStar(require("./SendToken.js"));
|
|
44
44
|
exports.SignIn = __importStar(require("./SignIn.js"));
|
|
45
|
+
exports.SignManifest = __importStar(require("./SignManifest.js"));
|
|
45
46
|
exports.SwapToken = __importStar(require("./SwapToken.js"));
|
|
46
47
|
exports.ViewCast = __importStar(require("./ViewCast.js"));
|
|
47
48
|
exports.ViewProfile = __importStar(require("./ViewProfile.js"));
|
package/dist/schemas/events.d.ts
CHANGED
|
@@ -25,32 +25,6 @@ export declare const eventMiniAppAddedSchema: z.ZodObject<{
|
|
|
25
25
|
} | undefined;
|
|
26
26
|
}>;
|
|
27
27
|
export type EventMiniAppAdded = z.infer<typeof eventMiniAppAddedSchema>;
|
|
28
|
-
export declare const eventFrameAddedSchema: z.ZodObject<{
|
|
29
|
-
event: z.ZodLiteral<"frame_added">;
|
|
30
|
-
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
31
|
-
url: z.ZodString;
|
|
32
|
-
token: z.ZodString;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
url: string;
|
|
35
|
-
token: string;
|
|
36
|
-
}, {
|
|
37
|
-
url: string;
|
|
38
|
-
token: string;
|
|
39
|
-
}>>;
|
|
40
|
-
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
event: "frame_added";
|
|
42
|
-
notificationDetails?: {
|
|
43
|
-
url: string;
|
|
44
|
-
token: string;
|
|
45
|
-
} | undefined;
|
|
46
|
-
}, {
|
|
47
|
-
event: "frame_added";
|
|
48
|
-
notificationDetails?: {
|
|
49
|
-
url: string;
|
|
50
|
-
token: string;
|
|
51
|
-
} | undefined;
|
|
52
|
-
}>;
|
|
53
|
-
export type EventFrameAdded = z.infer<typeof eventFrameAddedSchema>;
|
|
54
28
|
export declare const eventMiniAppRemovedSchema: z.ZodObject<{
|
|
55
29
|
event: z.ZodLiteral<"miniapp_removed">;
|
|
56
30
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -59,14 +33,6 @@ export declare const eventMiniAppRemovedSchema: z.ZodObject<{
|
|
|
59
33
|
event: "miniapp_removed";
|
|
60
34
|
}>;
|
|
61
35
|
export type EventMiniAppRemoved = z.infer<typeof eventMiniAppRemovedSchema>;
|
|
62
|
-
export declare const eventFrameRemovedSchema: z.ZodObject<{
|
|
63
|
-
event: z.ZodLiteral<"frame_removed">;
|
|
64
|
-
}, "strip", z.ZodTypeAny, {
|
|
65
|
-
event: "frame_removed";
|
|
66
|
-
}, {
|
|
67
|
-
event: "frame_removed";
|
|
68
|
-
}>;
|
|
69
|
-
export type EventFrameRemoved = z.infer<typeof eventFrameRemovedSchema>;
|
|
70
36
|
export declare const eventNotificationsEnabledSchema: z.ZodObject<{
|
|
71
37
|
event: z.ZodLiteral<"notifications_enabled">;
|
|
72
38
|
notificationDetails: z.ZodObject<{
|
|
@@ -161,35 +127,5 @@ export declare const serverEventSchema: z.ZodDiscriminatedUnion<"event", [z.ZodO
|
|
|
161
127
|
event: "notifications_disabled";
|
|
162
128
|
}, {
|
|
163
129
|
event: "notifications_disabled";
|
|
164
|
-
}>, z.ZodObject<{
|
|
165
|
-
event: z.ZodLiteral<"frame_added">;
|
|
166
|
-
notificationDetails: z.ZodOptional<z.ZodObject<{
|
|
167
|
-
url: z.ZodString;
|
|
168
|
-
token: z.ZodString;
|
|
169
|
-
}, "strip", z.ZodTypeAny, {
|
|
170
|
-
url: string;
|
|
171
|
-
token: string;
|
|
172
|
-
}, {
|
|
173
|
-
url: string;
|
|
174
|
-
token: string;
|
|
175
|
-
}>>;
|
|
176
|
-
}, "strip", z.ZodTypeAny, {
|
|
177
|
-
event: "frame_added";
|
|
178
|
-
notificationDetails?: {
|
|
179
|
-
url: string;
|
|
180
|
-
token: string;
|
|
181
|
-
} | undefined;
|
|
182
|
-
}, {
|
|
183
|
-
event: "frame_added";
|
|
184
|
-
notificationDetails?: {
|
|
185
|
-
url: string;
|
|
186
|
-
token: string;
|
|
187
|
-
} | undefined;
|
|
188
|
-
}>, z.ZodObject<{
|
|
189
|
-
event: z.ZodLiteral<"frame_removed">;
|
|
190
|
-
}, "strip", z.ZodTypeAny, {
|
|
191
|
-
event: "frame_removed";
|
|
192
|
-
}, {
|
|
193
|
-
event: "frame_removed";
|
|
194
130
|
}>]>;
|
|
195
131
|
export type MiniAppServerEvent = z.infer<typeof serverEventSchema>;
|
package/dist/schemas/events.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serverEventSchema = exports.notificationsDisabledSchema = exports.eventNotificationsEnabledSchema = exports.
|
|
3
|
+
exports.serverEventSchema = exports.notificationsDisabledSchema = exports.eventNotificationsEnabledSchema = exports.eventMiniAppRemovedSchema = exports.eventMiniAppAddedSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const notifications_ts_1 = require("./notifications.js");
|
|
6
6
|
exports.eventMiniAppAddedSchema = zod_1.z.object({
|
|
7
7
|
event: zod_1.z.literal('miniapp_added'),
|
|
8
8
|
notificationDetails: notifications_ts_1.notificationDetailsSchema.optional(),
|
|
9
9
|
});
|
|
10
|
-
exports.eventFrameAddedSchema = zod_1.z.object({
|
|
11
|
-
event: zod_1.z.literal('frame_added'),
|
|
12
|
-
notificationDetails: notifications_ts_1.notificationDetailsSchema.optional(),
|
|
13
|
-
});
|
|
14
10
|
exports.eventMiniAppRemovedSchema = zod_1.z.object({
|
|
15
11
|
event: zod_1.z.literal('miniapp_removed'),
|
|
16
12
|
});
|
|
17
|
-
exports.eventFrameRemovedSchema = zod_1.z.object({
|
|
18
|
-
event: zod_1.z.literal('frame_removed'),
|
|
19
|
-
});
|
|
20
13
|
exports.eventNotificationsEnabledSchema = zod_1.z.object({
|
|
21
14
|
event: zod_1.z.literal('notifications_enabled'),
|
|
22
15
|
notificationDetails: notifications_ts_1.notificationDetailsSchema.required(),
|
|
@@ -29,7 +22,4 @@ exports.serverEventSchema = zod_1.z.discriminatedUnion('event', [
|
|
|
29
22
|
exports.eventMiniAppRemovedSchema,
|
|
30
23
|
exports.eventNotificationsEnabledSchema,
|
|
31
24
|
exports.notificationsDisabledSchema,
|
|
32
|
-
// Remove after compatibility period
|
|
33
|
-
exports.eventFrameAddedSchema,
|
|
34
|
-
exports.eventFrameRemovedSchema,
|
|
35
25
|
]);
|