@microsoft/power-apps-native-host 0.2.25 → 0.3.3

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 (154) hide show
  1. package/README.md +21 -10
  2. package/compatibility/current.json +31 -4
  3. package/lib/NOTICE.txt +1325 -24
  4. package/lib/commonjs/auth/AuthContext.js +110 -33
  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/config/babelConfig.js +13 -0
  9. package/lib/commonjs/config/expoConfig.js +71 -0
  10. package/lib/commonjs/config/metroConfig.js +70 -0
  11. package/lib/commonjs/config/metroLogger.js +182 -0
  12. package/lib/commonjs/config/tamaguiConfig.js +98 -0
  13. package/lib/commonjs/connections/ConnectionSetupScreen.js +459 -80
  14. package/lib/commonjs/connections/PowerPlatformConnectionApi.js +946 -0
  15. package/lib/commonjs/connections/connectionMetadata.js +127 -0
  16. package/lib/commonjs/connections/connectionState.js +96 -0
  17. package/lib/commonjs/connections/disambiguate.js +19 -11
  18. package/lib/commonjs/connections/resolveConnections.js +348 -0
  19. package/lib/commonjs/connections/types.js +106 -0
  20. package/lib/commonjs/{platform → connections}/useConnectionRefs.js +130 -65
  21. package/lib/commonjs/connections/useConnectionSetup.js +111 -52
  22. package/lib/commonjs/controls/FilePicker.js +6 -0
  23. package/lib/commonjs/controls/ImagePicker.js +8 -0
  24. package/lib/commonjs/index.js +167 -4
  25. package/lib/commonjs/logger.js +9 -6
  26. package/lib/commonjs/offline/createOfflineHostActivationCallbacks.js +61 -0
  27. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.js +48 -0
  28. package/lib/commonjs/offline/useOfflineIntegrationWithStartupGate.web.js +13 -0
  29. package/lib/commonjs/platform/DataverseDataSources.js +18 -0
  30. package/lib/commonjs/platform/DataverseGlobalDiscoveryApi.js +94 -0
  31. package/lib/commonjs/platform/GlobalDiscovery.js +51 -0
  32. package/lib/commonjs/platform/PowerPlatformEnvironmentApi.js +6 -106
  33. package/lib/commonjs/provider/PowerAppsHostProvider.js +157 -25
  34. package/lib/commonjs/provider/PowerAppsProvider.js +178 -134
  35. package/lib/commonjs/provider/SessionDetailsGesture.js +208 -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 +110 -33
  40. package/lib/module/bridge/NativePowerAppsBridge.js +12 -19
  41. package/lib/module/bridge/PowerPagesBridge.js +27 -8
  42. package/lib/module/bridge/bridgeState.js +34 -0
  43. package/lib/module/config/babelConfig.js +9 -0
  44. package/lib/module/config/expoConfig.js +67 -0
  45. package/lib/module/config/metroConfig.js +65 -0
  46. package/lib/module/config/metroLogger.js +175 -0
  47. package/lib/module/config/tamaguiConfig.js +93 -0
  48. package/lib/module/connections/ConnectionSetupScreen.js +460 -81
  49. package/lib/module/connections/PowerPlatformConnectionApi.js +932 -0
  50. package/lib/module/connections/connectionMetadata.js +112 -0
  51. package/lib/module/connections/connectionState.js +82 -0
  52. package/lib/module/connections/disambiguate.js +19 -12
  53. package/lib/module/connections/resolveConnections.js +343 -0
  54. package/lib/module/connections/types.js +91 -0
  55. package/lib/module/{platform → connections}/useConnectionRefs.js +131 -66
  56. package/lib/module/connections/useConnectionSetup.js +113 -54
  57. package/lib/module/controls/FilePicker.js +6 -0
  58. package/lib/module/controls/ImagePicker.js +8 -0
  59. package/lib/module/index.js +14 -4
  60. package/lib/module/logger.js +8 -6
  61. package/lib/module/offline/createOfflineHostActivationCallbacks.js +55 -0
  62. package/lib/module/offline/useOfflineIntegrationWithStartupGate.js +44 -0
  63. package/lib/module/offline/useOfflineIntegrationWithStartupGate.web.js +9 -0
  64. package/lib/module/platform/DataverseDataSources.js +13 -0
  65. package/lib/module/platform/DataverseGlobalDiscoveryApi.js +89 -0
  66. package/lib/module/platform/GlobalDiscovery.js +45 -0
  67. package/lib/module/platform/PowerPlatformEnvironmentApi.js +5 -104
  68. package/lib/module/provider/PowerAppsHostProvider.js +160 -28
  69. package/lib/module/provider/PowerAppsProvider.js +182 -138
  70. package/lib/module/provider/SessionDetailsGesture.js +203 -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 +1 -0
  76. package/lib/typescript/commonjs/bridge/bridgeState.d.ts +5 -0
  77. package/lib/typescript/commonjs/config/babelConfig.d.ts +12 -0
  78. package/lib/typescript/commonjs/config/expoConfig.d.ts +21 -0
  79. package/lib/typescript/commonjs/config/metroConfig.d.ts +6 -0
  80. package/lib/typescript/commonjs/config/metroLogger.d.ts +21 -0
  81. package/lib/typescript/commonjs/config/tamaguiConfig.d.ts +1792 -0
  82. package/lib/typescript/commonjs/connections/ConnectionSetupScreen.d.ts +28 -7
  83. package/lib/typescript/commonjs/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  84. package/lib/typescript/commonjs/connections/connectionMetadata.d.ts +66 -0
  85. package/lib/typescript/commonjs/connections/connectionState.d.ts +16 -0
  86. package/lib/typescript/commonjs/connections/disambiguate.d.ts +4 -2
  87. package/lib/typescript/commonjs/{platform → connections}/resolveConnections.d.ts +22 -20
  88. package/lib/typescript/commonjs/connections/types.d.ts +129 -1
  89. package/lib/typescript/commonjs/{platform → connections}/useConnectionRefs.d.ts +36 -25
  90. package/lib/typescript/commonjs/connections/useConnectionSetup.d.ts +12 -8
  91. package/lib/typescript/commonjs/controls/FilePicker.d.ts +7 -1
  92. package/lib/typescript/commonjs/controls/ImagePicker.d.ts +9 -1
  93. package/lib/typescript/commonjs/index.d.ts +18 -10
  94. package/lib/typescript/commonjs/logger.d.ts +4 -4
  95. package/lib/typescript/commonjs/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  96. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  97. package/lib/typescript/commonjs/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  98. package/lib/typescript/commonjs/platform/DataverseDataSources.d.ts +28 -0
  99. package/lib/typescript/commonjs/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  100. package/lib/typescript/commonjs/platform/GlobalDiscovery.d.ts +4 -0
  101. package/lib/typescript/commonjs/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  102. package/lib/typescript/commonjs/provider/PowerAppsHostProvider.d.ts +29 -18
  103. package/lib/typescript/commonjs/provider/PowerAppsProvider.d.ts +54 -9
  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 +1 -0
  110. package/lib/typescript/module/bridge/bridgeState.d.ts +5 -0
  111. package/lib/typescript/module/config/babelConfig.d.ts +12 -0
  112. package/lib/typescript/module/config/expoConfig.d.ts +21 -0
  113. package/lib/typescript/module/config/metroConfig.d.ts +6 -0
  114. package/lib/typescript/module/config/metroLogger.d.ts +21 -0
  115. package/lib/typescript/module/config/tamaguiConfig.d.ts +1792 -0
  116. package/lib/typescript/module/connections/ConnectionSetupScreen.d.ts +28 -7
  117. package/lib/typescript/module/{platform → connections}/PowerPlatformConnectionApi.d.ts +52 -43
  118. package/lib/typescript/module/connections/connectionMetadata.d.ts +66 -0
  119. package/lib/typescript/module/connections/connectionState.d.ts +16 -0
  120. package/lib/typescript/module/connections/disambiguate.d.ts +4 -2
  121. package/lib/typescript/module/{platform → connections}/resolveConnections.d.ts +22 -20
  122. package/lib/typescript/module/connections/types.d.ts +129 -1
  123. package/lib/typescript/module/{platform → connections}/useConnectionRefs.d.ts +36 -25
  124. package/lib/typescript/module/connections/useConnectionSetup.d.ts +12 -8
  125. package/lib/typescript/module/controls/FilePicker.d.ts +7 -1
  126. package/lib/typescript/module/controls/ImagePicker.d.ts +9 -1
  127. package/lib/typescript/module/index.d.ts +18 -10
  128. package/lib/typescript/module/logger.d.ts +4 -4
  129. package/lib/typescript/module/offline/createOfflineHostActivationCallbacks.d.ts +12 -0
  130. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.d.ts +15 -0
  131. package/lib/typescript/module/offline/useOfflineIntegrationWithStartupGate.web.d.ts +6 -0
  132. package/lib/typescript/module/platform/DataverseDataSources.d.ts +28 -0
  133. package/lib/typescript/module/platform/DataverseGlobalDiscoveryApi.d.ts +3 -0
  134. package/lib/typescript/module/platform/GlobalDiscovery.d.ts +4 -0
  135. package/lib/typescript/module/platform/PowerPlatformEnvironmentApi.d.ts +3 -74
  136. package/lib/typescript/module/provider/PowerAppsHostProvider.d.ts +29 -18
  137. package/lib/typescript/module/provider/PowerAppsProvider.d.ts +54 -9
  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 +52 -13
  143. package/scripts/build-codegen-package.js +283 -0
  144. package/scripts/start-web.mjs +9 -5
  145. package/scripts/upgrade/runtime.js +139 -24
  146. package/scripts/upgrade-authoring.js +274 -180
  147. package/scripts/upgrade.js +10 -16
  148. package/src/config/generated-config.d.ts +4 -0
  149. package/src/config/index.d.ts +3 -0
  150. package/src/config/tsconfig.json +26 -0
  151. package/lib/commonjs/platform/PowerPlatformConnectionApi.js +0 -606
  152. package/lib/commonjs/platform/resolveConnections.js +0 -264
  153. package/lib/module/platform/PowerPlatformConnectionApi.js +0 -595
  154. package/lib/module/platform/resolveConnections.js +0 -259
