ncrypted 0.3.0 → 0.3.1
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/ai-sdk.d.ts +16 -0
- package/dist/ai-sdk.js +9 -4
- package/dist/client.d.ts +9 -3
- package/dist/client.js +7 -2
- package/package.json +1 -1
package/dist/ai-sdk.d.ts
CHANGED
|
@@ -974,17 +974,20 @@ export declare function ncryptedTools(options?: NcryptedToolsOptions): Partial<{
|
|
|
974
974
|
};
|
|
975
975
|
output: NoInfer<string | {
|
|
976
976
|
burned: boolean;
|
|
977
|
+
status: import("./client.js").SecretStatus;
|
|
977
978
|
}>;
|
|
978
979
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
979
980
|
} & {
|
|
980
981
|
outputSchema?: import("ai").FlexibleSchema<string | {
|
|
981
982
|
burned: boolean;
|
|
983
|
+
status: import("./client.js").SecretStatus;
|
|
982
984
|
}> | undefined;
|
|
983
985
|
execute: import("ai").ToolExecuteFunction<{
|
|
984
986
|
id: string;
|
|
985
987
|
receiptToken: string;
|
|
986
988
|
}, string | {
|
|
987
989
|
burned: boolean;
|
|
990
|
+
status: import("./client.js").SecretStatus;
|
|
988
991
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
989
992
|
} & {
|
|
990
993
|
description?: string | ((options: {
|
|
@@ -1010,6 +1013,7 @@ export declare function ncryptedTools(options?: NcryptedToolsOptions): Partial<{
|
|
|
1010
1013
|
receiptToken: string;
|
|
1011
1014
|
}, string | {
|
|
1012
1015
|
burned: boolean;
|
|
1016
|
+
status: import("./client.js").SecretStatus;
|
|
1013
1017
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
1014
1018
|
}) | ({
|
|
1015
1019
|
deferLoading?: boolean;
|
|
@@ -1043,17 +1047,20 @@ export declare function ncryptedTools(options?: NcryptedToolsOptions): Partial<{
|
|
|
1043
1047
|
};
|
|
1044
1048
|
output: NoInfer<string | {
|
|
1045
1049
|
burned: boolean;
|
|
1050
|
+
status: import("./client.js").SecretStatus;
|
|
1046
1051
|
}>;
|
|
1047
1052
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
1048
1053
|
} & {
|
|
1049
1054
|
outputSchema?: import("ai").FlexibleSchema<string | {
|
|
1050
1055
|
burned: boolean;
|
|
1056
|
+
status: import("./client.js").SecretStatus;
|
|
1051
1057
|
}> | undefined;
|
|
1052
1058
|
execute: import("ai").ToolExecuteFunction<{
|
|
1053
1059
|
id: string;
|
|
1054
1060
|
receiptToken: string;
|
|
1055
1061
|
}, string | {
|
|
1056
1062
|
burned: boolean;
|
|
1063
|
+
status: import("./client.js").SecretStatus;
|
|
1057
1064
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
1058
1065
|
} & {
|
|
1059
1066
|
description?: string | ((options: {
|
|
@@ -1079,6 +1086,7 @@ export declare function ncryptedTools(options?: NcryptedToolsOptions): Partial<{
|
|
|
1079
1086
|
receiptToken: string;
|
|
1080
1087
|
}, string | {
|
|
1081
1088
|
burned: boolean;
|
|
1089
|
+
status: import("./client.js").SecretStatus;
|
|
1082
1090
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
1083
1091
|
}) | ({
|
|
1084
1092
|
deferLoading?: boolean;
|
|
@@ -1112,17 +1120,20 @@ export declare function ncryptedTools(options?: NcryptedToolsOptions): Partial<{
|
|
|
1112
1120
|
};
|
|
1113
1121
|
output: NoInfer<string | {
|
|
1114
1122
|
burned: boolean;
|
|
1123
|
+
status: import("./client.js").SecretStatus;
|
|
1115
1124
|
}>;
|
|
1116
1125
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
1117
1126
|
} & {
|
|
1118
1127
|
outputSchema?: import("ai").FlexibleSchema<string | {
|
|
1119
1128
|
burned: boolean;
|
|
1129
|
+
status: import("./client.js").SecretStatus;
|
|
1120
1130
|
}> | undefined;
|
|
1121
1131
|
execute: import("ai").ToolExecuteFunction<{
|
|
1122
1132
|
id: string;
|
|
1123
1133
|
receiptToken: string;
|
|
1124
1134
|
}, string | {
|
|
1125
1135
|
burned: boolean;
|
|
1136
|
+
status: import("./client.js").SecretStatus;
|
|
1126
1137
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
1127
1138
|
} & {
|
|
1128
1139
|
type: "provider";
|
|
@@ -1140,6 +1151,7 @@ export declare function ncryptedTools(options?: NcryptedToolsOptions): Partial<{
|
|
|
1140
1151
|
receiptToken: string;
|
|
1141
1152
|
}, string | {
|
|
1142
1153
|
burned: boolean;
|
|
1154
|
+
status: import("./client.js").SecretStatus;
|
|
1143
1155
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
1144
1156
|
}) | ({
|
|
1145
1157
|
deferLoading?: boolean;
|
|
@@ -1173,17 +1185,20 @@ export declare function ncryptedTools(options?: NcryptedToolsOptions): Partial<{
|
|
|
1173
1185
|
};
|
|
1174
1186
|
output: NoInfer<string | {
|
|
1175
1187
|
burned: boolean;
|
|
1188
|
+
status: import("./client.js").SecretStatus;
|
|
1176
1189
|
}>;
|
|
1177
1190
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
1178
1191
|
} & {
|
|
1179
1192
|
outputSchema?: import("ai").FlexibleSchema<string | {
|
|
1180
1193
|
burned: boolean;
|
|
1194
|
+
status: import("./client.js").SecretStatus;
|
|
1181
1195
|
}> | undefined;
|
|
1182
1196
|
execute: import("ai").ToolExecuteFunction<{
|
|
1183
1197
|
id: string;
|
|
1184
1198
|
receiptToken: string;
|
|
1185
1199
|
}, string | {
|
|
1186
1200
|
burned: boolean;
|
|
1201
|
+
status: import("./client.js").SecretStatus;
|
|
1187
1202
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
1188
1203
|
} & {
|
|
1189
1204
|
type: "provider";
|
|
@@ -1201,6 +1216,7 @@ export declare function ncryptedTools(options?: NcryptedToolsOptions): Partial<{
|
|
|
1201
1216
|
receiptToken: string;
|
|
1202
1217
|
}, string | {
|
|
1203
1218
|
burned: boolean;
|
|
1219
|
+
status: import("./client.js").SecretStatus;
|
|
1204
1220
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
1205
1221
|
});
|
|
1206
1222
|
ncrypted_to_vercel_env: ({
|
package/dist/ai-sdk.js
CHANGED
|
@@ -61,7 +61,10 @@ export function ncryptedTools(options = {}) {
|
|
|
61
61
|
}),
|
|
62
62
|
ncrypted_status: tool({
|
|
63
63
|
description: "Check whether a secret you created has been opened (pending, read, burned or expired). Free.",
|
|
64
|
-
inputSchema: z.object({
|
|
64
|
+
inputSchema: z.object({
|
|
65
|
+
id: z.string().describe("The secret's id, returned by ncrypted_create."),
|
|
66
|
+
receiptToken: z.string().describe("The creator's receipt token, returned by ncrypted_create."),
|
|
67
|
+
}),
|
|
65
68
|
execute: async ({ id, receiptToken }) => {
|
|
66
69
|
try {
|
|
67
70
|
return await nc.status(id, receiptToken);
|
|
@@ -73,11 +76,13 @@ export function ncryptedTools(options = {}) {
|
|
|
73
76
|
}),
|
|
74
77
|
ncrypted_burn: tool({
|
|
75
78
|
description: "Destroy a secret you created before anyone opens it, e.g. if the link went to the wrong place. Free.",
|
|
76
|
-
inputSchema: z.object({
|
|
79
|
+
inputSchema: z.object({
|
|
80
|
+
id: z.string().describe("The secret's id, returned by ncrypted_create."),
|
|
81
|
+
receiptToken: z.string().describe("The creator's receipt token, returned by ncrypted_create."),
|
|
82
|
+
}),
|
|
77
83
|
execute: async ({ id, receiptToken }) => {
|
|
78
84
|
try {
|
|
79
|
-
await nc.burn(id, receiptToken);
|
|
80
|
-
return { burned: true };
|
|
85
|
+
return await nc.burn(id, receiptToken);
|
|
81
86
|
}
|
|
82
87
|
catch (e) {
|
|
83
88
|
return errorText(e);
|
package/dist/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type Destination, type DeliveryResult } from "./destinations.js";
|
|
|
2
2
|
export declare const DEFAULT_BASE_URL = "https://ncrypted.ai";
|
|
3
3
|
/** Hard cap on what the SDK will ever pay for one secret, whatever the server asks. */
|
|
4
4
|
export declare const MAX_PRICE = "$0.01";
|
|
5
|
-
export declare const SDK_VERSION = "0.3.
|
|
5
|
+
export declare const SDK_VERSION = "0.3.1";
|
|
6
6
|
export interface NcryptedOptions {
|
|
7
7
|
/** API origin. Defaults to NCRYPTED_URL or the hosted service. */
|
|
8
8
|
baseUrl?: string;
|
|
@@ -138,6 +138,12 @@ export declare class Ncrypted {
|
|
|
138
138
|
readAt?: string;
|
|
139
139
|
expiresAt?: string;
|
|
140
140
|
}>;
|
|
141
|
-
/**
|
|
142
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Destroys an unread secret early. Needs the creator's receipt token. Resolves { burned: false } with the current
|
|
143
|
+
* status when there was nothing left to destroy (already read, burned or expired).
|
|
144
|
+
*/
|
|
145
|
+
burn(id: string, receiptToken: string): Promise<{
|
|
146
|
+
burned: boolean;
|
|
147
|
+
status: SecretStatus;
|
|
148
|
+
}>;
|
|
143
149
|
}
|
package/dist/client.js
CHANGED
|
@@ -9,7 +9,7 @@ import { privateKeyToAccount as accountOf } from "viem/accounts";
|
|
|
9
9
|
export const DEFAULT_BASE_URL = "https://ncrypted.ai";
|
|
10
10
|
/** Hard cap on what the SDK will ever pay for one secret, whatever the server asks. */
|
|
11
11
|
export const MAX_PRICE = "$0.01";
|
|
12
|
-
export const SDK_VERSION = "0.3.
|
|
12
|
+
export const SDK_VERSION = "0.3.1";
|
|
13
13
|
export class NcryptedError extends Error {
|
|
14
14
|
status;
|
|
15
15
|
constructor(message, status) {
|
|
@@ -291,7 +291,10 @@ export class Ncrypted {
|
|
|
291
291
|
throw await errorFrom(res);
|
|
292
292
|
return (await res.json());
|
|
293
293
|
}
|
|
294
|
-
/**
|
|
294
|
+
/**
|
|
295
|
+
* Destroys an unread secret early. Needs the creator's receipt token. Resolves { burned: false } with the current
|
|
296
|
+
* status when there was nothing left to destroy (already read, burned or expired).
|
|
297
|
+
*/
|
|
295
298
|
async burn(id, receiptToken) {
|
|
296
299
|
const res = await fetch(`${this.baseUrl}/api/v1/secrets/${id}`, {
|
|
297
300
|
method: "DELETE",
|
|
@@ -299,5 +302,7 @@ export class Ncrypted {
|
|
|
299
302
|
});
|
|
300
303
|
if (!res.ok)
|
|
301
304
|
throw await errorFrom(res);
|
|
305
|
+
const body = (await res.json().catch(() => ({})));
|
|
306
|
+
return { burned: body.burned ?? true, status: body.status ?? "burned" };
|
|
302
307
|
}
|
|
303
308
|
}
|
package/package.json
CHANGED