@microsoft/power-apps-native-host 0.2.22 → 0.3.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.
Files changed (156) hide show
  1. package/README.md +162 -26
  2. package/compatibility/current.json +87 -0
  3. package/lib/NOTICE.txt +140 -1226
  4. package/lib/commonjs/auth/AuthContext.js +74 -18
  5. package/lib/commonjs/auth/AuthContext.web.js +32 -0
  6. package/lib/commonjs/auth/completePowerAppsAuthSession.js +16 -0
  7. package/lib/commonjs/bridge/NativePowerAppsBridge.js +20 -17
  8. package/lib/commonjs/bridge/PowerPagesBridge.js +157 -0
  9. package/lib/commonjs/bridge/bridgeState.js +40 -0
  10. package/lib/commonjs/connections/ConnectionSetupScreen.js +459 -80
  11. package/lib/commonjs/connections/PowerPlatformConnectionApi.js +946 -0
  12. package/lib/commonjs/connections/connectionMetadata.js +127 -0
  13. package/lib/commonjs/connections/connectionState.js +96 -0
  14. package/lib/commonjs/connections/disambiguate.js +19 -11
  15. package/lib/commonjs/connections/resolveConnections.js +347 -0
  16. package/lib/commonjs/connections/types.js +106 -0
  17. package/lib/commonjs/{platform → connections}/useConnectionRefs.js +128 -65
  18. package/lib/commonjs/connections/useConnectionSetup.js +111 -52
  19. package/lib/commonjs/controls/FilePicker.js +6 -0
  20. package/lib/commonjs/controls/ImagePicker.js +8 -0
  21. package/lib/commonjs/index.js +188 -6
  22. package/lib/commonjs/logger.js +9 -6
  23. package/lib/commonjs/offline/createOfflineHostActivationCallbacks.js +61 -0
  24. package/lib/commonjs/offline/useOfflineIntegration.js +12 -0
  25. package/lib/commonjs/offline/useOfflineIntegration.web.js +11 -0
  26. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.js +46 -0
  27. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.web.js +13 -0
  28. package/lib/commonjs/platform/DataverseDataSources.js +14 -0
  29. package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +49 -0
  30. package/lib/commonjs/platform/GlobalDiscovery.js +51 -0
  31. package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +6 -106
  32. package/lib/commonjs/provider/PowerAppsHostProvider.js +156 -25
  33. package/lib/commonjs/provider/PowerAppsHostProvider.web.js +41 -0
  34. package/lib/commonjs/provider/PowerAppsProvider.js +229 -133
  35. package/lib/commonjs/provider/SessionDetailsGesture.js +216 -0
  36. package/lib/commonjs/telemetry/OfflineSdkTelemetry.js +95 -0
  37. package/lib/commonjs/telemetry/OfflineSdkTelemetry.web.js +9 -0
  38. package/lib/commonjs/telemetry/index.js +22 -3
  39. package/lib/module/auth/AuthContext.js +74 -18
  40. package/lib/module/auth/AuthContext.web.js +26 -0
  41. package/lib/module/auth/completePowerAppsAuthSession.js +11 -0
  42. package/lib/module/bridge/NativePowerAppsBridge.js +21 -18
  43. package/lib/module/bridge/PowerPagesBridge.js +151 -0
  44. package/lib/module/bridge/bridgeState.js +34 -0
  45. package/lib/module/connections/ConnectionSetupScreen.js +460 -81
  46. package/lib/module/connections/PowerPlatformConnectionApi.js +932 -0
  47. package/lib/module/connections/connectionMetadata.js +112 -0
  48. package/lib/module/connections/connectionState.js +82 -0
  49. package/lib/module/connections/disambiguate.js +19 -12
  50. package/lib/module/connections/resolveConnections.js +342 -0
  51. package/lib/module/connections/types.js +91 -0
  52. package/lib/module/{platform → connections}/useConnectionRefs.js +129 -66
  53. package/lib/module/connections/useConnectionSetup.js +113 -54
  54. package/lib/module/controls/FilePicker.js +6 -0
  55. package/lib/module/controls/ImagePicker.js +8 -0
  56. package/lib/module/index.js +14 -6
  57. package/lib/module/logger.js +8 -6
  58. package/lib/module/offline/createOfflineHostActivationCallbacks.js +55 -0
  59. package/lib/module/offline/useOfflineIntegration.js +3 -0
  60. package/lib/module/offline/useOfflineIntegration.web.js +7 -0
  61. package/lib/module/offline/useOfflineIntegrationWithStartupGate.js +42 -0
  62. package/lib/module/offline/useOfflineIntegrationWithStartupGate.web.js +9 -0
  63. package/lib/module/platform/DataverseDataSources.js +10 -0
  64. package/lib/module/platform/DataverseGlobalDiscoveryApi.js +45 -0
  65. package/lib/module/platform/GlobalDiscovery.js +45 -0
  66. package/lib/module/platform/PowerPlatformEnvironmentApi.js +5 -104
  67. package/lib/module/provider/PowerAppsHostProvider.js +159 -28
  68. package/lib/module/provider/PowerAppsHostProvider.web.js +36 -0
  69. package/lib/module/provider/PowerAppsProvider.js +233 -137
  70. package/lib/module/provider/SessionDetailsGesture.js +211 -0
  71. package/lib/module/telemetry/OfflineSdkTelemetry.js +91 -0
  72. package/lib/module/telemetry/OfflineSdkTelemetry.web.js +5 -0
  73. package/lib/module/telemetry/index.js +15 -4
  74. package/lib/typescript/commonjs/auth/AuthContext.d.ts +3 -1
  75. package/lib/typescript/commonjs/auth/AuthContext.web.d.ts +21 -0
  76. package/lib/typescript/commonjs/auth/completePowerAppsAuthSession.d.ts +8 -0
  77. package/lib/typescript/commonjs/bridge/PowerPagesBridge.d.ts +18 -0
  78. package/lib/typescript/commonjs/bridge/bridgeState.d.ts +5 -0
  79. package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +28 -7
  80. package/lib/typescript/commonjs/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  81. package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +66 -0
  82. package/lib/typescript/commonjs/connections/connectionState.d.ts +16 -0
  83. package/lib/typescript/commonjs/connections/disambiguate.d.ts +4 -2
  84. package/lib/typescript/commonjs/{platform → connections}/resolveConnections.d.ts +19 -19
  85. package/lib/typescript/commonjs/connections/types.d.ts +129 -1
  86. package/lib/typescript/commonjs/{platform → connections}/useConnectionRefs.d.ts +33 -24
  87. package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +12 -8
  88. package/lib/typescript/commonjs/controls/FilePicker.d.ts +7 -1
  89. package/lib/typescript/commonjs/controls/ImagePicker.d.ts +9 -1
  90. package/lib/typescript/commonjs/index.d.ts +20 -10
  91. package/lib/typescript/commonjs/logger.d.ts +4 -4
  92. package/lib/typescript/commonjs/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  93. package/lib/typescript/commonjs/offline/useOfflineIntegration.d.ts +2 -0
  94. package/lib/typescript/commonjs/offline/useOfflineIntegration.web.d.ts +4 -0
  95. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  96. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  97. package/lib/typescript/commonjs/platform/DataverseDataSources.d.ts +27 -0
  98. package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  99. package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +4 -0
  100. package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  101. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +29 -18
  102. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.web.d.ts +5 -0
  103. package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +32 -10
  104. package/lib/typescript/commonjs/provider/SessionDetailsGesture.d.ts +13 -0
  105. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  106. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  107. package/lib/typescript/commonjs/telemetry/index.d.ts +13 -1
  108. package/lib/typescript/module/auth/AuthContext.d.ts +3 -1
  109. package/lib/typescript/module/auth/AuthContext.web.d.ts +21 -0
  110. package/lib/typescript/module/auth/completePowerAppsAuthSession.d.ts +8 -0
  111. package/lib/typescript/module/bridge/PowerPagesBridge.d.ts +18 -0
  112. package/lib/typescript/module/bridge/bridgeState.d.ts +5 -0
  113. package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +28 -7
  114. package/lib/typescript/module/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  115. package/lib/typescript/module/connections/connectionMetadata.d.ts +66 -0
  116. package/lib/typescript/module/connections/connectionState.d.ts +16 -0
  117. package/lib/typescript/module/connections/disambiguate.d.ts +4 -2
  118. package/lib/typescript/module/{platform → connections}/resolveConnections.d.ts +19 -19
  119. package/lib/typescript/module/connections/types.d.ts +129 -1
  120. package/lib/typescript/module/{platform → connections}/useConnectionRefs.d.ts +33 -24
  121. package/lib/typescript/module/connections/useConnectionSetup.d.ts +12 -8
  122. package/lib/typescript/module/controls/FilePicker.d.ts +7 -1
  123. package/lib/typescript/module/controls/ImagePicker.d.ts +9 -1
  124. package/lib/typescript/module/index.d.ts +24 -14
  125. package/lib/typescript/module/logger.d.ts +4 -4
  126. package/lib/typescript/module/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  127. package/lib/typescript/module/offline/useOfflineIntegration.d.ts +2 -0
  128. package/lib/typescript/module/offline/useOfflineIntegration.web.d.ts +4 -0
  129. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  130. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  131. package/lib/typescript/module/platform/DataverseDataSources.d.ts +27 -0
  132. package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  133. package/lib/typescript/module/platform/GlobalDiscovery.d.ts +4 -0
  134. package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  135. package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +29 -18
  136. package/lib/typescript/module/provider/PowerAppsHostProvider.web.d.ts +5 -0
  137. package/lib/typescript/module/provider/PowerAppsProvider.d.ts +34 -12
  138. package/lib/typescript/module/provider/SessionDetailsGesture.d.ts +13 -0
  139. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  140. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  141. package/lib/typescript/module/telemetry/index.d.ts +13 -1
  142. package/package.json +43 -18
  143. package/scripts/build-ios-base.js +66 -27
  144. package/scripts/bundle.js +212 -5
  145. package/scripts/generate-connector-schemas.js +8 -6
  146. package/scripts/metro-logger.js +213 -0
  147. package/scripts/start-web.mjs +137 -0
  148. package/scripts/upgrade/runtime.js +463 -0
  149. package/scripts/upgrade/system.js +244 -0
  150. package/scripts/upgrade-authoring.js +534 -0
  151. package/scripts/upgrade.js +188 -0
  152. package/scripts/wrap.js +536 -0
  153. package/lib/commonjs/platform/PowerPlatformConnectionApi.js +0 -606
  154. package/lib/commonjs/platform/resolveConnections.js +0 -264
  155. package/lib/module/platform/PowerPlatformConnectionApi.js +0 -595
  156. package/lib/module/platform/resolveConnections.js +0 -259
