@cedarjs/auth-supertokens-web 5.0.4-next.167 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +28 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/supertokens.d.ts +26 -0
- package/dist/cjs/supertokens.d.ts.map +1 -0
- package/dist/cjs/supertokens.js +63 -0
- package/package.json +18 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
createAuth: () => import_supertokens.createAuth
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(index_exports);
|
|
24
|
+
var import_supertokens = require("./supertokens.js");
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
createAuth
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type SuperTokens from 'supertokens-auth-react';
|
|
2
|
+
import type { CurrentUser } from '@cedarjs/auth';
|
|
3
|
+
export interface SuperTokensUser {
|
|
4
|
+
userId: string;
|
|
5
|
+
accessTokenPayload: any;
|
|
6
|
+
}
|
|
7
|
+
export type SessionRecipe = {
|
|
8
|
+
signOut: () => Promise<void>;
|
|
9
|
+
doesSessionExist: () => Promise<boolean>;
|
|
10
|
+
getAccessTokenPayloadSecurely: () => Promise<any>;
|
|
11
|
+
getAccessToken: () => Promise<any>;
|
|
12
|
+
getUserId: () => Promise<string>;
|
|
13
|
+
};
|
|
14
|
+
export declare function createAuth(superTokens: SuperTokensAuth, customProviderHooks?: {
|
|
15
|
+
useCurrentUser?: () => Promise<CurrentUser>;
|
|
16
|
+
useHasRole?: (currentUser: CurrentUser | null) => (rolesToCheck: string | string[]) => boolean;
|
|
17
|
+
}): {
|
|
18
|
+
AuthContext: import("react").Context<import("@cedarjs/auth").AuthContextInterface<SuperTokensUser, unknown, void, unknown, void, unknown, void, unknown, unknown, unknown, unknown, unknown> | undefined>;
|
|
19
|
+
AuthProvider: ({ children }: import("@cedarjs/auth").AuthProviderProps) => import("react").JSX.Element;
|
|
20
|
+
useAuth: () => import("@cedarjs/auth").AuthContextInterface<SuperTokensUser, unknown, void, unknown, void, unknown, void, unknown, unknown, unknown, unknown, unknown>;
|
|
21
|
+
};
|
|
22
|
+
export interface SuperTokensAuth {
|
|
23
|
+
sessionRecipe: SessionRecipe;
|
|
24
|
+
redirectToAuth: (typeof SuperTokens)['redirectToAuth'];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=supertokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supertokens.d.ts","sourceRoot":"","sources":["../../src/supertokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGhD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,EAAE,GAAG,CAAA;CACxB;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACxC,6BAA6B,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;IACjD,cAAc,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;CACjC,CAAA;AAED,wBAAgB,UAAU,CACxB,WAAW,EAAE,eAAe,EAC5B,mBAAmB,CAAC,EAAE;IACpB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,UAAU,CAAC,EAAE,CACX,WAAW,EAAE,WAAW,GAAG,IAAI,KAC5B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAA;CAClD;;;;EAKF;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,aAAa,CAAA;IAC5B,cAAc,EAAE,CAAC,OAAO,WAAW,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACvD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var supertokens_exports = {};
|
|
20
|
+
__export(supertokens_exports, {
|
|
21
|
+
createAuth: () => createAuth
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(supertokens_exports);
|
|
24
|
+
var import_auth = require("@cedarjs/auth");
|
|
25
|
+
function createAuth(superTokens, customProviderHooks) {
|
|
26
|
+
const authImplementation = createAuthImplementation(superTokens);
|
|
27
|
+
return (0, import_auth.createAuthentication)(authImplementation, customProviderHooks);
|
|
28
|
+
}
|
|
29
|
+
function createAuthImplementation(superTokens) {
|
|
30
|
+
return {
|
|
31
|
+
type: "supertokens",
|
|
32
|
+
login: () => {
|
|
33
|
+
return superTokens.redirectToAuth({ show: "signin", redirectBack: true });
|
|
34
|
+
},
|
|
35
|
+
signup: () => {
|
|
36
|
+
return superTokens.redirectToAuth({ show: "signup", redirectBack: true });
|
|
37
|
+
},
|
|
38
|
+
logout: () => {
|
|
39
|
+
return superTokens.sessionRecipe.signOut();
|
|
40
|
+
},
|
|
41
|
+
getToken: async () => {
|
|
42
|
+
if (await superTokens.sessionRecipe.doesSessionExist()) {
|
|
43
|
+
return superTokens.sessionRecipe.getAccessToken();
|
|
44
|
+
} else {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
getUserMetadata: async () => {
|
|
49
|
+
if (await superTokens.sessionRecipe.doesSessionExist()) {
|
|
50
|
+
return {
|
|
51
|
+
userId: await superTokens.sessionRecipe.getUserId(),
|
|
52
|
+
accessTokenPayload: await superTokens.sessionRecipe.getAccessTokenPayloadSecurely()
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
createAuth
|
|
63
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/auth-supertokens-web",
|
|
3
|
-
"version": "5.0.4
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -10,19 +10,28 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
13
|
+
"import": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"default": {
|
|
18
|
+
"types": "./dist/cjs/index.d.ts",
|
|
19
|
+
"default": "./dist/cjs/index.js"
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"./dist/supertokens": {
|
|
19
|
-
"
|
|
23
|
+
"import": {
|
|
20
24
|
"types": "./dist/supertokens.d.ts",
|
|
21
25
|
"default": "./dist/supertokens.js"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"types": "./dist/cjs/supertokens.d.ts",
|
|
29
|
+
"default": "./dist/cjs/supertokens.js"
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
},
|
|
25
|
-
"main": "./dist/index.js",
|
|
33
|
+
"main": "./dist/cjs/index.js",
|
|
34
|
+
"module": "./dist/index.js",
|
|
26
35
|
"types": "./dist/index.d.ts",
|
|
27
36
|
"files": [
|
|
28
37
|
"dist"
|
|
@@ -31,6 +40,7 @@
|
|
|
31
40
|
"build": "node ./build.ts",
|
|
32
41
|
"build:pack": "yarn pack -o cedarjs-auth-supertokens-web.tgz",
|
|
33
42
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
43
|
+
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
34
44
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
|
|
35
45
|
"check:attw": "yarn cedar-fwtools-attw",
|
|
36
46
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
@@ -39,17 +49,17 @@
|
|
|
39
49
|
"test:watch": "vitest watch"
|
|
40
50
|
},
|
|
41
51
|
"dependencies": {
|
|
42
|
-
"@cedarjs/auth": "5.0.4
|
|
52
|
+
"@cedarjs/auth": "5.0.4"
|
|
43
53
|
},
|
|
44
54
|
"devDependencies": {
|
|
45
|
-
"@cedarjs/framework-tools": "5.0.4
|
|
55
|
+
"@cedarjs/framework-tools": "5.0.4",
|
|
46
56
|
"@types/react": "^18.2.55",
|
|
47
57
|
"concurrently": "9.2.4",
|
|
48
|
-
"publint": "0.3.
|
|
58
|
+
"publint": "0.3.21",
|
|
49
59
|
"react": "18.3.1",
|
|
50
60
|
"supertokens-auth-react": "0.51.2",
|
|
51
61
|
"typescript": "5.9.3",
|
|
52
|
-
"vitest": "
|
|
62
|
+
"vitest": "3.2.6"
|
|
53
63
|
},
|
|
54
64
|
"peerDependencies": {
|
|
55
65
|
"supertokens-auth-react": "0.51.2"
|