tapass 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +97 -2
- package/dist/grpc/emit_subscription_error.d.ts +21 -0
- package/dist/grpc/emit_subscription_error.d.ts.map +1 -0
- package/dist/grpc/emit_subscription_error.js +26 -0
- package/dist/grpc/emit_subscription_error.js.map +1 -0
- package/dist/grpc/grpc_services.d.ts +46 -0
- package/dist/grpc/grpc_services.d.ts.map +1 -0
- package/dist/grpc/grpc_services.js +45 -0
- package/dist/grpc/grpc_services.js.map +1 -0
- package/dist/grpc/handle_remove_listener.d.ts +18 -0
- package/dist/grpc/handle_remove_listener.d.ts.map +1 -0
- package/dist/grpc/handle_remove_listener.js +22 -0
- package/dist/grpc/handle_remove_listener.js.map +1 -0
- package/dist/grpc/index.d.ts +32 -0
- package/dist/grpc/index.d.ts.map +1 -0
- package/dist/grpc/index.js +6 -0
- package/dist/grpc/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/tapd_grpc/api_for_proto.d.ts +28 -0
- package/dist/tapd_grpc/api_for_proto.d.ts.map +1 -0
- package/dist/tapd_grpc/api_for_proto.js +24 -0
- package/dist/tapd_grpc/api_for_proto.js.map +1 -0
- package/dist/tapd_grpc/authenticated_tapd_grpc.d.ts +35 -0
- package/dist/tapd_grpc/authenticated_tapd_grpc.d.ts.map +1 -0
- package/dist/tapd_grpc/authenticated_tapd_grpc.js +76 -0
- package/dist/tapd_grpc/authenticated_tapd_grpc.js.map +1 -0
- package/dist/tapd_grpc/decode_serialized.d.ts +18 -0
- package/dist/tapd_grpc/decode_serialized.d.ts.map +1 -0
- package/dist/tapd_grpc/decode_serialized.js +23 -0
- package/dist/tapd_grpc/decode_serialized.js.map +1 -0
- package/dist/tapd_grpc/grpc_credentials.d.ts +24 -0
- package/dist/tapd_grpc/grpc_credentials.d.ts.map +1 -0
- package/dist/tapd_grpc/grpc_credentials.js +39 -0
- package/dist/tapd_grpc/grpc_credentials.js.map +1 -0
- package/dist/tapd_grpc/grpc_options.d.ts +10 -0
- package/dist/tapd_grpc/grpc_options.d.ts.map +1 -0
- package/dist/tapd_grpc/grpc_options.js +9 -0
- package/dist/tapd_grpc/grpc_options.js.map +1 -0
- package/dist/tapd_grpc/grpc_ssl.d.ts +19 -0
- package/dist/tapd_grpc/grpc_ssl.d.ts.map +1 -0
- package/dist/tapd_grpc/grpc_ssl.js +18 -0
- package/dist/tapd_grpc/grpc_ssl.js.map +1 -0
- package/dist/tapd_grpc/index.d.ts +6 -0
- package/dist/tapd_grpc/index.d.ts.map +1 -0
- package/dist/tapd_grpc/index.js +2 -0
- package/dist/tapd_grpc/index.js.map +1 -0
- package/dist/tapd_grpc/types.d.ts +35 -0
- package/dist/tapd_grpc/types.d.ts.map +1 -0
- package/dist/tapd_grpc/types.js +2 -0
- package/dist/tapd_grpc/types.js.map +1 -0
- package/dist/tapd_methods/address/create_asset_address.d.ts +76 -0
- package/dist/tapd_methods/address/create_asset_address.d.ts.map +1 -0
- package/dist/tapd_methods/address/create_asset_address.js +159 -0
- package/dist/tapd_methods/address/create_asset_address.js.map +1 -0
- package/dist/tapd_methods/address/index.d.ts +4 -0
- package/dist/tapd_methods/address/index.d.ts.map +1 -0
- package/dist/tapd_methods/address/index.js +2 -0
- package/dist/tapd_methods/address/index.js.map +1 -0
- package/dist/tapd_methods/index.d.ts +2 -0
- package/dist/tapd_methods/index.d.ts.map +1 -0
- package/dist/tapd_methods/index.js +2 -0
- package/dist/tapd_methods/index.js.map +1 -0
- package/dist/tapd_requests/index.d.ts +4 -0
- package/dist/tapd_requests/index.d.ts.map +1 -0
- package/dist/tapd_requests/index.js +4 -0
- package/dist/tapd_requests/index.js.map +1 -0
- package/dist/tapd_requests/is_connection_failure.d.ts +23 -0
- package/dist/tapd_requests/is_connection_failure.d.ts.map +1 -0
- package/dist/tapd_requests/is_connection_failure.js +40 -0
- package/dist/tapd_requests/is_connection_failure.js.map +1 -0
- package/dist/tapd_requests/is_permission_denied.d.ts +19 -0
- package/dist/tapd_requests/is_permission_denied.d.ts.map +1 -0
- package/dist/tapd_requests/is_permission_denied.js +16 -0
- package/dist/tapd_requests/is_permission_denied.js.map +1 -0
- package/dist/tapd_requests/is_tapd.d.ts +19 -0
- package/dist/tapd_requests/is_tapd.d.ts.map +1 -0
- package/dist/tapd_requests/is_tapd.js +16 -0
- package/dist/tapd_requests/is_tapd.js.map +1 -0
- package/dist/typescript/index.d.ts +16 -0
- package/dist/typescript/index.d.ts.map +1 -0
- package/dist/typescript/index.js +2 -0
- package/dist/typescript/index.js.map +1 -0
- package/package.json +71 -3
- package/protos/VERSIONS +2 -0
- package/protos/lnrpc/lightning.proto +5380 -0
- package/protos/lnrpc/routerrpc/router.proto +1115 -0
- package/protos/taprpc/assetwalletrpc/assetwallet.proto +631 -0
- package/protos/taprpc/authmailboxrpc/mailbox.proto +281 -0
- package/protos/taprpc/mintrpc/mint.proto +452 -0
- package/protos/taprpc/portfoliopilotrpc/portfolio_pilot.proto +410 -0
- package/protos/taprpc/priceoraclerpc/price_oracle.proto +262 -0
- package/protos/taprpc/rfqrpc/rfq.proto +614 -0
- package/protos/taprpc/tapchannelrpc/tapchannel.proto +490 -0
- package/protos/taprpc/tapcommon.proto +47 -0
- package/protos/taprpc/tapdevrpc/tapdev.proto +120 -0
- package/protos/taprpc/taprootassets.proto +2117 -0
- package/protos/taprpc/universerpc/universe.proto +1101 -0
- package/src/grpc/emit_subscription_error.ts +39 -0
- package/src/grpc/grpc_services.ts +45 -0
- package/src/grpc/handle_remove_listener.ts +35 -0
- package/src/grpc/index.ts +18 -0
- package/src/index.ts +3 -0
- package/src/tapd_grpc/api_for_proto.ts +42 -0
- package/src/tapd_grpc/authenticated_tapd_grpc.ts +88 -0
- package/src/tapd_grpc/decode_serialized.ts +25 -0
- package/src/tapd_grpc/grpc_credentials.ts +48 -0
- package/src/tapd_grpc/grpc_options.ts +10 -0
- package/src/tapd_grpc/grpc_ssl.ts +20 -0
- package/src/tapd_grpc/index.ts +5 -0
- package/src/tapd_grpc/types.ts +35 -0
- package/src/tapd_methods/address/create_asset_address.ts +244 -0
- package/src/tapd_methods/address/index.ts +3 -0
- package/src/tapd_methods/index.ts +1 -0
- package/src/tapd_requests/index.ts +3 -0
- package/src/tapd_requests/is_connection_failure.ts +48 -0
- package/src/tapd_requests/is_permission_denied.ts +18 -0
- package/src/tapd_requests/is_tapd.ts +22 -0
- package/src/typescript/asyncjs_util.d.ts +14 -0
- package/src/typescript/index.ts +22 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import grpc from '@grpc/grpc-js';
|
|
2
|
+
export default _default;
|
|
3
|
+
/** Credentials for gRPC
|
|
4
|
+
|
|
5
|
+
{
|
|
6
|
+
[cert]: <Base64 or Hex Serialized tapd TLS Cert String>
|
|
7
|
+
[macaroon]: <Base64 or Hex Serialized Macaroon String>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@throws
|
|
11
|
+
<Error>
|
|
12
|
+
|
|
13
|
+
@returns
|
|
14
|
+
{
|
|
15
|
+
credentials: <gRPC Credentials Object>
|
|
16
|
+
}
|
|
17
|
+
*/
|
|
18
|
+
declare function _default({ cert, macaroon }: {
|
|
19
|
+
cert?: string;
|
|
20
|
+
macaroon?: string;
|
|
21
|
+
}): {
|
|
22
|
+
credentials: grpc.ChannelCredentials;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=grpc_credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc_credentials.d.ts","sourceRoot":"","sources":["../../src/tapd_grpc/grpc_credentials.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,eAAe,CAAC;;AAiBjC;;;;;;;;;;;;;;EAcE;0BACc,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import grpc from '@grpc/grpc-js';
|
|
2
|
+
import decodeSerialized from './decode_serialized.js';
|
|
3
|
+
import grpcSsl from './grpc_ssl.js';
|
|
4
|
+
const { combineChannelCredentials } = grpc.credentials;
|
|
5
|
+
const { createFromMetadataGenerator } = grpc.credentials;
|
|
6
|
+
const { Metadata } = grpc;
|
|
7
|
+
const generate = (macaroon) => {
|
|
8
|
+
const metadata = new Metadata();
|
|
9
|
+
metadata.add('macaroon', macaroon.toString('hex'));
|
|
10
|
+
return metadata;
|
|
11
|
+
};
|
|
12
|
+
/** Credentials for gRPC
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
[cert]: <Base64 or Hex Serialized tapd TLS Cert String>
|
|
16
|
+
[macaroon]: <Base64 or Hex Serialized Macaroon String>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@throws
|
|
20
|
+
<Error>
|
|
21
|
+
|
|
22
|
+
@returns
|
|
23
|
+
{
|
|
24
|
+
credentials: <gRPC Credentials Object>
|
|
25
|
+
}
|
|
26
|
+
*/
|
|
27
|
+
export default ({ cert, macaroon }) => {
|
|
28
|
+
if (!macaroon) {
|
|
29
|
+
return { credentials: grpcSsl({ cert }).ssl };
|
|
30
|
+
}
|
|
31
|
+
const mac = decodeSerialized({ serialized: macaroon }).decoded;
|
|
32
|
+
if (!mac?.length) {
|
|
33
|
+
throw new Error('ExpectedBase64OrHexEncodedMacaroonToCreateCredentials');
|
|
34
|
+
}
|
|
35
|
+
const creds = createFromMetadataGenerator((_, c) => c(null, generate(mac)));
|
|
36
|
+
const { ssl } = grpcSsl({ cert });
|
|
37
|
+
return { credentials: combineChannelCredentials(ssl, creds) };
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=grpc_credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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O,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC;IAE9B,OAAO,EAAC,WAAW,EAAE,yBAAyB,CAAC,GAAG,EAAE,KAAK,CAAC,EAAC,CAAC;AAC9D,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc_options.d.ts","sourceRoot":"","sources":["../../src/tapd_grpc/grpc_options.ts"],"names":[],"mappings":"AAEA,2BAA2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc_options.js","sourceRoot":"","sources":["../../src/tapd_grpc/grpc_options.ts"],"names":[],"mappings":"AAEA,2BAA2B;AAC3B,eAAe;IACb,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,IAAI;CACK,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import grpc from '@grpc/grpc-js';
|
|
2
|
+
export default _default;
|
|
3
|
+
/** Get SSL for gRPC
|
|
4
|
+
|
|
5
|
+
{
|
|
6
|
+
[cert]: <Cert Hex or Base64 String>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@returns
|
|
10
|
+
{
|
|
11
|
+
ssl: <SSL gRPC Object>
|
|
12
|
+
}
|
|
13
|
+
*/
|
|
14
|
+
declare function _default({ cert }: {
|
|
15
|
+
cert?: string;
|
|
16
|
+
}): {
|
|
17
|
+
ssl: grpc.ChannelCredentials;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=grpc_ssl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc_ssl.d.ts","sourceRoot":"","sources":["../../src/tapd_grpc/grpc_ssl.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,eAAe,CAAC;;AAMjC;;;;;;;;;;EAUE;0BACc,EAAC,IAAI,EAAC,EAAE;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAC;IAC7B,GAAG"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import grpc from '@grpc/grpc-js';
|
|
2
|
+
import decodeSerialized from './decode_serialized.js';
|
|
3
|
+
const { createSsl } = grpc.credentials;
|
|
4
|
+
/** Get SSL for gRPC
|
|
5
|
+
|
|
6
|
+
{
|
|
7
|
+
[cert]: <Cert Hex or Base64 String>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@returns
|
|
11
|
+
{
|
|
12
|
+
ssl: <SSL gRPC Object>
|
|
13
|
+
}
|
|
14
|
+
*/
|
|
15
|
+
export default ({ cert }) => {
|
|
16
|
+
return { ssl: createSsl(decodeSerialized({ serialized: cert }).decoded) };
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=grpc_ssl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc_ssl.js","sourceRoot":"","sources":["../../src/tapd_grpc/grpc_ssl.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,eAAe,CAAC;AAEjC,OAAO,gBAAgB,MAAM,wBAAwB,CAAC;AAEtD,MAAM,EAAC,SAAS,EAAC,GAAG,IAAI,CAAC,WAAW,CAAC;AAErC;;;;;;;;;;EAUE;AACF,eAAe,CAAC,EAAC,IAAI,EAAkB,EAAE,EAAE;IACzC,OAAO,EAAC,GAAG,EAAE,SAAS,CAAC,gBAAgB,CAAC,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC,OAAO,CAAC,EAAC,CAAC;AACxE,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as authenticatedTapdGrpc } from './authenticated_tapd_grpc.js';
|
|
2
|
+
export type { AuthenticatedTapd } from './types.js';
|
|
3
|
+
export type { TapdAuthentication } from './types.js';
|
|
4
|
+
export type { TapdService } from './types.js';
|
|
5
|
+
export type { TapdServiceType } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tapd_grpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,qBAAqB,EAAC,MAAM,8BAA8B,CAAC;AAC9E,YAAY,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAClD,YAAY,EAAC,kBAAkB,EAAC,MAAM,YAAY,CAAC;AACnD,YAAY,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAC5C,YAAY,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tapd_grpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,qBAAqB,EAAC,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** gRPC methods of one tapd service */
|
|
2
|
+
export type TapdService = {
|
|
3
|
+
[method: string]: (...args: any[]) => any;
|
|
4
|
+
};
|
|
5
|
+
/** Authenticated tapd gRPC API Object */
|
|
6
|
+
export type AuthenticatedTapd = {
|
|
7
|
+
/** AssetWallet Methods */
|
|
8
|
+
assetwallet: TapdService;
|
|
9
|
+
/** TaprootAssets Methods */
|
|
10
|
+
default: TapdService;
|
|
11
|
+
/** Mailbox Methods */
|
|
12
|
+
mailbox: TapdService;
|
|
13
|
+
/** Mint Methods */
|
|
14
|
+
mint: TapdService;
|
|
15
|
+
/** Rfq Methods */
|
|
16
|
+
rfq: TapdService;
|
|
17
|
+
/** TaprootAssetChannels Methods */
|
|
18
|
+
tapchannel: TapdService;
|
|
19
|
+
/** TapDev Methods */
|
|
20
|
+
tapdev: TapdService;
|
|
21
|
+
/** Universe Methods */
|
|
22
|
+
universe: TapdService;
|
|
23
|
+
};
|
|
24
|
+
export type TapdServiceType = keyof AuthenticatedTapd;
|
|
25
|
+
export type TapdAuthentication = {
|
|
26
|
+
/** Base64 or Hex Serialized tapd TLS Cert String */
|
|
27
|
+
cert?: string;
|
|
28
|
+
/** Base64 or Hex Serialized Macaroon String */
|
|
29
|
+
macaroon?: string;
|
|
30
|
+
/** Path to Protos Directory With taprpc and lnrpc Directories String */
|
|
31
|
+
path?: string;
|
|
32
|
+
/** Host:Port Network Address String */
|
|
33
|
+
socket?: string;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tapd_grpc/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,MAAM,MAAM,WAAW,GAAG;IAAC,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;CAAC,CAAC;AAEtE,yCAAyC;AACzC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,0BAA0B;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB,4BAA4B;IAC5B,OAAO,EAAE,WAAW,CAAC;IACrB,sBAAsB;IACtB,OAAO,EAAE,WAAW,CAAC;IACrB,mBAAmB;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,kBAAkB;IAClB,GAAG,EAAE,WAAW,CAAC;IACjB,mCAAmC;IACnC,UAAU,EAAE,WAAW,CAAC;IACxB,qBAAqB;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,uBAAuB;IACvB,QAAQ,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tapd_grpc/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { AuthenticatedTapdArgs } from '../../typescript/index.js';
|
|
2
|
+
import type { TapdMethod } from '../../typescript/index.js';
|
|
3
|
+
export type CreateAssetAddressArgs = AuthenticatedTapdArgs<{
|
|
4
|
+
/** Asset Units To Receive Numeric String */
|
|
5
|
+
amount?: string;
|
|
6
|
+
/** Asset Id Hex String */
|
|
7
|
+
asset_id?: string;
|
|
8
|
+
/** Asset Group Key Hex String */
|
|
9
|
+
group_key?: string;
|
|
10
|
+
/** Proof Courier Address String */
|
|
11
|
+
proof_courier?: string;
|
|
12
|
+
/** Address Version Number */
|
|
13
|
+
version?: number;
|
|
14
|
+
}>;
|
|
15
|
+
export type CreateAssetAddressResult = {
|
|
16
|
+
/** Encoded Taproot Assets Address String */
|
|
17
|
+
address: string;
|
|
18
|
+
/** Asset Units To Receive Numeric String */
|
|
19
|
+
amount: string;
|
|
20
|
+
/** Asset Id Hex String */
|
|
21
|
+
asset_id?: string;
|
|
22
|
+
/** Asset Version Number */
|
|
23
|
+
asset_version: number;
|
|
24
|
+
/** Asset Group Key Hex String */
|
|
25
|
+
group_key?: string;
|
|
26
|
+
/** Internal Key Hex String */
|
|
27
|
+
internal_key: string;
|
|
28
|
+
/** Asset Is Collectible Bool */
|
|
29
|
+
is_collectible: boolean;
|
|
30
|
+
/** Proof Courier Address String */
|
|
31
|
+
proof_courier: string;
|
|
32
|
+
/** Script Key Hex String */
|
|
33
|
+
script_key: string;
|
|
34
|
+
/** Tapscript Sibling Preimage Hex String */
|
|
35
|
+
tapscript_sibling?: string;
|
|
36
|
+
/** Taproot Output Key Hex String */
|
|
37
|
+
taproot_output_key: string;
|
|
38
|
+
/** Address Version Number */
|
|
39
|
+
version: number;
|
|
40
|
+
};
|
|
41
|
+
/** Create a Taproot Assets address to receive an asset
|
|
42
|
+
|
|
43
|
+
Requires `addresses:write` permission
|
|
44
|
+
|
|
45
|
+
An `asset_id` or a `group_key` is required, but not both
|
|
46
|
+
|
|
47
|
+
When there is a `group_key` and no `version`, tapd makes a V2 address
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
[amount]: <Asset Units To Receive Numeric String>
|
|
51
|
+
[asset_id]: <Asset Id Hex String>
|
|
52
|
+
[group_key]: <Asset Group Key Hex String>
|
|
53
|
+
[proof_courier]: <Proof Courier Address String>
|
|
54
|
+
tapd: <Authenticated tapd API Object>
|
|
55
|
+
[version]: <Address Version Number> // 0 || 1 || 2
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@returns via cbk or Promise
|
|
59
|
+
{
|
|
60
|
+
address: <Encoded Taproot Assets Address String>
|
|
61
|
+
amount: <Asset Units To Receive Numeric String>
|
|
62
|
+
[asset_id]: <Asset Id Hex String>
|
|
63
|
+
asset_version: <Asset Version Number>
|
|
64
|
+
[group_key]: <Asset Group Key Hex String>
|
|
65
|
+
internal_key: <Internal Key Hex String>
|
|
66
|
+
is_collectible: <Asset Is Collectible Bool>
|
|
67
|
+
proof_courier: <Proof Courier Address String>
|
|
68
|
+
script_key: <Script Key Hex String>
|
|
69
|
+
[tapscript_sibling]: <Tapscript Sibling Preimage Hex String>
|
|
70
|
+
taproot_output_key: <Taproot Output Key Hex String>
|
|
71
|
+
version: <Address Version Number>
|
|
72
|
+
}
|
|
73
|
+
*/
|
|
74
|
+
declare const createAssetAddress: TapdMethod<CreateAssetAddressArgs, CreateAssetAddressResult>;
|
|
75
|
+
export default createAssetAddress;
|
|
76
|
+
//# sourceMappingURL=create_asset_address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_asset_address.d.ts","sourceRoot":"","sources":["../../../src/tapd_methods/address/create_asset_address.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,qBAAqB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|
|
2
|
+
import { returnResult } from 'asyncjs-util';
|
|
3
|
+
import { isConnectionFailure } from '../../tapd_requests/index.js';
|
|
4
|
+
import { isPermissionDenied } from '../../tapd_requests/index.js';
|
|
5
|
+
import { isTapd } from '../../tapd_requests/index.js';
|
|
6
|
+
const addressVersions = [
|
|
7
|
+
'ADDR_VERSION_V0',
|
|
8
|
+
'ADDR_VERSION_V1',
|
|
9
|
+
'ADDR_VERSION_V2',
|
|
10
|
+
];
|
|
11
|
+
const assetVersions = ['ASSET_VERSION_V0', 'ASSET_VERSION_V1'];
|
|
12
|
+
const bufferAsHex = (n) => (!n.length ? undefined : n.toString('hex'));
|
|
13
|
+
const { from } = Buffer;
|
|
14
|
+
const isAssetId = (n) => /^[0-9A-F]{64}$/i.test(n);
|
|
15
|
+
const isBuffer = (n) => Buffer.isBuffer(n);
|
|
16
|
+
const isHex = (n) => !!n && !(n.length % 2) && /^[0-9A-F]*$/i.test(n);
|
|
17
|
+
const isNumeric = (n) => typeof n === 'string' && /^\d+$/.test(n);
|
|
18
|
+
const method = 'newAddr';
|
|
19
|
+
const notFoundError = 'unable to find asset or group';
|
|
20
|
+
const type = 'default';
|
|
21
|
+
const unspecifiedVersion = 'ADDR_VERSION_UNSPECIFIED';
|
|
22
|
+
/** Create a Taproot Assets address to receive an asset
|
|
23
|
+
|
|
24
|
+
Requires `addresses:write` permission
|
|
25
|
+
|
|
26
|
+
An `asset_id` or a `group_key` is required, but not both
|
|
27
|
+
|
|
28
|
+
When there is a `group_key` and no `version`, tapd makes a V2 address
|
|
29
|
+
|
|
30
|
+
{
|
|
31
|
+
[amount]: <Asset Units To Receive Numeric String>
|
|
32
|
+
[asset_id]: <Asset Id Hex String>
|
|
33
|
+
[group_key]: <Asset Group Key Hex String>
|
|
34
|
+
[proof_courier]: <Proof Courier Address String>
|
|
35
|
+
tapd: <Authenticated tapd API Object>
|
|
36
|
+
[version]: <Address Version Number> // 0 || 1 || 2
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@returns via cbk or Promise
|
|
40
|
+
{
|
|
41
|
+
address: <Encoded Taproot Assets Address String>
|
|
42
|
+
amount: <Asset Units To Receive Numeric String>
|
|
43
|
+
[asset_id]: <Asset Id Hex String>
|
|
44
|
+
asset_version: <Asset Version Number>
|
|
45
|
+
[group_key]: <Asset Group Key Hex String>
|
|
46
|
+
internal_key: <Internal Key Hex String>
|
|
47
|
+
is_collectible: <Asset Is Collectible Bool>
|
|
48
|
+
proof_courier: <Proof Courier Address String>
|
|
49
|
+
script_key: <Script Key Hex String>
|
|
50
|
+
[tapscript_sibling]: <Tapscript Sibling Preimage Hex String>
|
|
51
|
+
taproot_output_key: <Taproot Output Key Hex String>
|
|
52
|
+
version: <Address Version Number>
|
|
53
|
+
}
|
|
54
|
+
*/
|
|
55
|
+
const createAssetAddress = (args, cbk) => {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
return asyncAuto({
|
|
58
|
+
// Check arguments
|
|
59
|
+
validate: cbk => {
|
|
60
|
+
if (args.amount !== undefined && !isNumeric(args.amount)) {
|
|
61
|
+
return cbk([400, 'ExpectedNumericAmountToCreateAssetAddress']);
|
|
62
|
+
}
|
|
63
|
+
if (!args.asset_id && !args.group_key) {
|
|
64
|
+
return cbk([400, 'ExpectedAssetIdOrGroupKeyToCreateAssetAddress']);
|
|
65
|
+
}
|
|
66
|
+
if (!!args.asset_id && !!args.group_key) {
|
|
67
|
+
return cbk([400, 'UnexpectedAssetIdAndGroupKeyForAssetAddress']);
|
|
68
|
+
}
|
|
69
|
+
if (!!args.asset_id && !isAssetId(args.asset_id)) {
|
|
70
|
+
return cbk([400, 'ExpectedAssetIdHexToCreateAssetAddress']);
|
|
71
|
+
}
|
|
72
|
+
if (!!args.group_key && !isHex(args.group_key)) {
|
|
73
|
+
return cbk([400, 'ExpectedGroupKeyHexToCreateAssetAddress']);
|
|
74
|
+
}
|
|
75
|
+
if (!isTapd({ method, type, tapd: args.tapd })) {
|
|
76
|
+
return cbk([400, 'ExpectedAuthenticatedTapdToCreateAssetAddress']);
|
|
77
|
+
}
|
|
78
|
+
if (args.version !== undefined && !addressVersions[args.version]) {
|
|
79
|
+
return cbk([400, 'ExpectedKnownVersionToCreateAssetAddress']);
|
|
80
|
+
}
|
|
81
|
+
return cbk();
|
|
82
|
+
},
|
|
83
|
+
// Create the address
|
|
84
|
+
createAddress: [
|
|
85
|
+
'validate',
|
|
86
|
+
({}, cbk) => {
|
|
87
|
+
const request = {
|
|
88
|
+
address_version: args.version === undefined
|
|
89
|
+
? unspecifiedVersion
|
|
90
|
+
: addressVersions[args.version],
|
|
91
|
+
amt: args.amount || '0',
|
|
92
|
+
asset_id: from(args.asset_id || '', 'hex'),
|
|
93
|
+
group_key: from(args.group_key || '', 'hex'),
|
|
94
|
+
proof_courier_addr: args.proof_courier || '',
|
|
95
|
+
};
|
|
96
|
+
return args.tapd[type][method](request, (err, res) => {
|
|
97
|
+
if (isConnectionFailure({ err })) {
|
|
98
|
+
return cbk([503, 'FailedToConnectToTapdToCreateAssetAddress']);
|
|
99
|
+
}
|
|
100
|
+
if (isPermissionDenied({ err })) {
|
|
101
|
+
return cbk([403, 'PermissionDeniedToCreateAssetAddress']);
|
|
102
|
+
}
|
|
103
|
+
if (!!err && String(err.details).includes(notFoundError)) {
|
|
104
|
+
const isGroup = !!args.group_key;
|
|
105
|
+
return cbk([
|
|
106
|
+
404,
|
|
107
|
+
isGroup ? 'AssetGroupNotFound' : 'AssetNotFound',
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
if (!!err) {
|
|
111
|
+
return cbk([503, 'UnexpectedErrorCreatingAssetAddress', { err }]);
|
|
112
|
+
}
|
|
113
|
+
if (!res) {
|
|
114
|
+
return cbk([503, 'ExpectedResponseForAssetAddressCreation']);
|
|
115
|
+
}
|
|
116
|
+
if (!res.encoded) {
|
|
117
|
+
return cbk([503, 'ExpectedEncodedAddressInAddressResponse']);
|
|
118
|
+
}
|
|
119
|
+
if (!isNumeric(res.amount)) {
|
|
120
|
+
return cbk([503, 'ExpectedAmountInAssetAddressResponse']);
|
|
121
|
+
}
|
|
122
|
+
if (!isBuffer(res.asset_id) || !isBuffer(res.group_key)) {
|
|
123
|
+
return cbk([503, 'ExpectedAssetIdentityInAddressResponse']);
|
|
124
|
+
}
|
|
125
|
+
if (!isBuffer(res.internal_key) || !isBuffer(res.script_key)) {
|
|
126
|
+
return cbk([503, 'ExpectedKeysInAssetAddressResponse']);
|
|
127
|
+
}
|
|
128
|
+
if (!isBuffer(res.taproot_output_key)) {
|
|
129
|
+
return cbk([503, 'ExpectedOutputKeyInAssetAddressResponse']);
|
|
130
|
+
}
|
|
131
|
+
if (!isBuffer(res.tapscript_sibling)) {
|
|
132
|
+
return cbk([503, 'ExpectedTapscriptSiblingInAddressResponse']);
|
|
133
|
+
}
|
|
134
|
+
const version = addressVersions.indexOf(res.address_version);
|
|
135
|
+
if (version === -1) {
|
|
136
|
+
return cbk([503, 'ExpectedKnownVersionInAddressResponse']);
|
|
137
|
+
}
|
|
138
|
+
return cbk(null, {
|
|
139
|
+
version,
|
|
140
|
+
address: res.encoded,
|
|
141
|
+
amount: res.amount,
|
|
142
|
+
asset_id: bufferAsHex(res.asset_id),
|
|
143
|
+
asset_version: assetVersions.indexOf(res.asset_version),
|
|
144
|
+
group_key: bufferAsHex(res.group_key),
|
|
145
|
+
internal_key: res.internal_key.toString('hex'),
|
|
146
|
+
is_collectible: res.asset_type === 'COLLECTIBLE',
|
|
147
|
+
proof_courier: res.proof_courier_addr,
|
|
148
|
+
script_key: res.script_key.toString('hex'),
|
|
149
|
+
tapscript_sibling: bufferAsHex(res.tapscript_sibling),
|
|
150
|
+
taproot_output_key: res.taproot_output_key.toString('hex'),
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
}, returnResult({ reject, resolve, of: 'createAddress' }, cbk));
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
export default createAssetAddress;
|
|
159
|
+
//# sourceMappingURL=create_asset_address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_asset_address.js","sourceRoot":"","sources":["../../../src/tapd_methods/address/create_asset_address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,SAAS,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAMpD,MAAM,eAAe,GAAG;IACtB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;CAClB,CAAC;AACF,MAAM,aAAa,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;AAC/D,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/E,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,CAAC;AACtB,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3D,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACjE,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9E,MAAM,SAAS,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAA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K,aAAa;4BAChD,aAAa,EAAE,GAAG,CAAC,kBAAkB;4BACrC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;4BAC1C,iBAAiB,EAAE,WAAW,CAAC,GAAG,CAAC,iBAAiB,CAAC;4BACrD,kBAAkB,EAAE,GAAG,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC;yBAC3D,CAAC,CAAC;oBACL,CAAC,CAAC,CAAC;gBACL,CAAC;aACF;SACF,EACD,YAAY,CAAC,EAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,eAAe,EAAC,EAAE,GAAG,CAAC,CAC1D,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tapd_methods/address/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AACxE,YAAY,EAAC,sBAAsB,EAAC,MAAM,2BAA2B,CAAC;AACtE,YAAY,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tapd_methods/address/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tapd_methods/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tapd_methods/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tapd_requests/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tapd_requests/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Err = {
|
|
2
|
+
code?: number;
|
|
3
|
+
details?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
/** Determine if an error represents a failure to connect to the daemon
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
[err]: {
|
|
11
|
+
[code]: <gRPC Status Code Number>
|
|
12
|
+
[details]: <gRPC Status Details String>
|
|
13
|
+
[message]: <Error Message String>
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@returns
|
|
18
|
+
<Is Connection Failure Bool>
|
|
19
|
+
*/
|
|
20
|
+
declare function _default({ err }: {
|
|
21
|
+
err?: Err | null;
|
|
22
|
+
}): boolean;
|
|
23
|
+
//# sourceMappingURL=is_connection_failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_connection_failure.d.ts","sourceRoot":"","sources":["../../src/tapd_requests/is_connection_failure.ts"],"names":[],"mappings":"AAgBA,KAAK,GAAG,GAAG;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;;AAE/D;;;;;;;;;;;;EAYE;0BACc,EAAC,GAAG,EAAC,EAAE;IAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAA;CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import grpc from '@grpc/grpc-js';
|
|
2
|
+
const connectionFailureMessages = [
|
|
3
|
+
'channel is in state transient_failure',
|
|
4
|
+
'connect failed',
|
|
5
|
+
'connection dropped',
|
|
6
|
+
'econnrefused',
|
|
7
|
+
'econnreset',
|
|
8
|
+
'failed to connect to all addresses',
|
|
9
|
+
'no connection established',
|
|
10
|
+
'server is shutting down',
|
|
11
|
+
];
|
|
12
|
+
const isString = (n) => typeof n === 'string';
|
|
13
|
+
const unavailableCode = grpc.status.UNAVAILABLE;
|
|
14
|
+
/** Determine if an error represents a failure to connect to the daemon
|
|
15
|
+
|
|
16
|
+
{
|
|
17
|
+
[err]: {
|
|
18
|
+
[code]: <gRPC Status Code Number>
|
|
19
|
+
[details]: <gRPC Status Details String>
|
|
20
|
+
[message]: <Error Message String>
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@returns
|
|
25
|
+
<Is Connection Failure Bool>
|
|
26
|
+
*/
|
|
27
|
+
export default ({ err }) => {
|
|
28
|
+
// Exit early when there is no error
|
|
29
|
+
if (!err) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
// Exit early when the connection is reported as unavailable
|
|
33
|
+
if (err.code === unavailableCode) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
const text = [err.details, err.message].filter(isString).join(' ');
|
|
37
|
+
const normalized = text.toLowerCase();
|
|
38
|
+
return !!connectionFailureMessages.find(n => normalized.includes(n));
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=is_connection_failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_connection_failure.js","sourceRoot":"","sources":["../../src/tapd_requests/is_connection_failure.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,eAAe,CAAC;AAEjC,MAAM,yBAAyB,GAAG;IAChC,uCAAuC;IACvC,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,oCAAoC;IACpC,2BAA2B;IAC3B,yBAAyB;CAC1B,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;AACvD,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;AAIhD;;;;;;;;;;;;EAYE;AACF,eAAe,CAAC,EAAC,GAAG,EAAqB,EAAE,EAAE;IAC3C,oCAAoC;IACpC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IAED,4DAA4D;IAC5D,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEnE,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAEtC,OAAO,CAAC,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type Err = {
|
|
2
|
+
details?: string;
|
|
3
|
+
};
|
|
4
|
+
export default _default;
|
|
5
|
+
/** Determine if an error is a macaroon permission failure
|
|
6
|
+
|
|
7
|
+
{
|
|
8
|
+
[err]: {
|
|
9
|
+
[details]: <gRPC Status Details String>
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@returns
|
|
14
|
+
<Is Permission Denied Bool>
|
|
15
|
+
*/
|
|
16
|
+
declare function _default({ err }: {
|
|
17
|
+
err?: Err | null;
|
|
18
|
+
}): boolean;
|
|
19
|
+
//# sourceMappingURL=is_permission_denied.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is_permission_denied.d.ts","sourceRoot":"","sources":["../../src/tapd_requests/is_permission_denied.ts"],"names":[],"mappings":"AAEA,KAAK,GAAG,GAAG;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;;AAE9B;;;;;;;;;;EAUE;0BACc,EAAC,GAAG,EAAC,EAAE;IAAC,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAA;CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const permissionDeniedText = 'permission denied';
|
|
2
|
+
/** Determine if an error is a macaroon permission failure
|
|
3
|
+
|
|
4
|
+
{
|
|
5
|
+
[err]: {
|
|
6
|
+
[details]: <gRPC Status Details String>
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@returns
|
|
11
|
+
<Is Permission Denied Bool>
|
|
12
|
+
*/
|
|
13
|
+
export default ({ err }) => {
|
|
14
|
+
return String(err?.details).includes(permissionDeniedText);
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=is_permission_denied.js.map
|