UNPKG

@fairmint/canton-node-sdk

Version:
81 lines 3.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AllocateExternalParty = exports.AllocateExternalPartyParamsSchema = void 0; const zod_1 = require("zod"); const core_1 = require("../../../../../../core"); // Schema for signature const SignatureSchema = zod_1.z.object({ format: zod_1.z.string(), signature: zod_1.z.string(), signedBy: zod_1.z.string(), signingAlgorithmSpec: zod_1.z.string(), }); // Schema for signed transaction (signatures must be present or omitted, not undefined) const SignedTransactionSchema = zod_1.z.union([ zod_1.z.object({ transaction: zod_1.z.string(), signatures: zod_1.z.array(SignatureSchema), }), zod_1.z.object({ transaction: zod_1.z.string(), }), ]); // Schema for the parameters exports.AllocateExternalPartyParamsSchema = zod_1.z.object({ /** Synchronizer ID on which to onboard the party */ synchronizer: zod_1.z.string(), /** Topology transactions to onboard the external party (from generate-topology endpoint) */ onboardingTransactions: zod_1.z.array(SignedTransactionSchema).optional(), /** Signatures for the multi-hash (alternative to signing each individual transaction) */ multiHashSignatures: zod_1.z.array(SignatureSchema).optional(), /** Identity provider ID. If not set, assume the party is managed by the default identity provider. */ identityProviderId: zod_1.z.string(), }); /** * Allocate a new external party * * This endpoint completes the onboarding of an external party by submitting the signed topology transactions or * multi-hash signatures. The topology transactions and multi-hash should be obtained from the generate-topology * endpoint and signed with the external party's private key. * * @example * ```typescript * // Option 1: Using multi-hash signatures (recommended) * const result = await client.allocateExternalParty({ * synchronizer: 'global-synchronizer', * identityProviderId: 'default', * multiHashSignatures: [{ * format: 'SIGNATURE_FORMAT_RAW', * signature: 'base64-encoded-signature', * signedBy: 'public-key-fingerprint', * signingAlgorithmSpec: 'SIGNING_KEY_SPEC_EC_CURVE25519' * }] * }); * * // Option 2: Using signed transactions * const result = await client.allocateExternalParty({ * synchronizer: 'global-synchronizer', * identityProviderId: 'default', * onboardingTransactions: [{ * transaction: 'serialized-transaction', * signatures: [{ ... }] * }] * }); * ```; */ exports.AllocateExternalParty = (0, core_1.createApiOperation)({ paramsSchema: exports.AllocateExternalPartyParamsSchema, method: 'POST', buildUrl: (_params, apiUrl) => `${apiUrl}/v2/parties/external/allocate`, buildRequestData: (params, _client) => ({ synchronizer: params.synchronizer, identityProviderId: params.identityProviderId, ...(params.onboardingTransactions && { onboardingTransactions: params.onboardingTransactions, }), ...(params.multiHashSignatures && { multiHashSignatures: params.multiHashSignatures, }), }), }); //# sourceMappingURL=allocate-external-party.js.map