@akashnetwork/chain-sdk 1.0.0-alpha.4 → 1.0.0-alpha.5
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/cjs/sdk/chain/createChainNodeSDK.cjs.map +1 -1
- package/dist/cjs/sdk/client/createClientFactory.cjs.map +2 -2
- package/dist/cjs/sdk/client/createServiceClient.cjs.map +1 -1
- package/dist/cjs/sdk/provider/auth/jwt/validate-payload.cjs +66 -11
- package/dist/cjs/sdk/provider/auth/jwt/validate-payload.cjs.map +2 -2
- package/dist/cjs/sdk/transport/tx/createStargateClient/createStargateClient.cjs.map +2 -2
- package/dist/cjs/sdk/transport/tx/createTxTransport.cjs +8 -1
- package/dist/cjs/sdk/transport/tx/createTxTransport.cjs.map +2 -2
- package/dist/cjs/sdk/transport/tx/createTxTransport.spec.cjs +20 -0
- package/dist/cjs/sdk/transport/tx/createTxTransport.spec.cjs.map +2 -2
- package/dist/cjs/sdk/transport/types.cjs.map +1 -1
- package/dist/esm/{chunk-ICOYRYBC.js → chunk-WTSGBRN7.js} +75 -13
- package/dist/esm/chunk-WTSGBRN7.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/index.web.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/sdk/chain/createChainNodeSDK.d.ts +3 -0
- package/dist/types/sdk/client/createClientFactory.d.ts +2 -1
- package/dist/types/sdk/client/createServiceClient.d.ts +1 -1
- package/dist/types/sdk/provider/auth/jwt/validate-payload.d.ts +19 -1
- package/dist/types/sdk/transport/tx/createStargateClient/createStargateClient.d.ts +8 -0
- package/dist/types/sdk/transport/types.d.ts +1 -1
- package/package.json +1 -1
- package/dist/esm/chunk-ICOYRYBC.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/sdk/chain/createChainNodeSDK.ts"],
|
|
4
|
-
"sourcesContent": ["import type { GeneratedType } from \"@cosmjs/proto-signing\";\n\nimport { createSDK as createCosmosSDK, serviceLoader as cosmosServiceLoader } from \"../../generated/createCosmosSDK.ts\";\nimport { createSDK as createNodeSDK, serviceLoader as nodeServiceLoader } from \"../../generated/createNodeSDK.ts\";\nimport { patches as cosmosPatches } from \"../../generated/patches/cosmosCustomTypePatches.ts\";\nimport { patches as nodePatches } from \"../../generated/patches/nodeCustomTypePatches.ts\";\nimport { TxRaw } from \"../../generated/protos/cosmos/tx/v1beta1/tx.ts\";\nimport { createMessageType } from \"../client/createServiceLoader.ts\";\nimport type { MessageDesc } from \"../client/types.ts\";\nimport { createNoopTransport } from \"../transport/createNoopTransport.ts\";\nimport { createGrpcTransport } from \"../transport/grpc/createGrpcTransport.ts\";\nimport type { StargateClientOptions } from \"../transport/tx/createStargateClient/createStargateClient.ts\";\nimport { createStargateClient } from \"../transport/tx/createStargateClient/createStargateClient.ts\";\nimport { createTxTransport } from \"../transport/tx/createTxTransport.ts\";\nimport type { Transport, TxCallOptions } from \"../transport/types.ts\";\n\nexport type { PayloadOf, ResponseOf } from \"../types.ts\";\n\nexport function createChainNodeSDK(options: ChainNodeSDKOptions) {\n const queryTransport = createGrpcTransport({\n baseUrl: options.query.baseUrl,\n });\n let txTransport: Transport<TxCallOptions>;\n\n if (options.tx) {\n const { builtInTypes, ...txOptions } = options.tx;\n const defaultRegistryTypes = [\n createMessageType(TxRaw),\n ...(builtInTypes ?? []).map(createMessageType),\n ].reduce<Record<string, GeneratedType>>((acc, type) => {\n acc[type.typeUrl] = type;\n return acc;\n }, {});\n const getMessageType: StargateClientOptions[\"getMessageType\"] = (typeUrl) => nodeServiceLoader.getLoadedType(typeUrl) || cosmosServiceLoader.getLoadedType(typeUrl) || defaultRegistryTypes[typeUrl];\n txTransport = createTxTransport({\n getMessageType,\n client: createStargateClient({\n ...txOptions,\n getMessageType,\n }),\n });\n } else {\n txTransport = createNoopTransport({\n unaryErrorMessage: `Unable to sign transaction. \"tx\" option is not provided during chain SDK creation`,\n });\n }\n const nodeSDK = createNodeSDK(queryTransport, txTransport, {\n clientOptions: { typePatches: { ...cosmosPatches, ...nodePatches } },\n });\n const cosmosSDK = createCosmosSDK(queryTransport, txTransport, {\n clientOptions: { typePatches: cosmosPatches },\n });\n return { ...nodeSDK, ...cosmosSDK };\n}\n\nexport interface ChainNodeSDKOptions {\n query: {\n /**\n * Blockchain gRPC endpoint\n */\n baseUrl: string;\n };\n tx?: Omit<StargateClientOptions, \"getMessageType\" | \"builtInTypes\"> & {\n builtInTypes?: MessageDesc[];\n };\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type { GeneratedType } from \"@cosmjs/proto-signing\";\n\nimport { createSDK as createCosmosSDK, serviceLoader as cosmosServiceLoader } from \"../../generated/createCosmosSDK.ts\";\nimport { createSDK as createNodeSDK, serviceLoader as nodeServiceLoader } from \"../../generated/createNodeSDK.ts\";\nimport { patches as cosmosPatches } from \"../../generated/patches/cosmosCustomTypePatches.ts\";\nimport { patches as nodePatches } from \"../../generated/patches/nodeCustomTypePatches.ts\";\nimport { TxRaw } from \"../../generated/protos/cosmos/tx/v1beta1/tx.ts\";\nimport { createMessageType } from \"../client/createServiceLoader.ts\";\nimport type { MessageDesc } from \"../client/types.ts\";\nimport { createNoopTransport } from \"../transport/createNoopTransport.ts\";\nimport { createGrpcTransport } from \"../transport/grpc/createGrpcTransport.ts\";\nimport type { StargateClientOptions } from \"../transport/tx/createStargateClient/createStargateClient.ts\";\nimport { createStargateClient } from \"../transport/tx/createStargateClient/createStargateClient.ts\";\nimport { createTxTransport } from \"../transport/tx/createTxTransport.ts\";\nimport type { Transport, TxCallOptions } from \"../transport/types.ts\";\n\nexport type { PayloadOf, ResponseOf } from \"../types.ts\";\n\nexport function createChainNodeSDK(options: ChainNodeSDKOptions) {\n const queryTransport = createGrpcTransport({\n baseUrl: options.query.baseUrl,\n });\n let txTransport: Transport<TxCallOptions>;\n\n if (options.tx) {\n const { builtInTypes, ...txOptions } = options.tx;\n const defaultRegistryTypes = [\n createMessageType(TxRaw),\n ...(builtInTypes ?? []).map(createMessageType),\n ].reduce<Record<string, GeneratedType>>((acc, type) => {\n acc[type.typeUrl] = type;\n return acc;\n }, {});\n const getMessageType: StargateClientOptions[\"getMessageType\"] = (typeUrl) => nodeServiceLoader.getLoadedType(typeUrl) || cosmosServiceLoader.getLoadedType(typeUrl) || defaultRegistryTypes[typeUrl];\n txTransport = createTxTransport({\n getMessageType,\n client: createStargateClient({\n ...txOptions,\n getMessageType,\n }),\n });\n } else {\n txTransport = createNoopTransport({\n unaryErrorMessage: `Unable to sign transaction. \"tx\" option is not provided during chain SDK creation`,\n });\n }\n const nodeSDK = createNodeSDK(queryTransport, txTransport, {\n clientOptions: { typePatches: { ...cosmosPatches, ...nodePatches } },\n });\n const cosmosSDK = createCosmosSDK(queryTransport, txTransport, {\n clientOptions: { typePatches: cosmosPatches },\n });\n return { ...nodeSDK, ...cosmosSDK };\n}\n\nexport interface ChainNodeSDKOptions {\n query: {\n /**\n * Blockchain gRPC endpoint\n */\n baseUrl: string;\n };\n tx?: Omit<StargateClientOptions, \"getMessageType\" | \"builtInTypes\"> & {\n /**\n * Additional protobuf message types to register with the transaction transport\n */\n builtInTypes?: MessageDesc[];\n };\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,6BAAmF;AACnF,2BAA+E;AAC/E,qCAAyC;AACzC,mCAAuC;AACvC,gBAAsB;AACtB,iCAAkC;AAElC,iCAAoC;AACpC,iCAAoC;AAEpC,kCAAqC;AACrC,+BAAkC;AAK3B,SAAS,mBAAmB,SAA8B;AAC/D,QAAM,qBAAiB,gDAAoB;AAAA,IACzC,SAAS,QAAQ,MAAM;AAAA,EACzB,CAAC;AACD,MAAI;AAEJ,MAAI,QAAQ,IAAI;AACd,UAAM,EAAE,cAAc,GAAG,UAAU,IAAI,QAAQ;AAC/C,UAAM,uBAAuB;AAAA,UAC3B,8CAAkB,eAAK;AAAA,MACvB,IAAI,gBAAgB,CAAC,GAAG,IAAI,4CAAiB;AAAA,IAC/C,EAAE,OAAsC,CAAC,KAAK,SAAS;AACrD,UAAI,KAAK,OAAO,IAAI;AACpB,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AACL,UAAM,iBAA0D,CAAC,YAAY,qBAAAA,cAAkB,cAAc,OAAO,KAAK,uBAAAC,cAAoB,cAAc,OAAO,KAAK,qBAAqB,OAAO;AACnM,sBAAc,4CAAkB;AAAA,MAC9B;AAAA,MACA,YAAQ,kDAAqB;AAAA,QAC3B,GAAG;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,OAAO;AACL,sBAAc,gDAAoB;AAAA,MAChC,mBAAmB;AAAA,IACrB,CAAC;AAAA,EACH;AACA,QAAM,cAAU,qBAAAC,WAAc,gBAAgB,aAAa;AAAA,IACzD,eAAe,EAAE,aAAa,EAAE,GAAG,+BAAAC,SAAe,GAAG,6BAAAC,QAAY,EAAE;AAAA,EACrE,CAAC;AACD,QAAM,gBAAY,uBAAAC,WAAgB,gBAAgB,aAAa;AAAA,IAC7D,eAAe,EAAE,aAAa,+BAAAF,QAAc;AAAA,EAC9C,CAAC;AACD,SAAO,EAAE,GAAG,SAAS,GAAG,UAAU;AACpC;",
|
|
6
6
|
"names": ["nodeServiceLoader", "cosmosServiceLoader", "createNodeSDK", "cosmosPatches", "nodePatches", "createCosmosSDK"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/sdk/client/createClientFactory.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Transport } from \"../transport/types.ts\";\nimport type { Client, ServiceClientOptions } from \"./createServiceClient.ts\";\nimport { createServiceClient } from \"./createServiceClient.ts\";\nimport type { ServiceDesc } from \"./types.ts\";\n\nexport function createClientFactory<TCallOptions>(transport: Transport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iCAAoC;AAG7B,SAAS,oBAAkC,
|
|
4
|
+
"sourcesContent": ["import type { Transport } from \"../transport/types.ts\";\nimport type { Client, ServiceClientOptions } from \"./createServiceClient.ts\";\nimport { createServiceClient } from \"./createServiceClient.ts\";\nimport type { ServiceDesc } from \"./types.ts\";\n\nexport function createClientFactory<TCallOptions>(transport: Transport<TCallOptions>, options?: ServiceClientOptions): ClientFactory<TCallOptions> {\n const services: Record<string, Client<ServiceDesc, TCallOptions>> = Object.create(null);\n\n return function getClient<T extends ServiceDesc>(service: T): Client<T, TCallOptions> {\n if (!services[service.typeName]) {\n services[service.typeName] = createServiceClient<T, TCallOptions>(service, transport, options);\n }\n return services[service.typeName] as Client<T, TCallOptions>;\n };\n}\n\nexport type ClientFactory<TCallOptions> = <T extends ServiceDesc>(service: T) => Client<T, TCallOptions>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iCAAoC;AAG7B,SAAS,oBAAkC,WAAoC,SAA6D;AACjJ,QAAM,WAA8D,uBAAO,OAAO,IAAI;AAEtF,SAAO,SAAS,UAAiC,SAAqC;AACpF,QAAI,CAAC,SAAS,QAAQ,QAAQ,GAAG;AAC/B,eAAS,QAAQ,QAAQ,QAAI,gDAAqC,SAAS,WAAW,OAAO;AAAA,IAC/F;AACA,WAAO,SAAS,QAAQ,QAAQ;AAAA,EAClC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/sdk/client/createServiceClient.ts"],
|
|
4
|
-
"sourcesContent": ["import type { CallOptions, Transport } from \"../transport/types.ts\";\nimport type { TypePatches } from \"./applyPatches.ts\";\nimport { applyPatches } from \"./applyPatches.ts\";\nimport { createAsyncIterable, handleStreamResponse, mapStream } from \"./stream.ts\";\nimport type { MessageDesc, MessageInitShape, MessageShape, MethodDesc, ServiceDesc } from \"./types.ts\";\n\nexport type Client<Desc extends ServiceDesc, TCallOptions> = {\n [P in keyof Desc[\"methods\"]]:\n Desc[\"methods\"][P] extends MethodDesc<\"server_streaming\"> ? (input: MessageInitShape<Desc[\"methods\"][P][\"input\"]>, options?: TCallOptions) => AsyncIterable<MessageShape<Desc[\"methods\"][P][\"output\"]>>\n : Desc[\"methods\"][P] extends MethodDesc<\"client_streaming\"> ? (input: AsyncIterable<MessageInitShape<Desc[\"methods\"][P][\"input\"]>>, options?: TCallOptions) => Promise<MessageShape<Desc[\"methods\"][P][\"output\"]>>\n : Desc[\"methods\"][P] extends MethodDesc<\"bidi_streaming\"> ? (input: AsyncIterable<MessageInitShape<Desc[\"methods\"][P][\"input\"]>>, options?: TCallOptions) => AsyncIterable<MessageShape<Desc[\"methods\"][P][\"output\"]>>\n : Desc[\"methods\"][P] extends MethodDesc<\"unary\"> | Omit<MethodDesc<\"unary\">, \"kind\"> ? (input: MessageInitShape<Desc[\"methods\"][P][\"input\"]>, options?: TCallOptions) => Promise<MessageShape<Desc[\"methods\"][P][\"output\"]>>\n : never;\n};\n\nconst defaultEncoder: MethodOptions = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n encode: (type: MessageDesc<unknown>, value: unknown) => type.fromPartial(value as any),\n decode: (_: MessageDesc<unknown>, value: unknown) => value,\n};\n\nexport function createServiceClient<TSchema extends ServiceDesc, TCallOptions>(\n service: TSchema,\n transport: Transport
|
|
4
|
+
"sourcesContent": ["import type { CallOptions, Transport } from \"../transport/types.ts\";\nimport type { TypePatches } from \"./applyPatches.ts\";\nimport { applyPatches } from \"./applyPatches.ts\";\nimport { createAsyncIterable, handleStreamResponse, mapStream } from \"./stream.ts\";\nimport type { MessageDesc, MessageInitShape, MessageShape, MethodDesc, ServiceDesc } from \"./types.ts\";\n\nexport type Client<Desc extends ServiceDesc, TCallOptions> = {\n [P in keyof Desc[\"methods\"]]:\n Desc[\"methods\"][P] extends MethodDesc<\"server_streaming\"> ? (input: MessageInitShape<Desc[\"methods\"][P][\"input\"]>, options?: TCallOptions) => AsyncIterable<MessageShape<Desc[\"methods\"][P][\"output\"]>>\n : Desc[\"methods\"][P] extends MethodDesc<\"client_streaming\"> ? (input: AsyncIterable<MessageInitShape<Desc[\"methods\"][P][\"input\"]>>, options?: TCallOptions) => Promise<MessageShape<Desc[\"methods\"][P][\"output\"]>>\n : Desc[\"methods\"][P] extends MethodDesc<\"bidi_streaming\"> ? (input: AsyncIterable<MessageInitShape<Desc[\"methods\"][P][\"input\"]>>, options?: TCallOptions) => AsyncIterable<MessageShape<Desc[\"methods\"][P][\"output\"]>>\n : Desc[\"methods\"][P] extends MethodDesc<\"unary\"> | Omit<MethodDesc<\"unary\">, \"kind\"> ? (input: MessageInitShape<Desc[\"methods\"][P][\"input\"]>, options?: TCallOptions) => Promise<MessageShape<Desc[\"methods\"][P][\"output\"]>>\n : never;\n};\n\nconst defaultEncoder: MethodOptions = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n encode: (type: MessageDesc<unknown>, value: unknown) => type.fromPartial(value as any),\n decode: (_: MessageDesc<unknown>, value: unknown) => value,\n};\n\nexport function createServiceClient<TSchema extends ServiceDesc, TCallOptions>(\n service: TSchema,\n transport: Transport<TCallOptions>,\n options?: ServiceClientOptions,\n): Client<TSchema, TCallOptions> {\n const methodOptions: MethodOptions = options?.typePatches\n ? { encode: createEncodeWithPatches(options.typePatches), decode: createDecodeWithPatches(options.typePatches) }\n : defaultEncoder;\n const client: Record<string, ReturnType<typeof createMethod>> = {};\n const methodNames = Object.keys(service.methods);\n for (let i = 0; i < methodNames.length; i++) {\n const methodDesc = service.methods[methodNames[i]];\n client[methodNames[i]] = createMethod(methodDesc as MethodDesc, transport, methodOptions);\n }\n\n return client as Client<TSchema, TCallOptions>;\n}\n\nexport interface ServiceClientOptions {\n typePatches?: TypePatches;\n}\n\nfunction createMethod(methodDesc: MethodDesc, transport: Transport, options: MethodOptions) {\n switch (methodDesc.kind) {\n case \"server_streaming\":\n return createServerStreamingFn(transport, methodDesc as MethodDesc<\"server_streaming\", MessageDesc, MessageDesc>, options);\n case \"client_streaming\":\n return createClientStreamingFn(transport, methodDesc as MethodDesc<\"client_streaming\", MessageDesc, MessageDesc>, options);\n case \"bidi_streaming\":\n return createBiDiStreamingFn(transport, methodDesc as MethodDesc<\"bidi_streaming\", MessageDesc, MessageDesc>, options);\n default:\n return createUnaryFn(transport, methodDesc as MethodDesc<\"unary\", MessageDesc, MessageDesc>, options);\n }\n}\n\ninterface MethodOptions {\n encode(schema: MessageDesc<unknown>, value: unknown): unknown;\n decode(schema: MessageDesc<unknown>, value: unknown): unknown;\n}\n\ntype UnaryFn<I extends MessageDesc<unknown>, O extends MessageDesc<unknown>> = (\n input: MessageInitShape<I>,\n options?: CallOptions,\n) => Promise<MessageShape<O>>;\n\nfunction createUnaryFn<I extends MessageDesc<unknown>, O extends MessageDesc<unknown>>(\n transport: Transport,\n method: MethodDesc<\"unary\", I, O>,\n methodOptions: MethodOptions,\n): UnaryFn<I, O> {\n return async (input, options) => {\n const response = await transport.unary(\n method,\n methodOptions.encode(method.input, input) as MessageInitShape<I>,\n options,\n );\n options?.onHeader?.(response.header);\n options?.onTrailer?.(response.trailer);\n\n return methodOptions.decode(method.output, response.message) as MessageShape<O>;\n };\n}\n\ntype ServerStreamingFn<I extends MessageDesc, O extends MessageDesc> = (\n input: MessageInitShape<I>,\n options?: CallOptions,\n) => AsyncIterable<MessageShape<O>>;\n\nfunction createServerStreamingFn<\n I extends MessageDesc,\n O extends MessageDesc,\n>(\n transport: Transport,\n method: MethodDesc<\"server_streaming\", I, O>,\n methodOptions: MethodOptions,\n): ServerStreamingFn<I, O> {\n return (input, options) => {\n return handleStreamResponse(\n method,\n transport.stream(\n method,\n createAsyncIterable([methodOptions.encode(method.input, input) as MessageInitShape<I>]),\n options,\n ),\n options,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n methodOptions.decode as any,\n );\n };\n}\n\ntype ClientStreamingFn<I extends MessageDesc, O extends MessageDesc> = (\n input: AsyncIterable<MessageInitShape<I>>,\n options?: CallOptions,\n) => Promise<MessageShape<O>>;\n\nfunction createClientStreamingFn<\n I extends MessageDesc,\n O extends MessageDesc,\n>(\n transport: Transport,\n method: MethodDesc<\"client_streaming\", I, O>,\n methodOptions: MethodOptions,\n): ClientStreamingFn<I, O> {\n return async (input, options) => {\n const response = await transport.stream(\n method,\n mapStream(input, (json) => methodOptions.encode(method.input, json) as MessageInitShape<I>),\n options,\n );\n options?.onHeader?.(response.header);\n let singleMessage: MessageShape<O> | undefined;\n let count = 0;\n for await (const message of response.message) {\n singleMessage = message;\n count++;\n }\n if (!singleMessage) {\n throw new Error(\"akash sdk protocol error: missing response message\");\n }\n if (count > 1) {\n throw new Error(\"akash sdk protocol error: received extra messages for client streaming method\");\n }\n options?.onTrailer?.(response.trailer);\n return methodOptions.decode(method.output, singleMessage) as MessageShape<O>;\n };\n}\n\ntype BiDiStreamingFn<I extends MessageDesc, O extends MessageDesc> = (\n input: AsyncIterable<MessageInitShape<I>>,\n options?: CallOptions,\n) => AsyncIterable<MessageShape<O>>;\n\nfunction createBiDiStreamingFn<\n I extends MessageDesc,\n O extends MessageDesc,\n>(\n transport: Transport,\n method: MethodDesc<\"bidi_streaming\", I, O>,\n methodOptions: MethodOptions,\n): BiDiStreamingFn<I, O> {\n return (input, options) => {\n return handleStreamResponse(\n method,\n transport.stream(\n method,\n mapStream(input, (json) => methodOptions.encode(method.input, json) as MessageInitShape<I>),\n options,\n ),\n options,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n methodOptions.decode as any,\n );\n };\n}\n\nconst PATCHED_FROM_JSON_CACHE = new Map<TypePatches, MethodOptions[\"encode\"]>();\nfunction createEncodeWithPatches(patches: TypePatches): MethodOptions[\"encode\"] {\n if (PATCHED_FROM_JSON_CACHE.has(patches)) return PATCHED_FROM_JSON_CACHE.get(patches)!;\n\n const encode: MethodOptions[\"encode\"] = (messageDesc, value) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return applyPatches(\"encode\", messageDesc, messageDesc.fromPartial(value as any), patches);\n };\n PATCHED_FROM_JSON_CACHE.set(patches, encode);\n return encode;\n}\n\nconst PATCHED_TO_JSON_CACHE = new Map<TypePatches, MethodOptions[\"decode\"]>();\nfunction createDecodeWithPatches(patches: TypePatches): MethodOptions[\"decode\"] {\n if (PATCHED_TO_JSON_CACHE.has(patches)) return PATCHED_TO_JSON_CACHE.get(patches)!;\n\n const decode: MethodOptions[\"decode\"] = (schema, message) => {\n return applyPatches(\"decode\", schema, message, patches);\n };\n PATCHED_TO_JSON_CACHE.set(patches, decode);\n return decode;\n}\n"],
|
|
5
5
|
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -81,9 +81,10 @@ const schema = {
|
|
|
81
81
|
type: "string",
|
|
82
82
|
enum: [
|
|
83
83
|
"full",
|
|
84
|
-
"granular"
|
|
84
|
+
"granular",
|
|
85
|
+
"scoped"
|
|
85
86
|
],
|
|
86
|
-
description: "Access level for the lease: 'full' for unrestricted access to all actions, 'granular' for provider-specific permissions."
|
|
87
|
+
description: "Access level for the lease: 'full' for unrestricted access to all actions, 'scoped' for specific actions across all provider leases,'granular' for provider-specific permissions."
|
|
87
88
|
},
|
|
88
89
|
scope: {
|
|
89
90
|
type: "array",
|
|
@@ -103,7 +104,7 @@ const schema = {
|
|
|
103
104
|
"ip-migrate"
|
|
104
105
|
]
|
|
105
106
|
},
|
|
106
|
-
description: "Global list of permitted actions across all owned leases (no duplicates).
|
|
107
|
+
description: "Global list of permitted actions across all owned leases (no duplicates). Required when access is 'scoped'."
|
|
107
108
|
},
|
|
108
109
|
permissions: {
|
|
109
110
|
type: "array",
|
|
@@ -292,6 +293,27 @@ const schema = {
|
|
|
292
293
|
},
|
|
293
294
|
then: {
|
|
294
295
|
properties: {
|
|
296
|
+
permissions: false,
|
|
297
|
+
scope: false
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
if: {
|
|
303
|
+
properties: {
|
|
304
|
+
access: {
|
|
305
|
+
const: "scoped"
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
then: {
|
|
310
|
+
required: [
|
|
311
|
+
"scope"
|
|
312
|
+
],
|
|
313
|
+
properties: {
|
|
314
|
+
scope: {
|
|
315
|
+
minItems: 1
|
|
316
|
+
},
|
|
295
317
|
permissions: false
|
|
296
318
|
}
|
|
297
319
|
}
|
|
@@ -569,7 +591,7 @@ const validate = function() {
|
|
|
569
591
|
validate2.errors.push({ keywordLocation: "#/properties/leases/properties/access/type", instanceLocation: "#/leases/access" });
|
|
570
592
|
errorCount++;
|
|
571
593
|
} else {
|
|
572
|
-
if (!(data.leases.access === "full" || data.leases.access === "granular")) {
|
|
594
|
+
if (!(data.leases.access === "full" || data.leases.access === "granular" || data.leases.access === "scoped")) {
|
|
573
595
|
if (validate2.errors === null) validate2.errors = [];
|
|
574
596
|
validate2.errors.push({ keywordLocation: "#/properties/leases/properties/access/enum", instanceLocation: "#/leases/access" });
|
|
575
597
|
errorCount++;
|
|
@@ -974,8 +996,41 @@ const validate = function() {
|
|
|
974
996
|
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/0/then/properties/permissions", instanceLocation: "#/leases/permissions" });
|
|
975
997
|
errorCount++;
|
|
976
998
|
}
|
|
999
|
+
if ("scope" in data.leases && hasOwn(data.leases, "scope")) {
|
|
1000
|
+
if (validate2.errors === null) validate2.errors = [];
|
|
1001
|
+
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/0/then/properties/scope", instanceLocation: "#/leases/scope" });
|
|
1002
|
+
errorCount++;
|
|
1003
|
+
}
|
|
977
1004
|
}
|
|
978
1005
|
const sub4 = (() => {
|
|
1006
|
+
let errorCount2 = 0;
|
|
1007
|
+
if ("access" in data.leases && hasOwn(data.leases, "access")) {
|
|
1008
|
+
if (!(data.leases.access === "scoped")) errorCount2++;
|
|
1009
|
+
}
|
|
1010
|
+
return errorCount2 === 0;
|
|
1011
|
+
})();
|
|
1012
|
+
if (sub4) {
|
|
1013
|
+
if (!("scope" in data.leases && hasOwn(data.leases, "scope"))) {
|
|
1014
|
+
if (validate2.errors === null) validate2.errors = [];
|
|
1015
|
+
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/1/then/required", instanceLocation: "#/leases/scope" });
|
|
1016
|
+
errorCount++;
|
|
1017
|
+
}
|
|
1018
|
+
if ("scope" in data.leases && hasOwn(data.leases, "scope")) {
|
|
1019
|
+
if (Array.isArray(data.leases.scope)) {
|
|
1020
|
+
if (data.leases.scope.length < 1) {
|
|
1021
|
+
if (validate2.errors === null) validate2.errors = [];
|
|
1022
|
+
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/1/then/properties/scope/minItems", instanceLocation: "#/leases/scope" });
|
|
1023
|
+
errorCount++;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
if ("permissions" in data.leases && hasOwn(data.leases, "permissions")) {
|
|
1028
|
+
if (validate2.errors === null) validate2.errors = [];
|
|
1029
|
+
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/1/then/properties/permissions", instanceLocation: "#/leases/permissions" });
|
|
1030
|
+
errorCount++;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
const sub5 = (() => {
|
|
979
1034
|
let errorCount2 = 0;
|
|
980
1035
|
if (!("access" in data.leases && hasOwn(data.leases, "access"))) errorCount2++;
|
|
981
1036
|
if ("access" in data.leases && hasOwn(data.leases, "access")) {
|
|
@@ -983,15 +1038,15 @@ const validate = function() {
|
|
|
983
1038
|
}
|
|
984
1039
|
return errorCount2 === 0;
|
|
985
1040
|
})();
|
|
986
|
-
if (
|
|
1041
|
+
if (sub5) {
|
|
987
1042
|
if (!("permissions" in data.leases && hasOwn(data.leases, "permissions"))) {
|
|
988
1043
|
if (validate2.errors === null) validate2.errors = [];
|
|
989
|
-
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/
|
|
1044
|
+
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/2/then/required", instanceLocation: "#/leases/permissions" });
|
|
990
1045
|
errorCount++;
|
|
991
1046
|
}
|
|
992
1047
|
if ("scope" in data.leases && hasOwn(data.leases, "scope")) {
|
|
993
1048
|
if (validate2.errors === null) validate2.errors = [];
|
|
994
|
-
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/
|
|
1049
|
+
validate2.errors.push({ keywordLocation: "#/properties/leases/allOf/2/then/properties/scope", instanceLocation: "#/leases/scope" });
|
|
995
1050
|
errorCount++;
|
|
996
1051
|
}
|
|
997
1052
|
}
|
|
@@ -1004,7 +1059,7 @@ const validate = function() {
|
|
|
1004
1059
|
errorCount++;
|
|
1005
1060
|
}
|
|
1006
1061
|
}
|
|
1007
|
-
const
|
|
1062
|
+
const sub6 = (() => {
|
|
1008
1063
|
let errorCount2 = 0;
|
|
1009
1064
|
if (!("leases" in data && hasOwn(data, "leases"))) errorCount2++;
|
|
1010
1065
|
if ("leases" in data && hasOwn(data, "leases")) {
|
|
@@ -1017,7 +1072,7 @@ const validate = function() {
|
|
|
1017
1072
|
}
|
|
1018
1073
|
return errorCount2 === 0;
|
|
1019
1074
|
})();
|
|
1020
|
-
if (
|
|
1075
|
+
if (sub6) {
|
|
1021
1076
|
if ("leases" in data && hasOwn(data, "leases")) {
|
|
1022
1077
|
if (typeof data.leases === "object" && data.leases && !Array.isArray(data.leases)) {
|
|
1023
1078
|
if (!("permissions" in data.leases && hasOwn(data.leases, "permissions"))) {
|
|
@@ -1033,7 +1088,7 @@ const validate = function() {
|
|
|
1033
1088
|
}
|
|
1034
1089
|
}
|
|
1035
1090
|
}
|
|
1036
|
-
const
|
|
1091
|
+
const sub7 = (() => {
|
|
1037
1092
|
let errorCount2 = 0;
|
|
1038
1093
|
if (!("leases" in data && hasOwn(data, "leases"))) errorCount2++;
|
|
1039
1094
|
if ("leases" in data && hasOwn(data, "leases")) {
|
|
@@ -1050,7 +1105,7 @@ const validate = function() {
|
|
|
1050
1105
|
}
|
|
1051
1106
|
return errorCount2 === 0;
|
|
1052
1107
|
})();
|
|
1053
|
-
if (
|
|
1108
|
+
if (sub7) {
|
|
1054
1109
|
if ("leases" in data && hasOwn(data, "leases")) {
|
|
1055
1110
|
if (typeof data.leases === "object" && data.leases && !Array.isArray(data.leases)) {
|
|
1056
1111
|
if (!("access" in data.leases && hasOwn(data.leases, "access"))) {
|