0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 21:48:32 +00:00
renovatebot_renovate/lib/modules/datasource/hex/v2/signed.ts

120 lines
3.0 KiB
TypeScript

// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.178.0
// protoc v5.27.2
// source: signed.proto
// istanbul ignore file
/* eslint-disable */
import * as _m0 from 'protobufjs/minimal';
export const protobufPackage = '';
export interface Signed {
/** Signed contents */
payload: Uint8Array;
/** The signature */
signature?: Uint8Array | undefined;
}
function createBaseSigned(): Signed {
return { payload: new Uint8Array(0), signature: new Uint8Array(0) };
}
export const Signed = {
decode(input: _m0.Reader | Uint8Array, length?: number): Signed {
const reader =
input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSigned();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.payload = reader.bytes();
continue;
case 2:
if (tag !== 18) {
break;
}
message.signature = reader.bytes();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object: any): Signed {
return {
payload: isSet(object.payload)
? bytesFromBase64(object.payload)
: new Uint8Array(0),
signature: isSet(object.signature)
? bytesFromBase64(object.signature)
: new Uint8Array(0),
};
},
create<I extends Exact<DeepPartial<Signed>, I>>(base?: I): Signed {
return Signed.fromPartial(base ?? ({} as any));
},
fromPartial<I extends Exact<DeepPartial<Signed>, I>>(object: I): Signed {
const message = createBaseSigned();
message.payload = object.payload ?? new Uint8Array(0);
message.signature = object.signature ?? new Uint8Array(0);
return message;
},
};
function bytesFromBase64(b64: string): Uint8Array {
if ((globalThis as any).Buffer) {
return Uint8Array.from(globalThis.Buffer.from(b64, 'base64'));
} else {
const bin = globalThis.atob(b64);
const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i);
}
return arr;
}
}
type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export type DeepPartial<T> = T extends Builtin
? T
: T extends globalThis.Array<infer U>
? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: T extends {}
? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
};
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}