@@ -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,18 @@ 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
+ /** Whether power.config.json contains Dataverse database references. */
43
+ hasDataverse: boolean;
42
44
  /** Connector schema map keyed by data source name. */
43
45
  schemaMap: Record<string, ConnectorSchema>;
44
46
  environmentId: string;
45
47
  region: string;
46
- /** Used for ACL grants and the Dataverse instanceUrl fetch. */
48
+ /** Used for connection consent and the Dataverse instanceUrl fetch. */
47
49
  acquireToken: (scopes: string[]) => Promise<string | null>;
48
50
  /** Pre-acquired Power Platform API bearer token. */
49
51
  token: string;
50
- /** ISV client ID — when provided, runs pre-disambiguation ACL grants. */
52
+ /** ISV client ID — when provided, runs pre-disambiguation user consent. */
51
53
  isvClientId?: string;
52
54
  onDisambiguationNeeded?: OnDisambiguationNeeded;
53
55
  onMissingConnection?: OnMissingConnection;
@@ -59,7 +61,7 @@ export interface StaticRefsOptions {
59
61
  * 1. Build an apiId → schema lookup.
60
62
  * 2. In parallel: fetch the Dataverse instanceUrl and all connection instances
61
63
  * for every connector.
62
- * 3. If `isvClientId` is set, run pre-disambiguation ACL grants — connections
64
+ * 3. If `isvClientId` is set, run pre-disambiguation user consent — connections
63
65
  * where the grant fails are marked `NeedsAclGrant` and excluded from
64
66
  * resolution, prompting the user to create a new connection.
65
67
  * 4. Disambiguate: resolve single matches, invoke callbacks for ambiguous /
@@ -67,20 +69,20 @@ export interface StaticRefsOptions {
67
69
  * `true`.
68
70
  * 5. Build and return an `AppLaunchResult`-shaped object.
69
71
  */
70
- export declare function resolveViaStaticRefs({ connectionReferences, schemaMap, environmentId, region, acquireToken, token, isvClientId, onDisambiguationNeeded, onMissingConnection, }: StaticRefsOptions): Promise<AppLaunchResult>;
72
+ export declare function resolveViaStaticRefs({ connectionReferences, hasDataverse, schemaMap, environmentId, region, acquireToken, token, isvClientId, onDisambiguationNeeded, onMissingConnection, }: StaticRefsOptions): Promise<AppLaunchResult>;
71
73
  /**
72
- * Run idempotent post-resolution ACL grants on behalf of the ISV app.
74
+ * Run idempotent post-resolution delegated consent grants for the calling app.
73
75
  *
74
76
  * 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.
77
+ * launch API has already resolved the user's connections. Grants are applied
78
+ * only to user-selected connections; fixed shared connections are already
79
+ * authorized by their owner and must not receive delegated user consent.
77
80
  *
78
81
  * For the slow path the grants run before disambiguation inside
79
82
  * `resolveViaStaticRefs`, where they can still influence which connections
80
83
  * are considered available.
81
84
  *
82
- * Failures are swallowed — a failed grant will surface as a 403 at runtime
83
- * when the connector is called.
85
+ * Returns the connection names whose ACL grants failed so callers can fail closed.
84
86
  */
85
- export declare function applyAclGrants(connectionRefs: Record<string, AppConnectionReference>, environmentId: string, isvClientId: string, acquireToken: (scopes: string[]) => Promise<string | null>): Promise<void>;
87
+ export declare function applyAclGrants(connectionRefs: Record<string, AppConnectionReference>, connectionRequirements: ConnectionRequirement[], environmentId: string, region: string, acquireToken: (scopes: string[]) => Promise<string | null>): Promise<Set<string>>;
86
88
  //# sourceMappingURL=resolveConnections.d.ts.map
@@ -17,18 +17,146 @@ export declare enum ConnectionStatus {
17
17
  NeedsAclGrant = "NeedsAclGrant",
18
18
  NotConnected = "NotConnected"
19
19
  }
20
+ export interface ConnectionReferenceConfig {
21
+ id: string;
22
+ dataSources: string[];
23
+ displayName?: string;
24
+ iconUri?: string;
25
+ appActions?: string[];
26
+ sharedConnectionId?: string;
27
+ gatewayObjectIdHint?: string;
28
+ authenticationType?: string;
29
+ parameterSetName?: string;
30
+ workflowDetails?: {
31
+ workflowEntityId?: string;
32
+ workflowDisplayName?: string;
33
+ workflowName?: string;
34
+ };
35
+ dataSets?: Record<string, unknown>;
36
+ dependencies?: Record<string, unknown>;
37
+ dependents?: string[];
38
+ nestedActions?: Array<{
39
+ actionName?: string;
40
+ apiName?: string;
41
+ flowConnectionRef?: string;
42
+ }>;
43
+ parameterHintsV2?: Record<string, {
44
+ value?: unknown;
45
+ }>;
46
+ [key: string]: unknown;
47
+ }
48
+ export interface ConnectionRequirement {
49
+ localRefId: string;
50
+ apiId: string;
51
+ connectorId: string;
52
+ dataSources: string[];
53
+ displayName?: string;
54
+ iconUri?: string;
55
+ appActions?: string[];
56
+ sharedConnectionId?: string;
57
+ gatewayObjectIdHint?: string;
58
+ authenticationType?: string;
59
+ parameterSetName?: string;
60
+ apiScopes: {
61
+ will: string[];
62
+ wont: string[];
63
+ };
64
+ isFlowDependent: boolean;
65
+ }
66
+ export type ConnectionParameterType = 'string' | 'securestring' | 'boolean' | 'integer' | 'clientcertificate';
67
+ export interface ConnectionParameterDefinition {
68
+ name: string;
69
+ displayName: string;
70
+ type: ConnectionParameterType;
71
+ required: boolean;
72
+ hidden: boolean;
73
+ capabilities?: string[];
74
+ allowedValues?: Array<{
75
+ value: string;
76
+ displayName: string;
77
+ }>;
78
+ defaultValue?: string | boolean | number;
79
+ }
80
+ export interface ConnectionParameterSet {
81
+ /** Undefined for a connector's single, non-parameter-set authentication definition. */
82
+ name?: string;
83
+ displayName: string;
84
+ parameters: ConnectionParameterDefinition[];
85
+ requiresApiConsent: boolean;
86
+ gatewayParameterName?: string;
87
+ }
88
+ export type ConnectionParameterValue = string | boolean | number | {
89
+ pfx: string;
90
+ password: string;
91
+ } | {
92
+ gatewayObjectId: string;
93
+ };
94
+ export interface ConnectionInput {
95
+ parameterSetName?: string;
96
+ gatewayObjectId?: string;
97
+ gatewayParameterName?: string;
98
+ parameters: Record<string, ConnectionParameterValue>;
99
+ }
100
+ export interface ConnectionConsentDetails {
101
+ localRefId: string;
102
+ connectorId: string;
103
+ displayName: string;
104
+ description: string;
105
+ appActions: string[];
106
+ }
107
+ export interface ResourceConsentRequirement {
108
+ resourceId: string;
109
+ displayName: string;
110
+ }
111
+ export interface ConnectionUsageInput {
112
+ localRefId: string;
113
+ apiId: string;
114
+ connectionId: string;
115
+ dataSources: string[];
116
+ appActions: string[];
117
+ apiScopes: {
118
+ will: string[];
119
+ wont: string[];
120
+ };
121
+ }
122
+ export declare function normalizeApiId(apiId: string): string;
123
+ export declare function getConnectorId(apiId: string): string;
124
+ export declare function getConnectionDatasetName(reference: {
125
+ dataSets?: Record<string, unknown>;
126
+ }): string;
127
+ export declare function getFlowConnectionName(reference: ConnectionReferenceConfig): string;
128
+ export declare function getFlowDataSourceNames(reference: ConnectionReferenceConfig): string[];
129
+ export declare function buildConnectionRequirements(connectionReferences: Record<string, ConnectionReferenceConfig>, scopesByApiId?: Record<string, {
130
+ will: string[];
131
+ wont: string[];
132
+ }>): ConnectionRequirement[];
133
+ export declare function isCompositeConnectionApiId(apiId: string): boolean;
134
+ export declare function findConnectionDataSourceConflicts(requirements: ConnectionRequirement[]): string[];
135
+ export declare function hasCompleteStaticConnectionConfig(connectionReferences: Record<string, ConnectionReferenceConfig>, schemaMap: Record<string, {
136
+ name: string;
137
+ properties: {
138
+ primaryRuntimeUrl: string;
139
+ };
140
+ }>): boolean;
141
+ export declare function buildConnectionResolutionKey(appId: string | undefined, environmentId: string, connectionReferences: Record<string, ConnectionReferenceConfig>): string;
20
142
  /** A single connection instance returned by the Power Platform connectivity API. */
21
143
  export interface NativeConnectionInstance {
22
- /** Extracted connection UUID (hex, no dashes). */
144
+ /** Terminal connection resource name exactly as returned by Power Platform. */
23
145
  id: string;
24
146
  /** Full resource name from the API (connector-prefixed, e.g. "shared_office365users/abc123"). */
25
147
  name: string;
26
148
  /** Connector API identifier (e.g. "/providers/Microsoft.PowerApps/apis/shared_office365users"). */
27
149
  apiId: string;
150
+ /** Object ID of the connection owner when returned by the connectivity API. */
151
+ ownerId?: string;
28
152
  /** Resolved authorization status of this connection. */
29
153
  status: ConnectionStatus;
30
154
  /** Optional human-readable display name from the API. */
31
155
  displayName?: string;
156
+ accountName?: string;
157
+ parameterSetName?: string;
158
+ isAuthenticated?: boolean;
159
+ statusErrorCode?: string;
32
160
  }
33
161
  /**
34
162
  * Result of attempting to match a single connection reference to an instance.