@portaidentity/cli 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/dist/auth/browser-flow.d.ts +42 -0
- package/dist/auth/browser-flow.d.ts.map +1 -0
- package/dist/auth/browser-flow.js +193 -0
- package/dist/auth/browser-flow.js.map +1 -0
- package/dist/auth/callback-server.d.ts +81 -0
- package/dist/auth/callback-server.d.ts.map +1 -0
- package/dist/auth/callback-server.js +193 -0
- package/dist/auth/callback-server.js.map +1 -0
- package/dist/auth/metadata.d.ts +43 -0
- package/dist/auth/metadata.d.ts.map +1 -0
- package/dist/auth/metadata.js +66 -0
- package/dist/auth/metadata.js.map +1 -0
- package/dist/auth/pkce.d.ts +42 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +52 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/types.d.ts +72 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +11 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/client-factory.d.ts +29 -0
- package/dist/client-factory.d.ts.map +1 -0
- package/dist/client-factory.js +43 -0
- package/dist/client-factory.js.map +1 -0
- package/dist/commands/app-claim.d.ts +9 -0
- package/dist/commands/app-claim.d.ts.map +1 -0
- package/dist/commands/app-claim.js +128 -0
- package/dist/commands/app-claim.js.map +1 -0
- package/dist/commands/app-module.d.ts +9 -0
- package/dist/commands/app-module.d.ts.map +1 -0
- package/dist/commands/app-module.js +104 -0
- package/dist/commands/app-module.js.map +1 -0
- package/dist/commands/app-permission.d.ts +9 -0
- package/dist/commands/app-permission.d.ts.map +1 -0
- package/dist/commands/app-permission.js +118 -0
- package/dist/commands/app-permission.js.map +1 -0
- package/dist/commands/app-role.d.ts +9 -0
- package/dist/commands/app-role.d.ts.map +1 -0
- package/dist/commands/app-role.js +166 -0
- package/dist/commands/app-role.js.map +1 -0
- package/dist/commands/app.d.ts +12 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +255 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/audit.d.ts +12 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +96 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/bulk.d.ts +12 -0
- package/dist/commands/bulk.d.ts.map +1 -0
- package/dist/commands/bulk.js +77 -0
- package/dist/commands/bulk.js.map +1 -0
- package/dist/commands/client-secret.d.ts +18 -0
- package/dist/commands/client-secret.d.ts.map +1 -0
- package/dist/commands/client-secret.js +126 -0
- package/dist/commands/client-secret.js.map +1 -0
- package/dist/commands/client.d.ts +27 -0
- package/dist/commands/client.d.ts.map +1 -0
- package/dist/commands/client.js +385 -0
- package/dist/commands/client.js.map +1 -0
- package/dist/commands/completion.d.ts +27 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +42 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +14 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +85 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/doctor.d.ts +25 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +198 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/exports.d.ts +12 -0
- package/dist/commands/exports.d.ts.map +1 -0
- package/dist/commands/exports.js +80 -0
- package/dist/commands/exports.js.map +1 -0
- package/dist/commands/health.d.ts +12 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +53 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/keys.d.ts +14 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +91 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/login.d.ts +36 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +78 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +25 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +43 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/org.d.ts +26 -0
- package/dist/commands/org.d.ts.map +1 -0
- package/dist/commands/org.js +396 -0
- package/dist/commands/org.js.map +1 -0
- package/dist/commands/provision.d.ts +47 -0
- package/dist/commands/provision.d.ts.map +1 -0
- package/dist/commands/provision.js +400 -0
- package/dist/commands/provision.js.map +1 -0
- package/dist/commands/sessions.d.ts +14 -0
- package/dist/commands/sessions.d.ts.map +1 -0
- package/dist/commands/sessions.js +122 -0
- package/dist/commands/sessions.js.map +1 -0
- package/dist/commands/stats.d.ts +12 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +46 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/user-claim.d.ts +17 -0
- package/dist/commands/user-claim.d.ts.map +1 -0
- package/dist/commands/user-claim.js +123 -0
- package/dist/commands/user-claim.js.map +1 -0
- package/dist/commands/user-role.d.ts +17 -0
- package/dist/commands/user-role.d.ts.map +1 -0
- package/dist/commands/user-role.js +118 -0
- package/dist/commands/user-role.js.map +1 -0
- package/dist/commands/user.d.ts +26 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +352 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/version.d.ts +25 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +83 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/commands/whoami.d.ts +26 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +66 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/credential-store.d.ts +101 -0
- package/dist/credential-store.d.ts.map +1 -0
- package/dist/credential-store.js +121 -0
- package/dist/credential-store.js.map +1 -0
- package/dist/error-handler.d.ts +47 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/error-handler.js +166 -0
- package/dist/error-handler.js.map +1 -0
- package/dist/global-options.d.ts +50 -0
- package/dist/global-options.d.ts.map +1 -0
- package/dist/global-options.js +62 -0
- package/dist/global-options.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +75 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +100 -0
- package/dist/output.js.map +1 -0
- package/dist/parsers.d.ts +74 -0
- package/dist/parsers.d.ts.map +1 -0
- package/dist/parsers.js +125 -0
- package/dist/parsers.js.map +1 -0
- package/dist/prompt.d.ts +50 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +98 -0
- package/dist/prompt.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PKCE (Proof Key for Code Exchange) helpers.
|
|
3
|
+
*
|
|
4
|
+
* Implements RFC 7636 for the CLI login flow. PKCE prevents
|
|
5
|
+
* authorization code interception attacks by binding the code
|
|
6
|
+
* exchange to a cryptographically random verifier.
|
|
7
|
+
*
|
|
8
|
+
* INV1 resolution: PKCE functions were originally inline in
|
|
9
|
+
* `src/cli/commands/login.ts`. Extracted here as standalone
|
|
10
|
+
* helpers for the standalone CLI package.
|
|
11
|
+
*
|
|
12
|
+
* @module auth/pkce
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Generate a cryptographically random PKCE code_verifier.
|
|
16
|
+
*
|
|
17
|
+
* Per RFC 7636 §4.1: 32 random bytes encoded as base64url produces
|
|
18
|
+
* a 43-character string, well within the 43–128 character requirement.
|
|
19
|
+
*
|
|
20
|
+
* @returns Base64url-encoded code verifier
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateCodeVerifier(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate the PKCE code_challenge from a code_verifier using S256.
|
|
25
|
+
*
|
|
26
|
+
* Per RFC 7636 §4.2: code_challenge = BASE64URL(SHA256(code_verifier))
|
|
27
|
+
*
|
|
28
|
+
* @param verifier - The code_verifier to hash
|
|
29
|
+
* @returns Base64url-encoded SHA-256 hash of the verifier
|
|
30
|
+
*/
|
|
31
|
+
export declare function generateCodeChallenge(verifier: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Generate a cryptographically random state parameter.
|
|
34
|
+
*
|
|
35
|
+
* Used to prevent CSRF attacks on the OAuth callback. The CLI
|
|
36
|
+
* generates this value before opening the browser and validates
|
|
37
|
+
* it when the callback is received.
|
|
38
|
+
*
|
|
39
|
+
* @returns Base64url-encoded random state string
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateState(): string;
|
|
42
|
+
//# sourceMappingURL=pkce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../src/auth/pkce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PKCE (Proof Key for Code Exchange) helpers.
|
|
3
|
+
*
|
|
4
|
+
* Implements RFC 7636 for the CLI login flow. PKCE prevents
|
|
5
|
+
* authorization code interception attacks by binding the code
|
|
6
|
+
* exchange to a cryptographically random verifier.
|
|
7
|
+
*
|
|
8
|
+
* INV1 resolution: PKCE functions were originally inline in
|
|
9
|
+
* `src/cli/commands/login.ts`. Extracted here as standalone
|
|
10
|
+
* helpers for the standalone CLI package.
|
|
11
|
+
*
|
|
12
|
+
* @module auth/pkce
|
|
13
|
+
*/
|
|
14
|
+
import { randomBytes, createHash } from 'node:crypto';
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// PKCE Generation
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/**
|
|
19
|
+
* Generate a cryptographically random PKCE code_verifier.
|
|
20
|
+
*
|
|
21
|
+
* Per RFC 7636 §4.1: 32 random bytes encoded as base64url produces
|
|
22
|
+
* a 43-character string, well within the 43–128 character requirement.
|
|
23
|
+
*
|
|
24
|
+
* @returns Base64url-encoded code verifier
|
|
25
|
+
*/
|
|
26
|
+
export function generateCodeVerifier() {
|
|
27
|
+
return randomBytes(32).toString('base64url');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generate the PKCE code_challenge from a code_verifier using S256.
|
|
31
|
+
*
|
|
32
|
+
* Per RFC 7636 §4.2: code_challenge = BASE64URL(SHA256(code_verifier))
|
|
33
|
+
*
|
|
34
|
+
* @param verifier - The code_verifier to hash
|
|
35
|
+
* @returns Base64url-encoded SHA-256 hash of the verifier
|
|
36
|
+
*/
|
|
37
|
+
export function generateCodeChallenge(verifier) {
|
|
38
|
+
return createHash('sha256').update(verifier).digest('base64url');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Generate a cryptographically random state parameter.
|
|
42
|
+
*
|
|
43
|
+
* Used to prevent CSRF attacks on the OAuth callback. The CLI
|
|
44
|
+
* generates this value before opening the browser and validates
|
|
45
|
+
* it when the callback is received.
|
|
46
|
+
*
|
|
47
|
+
* @returns Base64url-encoded random state string
|
|
48
|
+
*/
|
|
49
|
+
export function generateState() {
|
|
50
|
+
return randomBytes(16).toString('base64url');
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=pkce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkce.js","sourceRoot":"","sources":["../../src/auth/pkce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtD,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the CLI authentication flow.
|
|
3
|
+
*
|
|
4
|
+
* Defines the data structures used during the OIDC Authorization Code
|
|
5
|
+
* + PKCE login flow: admin metadata discovery, token responses, and
|
|
6
|
+
* the intermediate auth flow result.
|
|
7
|
+
*
|
|
8
|
+
* @module auth/types
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Response shape from the admin metadata endpoint.
|
|
12
|
+
*
|
|
13
|
+
* `GET /api/admin/metadata` returns this data — an unauthenticated
|
|
14
|
+
* endpoint that exposes the OIDC client_id, issuer, and organization
|
|
15
|
+
* slug needed to initiate the login flow.
|
|
16
|
+
*/
|
|
17
|
+
export interface AdminMetadata {
|
|
18
|
+
/** OIDC issuer URL (e.g., "https://porta.local:3443/porta-admin") */
|
|
19
|
+
issuer: string;
|
|
20
|
+
/** OIDC client_id for the admin CLI PKCE client */
|
|
21
|
+
clientId: string;
|
|
22
|
+
/** Organization slug for the admin org (e.g., "porta-admin") */
|
|
23
|
+
orgSlug: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Token response from the OIDC token endpoint.
|
|
27
|
+
*
|
|
28
|
+
* Returned after exchanging an authorization code for tokens via
|
|
29
|
+
* `POST /{orgSlug}/token`.
|
|
30
|
+
*/
|
|
31
|
+
export interface TokenResponse {
|
|
32
|
+
/** JWT access token for API authorization */
|
|
33
|
+
access_token: string;
|
|
34
|
+
/** Refresh token for obtaining new access tokens */
|
|
35
|
+
refresh_token: string;
|
|
36
|
+
/** OIDC ID token containing user identity claims */
|
|
37
|
+
id_token: string;
|
|
38
|
+
/** Seconds until the access token expires */
|
|
39
|
+
expires_in: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result of the browser-based auth flow.
|
|
43
|
+
*
|
|
44
|
+
* Contains all tokens and user info needed to store credentials
|
|
45
|
+
* after a successful login.
|
|
46
|
+
*/
|
|
47
|
+
export interface AuthFlowResult {
|
|
48
|
+
/** Server URL that was authenticated against */
|
|
49
|
+
server: string;
|
|
50
|
+
/** Organization slug used during login */
|
|
51
|
+
orgSlug: string;
|
|
52
|
+
/** OIDC client ID used during login */
|
|
53
|
+
clientId: string;
|
|
54
|
+
/** JWT access token */
|
|
55
|
+
accessToken: string;
|
|
56
|
+
/** Refresh token for renewing access */
|
|
57
|
+
refreshToken: string;
|
|
58
|
+
/** OIDC ID token */
|
|
59
|
+
idToken: string;
|
|
60
|
+
/** ISO 8601 expiry timestamp for the access token */
|
|
61
|
+
expiresAt: string;
|
|
62
|
+
/** Decoded user info from the ID token */
|
|
63
|
+
userInfo: {
|
|
64
|
+
/** OIDC subject identifier (user ID) */
|
|
65
|
+
sub: string;
|
|
66
|
+
/** User email address */
|
|
67
|
+
email: string;
|
|
68
|
+
/** User display name (optional) */
|
|
69
|
+
name?: string;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,EAAE;QACR,wCAAwC;QACxC,GAAG,EAAE,MAAM,CAAC;QACZ,yBAAyB;QACzB,KAAK,EAAE,MAAM,CAAC;QACd,mCAAmC;QACnC,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the CLI authentication flow.
|
|
3
|
+
*
|
|
4
|
+
* Defines the data structures used during the OIDC Authorization Code
|
|
5
|
+
* + PKCE login flow: admin metadata discovery, token responses, and
|
|
6
|
+
* the intermediate auth flow result.
|
|
7
|
+
*
|
|
8
|
+
* @module auth/types
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK client factory for CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* Creates a configured `PortaClient` instance from CLI global options.
|
|
5
|
+
* Uses the SDK's `createCliAuth` provider which reads credentials from
|
|
6
|
+
* `~/.porta/credentials.json` and handles automatic token refresh.
|
|
7
|
+
*
|
|
8
|
+
* The factory resolves the server URL via the priority chain
|
|
9
|
+
* (--server > PORTA_SERVER > credentials file) and configures
|
|
10
|
+
* TLS handling based on the `--insecure` flag.
|
|
11
|
+
*
|
|
12
|
+
* @module client-factory
|
|
13
|
+
*/
|
|
14
|
+
import type { PortaClient } from '@portaidentity/sdk';
|
|
15
|
+
import { type GlobalOptions } from './global-options.js';
|
|
16
|
+
/**
|
|
17
|
+
* Creates a PortaClient configured from CLI global options.
|
|
18
|
+
*
|
|
19
|
+
* Resolves the server URL, sets up CLI auth (with auto-refresh),
|
|
20
|
+
* and creates a Node.js transport. The `--insecure` flag controls
|
|
21
|
+
* whether TLS certificate verification is skipped by setting the
|
|
22
|
+
* NODE_TLS_REJECT_UNAUTHORIZED environment variable.
|
|
23
|
+
*
|
|
24
|
+
* @param options - Global CLI options
|
|
25
|
+
* @returns A configured PortaClient ready for API calls
|
|
26
|
+
* @throws Error if no server URL can be resolved
|
|
27
|
+
*/
|
|
28
|
+
export declare function createClient(options: GlobalOptions): PortaClient;
|
|
29
|
+
//# sourceMappingURL=client-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-factory.d.ts","sourceRoot":"","sources":["../src/client-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAM3E;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,WAAW,CAahE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK client factory for CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* Creates a configured `PortaClient` instance from CLI global options.
|
|
5
|
+
* Uses the SDK's `createCliAuth` provider which reads credentials from
|
|
6
|
+
* `~/.porta/credentials.json` and handles automatic token refresh.
|
|
7
|
+
*
|
|
8
|
+
* The factory resolves the server URL via the priority chain
|
|
9
|
+
* (--server > PORTA_SERVER > credentials file) and configures
|
|
10
|
+
* TLS handling based on the `--insecure` flag.
|
|
11
|
+
*
|
|
12
|
+
* @module client-factory
|
|
13
|
+
*/
|
|
14
|
+
import { createPortaClient } from '@portaidentity/sdk';
|
|
15
|
+
import { createNodeTransport, createCliAuth } from '@portaidentity/sdk/node';
|
|
16
|
+
import { resolveServerUrl } from './global-options.js';
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Client Creation
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
/**
|
|
21
|
+
* Creates a PortaClient configured from CLI global options.
|
|
22
|
+
*
|
|
23
|
+
* Resolves the server URL, sets up CLI auth (with auto-refresh),
|
|
24
|
+
* and creates a Node.js transport. The `--insecure` flag controls
|
|
25
|
+
* whether TLS certificate verification is skipped by setting the
|
|
26
|
+
* NODE_TLS_REJECT_UNAUTHORIZED environment variable.
|
|
27
|
+
*
|
|
28
|
+
* @param options - Global CLI options
|
|
29
|
+
* @returns A configured PortaClient ready for API calls
|
|
30
|
+
* @throws Error if no server URL can be resolved
|
|
31
|
+
*/
|
|
32
|
+
export function createClient(options) {
|
|
33
|
+
const baseUrl = resolveServerUrl(options);
|
|
34
|
+
// Handle --insecure flag for self-signed certificates
|
|
35
|
+
// This must be set before creating the transport so fetch() picks it up
|
|
36
|
+
if (options.insecure) {
|
|
37
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
38
|
+
}
|
|
39
|
+
const auth = createCliAuth();
|
|
40
|
+
const transport = createNodeTransport({ baseUrl, auth });
|
|
41
|
+
return createPortaClient({ transport });
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=client-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-factory.js","sourceRoot":"","sources":["../src/client-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAsB,MAAM,qBAAqB,CAAC;AAE3E,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE1C,sDAAsD;IACtD,wEAAwE;IACxE,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,GAAG,CAAC;IACjD,CAAC;IAED,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,mBAAmB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzD,OAAO,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI custom claim definition subcommands.
|
|
3
|
+
*
|
|
4
|
+
* @module commands/app-claim
|
|
5
|
+
*/
|
|
6
|
+
import type { CommandModule } from 'yargs';
|
|
7
|
+
import type { GlobalOptions } from '../global-options.js';
|
|
8
|
+
export declare const appClaimCommand: CommandModule<GlobalOptions, GlobalOptions>;
|
|
9
|
+
//# sourceMappingURL=app-claim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-claim.d.ts","sourceRoot":"","sources":["../../src/commands/app-claim.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAuC1D,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,aAAa,EAAE,aAAa,CAoJvE,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI custom claim definition subcommands.
|
|
3
|
+
*
|
|
4
|
+
* @module commands/app-claim
|
|
5
|
+
*/
|
|
6
|
+
import { createClient } from '../client-factory.js';
|
|
7
|
+
import { handleError } from '../error-handler.js';
|
|
8
|
+
import { printTable, printJson, success, warn, info, formatDate, truncate } from '../output.js';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Command definition
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
export const appClaimCommand = {
|
|
13
|
+
command: 'claim',
|
|
14
|
+
describe: 'Manage custom claim definitions',
|
|
15
|
+
builder: (yargs) => {
|
|
16
|
+
return yargs
|
|
17
|
+
.command('create <app-id>', 'Create a custom claim definition', (y) => y
|
|
18
|
+
.positional('app-id', { type: 'string', demandOption: true, description: 'Application ID' })
|
|
19
|
+
.option('name', { type: 'string', demandOption: true, description: 'Claim name' })
|
|
20
|
+
.option('slug', { type: 'string', description: 'Claim slug' })
|
|
21
|
+
.option('type', {
|
|
22
|
+
type: 'string',
|
|
23
|
+
demandOption: true,
|
|
24
|
+
choices: ['string', 'number', 'boolean', 'json'],
|
|
25
|
+
description: 'Claim value type',
|
|
26
|
+
})
|
|
27
|
+
.option('description', { type: 'string', description: 'Claim description' }), async (argv) => {
|
|
28
|
+
try {
|
|
29
|
+
const client = createClient(argv);
|
|
30
|
+
const claim = await client.customClaims.create(argv['app-id'], {
|
|
31
|
+
applicationId: argv['app-id'],
|
|
32
|
+
name: argv.name,
|
|
33
|
+
slug: argv.slug,
|
|
34
|
+
valueType: argv.type,
|
|
35
|
+
description: argv.description,
|
|
36
|
+
});
|
|
37
|
+
if (argv.json) {
|
|
38
|
+
printJson(claim);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
success(`Claim created: ${claim.name} (${claim.slug})`);
|
|
42
|
+
printTable(['Field', 'Value'], [
|
|
43
|
+
['ID', claim.id],
|
|
44
|
+
['Name', claim.name],
|
|
45
|
+
['Slug', claim.slug],
|
|
46
|
+
['Type', claim.valueType],
|
|
47
|
+
['Created', formatDate(claim.createdAt)],
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
handleError(err, argv.verbose);
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.command('list <app-id>', 'List claim definitions for an application', (y) => y
|
|
56
|
+
.positional('app-id', { type: 'string', demandOption: true, description: 'Application ID' })
|
|
57
|
+
.option('page', { type: 'number', default: 1, description: 'Page number' })
|
|
58
|
+
.option('page-size', { type: 'number', default: 20, description: 'Items per page' }), async (argv) => {
|
|
59
|
+
try {
|
|
60
|
+
const client = createClient(argv);
|
|
61
|
+
const result = await client.customClaims.list(argv['app-id'], {
|
|
62
|
+
page: argv.page,
|
|
63
|
+
pageSize: argv['page-size'],
|
|
64
|
+
});
|
|
65
|
+
if (result.data.length === 0) {
|
|
66
|
+
warn('No claim definitions found');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (argv.json) {
|
|
70
|
+
printJson(result);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
printTable(['ID', 'Name', 'Slug', 'Type', 'Created'], result.data.map((c) => [
|
|
74
|
+
truncate(c.id, 8),
|
|
75
|
+
c.name,
|
|
76
|
+
c.slug,
|
|
77
|
+
c.valueType,
|
|
78
|
+
formatDate(c.createdAt),
|
|
79
|
+
]));
|
|
80
|
+
info(`Total: ${result.total} claim definitions`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
handleError(err, argv.verbose);
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
.command('show <app-id> <claim-id>', 'Show claim definition details', (y) => y
|
|
88
|
+
.positional('app-id', { type: 'string', demandOption: true, description: 'Application ID' })
|
|
89
|
+
.positional('claim-id', { type: 'string', demandOption: true, description: 'Claim definition ID' }), async (argv) => {
|
|
90
|
+
try {
|
|
91
|
+
const client = createClient(argv);
|
|
92
|
+
const claim = await client.customClaims.get(argv['app-id'], argv['claim-id']);
|
|
93
|
+
if (argv.json) {
|
|
94
|
+
printJson(claim);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
printTable(['Field', 'Value'], [
|
|
98
|
+
['ID', claim.id],
|
|
99
|
+
['Name', claim.name],
|
|
100
|
+
['Slug', claim.slug],
|
|
101
|
+
['Type', claim.valueType],
|
|
102
|
+
['Description', claim.description ?? '—'],
|
|
103
|
+
['Created', formatDate(claim.createdAt)],
|
|
104
|
+
['Updated', formatDate(claim.updatedAt)],
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
handleError(err, argv.verbose);
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
.command('archive <app-id> <claim-id>', 'Archive a claim definition', (y) => y
|
|
113
|
+
.positional('app-id', { type: 'string', demandOption: true, description: 'Application ID' })
|
|
114
|
+
.positional('claim-id', { type: 'string', demandOption: true, description: 'Claim definition ID' }), async (argv) => {
|
|
115
|
+
try {
|
|
116
|
+
const client = createClient(argv);
|
|
117
|
+
await client.customClaims.archive(argv['app-id'], argv['claim-id']);
|
|
118
|
+
success('Claim definition archived');
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
handleError(err, argv.verbose);
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
.demandCommand(1, 'Specify a claim subcommand: create, list, show, archive');
|
|
125
|
+
},
|
|
126
|
+
handler: () => { },
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=app-claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-claim.js","sourceRoot":"","sources":["../../src/commands/app-claim.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA8BhG,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAgD;IAC1E,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,iCAAiC;IAC3C,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACjB,OAAO,KAAK;aACT,OAAO,CACN,iBAAiB,EACjB,kCAAkC,EAClC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC;aACE,UAAU,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;aAC3F,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;aACjF,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;aAC7D,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,IAAI;YAClB,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,M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
* CLI application module subcommands.
|
|
3
|
+
*
|
|
4
|
+
* @module commands/app-module
|
|
5
|
+
*/
|
|
6
|
+
import type { CommandModule } from 'yargs';
|
|
7
|
+
import type { GlobalOptions } from '../global-options.js';
|
|
8
|
+
export declare const appModuleCommand: CommandModule<GlobalOptions, GlobalOptions>;
|
|
9
|
+
//# sourceMappingURL=app-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module.d.ts","sourceRoot":"","sources":["../../src/commands/app-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAqC1D,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,aAAa,EAAE,aAAa,CAsHxE,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI application module subcommands.
|
|
3
|
+
*
|
|
4
|
+
* @module commands/app-module
|
|
5
|
+
*/
|
|
6
|
+
import { createClient } from '../client-factory.js';
|
|
7
|
+
import { handleError } from '../error-handler.js';
|
|
8
|
+
import { printTable, printJson, success, warn, info, formatDate, truncate } from '../output.js';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Command definition
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
export const appModuleCommand = {
|
|
13
|
+
command: 'module',
|
|
14
|
+
describe: 'Manage application modules',
|
|
15
|
+
builder: (yargs) => {
|
|
16
|
+
return yargs
|
|
17
|
+
.command('add <app-id>', 'Add a module to an application', (y) => y
|
|
18
|
+
.positional('app-id', { type: 'string', demandOption: true, description: 'Application ID' })
|
|
19
|
+
.option('name', { type: 'string', demandOption: true, description: 'Module name' })
|
|
20
|
+
.option('slug', { type: 'string', description: 'Module slug' })
|
|
21
|
+
.option('description', { type: 'string', description: 'Module description' }), async (argv) => {
|
|
22
|
+
try {
|
|
23
|
+
const client = createClient(argv);
|
|
24
|
+
const mod = await client.applications.addModule(argv['app-id'], {
|
|
25
|
+
name: argv.name,
|
|
26
|
+
slug: argv.slug,
|
|
27
|
+
description: argv.description,
|
|
28
|
+
});
|
|
29
|
+
if (argv.json) {
|
|
30
|
+
printJson(mod);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
success(`Module added: ${mod.name} (${mod.slug})`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
handleError(err, argv.verbose);
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
.command('list <app-id>', 'List modules for an application', (y) => y.positional('app-id', { type: 'string', demandOption: true, description: 'Application ID' }), async (argv) => {
|
|
41
|
+
try {
|
|
42
|
+
const client = createClient(argv);
|
|
43
|
+
const modules = await client.applications.listModules(argv['app-id']);
|
|
44
|
+
if (modules.length === 0) {
|
|
45
|
+
warn('No modules found');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (argv.json) {
|
|
49
|
+
printJson(modules);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
printTable(['ID', 'Name', 'Slug', 'Active', 'Created'], modules.map((m) => [
|
|
53
|
+
truncate(m.id, 8),
|
|
54
|
+
m.name,
|
|
55
|
+
m.slug,
|
|
56
|
+
String(m.isActive),
|
|
57
|
+
formatDate(m.createdAt),
|
|
58
|
+
]));
|
|
59
|
+
info(`Total: ${modules.length} modules`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
handleError(err, argv.verbose);
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.command('update <app-id> <module-id>', 'Update a module', (y) => y
|
|
67
|
+
.positional('app-id', { type: 'string', demandOption: true, description: 'Application ID' })
|
|
68
|
+
.positional('module-id', { type: 'string', demandOption: true, description: 'Module ID' })
|
|
69
|
+
.option('name', { type: 'string', description: 'New module name' })
|
|
70
|
+
.option('description', { type: 'string', description: 'New description' }), async (argv) => {
|
|
71
|
+
try {
|
|
72
|
+
const client = createClient(argv);
|
|
73
|
+
const updated = await client.applications.updateModule(argv['app-id'], argv['module-id'], {
|
|
74
|
+
name: argv.name,
|
|
75
|
+
description: argv.description,
|
|
76
|
+
});
|
|
77
|
+
if (argv.json) {
|
|
78
|
+
printJson(updated);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
success(`Module updated: ${updated.name}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
handleError(err, argv.verbose);
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
.command('remove <app-id> <module-id>', 'Remove a module from an application', (y) => y
|
|
89
|
+
.positional('app-id', { type: 'string', demandOption: true, description: 'Application ID' })
|
|
90
|
+
.positional('module-id', { type: 'string', demandOption: true, description: 'Module ID' }), async (argv) => {
|
|
91
|
+
try {
|
|
92
|
+
const client = createClient(argv);
|
|
93
|
+
await client.applications.removeModule(argv['app-id'], argv['module-id']);
|
|
94
|
+
success('Module removed');
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
handleError(err, argv.verbose);
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
.demandCommand(1, 'Specify a module subcommand: add, list, update, remove');
|
|
101
|
+
},
|
|
102
|
+
handler: () => { },
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=app-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-module.js","sourceRoot":"","sources":["../../src/commands/app-module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAA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CAAC;YACjC,CAAC;QACH,CAAC,CACF;aAEA,OAAO,CACN,6BAA6B,EAC7B,qCAAqC,EACrC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC;aACE,UAAU,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;aAC3F,UAAU,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,EAC9F,KAAK,EAAE,IAAI,EAAE,EAAE;YACb,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;gBAClC,MAAM,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC1E,OAAO,CAAC,gBAAgB,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACjC,CAAC;QACH,CAAC,CACF;aACA,aAAa,CAAC,CAAC,EAAE,wDAAwD,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;CAClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI application permission subcommands.
|
|
3
|
+
*
|
|
4
|
+
* @module commands/app-permission
|
|
5
|
+
*/
|
|
6
|
+
import type { CommandModule } from 'yargs';
|
|
7
|
+
import type { GlobalOptions } from '../global-options.js';
|
|
8
|
+
export declare const appPermissionCommand: CommandModule<GlobalOptions, GlobalOptions>;
|
|
9
|
+
//# sourceMappingURL=app-permission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-permission.d.ts","sourceRoot":"","sources":["../../src/commands/app-permission.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAqC1D,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,aAAa,EAAE,aAAa,CA0I5E,CAAC"}
|