@@ -7,7 +7,9 @@
7
7
  * (`getAppLogger` / `configureAppLogger`). This module re-exports those
8
8
  * alongside the canonical host operation-name constants.
9
9
  */
10
- export { getAppLogger, configureAppLogger } from '@microsoft/power-apps-native-common';
10
+ import { HttpClient } from '@microsoft/power-apps-native-common/http';
11
+ export { getAppLogger, configureAppLogger, getCustomerTelemetryLogger } from '@microsoft/power-apps-native-common';
12
+ export type { ICustomerTelemetryLogger } from '@microsoft/power-apps-native-common';
11
13
  /**
12
14
  * Canonical operation names for host package telemetry.
13
15
  * Follow the `PowerAppsHost.<Subsystem>.<Action>` convention so events are
@@ -34,15 +36,25 @@ export declare const HostOperationNames: {
34
36
  readonly BridgeTokenAcquireFailed: "PowerAppsHost.Bridge.TokenAcquire.Failed";
35
37
  /** Top-level React error boundary caught an unhandled JS error. */
36
38
  readonly RuntimeUnhandledJsError: "PowerAppsHost.Runtime.UnhandledJsError";
39
+ /** Power Platform RP HTTP request, including backend correlation IDs. */
40
+ readonly PlatformHttpRequest: "PowerAppsHost.Platform.HttpRequest";
37
41
  /** Resolve Dataverse instanceUrl from Power Platform environment API. */
