@devvit/client 0.12.1-next-2025-08-25-18-37-07-407f1e009.0 → 0.12.1-next-2025-08-25-20-31-24-ed3784f8b.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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This method is used to check if the app has been granted all the requested scopes.
3
+ *
4
+ * @experimental
5
+ * @returns true if the app has been granted all the requested scopes, false otherwise.
6
+ */
7
+ export declare const canRunAsUser: () => Promise<boolean>;
8
+ //# sourceMappingURL=run-as-user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-as-user.d.ts","sourceRoot":"","sources":["../../src/effects/run-as-user.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAa,OAAO,CAAC,OAAO,CA2CpD,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { ConsentStatus } from '@devvit/protos/json/reddit/devvit/app_permission/v1/app_permission.js';
2
+ import { emitEffect } from '@devvit/shared-types/client/emit-effect.js';
3
+ /**
4
+ * This method is used to check if the app has been granted all the requested scopes.
5
+ *
6
+ * @experimental
7
+ * @returns true if the app has been granted all the requested scopes, false otherwise.
8
+ */
9
+ export const canRunAsUser = async () => {
10
+ const appPermissionState = devvit.appPermissionState;
11
+ if (!appPermissionState) {
12
+ // Note: The app permission state will be missing when the app runs on clients that haven't implemented this feature yet.
13
+ // "true" is the correct value for the time being, until we have all clients supporting this feature.
14
+ return true;
15
+ }
16
+ if (appPermissionState.requestedScopes.length === 0) {
17
+ // the app does not have permission to do anything as the user
18
+ return false;
19
+ }
20
+ switch (appPermissionState.consentStatus) {
21
+ case ConsentStatus.REVOKED:
22
+ return false;
23
+ case ConsentStatus.GRANTED:
24
+ // If the app has been granted all the requested scopes, return true
25
+ if (appPermissionState.requestedScopes.every((scope) => appPermissionState.grantedScopes.includes(scope))) {
26
+ return true;
27
+ }
28
+ // Otherwise, the sets of scopes do not overlap we emit the effect to request the scopes; continue
29
+ break;
30
+ case ConsentStatus.CONSENT_STATUS_UNKNOWN:
31
+ case ConsentStatus.UNRECOGNIZED:
32
+ // We don't know the status, so we'll have to ask.
33
+ break;
34
+ default: {
35
+ appPermissionState.consentStatus;
36
+ break;
37
+ }
38
+ }
39
+ const response = await emitEffect({
40
+ type: 11,
41
+ });
42
+ return response?.consentStatus?.consentStatus === ConsentStatus.GRANTED;
43
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-as-user.test.d.ts","sourceRoot":"","sources":["../../src/effects/run-as-user.test.ts"],"names":[],"mappings":""}
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { context } from './clientContext.js';
2
2
  export { addImmersiveModeChangeEventListener, exitImmersiveMode, removeImmersiveModeChangeEventListener, requestImmersiveMode, } from './effects/immersive-mode.js';
3
3
  export { navigateTo } from './effects/navigate-to.js';
4
+ export { canRunAsUser } from './effects/run-as-user.js';
4
5
  export { getShareData, type ShareSheetOpts, showShareSheet } from './effects/share.js';
5
6
  export { showForm } from './effects/show-form.js';
6
7
  export { showToast } from './effects/show-toast.js';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACL,mCAAmC,EACnC,iBAAiB,EACjB,sCAAsC,EACtC,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,YAAY,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACL,mCAAmC,EACnC,iBAAiB,EACjB,sCAAsC,EACtC,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,YAAY,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC"}
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { context } from './clientContext.js';
2
2
  export { addImmersiveModeChangeEventListener, exitImmersiveMode, removeImmersiveModeChangeEventListener, requestImmersiveMode, } from './effects/immersive-mode.js';
3
3
  export { navigateTo } from './effects/navigate-to.js';
4
+ export { canRunAsUser } from './effects/run-as-user.js';
4
5
  export { getShareData, showShareSheet } from './effects/share.js';
5
6
  export { showForm } from './effects/show-form.js';
6
7
  export { showToast } from './effects/show-toast.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/client",
3
- "version": "0.12.1-next-2025-08-25-18-37-07-407f1e009.0",
3
+ "version": "0.12.1-next-2025-08-25-20-31-24-ed3784f8b.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,16 +32,16 @@
32
32
  },
33
33
  "types": "./dist/index.d.ts",
34
34
  "dependencies": {
35
- "@devvit/protos": "0.12.1-next-2025-08-25-18-37-07-407f1e009.0",
36
- "@devvit/reddit": "0.12.1-next-2025-08-25-18-37-07-407f1e009.0",
37
- "@devvit/shared": "0.12.1-next-2025-08-25-18-37-07-407f1e009.0",
38
- "@devvit/shared-types": "0.12.1-next-2025-08-25-18-37-07-407f1e009.0",
39
- "@devvit/web-view-scripts": "0.12.1-next-2025-08-25-18-37-07-407f1e009.0"
35
+ "@devvit/protos": "0.12.1-next-2025-08-25-20-31-24-ed3784f8b.0",
36
+ "@devvit/reddit": "0.12.1-next-2025-08-25-20-31-24-ed3784f8b.0",
37
+ "@devvit/shared": "0.12.1-next-2025-08-25-20-31-24-ed3784f8b.0",
38
+ "@devvit/shared-types": "0.12.1-next-2025-08-25-20-31-24-ed3784f8b.0",
39
+ "@devvit/web-view-scripts": "0.12.1-next-2025-08-25-20-31-24-ed3784f8b.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ampproject/filesize": "4.3.0",
43
- "@devvit/repo-tools": "0.12.1-next-2025-08-25-18-37-07-407f1e009.0",
44
- "@devvit/tsconfig": "0.12.1-next-2025-08-25-18-37-07-407f1e009.0",
43
+ "@devvit/repo-tools": "0.12.1-next-2025-08-25-20-31-24-ed3784f8b.0",
44
+ "@devvit/tsconfig": "0.12.1-next-2025-08-25-20-31-24-ed3784f8b.0",
45
45
  "esbuild": "0.23.0",
46
46
  "eslint": "9.11.1",
47
47
  "typescript": "5.8.3",
@@ -54,5 +54,5 @@
54
54
  }
55
55
  },
56
56
  "source": "./src/index.ts",
57
- "gitHead": "5731a49d76d66e7133bce0878105c7e8ec3af7de"
57
+ "gitHead": "5aaac752a16018976a6e4759d1a37c930fb308ed"
58
58
  }