@microsoft/power-apps-native-host 0.2.25 → 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 (129) hide show
  1. package/README.md +21 -2
  2. package/compatibility/current.json +0 -1
  3. package/lib/NOTICE.txt +6 -12
  4. package/lib/commonjs/auth/AuthContext.js +74 -18
  5. package/lib/commonjs/bridge/NativePowerAppsBridge.js +11 -18
  6. package/lib/commonjs/bridge/PowerPagesBridge.js +27 -8
  7. package/lib/commonjs/bridge/bridgeState.js +40 -0
  8. package/lib/commonjs/connections/ConnectionSetupScreen.js +459 -80
  9. package/lib/commonjs/connections/PowerPlatformConnectionApi.js +946 -0
  10. package/lib/commonjs/connections/connectionMetadata.js +127 -0
  11. package/lib/commonjs/connections/connectionState.js +96 -0
  12. package/lib/commonjs/connections/disambiguate.js +19 -11
  13. package/lib/commonjs/connections/resolveConnections.js +347 -0
  14. package/lib/commonjs/connections/types.js +106 -0
  15. package/lib/commonjs/{platform → connections}/useConnectionRefs.js +128 -65
  16. package/lib/commonjs/connections/useConnectionSetup.js +111 -52
  17. package/lib/commonjs/controls/FilePicker.js +6 -0
  18. package/lib/commonjs/controls/ImagePicker.js +8 -0
  19. package/lib/commonjs/index.js +166 -4
  20. package/lib/commonjs/logger.js +9 -6
  21. package/lib/commonjs/offline/createOfflineHostActivationCallbacks.js +61 -0
  22. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.js +46 -0
  23. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.web.js +13 -0
  24. package/lib/commonjs/platform/DataverseDataSources.js +14 -0
  25. package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +49 -0
  26. package/lib/commonjs/platform/GlobalDiscovery.js +51 -0
  27. package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +6 -106
  28. package/lib/commonjs/provider/PowerAppsHostProvider.js +156 -25
  29. package/lib/commonjs/provider/PowerAppsProvider.js +173 -134
  30. package/lib/commonjs/provider/SessionDetailsGesture.js +216 -0
  31. package/lib/commonjs/telemetry/OfflineSdkTelemetry.js +95 -0
  32. package/lib/commonjs/telemetry/OfflineSdkTelemetry.web.js +9 -0
  33. package/lib/commonjs/telemetry/index.js +22 -3
  34. package/lib/module/auth/AuthContext.js +74 -18
  35. package/lib/module/bridge/NativePowerAppsBridge.js +12 -19
  36. package/lib/module/bridge/PowerPagesBridge.js +27 -8
  37. package/lib/module/bridge/bridgeState.js +34 -0
  38. package/lib/module/connections/ConnectionSetupScreen.js +460 -81
  39. package/lib/module/connections/PowerPlatformConnectionApi.js +932 -0
  40. package/lib/module/connections/connectionMetadata.js +112 -0
  41. package/lib/module/connections/connectionState.js +82 -0
  42. package/lib/module/connections/disambiguate.js +19 -12
  43. package/lib/module/connections/resolveConnections.js +342 -0
  44. package/lib/module/connections/types.js +91 -0
  45. package/lib/module/{platform → connections}/useConnectionRefs.js +129 -66
  46. package/lib/module/connections/useConnectionSetup.js +113 -54
  47. package/lib/module/controls/FilePicker.js +6 -0
  48. package/lib/module/controls/ImagePicker.js +8 -0
  49. package/lib/module/index.js +10 -4
  50. package/lib/module/logger.js +8 -6
  51. package/lib/module/offline/createOfflineHostActivationCallbacks.js +55 -0
  52. package/lib/module/offline/useOfflineIntegrationWithStartupGate.js +42 -0
  53. package/lib/module/offline/useOfflineIntegrationWithStartupGate.web.js +9 -0
  54. package/lib/module/platform/DataverseDataSources.js +10 -0
  55. package/lib/module/platform/DataverseGlobalDiscoveryApi.js +45 -0
  56. package/lib/module/platform/GlobalDiscovery.js +45 -0
  57. package/lib/module/platform/PowerPlatformEnvironmentApi.js +5 -104
  58. package/lib/module/provider/PowerAppsHostProvider.js +159 -28
  59. package/lib/module/provider/PowerAppsProvider.js +177 -138
  60. package/lib/module/provider/SessionDetailsGesture.js +211 -0
  61. package/lib/module/telemetry/OfflineSdkTelemetry.js +91 -0
  62. package/lib/module/telemetry/OfflineSdkTelemetry.web.js +5 -0
  63. package/lib/module/telemetry/index.js +15 -4
  64. package/lib/typescript/commonjs/auth/AuthContext.d.ts +3 -1
  65. package/lib/typescript/commonjs/auth/AuthContext.web.d.ts +1 -0
  66. package/lib/typescript/commonjs/bridge/bridgeState.d.ts +5 -0
  67. package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +28 -7
  68. package/lib/typescript/commonjs/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  69. package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +66 -0
  70. package/lib/typescript/commonjs/connections/connectionState.d.ts +16 -0
  71. package/lib/typescript/commonjs/connections/disambiguate.d.ts +4 -2
  72. package/lib/typescript/commonjs/{platform → connections}/resolveConnections.d.ts +19 -19
  73. package/lib/typescript/commonjs/connections/types.d.ts +129 -1
  74. package/lib/typescript/commonjs/{platform → connections}/useConnectionRefs.d.ts +33 -24
  75. package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +12 -8
  76. package/lib/typescript/commonjs/controls/FilePicker.d.ts +7 -1
  77. package/lib/typescript/commonjs/controls/ImagePicker.d.ts +9 -1
  78. package/lib/typescript/commonjs/index.d.ts +17 -10
  79. package/lib/typescript/commonjs/logger.d.ts +4 -4
  80. package/lib/typescript/commonjs/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  81. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  82. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  83. package/lib/typescript/commonjs/platform/DataverseDataSources.d.ts +27 -0
  84. package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  85. package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +4 -0
  86. package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  87. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +29 -18
  88. package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +30 -8
  89. package/lib/typescript/commonjs/provider/SessionDetailsGesture.d.ts +13 -0
  90. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  91. package/lib/typescript/commonjs/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  92. package/lib/typescript/commonjs/telemetry/index.d.ts +13 -1
  93. package/lib/typescript/module/auth/AuthContext.d.ts +3 -1
  94. package/lib/typescript/module/auth/AuthContext.web.d.ts +1 -0
  95. package/lib/typescript/module/bridge/bridgeState.d.ts +5 -0
  96. package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +28 -7
  97. package/lib/typescript/module/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  98. package/lib/typescript/module/connections/connectionMetadata.d.ts +66 -0
  99. package/lib/typescript/module/connections/connectionState.d.ts +16 -0
  100. package/lib/typescript/module/connections/disambiguate.d.ts +4 -2
  101. package/lib/typescript/module/{platform → connections}/resolveConnections.d.ts +19 -19
  102. package/lib/typescript/module/connections/types.d.ts +129 -1
  103. package/lib/typescript/module/{platform → connections}/useConnectionRefs.d.ts +33 -24
  104. package/lib/typescript/module/connections/useConnectionSetup.d.ts +12 -8
  105. package/lib/typescript/module/controls/FilePicker.d.ts +7 -1
  106. package/lib/typescript/module/controls/ImagePicker.d.ts +9 -1
  107. package/lib/typescript/module/index.d.ts +17 -10
  108. package/lib/typescript/module/logger.d.ts +4 -4
  109. package/lib/typescript/module/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  110. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  111. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  112. package/lib/typescript/module/platform/DataverseDataSources.d.ts +27 -0
  113. package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  114. package/lib/typescript/module/platform/GlobalDiscovery.d.ts +4 -0
  115. package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  116. package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +29 -18
  117. package/lib/typescript/module/provider/PowerAppsProvider.d.ts +30 -8
  118. package/lib/typescript/module/provider/SessionDetailsGesture.d.ts +13 -0
  119. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.d.ts +15 -0
  120. package/lib/typescript/module/telemetry/OfflineSdkTelemetry.web.d.ts +2 -0
  121. package/lib/typescript/module/telemetry/index.d.ts +13 -1
  122. package/package.json +11 -6
  123. package/scripts/metro-logger.js +213 -0
  124. package/scripts/upgrade/runtime.js +13 -7
  125. package/scripts/upgrade-authoring.js +5 -6
  126. package/lib/commonjs/platform/PowerPlatformConnectionApi.js +0 -606
  127. package/lib/commonjs/platform/resolveConnections.js +0 -264
  128. package/lib/module/platform/PowerPlatformConnectionApi.js +0 -595
  129. package/lib/module/platform/resolveConnections.js +0 -259
