@shinkai_protocol/shinkai-typescript-lib
Advanced tools
Comparing version 0.7.0 to 0.7.1-development.29
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.blake3FromObj = exports.verify_inner_layer_signature = exports.sign_inner_layer = exports.sign_outer_layer = exports.verify_outer_layer_signature = exports.generateSignatureKeys = exports.ShinkaiMessageError = void 0; | ||
const ed = __importStar(require("noble-ed25519")); | ||
const ed25519_1 = require("@noble/curves/ed25519"); | ||
const blake3_1 = require("@noble/hashes/blake3"); | ||
@@ -39,5 +16,5 @@ const crypto_utils_1 = require("./crypto_utils"); | ||
const generateSignatureKeys = async (seed) => { | ||
seed = seed || ed.utils.randomPrivateKey(); | ||
seed = seed || ed25519_1.ed25519.utils.randomPrivateKey(); | ||
const privKey = new Uint8Array(seed); | ||
const pubKey = await ed.getPublicKey(privKey); | ||
const pubKey = await ed25519_1.ed25519.getPublicKey(privKey); | ||
const my_identity_sk_string = (0, crypto_utils_1.toHexString)(privKey); | ||
@@ -73,3 +50,3 @@ const my_identity_pk_string = (0, crypto_utils_1.toHexString)(pubKey); | ||
const messageHashBytes = new Uint8Array(messageHashMatched.map((byte) => parseInt(byte, 16))); | ||
return await ed.verify(signatureBytes, messageHashBytes, publicKey); | ||
return await ed25519_1.ed25519.verify(signatureBytes, messageHashBytes, publicKey); | ||
} | ||
@@ -98,3 +75,3 @@ catch (e) { | ||
const messageHashBytes = new Uint8Array(messageHashMatched.map((byte) => parseInt(byte, 16))); | ||
const signature = await ed.sign(messageHashBytes, secretKey); | ||
const signature = await ed25519_1.ed25519.sign(messageHashBytes, secretKey); | ||
shinkaiMessage.external_metadata.signature = Array.from(signature) | ||
@@ -126,3 +103,3 @@ .map((b) => b.toString(16).padStart(2, "0")) | ||
const messageHashBytes = new Uint8Array(messageHashMatched.map((byte) => parseInt(byte, 16))); | ||
const signature = await ed.sign(messageHashBytes, secretKey); | ||
const signature = await ed25519_1.ed25519.sign(messageHashBytes, secretKey); | ||
shinkaiBody.internal_metadata.signature = Array.from(signature) | ||
@@ -166,3 +143,3 @@ .map((b) => b.toString(16).padStart(2, "0")) | ||
const messageHashBytes = new Uint8Array(bodyHashMatched.map((byte) => parseInt(byte, 16))); | ||
return await ed.verify(signatureBytes, messageHashBytes, publicKey); | ||
return await ed25519_1.ed25519.verify(signatureBytes, messageHashBytes, publicKey); | ||
} | ||
@@ -169,0 +146,0 @@ catch (e) { |
@@ -36,5 +36,6 @@ import { ShinkaiMessage } from "../shinkai_message/shinkai_message"; | ||
export interface JobScope { | ||
local: string[]; | ||
local_vrkai: string[]; | ||
local_vrpack: string[]; | ||
vector_fs_items: []; | ||
vector_fs_folders: []; | ||
vector_fs_folders: VectorFSFolderScopeEntry[]; | ||
network_folders: []; | ||
@@ -44,2 +45,3 @@ } | ||
scope: JobScope; | ||
is_hidden?: boolean; | ||
} | ||
@@ -192,2 +194,6 @@ export interface JobMessage { | ||
} | ||
export interface VectorFSFolderScopeEntry { | ||
name: string; | ||
path: string; | ||
} | ||
export type PaymentOption = { | ||
@@ -194,0 +200,0 @@ type: 'USD'; |
@@ -47,3 +47,3 @@ import { APICreateShareableFolder, JobScope, MessageSchemaType, SerializedAgent, SubscriptionPayment, TSEncryptionMethod } from "../schemas/schema_types"; | ||
static ackMessage(my_encryption_secret_key: EncryptionStaticKey, my_signature_secret_key: SignatureStaticKey, receiver_public_key: EncryptionPublicKey, sender: ProfileName, receiver: ProfileName): Promise<ShinkaiMessage>; | ||
static jobCreation(scope: JobScope, my_encryption_secret_key: EncryptionStaticKey, my_signature_secret_key: SignatureStaticKey, receiver_public_key: EncryptionPublicKey, sender: ProfileName, sender_subidentity: string, node_receiver: ProfileName, node_receiver_subidentity: string): Promise<ShinkaiMessage>; | ||
static jobCreation(scope: JobScope, is_hidden: boolean | undefined, my_encryption_secret_key: EncryptionStaticKey, my_signature_secret_key: SignatureStaticKey, receiver_public_key: EncryptionPublicKey, sender: ProfileName, sender_subidentity: string, node_receiver: ProfileName, node_receiver_subidentity: string): Promise<ShinkaiMessage>; | ||
static jobMessage(job_id: string, content: string, files_inbox: string, parent: string | null, my_encryption_secret_key: EncryptionStaticKey, my_signature_secret_key: SignatureStaticKey, receiver_public_key: EncryptionPublicKey, node_sender: ProfileName, sender_subidentity: string, node_receiver: ProfileName, node_receiver_subidentity: string): Promise<ShinkaiMessage>; | ||
@@ -50,0 +50,0 @@ static jobMessageFromAgent(job_id: string, content: string, my_signature_secret_key: SignatureStaticKey, node_sender: ProfileName, node_receiver: ProfileName): Promise<ShinkaiMessage>; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -38,3 +15,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const shinkai_version_1 = require("../shinkai_message/shinkai_version"); | ||
const ed = __importStar(require("noble-ed25519")); | ||
const ed25519_1 = require("@noble/curves/ed25519"); | ||
class ShinkaiMessageBuilder { | ||
@@ -53,3 +30,3 @@ constructor(my_encryption_secret_key, my_signature_secret_key, receiver_public_key) { | ||
async init() { | ||
this.my_signature_public_key = await ed.getPublicKey(this.my_signature_secret_key); | ||
this.my_signature_public_key = await ed25519_1.ed25519.getPublicKey(this.my_signature_secret_key); | ||
return this; | ||
@@ -318,4 +295,4 @@ } | ||
} | ||
static async jobCreation(scope, my_encryption_secret_key, my_signature_secret_key, receiver_public_key, sender, sender_subidentity, node_receiver, node_receiver_subidentity) { | ||
const jobCreation = { scope }; | ||
static async jobCreation(scope, is_hidden, my_encryption_secret_key, my_signature_secret_key, receiver_public_key, sender, sender_subidentity, node_receiver, node_receiver_subidentity) { | ||
const jobCreation = { scope, is_hidden }; | ||
const body = JSON.stringify(jobCreation); | ||
@@ -331,3 +308,10 @@ return new ShinkaiMessageBuilder(my_encryption_secret_key, my_signature_secret_key, receiver_public_key) | ||
static async jobMessage(job_id, content, files_inbox, parent, my_encryption_secret_key, my_signature_secret_key, receiver_public_key, node_sender, sender_subidentity, node_receiver, node_receiver_subidentity) { | ||
const jobMessage = { job_id, content, files_inbox, parent: parent || "" }; | ||
const jobMessage = { | ||
job_id, | ||
content, | ||
files_inbox, | ||
parent: parent || '', | ||
workflow_code: null, | ||
workflow_name: null, | ||
}; | ||
const body = JSON.stringify(jobMessage); | ||
@@ -380,3 +364,3 @@ const inbox = inbox_name_1.InboxName.getJobInboxNameFromParams(job_id).value; | ||
static async useCodeRegistrationForProfile(profile_encryption_sk, profile_signature_sk, receiver_public_key, code, identity_type, permission_type, registration_name, sender_subidentity, sender, receiver) { | ||
const profile_signature_pk = await ed.getPublicKey(profile_signature_sk); | ||
const profile_signature_pk = await ed25519_1.ed25519.getPublicKey(profile_signature_sk); | ||
const profile_encryption_pk = tweetnacl_1.default.box.keyPair.fromSecretKey(profile_encryption_sk).publicKey; | ||
@@ -400,5 +384,5 @@ const registration_code = { | ||
static async useCodeRegistrationForDevice(my_device_encryption_sk, my_device_signature_sk, profile_encryption_sk, profile_signature_sk, receiver_public_key, code, identity_type, permission_type, registration_name, sender_subidentity, sender, receiver) { | ||
const my_device_signature_pk = await ed.getPublicKey(my_device_signature_sk); | ||
const my_device_signature_pk = await ed25519_1.ed25519.getPublicKey(my_device_signature_sk); | ||
const my_device_encryption_pk = tweetnacl_1.default.box.keyPair.fromSecretKey(my_device_encryption_sk).publicKey; | ||
const profile_signature_pk = await ed.getPublicKey(profile_signature_sk); | ||
const profile_signature_pk = await ed25519_1.ed25519.getPublicKey(profile_signature_sk); | ||
const profile_encryption_pk = tweetnacl_1.default.box.keyPair.fromSecretKey(profile_encryption_sk).publicKey; | ||
@@ -427,5 +411,5 @@ const other = Array.from(my_device_encryption_pk) | ||
static async initialRegistrationWithNoCodeForDevice(my_device_encryption_sk, my_device_signature_sk, profile_encryption_sk, profile_signature_sk, registration_name, sender_subidentity, sender, receiver) { | ||
const my_device_signature_pk = await ed.getPublicKey(my_device_signature_sk); | ||
const my_device_signature_pk = await ed25519_1.ed25519.getPublicKey(my_device_signature_sk); | ||
const my_device_encryption_pk = tweetnacl_1.default.box.keyPair.fromSecretKey(my_device_encryption_sk).publicKey; | ||
const profile_signature_pk = await ed.getPublicKey(profile_signature_sk); | ||
const profile_signature_pk = await ed25519_1.ed25519.getPublicKey(profile_signature_sk); | ||
const profile_encryption_pk = tweetnacl_1.default.box.keyPair.fromSecretKey(profile_encryption_sk).publicKey; | ||
@@ -432,0 +416,0 @@ const other = Array.from(my_device_encryption_pk) |
{ | ||
"name": "@shinkai_protocol/shinkai-typescript-lib", | ||
"version": "0.7.0", | ||
"version": "0.7.1-development.29", | ||
"description": "Typescript library to build and handle Shinkai Messages", | ||
@@ -39,3 +39,3 @@ "type": "commonjs", | ||
"dependencies": { | ||
"@noble/ed25519": "^2.0.0", | ||
"@noble/curves": "^1.4.2", | ||
"@noble/hashes": "^1.3.2", | ||
@@ -46,3 +46,2 @@ "@peculiar/webcrypto": "^1.4.3", | ||
"libsodium-wrappers-sumo": "^0.7.13", | ||
"noble-ed25519": "^1.2.6", | ||
"tweetnacl": "^1.0.3" | ||
@@ -49,0 +48,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7
120391
2222
+ Added@noble/curves@^1.4.2
+ Added@noble/curves@1.8.0(transitive)
- Removed@noble/ed25519@^2.0.0
- Removednoble-ed25519@^1.2.6
- Removed@noble/ed25519@2.2.2(transitive)
- Removednoble-ed25519@1.2.6(transitive)