38
42
  readonly PlatformFetchInstanceUrl: "PowerAppsHost.Platform.FetchInstanceUrl";
39
43
  /** useConnectionRefs failed to resolve connections (recoverable). Recorded only on failure. */
40
44
  readonly PlatformLoadConnectionsFailed: "PowerAppsHost.Platform.LoadConnections.Failed";
41
45
  /** Create a new Power Platform connection. */
42
46
  readonly PlatformCreateConnection: "PowerAppsHost.Platform.CreateConnection";
47
+ /** Repair an existing Power Platform connection. */
48
+ readonly PlatformRepairConnection: "PowerAppsHost.Platform.RepairConnection";
49
+ /** Poll a connection until it becomes active. */
50
+ readonly PlatformPollConnectionStatus: "PowerAppsHost.Platform.PollConnectionStatus";
43
51
  /** Resolve app connection references for the current launch. */
44
52
  readonly PlatformResolveConnectionRefs: "PowerAppsHost.Platform.ResolveConnectionRefs";
45
53
  /** Grant this app access to a Power Platform connection ACL. */
46
54
  readonly PlatformConnectionAclGrant: "PowerAppsHost.Platform.ConnectionAclGrant";
55
+ /** Installed Offline SDK predates the SDK-owned routing contract. */
56
+ readonly OfflineRoutingContractUnsupported: "PowerAppsHost.Offline.RoutingContract.Unsupported";
47
57
  };
58
+ export declare const bridgeHttpClient: HttpClient;
59
+ export declare const platformHttpClient: HttpClient;
48
60
  //# sourceMappingURL=index.d.ts.map
@@ -46,9 +46,11 @@ export interface AuthProviderProps {
46
46
  * Pass explicitly only to override the default (e.g. in tests).
47
47
  */
48
48
  intuneConfig?: IntuneConfig;
49
+ /** Token audiences that must be available before the account is considered signed in. */
50
+ requiredScopes?: string[];
49
51
  children: React.ReactNode;
50
52
  }
51
- export declare function AuthProvider({ msalConfig, intuneConfig, children }: AuthProviderProps): React.JSX.Element;
53
+ export declare function AuthProvider({ msalConfig, intuneConfig, requiredScopes, children, }: AuthProviderProps): React.JSX.Element;
52
54
  /**
53
55
  * Returns the current auth state from the nearest <AuthProvider>.
54
56
  * Must be called within the AuthProvider tree.
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { IntuneConfig, MsalAuthConfig } from '@microsoft/power-apps-native-auth';
3
+ export interface AuthState {
4
+ isLoading: boolean;
5
+ isAuthReady: boolean;
6
+ isSignedIn: boolean;
7
+ hasRealAccount: boolean;
8
+ error: Error | null;
9
+ acquireToken: (scopes: string[]) => Promise<string | null>;
10
+ signIn: () => Promise<void>;
11
+ signOut: () => Promise<void>;
12
+ }
13
+ export interface AuthProviderProps {
14
+ msalConfig: MsalAuthConfig;
15
+ intuneConfig?: IntuneConfig;
16
+ requiredScopes?: string[];
17
+ children: React.ReactNode;
18
+ }
19
+ export declare function AuthProvider({ children }: AuthProviderProps): React.JSX.Element;
20
+ export declare function useAuth(): AuthState;
21
+ //# sourceMappingURL=AuthContext.web.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { WebBrowserCompleteAuthSessionOptions, WebBrowserCompleteAuthSessionResult } from 'expo-web-browser';
2
+ /**
3
+ * Completes an Expo web authentication popup when the current route is its
4
+ * redirect target. Call this at module initialization in the OAuth callback
5
+ * route; navigation after completion remains application-owned.
6
+ */
7
+ export declare function completePowerAppsAuthSession(options?: WebBrowserCompleteAuthSessionOptions): WebBrowserCompleteAuthSessionResult;
8
+ //# sourceMappingURL=completePowerAppsAuthSession.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { AppConnectionReference, CdsDataSourceConfig } from './NativePowerAppsBridge.js';
2
+ export type PowerPagesBridgeOptions = {
3
+ dataSources: CdsDataSourceConfig[];
4
+ connections: Record<string, AppConnectionReference>;
5
+ };
6
+ export declare class PowerPagesBridge {
7
+ private options;
8
+ constructor(options: PowerPagesBridgeOptions);
9
+ updateOptions(options: PowerPagesBridgeOptions): void;
10
+ initialize(): Promise<void>;
11
+ createRequestBody(config: {
12
+ body?: string | Uint8Array | ArrayBuffer | Blob;
13
+ }): Blob | string | Uint8Array | ArrayBuffer;
14
+ executePluginAsync<T = unknown>(pluginName: string, pluginAction: string, params: unknown[]): Promise<T>;
15
+ private sendHttpAsync;
16
+ }
17
+ export declare function setupPowerPagesHost(options: PowerPagesBridgeOptions): void;
18
+ //# sourceMappingURL=PowerPagesBridge.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { NativeBridgeOptions } from './NativePowerAppsBridge.js';
2
+ export declare function getRequestBodyForMethod(method: string, body: BodyInit | null): BodyInit | null;
3
+ export declare function assertSuccessfulHttpStatus(status: number, method: string): void;
4
+ export declare function updateBridgeOptionsInPlace(current: NativeBridgeOptions, next: NativeBridgeOptions): NativeBridgeOptions;
5
+ //# sourceMappingURL=bridgeState.d.ts.map
@@ -39,12 +39,23 @@
39
39
  * the consuming app decides how to render it (full-screen, modal, etc.).
