@akanjs/nest 0.0.97 → 0.0.98
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/index.cjs +21 -0
- package/index.js +1 -21
- package/package.json +2 -2
- package/src/{authGuards.mjs → authGuards.cjs} +56 -15
- package/src/authGuards.js +15 -56
- package/src/authentication.cjs +122 -0
- package/src/authentication.js +27 -67
- package/src/authorization.cjs +79 -0
- package/src/authorization.js +12 -46
- package/src/cacheClient.cjs +45 -0
- package/src/cacheClient.js +5 -26
- package/src/databaseClient.cjs +51 -0
- package/src/databaseClient.js +8 -29
- package/src/{decorators.mjs → decorators.cjs} +33 -6
- package/src/decorators.js +6 -33
- package/src/{exceptions.mjs → exceptions.cjs} +29 -8
- package/src/exceptions.js +8 -29
- package/src/{exporter.mjs → exporter.cjs} +40 -3
- package/src/exporter.js +3 -40
- package/src/{generateSecrets.mjs → generateSecrets.cjs} +43 -13
- package/src/generateSecrets.js +13 -43
- package/src/index.cjs +73 -0
- package/src/index.js +21 -72
- package/src/{interceptors.mjs → interceptors.cjs} +55 -36
- package/src/interceptors.js +36 -55
- package/src/mongoose.cjs +93 -0
- package/src/mongoose.js +11 -44
- package/src/{pipes.mjs → pipes.cjs} +51 -22
- package/src/pipes.js +22 -51
- package/src/redis-io.adapter.cjs +84 -0
- package/src/redis-io.adapter.js +12 -35
- package/src/{searchClient.mjs → searchClient.cjs} +28 -7
- package/src/searchClient.js +7 -28
- package/src/{sso.mjs → sso.cjs} +56 -24
- package/src/sso.js +24 -56
- package/src/verifyPayment.cjs +50 -0
- package/src/verifyPayment.js +4 -37
- package/index.mjs +0 -1
- package/src/authentication.mjs +0 -82
- package/src/authorization.mjs +0 -45
- package/src/cacheClient.mjs +0 -24
- package/src/databaseClient.mjs +0 -30
- package/src/index.mjs +0 -22
- package/src/mongoose.mjs +0 -60
- package/src/redis-io.adapter.mjs +0 -61
- package/src/verifyPayment.mjs +0 -17
package/src/{sso.mjs → sso.cjs}
RENAMED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
3
28
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
29
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
30
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -9,21 +34,27 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
34
|
__defProp(target, key, result);
|
|
10
35
|
return result;
|
|
11
36
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
var sso_exports = {};
|
|
38
|
+
__export(sso_exports, {
|
|
39
|
+
getSsoProviders: () => getSsoProviders,
|
|
40
|
+
verifyAppleUser: () => verifyAppleUser
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(sso_exports);
|
|
43
|
+
var import_common = require("@nestjs/common");
|
|
44
|
+
var import_passport = require("@nestjs/passport");
|
|
45
|
+
var appleSignin = __toESM(require("apple-signin"), 1);
|
|
46
|
+
var jwt = __toESM(require("jsonwebtoken"), 1);
|
|
47
|
+
var import_passport_apple = require("passport-apple");
|
|
48
|
+
var import_passport_facebook = require("passport-facebook");
|
|
49
|
+
var import_passport_github = require("passport-github");
|
|
50
|
+
var import_passport_google_oauth20 = require("passport-google-oauth20");
|
|
51
|
+
var import_passport_kakao = require("passport-kakao");
|
|
52
|
+
var import_passport_naver = require("passport-naver");
|
|
22
53
|
const getSsoProviders = (host, ssoOptions) => {
|
|
23
54
|
const origin = host === "localhost" ? "http://localhost:8080/backend" : `https://${host}/backend`;
|
|
24
55
|
const providers = [];
|
|
25
56
|
if (ssoOptions.kakao) {
|
|
26
|
-
let KakaoOauthStrategy = class extends PassportStrategy(
|
|
57
|
+
let KakaoOauthStrategy = class extends (0, import_passport.PassportStrategy)(import_passport_kakao.Strategy, "kakao") {
|
|
27
58
|
constructor() {
|
|
28
59
|
super({
|
|
29
60
|
...ssoOptions.kakao,
|
|
@@ -40,12 +71,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
40
71
|
}
|
|
41
72
|
};
|
|
42
73
|
KakaoOauthStrategy = __decorateClass([
|
|
43
|
-
Injectable()
|
|
74
|
+
(0, import_common.Injectable)()
|
|
44
75
|
], KakaoOauthStrategy);
|
|
45
76
|
providers.push(KakaoOauthStrategy);
|
|
46
77
|
}
|
|
47
78
|
if (ssoOptions.naver) {
|
|
48
|
-
let NaverOauthStrategy = class extends PassportStrategy(
|
|
79
|
+
let NaverOauthStrategy = class extends (0, import_passport.PassportStrategy)(import_passport_naver.Strategy, "naver") {
|
|
49
80
|
constructor() {
|
|
50
81
|
super({ ...ssoOptions.naver, callbackURL: `${origin}/user/naver/callback` });
|
|
51
82
|
}
|
|
@@ -58,12 +89,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
58
89
|
}
|
|
59
90
|
};
|
|
60
91
|
NaverOauthStrategy = __decorateClass([
|
|
61
|
-
Injectable()
|
|
92
|
+
(0, import_common.Injectable)()
|
|
62
93
|
], NaverOauthStrategy);
|
|
63
94
|
providers.push(NaverOauthStrategy);
|
|
64
95
|
}
|
|
65
96
|
if (ssoOptions.github) {
|
|
66
|
-
let GithubOauthStrategy = class extends PassportStrategy(
|
|
97
|
+
let GithubOauthStrategy = class extends (0, import_passport.PassportStrategy)(import_passport_github.Strategy, "github") {
|
|
67
98
|
constructor() {
|
|
68
99
|
super({ ...ssoOptions.github, callbackURL: `${origin}/user/github/callback`, scope: ["user"] });
|
|
69
100
|
}
|
|
@@ -72,12 +103,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
72
103
|
}
|
|
73
104
|
};
|
|
74
105
|
GithubOauthStrategy = __decorateClass([
|
|
75
|
-
Injectable()
|
|
106
|
+
(0, import_common.Injectable)()
|
|
76
107
|
], GithubOauthStrategy);
|
|
77
108
|
providers.push(GithubOauthStrategy);
|
|
78
109
|
}
|
|
79
110
|
if (ssoOptions.google) {
|
|
80
|
-
let GoogleOauthStrategy = class extends PassportStrategy(
|
|
111
|
+
let GoogleOauthStrategy = class extends (0, import_passport.PassportStrategy)(import_passport_google_oauth20.Strategy, "google") {
|
|
81
112
|
constructor() {
|
|
82
113
|
super({ ...ssoOptions.google, callbackURL: `${origin}/user/google/callback`, scope: ["email", "profile"] });
|
|
83
114
|
}
|
|
@@ -86,12 +117,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
86
117
|
}
|
|
87
118
|
};
|
|
88
119
|
GoogleOauthStrategy = __decorateClass([
|
|
89
|
-
Injectable()
|
|
120
|
+
(0, import_common.Injectable)()
|
|
90
121
|
], GoogleOauthStrategy);
|
|
91
122
|
providers.push(GoogleOauthStrategy);
|
|
92
123
|
}
|
|
93
124
|
if (ssoOptions.facebook) {
|
|
94
|
-
let FacebookOauthStrategy = class extends PassportStrategy(
|
|
125
|
+
let FacebookOauthStrategy = class extends (0, import_passport.PassportStrategy)(import_passport_facebook.Strategy, "facebook") {
|
|
95
126
|
constructor() {
|
|
96
127
|
super({
|
|
97
128
|
...ssoOptions.facebook,
|
|
@@ -105,12 +136,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
105
136
|
}
|
|
106
137
|
};
|
|
107
138
|
FacebookOauthStrategy = __decorateClass([
|
|
108
|
-
Injectable()
|
|
139
|
+
(0, import_common.Injectable)()
|
|
109
140
|
], FacebookOauthStrategy);
|
|
110
141
|
providers.push(FacebookOauthStrategy);
|
|
111
142
|
}
|
|
112
143
|
if (ssoOptions.apple) {
|
|
113
|
-
let AppleOauthStrategy = class extends PassportStrategy(
|
|
144
|
+
let AppleOauthStrategy = class extends (0, import_passport.PassportStrategy)(import_passport_apple.Strategy, "apple") {
|
|
114
145
|
constructor() {
|
|
115
146
|
super({
|
|
116
147
|
...ssoOptions.apple,
|
|
@@ -124,7 +155,7 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
124
155
|
}
|
|
125
156
|
};
|
|
126
157
|
AppleOauthStrategy = __decorateClass([
|
|
127
|
-
Injectable()
|
|
158
|
+
(0, import_common.Injectable)()
|
|
128
159
|
], AppleOauthStrategy);
|
|
129
160
|
providers.push(AppleOauthStrategy);
|
|
130
161
|
}
|
|
@@ -149,7 +180,8 @@ const verifyAppleUser = async (payload, origin, sso) => {
|
|
|
149
180
|
const data = jwt.decode(tokens.id_token);
|
|
150
181
|
return { tokens, data };
|
|
151
182
|
};
|
|
152
|
-
export
|
|
183
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
184
|
+
0 && (module.exports = {
|
|
153
185
|
getSsoProviders,
|
|
154
186
|
verifyAppleUser
|
|
155
|
-
};
|
|
187
|
+
});
|
package/src/sso.js
CHANGED
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
3
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
29
4
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
30
5
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -34,27 +9,21 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
34
9
|
__defProp(target, key, result);
|
|
35
10
|
return result;
|
|
36
11
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var import_passport_apple = require("passport-apple");
|
|
48
|
-
var import_passport_facebook = require("passport-facebook");
|
|
49
|
-
var import_passport_github = require("passport-github");
|
|
50
|
-
var import_passport_google_oauth20 = require("passport-google-oauth20");
|
|
51
|
-
var import_passport_kakao = require("passport-kakao");
|
|
52
|
-
var import_passport_naver = require("passport-naver");
|
|
12
|
+
import { Injectable } from "@nestjs/common";
|
|
13
|
+
import { PassportStrategy } from "@nestjs/passport";
|
|
14
|
+
import * as appleSignin from "apple-signin";
|
|
15
|
+
import * as jwt from "jsonwebtoken";
|
|
16
|
+
import { Strategy as AppleStrategy } from "passport-apple";
|
|
17
|
+
import { Strategy as FacebookStrategy } from "passport-facebook";
|
|
18
|
+
import { Strategy as GithubStrategy } from "passport-github";
|
|
19
|
+
import { Strategy as GoogleStrategy } from "passport-google-oauth20";
|
|
20
|
+
import { Strategy as KakaoStrategy } from "passport-kakao";
|
|
21
|
+
import { Strategy as NaverStrategy } from "passport-naver";
|
|
53
22
|
const getSsoProviders = (host, ssoOptions) => {
|
|
54
23
|
const origin = host === "localhost" ? "http://localhost:8080/backend" : `https://${host}/backend`;
|
|
55
24
|
const providers = [];
|
|
56
25
|
if (ssoOptions.kakao) {
|
|
57
|
-
let KakaoOauthStrategy = class extends
|
|
26
|
+
let KakaoOauthStrategy = class extends PassportStrategy(KakaoStrategy, "kakao") {
|
|
58
27
|
constructor() {
|
|
59
28
|
super({
|
|
60
29
|
...ssoOptions.kakao,
|
|
@@ -71,12 +40,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
71
40
|
}
|
|
72
41
|
};
|
|
73
42
|
KakaoOauthStrategy = __decorateClass([
|
|
74
|
-
|
|
43
|
+
Injectable()
|
|
75
44
|
], KakaoOauthStrategy);
|
|
76
45
|
providers.push(KakaoOauthStrategy);
|
|
77
46
|
}
|
|
78
47
|
if (ssoOptions.naver) {
|
|
79
|
-
let NaverOauthStrategy = class extends
|
|
48
|
+
let NaverOauthStrategy = class extends PassportStrategy(NaverStrategy, "naver") {
|
|
80
49
|
constructor() {
|
|
81
50
|
super({ ...ssoOptions.naver, callbackURL: `${origin}/user/naver/callback` });
|
|
82
51
|
}
|
|
@@ -89,12 +58,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
89
58
|
}
|
|
90
59
|
};
|
|
91
60
|
NaverOauthStrategy = __decorateClass([
|
|
92
|
-
|
|
61
|
+
Injectable()
|
|
93
62
|
], NaverOauthStrategy);
|
|
94
63
|
providers.push(NaverOauthStrategy);
|
|
95
64
|
}
|
|
96
65
|
if (ssoOptions.github) {
|
|
97
|
-
let GithubOauthStrategy = class extends
|
|
66
|
+
let GithubOauthStrategy = class extends PassportStrategy(GithubStrategy, "github") {
|
|
98
67
|
constructor() {
|
|
99
68
|
super({ ...ssoOptions.github, callbackURL: `${origin}/user/github/callback`, scope: ["user"] });
|
|
100
69
|
}
|
|
@@ -103,12 +72,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
103
72
|
}
|
|
104
73
|
};
|
|
105
74
|
GithubOauthStrategy = __decorateClass([
|
|
106
|
-
|
|
75
|
+
Injectable()
|
|
107
76
|
], GithubOauthStrategy);
|
|
108
77
|
providers.push(GithubOauthStrategy);
|
|
109
78
|
}
|
|
110
79
|
if (ssoOptions.google) {
|
|
111
|
-
let GoogleOauthStrategy = class extends
|
|
80
|
+
let GoogleOauthStrategy = class extends PassportStrategy(GoogleStrategy, "google") {
|
|
112
81
|
constructor() {
|
|
113
82
|
super({ ...ssoOptions.google, callbackURL: `${origin}/user/google/callback`, scope: ["email", "profile"] });
|
|
114
83
|
}
|
|
@@ -117,12 +86,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
117
86
|
}
|
|
118
87
|
};
|
|
119
88
|
GoogleOauthStrategy = __decorateClass([
|
|
120
|
-
|
|
89
|
+
Injectable()
|
|
121
90
|
], GoogleOauthStrategy);
|
|
122
91
|
providers.push(GoogleOauthStrategy);
|
|
123
92
|
}
|
|
124
93
|
if (ssoOptions.facebook) {
|
|
125
|
-
let FacebookOauthStrategy = class extends
|
|
94
|
+
let FacebookOauthStrategy = class extends PassportStrategy(FacebookStrategy, "facebook") {
|
|
126
95
|
constructor() {
|
|
127
96
|
super({
|
|
128
97
|
...ssoOptions.facebook,
|
|
@@ -136,12 +105,12 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
136
105
|
}
|
|
137
106
|
};
|
|
138
107
|
FacebookOauthStrategy = __decorateClass([
|
|
139
|
-
|
|
108
|
+
Injectable()
|
|
140
109
|
], FacebookOauthStrategy);
|
|
141
110
|
providers.push(FacebookOauthStrategy);
|
|
142
111
|
}
|
|
143
112
|
if (ssoOptions.apple) {
|
|
144
|
-
let AppleOauthStrategy = class extends
|
|
113
|
+
let AppleOauthStrategy = class extends PassportStrategy(AppleStrategy, "apple") {
|
|
145
114
|
constructor() {
|
|
146
115
|
super({
|
|
147
116
|
...ssoOptions.apple,
|
|
@@ -155,7 +124,7 @@ const getSsoProviders = (host, ssoOptions) => {
|
|
|
155
124
|
}
|
|
156
125
|
};
|
|
157
126
|
AppleOauthStrategy = __decorateClass([
|
|
158
|
-
|
|
127
|
+
Injectable()
|
|
159
128
|
], AppleOauthStrategy);
|
|
160
129
|
providers.push(AppleOauthStrategy);
|
|
161
130
|
}
|
|
@@ -180,8 +149,7 @@ const verifyAppleUser = async (payload, origin, sso) => {
|
|
|
180
149
|
const data = jwt.decode(tokens.id_token);
|
|
181
150
|
return { tokens, data };
|
|
182
151
|
};
|
|
183
|
-
|
|
184
|
-
0 && (module.exports = {
|
|
152
|
+
export {
|
|
185
153
|
getSsoProviders,
|
|
186
154
|
verifyAppleUser
|
|
187
|
-
}
|
|
155
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var verifyPayment_exports = {};
|
|
29
|
+
__export(verifyPayment_exports, {
|
|
30
|
+
verifyPayment: () => verifyPayment
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(verifyPayment_exports);
|
|
33
|
+
var import_iap = __toESM(require("iap"), 1);
|
|
34
|
+
const verifyPayment = async (payment) => {
|
|
35
|
+
return new Promise(
|
|
36
|
+
(resolve, reject) => (
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
38
|
+
import_iap.default.verifyPayment(payment.platform, { ...payment }, (error, response) => {
|
|
39
|
+
if (error)
|
|
40
|
+
reject(`App Purchase Verify Failed. ${response}`);
|
|
41
|
+
else
|
|
42
|
+
resolve(response);
|
|
43
|
+
})
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
verifyPayment
|
|
50
|
+
});
|
package/src/verifyPayment.js
CHANGED
|
@@ -1,41 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var verifyPayment_exports = {};
|
|
29
|
-
__export(verifyPayment_exports, {
|
|
30
|
-
verifyPayment: () => verifyPayment
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(verifyPayment_exports);
|
|
33
|
-
var import_iap = __toESM(require("iap"));
|
|
1
|
+
import iap from "iap";
|
|
34
2
|
const verifyPayment = async (payment) => {
|
|
35
3
|
return new Promise(
|
|
36
4
|
(resolve, reject) => (
|
|
37
5
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
38
|
-
|
|
6
|
+
iap.verifyPayment(payment.platform, { ...payment }, (error, response) => {
|
|
39
7
|
if (error)
|
|
40
8
|
reject(`App Purchase Verify Failed. ${response}`);
|
|
41
9
|
else
|
|
@@ -44,7 +12,6 @@ const verifyPayment = async (payment) => {
|
|
|
44
12
|
)
|
|
45
13
|
);
|
|
46
14
|
};
|
|
47
|
-
|
|
48
|
-
0 && (module.exports = {
|
|
15
|
+
export {
|
|
49
16
|
verifyPayment
|
|
50
|
-
}
|
|
17
|
+
};
|
package/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src";
|
package/src/authentication.mjs
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { dayjs } from "@akanjs/base";
|
|
2
|
-
import { createParamDecorator, UnauthorizedException } from "@nestjs/common";
|
|
3
|
-
import UAParser from "ua-parser-js";
|
|
4
|
-
import { getRequest, getResponse } from "./authGuards";
|
|
5
|
-
const Account = createParamDecorator((option, context) => {
|
|
6
|
-
const { account } = getRequest(context);
|
|
7
|
-
return account;
|
|
8
|
-
});
|
|
9
|
-
const Self = createParamDecorator((option, context) => {
|
|
10
|
-
const { account } = getRequest(context);
|
|
11
|
-
const self = account.self;
|
|
12
|
-
if (!self && !option.nullable)
|
|
13
|
-
throw new UnauthorizedException("No or Invalid Account in Self (User)");
|
|
14
|
-
return self;
|
|
15
|
-
});
|
|
16
|
-
const Me = createParamDecorator((option, context) => {
|
|
17
|
-
const { account } = getRequest(context);
|
|
18
|
-
const me = account.me;
|
|
19
|
-
if (!me && !option.nullable)
|
|
20
|
-
throw new UnauthorizedException("No or Invalid Account in Me (Admin)");
|
|
21
|
-
return me;
|
|
22
|
-
});
|
|
23
|
-
const UserIp = createParamDecorator((option, context) => {
|
|
24
|
-
const req = getRequest(context);
|
|
25
|
-
const ip = req.ip;
|
|
26
|
-
if (!ip && !option.nullable)
|
|
27
|
-
throw new UnauthorizedException("Invalid IP");
|
|
28
|
-
return { ip };
|
|
29
|
-
});
|
|
30
|
-
const Access = createParamDecorator((option, context) => {
|
|
31
|
-
const req = getRequest(context);
|
|
32
|
-
const res = new UAParser(req.userAgent).getResult();
|
|
33
|
-
if (!req.userAgent && !option.nullable)
|
|
34
|
-
throw new UnauthorizedException("Invalid UserAgent");
|
|
35
|
-
return {
|
|
36
|
-
...req.geolocation ? JSON.parse(req.geolocation) : {},
|
|
37
|
-
osName: res.os.name,
|
|
38
|
-
osVersion: res.os.version,
|
|
39
|
-
browserName: res.browser.name,
|
|
40
|
-
browserVersion: res.browser.version,
|
|
41
|
-
mobileModel: res.device.model,
|
|
42
|
-
mobileVendor: res.device.vendor,
|
|
43
|
-
deviceType: res.device.type ?? "desktop",
|
|
44
|
-
at: dayjs(),
|
|
45
|
-
period: 0
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
const Req = createParamDecorator((option, context) => {
|
|
49
|
-
return getRequest(context);
|
|
50
|
-
});
|
|
51
|
-
const Res = createParamDecorator((option, context) => {
|
|
52
|
-
return getResponse(context);
|
|
53
|
-
});
|
|
54
|
-
const Ws = createParamDecorator((option, context) => {
|
|
55
|
-
const socket = context.getArgByIndex(0);
|
|
56
|
-
const { __subscribe__ } = context.getArgByIndex(1);
|
|
57
|
-
return {
|
|
58
|
-
socket,
|
|
59
|
-
subscribe: __subscribe__,
|
|
60
|
-
onDisconnect: (handler) => {
|
|
61
|
-
socket.on("disconnect", handler);
|
|
62
|
-
},
|
|
63
|
-
onSubscribe: (handler) => {
|
|
64
|
-
if (__subscribe__)
|
|
65
|
-
handler();
|
|
66
|
-
},
|
|
67
|
-
onUnsubscribe: (handler) => {
|
|
68
|
-
if (!__subscribe__)
|
|
69
|
-
handler();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
export {
|
|
74
|
-
Access,
|
|
75
|
-
Account,
|
|
76
|
-
Me,
|
|
77
|
-
Req,
|
|
78
|
-
Res,
|
|
79
|
-
Self,
|
|
80
|
-
UserIp,
|
|
81
|
-
Ws
|
|
82
|
-
};
|
package/src/authorization.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { baseEnv } from "@akanjs/base";
|
|
2
|
-
import { defaultAccount } from "@akanjs/signal";
|
|
3
|
-
import { AuthenticationError } from "@nestjs/apollo";
|
|
4
|
-
import * as jwt from "jsonwebtoken";
|
|
5
|
-
const verifyToken = (secret, authorization) => {
|
|
6
|
-
const [type, token] = authorization?.split(" ") ?? [void 0, void 0];
|
|
7
|
-
if (!token || type !== "Bearer")
|
|
8
|
-
return defaultAccount;
|
|
9
|
-
try {
|
|
10
|
-
const account = jwt.verify(token, secret);
|
|
11
|
-
if (account.appName !== baseEnv.appName || account.environment !== baseEnv.environment)
|
|
12
|
-
return defaultAccount;
|
|
13
|
-
return {
|
|
14
|
-
__InternalArg__: "Account",
|
|
15
|
-
self: account.self && !account.self.removedAt ? account.self : void 0,
|
|
16
|
-
me: account.me && !account.me.removedAt ? account.me : void 0,
|
|
17
|
-
appName: account.appName,
|
|
18
|
-
environment: account.environment
|
|
19
|
-
};
|
|
20
|
-
} catch (e) {
|
|
21
|
-
return defaultAccount;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const allow = (account, roles, userId) => {
|
|
25
|
-
if (!account)
|
|
26
|
-
throw new AuthenticationError("No Authentication Account");
|
|
27
|
-
for (const role of roles) {
|
|
28
|
-
if (role === "user" && account.self?.roles.includes("user"))
|
|
29
|
-
return true;
|
|
30
|
-
else if (role === "admin" && account.me?.roles.includes("admin"))
|
|
31
|
-
return true;
|
|
32
|
-
else if (role === "superAdmin" && account.me?.roles.includes("superAdmin"))
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
throw new AuthenticationError(
|
|
36
|
-
`No Authentication With Roles: ${roles.join(", ")}, Your roles are ${[
|
|
37
|
-
...account.self?.roles ?? [],
|
|
38
|
-
...account.me?.roles ?? []
|
|
39
|
-
].join(", ")}${!account.self?.roles.length && !account.me?.roles.length ? " (No Roles)" : ""}`
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
export {
|
|
43
|
-
allow,
|
|
44
|
-
verifyToken
|
|
45
|
-
};
|
package/src/cacheClient.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
13
|
-
let CacheClient = class {
|
|
14
|
-
redis;
|
|
15
|
-
};
|
|
16
|
-
__decorateClass([
|
|
17
|
-
Inject("REDIS_CLIENT")
|
|
18
|
-
], CacheClient.prototype, "redis", 2);
|
|
19
|
-
CacheClient = __decorateClass([
|
|
20
|
-
Injectable()
|
|
21
|
-
], CacheClient);
|
|
22
|
-
export {
|
|
23
|
-
CacheClient
|
|
24
|
-
};
|
package/src/databaseClient.mjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import { capitalize } from "@akanjs/common";
|
|
13
|
-
import { Injectable } from "@nestjs/common";
|
|
14
|
-
import { InjectConnection } from "@nestjs/mongoose";
|
|
15
|
-
let DatabaseClient = class {
|
|
16
|
-
connection;
|
|
17
|
-
getModel(modelName) {
|
|
18
|
-
const model = this.connection.models[capitalize(modelName)];
|
|
19
|
-
return model;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
__decorateClass([
|
|
23
|
-
InjectConnection()
|
|
24
|
-
], DatabaseClient.prototype, "connection", 2);
|
|
25
|
-
DatabaseClient = __decorateClass([
|
|
26
|
-
Injectable()
|
|
27
|
-
], DatabaseClient);
|
|
28
|
-
export {
|
|
29
|
-
DatabaseClient
|
|
30
|
-
};
|
package/src/index.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export * from "./authorization";
|
|
2
|
-
export * from "./authGuards";
|
|
3
|
-
import * as guards from "./authGuards";
|
|
4
|
-
export * from "./authentication";
|
|
5
|
-
export * from "./interceptors";
|
|
6
|
-
export * from "./redis-io.adapter";
|
|
7
|
-
export * from "./pipes";
|
|
8
|
-
import * as Exporter from "./exporter";
|
|
9
|
-
export * from "./exporter";
|
|
10
|
-
export * from "./verifyPayment";
|
|
11
|
-
export * from "./sso";
|
|
12
|
-
export * from "./exceptions";
|
|
13
|
-
export * from "./generateSecrets";
|
|
14
|
-
export * from "./mongoose";
|
|
15
|
-
export * from "./searchClient";
|
|
16
|
-
export * from "./cacheClient";
|
|
17
|
-
export * from "./databaseClient";
|
|
18
|
-
export * from "./decorators";
|
|
19
|
-
export {
|
|
20
|
-
Exporter,
|
|
21
|
-
guards
|
|
22
|
-
};
|