@@ -27,9 +27,10 @@
27
27
  * </PowerAppsHostProvider>
28
28
  */
29
29
  import React from 'react';
30
- import type { ConnectorSchema } from '../platform/useConnectionRefs';
31
- import type { DatabaseReference } from '../platform/PowerPlatformEnvironmentApi';
30
+ import type { ConnectorSchema } from '../connections/useConnectionRefs';
31
+ import type { DatabaseReference } from '../platform/DataverseDataSources';
32
32
  import type { OnDisambiguationNeeded } from '../connections/types';
33
+ import type { ConnectionReferenceConfig, ConnectionUsageInput, ResourceConsentRequirement } from '../connections/types';
33
34
  export interface PowerAppsHostProviderProps {
34
35
  /**
35
36
  * Callback to acquire an access token for the given scopes.
@@ -41,12 +42,12 @@ export interface PowerAppsHostProviderProps {
41
42
  * Connection resolution only runs when this is true.
42
43
  */
43
44
  isSignedIn: boolean;
45
+ /** Sign out the active account. Shown on blocking connection error screens. */
46
+ onSignOut?: () => void | Promise<void>;
44
47
  /**
45
48
  * PowerApps app GUID (from power.config.json `appId`).
46
- * When set, connection references are fetched from the PowerApps RP
47
- * `/apps/{appId}/launch` API at runtime instead of using the static
48
- * `connectionReferences` prop. Leave undefined during local development
49
- * to fall back to the static `connectionReferences`.
49
+ * Outside Dev Player, app and connection metadata is fetched exclusively
50
+ * from the PowerApps RP `/apps/{appId}/launch` API.
50
51
  */
51
52
  appId?: string;
52
53
  /** Power Platform environment GUID (from power.config.json). */
@@ -58,6 +59,7 @@ export interface PowerAppsHostProviderProps {
58
59
  region?: string;
59
60
  /**
60
61
  * The connectionReferences map from power.config.json.
62
+ * Used only in Dev Player for unpublished local apps.
61
63
  * Shape: { [refId]: { id: string; dataSources: string[] } }
62
64
  *
63
65
  * NOTE: This prop must be referentially stable across renders (memoize it in
@@ -65,18 +67,16 @@ export interface PowerAppsHostProviderProps {
65
67
  * so passing a fresh object literal every render forces continuous
66
68
  * re-registration.
67
69
  */
68
- connectionReferences: Record<string, {
69
- id: string;
70
- dataSources: string[];
71
- }>;
70
+ connectionReferences: Record<string, ConnectionReferenceConfig>;
72
71
  /**
73
72
  * Connector schema map keyed by data source name.
73
+ * Used only in Dev Player for unpublished local apps.
74
74
  * Generated automatically by generate-connector-schemas.
75
75
  */
76
76
  schemaMap: Record<string, ConnectorSchema>;
77
77
  /**
78
78
  * The databaseReferences map from power.config.json.
79
- * Used to build CDS data sources for the bridge.
79
+ * Used only in Dev Player. Production database references come from RP.
80
80
  *
81
81
  * NOTE: Like `connectionReferences`, pass a referentially stable value; an
82
82
  * unstable identity each render triggers redundant bridge re-registration.
@@ -84,8 +84,8 @@ export interface PowerAppsHostProviderProps {
84
84
  databaseReferences?: Record<string, DatabaseReference>;
85
85
  /**
86
86
  * Optional custom renderer for the OAuth consent WebView shown during
87
- * connection creation. If not provided, the system browser is used via
88
- * Linking.openURL().
87
+ * connection creation. If not provided, the system authentication browser
88
+ * is used. Pass the final redirect URL to onDone when the custom view captures it.
89
89
  *
90
90
  * @example
91
91
  * // Using react-native-webview:
@@ -96,20 +96,31 @@ export interface PowerAppsHostProviderProps {
96
96
  * </Modal>
97
97
  * )}
98
98
  */
99
- renderOAuthWebView?: (url: string, onDone: () => void) => React.ReactNode;
99
+ renderOAuthWebView?: (url: string, onDone: (redirectUrl?: string) => void) => React.ReactNode;
100
100
  /**
101
101
  * The ISV/wrap-app AAD client ID (from auth.config.json `msal.clientId`).
102
102
  * When provided, the ISV's service principal is granted CanView access on
103
103
  * each newly created connection, allowing APIM to accept tokens with this
104
104
  * appid at runtime (prevents 403 "missing connection ACL" for third-party tokens).
105
105
  */
106
- isvClientId?: string;
106
+ isvClientId: string;
107
107
  /**
108
108
  * Called when multiple Connected connections exist for the same connector.
109
- * Present a native picker UI and return the chosen connectionId, or null to
110
- * accept the first Connected connection as a fallback.
109
+ * Present a native picker UI and return the chosen connectionId, or null to
110
+ * leave the reference unresolved.
111
111
  */
112
112
  onDisambiguationNeeded?: OnDisambiguationNeeded;
113
+ /**
114
+ * Called after the user selects Allow and before the player launches.
115
+ * Use this to persist app-to-connection usage through an approved public RP endpoint.
116
+ * Rejecting keeps the app gated and shows the error in the consent screen.
117
+ * Not invoked in Power Apps Dev Player; local testing is intentionally non-persistent.
118
+ */
119
+ onConnectionConsent?: (usages: ConnectionUsageInput[]) => void | Promise<void>;
120
+ /** Persist protected resource approval in production. Not invoked in Dev Player. */
121
+ onResourceConsent?: (resources: ResourceConsentRequirement[]) => void | Promise<void>;
122
+ /** Called when the user selects Do not allow. */
123
+ onConnectionConsentDeclined?: () => void | Promise<void>;
113
124
  children: React.ReactNode;
114
125
  }
115
126
  /**
@@ -119,5 +130,5 @@ export interface PowerAppsHostProviderProps {
119
130
  *
120
131
  * Children are never rendered until all required connections are resolved.
121
132
  */
122
- export declare function PowerAppsHostProvider({ acquireToken, isSignedIn, appId, environmentId, region, connectionReferences, schemaMap, databaseReferences, renderOAuthWebView, isvClientId, onDisambiguationNeeded, children, }: PowerAppsHostProviderProps): React.JSX.Element;
133
+ export declare function PowerAppsHostProvider({ acquireToken, isSignedIn, onSignOut, appId, environmentId, region, connectionReferences, schemaMap, databaseReferences, renderOAuthWebView, isvClientId, onDisambiguationNeeded, onConnectionConsent, onResourceConsent, onConnectionConsentDeclined, children, }: PowerAppsHostProviderProps): React.JSX.Element;
123
134
  //# sourceMappingURL=PowerAppsHostProvider.d.ts.map
@@ -28,11 +28,12 @@ import React from 'react';
28
28
  import { createTamagui } from '@tamagui/core';
29
29
  import type { AuthProviderProps } from '../auth/AuthContext';
30
30
  import type { PowerAppsHostProviderProps } from './PowerAppsHostProvider';
31
- import type { ConnectorSchema } from '../platform/useConnectionRefs';
32
- import type { DatabaseReference } from '../platform/PowerPlatformEnvironmentApi';
33
- import type { OnDisambiguationNeeded } from '../connections/types';
31
+ import type { ConnectorSchema } from '../connections/useConnectionRefs';
32
+ import type { DatabaseReference } from '../platform/DataverseDataSources';
33
+ import type { ConnectionReferenceConfig, OnDisambiguationNeeded } from '../connections/types';
34
34
  import type { ThemeTokens } from '../theme/tokens';
35
35
  import type { ILogger } from '@microsoft/power-apps-native-common';
36
+ import type { ApplicationInsightsTelemetryProviderConfig } from '@microsoft/power-apps-native-common';
36
37
  /** Shape of power.config.json consumed by the provider. */
37
38
  export interface PowerConfig {
38
39
  /**
@@ -53,10 +54,7 @@ export interface PowerConfig {
53
54
  * Omit for the default global collector.
54
55
  */
55
56
  geoRegion?: string;
56
- connectionReferences?: Record<string, {
57
- id: string;
58
- dataSources: string[];
59
- }>;
57
+ connectionReferences?: Record<string, ConnectionReferenceConfig>;
60
58
  databaseReferences?: Record<string, DatabaseReference>;
61
59
  /**
62
60
  * Allow additional keys — the offline SDK reads arbitrary fields from
@@ -67,6 +65,10 @@ export interface PowerConfig {
67
65
  [key: string]: unknown;
68
66
  }
69
67
  type TamaguiConfig = ReturnType<typeof createTamagui>;
68
+ export interface AppInsightsConfig extends Omit<ApplicationInsightsTelemetryProviderConfig, 'deviceId' | 'sessionId'> {
69
+ /** Explicit opt-in. Application Insights telemetry is disabled unless this is true. */
70
+ enabled: boolean;
71
+ }
70
72
  export interface PowerAppsProviderProps {
71
73
  /** MSAL configuration from auth.config.json (msal section). */
72
74
  msalConfig: AuthProviderProps['msalConfig'];
@@ -106,6 +108,12 @@ export interface PowerAppsProviderProps {
106
108
  renderOAuthWebView?: PowerAppsHostProviderProps['renderOAuthWebView'];
107
109
  /** See PowerAppsHostProviderProps.onDisambiguationNeeded. */
108
110
  onDisambiguationNeeded?: OnDisambiguationNeeded;
111
+ /** See PowerAppsHostProviderProps.onConnectionConsent. */
112
+ onConnectionConsent?: PowerAppsHostProviderProps['onConnectionConsent'];
113
+ /** See PowerAppsHostProviderProps.onResourceConsent. */
114
+ onResourceConsent?: PowerAppsHostProviderProps['onResourceConsent'];
115
+ /** See PowerAppsHostProviderProps.onConnectionConsentDeclined. */
116
+ onConnectionConsentDeclined?: PowerAppsHostProviderProps['onConnectionConsentDeclined'];
109
117
  /**
110
118
  * App name used as `clientType` in the auto-wired 1DS telemetry provider.
111
119
  * Appears in Kusto as the `clientType` column — use a stable
@@ -125,6 +133,20 @@ export interface PowerAppsProviderProps {
125
133
  * logger becomes a no-op regardless of build variant.
126
134
  */
127
135
  logger?: ILogger | null;
136
+ /**
137
+ * Show app and telemetry session details after a three-finger downward swipe.
138
+ * Available in both development and published native apps. @default true
139
+ */
140
+ showSessionDetailsOnSwipe?: boolean;
141
+ /**
142
+ * Optional customer-owned Application Insights destination.
143
+ *
144
+ * Events are sent directly to the selected C1-owned Application Insights
145
+ * resource and fan out alongside the default Microsoft OneDS provider.
146
+ * Defaults to `expo.extra.appInsightsConfig` from app.json.
147
+ * Ignored when `logger` is provided or `null`.
148
+ */
149
+ appInsightsConfig?: AppInsightsConfig;
128
150
  /**
129
151
  * Offline profile JSON — optional override.
130
152
  * Primary source: SDK config plugin embeds offline-profile.json into the app
@@ -143,6 +165,6 @@ export interface PowerAppsProviderProps {
143
165
  * root layout.
144
166
  */
145
167
  export declare function PowerAppsProvider({ msalConfig, intuneConfig, powerConfig, schemaMap, tamaguiConfig, // override with app's tamagui.config.ts
146
- defaultTheme, theme, darkTheme, followSystemTheme, renderOAuthWebView, onDisambiguationNeeded, appName, logger: loggerProp, offlineProfile, children, }: PowerAppsProviderProps): React.JSX.Element;
168
+ defaultTheme, theme, darkTheme, followSystemTheme, renderOAuthWebView, onDisambiguationNeeded, onConnectionConsent, onResourceConsent, onConnectionConsentDeclined, appName, logger: loggerProp, showSessionDetailsOnSwipe, appInsightsConfig, offlineProfile, children, }: PowerAppsProviderProps): React.JSX.Element;
147
169
  export {};
148
170
  //# sourceMappingURL=PowerAppsProvider.d.ts.map
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ interface SessionDetailsGestureProps {
3
+ enabled: boolean;
4
+ appName: string;
5
+ appId?: string;
6
+ environmentId?: string;
7
+ region: string;
8
+ appVersion?: string;
9
+ children: React.ReactNode;
10
+ }
11
+ export declare function SessionDetailsGesture({ enabled, appName, appId, environmentId, region, appVersion, children, }: SessionDetailsGestureProps): React.JSX.Element;
12
+ export {};
13
+ //# sourceMappingURL=SessionDetailsGesture.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Forwards the privacy-safe Offline SDK transport through the host's existing
3
+ * app logger so offline events carry the same session, device, and user data.
4
+ *
5
+ * The host owns exactly one thing here: binding the SDK transport to this
6
+ * host's logger. Buffering and teardown semantics live in the SDK.
7
+ *
8
+ * Setup and teardown are fail-open but not silent. This runs from an effect in
9
+ * the provider that roots the app, so an unguarded throw would take down the
10
+ * whole tree — telemetry is never worth an app that will not start. An
11
+ * unexpected failure is therefore downgraded to a logged diagnostic rather than
12
+ * swallowed, so broken wiring stays observable.
13
+ */
14
+ export declare function configureOfflineSdkTelemetry(forwardEvents: boolean): () => void;
15
+ //# sourceMappingURL=OfflineSdkTelemetry.d.ts.map
@@ -0,0 +1,2 @@
1
+ export declare function configureOfflineSdkTelemetry(_forwardEvents: boolean): () => void;
2
+ //# sourceMappingURL=OfflineSdkTelemetry.web.d.ts.map
@@ -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.
@@ -13,6 +13,7 @@ export interface AuthState {
13
13
  export interface AuthProviderProps {
14
14
  msalConfig: MsalAuthConfig;
15
15
  intuneConfig?: IntuneConfig;
16
+ requiredScopes?: string[];
16
17
  children: React.ReactNode;
17
18
  }
18
19
  export declare function AuthProvider({ children }: AuthProviderProps): React.JSX.Element;
@@ -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