40
40
  */
41
41
  import React from 'react';
42
- import type { ConnectorSchema } from '../platform/useConnectionRefs.js';
42
+ import type { ConnectionConsentDetails, ResourceConsentRequirement } from '../connections/types.js';
43
+ import type { ConnectorSchema } from './useConnectionRefs.js';
43
44
  export interface MissingConnectorEntry {
44
45
  /** Connector API ID (e.g. "/providers/Microsoft.PowerApps/apis/shared_office365users"). */
45
46
  apiId: string;
46
47
  /** Local ref ID from power.config.json (for correlation). */
47
48
  localRefId: string;
49
+ /** Canonical connector short name. Supplied by useConnectionRefs. */
50
+ connectorId?: string;
51
+ dataSources?: string[];
52
+ displayName?: string;
53
+ iconUri?: string;
54
+ appActions?: string[];
55
+ gatewayObjectIdHint?: string;
56
+ authenticationType?: string;
57
+ parameterSetName?: string;
58
+ sharedConnectionId?: string;
48
59
  }
49
60
  export interface ConnectionSetupScreenProps {
50
61
  /**
@@ -60,11 +71,20 @@ export interface ConnectionSetupScreenProps {
60
71
  environmentId: string;
61
72
  region?: string;
62
73
  acquireToken: (scopes: string[]) => Promise<string | null>;
74
+ onSignOut?: () => void | Promise<void>;
63
75
  /**
64
76
  * Called when all missing connections have been resolved.
65
- * `resolvedIds` maps apiId → connectionId for all newly created connections.
77
+ * `resolvedIds` maps localRefId → connectionId for all newly created connections.
66
78
  */
67
- onAllConnected: (resolvedIds: Record<string, string>) => void;
79
+ onAllConnected: (resolvedIds: Record<string, string>) => void | Promise<void>;
80
+ /** All connector usages requiring user approval, including already-resolved references. */
81
+ consentDetails?: ConnectionConsentDetails[];
82
+ /** Additional protected resources, such as cross-environment Dataverse instances. */
83
+ resourceConsents?: ResourceConsentRequirement[];
84
+ /** Called when the user explicitly declines access. */
85
+ onConsentDeclined?: () => void | Promise<void>;
86
+ /** Whether to show app-level Review Access after authentication. Defaults to true. */
87
+ showReview?: boolean;
68
88
  /**
69
89
  * If provided, a "Skip" button is shown. Useful for non-blocking connection flows.
70
90
  * The app should handle the case where connections remain unresolved.
@@ -76,11 +96,12 @@ export interface ConnectionSetupScreenProps {
76
96
  * access on each newly created connection, fixing the APIM 403 for
77
97
  * third-party app tokens.
78
98
  */
79
- isvClientId?: string;
99
+ isvClientId: string;
80
100
  /**
81
101
  * Optional custom renderer for the OAuth WebView.
82
102
  * Receives the consent URL and a dismiss callback.
83
- * If not provided, `Linking.openURL()` is used to open the URL in the system browser.
103
+ * If not provided, Expo's system authentication browser is used.
104
+ * Custom views should pass their final redirect URL to `onDone` when available.
84
105
  *
85
106
  * @example
86
107
  * // Using react-native-webview:
@@ -91,7 +112,7 @@ export interface ConnectionSetupScreenProps {
91
112
  * </Modal>
92
113
  * )}
93
114
  */
94
- renderOAuthWebView?: (url: string, onDone: () => void) => React.ReactNode;
115
+ renderOAuthWebView?: (url: string, onDone: (redirectUrl?: string) => void) => React.ReactNode;
95
116
  /** Optional title override (default: "Set up connections"). */
96
117
  title?: string;
97
118
  }
@@ -103,5 +124,5 @@ export interface ConnectionSetupScreenProps {
103
124
  * resolved `onAllConnected` fires and the parent app should unmount this
104
125
  * component and proceed to launch the app.
105
126
  */
106
- export declare function ConnectionSetupScreen({ missingConnectors, schemaMap, environmentId, region, acquireToken, isvClientId, onAllConnected, onSkip, renderOAuthWebView, title, }: ConnectionSetupScreenProps): React.JSX.Element;
127
+ export declare function ConnectionSetupScreen({ missingConnectors, schemaMap, environmentId, region, acquireToken, onSignOut, isvClientId, onAllConnected, onSkip, consentDetails, resourceConsents, onConsentDeclined, showReview, renderOAuthWebView, title, }: ConnectionSetupScreenProps): React.JSX.Element;
107
128
  //# sourceMappingURL=ConnectionSetupScreen.d.ts.map
@@ -7,14 +7,12 @@
7
7
  * These mirror the endpoints used by ConnectorsApi in @microsoft/power-apps-common
8
8
  * but are implemented as plain async functions so they have no external dependencies.
9
9
  */
10
- import type { NativeConnectionInstance } from '../connections/types.js';
10
+ import type { DatabaseReference } from '../platform/DataverseDataSources.js';
11
+ import type { ConnectionInput, ConnectionParameterSet, ConnectionRequirement, ConnectionUsageInput, NativeConnectionInstance, ResourceConsentRequirement } from './types.js';
11
12
  import type { AppConnectionReference } from '../bridge/NativePowerAppsBridge.js';
12
- /**
13
- * Token scope for the Power Apps RP (api.powerapps.com).
14
- * Required when calling modifyPermissions to register a service principal
15
- * in the connection ACE so that APIM accepts third-party app tokens at runtime.
16
- */
17
- export declare const SERVICE_POWERAPPS_SCOPE = "https://service.powerapps.com/.default";
13
+ export declare class AppLaunchAccessDeniedError extends Error {
14
+ constructor();
15
+ }
18
16
  /** Subset of connector metadata returned by the Power Platform API. */
19
17
  export interface ConnectorMetadata {
20
18
  /** Short connector name, e.g. "shared_office365users". */
@@ -25,8 +23,15 @@ export interface ConnectorMetadata {
25
23
  iconUri: string;
26
24
  /** Description text. */
27
25
  description: string;
28
- /** Whether this is a first-party (Microsoft-published) connector. */
29
- isFirstParty: boolean;
26
+ /** Environment-specific APIM runtime URL used for connector requests. */
27
+ primaryRuntimeUrl: string;
28
+ scopes: {
29
+ will: string[];
30
+ wont: string[];
31
+ };
32
+ /** Whether the connector authenticates through an OAuth consent flow. */
33
+ hasOAuthParameter: boolean;
34
+ parameterSets: ConnectionParameterSet[];
30
35
  }
31
36
  /**
32
37
  * Fetch metadata for a single connector from the Power Platform API.
@@ -43,6 +48,8 @@ export declare function fetchConnectorMetadata(connectorId: string, environmentI
43
48
  * Returns only the `NativeConnectionInstance` shape used by the disambiguation layer.
44
49
  */
45
50
  export declare function fetchConnectionsForConnector(connectorId: string, environmentId: string, region: string, token: string): Promise<NativeConnectionInstance[]>;
51
+ /** Delete a single connection instance from the user's environment. */
52
+ export declare function deleteConnection(connectorId: string, connectionId: string, environmentId: string, region: string, token: string): Promise<boolean>;
46
53
  /**
47
54
  * Result of initiating an OAuth connection creation.
48
55
  *
@@ -51,8 +58,7 @@ export declare function fetchConnectionsForConnector(connectorId: string, enviro
51
58
  * user can complete the OAuth consent flow. Poll `pollConnectionStatus`
52
59
  * until the status changes to "Connected".
53
60
  *
54
- * `connected` — the connection was created and is already Connected (e.g.,
55
- * first-party SSO connections that do not need explicit OAuth consent).
61
+ * `connected` — the connection resource was created in Connected state.
56
62
  *
57
63
  * `error` — creation failed; `message` contains the error description.
58
64
  */
@@ -71,7 +77,7 @@ export type CreateConnectionResult = {
71
77
  * Create a new connection for a connector in the user's environment.
72
78
  *
73
79
  * Calls:
74
- * POST {envBase}/connectivity/apis/{connectorId}/connections
80
+ * PUT {envBase}/connectivity/connectors/{connectorId}/connections/{connectionId}
75
81
  *
76
82
  * If the response contains a `consentLink`, the connection needs OAuth
77
83
  * completion (caller should open the URL and then poll `pollConnectionStatus`).
@@ -86,7 +92,8 @@ export type CreateConnectionResult = {
86
92
  * will redirect the user here after consent. Defaults to
87
93
  * the standard native-client redirect accepted by Power Platform.
88
94
  */
89
- export declare function createConnection(connectorId: string, environmentId: string, region: string, token: string, displayName?: string, oauthRedirectUrl?: string): Promise<CreateConnectionResult>;
95
+ export declare function createConnection(connectorId: string, environmentId: string, region: string, token: string, displayName?: string, oauthRedirectUrl?: string, input?: ConnectionInput): Promise<CreateConnectionResult>;
96
+ export declare function repairConnection(connectorId: string, connectionName: string, environmentId: string, region: string, token: string, oauthRedirectUrl?: string, input?: ConnectionInput, requiresApiConsent?: boolean): Promise<CreateConnectionResult>;
90
97
  /**
91
98
  * Poll a connection's status until it is "Connected" or a timeout is reached.
92
99
  *
@@ -101,6 +108,7 @@ export declare function createConnection(connectorId: string, environmentId: str
101
108
  export declare function pollConnectionStatus(connectorId: string, connectionName: string, environmentId: string, region: string, acquireToken: (scopes: string[]) => Promise<string | null>, options?: {
102
109
  intervalMs?: number;
103
110
  timeoutMs?: number;
111
+ signal?: AbortSignal;
104
112
  }): Promise<NativeConnectionInstance | null>;
105
113
  /**
106
114
  * Confirm a consent code returned by the APIM consent server in the OAuth
@@ -141,13 +149,38 @@ export interface AppLaunchResult {
141
149
  * has no linked Dataverse database).
142
150
  */
143
151
  dataverseOrgUrl: string;
152
+ /** Dataverse table metadata returned by the app launch endpoint. */
153
+ databaseReferences: Record<string, DatabaseReference>;
144
154
  /**
145
155
  * Connector short-names (e.g. "shared_office365users") for which the
146
156
  * launch API found no "Connected" connection instance for the signed-in
147
157
  * user. These connectors need the connection setup flow.
148
158
  */
149
159
  missingConnectors: string[];
160
+ /** Missing requirements keyed by the app's local connection-reference ID. */
161
+ missingConnectionReferences: ConnectionRequirement[];
162
+ /** Every app requirement, including references resolved by the launch API. */
163
+ connectionRequirements: ConnectionRequirement[];
164
+ /** Connected candidates retained for explicit per-reference disambiguation. */
165
+ connectionCandidates: Record<string, NativeConnectionInstance[]>;
166
+ /** Non-connector protected resources requiring explicit user disclosure. */
167
+ resourceConsents: ResourceConsentRequirement[];
168
+ /** Configuration errors that make bridge connection binding ambiguous. */
169
+ configurationErrors: string[];
170
+ /** Durable app-to-connection bindings returned by launch or the app connections API. */
171
+ registeredConnectionUsages: RegisteredConnectionUsage[];
172
+ /** True when at least one selected local reference/action is not durably registered. */
173
+ requiresConnectionConsent: boolean;
174
+ }
175
+ export interface RegisteredConnectionUsage {
176
+ reference: string;
177
+ apiId: string;
178
+ connectionId: string;
179
+ appActions: string[];
150
180
  }
181
+ export declare function fetchAppConnectionUsages(appId: string, environmentId: string, region: string, token: string): Promise<RegisteredConnectionUsage[]>;
182
+ export declare function postConnectionUsage(appId: string, usage: ConnectionUsageInput, environmentId: string, region: string, token: string): Promise<void>;
183
+ export declare function reportScopeConsents(appId: string, usages: ConnectionUsageInput[], environmentId: string, region: string, token: string): Promise<void>;
151
184
  /**
152
185
  * Fetch app launch data from the Power Platform environment-scoped launch
153
186
  * endpoint and process it into the shape the NativePowerAppsBridge needs.
@@ -160,7 +193,7 @@ export interface AppLaunchResult {
160
193
  * — Dataverse org URL
161
194
  *
162
195
  * Endpoint (environment-scoped, same base as all Power Platform API calls):
163
- * GET {envEndpoint}/powerapps/apps/{appId}/launch
196
+ * POST {envEndpoint}/powerapps/apps/{appId}/launch
164
197
  * ?api-version=2&lastKnownGoodPublishedVersion=true
165
198
  *
166
199
  * Authentication: bearer token for {@link powerPlatformScope}`(region)`.
@@ -169,37 +202,13 @@ export interface AppLaunchResult {
169
202
  * @param environmentId - Environment GUID.
170
203
  * @param region - Cluster region (default "prod").
171
204
  * @param token - Bearer token for {@link powerPlatformScope}`(region)`.
172
- * @returns Processed launch data, or `null` if the call fails.
205
+ * @returns Processed launch data, or `null` when the app is not found.
173
206
  */
174
207
  export declare function fetchAppLaunchData(appId: string, environmentId: string, region: string, token: string): Promise<AppLaunchResult | null>;
175
208
  /**
176
- * Decode the `oid` (object ID) claim from a JWT access token.
177
- *
178
- * The oid claim is in the base64url-encoded payload section (middle part).
179
- * Available in Hermes (React Native) via the global `atob`.
180
- */
181
- export declare function parseJwtOid(jwtToken: string): string | null;
182
- /**
183
- * Add the ISV's AAD application (client) ID to the connection's ACL AppIds
184
- * list via the Power Apps RP `addAadAppToConnectionAcl` endpoint.
185
- *
186
- * The RP finds the user's existing ACE (identified by `userOid`) and appends
187
- * `isvClientId` to its `AppIds` list. APIM's stage-2 token check verifies
188
- * that the requesting token's `appid` is present in this list, so without
189
- * this call APIM returns 403 "missing connection ACL" for third-party tokens.
190
- *
191
- * POST https://api.powerapps.com/providers/Microsoft.PowerApps/environments/{environmentId}
192
- * /apis/{connectorId}/connections/{connectionId}/addAadAppToConnectionAcl
193
- * ?api-version=2016-11-01
194
- *
195
- * Body: { "aadApplicationId": "<ISV client ID>", "objectId": "<user OID>" }
196
- *
197
- * @param connectorId - Connector short name (e.g. "shared_office365users").
198
- * @param connectionId - Bare 32-char hex connection ID.
199
- * @param environmentId - Environment GUID.
200
- * @param isvClientId - The ISV's AAD application (client) ID.
201
- * @param userOid - The signed-in user's AAD object ID (oid JWT claim).
202
- * @param token - Bearer token for `https://service.powerapps.com/.default`.
209
+ * Grant the calling application's delegated access to a connection for the
210
+ * signed-in user. The backend derives both identities from the token and
211
+ * selects the most specific applicable user, group, or tenant ACL.
203
212
  */
204
- export declare function addAadAppToConnectionAcl(connectorId: string, connectionId: string, environmentId: string, isvClientId: string, userOid: string, token: string): Promise<boolean>;
213
+ export declare function grantConnectionUserConsent(connectorId: string, connectionId: string, environmentId: string, region: string, token: string): Promise<boolean>;
205
214
  //# sourceMappingURL=PowerPlatformConnectionApi.d.ts.map
@@ -0,0 +1,66 @@
1
+ import type { ConnectionInput, ConnectionParameterDefinition, ConnectionParameterSet, ConnectionUsageInput } from './types.js';
2
+ export interface ConsentLinkDefinition {
3
+ redirectUrl: string;
4
+ }
5
+ export type SerializedConnectionParameters = {
6
+ connectionParameters: ConnectionInput['parameters'];
7
+ } | {
8
+ connectionParametersSet: {
9
+ name: string;
10
+ values: Record<string, {
11
+ value: ConnectionInput['parameters'][string];
12
+ }>;
13
+ };
14
+ };
15
+ export interface RawConnectionParameter {
16
+ type?: string;
17
+ defaultValue?: string | boolean | number;
18
+ uiDefinition?: {
19
+ displayName?: string;
20
+ constraints?: {
21
+ required?: string | boolean;
22
+ hidden?: string | boolean;
23
+ capability?: string[];
24
+ allowedValues?: Array<{
25
+ value?: string;
26
+ displayName?: string;
27
+ }>;
28
+ };
29
+ };
30
+ }
31
+ export interface RawConnectionParameterSet {
32
+ name?: string;
33
+ uiDefinition?: {
34
+ displayName?: string;
35
+ };
36
+ connectionParameters?: Record<string, RawConnectionParameter>;
37
+ parameters?: Record<string, RawConnectionParameter>;
38
+ }
39
+ export declare function parseConnectionParameters(parameters: Record<string, RawConnectionParameter> | undefined): ConnectionParameterDefinition[];
40
+ export declare function buildConnectionParameterSets(connectionParameters: Record<string, RawConnectionParameter> | undefined, parameterSets: RawConnectionParameterSet[] | undefined): ConnectionParameterSet[];
41
+ export declare function hasOAuthParameter(parameters: Record<string, RawConnectionParameter> | undefined): boolean;
42
+ export declare function buildConnectionUserConsentUrl(environmentEndpoint: string, connectorId: string, connectionId: string): string;
43
+ export declare function getAppLaunchFailureMessage(status: number, statusText: string, responseText: string): string | null;
44
+ export declare function isAppLaunchAccessDenied(status: number, responseText: string): boolean;
45
+ export declare function buildConsentLinkDefinition(redirectUrl: string): ConsentLinkDefinition;
46
+ export declare function serializeConnectionParameters(input?: ConnectionInput): SerializedConnectionParameters;
47
+ export declare function buildConnectionUsageUrl(environmentBaseUrl: string, environmentId: string, usage: ConnectionUsageInput): string;
48
+ export declare function buildConnectionUsageRequest(appId: string, usage: ConnectionUsageInput): {
49
+ properties: {
50
+ reference: string;
51
+ resourceId: string;
52
+ appActions: string[];
53
+ };
54
+ };
55
+ export declare function buildScopeConsentUrl(environmentBaseUrl: string, appId: string): string;
56
+ export declare function buildScopeConsentRequest(usages: ConnectionUsageInput[]): {
57
+ consents: Array<{
58
+ connectionId: string;
59
+ consentType: 'userConsent';
60
+ scopes: {
61
+ will: string[];
62
+ wont: string[];
63
+ };
64
+ }>;
65
+ };
66
+ //# sourceMappingURL=connectionMetadata.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { AppLaunchResult } from './PowerPlatformConnectionApi.js';
2
+ import type { RegisteredConnectionUsage } from './PowerPlatformConnectionApi.js';
3
+ import type { AppConnectionReference } from '../bridge/NativePowerAppsBridge.js';
4
+ import type { ConnectionRequirement } from './types.js';
5
+ export declare function isTransientConnectionConsentStatus(status: number): boolean;
6
+ export declare function shouldGrantConnectionUserConsent(requirement: Pick<ConnectionRequirement, 'sharedConnectionId'>, runningInDevPlayer: boolean): boolean;
7
+ export declare function getConnectionNamesRequiringAclGrant(connectionRefs: Record<string, AppConnectionReference>, connectionRequirements: ConnectionRequirement[]): string[];
8
+ export declare function invalidateFailedAclGrants(result: AppLaunchResult, failedConnectionNames: ReadonlySet<string>): void;
9
+ export declare function selectLaunchConnection(result: AppLaunchResult, localRefId: string, connectionId: string): boolean;
10
+ export declare function getUnregisteredConnectionRequirements(result: AppLaunchResult, usages?: RegisteredConnectionUsage[]): ConnectionRequirement[];
11
+ export declare function applyRegisteredConnectionSelections(result: AppLaunchResult, usages: RegisteredConnectionUsage[]): void;
12
+ export declare function hasRegisteredConnectionConsent(result: AppLaunchResult, usages?: RegisteredConnectionUsage[]): boolean;
13
+ export declare function applyRegisteredConnectionUsages(result: AppLaunchResult, usages: RegisteredConnectionUsage[]): void;
14
+ export declare function shouldPersistConnectionUsages(runningInDevPlayer: boolean, appId: string | undefined): boolean;
15
+ export declare function shouldShowConnectionReview(runningInDevPlayer: boolean, requiresConnectionConsent: boolean, hasResourceConsents: boolean): boolean;
16
+ //# sourceMappingURL=connectionState.d.ts.map
@@ -27,6 +27,7 @@ import type { NativeConnectionInstance, NativeConnectionResolution } from './typ
27
27
  export declare function disambiguateConnections(connectionReferences: Record<string, {
28
28
  id: string;
29
29
  dataSources: string[];
30
+ sharedConnectionId?: string;
30
31
  }>, allConnectionsByApiId: Record<string, NativeConnectionInstance[]>): NativeConnectionResolution[];
31
32
  /**
32
33
  * Extract the connection UUID from a raw connection name returned by the API.
@@ -36,8 +37,9 @@ export declare function disambiguateConnections(connectionReferences: Record<str
36
37
  * "abc12345def6789012345678901234ab" (bare UUID, no dashes)
37
38
  * "abc12345-def6-7890-1234-5678901234ab" (UUID with dashes)
38
39
  *
39
- * Returns the 32-char hex ID (dashes stripped) or the raw string if no UUID
40
- * pattern is found.
40
+ * Returns the terminal resource name exactly as supplied by Power Platform.
41
+ * Some connectors require dashed GUIDs while others use compact IDs.
41
42
  */
42
43
  export declare function extractConnectionId(rawName: string): string;
44
+ export declare function connectionIdsEqual(left: string, right: string): boolean;
43
45
  //# sourceMappingURL=disambiguate.d.ts.map
@@ -5,19 +5,18 @@
5
5
  * useConnectionRefs:
6
6
  *
7
7
  * • resolveViaStaticRefs — per-connector resolution using the static
8
- * connectionReferences map from power.config.json. Used by the Dev Player
9
- * and during local development (no appId) or when the launch API is
10
- * unavailable. Handles pre-disambiguation ACL grants so inaccessible
11
- * connections are excluded before the user is asked to pick.
8
+ * connectionReferences map from power.config.json. Used only by Dev Player
9
+ * for unpublished local apps. Handles pre-disambiguation ACL grants so
10
+ * inaccessible connections are excluded before the user is asked to pick.
12
11
  *
13
- * • applyAclGrants — post-resolution ACL grants used by the fast path
12
+ * • applyAclGrants — post-resolution user consent used by the fast path
14
13
  * (production APKs via fetchAppLaunchData).
15
14
  *
16
15
  * Both helpers return / consume the shared AppLaunchResult shape so the
17
16
  * hook orchestrator can handle them uniformly.
18
17
  */
19
18
  import type { AppLaunchResult } from './PowerPlatformConnectionApi.js';
20
- import type { OnDisambiguationNeeded, OnMissingConnection } from '../connections/types.js';
19
+ import type { ConnectionReferenceConfig, ConnectionRequirement, OnDisambiguationNeeded, OnMissingConnection } from './types.js';
21
20
  import type { AppConnectionReference } from '../bridge/NativePowerAppsBridge.js';
22
21
  /**
23
22
  * Connector schema entry generated by `generate-connector-schemas`.
@@ -28,6 +27,10 @@ export interface ConnectorSchema {
28
27
  name: string;
29
28
  properties: {
30
29
  primaryRuntimeUrl: string;
30
+ scopes?: {
31
+ will?: string[];
32
+ wont?: string[];
33
+ };
31
34
  };
32
35
  }
33
36
  export interface StaticRefsOptions {
@@ -35,19 +38,16 @@ export interface StaticRefsOptions {
35
38
  * Static connectionReferences from power.config.json.
36
39
  * Shape: { [refId]: { id: string; dataSources: string[] } }
37
40
  */
38
- connectionReferences: Record<string, {
39
- id: string;
40
- dataSources: string[];
41
- }>;
41
+ connectionReferences: Record<string, ConnectionReferenceConfig>;
42
42
  /** Connector schema map keyed by data source name. */
43
43
  schemaMap: Record<string, ConnectorSchema>;
44
44
  environmentId: string;
45
45
  region: string;
46
- /** Used for ACL grants and the Dataverse instanceUrl fetch. */
46
+ /** Used for connection consent and the Dataverse instanceUrl fetch. */
47
47
  acquireToken: (scopes: string[]) => Promise<string | null>;
48
48
  /** Pre-acquired Power Platform API bearer token. */
49
49
  token: string;
50
- /** ISV client ID — when provided, runs pre-disambiguation ACL grants. */
50
+ /** ISV client ID — when provided, runs pre-disambiguation user consent. */
51
51
  isvClientId?: string;
52
52
  onDisambiguationNeeded?: OnDisambiguationNeeded;
53
53
  onMissingConnection?: OnMissingConnection;
@@ -59,7 +59,7 @@ export interface StaticRefsOptions {
59
59
  * 1. Build an apiId → schema lookup.
60
60
  * 2. In parallel: fetch the Dataverse instanceUrl and all connection instances
61
61
  * for every connector.
62
- * 3. If `isvClientId` is set, run pre-disambiguation ACL grants — connections
62
+ * 3. If `isvClientId` is set, run pre-disambiguation user consent — connections
63
63
  * where the grant fails are marked `NeedsAclGrant` and excluded from
64
64
  * resolution, prompting the user to create a new connection.
65
65
  * 4. Disambiguate: resolve single matches, invoke callbacks for ambiguous /
@@ -69,18 +69,18 @@ export interface StaticRefsOptions {
69
69
  */
70
70
  export declare function resolveViaStaticRefs({ connectionReferences, schemaMap, environmentId, region, acquireToken, token, isvClientId, onDisambiguationNeeded, onMissingConnection, }: StaticRefsOptions): Promise<AppLaunchResult>;
71
71
  /**
72
- * Run idempotent post-resolution ACL grants on behalf of the ISV app.
72
+ * Run idempotent post-resolution delegated consent grants for the calling app.
73
73
  *
74
74
  * Used by the fast path (production APKs via `fetchAppLaunchData`) where the
75
- * launch API has already resolved the user's connections — grants are applied
76
- * after the fact so APIM accepts tokens issued to the ISV's AAD app.
75
+ * launch API has already resolved the user's connections. Grants are applied
76
+ * only to user-selected connections; fixed shared connections are already
77
+ * authorized by their owner and must not receive delegated user consent.
77
78
  *
78
79
  * For the slow path the grants run before disambiguation inside
79
80
  * `resolveViaStaticRefs`, where they can still influence which connections
80
81
  * are considered available.
81
82
  *
82
- * Failures are swallowed — a failed grant will surface as a 403 at runtime
83
- * when the connector is called.
83
+ * Returns the connection names whose ACL grants failed so callers can fail closed.
84
84
  */
85
- export declare function applyAclGrants(connectionRefs: Record<string, AppConnectionReference>, environmentId: string, isvClientId: string, acquireToken: (scopes: string[]) => Promise<string | null>): Promise<void>;
85
+ export declare function applyAclGrants(connectionRefs: Record<string, AppConnectionReference>, connectionRequirements: ConnectionRequirement[], environmentId: string, region: string, acquireToken: (scopes: string[]) => Promise<string | null>): Promise<Set<string>>;
86
86
  //# sourceMappingURL=resolveConnections.d.ts.map